/ Check-in [f3608187]
Login

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

Overview
Comment:Rename the SQLITE_OMIT_BUILTIN_TEST compile-time option to SQLITE_UNTESTABLE.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:f360818737e73ee4f944685a547abc8f14f47819
User & Date: drh 2016-12-07 15:49:02
Context
2016-12-07
17:06
Put the SQLITE_UNTESTABLE compile-time option in the correct order for PRAGMA compile_options. check-in: 24574a15 user: drh tags: trunk
15:49
Rename the SQLITE_OMIT_BUILTIN_TEST compile-time option to SQLITE_UNTESTABLE. check-in: f3608187 user: drh tags: trunk
15:38
Prevent the flattening or where-term push-down optimizations from obscuring misuses of SQL row values that can lead to crashes or assert() failures. check-in: 433d16ff user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/bitvec.c.

   289    289   ** Return the value of the iSize parameter specified when Bitvec *p
   290    290   ** was created.
   291    291   */
   292    292   u32 sqlite3BitvecSize(Bitvec *p){
   293    293     return p->iSize;
   294    294   }
   295    295   
   296         -#ifndef SQLITE_OMIT_BUILTIN_TEST
          296  +#ifndef SQLITE_UNTESTABLE
   297    297   /*
   298    298   ** Let V[] be an array of unsigned characters sufficient to hold
   299    299   ** up to N bits.  Let I be an integer between 0 and N.  0<=I<N.
   300    300   ** Then the following macros can be used to set, clear, or test
   301    301   ** individual bits within V.
   302    302   */
   303    303   #define SETBIT(V,I)      V[I>>3] |= (1<<(I&7))
................................................................................
   404    404     /* Free allocated structure */
   405    405   bitvec_end:
   406    406     sqlite3_free(pTmpSpace);
   407    407     sqlite3_free(pV);
   408    408     sqlite3BitvecDestroy(pBitvec);
   409    409     return rc;
   410    410   }
   411         -#endif /* SQLITE_OMIT_BUILTIN_TEST */
          411  +#endif /* SQLITE_UNTESTABLE */

Changes to src/ctime.c.

   229    229   #endif
   230    230   #if SQLITE_OMIT_BLOB_LITERAL
   231    231     "OMIT_BLOB_LITERAL",
   232    232   #endif
   233    233   #if SQLITE_OMIT_BTREECOUNT
   234    234     "OMIT_BTREECOUNT",
   235    235   #endif
   236         -#if SQLITE_OMIT_BUILTIN_TEST
   237         -  "OMIT_BUILTIN_TEST",
          236  +#if SQLITE_UNTESTABLE
          237  +  "UNTESTABLE"
   238    238   #endif
   239    239   #if SQLITE_OMIT_CAST
   240    240     "OMIT_CAST",
   241    241   #endif
   242    242   #if SQLITE_OMIT_CHECK
   243    243     "OMIT_CHECK",
   244    244   #endif

Changes to src/date.c.

   504    504   #if !HAVE_LOCALTIME_R && !HAVE_LOCALTIME_S
   505    505     struct tm *pX;
   506    506   #if SQLITE_THREADSAFE>0
   507    507     sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
   508    508   #endif
   509    509     sqlite3_mutex_enter(mutex);
   510    510     pX = localtime(t);
   511         -#ifndef SQLITE_OMIT_BUILTIN_TEST
          511  +#ifndef SQLITE_UNTESTABLE
   512    512     if( sqlite3GlobalConfig.bLocaltimeFault ) pX = 0;
   513    513   #endif
   514    514     if( pX ) *pTm = *pX;
   515    515     sqlite3_mutex_leave(mutex);
   516    516     rc = pX==0;
   517    517   #else
   518         -#ifndef SQLITE_OMIT_BUILTIN_TEST
          518  +#ifndef SQLITE_UNTESTABLE
   519    519     if( sqlite3GlobalConfig.bLocaltimeFault ) return 1;
   520    520   #endif
   521    521   #if HAVE_LOCALTIME_R
   522    522     rc = localtime_r(t, pTm)==0;
   523    523   #else
   524    524     rc = localtime_s(pTm, t);
   525    525   #endif /* HAVE_LOCALTIME_R */

