add unit test for find_secondary
host functions
#1024
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which key should the
find_secondary
host function return when there are duplicate keys? cdt avoids this question entirely by never using these host functions and instead always doing alowerbound
(it's possible thefind_secondary
host function has never once been used on EOS! Unless a rare contract built with something other then cdt used it of course)The host function ultimately performs a "partial key lookup" on the table (this then goes through to chainbase's
find()
)spring/libraries/chain/include/eosio/chain/apply_context.hpp
Lines 291 to 297 in f871bf2
In leap 3.1+ & spring, the underlying data structure (boost intrusive avltree) does specify that
find()
is treated likelowerbound()
. And even looking through the code makes it clear thatfind()
simply callslowerbound()
.EOSIO 2.0 and earlier it is not so clear: the documentation for the data structure in use (boost multindex directly) simply says it finds "a" matching key. But eyeballing the code suggests it does effectively behave like lowerbound. And empirically the test code still passes on 2.0.
This test confirms that the
find_secondary
host functions behave like lowerbound: lowest primary key is returned.Closes #1019