/ Check-in [85fd92c7]
Login

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

Overview
Comment:Merge in all changes for release 3.26.0.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | begin-concurrent-pnu
Files: files | file ages | folders
SHA3-256: 85fd92c71fd5b29bd45bb1717a5be761600fc23bed12eaff9eed708701a0fdf7
User & Date: drh 2018-12-03 18:24:31
Context
2018-12-05
13:49
Merge enhancements from trunk, especially the sqlite3_normalized_sql() enhancement. check-in: 342c9538 user: drh tags: begin-concurrent-pnu
2018-12-03
18:24
Merge in all changes for release 3.26.0. check-in: 85fd92c7 user: drh tags: begin-concurrent-pnu
18:15
Bring up to date with version 3.26.0. check-in: f0ddb358 user: drh tags: begin-concurrent
2018-11-30
16:26
Merge the mutex-free PRNG change into this branch. check-in: 81e626f4 user: dan tags: begin-concurrent-pnu
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to Makefile.in.

    28     28   # are provide so that these aspects of the build process can be changed
    29     29   # on the "make" command-line.  Ex:  "make CC=clang CFLAGS=-fsanitize=undefined"
    30     30   #
    31     31   CC = @CC@
    32     32   CFLAGS = @CPPFLAGS@ @CFLAGS@
    33     33   TCC = ${CC} ${CFLAGS} -I. -I${TOP}/src -I${TOP}/ext/rtree -I${TOP}/ext/icu
    34     34   TCC += -I${TOP}/ext/fts3 -I${TOP}/ext/async -I${TOP}/ext/session
           35  +TCC += -I${TOP}/ext/userauth
    35     36   
    36     37   # Define this for the autoconf-based build, so that the code knows it can
    37     38   # include the generated config.h
    38     39   #
    39     40   TCC += -D_HAVE_SQLITE_CONFIG_H -DBUILD_sqlite
    40     41   
    41     42   # Define -DNDEBUG to compile without debugging (i.e., for production usage)
................................................................................
   183    184            memdb.lo memjournal.lo \
   184    185            mutex.lo mutex_noop.lo mutex_unix.lo mutex_w32.lo \
   185    186            notify.lo opcodes.lo os.lo os_unix.lo os_win.lo \
   186    187            pager.lo parse.lo pcache.lo pcache1.lo pragma.lo prepare.lo printf.lo \
   187    188            random.lo resolve.lo rowset.lo rtree.lo \
   188    189            sqlite3session.lo select.lo sqlite3rbu.lo status.lo stmt.lo \
   189    190            table.lo threads.lo tokenize.lo treeview.lo trigger.lo \
   190         -         update.lo upsert.lo util.lo vacuum.lo \
          191  +         update.lo userauth.lo upsert.lo util.lo vacuum.lo \
   191    192            vdbe.lo vdbeapi.lo vdbeaux.lo vdbeblob.lo vdbemem.lo vdbesort.lo \
   192    193            vdbetrace.lo wal.lo walker.lo where.lo wherecode.lo whereexpr.lo \
   193    194            window.lo utf.lo vtab.lo
   194    195   
   195    196   # Object files for the amalgamation.
   196    197   #
   197    198   LIBOBJS1 = sqlite3.lo
................................................................................
   352    353     $(TOP)/ext/rtree/rtree.h \
   353    354     $(TOP)/ext/rtree/rtree.c \
   354    355     $(TOP)/ext/rtree/geopoly.c
   355    356   SRC += \
   356    357     $(TOP)/ext/session/sqlite3session.c \
   357    358     $(TOP)/ext/session/sqlite3session.h
   358    359   SRC += \
          360  +  $(TOP)/ext/userauth/userauth.c \
          361  +  $(TOP)/ext/userauth/sqlite3userauth.h
          362  +SRC += \
   359    363     $(TOP)/ext/rbu/sqlite3rbu.h \
   360    364     $(TOP)/ext/rbu/sqlite3rbu.c
   361    365   SRC += \
   362    366     $(TOP)/ext/misc/json1.c \
   363    367     $(TOP)/ext/misc/stmt.c
   364    368   
   365    369   # Generated source code files
................................................................................
   451    455     $(TOP)/ext/misc/regexp.c \
   452    456     $(TOP)/ext/misc/remember.c \
   453    457     $(TOP)/ext/misc/series.c \
   454    458     $(TOP)/ext/misc/spellfix.c \
   455    459     $(TOP)/ext/misc/totype.c \
   456    460     $(TOP)/ext/misc/unionvtab.c \
   457    461     $(TOP)/ext/misc/wholenumber.c \
   458         -  $(TOP)/ext/misc/zipfile.c
          462  +  $(TOP)/ext/misc/zipfile.c \
          463  +  $(TOP)/ext/userauth/userauth.c
   459    464   
   460    465   # Source code to the library files needed by the test fixture
   461    466   #
   462    467   TESTSRC2 = \
   463    468     $(TOP)/src/attach.c \
   464    469     $(TOP)/src/backup.c \
   465    470     $(TOP)/src/bitvec.c \
................................................................................
   467    472     $(TOP)/src/build.c \
   468    473     $(TOP)/src/ctime.c \
   469    474     $(TOP)/src/date.c \
   470    475     $(TOP)/src/dbpage.c \
   471    476     $(TOP)/src/dbstat.c \
   472    477     $(TOP)/src/expr.c \
   473    478     $(TOP)/src/func.c \
          479  +  $(TOP)/src/global.c \
   474    480     $(TOP)/src/insert.c \
   475    481     $(TOP)/src/wal.c \
   476    482     $(TOP)/src/main.c \
   477    483     $(TOP)/src/mem5.c \
   478    484     $(TOP)/src/os.c \
   479    485     $(TOP)/src/os_unix.c \
   480    486     $(TOP)/src/os_win.c \
................................................................................
   556    562   EXTHDR += \
   557    563     $(TOP)/ext/rtree/rtree.h \
   558    564     $(TOP)/ext/rtree/geopoly.c
   559    565   EXTHDR += \
   560    566     $(TOP)/ext/icu/sqliteicu.h
   561    567   EXTHDR += \
   562    568     $(TOP)/ext/rtree/sqlite3rtree.h
          569  +EXTHDR += \
          570  +  $(TOP)/ext/userauth/sqlite3userauth.h
   563    571   
   564    572   # executables needed for testing
   565    573   #
   566    574   TESTPROGS = \
   567    575     testfixture$(TEXE) \
   568    576     sqlite3$(TEXE) \
   569    577     sqlite3_analyzer$(TEXE) \
................................................................................
  1113   1121   
  1114   1122   fts3_write.lo:	$(TOP)/ext/fts3/fts3_write.c $(HDR) $(EXTHDR)
  1115   1123   	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/fts3/fts3_write.c
  1116   1124   
  1117   1125   rtree.lo:	$(TOP)/ext/rtree/rtree.c $(HDR) $(EXTHDR)
  1118   1126   	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/rtree/rtree.c
  1119   1127   
  1120         -sqlite3session.lo:	$(TOP)/ext/session/sqlite3session.c $(HDR) $(EXTHDR)
         1128  +sqlite3session.lo:	$(TOP)/ext/userauth/userauth.c $(HDR) $(EXTHDR)
         1129  +	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/userauth/userauth.c
         1130  +
         1131  +userauth.lo:	$(TOP)/ext/session/sqlite3session.c $(HDR) $(EXTHDR)
  1121   1132   	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/session/sqlite3session.c
  1122   1133   
  1123   1134   json1.lo:	$(TOP)/ext/misc/json1.c
  1124   1135   	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/misc/json1.c
  1125   1136   
  1126   1137   stmt.lo:	$(TOP)/ext/misc/stmt.c
  1127   1138   	$(LTCOMPILE) -DSQLITE_CORE -c $(TOP)/ext/misc/stmt.c

Changes to Makefile.msc.

   341    341   OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_RTREE=1
   342    342   OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_GEOPOLY=1
   343    343   OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_JSON1=1
   344    344   OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_STMTVTAB=1
   345    345   OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBPAGE_VTAB=1
   346    346   OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DBSTAT_VTAB=1
   347    347   OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_INTROSPECTION_PRAGMAS=1
          348  +OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_DESERIALIZE=1
   348    349   !ENDIF
   349    350   OPT_FEATURE_FLAGS = $(OPT_FEATURE_FLAGS) -DSQLITE_ENABLE_COLUMN_METADATA=1
   350    351   !ENDIF
   351    352   
   352    353   # Should the session extension be enabled?  If so, add compilation options
   353    354   # to enable it.
   354    355   #

Changes to doc/lemon.html.

   772    772   
   773    773   <p><pre>
   774    774      %include {#include &lt;unistd.h&gt;}
   775    775   </pre></p>
   776    776   
   777    777   <p>This might be needed, for example, if some of the C actions in the
   778    778   grammar call functions that are prototyped in unistd.h.</p>
          779  +
          780  +<p>Use the <tt><a href="#pcode">%code</a></tt> directive to add code to
          781  +the end of the generated parser.</p>
   779    782   
   780    783   <a name='pleft'></a>
   781    784   <h4>The <tt>%left</tt> directive</h4>
   782    785   
   783    786   The <tt>%left</tt> directive is used (along with the
   784    787   <tt><a href='#pright'>%right</a></tt> and
   785    788   <tt><a href='#pnonassoc'>%nonassoc</a></tt> directives) to declare

Changes to ext/fts3/fts3.c.

  4162   4162       }
  4163   4163       assert( pToken->pSegcsr==0 );
  4164   4164     }
  4165   4165   
  4166   4166     return rc;
  4167   4167   }
  4168   4168   
         4169  +#ifndef SQLITE_DISABLE_FTS4_DEFERRED
  4169   4170   /*
  4170   4171   ** This function is called on each phrase after the position lists for
  4171   4172   ** any deferred tokens have been loaded into memory. It updates the phrases
  4172   4173   ** current position list to include only those positions that are really
  4173   4174   ** instances of the phrase (after considering deferred tokens). If this
  4174   4175   ** means that the phrase does not appear in the current row, doclist.pList
  4175   4176   ** and doclist.nList are both zeroed.
................................................................................
  4265   4266         }
  4266   4267         sqlite3_free(aPoslist);
  4267   4268       }
  4268   4269     }
  4269   4270   
  4270   4271     return SQLITE_OK;
  4271   4272   }
         4273  +#endif /* SQLITE_DISABLE_FTS4_DEFERRED */
  4272   4274   
  4273   4275   /*
  4274   4276   ** Maximum number of tokens a phrase may have to be considered for the
  4275   4277   ** incremental doclists strategy.
  4276   4278   */
  4277   4279   #define MAX_INCR_PHRASE_TOKENS 4
  4278   4280   