Changes to src/fault.c.

    22     22   ** is completely recoverable simply by not carrying out the resize. The 
    23     23   ** hash table will continue to function normally.  So a malloc failure 
    24     24   ** during a hash table resize is a benign fault.
    25     25   */
    26     26   
    27     27   #include "sqliteInt.h"
    28     28   
    29         -#ifndef SQLITE_OMIT_BUILTIN_TEST
           29  +#ifndef SQLITE_UNTESTABLE
    30     30   
    31     31   /*
    32     32   ** Global variables.
    33     33   */
    34     34   typedef struct BenignMallocHooks BenignMallocHooks;
    35     35   static SQLITE_WSD struct BenignMallocHooks {
    36     36     void (*xBenignBegin)(void);
................................................................................
    80     80   void sqlite3EndBenignMalloc(void){
    81     81     wsdHooksInit;
    82     82     if( wsdHooks.xBenignEnd ){
    83     83       wsdHooks.xBenignEnd();
    84     84     }
    85     85   }
    86     86   
    87         -#endif   /* #ifndef SQLITE_OMIT_BUILTIN_TEST */
           87  +#endif   /* #ifndef SQLITE_UNTESTABLE */

Changes to src/global.c.

   215    215      0,                         /* xSqllog */
   216    216      0,                         /* pSqllogArg */
   217    217   #endif
   218    218   #ifdef SQLITE_VDBE_COVERAGE
   219    219      0,                         /* xVdbeBranch */
   220    220      0,                         /* pVbeBranchArg */
   221    221   #endif
   222         -#ifndef SQLITE_OMIT_BUILTIN_TEST
          222  +#ifndef SQLITE_UNTESTABLE
   223    223      0,                         /* xTestCallback */
   224    224   #endif
   225    225      0,                         /* bLocaltimeFault */
   226    226      0x7ffffffe                 /* iOnceResetThreshold */
   227    227   };
   228    228   
   229    229   /*

Changes to src/main.c.

  3529   3529   }
  3530   3530   
  3531   3531   /*
  3532   3532   ** Interface to the testing logic.
  3533   3533   */
  3534   3534   int sqlite3_test_control(int op, ...){
  3535   3535     int rc = 0;
  3536         -#ifdef SQLITE_OMIT_BUILTIN_TEST
         3536  +#ifdef SQLITE_UNTESTABLE
  3537   3537     UNUSED_PARAMETER(op);
  3538   3538   #else
  3539   3539     va_list ap;
  3540   3540     va_start(ap, op);
  3541   3541     switch( op ){
  3542   3542   
  3543   3543       /*
................................................................................
  3866   3866           sqlite3ResetAllSchemasOfConnection(db);
  3867   3867         }
  3868   3868         sqlite3_mutex_leave(db->mutex);
  3869   3869         break;
  3870   3870       }
  3871   3871     }
  3872   3872     va_end(ap);
  3873         -#endif /* SQLITE_OMIT_BUILTIN_TEST */
         3873  +#endif /* SQLITE_UNTESTABLE */
  3874   3874     return rc;
  3875   3875   }
  3876   3876   
  3877   3877   /*
  3878   3878   ** This is a utility routine, useful to VFS implementations, that checks
  3879   3879   ** to see if a database file was a URI that contained a specific query 
  3880   3880   ** parameter, and if so obtains the value of the query parameter.

Changes to src/random.c.

   102    102       wsdPrng.s[wsdPrng.j] = t;
   103    103       t += wsdPrng.s[wsdPrng.i];
   104    104       *(zBuf++) = wsdPrng.s[t];
   105    105     }while( --N );
   106    106     sqlite3_mutex_leave(mutex);
   107    107   }
   108    108   
   109         -#ifndef SQLITE_OMIT_BUILTIN_TEST
          109  +#ifndef SQLITE_UNTESTABLE
   110    110   /*
   111    111   ** For testing purposes, we sometimes want to preserve the state of
   112    112   ** PRNG and restore the PRNG to its saved state at a later time, or
   113    113   ** to reset the PRNG to its initial state.  These routines accomplish
   114    114   ** those tasks.
   115    115   **
   116    116   ** The sqlite3_test_control() interface calls these routines to
................................................................................
   127    127   void sqlite3PrngRestoreState(void){
   128    128     memcpy(
   129    129       &GLOBAL(struct sqlite3PrngType, sqlite3Prng),
   130    130       &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng),
   131    131       sizeof(sqlite3Prng)
   132    132     );
   133    133   }
   134         -#endif /* SQLITE_OMIT_BUILTIN_TEST */
          134  +#endif /* SQLITE_UNTESTABLE */

Changes to src/shell.c.

  2579   2579       if( f==0 ){
  2580   2580         utf8_printf(stderr, "Error: cannot open \"%s\"\n", zFile);
  2581   2581       }
  2582   2582     }
  2583   2583     return f;
  2584   2584   }
  2585   2585   
  2586         -#if !defined(SQLITE_OMIT_BUILTIN_TEST)
         2586  +#if !defined(SQLITE_UNTESTABLE)
  2587   2587   #if !defined(SQLITE_OMIT_TRACE) && !defined(SQLITE_OMIT_FLOATING_POINT)
  2588   2588   /*
  2589   2589   ** A routine for handling output from sqlite3_trace().
  2590   2590   */
  2591   2591   static int sql_trace_callback(
  2592   2592     unsigned mType,
  2593   2593     void *pArg,
................................................................................
  3855   3855       }else if( rc != SQLITE_OK ){
  3856   3856         raw_printf(stderr,
  3857   3857                    "Error: querying sqlite_master and sqlite_temp_master\n");
  3858   3858         rc = 1;
  3859   3859       }
  3860   3860     }else
  3861   3861   
  3862         -#ifndef SQLITE_OMIT_BUILTIN_TEST
         3862  +#ifndef SQLITE_UNTESTABLE
  3863   3863     if( c=='i' && strncmp(azArg[0], "imposter", n)==0 ){
  3864   3864       char *zSql;
  3865   3865       char *zCollist = 0;
  3866   3866       sqlite3_stmt *pStmt;
  3867   3867       int tnum = 0;
  3868   3868       int i;
  3869   3869       if( nArg!=3 ){
................................................................................
  4791   4791       if( nArg>=2 ){
  4792   4792         sqlite3_snprintf(sizeof(p->zTestcase), p->zTestcase, "%s", azArg[1]);
  4793   4793       }else{
  4794   4794         sqlite3_snprintf(sizeof(p->zTestcase), p->zTestcase, "?");
  4795   4795       }
  4796   4796     }else
  4797   4797   
  4798         -#ifndef SQLITE_OMIT_BUILTIN_TEST
         4798  +#ifndef SQLITE_UNTESTABLE
  4799   4799     if( c=='t' && n>=8 && strncmp(azArg[0], "testctrl", n)==0 && nArg>=2 ){
  4800   4800       static const struct {
  4801   4801          const char *zCtrlName;   /* Name of a test-control option */
  4802   4802          int ctrlCode;            /* Integer code for that option */
  4803   4803       } aCtrl[] = {
  4804   4804         { "prng_save",             SQLITE_TESTCTRL_PRNG_SAVE              },
  4805   4805         { "prng_restore",          SQLITE_TESTCTRL_PRNG_RESTORE           },
................................................................................
  4967   4967       if( p->traceOut==0 ){
  4968   4968         sqlite3_trace_v2(p->db, 0, 0, 0);
  4969   4969       }else{
  4970   4970         sqlite3_trace_v2(p->db, SQLITE_TRACE_STMT, sql_trace_callback,p->traceOut);
  4971   4971       }
  4972   4972   #endif
  4973   4973     }else
  4974         -#endif /* !defined(SQLITE_OMIT_BUILTIN_TEST) */
         4974  +#endif /* !defined(SQLITE_UNTESTABLE) */
  4975   4975   
  4976   4976   #if SQLITE_USER_AUTHENTICATION
  4977   4977     if( c=='u' && strncmp(azArg[0], "user", n)==0 ){
  4978   4978       if( nArg<2 ){
  4979   4979         raw_printf(stderr, "Usage: .user SUBCOMMAND ...\n");
  4980   4980         rc = 1;
  4981   4981         goto meta_command_exit;

Changes to src/sqliteInt.h.

  3228   3228   #ifdef SQLITE_VDBE_COVERAGE
  3229   3229     /* The following callback (if not NULL) is invoked on every VDBE branch
  3230   3230     ** operation.  Set the callback using SQLITE_TESTCTRL_VDBE_COVERAGE.
  3231   3231     */
  3232   3232     void (*xVdbeBranch)(void*,int iSrcLine,u8 eThis,u8 eMx);  /* Callback */
  3233   3233     void *pVdbeBranchArg;                                     /* 1st argument */
  3234   3234   #endif
  3235         -#ifndef SQLITE_OMIT_BUILTIN_TEST
         3235  +#ifndef SQLITE_UNTESTABLE
  3236   3236     int (*xTestCallback)(int);        /* Invoked by sqlite3FaultSim() */
  3237   3237   #endif
  3238   3238     int bLocaltimeFault;              /* True to fail localtime() calls */
  3239   3239     int iOnceResetThreshold;          /* When to reset OP_Once counters */
  3240   3240   };
  3241   3241   
  3242   3242   /*
................................................................................
  3432   3432   int sqlite3MallocSize(void*);
  3433   3433   int sqlite3DbMallocSize(sqlite3*, void*);
  3434   3434   void *sqlite3ScratchMalloc(int);
  3435   3435   void sqlite3ScratchFree(void*);
  3436   3436   void *sqlite3PageMalloc(int);
  3437   3437   void sqlite3PageFree(void*);
  3438   3438   void sqlite3MemSetDefault(void);
  3439         -#ifndef SQLITE_OMIT_BUILTIN_TEST
         3439  +#ifndef SQLITE_UNTESTABLE
  3440   3440   void sqlite3BenignMallocHooks(void (*)(void), void (*)(void));
  3441   3441   #endif
  3442   3442   int sqlite3HeapNearlyFull(void);
  3443   3443   
  3444   3444   /*
  3445   3445   ** On systems with ample stack space and that support alloca(), make
  3446   3446   ** use of alloca() to obtain space for large automatic objects.  By default,
................................................................................
  3587   3587   void sqlite3AddDefaultValue(Parse*,ExprSpan*);
  3588   3588   void sqlite3AddCollateType(Parse*, Token*);
  3589   3589   void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
  3590   3590   int sqlite3ParseUri(const char*,const char*,unsigned int*,
  3591   3591                       sqlite3_vfs**,char**,char **);
  3592   3592   Btree *sqlite3DbNameToBtree(sqlite3*,const char*);
  3593   3593   
  3594         -#ifdef SQLITE_OMIT_BUILTIN_TEST
         3594  +#ifdef SQLITE_UNTESTABLE
  3595   3595   # define sqlite3FaultSim(X) SQLITE_OK
  3596   3596   #else
  3597   3597     int sqlite3FaultSim(int);
  3598   3598   #endif
  3599   3599   
  3600   3600   Bitvec *sqlite3BitvecCreate(u32);
  3601   3601   int sqlite3BitvecTest(Bitvec*, u32);
  3602   3602   int sqlite3BitvecTestNotNull(Bitvec*, u32);
  3603   3603   int sqlite3BitvecSet(Bitvec*, u32);
  3604   3604   void sqlite3BitvecClear(Bitvec*, u32, void*);
  3605   3605   void sqlite3BitvecDestroy(Bitvec*);
  3606   3606   u32 sqlite3BitvecSize(Bitvec*);
  3607         -#ifndef SQLITE_OMIT_BUILTIN_TEST
         3607  +#ifndef SQLITE_UNTESTABLE
  3608   3608   int sqlite3BitvecBuiltinTest(int,int*);
  3609   3609   #endif
  3610   3610   
  3611   3611   RowSet *sqlite3RowSetInit(sqlite3*, void*, unsigned int);
  3612   3612   void sqlite3RowSetClear(RowSet*);
  3613   3613   void sqlite3RowSetInsert(RowSet*, i64);
  3614   3614   int sqlite3RowSetTest(RowSet*, int iBatch, i64);
................................................................................
  3720   3720   int sqlite3ExprListCompare(ExprList*, ExprList*, int);
  3721   3721   int sqlite3ExprImpliesExpr(Expr*, Expr*, int);
  3722   3722   void sqlite3ExprAnalyzeAggregates(NameContext*, Expr*);
  3723   3723   void sqlite3ExprAnalyzeAggList(NameContext*,ExprList*);
  3724   3724   int sqlite3ExprCoveredByIndex(Expr*, int iCur, Index *pIdx);
  3725   3725   int sqlite3FunctionUsesThisSrc(Expr*, SrcList*);
  3726   3726   Vdbe *sqlite3GetVdbe(Parse*);
  3727         -#ifndef SQLITE_OMIT_BUILTIN_TEST
         3727  +#ifndef SQLITE_UNTESTABLE
  3728   3728   void sqlite3PrngSaveState(void);
  3729   3729   void sqlite3PrngRestoreState(void);
  3730   3730   #endif
  3731   3731   void sqlite3RollbackAll(sqlite3*,int);
  3732   3732   void sqlite3CodeVerifySchema(Parse*, int);
  3733   3733   void sqlite3CodeVerifyNamedSchema(Parse*, const char *zDb);
  3734   3734   void sqlite3BeginTransaction(Parse*, int);
................................................................................
  4148   4148   ** Available fault injectors.  Should be numbered beginning with 0.
  4149   4149   */
  4150   4150   #define SQLITE_FAULTINJECTOR_MALLOC     0
  4151   4151   #define SQLITE_FAULTINJECTOR_COUNT      1
  4152   4152   
  4153   4153   /*
  4154   4154   ** The interface to the code in fault.c used for identifying "benign"
  4155         -** malloc failures. This is only present if SQLITE_OMIT_BUILTIN_TEST
         4155  +** malloc failures. This is only present if SQLITE_UNTESTABLE
  4156   4156   ** is not defined.
  4157   4157   */
  4158         -#ifndef SQLITE_OMIT_BUILTIN_TEST
         4158  +#ifndef SQLITE_UNTESTABLE
  4159   4159     void sqlite3BeginBenignMalloc(void);
  4160   4160     void sqlite3EndBenignMalloc(void);
  4161   4161   #else
  4162   4162     #define sqlite3BeginBenignMalloc()
  4163   4163     #define sqlite3EndBenignMalloc()
  4164   4164   #endif
  4165   4165   

Changes to src/test_config.c.

   264    264   
   265    265   #ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION
   266    266     Tcl_SetVar2(interp, "sqlite_options", "between_opt", "0", TCL_GLOBAL_ONLY);
   267    267   #else
   268    268     Tcl_SetVar2(interp, "sqlite_options", "between_opt", "1", TCL_GLOBAL_ONLY);
   269    269   #endif
   270    270   
   271         -#ifdef SQLITE_OMIT_BUILTIN_TEST
          271  +#ifdef SQLITE_UNTESTABLE
   272    272     Tcl_SetVar2(interp, "sqlite_options", "builtin_test", "0", TCL_GLOBAL_ONLY);
   273    273   #else
   274    274     Tcl_SetVar2(interp, "sqlite_options", "builtin_test", "1", TCL_GLOBAL_ONLY);
   275    275   #endif
   276    276   
   277    277   #ifdef SQLITE_OMIT_BLOB_LITERAL
   278    278     Tcl_SetVar2(interp, "sqlite_options", "bloblit", "0", TCL_GLOBAL_ONLY);

Changes to src/test_func.c.

   151    151   }
   152    152   
   153    153   /*
   154    154   ** The following aggregate function, test_agg_errmsg16(), takes zero 
   155    155   ** arguments. It returns the text value returned by the sqlite3_errmsg16()
   156    156   ** API function.
   157    157   */
   158         -#ifndef SQLITE_OMIT_BUILTIN_TEST
          158  +#ifndef SQLITE_UNTESTABLE
   159    159   void sqlite3BeginBenignMalloc(void);
   160    160   void sqlite3EndBenignMalloc(void);
   161    161   #else
   162    162     #define sqlite3BeginBenignMalloc()
   163    163     #define sqlite3EndBenignMalloc()
   164    164   #endif
   165    165   static void test_agg_errmsg16_step(sqlite3_context *a, int b,sqlite3_value **c){

Changes to src/util.c.

    38     38   **
    39     39   ** The intent of the integer argument is to let the fault simulator know
    40     40   ** which of multiple sqlite3FaultSim() calls has been hit.
    41     41   **
    42     42   ** Return whatever integer value the test callback returns, or return
    43     43   ** SQLITE_OK if no test callback is installed.
    44     44   */
    45         -#ifndef SQLITE_OMIT_BUILTIN_TEST
           45  +#ifndef SQLITE_UNTESTABLE
    46     46   int sqlite3FaultSim(int iTest){
    47     47     int (*xCallback)(int) = sqlite3GlobalConfig.xTestCallback;
    48     48     return xCallback ? xCallback(iTest) : SQLITE_OK;
    49     49   }
    50     50   #endif
    51     51   
    52     52   #ifndef SQLITE_OMIT_FLOATING_POINT

Changes to src/vdbe.c.

   107    107   int sqlite3_found_count = 0;
   108    108   #endif
   109    109   
   110    110   /*
   111    111   ** Test a register to see if it exceeds the current maximum blob size.
   112    112   ** If it does, record the new maximum blob size.
   113    113   */
   114         -#if defined(SQLITE_TEST) && !defined(SQLITE_OMIT_BUILTIN_TEST)
          114  +#if defined(SQLITE_TEST) && !defined(SQLITE_UNTESTABLE)
   115    115   # define UPDATE_MAX_BLOBSIZE(P)  updateMaxBlobsize(P)
   116    116   #else
   117    117   # define UPDATE_MAX_BLOBSIZE(P)
   118    118   #endif
   119    119   
   120    120   /*
   121    121   ** Invoke the VDBE coverage callback, if that callback is defined.  This