aboutsummaryrefslogtreecommitdiff
path: root/src/sqliteInt.h
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2015-11-05 22:30:54 +0000
committerdrh <drh@noemail.net>2015-11-05 22:30:54 +0000
commitb1d607de25eae569ccdf6b56f5b648124bc4def3 (patch)
tree19f0c147aa99219075c4b1b8977b46fba0a7aa98 /src/sqliteInt.h
parent70528d7868e67752833c6bac7b34f4d5d652d130 (diff)
downloadsqlite-b1d607de25eae569ccdf6b56f5b648124bc4def3.tar.gz
sqlite-b1d607de25eae569ccdf6b56f5b648124bc4def3.zip
Improvements and simplifications to the equality seek logic. Tests are
adjusted so that they all pass now. FossilOrigin-Name: 997ce6c90b454c03cc2ef6934752ee8dd2e520e3
Diffstat (limited to 'src/sqliteInt.h')
-rw-r--r--src/sqliteInt.h34
1 files changed, 26 insertions, 8 deletions
diff --git a/src/sqliteInt.h b/src/sqliteInt.h
index b86de1b2b..2b9ece78e 100644
--- a/src/sqliteInt.h
+++ b/src/sqliteInt.h
@@ -1812,9 +1812,8 @@ struct KeyInfo {
};
/*
-** An instance of the following structure holds information about a
-** single index record that has already been parsed out into individual
-** values.
+** This object holds a record which has been parsed out into individual
+** fields, for the purposes of doing a comparison.
**
** A record is an object that contains one or more fields of data.
** Records are used to store the content of a table row and to store
@@ -1822,11 +1821,30 @@ struct KeyInfo {
** the OP_MakeRecord opcode of the VDBE and is disassembled by the
** OP_Column opcode.
**
-** This structure holds a record that has already been disassembled
-** into its constituent fields.
-**
-** The r1 and r2 member variables are only used by the optimized comparison
-** functions vdbeRecordCompareInt() and vdbeRecordCompareString().
+** An instance of this object serves as a "key" for doing a search on
+** an index b+tree. The goal of the search is to find the entry that
+** is closed to the key described by this object. This object might hold
+** just a prefix of the key. The number of fields is given by
+** pKeyInfo->nField.
+**
+** The r1 and r2 fields are the values to return if this key is less than
+** or greater than a key in the btree, respectively. These are normally
+** -1 and +1 respectively, but might be inverted to +1 and -1 if the b-tree
+** is in DESC order.
+**
+** The key comparison functions actually return default_rc when they find
+** an equals comparison. default_rc can be -1, 0, or +1. If there are
+** multiple entries in the b-tree with the same key (when only looking
+** at the first pKeyInfo->nFields,) then default_rc can be set to -1 to
+** cause the search to find the last match, or +1 to cause the search to
+** find the first match.
+**
+** The key comparison functions will set eqSeen to true if they ever
+** get and equal results when comparing this structure to a b-tree record.
+** When default_rc!=0, the search might end up on the record immediately
+** before the first match or immediately after the last match. The
+** eqSeen field will indicate whether or not an exact match exists in the
+** b-tree.
*/
struct UnpackedRecord {
KeyInfo *pKeyInfo; /* Collation and sort-order information */