Changes to ext/rtree/geopoly.c.

   540    540          4+8*p->nVertex, SQLITE_TRANSIENT);
   541    541       sqlite3_free(p);
   542    542     }            
   543    543   }
   544    544   
   545    545   #define GEOPOLY_PI 3.1415926535897932385
   546    546   
   547         -/* Fast approximation for cosine(X) for X between -0.5*pi and 2*pi
          547  +/* Fast approximation for sine(X) for X between -0.5*pi and 2*pi
   548    548   */
   549         -static double geopolyCosine(double r){
          549  +static double geopolySine(double r){
   550    550     assert( r>=-0.5*GEOPOLY_PI && r<=2.0*GEOPOLY_PI );
   551    551     if( r>=1.5*GEOPOLY_PI ){
   552    552       r -= 2.0*GEOPOLY_PI;
   553    553     }
   554    554     if( r>=0.5*GEOPOLY_PI ){
   555         -    return -geopolyCosine(r-GEOPOLY_PI);
          555  +    return -geopolySine(r-GEOPOLY_PI);
   556    556     }else{
   557    557       double r2 = r*r;
   558    558       double r3 = r2*r;
   559    559       double r5 = r3*r2;
   560    560       return 0.9996949*r - 0.1656700*r3 + 0.0075134*r5;
   561    561     }
   562    562   }
................................................................................
   589    589     i = 1;
   590    590     p->hdr[0] = *(unsigned char*)&i;
   591    591     p->hdr[1] = 0;
   592    592     p->hdr[2] = (n>>8)&0xff;
   593    593     p->hdr[3] = n&0xff;
   594    594     for(i=0; i<n; i++){
   595    595       double rAngle = 2.0*GEOPOLY_PI*i/n;
   596         -    p->a[i*2] = x - r*geopolyCosine(rAngle-0.5*GEOPOLY_PI);
   597         -    p->a[i*2+1] = y + r*geopolyCosine(rAngle);
          596  +    p->a[i*2] = x - r*geopolySine(rAngle-0.5*GEOPOLY_PI);
          597  +    p->a[i*2+1] = y + r*geopolySine(rAngle);
   598    598     }
   599    599     sqlite3_result_blob(context, p->hdr, 4+8*n, SQLITE_TRANSIENT);
   600    600     sqlite3_free(p);
   601    601   }
   602    602   
   603    603   /*
   604    604   ** If pPoly is a polygon, compute its bounding box. Then:

Changes to ext/rtree/sqlite3rtree.h.

    92     92     unsigned int *anQueue;            /* Number of pending entries in the queue */
    93     93     int nCoord;                       /* Number of coordinates */
    94     94     int iLevel;                       /* Level of current node or entry */
    95     95     int mxLevel;                      /* The largest iLevel value in the tree */
    96     96     sqlite3_int64 iRowid;             /* Rowid for current entry */
    97     97     sqlite3_rtree_dbl rParentScore;   /* Score of parent node */
    98     98     int eParentWithin;                /* Visibility of parent node */
    99         -  int eWithin;                      /* OUT: Visiblity */
           99  +  int eWithin;                      /* OUT: Visibility */
   100    100     sqlite3_rtree_dbl rScore;         /* OUT: Write the score here */
   101    101     /* The following fields are only available in 3.8.11 and later */
   102    102     sqlite3_value **apSqlParam;       /* Original SQL values of parameters */
   103    103   };
   104    104   
   105    105   /*
   106    106   ** Allowed values for sqlite3_rtree_query.eWithin and .eParentWithin.

Changes to main.mk.

   392    392     $(TOP)/src/btree.c \
   393    393     $(TOP)/src/build.c \
   394    394     $(TOP)/src/date.c \
   395    395     $(TOP)/src/dbpage.c \
   396    396     $(TOP)/src/dbstat.c \
   397    397     $(TOP)/src/expr.c \
   398    398     $(TOP)/src/func.c \
          399  +  $(TOP)/src/global.c \
   399    400     $(TOP)/src/insert.c \
   400    401     $(TOP)/src/wal.c \
   401    402     $(TOP)/src/main.c \
   402    403     $(TOP)/src/mem5.c \
   403    404     $(TOP)/src/os.c \
   404    405     $(TOP)/src/os_unix.c \
   405    406     $(TOP)/src/os_win.c \

Changes to src/alter.c.

   663    663     }
   664    664   }
   665    665   #else
   666    666   # define renameTokenCheckAll(x,y)
   667    667   #endif
   668    668   
   669    669   /*
   670         -** Add a new RenameToken object mapping parse tree element pPtr into
   671         -** token *pToken to the Parse object currently under construction.
          670  +** Remember that the parser tree element pPtr was created using
          671  +** the token pToken.
   672    672   **
   673         -** Return a copy of pPtr.
          673  +** In other words, construct a new RenameToken object and add it
          674  +** to the list of RenameToken objects currently being built up
          675  +** in pParse->pRename.
          676  +**
          677  +** The pPtr argument is returned so that this routine can be used
          678  +** with tail recursion in tokenExpr() routine, for a small performance
          679  +** improvement.
   674    680   */
   675    681   void *sqlite3RenameTokenMap(Parse *pParse, void *pPtr, Token *pToken){
   676    682     RenameToken *pNew;
   677    683     assert( pPtr || pParse->db->mallocFailed );
   678    684     renameTokenCheckAll(pParse, pPtr);
   679    685     pNew = sqlite3DbMallocZero(pParse->db, sizeof(RenameToken));
   680    686     if( pNew ){
................................................................................
  1178   1184   **   8. bTemp:    True if zSql comes from temp schema
  1179   1185   **
  1180   1186   ** Do a column rename operation on the CREATE statement given in zSql.
  1181   1187   ** The iCol-th column (left-most is 0) of table zTable is renamed from zCol
  1182   1188   ** into zNew.  The name should be quoted if bQuote is true.
  1183   1189   **
  1184   1190   ** This function is used internally by the ALTER TABLE RENAME COLUMN command.
  1185         -** Though accessible to application code, it is not intended for use by
  1186         -** applications.  The existance of this function, and the way it works,
  1187         -** is subject to change without notice.
  1188         -**
  1189         -** If any of the parameters are out-of-bounds, then simply return NULL.
  1190         -** An out-of-bounds parameter can only occur when the application calls
  1191         -** this function directly.  The parameters will always be well-formed when
  1192         -** this routine is invoked by the bytecode for a legitimate ALTER TABLE
  1193         -** statement.
         1191  +** It is only accessible to SQL created using sqlite3NestedParse().  It is
         1192  +** not reachable from ordinary SQL passed into sqlite3_prepare().
  1194   1193   */
  1195   1194   static void renameColumnFunc(
  1196   1195     sqlite3_context *context,
  1197   1196     int NotUsed,
  1198   1197     sqlite3_value **argv
  1199   1198   ){
  1200   1199     sqlite3 *db = sqlite3_context_db_handle(context);
................................................................................
  1594   1593   }
  1595   1594   
  1596   1595   /*
  1597   1596   ** Register built-in functions used to help implement ALTER TABLE
  1598   1597   */
  1599   1598   void sqlite3AlterFunctions(void){
  1600   1599     static FuncDef aAlterTableFuncs[] = {
  1601         -    FUNCTION(sqlite_rename_column,  9, 0, 0, renameColumnFunc),
  1602         -    FUNCTION(sqlite_rename_table,  7, 0, 0, renameTableFunc),
  1603         -    FUNCTION(sqlite_rename_test,  5, 0, 0, renameTableTest),
         1600  +    INTERNAL_FUNCTION(sqlite_rename_column, 9, renameColumnFunc),
         1601  +    INTERNAL_FUNCTION(sqlite_rename_table,  7, renameTableFunc),
         1602  +    INTERNAL_FUNCTION(sqlite_rename_test,   5, renameTableTest),
  1604   1603     };
  1605   1604     sqlite3InsertBuiltinFuncs(aAlterTableFuncs, ArraySize(aAlterTableFuncs));
  1606   1605   }
  1607   1606   #endif  /* SQLITE_ALTER_TABLE */

Changes to src/build.c.

   542    542   /*
   543    543   ** Erase all schema information from all attached databases (including
   544    544   ** "main" and "temp") for a single database connection.
   545    545   */
   546    546   void sqlite3ResetAllSchemasOfConnection(sqlite3 *db){
   547    547     int i;
   548    548     sqlite3BtreeEnterAll(db);
   549         -  assert( db->nSchemaLock==0 );
   550    549     for(i=0; i<db->nDb; i++){
   551    550       Db *pDb = &db->aDb[i];
   552    551       if( pDb->pSchema ){
   553         -      sqlite3SchemaClear(pDb->pSchema);
          552  +      if( db->nSchemaLock==0 ){
          553  +        sqlite3SchemaClear(pDb->pSchema);
          554  +      }else{
          555  +        DbSetProperty(db, i, DB_ResetWanted);
          556  +      }
   554    557       }
   555    558     }
   556    559     db->mDbFlags &= ~(DBFLAG_SchemaChange|DBFLAG_SchemaKnownOk);
   557    560     sqlite3VtabUnlockList(db);
   558    561     sqlite3BtreeLeaveAll(db);
   559         -  sqlite3CollapseDatabaseArray(db);
          562  +  if( db->nSchemaLock==0 ){
          563  +    sqlite3CollapseDatabaseArray(db);
          564  +  }
   560    565   }
   561    566   
   562    567   /*
   563    568   ** This routine is called when a commit occurs.
   564    569   */
   565    570   void sqlite3CommitInternalChanges(sqlite3 *db){
   566    571     db->mDbFlags &= ~DBFLAG_SchemaChange;
................................................................................
  1892   1897       assert( pTab->nCol==j );
  1893   1898     }else{
  1894   1899       pPk->nColumn = pTab->nCol;
  1895   1900     }
  1896   1901     recomputeColumnsNotIndexed(pPk);
  1897   1902   }
  1898   1903   
         1904  +#ifndef SQLITE_OMIT_VIRTUALTABLE
  1899   1905   /*
  1900   1906   ** Return true if zName is a shadow table name in the current database
  1901   1907   ** connection.
  1902   1908   **
  1903   1909   ** zName is temporarily modified while this routine is running, but is
  1904   1910   ** restored to its original value prior to this routine returning.
  1905   1911   */
................................................................................
  1917   1923     if( !IsVirtual(pTab) ) return 0;
  1918   1924     pMod = (Module*)sqlite3HashFind(&db->aModule, pTab->azModuleArg[0]);
  1919   1925     if( pMod==0 ) return 0;
  1920   1926     if( pMod->pModule->iVersion<3 ) return 0;
  1921   1927     if( pMod->pModule->xShadowName==0 ) return 0;
  1922   1928     return pMod->pModule->xShadowName(zTail+1);
  1923   1929   }
         1930  +#else
         1931  +# define isShadowTableName(x,y) 0
         1932  +#endif /* ifndef SQLITE_OMIT_VIRTUALTABLE */
  1924   1933   
  1925   1934   /*
  1926   1935   ** This routine is called to report the final ")" that terminates
  1927   1936   ** a CREATE TABLE statement.
  1928   1937   **
  1929   1938   ** The table structure that other action routines have been building
  1930   1939   ** is added to the internal hash tables, assuming no errors have

Changes to src/delete.c.

    66     66     }
    67     67     if( (pTab->tabFlags & (TF_Readonly|TF_Shadow))==0 ) return 0;
    68     68     db = pParse->db;
    69     69     if( (pTab->tabFlags & TF_Readonly)!=0 ){
    70     70       return sqlite3WritableSchema(db)==0 && pParse->nested==0;
    71     71     }
    72     72     assert( pTab->tabFlags & TF_Shadow );
    73         -  return (db->flags & SQLITE_Defensive)!=0
    74         -           && db->nVdbeExec==0
    75         -           && db->pVtabCtx==0;
           73  +  return (db->flags & SQLITE_Defensive)!=0 
           74  +#ifndef SQLITE_OMIT_VIRTUALTABLE
           75  +          && db->pVtabCtx==0
           76  +#endif
           77  +          && db->nVdbeExec==0;
    76     78   }
    77     79   
    78     80   /*
    79     81   ** Check to make sure the given table is writable.  If it is not
    80     82   ** writable, generate an error message and return 1.  If it is
    81     83   ** writable return 0;
    82     84   */

