/ Check-in [253945d4]
Login

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

Overview
Comment:Fix a register allocation problem in PRAGMA integrity_check that caused the same register to be used for two different purposes on the first ATTACHed database if the schema for the ATTACHed database was noticable more complex than the schema for the first database. Fix for ticket [a4e06e75a9ab61a1].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 253945d480b052bfe311888022b5eb0be91c8c80cda05036e58207d57520262c
User & Date: drh 2017-07-15 20:33:19
Context
2017-07-17
13:37
Merge the pointer-type enhancement from the 3.20 branch. check-in: 9e8e1c4a user: drh tags: trunk
2017-07-15
20:48
Add the "unionvtab" virtual table extension in ext/misc/unionvtab.c. check-in: 62a86aa6 user: dan tags: union-vtab
20:44
Merge the fix for ticket [a4e06e75a9ab61a12] from trunk. check-in: b64d64c8 user: drh tags: branch-3.20
20:33
Fix a register allocation problem in PRAGMA integrity_check that caused the same register to be used for two different purposes on the first ATTACHed database if the schema for the ATTACHed database was noticable more complex than the schema for the first database. Fix for ticket [a4e06e75a9ab61a1]. check-in: 253945d4 user: drh tags: trunk
20:25
Fix a missing \n at the end of a comment causing a line to be too long. No code changes. check-in: 687bd478 user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/expr.c.

  5251   5251   ** iFirst..iLast, inclusive.  This routine is only call from within assert()
  5252   5252   ** statements.
  5253   5253   */
  5254   5254   #ifdef SQLITE_DEBUG
  5255   5255   int sqlite3NoTempsInRange(Parse *pParse, int iFirst, int iLast){
  5256   5256     int i;
  5257   5257     if( pParse->nRangeReg>0
  5258         -   && pParse->iRangeReg+pParse->nRangeReg<iLast
  5259         -   && pParse->iRangeReg>=iFirst
         5258  +   && pParse->iRangeReg+pParse->nRangeReg > iFirst
         5259  +   && pParse->iRangeReg <= iLast
  5260   5260     ){
  5261   5261        return 0;
  5262   5262     }
  5263   5263     for(i=0; i<pParse->nTempReg; i++){
  5264   5264       if( pParse->aTempReg[i]>=iFirst && pParse->aTempReg[i]<=iLast ){
  5265   5265         return 0;
  5266   5266       }
  5267   5267     }
  5268   5268     return 1;
  5269   5269   }
  5270   5270   #endif /* SQLITE_DEBUG */

Changes to src/pragma.c.

  1524   1524             aRoot[cnt++] = pIdx->tnum;
  1525   1525           }
  1526   1526         }
  1527   1527         aRoot[cnt] = 0;
  1528   1528   
  1529   1529         /* Make sure sufficient number of registers have been allocated */
  1530   1530         pParse->nMem = MAX( pParse->nMem, 8+mxIdx );
         1531  +      sqlite3ClearTempRegCache(pParse);
  1531   1532   
  1532   1533         /* Do the b-tree integrity checks */
  1533   1534         sqlite3VdbeAddOp4(v, OP_IntegrityCk, 2, cnt, 1, (char*)aRoot,P4_INTARRAY);
  1534   1535         sqlite3VdbeChangeP5(v, (u8)i);
  1535   1536         addr = sqlite3VdbeAddOp1(v, OP_IsNull, 2); VdbeCoverage(v);
  1536   1537         sqlite3VdbeAddOp4(v, OP_String8, 0, 3, 0,
  1537   1538            sqlite3MPrintf(db, "*** in database %s ***\n", db->aDb[i].zDbSName),

Changes to test/attach.test.

   866    866   do_execsql_test attach-11.1 {
   867    867     ATTACH printf('file:%09000x/x.db?mode=memory&cache=shared',1) AS aux1;
   868    868     CREATE TABLE aux1.t1(x,y);
   869    869     INSERT INTO aux1.t1(x,y) VALUES(1,2),(3,4);
   870    870     SELECT * FROM aux1.t1;
   871    871   } {1 2 3 4}
   872    872   
          873  +# Ticket https://sqlite.org/src/tktview/a4e06e75a9ab61a1  2017-07-15
          874  +# False positive when running integrity_check on a connection with
          875  +# attached databases.  
          876  +#
          877  +db close
          878  +sqlite3 db :memory:
          879  +do_execsql_test attach-12.1 {
          880  +  CREATE TABLE Table1 (col TEXT NOT NULL PRIMARY KEY);
          881  +  ATTACH ':memory:' AS db2;
          882  +  CREATE TABLE db2.Table2(col1 INTEGER, col2 INTEGER, col3 INTEGER, col4);
          883  +  CREATE UNIQUE INDEX db2.idx_col1_unique ON Table2 (col1);
          884  +  CREATE UNIQUE INDEX db2.idx_col23_unique ON Table2 (col2, col3);
          885  +  CREATE INDEX db2.idx_col2 ON Table2 (col2);
          886  +  INSERT INTO Table2 VALUES(1,2,3,4);
          887  +  PRAGMA integrity_check;
          888  +} {ok}
   873    889   
   874    890   finish_test