/ Check-in [2e3df0bc]
Login

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

Overview
Comment:Fix bug in the logic that determines the end of a CREATE INDEX statement. Added a VACUUM test case that exposed the bug.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | partial-indices
Files: files | file ages | folders
SHA1: 2e3df0bc900c01286d3ce32c2bbf9e5293973f9b
User & Date: drh 2013-08-01 16:02:40
Context
2013-08-02
14:18
Silently ignore database name qualifiers in CHECK constraints and in partial index WHERE clauses. Closed-Leaf check-in: 2e8c845e user: drh tags: partial-indices
2013-08-01
16:02
Fix bug in the logic that determines the end of a CREATE INDEX statement. Added a VACUUM test case that exposed the bug. check-in: 2e3df0bc user: drh tags: partial-indices
15:09
More test cases and corresponding bug fixes. check-in: 0c8cfdfa user: drh tags: partial-indices
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/build.c.

  2857   2857       sqlite3BeginWriteOperation(pParse, 1, iDb);
  2858   2858       sqlite3VdbeAddOp2(v, OP_CreateIndex, iDb, iMem);
  2859   2859   
  2860   2860       /* Gather the complete text of the CREATE INDEX statement into
  2861   2861       ** the zStmt variable
  2862   2862       */
  2863   2863       if( pStart ){
  2864         -      int n = (pParse->sLastToken.z - pName->z) + 1;
         2864  +      int n = (pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
  2865   2865         if( pName->z[n-1]==';' ) n--;
  2866   2866         /* A named index with an explicit CREATE INDEX statement */
  2867   2867         zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
  2868   2868           onError==OE_None ? "" : " UNIQUE", n, pName->z);
  2869   2869       }else{
  2870   2870         /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
  2871   2871         /* zStmt = sqlite3MPrintf(""); */

Changes to test/index6.test.

   207    207       INSERT INTO t3(a,b) VALUES(999, 'test1'), (999, 'test2');
   208    208     }
   209    209   } {0 {}}
   210    210   do_execsql_test index6-3.4 {
   211    211     SELECT count(*) FROM t3 WHERE a=999;
   212    212   } {162}
   213    213   integrity_check index6-3.5
          214  +
          215  +do_execsql_test index6-4.0 {
          216  +  VACUUM;
          217  +  PRAGMA integrity_check;
          218  +} {ok}
   214    219   
   215    220   finish_test