Changes to src/global.c.

   236    236      0,                         /* xVdbeBranch */
   237    237      0,                         /* pVbeBranchArg */
   238    238   #endif
   239    239   #ifndef SQLITE_UNTESTABLE
   240    240      0,                         /* xTestCallback */
   241    241   #endif
   242    242      0,                         /* bLocaltimeFault */
          243  +   0,                         /* bInternalFunctions */
   243    244      0x7ffffffe,                /* iOnceResetThreshold */
   244    245      SQLITE_DEFAULT_SORTERREF_SIZE   /* szSorterRef */
   245    246   };
   246    247   
   247    248   /*
   248    249   ** Hash table for global functions - functions common to all
   249    250   ** database connections.  After initialization, this table is

Changes to src/loadext.c.

    80     80   
    81     81   #ifdef SQLITE_OMIT_VIRTUALTABLE
    82     82   # define sqlite3_create_module 0
    83     83   # define sqlite3_create_module_v2 0
    84     84   # define sqlite3_declare_vtab 0
    85     85   # define sqlite3_vtab_config 0
    86     86   # define sqlite3_vtab_on_conflict 0
           87  +# define sqlite3_vtab_collation 0
    87     88   #endif
    88     89   
    89     90   #ifdef SQLITE_OMIT_SHARED_CACHE
    90     91   # define sqlite3_enable_shared_cache 0
    91     92   #endif
    92     93   
    93     94   #if defined(SQLITE_OMIT_TRACE) || defined(SQLITE_OMIT_DEPRECATED)

Changes to src/main.c.

  3949   3949         sqlite3 *db = va_arg(ap, sqlite3*);
  3950   3950         db->dbOptFlags = (u16)(va_arg(ap, int) & 0xffff);
  3951   3951         break;
  3952   3952       }
  3953   3953   
  3954   3954       /*   sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, int onoff);
  3955   3955       **
  3956         -    ** If parameter onoff is non-zero, configure the wrappers so that all
  3957         -    ** subsequent calls to localtime() and variants fail. If onoff is zero,
  3958         -    ** undo this setting.
         3956  +    ** If parameter onoff is non-zero, subsequent calls to localtime()
         3957  +    ** and its variants fail. If onoff is zero, undo this setting.
  3959   3958       */
  3960   3959       case SQLITE_TESTCTRL_LOCALTIME_FAULT: {
  3961   3960         sqlite3GlobalConfig.bLocaltimeFault = va_arg(ap, int);
  3962   3961         break;
  3963   3962       }
         3963  +
         3964  +    /*   sqlite3_test_control(SQLITE_TESTCTRL_INTERNAL_FUNCS, int onoff);
         3965  +    **
         3966  +    ** If parameter onoff is non-zero, internal-use-only SQL functions
         3967  +    ** are visible to ordinary SQL.  This is useful for testing but is
         3968  +    ** unsafe because invalid parameters to those internal-use-only functions
         3969  +    ** can result in crashes or segfaults.
         3970  +    */
         3971  +    case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS: {
         3972  +      sqlite3GlobalConfig.bInternalFunctions = va_arg(ap, int);
         3973  +      break;
         3974  +    }
  3964   3975   
  3965   3976       /*   sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, int);
  3966   3977       **
  3967   3978       ** Set or clear a flag that indicates that the database file is always well-
  3968   3979       ** formed and never corrupt.  This flag is clear by default, indicating that
  3969   3980       ** database files might have arbitrary corruption.  Setting the flag during
  3970   3981       ** testing causes certain assert() statements in the code to be activated

Changes to src/pager.c.

   848    848       return (rc==SQLITE_OK && iRead==0);
   849    849     }
   850    850   #endif
   851    851     return 1;
   852    852   }
   853    853   #endif
   854    854   
   855         -/*
   856         -** Return true if this pager uses a write-ahead log to read page pgno.
   857         -** Return false if the pager reads pgno directly from the database.
   858         -*/
   859         -#if !defined(SQLITE_OMIT_WAL) && defined(SQLITE_DIRECT_OVERFLOW_READ)
   860         -int sqlite3PagerUseWal(Pager *pPager, Pgno pgno){
   861         -  u32 iRead = 0;
   862         -  int rc;
   863         -  if( pPager->pWal==0 ) return 0;
   864         -  rc = sqlite3WalFindFrame(pPager->pWal, pgno, &iRead);
   865         -  return rc || iRead;
   866         -}
   867         -#endif
   868    855   #ifndef SQLITE_OMIT_WAL
   869    856   # define pagerUseWal(x) ((x)->pWal!=0)
   870    857   #else
   871    858   # define pagerUseWal(x) 0
   872    859   # define pagerRollbackWal(x) 0
   873    860   # define pagerWalFrames(v,w,x,y) 0
   874    861   # define pagerOpenWalIfPresent(z) SQLITE_OK
................................................................................
  7196   7183   void sqlite3PagerSetCodec(
  7197   7184     Pager *pPager,
  7198   7185     void *(*xCodec)(void*,void*,Pgno,int),
  7199   7186     void (*xCodecSizeChng)(void*,int,int),
  7200   7187     void (*xCodecFree)(void*),
  7201   7188     void *pCodec
  7202   7189   ){
  7203         -  pager_reset(pPager);
  7204         -  if( pPager->xCodecFree ) pPager->xCodecFree(pPager->pCodec);
         7190  +  if( pPager->xCodecFree ){
         7191  +    pPager->xCodecFree(pPager->pCodec);
         7192  +  }else{
         7193  +    pager_reset(pPager);
         7194  +  }
  7205   7195     pPager->xCodec = pPager->memDb ? 0 : xCodec;
  7206   7196     pPager->xCodecSizeChng = xCodecSizeChng;
  7207   7197     pPager->xCodecFree = xCodecFree;
  7208   7198     pPager->pCodec = pCodec;
  7209   7199     setGetterMethod(pPager);
  7210   7200     pagerReportSize(pPager);
  7211   7201   }

Changes to src/pager.h.

   176    176   
   177    177   #ifndef SQLITE_OMIT_WAL
   178    178     int sqlite3PagerCheckpoint(Pager *pPager, sqlite3*, int, int*, int*);
   179    179     int sqlite3PagerWalSupported(Pager *pPager);
   180    180     int sqlite3PagerWalCallback(Pager *pPager);
   181    181     int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
   182    182     int sqlite3PagerCloseWal(Pager *pPager, sqlite3*);
   183         -# ifdef SQLITE_DIRECT_OVERFLOW_READ
   184         -  int sqlite3PagerUseWal(Pager *pPager, Pgno);
   185         -# endif
   186    183   # ifdef SQLITE_ENABLE_SNAPSHOT
   187    184     int sqlite3PagerSnapshotGet(Pager *pPager, sqlite3_snapshot **ppSnapshot);
   188    185     int sqlite3PagerSnapshotOpen(Pager *pPager, sqlite3_snapshot *pSnapshot);
   189    186     int sqlite3PagerSnapshotRecover(Pager *pPager);
   190    187     int sqlite3PagerSnapshotCheck(Pager *pPager, sqlite3_snapshot *pSnapshot);
   191    188     void sqlite3PagerSnapshotUnlock(Pager *pPager);
   192    189   # endif
   193         -#else
   194         -# define sqlite3PagerUseWal(x,y) 0
   195    190   #endif
   196    191   
   197    192   #ifdef SQLITE_DIRECT_OVERFLOW_READ
   198    193     int sqlite3PagerDirectReadOk(Pager *pPager, Pgno pgno);
   199    194   #endif
   200    195   
   201    196   #ifdef SQLITE_ENABLE_ZIPVFS

