/ Check-in [2e3df0bc]
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: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 Unified Diffs Ignore Whitespace Patch

Changes to src/build.c.

2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
    sqlite3BeginWriteOperation(pParse, 1, iDb);
    sqlite3VdbeAddOp2(v, OP_CreateIndex, iDb, iMem);

    /* Gather the complete text of the CREATE INDEX statement into
    ** the zStmt variable
    */
    if( pStart ){
      int n = (pParse->sLastToken.z - pName->z) + 1;
      if( pName->z[n-1]==';' ) n--;
      /* A named index with an explicit CREATE INDEX statement */
      zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
        onError==OE_None ? "" : " UNIQUE", n, pName->z);
    }else{
      /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
      /* zStmt = sqlite3MPrintf(""); */







|







2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
    sqlite3BeginWriteOperation(pParse, 1, iDb);
    sqlite3VdbeAddOp2(v, OP_CreateIndex, iDb, iMem);

    /* Gather the complete text of the CREATE INDEX statement into
    ** the zStmt variable
    */
    if( pStart ){
      int n = (pParse->sLastToken.z - pName->z) + pParse->sLastToken.n;
      if( pName->z[n-1]==';' ) n--;
      /* A named index with an explicit CREATE INDEX statement */
      zStmt = sqlite3MPrintf(db, "CREATE%s INDEX %.*s",
        onError==OE_None ? "" : " UNIQUE", n, pName->z);
    }else{
      /* An automatic index created by a PRIMARY KEY or UNIQUE constraint */
      /* zStmt = sqlite3MPrintf(""); */

Changes to test/index6.test.

207
208
209
210
211
212
213
214





215
    INSERT INTO t3(a,b) VALUES(999, 'test1'), (999, 'test2');
  }
} {0 {}}
do_execsql_test index6-3.4 {
  SELECT count(*) FROM t3 WHERE a=999;
} {162}
integrity_check index6-3.5






finish_test








>
>
>
>
>

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

do_execsql_test index6-4.0 {
  VACUUM;
  PRAGMA integrity_check;
} {ok}

finish_test