/ Check-in [a7a15547]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Change two automatic array variables into static constant arrays. Update and reformat some comments for cleaner presentation.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: a7a15547cccb4aeb719aba19641f31390c316d8c
User & Date: drh 2010-08-06 02:10:00
Context
2010-08-06
13:50
Do not run some tests in notify3.test with the inmemory_journal permutation. They do not pass as the tests assume that the database schema is not loaded until the first invocation of [db eval]. This is not true with the inmemory_journal permutation. check-in: 698fba82 user: dan tags: trunk
02:10
Change two automatic array variables into static constant arrays. Update and reformat some comments for cleaner presentation. check-in: a7a15547 user: drh tags: trunk
2010-08-05
11:56
Make the size of a Bitvec object 512 bytes on all platforms, instead of having the size depend on the size of a pointer. This makes testing easier. check-in: ca479f3d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/sqliteInt.h.

  1352   1352   ** argument to sqlite3VdbeKeyCompare and is used to control the 
  1353   1353   ** comparison of the two index keys.
  1354   1354   */
  1355   1355   struct KeyInfo {
  1356   1356     sqlite3 *db;        /* The database connection */
  1357   1357     u8 enc;             /* Text encoding - one of the TEXT_Utf* values */
  1358   1358     u16 nField;         /* Number of entries in aColl[] */
  1359         -  u8 *aSortOrder;     /* If defined an aSortOrder[i] is true, sort DESC */
         1359  +  u8 *aSortOrder;     /* Sort order for each column.  May be NULL */
  1360   1360     CollSeq *aColl[1];  /* Collating sequence for each term of the key */
  1361   1361   };
  1362   1362   
  1363   1363   /*
  1364   1364   ** An instance of the following structure holds information about a
  1365   1365   ** single index record that has already been parsed out into individual
  1366   1366   ** values.

Changes to src/vdbe.c.

  4345   4345   ** then jump to P2.  Otherwise fall through to the next instruction.
  4346   4346   **
  4347   4347   ** If P5 is non-zero then the key value is increased by an epsilon 
  4348   4348   ** prior to the comparison.  This make the opcode work like IdxGT except
  4349   4349   ** that if the key from register P3 is a prefix of the key in the cursor,
  4350   4350   ** the result is false whereas it would be true with IdxGT.
  4351   4351   */
  4352         -/* Opcode: IdxLT P1 P2 P3 * P5
         4352  +/* Opcode: IdxLT P1 P2 P3 P4 P5
  4353   4353   **
  4354   4354   ** The P4 register values beginning with P3 form an unpacked index 
  4355   4355   ** key that omits the ROWID.  Compare this key value against the index 
  4356   4356   ** that P1 is currently pointing to, ignoring the ROWID on the P1 index.
  4357   4357   **
  4358   4358   ** If the P1 index entry is less than the key value then jump to P2.
  4359   4359   ** Otherwise fall through to the next instruction.

Changes to src/where.c.

  3361   3361       **         If there are no inequality constraints, then N is at
  3362   3362       **         least one.
  3363   3363       **
  3364   3364       **         This case is also used when there are no WHERE clause
  3365   3365       **         constraints but an index is selected anyway, in order
  3366   3366       **         to force the output order to conform to an ORDER BY.
  3367   3367       */  
  3368         -    int aStartOp[] = {
         3368  +    static const u8 aStartOp[] = {
  3369   3369         0,
  3370   3370         0,
  3371   3371         OP_Rewind,           /* 2: (!start_constraints && startEq &&  !bRev) */
  3372   3372         OP_Last,             /* 3: (!start_constraints && startEq &&   bRev) */
  3373   3373         OP_SeekGt,           /* 4: (start_constraints  && !startEq && !bRev) */
  3374   3374         OP_SeekLt,           /* 5: (start_constraints  && !startEq &&  bRev) */
  3375   3375         OP_SeekGe,           /* 6: (start_constraints  &&  startEq && !bRev) */
  3376   3376         OP_SeekLe            /* 7: (start_constraints  &&  startEq &&  bRev) */
  3377   3377       };
  3378         -    int aEndOp[] = {
         3378  +    static const u8 aEndOp[] = {
  3379   3379         OP_Noop,             /* 0: (!end_constraints) */
  3380   3380         OP_IdxGE,            /* 1: (end_constraints && !bRev) */
  3381   3381         OP_IdxLT             /* 2: (end_constraints && bRev) */
  3382   3382       };
  3383         -    int nEq = pLevel->plan.nEq;
         3383  +    int nEq = pLevel->plan.nEq;  /* Number of == or IN terms */
  3384   3384       int isMinQuery = 0;          /* If this is an optimized SELECT min(x).. */
  3385   3385       int regBase;                 /* Base register holding constraint values */
  3386   3386       int r1;                      /* Temp register */
  3387   3387       WhereTerm *pRangeStart = 0;  /* Inequality constraint at range start */
  3388   3388       WhereTerm *pRangeEnd = 0;    /* Inequality constraint at range end */
  3389   3389       int startEq;                 /* True if range start uses ==, >= or <= */
  3390   3390       int endEq;                   /* True if range end uses ==, >= or <= */
  3391   3391       int start_constraints;       /* Start of range is constrained */
  3392   3392       int nConstraint;             /* Number of constraint terms */
  3393         -    Index *pIdx;         /* The index we will be using */
  3394         -    int iIdxCur;         /* The VDBE cursor for the index */
  3395         -    int nExtraReg = 0;   /* Number of extra registers needed */
  3396         -    int op;              /* Instruction opcode */
         3393  +    Index *pIdx;                 /* The index we will be using */
         3394  +    int iIdxCur;                 /* The VDBE cursor for the index */
         3395  +    int nExtraReg = 0;           /* Number of extra registers needed */
         3396  +    int op;                      /* Instruction opcode */
  3397   3397       char *zStartAff;             /* Affinity for start of range constraint */
  3398   3398       char *zEndAff;               /* Affinity for end of range constraint */
  3399   3399   
  3400   3400       pIdx = pLevel->plan.u.pIdx;
  3401   3401       iIdxCur = pLevel->iIdxCur;
  3402   3402       k = pIdx->aiColumn[nEq];     /* Column for inequality constraints */
  3403   3403