Changes to src/pcache1.c.

   101    101     PgHdr1 *pNext;                 /* Next in hash table chain */
   102    102     PCache1 *pCache;               /* Cache that currently owns this page */
   103    103     PgHdr1 *pLruNext;              /* Next in LRU list of unpinned pages */
   104    104     PgHdr1 *pLruPrev;              /* Previous in LRU list of unpinned pages */
   105    105   };
   106    106   
   107    107   /*
   108         -** A page is pinned if it is no on the LRU list
          108  +** A page is pinned if it is not on the LRU list.  To be "pinned" means
          109  +** that the page is in active use and must not be deallocated.
   109    110   */
   110    111   #define PAGE_IS_PINNED(p)    ((p)->pLruNext==0)
   111    112   #define PAGE_IS_UNPINNED(p)  ((p)->pLruNext!=0)
   112    113   
   113    114   /* Each page cache (or PCache) belongs to a PGroup.  A PGroup is a set 
   114    115   ** of one or more PCaches that are able to recycle each other's unpinned
   115    116   ** pages when they are under memory pressure.  A PGroup is an instance of

Changes to src/pragma.c.

  1235   1235     case PragTyp_FUNCTION_LIST: {
  1236   1236       int i;
  1237   1237       HashElem *j;
  1238   1238       FuncDef *p;
  1239   1239       pParse->nMem = 2;
  1240   1240       for(i=0; i<SQLITE_FUNC_HASH_SZ; i++){
  1241   1241         for(p=sqlite3BuiltinFunctions.a[i]; p; p=p->u.pHash ){
         1242  +        if( p->funcFlags & SQLITE_FUNC_INTERNAL ) continue;
  1242   1243           sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 1);
  1243   1244         }
  1244   1245       }
  1245   1246       for(j=sqliteHashFirst(&db->aFunc); j; j=sqliteHashNext(j)){
  1246   1247         p = (FuncDef*)sqliteHashData(j);
  1247   1248         sqlite3VdbeMultiLoad(v, 1, "si", p->zName, 0);
  1248   1249       }

Changes to src/resolve.c.

   766    766           }
   767    767           if( (pDef->funcFlags & SQLITE_FUNC_CONSTANT)==0 ){
   768    768             /* Date/time functions that use 'now', and other functions like
   769    769             ** sqlite_version() that might change over time cannot be used
   770    770             ** in an index. */
   771    771             notValid(pParse, pNC, "non-deterministic functions",
   772    772                      NC_IdxExpr|NC_PartIdx);
          773  +        }
          774  +        if( (pDef->funcFlags & SQLITE_FUNC_INTERNAL)!=0
          775  +         && pParse->nested==0
          776  +         && sqlite3Config.bInternalFunctions==0
          777  +        ){
          778  +          /* Internal-use-only functions are disallowed unless the
          779  +          ** SQL is being compiled using sqlite3NestedParse() */
          780  +          no_such_func = 1;
          781  +          pDef = 0;
   773    782           }
   774    783         }
   775    784   
   776    785         if( 0==IN_RENAME_OBJECT ){
   777    786   #ifndef SQLITE_OMIT_WINDOWFUNC
   778    787           assert( is_agg==0 || (pDef->funcFlags & SQLITE_FUNC_MINMAX)
   779    788             || (pDef->xValue==0 && pDef->xInverse==0)

Changes to src/shell.c.in.

  7673   7673         { "always",             SQLITE_TESTCTRL_ALWAYS,        "BOOLEAN"            },
  7674   7674         { "assert",             SQLITE_TESTCTRL_ASSERT,        "BOOLEAN"            },
  7675   7675       /*{ "benign_malloc_hooks",SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS, ""          },*/
  7676   7676       /*{ "bitvec_test",        SQLITE_TESTCTRL_BITVEC_TEST,   ""                },*/
  7677   7677         { "byteorder",          SQLITE_TESTCTRL_BYTEORDER,     ""                   },
  7678   7678       /*{ "fault_install",      SQLITE_TESTCTRL_FAULT_INSTALL, ""                }, */
  7679   7679         { "imposter",           SQLITE_TESTCTRL_IMPOSTER,   "SCHEMA ON/OFF ROOTPAGE"},
         7680  +      { "internal_functions", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS, "BOOLEAN"       },
  7680   7681         { "localtime_fault",    SQLITE_TESTCTRL_LOCALTIME_FAULT,"BOOLEAN"           },
  7681   7682         { "never_corrupt",      SQLITE_TESTCTRL_NEVER_CORRUPT, "BOOLEAN"            },
  7682   7683         { "optimizations",      SQLITE_TESTCTRL_OPTIMIZATIONS, "DISABLE-MASK"       },
  7683   7684   #ifdef YYCOVERAGE
  7684   7685         { "parser_coverage",    SQLITE_TESTCTRL_PARSER_COVERAGE, ""                 },
  7685   7686   #endif
  7686   7687         { "pending_byte",       SQLITE_TESTCTRL_PENDING_BYTE,  "OFFSET  "           },
................................................................................
  7767   7768               isOk = 3;
  7768   7769             }
  7769   7770             break;
  7770   7771   
  7771   7772           /* sqlite3_test_control(int, int) */
  7772   7773           case SQLITE_TESTCTRL_ASSERT:
  7773   7774           case SQLITE_TESTCTRL_ALWAYS:
         7775  +        case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS:
  7774   7776             if( nArg==3 ){
  7775   7777               int opt = booleanValue(azArg[2]);
  7776   7778               rc2 = sqlite3_test_control(testctrl, opt);
  7777   7779               isOk = 1;
  7778   7780             }
  7779   7781             break;
  7780   7782   

Changes to src/sqlite.h.in.

  3629   3629   ** deplete the limited store of lookaside memory. Future versions of
  3630   3630   ** SQLite may act on this hint differently.
  3631   3631   **
  3632   3632   ** [[SQLITE_PREPARE_NORMALIZE]] ^(<dt>SQLITE_PREPARE_NORMALIZE</dt>
  3633   3633   ** <dd>The SQLITE_PREPARE_NORMALIZE flag indicates that a normalized
  3634   3634   ** representation of the SQL statement should be calculated and then
  3635   3635   ** associated with the prepared statement, which can be obtained via
  3636         -** the [sqlite3_normalized_sql()] interface.  The semantics used to
         3636  +** the [sqlite3_normalized_sql()] interface.)^  The semantics used to
  3637   3637   ** normalize a SQL statement are unspecified and subject to change.
  3638   3638   ** At a minimum, literal values will be replaced with suitable
  3639   3639   ** placeholders.
  3640   3640   ** </dl>
  3641   3641   */
  3642   3642   #define SQLITE_PREPARE_PERSISTENT              0x01
  3643   3643   #define SQLITE_PREPARE_NORMALIZE               0x02
................................................................................
  7238   7238   #define SQLITE_TESTCTRL_PENDING_BYTE            11
  7239   7239   #define SQLITE_TESTCTRL_ASSERT                  12
  7240   7240   #define SQLITE_TESTCTRL_ALWAYS                  13
  7241   7241   #define SQLITE_TESTCTRL_RESERVE                 14
  7242   7242   #define SQLITE_TESTCTRL_OPTIMIZATIONS           15
  7243   7243   #define SQLITE_TESTCTRL_ISKEYWORD               16  /* NOT USED */
  7244   7244   #define SQLITE_TESTCTRL_SCRATCHMALLOC           17  /* NOT USED */
         7245  +#define SQLITE_TESTCTRL_INTERNAL_FUNCTIONS      17
  7245   7246   #define SQLITE_TESTCTRL_LOCALTIME_FAULT         18
  7246   7247   #define SQLITE_TESTCTRL_EXPLAIN_STMT            19  /* NOT USED */
  7247   7248   #define SQLITE_TESTCTRL_ONCE_RESET_THRESHOLD    19
  7248   7249   #define SQLITE_TESTCTRL_NEVER_CORRUPT           20
  7249   7250   #define SQLITE_TESTCTRL_VDBE_COVERAGE           21
  7250   7251   #define SQLITE_TESTCTRL_BYTEORDER               22
  7251   7252   #define SQLITE_TESTCTRL_ISINIT                  23

Changes to src/sqliteInt.h.

  1691   1691   #define SQLITE_FUNC_UNLIKELY 0x0400 /* Built-in unlikely() function */
  1692   1692   #define SQLITE_FUNC_CONSTANT 0x0800 /* Constant inputs give a constant output */
  1693   1693   #define SQLITE_FUNC_MINMAX   0x1000 /* True for min() and max() aggregates */
  1694   1694   #define SQLITE_FUNC_SLOCHNG  0x2000 /* "Slow Change". Value constant during a
  1695   1695                                       ** single query - might change over time */
  1696   1696   #define SQLITE_FUNC_AFFINITY 0x4000 /* Built-in affinity() function */
  1697   1697   #define SQLITE_FUNC_OFFSET   0x8000 /* Built-in sqlite_offset() function */
  1698         -#define SQLITE_FUNC_WINDOW  0x10000 /* Built-in window-only function */
  1699         -#define SQLITE_FUNC_WINDOW_SIZE  0x20000  /* Requires partition size as arg. */
         1698  +#define SQLITE_FUNC_WINDOW   0x00010000 /* Built-in window-only function */
         1699  +#define SQLITE_FUNC_WINDOW_SIZE 0x20000 /* Requires partition size as arg. */
         1700  +#define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */
  1700   1701   
  1701   1702   /*
  1702   1703   ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
  1703   1704   ** used to create the initializers for the FuncDef structures.
  1704   1705   **
  1705   1706   **   FUNCTION(zName, nArg, iArg, bNC, xFunc)
  1706   1707   **     Used to create a scalar function definition of a function zName
................................................................................
  1768   1769      (void *)arg, 0, likeFunc, 0, 0, 0, #zName, {0} }
  1769   1770   #define AGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue) \
  1770   1771     {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL), \
  1771   1772      SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,0,#zName, {0}}
  1772   1773   #define AGGREGATE2(zName, nArg, arg, nc, xStep, xFinal, extraFlags) \
  1773   1774     {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|extraFlags, \
  1774   1775      SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xFinal,0,#zName, {0}}
  1775         -
  1776   1776   #define WAGGREGATE(zName, nArg, arg, nc, xStep, xFinal, xValue, xInverse, f) \
  1777   1777     {nArg, SQLITE_UTF8|(nc*SQLITE_FUNC_NEEDCOLL)|f, \
  1778   1778      SQLITE_INT_TO_PTR(arg), 0, xStep,xFinal,xValue,xInverse,#zName, {0}}
         1779  +#define INTERNAL_FUNCTION(zName, nArg, xFunc) \
         1780  +  {nArg, SQLITE_FUNC_INTERNAL|SQLITE_UTF8|SQLITE_FUNC_CONSTANT, \
         1781  +   0, 0, xFunc, 0, 0, 0, #zName, {0} }
         1782  +
  1779   1783   
  1780   1784   /*
  1781   1785   ** All current savepoints are stored in a linked list starting at
  1782   1786   ** sqlite3.pSavepoint. The first element in the list is the most recently
  1783   1787   ** opened savepoint. Savepoints are added to the list by the vdbe
  1784   1788   ** OP_Savepoint instruction.
  1785   1789   */
................................................................................
  3422   3426     void (*xVdbeBranch)(void*,unsigned iSrcLine,u8 eThis,u8 eMx);  /* Callback */
  3423   3427     void *pVdbeBranchArg;                                     /* 1st argument */
  3424   3428   #endif
  3425   3429   #ifndef SQLITE_UNTESTABLE
  3426   3430     int (*xTestCallback)(int);        /* Invoked by sqlite3FaultSim() */
  3427   3431   #endif
  3428   3432     int bLocaltimeFault;              /* True to fail localtime() calls */
         3433  +  int bInternalFunctions;           /* Internal SQL functions are visible */
  3429   3434     int iOnceResetThreshold;          /* When to reset OP_Once counters */
  3430   3435     u32 szSorterRef;                  /* Min size in bytes to use sorter-refs */
  3431   3436   };
  3432   3437   
  3433   3438   /*
  3434   3439   ** This macro is used inside of assert() statements to indicate that
  3435   3440   ** the assert is only valid on a well-formed database.  Instead of:

Changes to src/test1.c.

  6325   6325     sqlite3_test_control(SQLITE_TESTCTRL_PRNG_RESET);
  6326   6326     return TCL_OK;
  6327   6327   }
  6328   6328   
  6329   6329   /*
  6330   6330   ** tclcmd:  database_may_be_corrupt
  6331   6331   **
  6332         -** Indicate that database files might be corrupt.  In other words, set the normal
         6332  +** Indicate that database files might be corrupt. In other words, set the normal
  6333   6333   ** state of operation.
  6334   6334   */
  6335   6335   static int SQLITE_TCLAPI database_may_be_corrupt(
  6336   6336     ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
  6337   6337     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
  6338   6338     int objc,              /* Number of arguments */
  6339   6339     Tcl_Obj *CONST objv[]  /* Command arguments */
................................................................................
  6340   6340   ){
  6341   6341     sqlite3_test_control(SQLITE_TESTCTRL_NEVER_CORRUPT, 0);
  6342   6342     return TCL_OK;
  6343   6343   }
  6344   6344   /*
  6345   6345   ** tclcmd:  database_never_corrupt
  6346   6346   **
  6347         -** Indicate that database files are always well-formed.  This enables extra assert()
  6348         -** statements that test conditions that are always true for well-formed databases.
         6347  +** Indicate that database files are always well-formed. This enables
         6348  +** extra assert() statements that test conditions that are always true
         6349  +** for well-formed databases.
  6349   6350   */
  6350   6351   static int SQLITE_TCLAPI database_never_corrupt(
  6351   6352     ClientData clientData, /* Pointer to sqlite3_enable_XXX function */
  6352   6353     Tcl_Interp *interp,    /* The TCL interpreter that invoked this command */
  6353   6354     int objc,              /* Number of arguments */
  6354   6355     Tcl_Obj *CONST objv[]  /* Command arguments */
  6355   6356   ){
................................................................................
  6707   6708     int objc,
  6708   6709     Tcl_Obj *CONST objv[]
  6709   6710   ){
  6710   6711     struct Verb {
  6711   6712       const char *zName;
  6712   6713       int i;
  6713   6714     } aVerb[] = {
  6714         -    { "SQLITE_TESTCTRL_LOCALTIME_FAULT", SQLITE_TESTCTRL_LOCALTIME_FAULT }, 
  6715         -    { "SQLITE_TESTCTRL_SORTER_MMAP",     SQLITE_TESTCTRL_SORTER_MMAP     }, 
  6716         -    { "SQLITE_TESTCTRL_IMPOSTER",        SQLITE_TESTCTRL_IMPOSTER        },
         6715  +    { "SQLITE_TESTCTRL_LOCALTIME_FAULT",    SQLITE_TESTCTRL_LOCALTIME_FAULT }, 
         6716  +    { "SQLITE_TESTCTRL_SORTER_MMAP",        SQLITE_TESTCTRL_SORTER_MMAP     }, 
         6717  +    { "SQLITE_TESTCTRL_IMPOSTER",           SQLITE_TESTCTRL_IMPOSTER        },
         6718  +    { "SQLITE_TESTCTRL_INTERNAL_FUNCTIONS", SQLITE_TESTCTRL_INTERNAL_FUNCTIONS},
  6717   6719     };
  6718   6720     int iVerb;
  6719   6721     int iFlag;
  6720   6722     int rc;
  6721   6723   
  6722   6724     if( objc<2 ){
  6723   6725       Tcl_WrongNumArgs(interp, 1, objv, "VERB ARGS...");
................................................................................
  6727   6729     rc = Tcl_GetIndexFromObjStruct(
  6728   6730         interp, objv[1], aVerb, sizeof(aVerb[0]), "VERB", 0, &iVerb
  6729   6731     );
  6730   6732     if( rc!=TCL_OK ) return rc;
  6731   6733   
  6732   6734     iFlag = aVerb[iVerb].i;
  6733   6735     switch( iFlag ){
         6736  +    case SQLITE_TESTCTRL_INTERNAL_FUNCTIONS:
  6734   6737       case SQLITE_TESTCTRL_LOCALTIME_FAULT: {
  6735   6738         int val;
  6736   6739         if( objc!=3 ){
  6737   6740           Tcl_WrongNumArgs(interp, 2, objv, "ONOFF");
  6738   6741           return TCL_ERROR;
  6739   6742         }
  6740   6743         if( Tcl_GetBooleanFromObj(interp, objv[2], &val) ) return TCL_ERROR;
  6741         -      sqlite3_test_control(SQLITE_TESTCTRL_LOCALTIME_FAULT, val);
         6744  +      sqlite3_test_control(iFlag, val);
  6742   6745         break;
  6743   6746       }
  6744   6747   
  6745   6748       case SQLITE_TESTCTRL_SORTER_MMAP: {
  6746   6749         int val;
  6747   6750         sqlite3 *db;
  6748   6751         if( objc!=4 ){

Changes to test/alter.test.

   680    680     }
   681    681   } {1 18 2 9}
   682    682   
   683    683   #--------------------------------------------------------------------------
   684    684   # alter-9.X - Special test: Make sure the sqlite_rename_column() and
   685    685   # rename_table() functions do not crash when handed bad input.
   686    686   #
          687  +sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 1
   687    688   do_test alter-9.1 {
   688    689     execsql {SELECT SQLITE_RENAME_COLUMN(0,0,0,0,0,0,0,0,0)}
   689    690   } {{}}
   690    691   foreach {tn sql} {
   691    692       1 { SELECT SQLITE_RENAME_TABLE(0,0,0,0,0,0,0) }
   692    693       2 { SELECT SQLITE_RENAME_TABLE(10,20,30,40,50,60,70) }
   693    694       3 { SELECT SQLITE_RENAME_TABLE('foo','foo','foo','foo','foo','foo','foo') }
   694    695   } {
   695    696     do_test alter-9.2.$tn {
   696    697       catch { execsql $sql }
   697    698     } 1
   698    699   }
          700  +sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 0
          701  +
          702  +# If the INTERNAL_FUNCTIONS test-control is disabled (which is the default),
          703  +# then the sqlite_rename_table() SQL function is not accessible to ordinary SQL.
          704  +#
          705  +do_catchsql_test alter-9.3 {
          706  +  SELECT sqlite_rename_table(0,0,0,0,0,0,0);
          707  +} {1 {no such function: sqlite_rename_table}}
   699    708   
   700    709   #------------------------------------------------------------------------
   701    710   # alter-10.X - Make sure ALTER TABLE works with multi-byte UTF-8 characters 
   702    711   # in the names.
   703    712   #
   704    713   do_test alter-10.1 {
   705    714     execsql "CREATE TABLE xyz(x UNIQUE)"

Changes to test/altercol.test.

   614    614       ALTER TABLE x1 RENAME COLUMN t TO ttt;
   615    615     } "1 {error in trigger tr1: $error}"
   616    616   }
   617    617   
   618    618   #-------------------------------------------------------------------------
   619    619   # Passing invalid parameters directly to sqlite_rename_column().
   620    620   #
          621  +sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 1
   621    622   do_execsql_test 14.1 {
   622    623     CREATE TABLE ddd(sql, type, object, db, tbl, icol, znew, bquote);
   623    624     INSERT INTO ddd VALUES(
   624    625         'CREATE TABLE x1(i INTEGER, t TEXT)',
   625    626         'table', 'x1', 'main', 'x1', -1, 'zzz', 0
   626    627     ), (
   627    628         'CREATE TABLE x1(i INTEGER, t TEXT)',
................................................................................
   636    637   } {}
   637    638   
   638    639   do_execsql_test 14.2 {
   639    640     SELECT 
   640    641     sqlite_rename_column(sql, type, object, db, tbl, icol, znew, bquote, 0)
   641    642     FROM ddd;
   642    643   } {{} {} {} {}}
          644  +sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 0
          645  +
          646  +# If the INTERNAL_FUNCTIONS test-control is disabled (which is the default)
          647  +# then the sqlite_rename_table() SQL function is not accessible to
          648  +# ordinary SQL.
          649  +#
          650  +do_catchsql_test 14.3 {
          651  +  SELECT sqlite_rename_column(0,0,0,0,0,0,0,0,0);
          652  +} {1 {no such function: sqlite_rename_column}}
   643    653   
   644    654   #-------------------------------------------------------------------------
   645    655   #
   646    656   reset_db
   647    657   do_execsql_test 15.0 {
   648    658     CREATE TABLE xxx(a, b, c);
   649    659     SELECT a AS d FROM xxx WHERE d=0;

Changes to test/altertab.test.

   236    236       ), (
   237    237           'main', 'CREATE TABLE x1(i INTEGER, t TEXT)', NULL, 'eee', 0
   238    238       ), (
   239    239           'main', NULL, 'ddd', 'eee', 0
   240    240       );
   241    241     } {}
   242    242     
          243  +  sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 1
   243    244     do_execsql_test 7.2 {
   244    245       SELECT 
   245    246       sqlite_rename_table(db, 0, 0, sql, zOld, zNew, bTemp)
   246    247       FROM ddd;
   247    248     } {{} {} {}}
          249  +  sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 0
   248    250   }
   249    251   
   250    252   #-------------------------------------------------------------------------
   251    253   #
   252    254   reset_db
   253    255   forcedelete test.db2
   254    256   do_execsql_test 8.1 {

Changes to test/attach.test.

   722    722       catchsql {
   723    723         CREATE TRIGGER r5 AFTER INSERT ON t5 BEGIN
   724    724           DELETE FROM t1 WHERE x<(SELECT min(x) FROM temp.t6);
   725    725         END;
   726    726       } db2
   727    727     } {1 {trigger r5 cannot reference objects in database temp}}
   728    728   } ;# endif subquery
   729         -ifcapable json1 {
          729  +ifcapable json1&&vtab {
   730    730     do_test attach-5.10 {
   731    731       db close
   732    732       catch {db2 close}
   733    733       forcedelete test.db
   734    734       sqlite3 db test.db
   735    735       db eval {
   736    736         CREATE TABLE t1(x);

Changes to test/fkey2.test.

   983    983     # Test the sqlite_rename_parent() function directly.
   984    984     #
   985    985     proc test_rename_parent {zCreate zOld zNew} {
   986    986       db eval {SELECT sqlite_rename_table(
   987    987           'main', 'table', 't1', $zCreate, $zOld, $zNew, 0
   988    988       )}
   989    989     }
          990  +  sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 1
   990    991     do_test fkey2-14.2.1.1 {
   991    992       test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3
   992    993     } {{CREATE TABLE t1(a REFERENCES "t3")}}
   993    994     do_test fkey2-14.2.1.2 {
   994    995       test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3
   995    996     } {{CREATE TABLE t1(a REFERENCES t2)}}
   996    997     do_test fkey2-14.2.1.3 {
   997    998       test_rename_parent {CREATE TABLE t1(a REFERENCES "t2")} t2 t3
   998    999     } {{CREATE TABLE t1(a REFERENCES "t3")}}
         1000  +  sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 0
   999   1001     
  1000   1002     # Test ALTER TABLE RENAME TABLE a bit.
  1001   1003     #
  1002   1004     do_test fkey2-14.2.2.1 {
  1003   1005       drop_all_tables
  1004   1006       execsql {
  1005   1007         CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1);
................................................................................
  1064   1066         PRAGMA foreign_keys = off;
  1065   1067         ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;
  1066   1068         PRAGMA foreign_keys = on;
  1067   1069         SELECT sql FROM temp.sqlite_master WHERE name='t2';
  1068   1070       }
  1069   1071     } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}
  1070   1072   
         1073  +  sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 1
  1071   1074     do_test fkey2-14.2tmp.1.1 {
  1072   1075       test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3
  1073   1076     } {{CREATE TABLE t1(a REFERENCES "t3")}}
  1074   1077     do_test fkey2-14.2tmp.1.2 {
  1075   1078       test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3
  1076   1079     } {{CREATE TABLE t1(a REFERENCES t2)}}
  1077   1080     do_test fkey2-14.2tmp.1.3 {
  1078   1081       test_rename_parent {CREATE TABLE t1(a REFERENCES "t2")} t2 t3
  1079   1082     } {{CREATE TABLE t1(a REFERENCES "t3")}}
         1083  +  sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 0
  1080   1084     
  1081   1085     # Test ALTER TABLE RENAME TABLE a bit.
  1082   1086     #
  1083   1087     do_test fkey2-14.2tmp.2.1 {
  1084   1088       drop_all_tables
  1085   1089       execsql {
  1086   1090         CREATE TEMP TABLE t1(a PRIMARY KEY, b REFERENCES t1);
................................................................................
  1146   1150         PRAGMA foreign_keys = off;
  1147   1151         ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;
  1148   1152         PRAGMA foreign_keys = on;
  1149   1153         SELECT sql FROM aux.sqlite_master WHERE name='t2';
  1150   1154       }
  1151   1155     } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}
  1152   1156   
         1157  +  sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 1
  1153   1158     do_test fkey2-14.2aux.1.1 {
  1154   1159       test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3
  1155   1160     } {{CREATE TABLE t1(a REFERENCES "t3")}}
  1156   1161     do_test fkey2-14.2aux.1.2 {
  1157   1162       test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3
  1158   1163     } {{CREATE TABLE t1(a REFERENCES t2)}}
  1159   1164     do_test fkey2-14.2aux.1.3 {
  1160   1165       test_rename_parent {CREATE TABLE t1(a REFERENCES "t2")} t2 t3
  1161   1166     } {{CREATE TABLE t1(a REFERENCES "t3")}}
         1167  +  sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 0
  1162   1168     
  1163   1169     # Test ALTER TABLE RENAME TABLE a bit.
  1164   1170     #
  1165   1171     do_test fkey2-14.2aux.2.1 {
  1166   1172       drop_all_tables
  1167   1173       execsql {
  1168   1174         CREATE TABLE aux.t1(a PRIMARY KEY, b REFERENCES t1);

Changes to test/incrvacuum.test.

   784    784   } {ok}
   785    785   
   786    786   #-------------------------------------------------------------------------
   787    787   # At one point it was unsafe to truncate a db file on windows while there
   788    788   # were outstanding xFetch() references. This test case attempts to hit
   789    789   # that case.
   790    790   #
   791         -reset_db
   792         -do_execsql_test incrvacuum-16.0 {
   793         -  PRAGMA auto_vacuum = 2;
   794         -  CREATE TABLE t3(a);
   795         -  INSERT INTO t3 VALUES(1), (2), (3), (4);
   796         -
   797         -  CREATE TABLE t2(x);
   798         -  INSERT INTO t2 VALUES( randomblob(1000) );
   799         -  INSERT INTO t2 VALUES( randomblob(1000) );
   800         -  INSERT INTO t2 VALUES( randomblob(1000) );
   801         -  INSERT INTO t2 VALUES( randomblob(1000) );
   802         -  INSERT INTO t2 VALUES( randomblob(1000) );
   803         -  INSERT INTO t2 VALUES( randomblob(1000) );
   804         -} {}
   805         -
   806         -# Reopen db to ensure the page-cache is empty.
   807         -#
   808         -db close
   809         -sqlite3 db test.db
   810         -
   811         -# Open db in mmap-mode. Open a transaction, delete some data, then run
   812         -# incremental-vacuum. Do not commit the transaction. 
   813         -#
   814         -do_execsql_test incrvacuum-16.1 {
   815         -  PRAGMA mmap_size = 1000000;
   816         -  BEGIN;
   817         -  DELETE FROM t2;
   818         -  PRAGMA incremental_vacuum = 1000;
   819         -} {1000000}
          791  +ifcapable mmap {
          792  +  reset_db
          793  +  do_execsql_test incrvacuum-16.0 {
          794  +    PRAGMA auto_vacuum = 2;
          795  +    CREATE TABLE t3(a);
          796  +    INSERT INTO t3 VALUES(1), (2), (3), (4);
          797  +  
          798  +    CREATE TABLE t2(x);
          799  +    INSERT INTO t2 VALUES( randomblob(1000) );
          800  +    INSERT INTO t2 VALUES( randomblob(1000) );
          801  +    INSERT INTO t2 VALUES( randomblob(1000) );
          802  +    INSERT INTO t2 VALUES( randomblob(1000) );
          803  +    INSERT INTO t2 VALUES( randomblob(1000) );
          804  +    INSERT INTO t2 VALUES( randomblob(1000) );
          805  +  } {}
          806  +  
          807  +  # Reopen db to ensure the page-cache is empty.
          808  +  #
          809  +  db close
          810  +  sqlite3 db test.db
          811  +  
          812  +  # Open db in mmap-mode. Open a transaction, delete some data, then run
          813  +  # incremental-vacuum. Do not commit the transaction. 
          814  +  #
          815  +  do_execsql_test incrvacuum-16.1 {
          816  +    PRAGMA mmap_size = 1000000;
          817  +    BEGIN;
          818  +    DELETE FROM t2;
          819  +    PRAGMA incremental_vacuum = 1000;
          820  +  } {1000000}
   820    821   
   821         -# Scan through table t3 (which is all clean pages - so mmap is used). Then,
   822         -# midway through, commit the transaction. This causes the db to be truncated
   823         -# while there are outstanding xFetch pages.
   824         -#
   825         -do_test incrvacuum-16.2 {
   826         -  set res [list]
   827         -  db eval { SELECT a FROM t3 } {
   828         -    if {$a==3} { db eval COMMIT }
   829         -    lappend res $a
   830         -  }
   831         -  set res
   832         -} {1 2 3 4}
   833         -
          822  +  # Scan through table t3 (which is all clean pages - so mmap is used). Then,
          823  +  # midway through, commit the transaction. This causes the db to be truncated
          824  +  # while there are outstanding xFetch pages.
          825  +  #
          826  +  do_test incrvacuum-16.2 {
          827  +    set res [list]
          828  +    db eval { SELECT a FROM t3 } {
          829  +      if {$a==3} { db eval COMMIT }
          830  +      lappend res $a
          831  +    }
          832  +    set res
          833  +  } {1 2 3 4}
          834  +}
          835  +  
   834    836   finish_test

Changes to test/indexexpr2.test.

   197    197     set ::cnt
   198    198     # Refcnt() should not be invoked because that index does not change.
   199    199   } {0}
   200    200   
   201    201   # Additional test cases to show that UPDATE does not modify indexes that
   202    202   # do not involve unchanged columns.
   203    203   #
   204         -load_static_extension db explain
   205         -do_execsql_test 4.200 {
   206         -  CREATE TABLE t2(a,b,c,d,e,f);
   207         -  INSERT INTO t2 VALUES(2,3,4,5,6,7);
   208         -  CREATE INDEX t2abc ON t2(a+b+c);
   209         -  CREATE INDEX t2cd ON t2(c*d);
   210         -  CREATE INDEX t2def ON t2(d,e+25*f);
   211         -  SELECT sqlite_master.name 
   212         -    FROM sqlite_master, explain('UPDATE t2 SET b=b+1')
   213         -   WHERE explain.opcode LIKE 'Open%'
   214         -     AND sqlite_master.rootpage=explain.p2
   215         -   ORDER BY 1;
   216         -} {t2 t2abc}
   217         -do_execsql_test 4.210 {
   218         -  SELECT sqlite_master.name 
   219         -    FROM sqlite_master, explain('UPDATE t2 SET c=c+1')
   220         -   WHERE explain.opcode LIKE 'Open%'
   221         -     AND sqlite_master.rootpage=explain.p2
   222         -   ORDER BY 1;
   223         -} {t2 t2abc t2cd}
   224         -do_execsql_test 4.220 {
   225         -  SELECT sqlite_master.name 
   226         -    FROM sqlite_master, explain('UPDATE t2 SET c=c+1, f=NULL')
   227         -   WHERE explain.opcode LIKE 'Open%'
   228         -     AND sqlite_master.rootpage=explain.p2
   229         -   ORDER BY 1;
   230         -} {t2 t2abc t2cd t2def}
          204  +ifcapable vtab {
          205  +  load_static_extension db explain
          206  +  do_execsql_test 4.200 {
          207  +    CREATE TABLE t2(a,b,c,d,e,f);
          208  +    INSERT INTO t2 VALUES(2,3,4,5,6,7);
          209  +    CREATE INDEX t2abc ON t2(a+b+c);
          210  +    CREATE INDEX t2cd ON t2(c*d);
          211  +    CREATE INDEX t2def ON t2(d,e+25*f);
          212  +    SELECT sqlite_master.name 
          213  +      FROM sqlite_master, explain('UPDATE t2 SET b=b+1')
          214  +     WHERE explain.opcode LIKE 'Open%'
          215  +       AND sqlite_master.rootpage=explain.p2
          216  +     ORDER BY 1;
          217  +  } {t2 t2abc}
          218  +  do_execsql_test 4.210 {
          219  +    SELECT sqlite_master.name 
          220  +      FROM sqlite_master, explain('UPDATE t2 SET c=c+1')
          221  +     WHERE explain.opcode LIKE 'Open%'
          222  +       AND sqlite_master.rootpage=explain.p2
          223  +     ORDER BY 1;
          224  +  } {t2 t2abc t2cd}
          225  +  do_execsql_test 4.220 {
          226  +    SELECT sqlite_master.name 
          227  +      FROM sqlite_master, explain('UPDATE t2 SET c=c+1, f=NULL')
          228  +     WHERE explain.opcode LIKE 'Open%'
          229  +       AND sqlite_master.rootpage=explain.p2
          230  +     ORDER BY 1;
          231  +  } {t2 t2abc t2cd t2def}
          232  +}
   231    233   
   232    234   
   233    235   finish_test

Added test/lemon-test01.y.

            1  +// A test case for the LEMON parser generator.  Run as follows:
            2  +//
            3  +//     lemon lemon-test01.y && gcc -g lemon-test01.c && ./a.out
            4  +//
            5  +%token_prefix TK_
            6  +%token_type   int
            7  +%default_type int
            8  +%include {
            9  +  static int nSyntaxError = 0;
           10  +  static int nAccept = 0;
           11  +  static int nFailure = 0;
           12  +}
           13  +
           14  +all ::=  A B.
           15  +all ::=  error B.
           16  +
           17  +%syntax_error {
           18  +  nSyntaxError++;
           19  +}
           20  +%parse_accept {
           21  +  nAccept++;
           22  +}
           23  +%parse_failure {
           24  +  nFailure++;
           25  +}
           26  +%code {
           27  +  #include <assert.h>
           28  +  #include "lemon-test01.h"
           29  +  static int nTest = 0;
           30  +  static int nErr = 0;
           31  +  static int testCase(int testId, int shouldBe, int actual){
           32  +    nTest++;
           33  +    if( shouldBe==actual ){
           34  +      printf("test %d: ok\n", testId);
           35  +    }else{
           36  +      printf("test %d: got %d, expected %d\n", testId, actual, shouldBe);
           37  +      nErr++;
           38  +    }
           39  +  }
           40  +  int main(int argc, char **argv){
           41  +    yyParser xp;
           42  +    ParseInit(&xp);
           43  +    Parse(&xp, TK_A, 0);
           44  +    Parse(&xp, TK_B, 0);
           45  +    Parse(&xp, 0, 0);
           46  +    ParseFinalize(&xp);
           47  +    testCase(100, 0, nSyntaxError);
           48  +    testCase(110, 1, nAccept);
           49  +    testCase(120, 0, nFailure);
           50  +    nSyntaxError = nAccept = nFailure = 0;
           51  +    ParseInit(&xp);
           52  +    Parse(&xp, TK_B, 0);
           53  +    Parse(&xp, TK_B, 0);
           54  +    Parse(&xp, 0, 0);
           55  +    ParseFinalize(&xp);
           56  +    testCase(200, 1, nSyntaxError);
           57  +    testCase(210, 1, nAccept);
           58  +    testCase(220, 0, nFailure);
           59  +    nSyntaxError = nAccept = nFailure = 0;
           60  +    ParseInit(&xp);
           61  +    Parse(&xp, TK_A, 0);
           62  +    Parse(&xp, TK_A, 0);
           63  +    Parse(&xp, 0, 0);
           64  +    ParseFinalize(&xp);
           65  +    testCase(200, 1, nSyntaxError);
           66  +    testCase(210, 0, nAccept);
           67  +    testCase(220, 0, nFailure);
           68  +    if( nErr==0 ){
           69  +      printf("%d tests pass\n", nTest);
           70  +    }else{
           71  +      printf("%d errors out %d tests\n", nErr, nTest);
           72  +    }
           73  +    return nErr;
           74  +  }
           75  +}

Changes to test/pragma4.test.

   118    118   }
   119    119   do_test 4.1.4 { 
   120    120     sqlite3 db3 test.db
   121    121     sqlite3 db2 test.db2
   122    122     execsql { DROP TABLE t1 } db3
   123    123     execsql { DROP TABLE t2 } db2
   124    124   } {}
   125         -do_execsql_test 4.1.5 { PRAGMA table_info = t1 }
   126         -do_execsql_test 4.1.6 { PRAGMA table_info = t2 }
          125  +do_execsql_test 4.1.5 { PRAGMA table_info(t1) }
          126  +do_execsql_test 4.1.6 { PRAGMA table_info(t2) }
   127    127   
   128    128   db2 close
   129    129   db3 close
   130    130   reset_db
   131    131   forcedelete test.db2
   132    132   do_execsql_test 4.2.1 {
   133    133     CREATE TABLE t1(a, b, c);
   134    134     ATTACH 'test.db2' AS aux;
   135    135     CREATE TABLE aux.t2(d, e, f);
   136    136   }
   137         -do_execsql_test 4.2.2 { SELECT * FROM pragma_table_info('t1') } {
   138         -  0 a {} 0 {} 0 1 b {} 0 {} 0 2 c {} 0 {} 0
   139         -}
   140         -do_execsql_test 4.2.3 { SELECT * FROM pragma_table_info('t2') } {
   141         -  0 d {} 0 {} 0 1 e {} 0 {} 0 2 f {} 0 {} 0
          137  +ifcapable vtab {
          138  +  do_execsql_test 4.2.2 { SELECT * FROM pragma_table_info('t1') } {
          139  +    0 a {} 0 {} 0 1 b {} 0 {} 0 2 c {} 0 {} 0
          140  +  }
          141  +  do_execsql_test 4.2.3 { SELECT * FROM pragma_table_info('t2') } {
          142  +    0 d {} 0 {} 0 1 e {} 0 {} 0 2 f {} 0 {} 0
          143  +  }
   142    144   }
   143    145   do_test 4.2.4 { 
   144    146     sqlite3 db3 test.db
   145    147     sqlite3 db2 test.db2
   146    148     execsql { DROP TABLE t1 } db3
   147    149     execsql { DROP TABLE t2 } db2
   148    150   } {}
   149         -do_execsql_test 4.2.5 { SELECT * FROM pragma_table_info('t1') } 
   150         -do_execsql_test 4.2.6 { SELECT * FROM pragma_table_info('t2') } 
          151  +ifcapable vtab {
          152  +  do_execsql_test 4.2.5 { SELECT * FROM pragma_table_info('t1') } 
          153  +  do_execsql_test 4.2.6 { SELECT * FROM pragma_table_info('t2') } 
          154  +}
   151    155   
   152    156   db2 close
   153    157   db3 close
   154    158   reset_db
   155    159   forcedelete test.db2
   156    160   do_execsql_test 4.3.1 {
   157    161     CREATE TABLE t1(a, b, c);
   158    162     CREATE INDEX i1 ON t1(b);
   159    163     ATTACH 'test.db2' AS aux;
   160    164     CREATE TABLE aux.t2(d, e, f);
   161    165     CREATE INDEX aux.i2 ON t2(e);
   162    166   }
   163         -do_execsql_test 4.3.2 { SELECT * FROM pragma_index_info('i1') } {0 1 b}
   164         -do_execsql_test 4.3.3 { SELECT * FROM pragma_index_info('i2') } {0 1 e}
          167  +ifcapable vtab {
          168  +  do_execsql_test 4.3.2 { SELECT * FROM pragma_index_info('i1') } {0 1 b}
          169  +  do_execsql_test 4.3.3 { SELECT * FROM pragma_index_info('i2') } {0 1 e}
          170  +}
   165    171   do_test 4.3.4 { 
   166    172     sqlite3 db3 test.db
   167    173     sqlite3 db2 test.db2
   168    174     execsql { DROP INDEX i1 } db3
   169    175     execsql { DROP INDEX i2 } db2
   170    176   } {}
   171         -do_execsql_test 4.3.5 { SELECT * FROM pragma_index_info('i1') } 
   172         -do_execsql_test 4.3.6 { SELECT * FROM pragma_index_info('i2') } 
          177  +ifcapable vtab {
          178  +  do_execsql_test 4.3.5 { SELECT * FROM pragma_index_info('i1') } 
          179  +  do_execsql_test 4.3.6 { SELECT * FROM pragma_index_info('i2') } 
          180  +}
   173    181   
          182  +execsql {SELECT * FROM main.sqlite_master, aux.sqlite_master}
   174    183   do_execsql_test 4.4.0 {
   175    184     CREATE INDEX main.i1 ON t1(b, c);
   176    185     CREATE INDEX aux.i2 ON t2(e, f);
   177    186   }
   178         -do_execsql_test 4.4.1 { SELECT * FROM pragma_index_list('t1') } {0 i1 0 c 0}
   179         -do_execsql_test 4.4.2 { SELECT * FROM pragma_index_list('t2') } {0 i2 0 c 0}
          187  +ifcapable vtab {
          188  +  do_execsql_test 4.4.1 { SELECT * FROM pragma_index_list('t1') } {0 i1 0 c 0}
          189  +  do_execsql_test 4.4.2 { SELECT * FROM pragma_index_list('t2') } {0 i2 0 c 0}
          190  +}
   180    191   do_test 4.4.3 { 
   181    192     execsql { DROP INDEX i1 } db3
   182    193     execsql { DROP INDEX i2 } db2
   183    194   } {}
   184         -do_execsql_test 4.4.5 { SELECT * FROM pragma_index_list('t1') } {}
   185         -do_execsql_test 4.4.6 { SELECT * FROM pragma_index_list('t2') } {}
          195  +ifcapable vtab {
          196  +  do_execsql_test 4.4.5 { SELECT * FROM pragma_index_list('t1') } {}
          197  +  do_execsql_test 4.4.6 { SELECT * FROM pragma_index_list('t2') } {}
          198  +}
          199  +execsql {SELECT * FROM main.sqlite_master, aux.sqlite_master}
   186    200   
   187    201   do_execsql_test 4.5.0 {
   188    202     CREATE UNIQUE INDEX main.i1 ON t1(a);
   189    203     CREATE UNIQUE INDEX aux.i2 ON t2(d);
   190    204     CREATE TABLE main.c1 (a, b, c REFERENCES t1(a));
   191    205     CREATE TABLE aux.c2 (d, e, r REFERENCES t2(d));
   192    206   }
   193         -do_execsql_test 4.5.1 { SELECT * FROM pragma_foreign_key_list('c1') } {
   194         -  0 0 t1 c a {NO ACTION} {NO ACTION} NONE
   195         -}
   196         -do_execsql_test 4.5.2 { SELECT * FROM pragma_foreign_key_list('c2') } {
   197         -  0 0 t2 r d {NO ACTION} {NO ACTION} NONE
          207  +ifcapable vtab {
          208  +  do_execsql_test 4.5.1 { SELECT * FROM pragma_foreign_key_list('c1') } {
          209  +    0 0 t1 c a {NO ACTION} {NO ACTION} NONE
          210  +  }
          211  +  do_execsql_test 4.5.2 { SELECT * FROM pragma_foreign_key_list('c2') } {
          212  +    0 0 t2 r d {NO ACTION} {NO ACTION} NONE
          213  +  }
   198    214   }
   199    215   do_test 4.5.3 { 
   200    216     execsql { DROP TABLE c1 } db3
   201    217     execsql { DROP TABLE c2 } db2
   202    218   } {}
   203         -do_execsql_test 4.5.1 { SELECT * FROM pragma_foreign_key_list('c1') }
   204         -do_execsql_test 4.5.2 { SELECT * FROM pragma_foreign_key_list('c2') } 
          219  +ifcapable vtab {
          220  +  do_execsql_test 4.5.4 { SELECT * FROM pragma_foreign_key_list('c1') }
          221  +  do_execsql_test 4.5.5 { SELECT * FROM pragma_foreign_key_list('c2') } 
          222  +}
          223  +execsql {SELECT * FROM main.sqlite_master, aux.sqlite_master}
   205    224   
   206    225   do_execsql_test 4.6.0 {
   207    226     CREATE TABLE main.c1 (a, b, c REFERENCES t1(a));
   208    227     CREATE TABLE aux.c2 (d, e, r REFERENCES t2(d));
   209    228     INSERT INTO main.c1 VALUES(1, 2, 3);
   210    229     INSERT INTO aux.c2 VALUES(4, 5, 6);
   211    230   }
................................................................................
   220    239   } {}
   221    240   do_execsql_test 4.6.4 { pragma foreign_key_check('c1') } {c1 1 t1 0}
   222    241   do_catchsql_test 4.6.5 { 
   223    242     pragma foreign_key_check('c2') 
   224    243   } {1 {no such table: c2}}
   225    244   
   226    245   finish_test
   227         -

Changes to test/releasetest.tcl.

    75     75       -DHAVE_UTIME=0
    76     76     }
    77     77     "Unlock-Notify" {
    78     78       -O2
    79     79       -DSQLITE_ENABLE_UNLOCK_NOTIFY
    80     80       -DSQLITE_THREADSAFE
    81     81       -DSQLITE_TCL_DEFAULT_FULLMUTEX=1
           82  +  }
           83  +  "User-Auth" {
           84  +    -O2
    82     85       -DSQLITE_USER_AUTHENTICATION=1
    83     86     }
    84     87     "Secure-Delete" {
    85     88       -O2
    86     89       -DSQLITE_SECURE_DELETE=1
    87     90       -DSQLITE_SOUNDEX=1
    88     91     }
