cruppstahl / upscaledb

A very fast lightweight embedded database engine with a built-in query language.
https://upscaledb.com
Apache License 2.0
570 stars 71 forks source link

cursor returns wrong record when moving back and forth w/ approx. matching #41

Closed cruppstahl closed 10 years ago

cruppstahl commented 10 years ago

Example: The time series is created sequentially by inserting (1,1) (2,2) (3,3) ...

Key, Value 1,1 2,2 3,3 4,4 5,5 6,6

The read cursor is put at the end via cursor.move_last() to be at the end of the series shortly after a new entry is inserted. So the read cursor is at the end while a new entry is put "behind" the end. This seems to be a critical action, because if this is not this constellation the following does not happen!

Read cursor is at position 5. Write cursor puts in (6,6). Read cursor is positioned via cursor.move_last(). Now the read cursor is put again at position 6 (ok) Now the read cursor is asked to find(key,record,HAM_FIND_LT_MATCH) with key = 6. The result is key=5 and record=5 (ok) Now repeat the step backward in time: find(key,record,HAM_FIND_LT_MATCH) with key=5. The result is key=4 and record = 4 (ok) Now ask for the step forward in time: find(key,record,HAM_FIND_GT_MATCH) with key=4. The result is key=4 and record=6 (?????)

All this is NOT happening, if the last entry is put at the end and the read cursor is not at the last position.

cruppstahl commented 10 years ago

Fixed in 4a4f6ced7f2a85b95a2a69eaef2e6403919292bb