/ Check-in [b64d64c8]
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:Merge the fix for ticket [a4e06e75a9ab61a12] from trunk.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | branch-3.20
Files: files | file ages | folders
SHA3-256: b64d64c84484162d1822430036ba0483365a39ef4cf82cd6a7b9436d9e9f50c8
User & Date: drh 2017-07-15 20:44:33
Context
2017-07-17
12:27
Add the pointer-type parameter to sqlite3_bind_pointer(), sqlite3_result_pointer(), and sqlite3_value_pointer(). The pointer type is a static string that must match (according to strcmp()) or else the pointer is passed as a NULL. This is a security measure to prevent crossing pointers between different extensions. check-in: e1196567 user: drh tags: branch-3.20
00:40
Add an experimental "pointer type" parameter to sqlite3_bind_pointer(), sqlite3_result_pointer(), and sqlite3_value_pointer(). The pointer type is a string that must compare equal using strcmp() or else the pointer comes through as a NULL. check-in: 211cce04 user: drh tags: pointer-types
2017-07-15
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
13:49
Minor change to one of the command-line shell test scripts to make that script compatible with Tcl 8.5. check-in: 47cf83a0 user: drh tags: branch-3.20
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),
................................................................................
  1938   1939     **              information from the current session in the
  1939   1940     **              database file so that it will be available to "optimize"
  1940   1941     **              pragmas run by future database connections.
  1941   1942     **
  1942   1943     **    0x0008    (Not yet implemented) Create indexes that might have
  1943   1944     **              been helpful to recent queries
  1944   1945     **
  1945         -  ** The default MASK is and always shall be 0xfffe.  0xfffe means perform all    ** of the optimizations listed above except Debug Mode, including new
         1946  +  ** The default MASK is and always shall be 0xfffe.  0xfffe means perform all
         1947  +  ** of the optimizations listed above except Debug Mode, including new
  1946   1948     ** optimizations that have not yet been invented.  If new optimizations are
  1947   1949     ** ever added that should be off by default, those off-by-default 
  1948   1950     ** optimizations will have bitmasks of 0x10000 or larger.
  1949   1951     **
  1950   1952     ** DETERMINATION OF WHEN TO RUN ANALYZE
  1951   1953     **
  1952   1954     ** In the current implementation, a table is analyzed if only if all of

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

Changes to tool/showstat4.c.

   114    114         }else if( iVal<=7 ){
   115    115           v = (signed char)aSample[y];
   116    116           for(j=1; j<sz; j++){
   117    117             v = (v<<8) + aSample[y+j];
   118    118           }
   119    119           if( iVal==7 ){
   120    120             double r;
          121  +          char *z;
   121    122             memcpy(&r, &v, sizeof(r));
   122         -          printf("%s%#g", zSep, r);
          123  +          z = sqlite3_mprintf("%s%!.15g", zSep, r);
          124  +          printf("%s", z);
          125  +          sqlite3_free(z);
   123    126           }else{
   124    127             printf("%s%lld", zSep, v);
   125    128           }
   126    129         }else if( (iVal&1)==0 ){
   127    130           printf("%sx'", zSep);
   128    131           for(j=0; j<sz; j++){
   129    132             printf("%02x", aSample[y+j]);