................................................................................
   270    273     Linux-x86_64 {
   271    274       "Check-Symbols"           checksymbols
   272    275       "Fast-One"                "fuzztest test"
   273    276       "Debug-One"               "mptest test"
   274    277       "Have-Not"                test
   275    278       "Secure-Delete"           test
   276    279       "Unlock-Notify"           "QUICKTEST_INCLUDE=notify2.test test"
          280  +    "User-Auth"               tcltest
   277    281       "Update-Delete-Limit"     test
   278    282       "Extra-Robustness"        test
   279    283       "Device-Two"              test
   280    284       "No-lookaside"            test
   281    285       "Devkit"                  test
   282    286       "Apple"                   test
   283    287       "Sanitize"                {QUICKTEST_OMIT=func4.test,nan.test test}

Changes to test/vtab_err.test.

    16     16   
    17     17   ifcapable !vtab {
    18     18     finish_test
    19     19     return
    20     20   }
    21     21   
    22     22   
    23         -
    24     23   unset -nocomplain echo_module_begin_fail
    25     24   do_ioerr_test vtab_err-1 -tclprep {
    26     25     register_echo_module [sqlite3_connection_pointer db]
    27     26   } -sqlbody {
    28     27     BEGIN;
    29     28     CREATE TABLE r(a PRIMARY KEY, b, c);
    30     29     CREATE VIRTUAL TABLE e USING echo(r);
................................................................................
    58     57       CREATE TABLE r2(a, b, c);
    59     58       INSERT INTO r2 SELECT * FROM e;
    60     59       INSERT INTO e SELECT a||'x', b, c FROM r2;
    61     60     COMMIT;
    62     61   } 
    63     62   
    64     63   sqlite3_memdebug_fail -1
           64  +
           65  +reset_db
           66  +register_echo_module [sqlite3_connection_pointer db]
           67  +do_execsql_test vtab_err-3.0 {
           68  +  CREATE TABLE r(a PRIMARY KEY, b, c);
           69  +  CREATE VIRTUAL TABLE e USING echo(r);
           70  +}
           71  +faultsim_save_and_close
           72  +
           73  +do_faultsim_test vtab_err-3 -faults oom-t* -prep {
           74  +  faultsim_restore_and_reopen
           75  +  register_echo_module [sqlite3_connection_pointer db]
           76  +} -body {
           77  +  execsql {
           78  +    BEGIN;
           79  +      CREATE TABLE xyz(x);
           80  +      SELECT a FROM e;
           81  +    COMMIT;
           82  +  }
           83  +} -test {
           84  +  faultsim_test_result {0 {}}
           85  +}
    65     86   
    66     87   finish_test

Changes to test/without_rowid3.test.

   949    949     # Test the sqlite_rename_parent() function directly.
   950    950     #
   951    951     proc test_rename_parent {zCreate zOld zNew} {
   952    952       db eval {SELECT sqlite_rename_table(
   953    953           'main', 'table', 't1', $zCreate, $zOld, $zNew, 0
   954    954       )}
   955    955     }
          956  +  sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 1
   956    957     do_test without_rowid3-14.2.1.1 {
   957    958       test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3
   958    959     } {{CREATE TABLE t1(a REFERENCES "t3")}}
   959    960     do_test without_rowid3-14.2.1.2 {
   960    961       test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3
   961    962     } {{CREATE TABLE t1(a REFERENCES t2)}}
   962    963     do_test without_rowid3-14.2.1.3 {
   963    964       test_rename_parent {CREATE TABLE t1(a REFERENCES "t2")} t2 t3
   964    965     } {{CREATE TABLE t1(a REFERENCES "t3")}}
          966  +  sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 0
   965    967     
   966    968     # Test ALTER TABLE RENAME TABLE a bit.
   967    969     #
   968    970     do_test without_rowid3-14.2.2.1 {
   969    971       drop_all_tables
   970    972       execsql {
   971    973         CREATE TABLE t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid;
................................................................................
  1033   1035         PRAGMA foreign_keys = off;
  1034   1036         ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;
  1035   1037         PRAGMA foreign_keys = on;
  1036   1038         SELECT sql FROM temp.sqlite_master WHERE name='t2';
  1037   1039       }
  1038   1040     } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}
  1039   1041   
         1042  +  sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 1
  1040   1043     do_test without_rowid3-14.2tmp.1.1 {
  1041   1044       test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3
  1042   1045     } {{CREATE TABLE t1(a REFERENCES "t3")}}
  1043   1046     do_test without_rowid3-14.2tmp.1.2 {
  1044   1047       test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3
  1045   1048     } {{CREATE TABLE t1(a REFERENCES t2)}}
  1046   1049     do_test without_rowid3-14.2tmp.1.3 {
  1047   1050       test_rename_parent {CREATE TABLE t1(a REFERENCES "t2")} t2 t3
  1048   1051     } {{CREATE TABLE t1(a REFERENCES "t3")}}
         1052  +  sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 0
  1049   1053     
  1050   1054     # Test ALTER TABLE RENAME TABLE a bit.
  1051   1055     #
  1052   1056     do_test without_rowid3-14.2tmp.2.1 {
  1053   1057       drop_all_tables
  1054   1058       execsql {
  1055   1059         CREATE TEMP TABLE t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid;
................................................................................
  1118   1122         PRAGMA foreign_keys = off;
  1119   1123         ALTER TABLE t2 ADD COLUMN h DEFAULT 'text' REFERENCES t1;
  1120   1124         PRAGMA foreign_keys = on;
  1121   1125         SELECT sql FROM aux.sqlite_master WHERE name='t2';
  1122   1126       }
  1123   1127     } {{CREATE TABLE t2(a, b, c REFERENCES t1, d DEFAULT NULL REFERENCES t1, e REFERENCES t1 DEFAULT NULL, h DEFAULT 'text' REFERENCES t1)}}
  1124   1128   
         1129  +  sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 1
  1125   1130     do_test without_rowid3-14.2aux.1.1 {
  1126   1131       test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t2 t3
  1127   1132     } {{CREATE TABLE t1(a REFERENCES "t3")}}
  1128   1133     do_test without_rowid3-14.2aux.1.2 {
  1129   1134       test_rename_parent {CREATE TABLE t1(a REFERENCES t2)} t4 t3
  1130   1135     } {{CREATE TABLE t1(a REFERENCES t2)}}
  1131   1136     do_test without_rowid3-14.2aux.1.3 {
  1132   1137       test_rename_parent {CREATE TABLE t1(a REFERENCES "t2")} t2 t3
  1133   1138     } {{CREATE TABLE t1(a REFERENCES "t3")}}
         1139  +  sqlite3_test_control SQLITE_TESTCTRL_INTERNAL_FUNCTIONS 0
  1134   1140     
  1135   1141     # Test ALTER TABLE RENAME TABLE a bit.
  1136   1142     #
  1137   1143     do_test without_rowid3-14.2aux.2.1 {
  1138   1144       drop_all_tables
  1139   1145       execsql {
  1140   1146         CREATE TABLE aux.t1(a PRIMARY KEY, b REFERENCES t1) WITHOUT rowid;

Changes to tool/lempar.c.

    19     19   ** of this template is copied straight through into the generate parser
    20     20   ** source file.
    21     21   **
    22     22   ** The following is the concatenation of all %include directives from the
    23     23   ** input grammar file:
    24     24   */
    25     25   #include <stdio.h>
           26  +#include <assert.h>
    26     27   /************ Begin %include sections from the grammar ************************/
    27     28   %%
    28     29   /**************** End of %include directives **********************************/
    29     30   /* These constants specify the various numeric values for terminal symbols
    30     31   ** in a format understandable to "makeheaders".  This section is blank unless
    31     32   ** "lemon" is run with the "-m" command-line option.
    32     33   ***************** Begin makeheaders token definitions *************************/
................................................................................
   983    984                yyTracePrompt,yyTokenName[yymajor]);
   984    985           }
   985    986   #endif
   986    987           yy_destructor(yypParser, (YYCODETYPE)yymajor, &yyminorunion);
   987    988           yymajor = YYNOCODE;
   988    989         }else{
   989    990           while( yypParser->yytos >= yypParser->yystack
   990         -            && yymx != YYERRORSYMBOL
   991    991               && (yyact = yy_find_reduce_action(
   992    992                           yypParser->yytos->stateno,
   993         -                        YYERRORSYMBOL)) >= YY_MIN_REDUCE
          993  +                        YYERRORSYMBOL)) > YY_MAX_SHIFTREDUCE
   994    994           ){
   995    995             yy_pop_parser_stack(yypParser);
   996    996           }
   997    997           if( yypParser->yytos < yypParser->yystack || yymajor==0 ){
   998    998             yy_destructor(yypParser,(YYCODETYPE)yymajor,&yyminorunion);
   999    999             yy_parse_failed(yypParser);
  1000   1000   #ifndef YYNOERRORRECOVERY