/ Check-in [287f508d]
Login
SQLite training in Houston TX on 2019-11-05 (details)
Part of the 2019 Tcl Conference

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

Overview
Comment:Revise compiler checks for the rand_s() function.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 287f508dd6abc1b9ffdbec6a685ebe79eeac992b
User & Date: mistachkin 2016-02-15 22:01:24
Context
2016-02-15
22:28
Fix comment. No changes to code. check-in: 2e1f2eff user: mistachkin tags: trunk
22:01
Revise compiler checks for the rand_s() function. check-in: 287f508d user: mistachkin tags: trunk
21:31
On windows systems when rand_s() is available, use it to obtain additional seed material in winRandomness(). check-in: 139081be user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/msvc.h.

    12     12   **
    13     13   ** This file contains code that is specific to MSVC.
    14     14   */
    15     15   #ifndef _MSVC_H_
    16     16   #define _MSVC_H_
    17     17   
    18     18   #if defined(_MSC_VER)
    19         -#define _CRT_RAND_S  /* Make rand_s() available on windows systems */
    20     19   #pragma warning(disable : 4054)
    21     20   #pragma warning(disable : 4055)
    22     21   #pragma warning(disable : 4100)
    23     22   #pragma warning(disable : 4127)
    24     23   #pragma warning(disable : 4130)
    25     24   #pragma warning(disable : 4152)
    26     25   #pragma warning(disable : 4189)

Changes to src/os_win.c.

  5420   5420     UNUSED_PARAMETER(pVfs);
  5421   5421     memset(zBuf, 0, nBuf);
  5422   5422     return nBuf;
  5423   5423   #else
  5424   5424     EntropyGatherer e;
  5425   5425     UNUSED_PARAMETER(pVfs);
  5426   5426     memset(zBuf, 0, nBuf);
  5427         -#ifdef _MSC_VER
  5428         -  rand_s((int*)zBuf);  /* rand_s() is not available with MinGW */
         5427  +#if defined(_MSC_VER) && _MSC_VER>=1400
         5428  +  rand_s((int*)zBuf); /* rand_s() is not available with MinGW */
  5429   5429   #endif
  5430   5430     e.a = (unsigned char*)zBuf;
  5431   5431     e.na = nBuf;
  5432   5432     e.nXor = 0;
  5433   5433     e.i = 0;
  5434   5434     {
  5435   5435       SYSTEMTIME x;

Changes to src/sqliteInt.h.

    11     11   *************************************************************************
    12     12   ** Internal interface definitions for SQLite.
    13     13   **
    14     14   */
    15     15   #ifndef _SQLITEINT_H_
    16     16   #define _SQLITEINT_H_
    17     17   
           18  +/*
           19  +** Make sure that rand_s() is available on Windows systems with MSVC 2005
           20  +** or higher.
           21  +*/
           22  +#if defined(_MSC_VER) && _MSC_VER>=1400
           23  +#  define _CRT_RAND_S
           24  +#endif
           25  +
    18     26   /*
    19     27   ** Include the header file used to customize the compiler options for MSVC.
    20     28   ** This should be done first so that it can successfully prevent spurious
    21     29   ** compiler warnings due to subsequent content in this file and other files
    22     30   ** that are included by this file.
    23     31   */
    24     32   #include "msvc.h"
................................................................................
   145    153   
   146    154   /*
   147    155   ** The following macros are used to cast pointers to integers and
   148    156   ** integers to pointers.  The way you do this varies from one compiler
   149    157   ** to the next, so we have developed the following set of #if statements
   150    158   ** to generate appropriate macros for a wide range of compilers.
   151    159   **
   152         -** The correct "ANSI" way to do this is to use the intptr_t type. 
          160  +** The correct "ANSI" way to do this is to use the intptr_t type.
   153    161   ** Unfortunately, that typedef is not available on all compilers, or
   154    162   ** if it is available, it requires an #include of specific headers
   155    163   ** that vary from one machine to the next.
   156    164   **
   157    165   ** Ticket #3860:  The llvm-gcc-4.2 compiler from Apple chokes on
   158    166   ** the ((void*)&((char*)0)[X]) construct.  But MSVC chokes on ((void*)(X)).
   159    167   ** So we have to define the macros in different ways depending on the
................................................................................
   312    320   **
   313    321   ** Setting NDEBUG makes the code smaller and faster by disabling the
   314    322   ** assert() statements in the code.  So we want the default action
   315    323   ** to be for NDEBUG to be set and NDEBUG to be undefined only if SQLITE_DEBUG
   316    324   ** is set.  Thus NDEBUG becomes an opt-in rather than an opt-out
   317    325   ** feature.
   318    326   */
   319         -#if !defined(NDEBUG) && !defined(SQLITE_DEBUG) 
          327  +#if !defined(NDEBUG) && !defined(SQLITE_DEBUG)
   320    328   # define NDEBUG 1
   321    329   #endif
   322    330   #if defined(NDEBUG) && defined(SQLITE_DEBUG)
   323    331   # undef NDEBUG
   324    332   #endif
   325    333   
   326    334   /*
................................................................................
   327    335   ** Enable SQLITE_ENABLE_EXPLAIN_COMMENTS if SQLITE_DEBUG is turned on.
   328    336   */
   329    337   #if !defined(SQLITE_ENABLE_EXPLAIN_COMMENTS) && defined(SQLITE_DEBUG)
   330    338   # define SQLITE_ENABLE_EXPLAIN_COMMENTS 1
   331    339   #endif
   332    340   
   333    341   /*
   334         -** The testcase() macro is used to aid in coverage testing.  When 
          342  +** The testcase() macro is used to aid in coverage testing.  When
   335    343   ** doing coverage testing, the condition inside the argument to
   336    344   ** testcase() must be evaluated both true and false in order to
   337    345   ** get full branch coverage.  The testcase() macro is inserted
   338    346   ** to help ensure adequate test coverage in places where simple
   339    347   ** condition/decision coverage is inadequate.  For example, testcase()
   340    348   ** can be used to make sure boundary values are tested.  For
   341    349   ** bitmask tests, testcase() can be used to make sure each bit
................................................................................
   373    381   #ifndef NDEBUG
   374    382   # define VVA_ONLY(X)  X
   375    383   #else
   376    384   # define VVA_ONLY(X)
   377    385   #endif
   378    386   
   379    387   /*
   380         -** The ALWAYS and NEVER macros surround boolean expressions which 
          388  +** The ALWAYS and NEVER macros surround boolean expressions which
   381    389   ** are intended to always be true or false, respectively.  Such
   382    390   ** expressions could be omitted from the code completely.  But they
   383    391   ** are included in a few cases in order to enhance the resilience
   384    392   ** of SQLite to unexpected behavior - to make the code "self-healing"
   385    393   ** or "ductile" rather than being "brittle" and crashing at the first
   386    394   ** hint of unplanned behavior.
   387    395   **
................................................................................
   486    494   #endif
   487    495   #ifndef SQLITE_BIG_DBL
   488    496   # define SQLITE_BIG_DBL (1e99)
   489    497   #endif
   490    498   
   491    499   /*
   492    500   ** OMIT_TEMPDB is set to 1 if SQLITE_OMIT_TEMPDB is defined, or 0
   493         -** afterward. Having this macro allows us to cause the C compiler 
          501  +** afterward. Having this macro allows us to cause the C compiler
   494    502   ** to omit code used by TEMP tables without messy #ifndef statements.
   495    503   */
   496    504   #ifdef SQLITE_OMIT_TEMPDB
   497    505   #define OMIT_TEMPDB 1
   498    506   #else
   499    507   #define OMIT_TEMPDB 0
   500    508   #endif
................................................................................
   525    533   #ifndef SQLITE_TEMP_STORE
   526    534   # define SQLITE_TEMP_STORE 1
   527    535   # define SQLITE_TEMP_STORE_xc 1  /* Exclude from ctime.c */
   528    536   #endif
   529    537   
   530    538   /*
   531    539   ** If no value has been provided for SQLITE_MAX_WORKER_THREADS, or if
   532         -** SQLITE_TEMP_STORE is set to 3 (never use temporary files), set it 
          540  +** SQLITE_TEMP_STORE is set to 3 (never use temporary files), set it
   533    541   ** to zero.
   534    542   */
   535    543   #if SQLITE_TEMP_STORE==3 || SQLITE_THREADSAFE==0
   536    544   # undef SQLITE_MAX_WORKER_THREADS
   537    545   # define SQLITE_MAX_WORKER_THREADS 0
   538    546   #endif
   539    547   #ifndef SQLITE_MAX_WORKER_THREADS
................................................................................
   673    681   ** Examples:
   674    682   **      1 -> 0              20 -> 43          10000 -> 132
   675    683   **      2 -> 10             25 -> 46          25000 -> 146
   676    684   **      3 -> 16            100 -> 66        1000000 -> 199
   677    685   **      4 -> 20           1000 -> 99        1048576 -> 200
   678    686   **     10 -> 33           1024 -> 100    4294967296 -> 320
   679    687   **
   680         -** The LogEst can be negative to indicate fractional values. 
          688  +** The LogEst can be negative to indicate fractional values.
   681    689   ** Examples:
   682    690   **
   683    691   **    0.5 -> -10           0.1 -> -33        0.0625 -> -40
   684    692   */
   685    693   typedef INT16_TYPE LogEst;
   686    694   
   687    695   /*
................................................................................
   739    747   ** Constants for the largest and smallest possible 64-bit signed integers.
   740    748   ** These macros are designed to work correctly on both 32-bit and 64-bit
   741    749   ** compilers.
   742    750   */
   743    751   #define LARGEST_INT64  (0xffffffff|(((i64)0x7fffffff)<<32))
   744    752   #define SMALLEST_INT64 (((i64)-1) - LARGEST_INT64)
   745    753   
   746         -/* 
          754  +/*
   747    755   ** Round up a number to the next larger multiple of 8.  This is used
   748    756   ** to force 8-byte alignment on 64-bit architectures.
   749    757   */
   750    758   #define ROUND8(x)     (((x)+7)&~7)
   751    759   
   752    760   /*
   753    761   ** Round down to the nearest multiple of 8
................................................................................
   833    841   # define SELECTTRACE_ENABLED 1
   834    842   #else
   835    843   # define SELECTTRACE_ENABLED 0
   836    844   #endif
   837    845   
   838    846   /*
   839    847   ** An instance of the following structure is used to store the busy-handler
   840         -** callback for a given sqlite handle. 
          848  +** callback for a given sqlite handle.
   841    849   **
   842    850   ** The sqlite.busyHandler member of the sqlite struct contains the busy
   843    851   ** callback for the database handle. Each pager opened via the sqlite
   844    852   ** handle is passed a pointer to sqlite.busyHandler. The busy-handler
   845    853   ** callback is currently invoked only from within pager.c.
   846    854   */
   847    855   typedef struct BusyHandler BusyHandler;
................................................................................
   878    886   /*
   879    887   ** Determine if the argument is a power of two
   880    888   */
   881    889   #define IsPowerOfTwo(X) (((X)&((X)-1))==0)
   882    890   
   883    891   /*
   884    892   ** The following value as a destructor means to use sqlite3DbFree().
   885         -** The sqlite3DbFree() routine requires two parameters instead of the 
   886         -** one parameter that destructors normally want.  So we have to introduce 
   887         -** this magic value that the code knows to handle differently.  Any 
          893  +** The sqlite3DbFree() routine requires two parameters instead of the
          894  +** one parameter that destructors normally want.  So we have to introduce
          895  +** this magic value that the code knows to handle differently.  Any
   888    896   ** pointer will work here as long as it is distinct from SQLITE_STATIC
   889    897   ** and SQLITE_TRANSIENT.
   890    898   */
   891    899   #define SQLITE_DYNAMIC   ((sqlite3_destructor_type)sqlite3MallocSize)
   892    900   
   893    901   /*
   894    902   ** When SQLITE_OMIT_WSD is defined, it means that the target platform does
................................................................................
   907    915   #ifdef SQLITE_OMIT_WSD
   908    916     #define SQLITE_WSD const
   909    917     #define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
   910    918     #define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
   911    919     int sqlite3_wsd_init(int N, int J);
   912    920     void *sqlite3_wsd_find(void *K, int L);
   913    921   #else
   914         -  #define SQLITE_WSD 
          922  +  #define SQLITE_WSD
   915    923     #define GLOBAL(t,v) v
   916    924     #define sqlite3GlobalConfig sqlite3Config
   917    925   #endif
   918    926   
   919    927   /*
   920    928   ** The following macros are used to suppress compiler warnings and to
   921         -** make it clear to human readers when a function parameter is deliberately 
          929  +** make it clear to human readers when a function parameter is deliberately
   922    930   ** left unused within the body of a function. This usually happens when
   923         -** a function is called via a function pointer. For example the 
          931  +** a function is called via a function pointer. For example the
   924    932   ** implementation of an SQL aggregate step callback may not use the
   925    933   ** parameter indicating the number of arguments passed to the aggregate,
   926    934   ** if it knows that this is enforced elsewhere.
   927    935   **
   928    936   ** When a function parameter is not used at all within the body of a function,
   929    937   ** it is generally named "NotUsed" or "NotUsed2" to make things even clearer.
   930    938   ** However, these macros may also be used to suppress warnings related to
................................................................................
   982    990   typedef struct VTable VTable;
   983    991   typedef struct VtabCtx VtabCtx;
   984    992   typedef struct Walker Walker;
   985    993   typedef struct WhereInfo WhereInfo;
   986    994   typedef struct With With;
   987    995   
   988    996   /*
   989         -** Defer sourcing vdbe.h and btree.h until after the "u8" and 
          997  +** Defer sourcing vdbe.h and btree.h until after the "u8" and
   990    998   ** "BusyHandler" typedefs. vdbe.h also requires a few of the opaque
   991    999   ** pointer types (i.e. FuncDef) defined above.
   992   1000   */
   993   1001   #include "btree.h"
   994   1002   #include "vdbe.h"
   995   1003   #include "pager.h"
   996   1004   #include "pcache.h"
................................................................................
  1016   1024   /*
  1017   1025   ** An instance of the following structure stores a database schema.
  1018   1026   **
  1019   1027   ** Most Schema objects are associated with a Btree.  The exception is
  1020   1028   ** the Schema for the TEMP databaes (sqlite3.aDb[1]) which is free-standing.
  1021   1029   ** In shared cache mode, a single Schema object can be shared by multiple
  1022   1030   ** Btrees that refer to the same underlying BtShared object.
  1023         -** 
         1031  +**
  1024   1032   ** Schema objects are automatically deallocated when the last Btree that
  1025   1033   ** references them is destroyed.   The TEMP Schema is manually freed by
  1026   1034   ** sqlite3_close().
  1027   1035   *
  1028   1036   ** A thread must be holding a mutex on the corresponding Btree in order
  1029   1037   ** to access Schema content.  This implies that the thread must also be
  1030   1038   ** holding a mutex on the sqlite3 connection pointer that owns the Btree.
................................................................................
  1041   1049     u8 file_format;      /* Schema format version for this file */
  1042   1050     u8 enc;              /* Text encoding used by this database */
  1043   1051     u16 schemaFlags;     /* Flags associated with this schema */
  1044   1052     int cache_size;      /* Number of pages to use in the cache */
  1045   1053   };
  1046   1054   
  1047   1055   /*
  1048         -** These macros can be used to test, set, or clear bits in the 
         1056  +** These macros can be used to test, set, or clear bits in the
  1049   1057   ** Db.pSchema->flags field.
  1050   1058   */
  1051   1059   #define DbHasProperty(D,I,P)     (((D)->aDb[I].pSchema->schemaFlags&(P))==(P))
  1052   1060   #define DbHasAnyProperty(D,I,P)  (((D)->aDb[I].pSchema->schemaFlags&(P))!=0)
  1053   1061   #define DbSetProperty(D,I,P)     (D)->aDb[I].pSchema->schemaFlags|=(P)
  1054   1062   #define DbClearProperty(D,I,P)   (D)->aDb[I].pSchema->schemaFlags&=~(P)
  1055   1063   
................................................................................
  1206   1214     int nVDestroy;                /* Number of active OP_VDestroy operations */
  1207   1215     int nExtension;               /* Number of loaded extensions */
  1208   1216     void **aExtension;            /* Array of shared library handles */
  1209   1217     void (*xTrace)(void*,const char*);        /* Trace function */
  1210   1218     void *pTraceArg;                          /* Argument to the trace function */
  1211   1219     void (*xProfile)(void*,const char*,u64);  /* Profiling function */
  1212   1220     void *pProfileArg;                        /* Argument to profile function */
  1213         -  void *pCommitArg;                 /* Argument to xCommitCallback() */   
         1221  +  void *pCommitArg;                 /* Argument to xCommitCallback() */
  1214   1222     int (*xCommitCallback)(void*);    /* Invoked at every commit. */
  1215         -  void *pRollbackArg;               /* Argument to xRollbackCallback() */   
         1223  +  void *pRollbackArg;               /* Argument to xRollbackCallback() */
  1216   1224     void (*xRollbackCallback)(void*); /* Invoked at every commit. */
  1217   1225     void *pUpdateArg;
  1218   1226     void (*xUpdateCallback)(void*,int, const char*,const char*,sqlite_int64);
  1219   1227   #ifndef SQLITE_OMIT_WAL
  1220   1228     int (*xWalCallback)(void *, sqlite3 *, const char *, int);
  1221   1229     void *pWalArg;
  1222   1230   #endif
................................................................................
  1253   1261     int busyTimeout;              /* Busy handler timeout, in msec */
  1254   1262     int nSavepoint;               /* Number of non-transaction savepoints */
  1255   1263     int nStatement;               /* Number of nested statement-transactions  */
  1256   1264     i64 nDeferredCons;            /* Net deferred constraints this transaction. */
  1257   1265     i64 nDeferredImmCons;         /* Net deferred immediate constraints */
  1258   1266     int *pnBytesFreed;            /* If not NULL, increment this in DbFree() */
  1259   1267   #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
  1260         -  /* The following variables are all protected by the STATIC_MASTER 
  1261         -  ** mutex, not by sqlite3.mutex. They are used by code in notify.c. 
         1268  +  /* The following variables are all protected by the STATIC_MASTER
         1269  +  ** mutex, not by sqlite3.mutex. They are used by code in notify.c.
  1262   1270     **
  1263   1271     ** When X.pUnlockConnection==Y, that means that X is waiting for Y to
  1264   1272     ** unlock so that it can proceed.
  1265   1273     **
  1266   1274     ** When X.pBlockingConnection==Y, that means that something that X tried
  1267   1275     ** tried to do recently failed with an SQLITE_LOCKED error due to locks
  1268   1276     ** held by Y.
................................................................................
  1394   1402     } u;
  1395   1403   };
  1396   1404   
  1397   1405   /*
  1398   1406   ** This structure encapsulates a user-function destructor callback (as
  1399   1407   ** configured using create_function_v2()) and a reference counter. When
  1400   1408   ** create_function_v2() is called to create a function with a destructor,
  1401         -** a single object of this type is allocated. FuncDestructor.nRef is set to 
         1409  +** a single object of this type is allocated. FuncDestructor.nRef is set to
  1402   1410   ** the number of FuncDef objects created (either 1 or 3, depending on whether
  1403   1411   ** or not the specified encoding is SQLITE_ANY). The FuncDef.pDestructor
  1404   1412   ** member of each of the new FuncDef objects is set to point to the allocated
  1405   1413   ** FuncDestructor.
  1406   1414   **
  1407   1415   ** Thereafter, when one of the FuncDef objects is deleted, the reference
  1408   1416   ** count on this object is decremented. When it reaches 0, the destructor
................................................................................
  1436   1444                                       ** single query - might change over time */
  1437   1445   
  1438   1446   /*
  1439   1447   ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
  1440   1448   ** used to create the initializers for the FuncDef structures.
  1441   1449   **
  1442   1450   **   FUNCTION(zName, nArg, iArg, bNC, xFunc)
  1443         -**     Used to create a scalar function definition of a function zName 
         1451  +**     Used to create a scalar function definition of a function zName
  1444   1452   **     implemented by C function xFunc that accepts nArg arguments. The
  1445   1453   **     value passed as iArg is cast to a (void*) and made available
  1446         -**     as the user-data (sqlite3_user_data()) for the function. If 
         1454  +**     as the user-data (sqlite3_user_data()) for the function. If
  1447   1455   **     argument bNC is true, then the SQLITE_FUNC_NEEDCOLL flag is set.
  1448   1456   **
  1449   1457   **   VFUNCTION(zName, nArg, iArg, bNC, xFunc)
  1450   1458   **     Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag.
  1451   1459   **
  1452   1460   **   DFUNCTION(zName, nArg, iArg, bNC, xFunc)
  1453   1461   **     Like FUNCTION except it omits the SQLITE_FUNC_CONSTANT flag and
................................................................................
  1458   1466   **   AGGREGATE(zName, nArg, iArg, bNC, xStep, xFinal)
  1459   1467   **     Used to create an aggregate function definition implemented by
  1460   1468   **     the C functions xStep and xFinal. The first four parameters
  1461   1469   **     are interpreted in the same way as the first 4 parameters to
  1462   1470   **     FUNCTION().
  1463   1471   **
  1464   1472   **   LIKEFUNC(zName, nArg, pArg, flags)
  1465         -**     Used to create a scalar function definition of a function zName 
  1466         -**     that accepts nArg arguments and is implemented by a call to C 
         1473  +**     Used to create a scalar function definition of a function zName
         1474  +**     that accepts nArg arguments and is implemented by a call to C
  1467   1475   **     function likeFunc. Argument pArg is cast to a (void *) and made
  1468   1476   **     available as the function user-data (sqlite3_user_data()). The
  1469   1477   **     FuncDef.flags variable is set to the value passed as the flags
  1470   1478   **     parameter.
  1471   1479   */
  1472   1480   #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
  1473   1481     {nArg, SQLITE_FUNC_CONSTANT|SQLITE_UTF8|(bNC*SQLITE_FUNC_NEEDCOLL), \
................................................................................
  1575   1583   #define SQLITE_SO_UNDEFINED -1 /* No sort order specified */
  1576   1584   
  1577   1585   /*
  1578   1586   ** Column affinity types.
  1579   1587   **
  1580   1588   ** These used to have mnemonic name like 'i' for SQLITE_AFF_INTEGER and
  1581   1589   ** 't' for SQLITE_AFF_TEXT.  But we can save a little space and improve
  1582         -** the speed a little by numbering the values consecutively.  
         1590  +** the speed a little by numbering the values consecutively.
  1583   1591   **
  1584   1592   ** But rather than start with 0 or 1, we begin with 'A'.  That way,
  1585   1593   ** when multiple affinity types are concatenated into a string and
  1586   1594   ** used as the P4 operand, they will be more readable.
  1587   1595   **
  1588   1596   ** Note also that the numeric types are grouped together so that testing
  1589   1597   ** for a numeric type is a single comparison.  And the BLOB type is first.
................................................................................
  1594   1602   #define SQLITE_AFF_INTEGER  'D'
  1595   1603   #define SQLITE_AFF_REAL     'E'
  1596   1604   
  1597   1605   #define sqlite3IsNumericAffinity(X)  ((X)>=SQLITE_AFF_NUMERIC)
  1598   1606   
  1599   1607   /*
  1600   1608   ** The SQLITE_AFF_MASK values masks off the significant bits of an
  1601         -** affinity value. 
         1609  +** affinity value.
  1602   1610   */
  1603   1611   #define SQLITE_AFF_MASK     0x47
  1604   1612   
  1605   1613   /*
  1606   1614   ** Additional bit values that can be ORed with an affinity without
  1607   1615   ** changing the affinity.
  1608   1616   **
................................................................................
  1614   1622   #define SQLITE_JUMPIFNULL   0x10  /* jumps if either operand is NULL */
  1615   1623   #define SQLITE_STOREP2      0x20  /* Store result in reg[P2] rather than jump */
  1616   1624   #define SQLITE_NULLEQ       0x80  /* NULL=NULL */
  1617   1625   #define SQLITE_NOTNULL      0x90  /* Assert that operands are never NULL */
  1618   1626   
  1619   1627   /*
  1620   1628   ** An object of this type is created for each virtual table present in
  1621         -** the database schema. 
         1629  +** the database schema.
  1622   1630   **
  1623   1631   ** If the database schema is shared, then there is one instance of this
  1624   1632   ** structure for each database connection (sqlite3*) that uses the shared
  1625   1633   ** schema. This is because each database connection requires its own unique
  1626         -** instance of the sqlite3_vtab* handle used to access the virtual table 
  1627         -** implementation. sqlite3_vtab* handles can not be shared between 
  1628         -** database connections, even when the rest of the in-memory database 
         1634  +** instance of the sqlite3_vtab* handle used to access the virtual table
         1635  +** implementation. sqlite3_vtab* handles can not be shared between
         1636  +** database connections, even when the rest of the in-memory database
  1629   1637   ** schema is shared, as the implementation often stores the database
  1630   1638   ** connection handle passed to it via the xConnect() or xCreate() method
  1631   1639   ** during initialization internally. This database connection handle may
  1632         -** then be used by the virtual table implementation to access real tables 
  1633         -** within the database. So that they appear as part of the callers 
  1634         -** transaction, these accesses need to be made via the same database 
         1640  +** then be used by the virtual table implementation to access real tables
         1641  +** within the database. So that they appear as part of the callers
         1642  +** transaction, these accesses need to be made via the same database
  1635   1643   ** connection as that used to execute SQL operations on the virtual table.
  1636   1644   **
  1637   1645   ** All VTable objects that correspond to a single table in a shared
  1638   1646   ** database schema are initially stored in a linked-list pointed to by
  1639   1647   ** the Table.pVTable member variable of the corresponding Table object.
  1640   1648   ** When an sqlite3_prepare() operation is required to access the virtual
  1641   1649   ** table, it searches the list for the VTable that corresponds to the
  1642   1650   ** database connection doing the preparing so as to use the correct
  1643   1651   ** sqlite3_vtab* handle in the compiled query.
  1644   1652   **
  1645   1653   ** When an in-memory Table object is deleted (for example when the
  1646         -** schema is being reloaded for some reason), the VTable objects are not 
  1647         -** deleted and the sqlite3_vtab* handles are not xDisconnect()ed 
         1654  +** schema is being reloaded for some reason), the VTable objects are not
         1655  +** deleted and the sqlite3_vtab* handles are not xDisconnect()ed
  1648   1656   ** immediately. Instead, they are moved from the Table.pVTable list to
  1649   1657   ** another linked list headed by the sqlite3.pDisconnect member of the
  1650         -** corresponding sqlite3 structure. They are then deleted/xDisconnected 
         1658  +** corresponding sqlite3 structure. They are then deleted/xDisconnected
  1651   1659   ** next time a statement is prepared using said sqlite3*. This is done
  1652   1660   ** to avoid deadlock issues involving multiple sqlite3.mutex mutexes.
  1653   1661   ** Refer to comments above function sqlite3VtabUnlockList() for an
  1654   1662   ** explanation as to why it is safe to add an entry to an sqlite3.pDisconnect
  1655   1663   ** list without holding the corresponding sqlite3.mutex mutex.
  1656   1664   **
  1657         -** The memory for objects of this type is always allocated by 
  1658         -** sqlite3DbMalloc(), using the connection handle stored in VTable.db as 
         1665  +** The memory for objects of this type is always allocated by
         1666  +** sqlite3DbMalloc(), using the connection handle stored in VTable.db as
  1659   1667   ** the first argument.
  1660   1668   */
  1661   1669   struct VTable {
  1662   1670     sqlite3 *db;              /* Database connection associated with this table */
  1663   1671     Module *pMod;             /* Pointer to module implementation */
  1664   1672     sqlite3_vtab *pVtab;      /* Pointer to vtab instance */
  1665   1673     int nRef;                 /* Number of pointers to this structure */
................................................................................
  1819   1827   **
  1820   1828   ** RESTRICT, SETNULL, and CASCADE actions apply only to foreign keys.
  1821   1829   ** RESTRICT is the same as ABORT for IMMEDIATE foreign keys and the
  1822   1830   ** same as ROLLBACK for DEFERRED keys.  SETNULL means that the foreign
  1823   1831   ** key is set to NULL.  CASCADE means that a DELETE or UPDATE of the
  1824   1832   ** referenced table row is propagated into the row that holds the
  1825   1833   ** foreign key.
  1826         -** 
         1834  +**
  1827   1835   ** The following symbolic values are used to record which type
  1828   1836   ** of action to take.
  1829   1837   */
  1830   1838   #define OE_None     0   /* There is no constraint to check */
  1831   1839   #define OE_Rollback 1   /* Fail the operation and rollback the transaction */
  1832   1840   #define OE_Abort    2   /* Back out changes but do no rollback transaction */
  1833   1841   #define OE_Fail     3   /* Stop the operation but leave all prior changes */
................................................................................
  1840   1848   #define OE_Cascade  9   /* Cascade the changes */
  1841   1849   
  1842   1850   #define OE_Default  10  /* Do whatever the default action is */
  1843   1851   
  1844   1852   
  1845   1853   /*
  1846   1854   ** An instance of the following structure is passed as the first
  1847         -** argument to sqlite3VdbeKeyCompare and is used to control the 
         1855  +** argument to sqlite3VdbeKeyCompare and is used to control the
  1848   1856   ** comparison of the two index keys.
  1849   1857   **
  1850   1858   ** Note that aSortOrder[] and aColl[] have nField+1 slots.  There
  1851   1859   ** are nField slots for the columns of an index then one extra slot
  1852   1860   ** for the rowid at the end.
  1853   1861   */
  1854   1862   struct KeyInfo {
................................................................................
  1881   1889   ** or greater than a key in the btree, respectively.  These are normally
  1882   1890   ** -1 and +1 respectively, but might be inverted to +1 and -1 if the b-tree
  1883   1891   ** is in DESC order.
  1884   1892   **
  1885   1893   ** The key comparison functions actually return default_rc when they find
  1886   1894   ** an equals comparison.  default_rc can be -1, 0, or +1.  If there are
  1887   1895   ** multiple entries in the b-tree with the same key (when only looking
  1888         -** at the first pKeyInfo->nFields,) then default_rc can be set to -1 to 
         1896  +** at the first pKeyInfo->nFields,) then default_rc can be set to -1 to
  1889   1897   ** cause the search to find the last match, or +1 to cause the search to
  1890   1898   ** find the first match.
  1891   1899   **
  1892   1900   ** The key comparison functions will set eqSeen to true if they ever
  1893   1901   ** get and equal results when comparing this structure to a b-tree record.
  1894   1902   ** When default_rc!=0, the search might end up on the record immediately
  1895   1903   ** before the first match or immediately after the last match.  The
................................................................................
  1918   1926   **
  1919   1927   **     CREATE TABLE Ex1(c1 int, c2 int, c3 text);
  1920   1928   **     CREATE INDEX Ex2 ON Ex1(c3,c1);
  1921   1929   **
  1922   1930   ** In the Table structure describing Ex1, nCol==3 because there are
  1923   1931   ** three columns in the table.  In the Index structure describing
  1924   1932   ** Ex2, nColumn==2 since 2 of the 3 columns of Ex1 are indexed.
  1925         -** The value of aiColumn is {2, 0}.  aiColumn[0]==2 because the 
         1933  +** The value of aiColumn is {2, 0}.  aiColumn[0]==2 because the
  1926   1934   ** first column to be indexed (c3) has an index of 2 in Ex1.aCol[].
  1927   1935   ** The second column to be indexed (c1) has an index of 0 in
  1928   1936   ** Ex1.aCol[], hence Ex2.aiColumn[1]==0.
  1929   1937   **
  1930   1938   ** The Index.onError field determines whether or not the indexed columns
  1931   1939   ** must be unique and what to do if they are not.  When Index.onError=OE_None,
  1932   1940   ** it means this is not a unique index.  Otherwise it is a unique index
  1933         -** and the value of Index.onError indicate the which conflict resolution 
         1941  +** and the value of Index.onError indicate the which conflict resolution
  1934   1942   ** algorithm to employ whenever an attempt is made to insert a non-unique
  1935   1943   ** element.
  1936   1944   **
  1937   1945   ** While parsing a CREATE TABLE or CREATE INDEX statement in order to
  1938   1946   ** generate VDBE code (as opposed to parsing one read from an sqlite_master
  1939   1947   ** table as part of parsing an existing database schema), transient instances
  1940   1948   ** of this structure may be created. In this case the Index.tnum variable is
................................................................................
  1991   1999   /* The Index.aiColumn[] values are normally positive integer.  But
  1992   2000   ** there are some negative values that have special meaning:
  1993   2001   */
  1994   2002   #define XN_ROWID     (-1)     /* Indexed column is the rowid */
  1995   2003   #define XN_EXPR      (-2)     /* Indexed column is an expression */
  1996   2004   
  1997   2005   /*
  1998         -** Each sample stored in the sqlite_stat3 table is represented in memory 
         2006  +** Each sample stored in the sqlite_stat3 table is represented in memory
  1999   2007   ** using a structure of this type.  See documentation at the top of the
  2000   2008   ** analyze.c source file for additional information.
  2001   2009   */
  2002   2010   struct IndexSample {
  2003   2011     void *p;          /* Pointer to sampled record */
  2004   2012     int n;            /* Size of record in bytes */
  2005   2013     tRowcnt *anEq;    /* Est. number of rows where the key equals this sample */
................................................................................
  2086   2094   **
  2087   2095   ** Expr.op is the opcode. The integer parser token codes are reused
  2088   2096   ** as opcodes here. For example, the parser defines TK_GE to be an integer
  2089   2097   ** code representing the ">=" operator. This same integer code is reused
  2090   2098   ** to represent the greater-than-or-equal-to operator in the expression
  2091   2099   ** tree.
  2092   2100   **
  2093         -** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB, 
         2101  +** If the expression is an SQL literal (TK_INTEGER, TK_FLOAT, TK_BLOB,
  2094   2102   ** or TK_STRING), then Expr.token contains the text of the SQL literal. If
  2095         -** the expression is a variable (TK_VARIABLE), then Expr.token contains the 
         2103  +** the expression is a variable (TK_VARIABLE), then Expr.token contains the
  2096   2104   ** variable name. Finally, if the expression is an SQL function (TK_FUNCTION),
  2097   2105   ** then Expr.token contains the name of the function.
  2098   2106   **
  2099   2107   ** Expr.pRight and Expr.pLeft are the left and right subexpressions of a
  2100   2108   ** binary operator. Either or both may be NULL.
  2101   2109   **
  2102   2110   ** Expr.x.pList is a list of arguments if the expression is an SQL function,
  2103   2111   ** a CASE expression or an IN expression of the form "<lhs> IN (<y>, <z>...)".
  2104   2112   ** Expr.x.pSelect is used if the expression is a sub-select or an expression of
  2105   2113   ** the form "<lhs> IN (SELECT ...)". If the EP_xIsSelect bit is set in the
  2106         -** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is 
         2114  +** Expr.flags mask, then Expr.x.pSelect is valid. Otherwise, Expr.x.pList is
  2107   2115   ** valid.
  2108   2116   **
  2109   2117   ** An expression of the form ID or ID.ID refers to a column in a table.
  2110   2118   ** For such expressions, Expr.op is set to TK_COLUMN and Expr.iTable is
  2111   2119   ** the integer cursor number of a VDBE cursor pointing to that table and
  2112   2120   ** Expr.iColumn is the column number for the specific column.  If the
  2113   2121   ** expression is used as a result in an aggregate SELECT, then the
  2114   2122   ** value is also stored in the Expr.iAgg column in the aggregate so that
  2115   2123   ** it can be accessed after all aggregates are computed.
  2116   2124   **
  2117         -** If the expression is an unbound variable marker (a question mark 
  2118         -** character '?' in the original SQL) then the Expr.iTable holds the index 
         2125  +** If the expression is an unbound variable marker (a question mark
         2126  +** character '?' in the original SQL) then the Expr.iTable holds the index
  2119   2127   ** number for that variable.
  2120   2128   **
  2121   2129   ** If the expression is a subquery then Expr.iColumn holds an integer
  2122   2130   ** register number containing the result of the subquery.  If the
  2123   2131   ** subquery gives a constant result, then iTable is -1.  If the subquery
  2124   2132   ** gives a different answer at different times during statement processing
  2125   2133   ** then iTable is the address of a subroutine that computes the subquery.
................................................................................
  2150   2158     union {
  2151   2159       char *zToken;          /* Token value. Zero terminated and dequoted */
  2152   2160       int iValue;            /* Non-negative integer value if EP_IntValue */
  2153   2161     } u;
  2154   2162   
  2155   2163     /* If the EP_TokenOnly flag is set in the Expr.flags mask, then no
  2156   2164     ** space is allocated for the fields below this point. An attempt to
  2157         -  ** access them will result in a segfault or malfunction. 
         2165  +  ** access them will result in a segfault or malfunction.
  2158   2166     *********************************************************************/
  2159   2167   
  2160   2168     Expr *pLeft;           /* Left subnode */
  2161   2169     Expr *pRight;          /* Right subnode */
  2162   2170     union {
  2163   2171       ExprList *pList;     /* op = IN, EXISTS, SELECT, CASE, FUNCTION, BETWEEN */
  2164   2172       Select *pSelect;     /* EP_xIsSelect and op = IN, EXISTS, SELECT */
................................................................................
  2216   2224   
  2217   2225   /*
  2218   2226   ** Combinations of two or more EP_* flags
  2219   2227   */
  2220   2228   #define EP_Propagate (EP_Collate|EP_Subquery) /* Propagate these bits up tree */
  2221   2229   
  2222   2230   /*
  2223         -** These macros can be used to test, set, or clear bits in the 
         2231  +** These macros can be used to test, set, or clear bits in the
  2224   2232   ** Expr.flags field.
  2225   2233   */
  2226   2234   #define ExprHasProperty(E,P)     (((E)->flags&(P))!=0)
  2227   2235   #define ExprHasAllProperty(E,P)  (((E)->flags&(P))==(P))
  2228   2236   #define ExprSetProperty(E,P)     (E)->flags|=(P)
  2229   2237   #define ExprClearProperty(E,P)   (E)->flags&=~(P)
  2230   2238   
................................................................................
  2235   2243   #ifdef SQLITE_DEBUG
  2236   2244   # define ExprSetVVAProperty(E,P)  (E)->flags|=(P)
  2237   2245   #else
  2238   2246   # define ExprSetVVAProperty(E,P)
  2239   2247   #endif
  2240   2248   
  2241   2249   /*
  2242         -** Macros to determine the number of bytes required by a normal Expr 
  2243         -** struct, an Expr struct with the EP_Reduced flag set in Expr.flags 
         2250  +** Macros to determine the number of bytes required by a normal Expr
         2251  +** struct, an Expr struct with the EP_Reduced flag set in Expr.flags
  2244   2252   ** and an Expr struct with the EP_TokenOnly flag set.
  2245   2253   */
  2246   2254   #define EXPR_FULLSIZE           sizeof(Expr)           /* Full size */
  2247   2255   #define EXPR_REDUCEDSIZE        offsetof(Expr,iTable)  /* Common features */
  2248   2256   #define EXPR_TOKENONLYSIZE      offsetof(Expr,pLeft)   /* Fewer features */
  2249   2257   
  2250   2258   /*
  2251         -** Flags passed to the sqlite3ExprDup() function. See the header comment 
         2259  +** Flags passed to the sqlite3ExprDup() function. See the header comment
  2252   2260   ** above sqlite3ExprDup() for details.
  2253   2261   */
  2254   2262   #define EXPRDUP_REDUCE         0x0001  /* Used reduced-size Expr nodes */
  2255   2263   
  2256   2264   /*
  2257   2265   ** A list of expressions.  Each expression may optionally have a
  2258   2266   ** name.  An expr/name combination can be used in several ways, such
................................................................................
  2443   2451   ** names.  The context consists of a list of tables (the pSrcList) field and
  2444   2452   ** a list of named expression (pEList).  The named expression list may
  2445   2453   ** be NULL.  The pSrc corresponds to the FROM clause of a SELECT or
  2446   2454   ** to the table being operated on by INSERT, UPDATE, or DELETE.  The
  2447   2455   ** pEList corresponds to the result set of a SELECT and is NULL for
  2448   2456   ** other statements.
  2449   2457   **
  2450         -** NameContexts can be nested.  When resolving names, the inner-most 
         2458  +** NameContexts can be nested.  When resolving names, the inner-most
  2451   2459   ** context is searched first.  If no match is found, the next outer
  2452   2460   ** context is checked.  If there is still no match, the next context
  2453   2461   ** is checked.  This process continues until either a match is found
  2454   2462   ** or all contexts are check.  When a match is found, the nRef member of
  2455         -** the context containing the match is incremented. 
         2463  +** the context containing the match is incremented.
  2456   2464   **
  2457   2465   ** Each subquery gets a new NameContext.  The pNext field points to the
  2458   2466   ** NameContext in the parent query.  Thus the process of scanning the
  2459   2467   ** NameContext list corresponds to searching through successively outer
  2460   2468   ** subqueries looking for a match.
  2461   2469   */
  2462   2470   struct NameContext {
................................................................................
  2471   2479   };
  2472   2480   
  2473   2481   /*
  2474   2482   ** Allowed values for the NameContext, ncFlags field.
  2475   2483   **
  2476   2484   ** Note:  NC_MinMaxAgg must have the same value as SF_MinMaxAgg and
  2477   2485   ** SQLITE_FUNC_MINMAX.
  2478         -** 
         2486  +**
  2479   2487   */
  2480   2488   #define NC_AllowAgg  0x0001  /* Aggregate functions are allowed here */
  2481   2489   #define NC_HasAgg    0x0002  /* One or more aggregate functions seen */
  2482   2490   #define NC_IsCheck   0x0004  /* True if resolving names in a CHECK constraint */
  2483   2491   #define NC_InAggFunc 0x0008  /* True if analyzing arguments to an agg func */
  2484   2492   #define NC_PartIdx   0x0010  /* True if resolving a partial index WHERE */
  2485   2493   #define NC_IdxExpr   0x0020  /* True if resolving columns of CREATE INDEX */
................................................................................
  2550   2558   
  2551   2559   
  2552   2560   /*
  2553   2561   ** The results of a SELECT can be distributed in several ways, as defined
  2554   2562   ** by one of the following macros.  The "SRT" prefix means "SELECT Result
  2555   2563   ** Type".
  2556   2564   **
  2557         -**     SRT_Union       Store results as a key in a temporary index 
         2565  +**     SRT_Union       Store results as a key in a temporary index
  2558   2566   **                     identified by pDest->iSDParm.
  2559   2567   **
  2560   2568   **     SRT_Except      Remove results from the temporary index pDest->iSDParm.
  2561   2569   **
  2562   2570   **     SRT_Exists      Store a 1 in memory cell pDest->iSDParm if the result
  2563   2571   **                     set is not empty.
  2564   2572   **
................................................................................
  2574   2582   **
  2575   2583   **     SRT_Mem         Only valid if the result is a single column.
  2576   2584   **                     Store the first column of the first result row
  2577   2585   **                     in register pDest->iSDParm then abandon the rest
  2578   2586   **                     of the query.  This destination implies "LIMIT 1".
  2579   2587   **
  2580   2588   **     SRT_Set         The result must be a single column.  Store each
  2581         -**                     row of result as the key in table pDest->iSDParm. 
         2589  +**                     row of result as the key in table pDest->iSDParm.
  2582   2590   **                     Apply the affinity pDest->affSdst before storing
  2583   2591   **                     results.  Used to implement "IN (SELECT ...)".
  2584   2592   **
  2585   2593   **     SRT_EphemTab    Create an temporary table pDest->iSDParm and store
  2586   2594   **                     the result there. The cursor is left open after
  2587   2595   **                     returning.  This is like SRT_Table except that
  2588   2596   **                     this destination uses OP_OpenEphemeral to create
................................................................................
  2642   2650     int iSDParm;         /* A parameter used by the eDest disposal method */
  2643   2651     int iSdst;           /* Base register where results are written */
  2644   2652     int nSdst;           /* Number of registers allocated */
  2645   2653     ExprList *pOrderBy;  /* Key columns for SRT_Queue and SRT_DistQueue */
  2646   2654   };
  2647   2655   
  2648   2656   /*
  2649         -** During code generation of statements that do inserts into AUTOINCREMENT 
         2657  +** During code generation of statements that do inserts into AUTOINCREMENT
  2650   2658   ** tables, the following information is attached to the Table.u.autoInc.p
  2651   2659   ** pointer of each autoincrement table to record some side information that
  2652   2660   ** the code generator needs.  We have to keep per-table autoincrement
  2653   2661   ** information in case inserts are done within triggers.  Triggers do not
  2654   2662   ** normally coordinate their activities, but we do need to coordinate the
  2655   2663   ** loading and saving of autoincrement information.
  2656   2664   */
................................................................................
  2665   2673   ** Size of the column cache
  2666   2674   */
  2667   2675   #ifndef SQLITE_N_COLCACHE
  2668   2676   # define SQLITE_N_COLCACHE 10
  2669   2677   #endif
  2670   2678   
  2671   2679   /*
  2672         -** At least one instance of the following structure is created for each 
         2680  +** At least one instance of the following structure is created for each
  2673   2681   ** trigger that may be fired while parsing an INSERT, UPDATE or DELETE
  2674   2682   ** statement. All such objects are stored in the linked list headed at
  2675   2683   ** Parse.pTriggerPrg and deleted once statement compilation has been
  2676   2684   ** completed.
  2677   2685   **
  2678   2686   ** A Vdbe sub-program that implements the body and WHEN clause of trigger
  2679   2687   ** TriggerPrg.pTrigger, assuming a default ON CONFLICT clause of
  2680   2688   ** TriggerPrg.orconf, is stored in the TriggerPrg.pProgram variable.
  2681   2689   ** The Parse.pTriggerPrg list never contains two entries with the same
  2682   2690   ** values for both pTrigger and orconf.
  2683   2691   **
  2684   2692   ** The TriggerPrg.aColmask[0] variable is set to a mask of old.* columns
  2685         -** accessed (or set to 0 for triggers fired as a result of INSERT 
         2693  +** accessed (or set to 0 for triggers fired as a result of INSERT
  2686   2694   ** statements). Similarly, the TriggerPrg.aColmask[1] variable is set to
  2687   2695   ** a mask of new.* columns used by the program.
  2688   2696   */
  2689   2697   struct TriggerPrg {
  2690   2698     Trigger *pTrigger;      /* Trigger this program was coded from */
  2691   2699     TriggerPrg *pNext;      /* Next entry in Parse.pTriggerPrg list */
  2692   2700     SubProgram *pProgram;   /* Program implementing pTrigger/orconf */
................................................................................
  2719   2727   ** carry around information that is global to the entire parse.
  2720   2728   **
  2721   2729   ** The structure is divided into two parts.  When the parser and code
  2722   2730   ** generate call themselves recursively, the first part of the structure
  2723   2731   ** is constant but the second part is reset at the beginning and end of
  2724   2732   ** each recursion.
  2725   2733   **
  2726         -** The nTableLock and aTableLock variables are only used if the shared-cache 
         2734  +** The nTableLock and aTableLock variables are only used if the shared-cache
  2727   2735   ** feature is enabled (if sqlite3Tsd()->useSharedData is true). They are
  2728   2736   ** used to store the set of table-locks required by the statement being
  2729   2737   ** compiled. Function sqlite3TableLock() is used to add entries to the
  2730   2738   ** list.
  2731   2739   */
  2732   2740   struct Parse {
  2733   2741     sqlite3 *db;         /* The main database structure */
................................................................................
  2872   2880   #define OPFLAG_P2ISREG       0x10    /* P2 to OP_Open** is a register number */
  2873   2881   #define OPFLAG_PERMUTE       0x01    /* OP_Compare: use the permutation */
  2874   2882   #define OPFLAG_SAVEPOSITION  0x02    /* OP_Delete: keep cursor position */
  2875   2883   #define OPFLAG_AUXDELETE     0x04    /* OP_Delete: index in a DELETE op */
  2876   2884   
  2877   2885   /*
  2878   2886    * Each trigger present in the database schema is stored as an instance of
  2879         - * struct Trigger. 
         2887  + * struct Trigger.
  2880   2888    *
  2881   2889    * Pointers to instances of struct Trigger are stored in two ways.
  2882         - * 1. In the "trigHash" hash table (part of the sqlite3* that represents the 
         2890  + * 1. In the "trigHash" hash table (part of the sqlite3* that represents the
  2883   2891    *    database). This allows Trigger structures to be retrieved by name.
  2884   2892    * 2. All triggers associated with a single table form a linked list, using the
  2885   2893    *    pNext member of struct Trigger. A pointer to the first element of the
  2886   2894    *    linked list is stored as the "pTrigger" member of the associated
  2887   2895    *    struct Table.
  2888   2896    *
  2889   2897    * The "step_list" member points to the first element of a linked list
................................................................................
  2901   2909     Schema *pTabSchema;     /* Schema containing the table */
  2902   2910     TriggerStep *step_list; /* Link list of trigger program steps             */
  2903   2911     Trigger *pNext;         /* Next trigger associated with the table */
  2904   2912   };
  2905   2913   
  2906   2914   /*
  2907   2915   ** A trigger is either a BEFORE or an AFTER trigger.  The following constants
  2908         -** determine which. 
         2916  +** determine which.
  2909   2917   **
  2910   2918   ** If there are multiple triggers, you might of some BEFORE and some AFTER.
  2911   2919   ** In that cases, the constants below can be ORed together.
  2912   2920   */
  2913   2921   #define TRIGGER_BEFORE  1
  2914   2922   #define TRIGGER_AFTER   2
  2915   2923   
  2916   2924   /*
  2917   2925    * An instance of struct TriggerStep is used to store a single SQL statement
  2918         - * that is a part of a trigger-program. 
         2926  + * that is a part of a trigger-program.
  2919   2927    *
  2920   2928    * Instances of struct TriggerStep are stored in a singly linked list (linked
  2921         - * using the "pNext" member) referenced by the "step_list" member of the 
         2929  + * using the "pNext" member) referenced by the "step_list" member of the
  2922   2930    * associated struct Trigger instance. The first element of the linked list is
  2923   2931    * the first step of the trigger-program.
  2924         - * 
         2932  + *
  2925   2933    * The "op" member indicates whether this is a "DELETE", "INSERT", "UPDATE" or
  2926         - * "SELECT" statement. The meanings of the other members is determined by the 
         2934  + * "SELECT" statement. The meanings of the other members is determined by the
  2927   2935    * value of "op" as follows:
  2928   2936    *
  2929   2937    * (op == TK_INSERT)
  2930   2938    * orconf    -> stores the ON CONFLICT algorithm
  2931   2939    * pSelect   -> If this is an INSERT INTO ... SELECT ... statement, then
  2932   2940    *              this stores a pointer to the SELECT statement. Otherwise NULL.
  2933   2941    * zTarget   -> Dequoted name of the table to insert into.
  2934   2942    * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then
  2935   2943    *              this stores values to be inserted. Otherwise NULL.
  2936         - * pIdList   -> If this is an INSERT INTO ... (<column-names>) VALUES ... 
         2944  + * pIdList   -> If this is an INSERT INTO ... (<column-names>) VALUES ...
  2937   2945    *              statement, then this stores the column-names to be
  2938   2946    *              inserted into.
  2939   2947    *
  2940   2948    * (op == TK_DELETE)
  2941   2949    * zTarget   -> Dequoted name of the table to delete from.
  2942   2950    * pWhere    -> The WHERE clause of the DELETE statement if one is specified.
  2943   2951    *              Otherwise NULL.
  2944         - * 
         2952  + *
  2945   2953    * (op == TK_UPDATE)
  2946   2954    * zTarget   -> Dequoted name of the table to update.
  2947   2955    * pWhere    -> The WHERE clause of the UPDATE statement if one is specified.
  2948   2956    *              Otherwise NULL.
  2949   2957    * pExprList -> A list of the columns to update and the expressions to update
  2950   2958    *              them to. See sqlite3Update() documentation of "pChanges"
  2951   2959    *              argument.
  2952         - * 
         2960  + *
  2953   2961    */
  2954   2962   struct TriggerStep {
  2955   2963     u8 op;               /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */
  2956   2964     u8 orconf;           /* OE_Rollback etc. */
  2957   2965     Trigger *pTrig;      /* The trigger that this step is a part of */
  2958   2966     Select *pSelect;     /* SELECT statement or RHS of INSERT INTO SELECT ... */
  2959   2967     char *zTarget;       /* Target table for DELETE, UPDATE, INSERT */
................................................................................
  2963   2971     TriggerStep *pNext;  /* Next in the link-list */
  2964   2972     TriggerStep *pLast;  /* Last element in link-list. Valid for 1st elem only */
  2965   2973   };
  2966   2974   
  2967   2975   /*
  2968   2976   ** The following structure contains information used by the sqliteFix...
  2969   2977   ** routines as they walk the parse tree to make database references
  2970         -** explicit.  
         2978  +** explicit.
  2971   2979   */
  2972   2980   typedef struct DbFixer DbFixer;
  2973   2981   struct DbFixer {
  2974   2982     Parse *pParse;      /* The parsing context.  Error messages written here */
  2975   2983     Schema *pSchema;    /* Fix items to this schema */
  2976   2984     int bVarOnly;       /* Check for variable references only */
  2977   2985     const char *zDb;    /* Make sure all objects are contained in this database */
................................................................................
  3278   3286   **
  3279   3287   ** The alloca() routine never returns NULL.  This will cause code paths
  3280   3288   ** that deal with sqlite3StackAlloc() failures to be unreachable.
  3281   3289   */
  3282   3290   #ifdef SQLITE_USE_ALLOCA
  3283   3291   # define sqlite3StackAllocRaw(D,N)   alloca(N)
  3284   3292   # define sqlite3StackAllocZero(D,N)  memset(alloca(N), 0, N)
  3285         -# define sqlite3StackFree(D,P)       
         3293  +# define sqlite3StackFree(D,P)
  3286   3294   #else
  3287   3295   # define sqlite3StackAllocRaw(D,N)   sqlite3DbMallocRaw(D,N)
  3288   3296   # define sqlite3StackAllocZero(D,N)  sqlite3DbMallocZero(D,N)
  3289   3297   # define sqlite3StackFree(D,P)       sqlite3DbFree(D,P)
  3290   3298   #endif
  3291   3299   
  3292   3300   #ifdef SQLITE_ENABLE_MEMSYS3
................................................................................
  3735   3743   #else
  3736   3744   # define sqlite3FileSuffix3(X,Y)
  3737   3745   #endif
  3738   3746   u8 sqlite3GetBoolean(const char *z,u8);
  3739   3747   
  3740   3748   const void *sqlite3ValueText(sqlite3_value*, u8);
  3741   3749   int sqlite3ValueBytes(sqlite3_value*, u8);
  3742         -void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8, 
         3750  +void sqlite3ValueSetStr(sqlite3_value*, int, const void *,u8,
  3743   3751                           void(*)(void*));
  3744   3752   void sqlite3ValueSetNull(sqlite3_value*);
  3745   3753   void sqlite3ValueFree(sqlite3_value*);
  3746   3754   sqlite3_value *sqlite3ValueNew(sqlite3 *);
  3747   3755   char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8);
  3748   3756   int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);
  3749   3757   void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
................................................................................
  3795   3803   KeyInfo *sqlite3KeyInfoAlloc(sqlite3*,int,int);
  3796   3804   void sqlite3KeyInfoUnref(KeyInfo*);
  3797   3805   KeyInfo *sqlite3KeyInfoRef(KeyInfo*);
  3798   3806   KeyInfo *sqlite3KeyInfoOfIndex(Parse*, Index*);
  3799   3807   #ifdef SQLITE_DEBUG
  3800   3808   int sqlite3KeyInfoIsWriteable(KeyInfo*);
  3801   3809   #endif
  3802         -int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *, 
         3810  +int sqlite3CreateFunc(sqlite3 *, const char *, int, int, void *,
  3803   3811     void (*)(sqlite3_context*,int,sqlite3_value **),
  3804   3812     void (*)(sqlite3_context*,int,sqlite3_value **), void (*)(sqlite3_context*),
  3805   3813     FuncDestructor *pDestructor
  3806   3814   );
  3807   3815   void sqlite3OomFault(sqlite3*);
  3808   3816   void sqlite3OomClear(sqlite3*);
  3809   3817   int sqlite3ApiExit(sqlite3 *db, int);
................................................................................
  3858   3866   
  3859   3867   #ifdef SQLITE_OMIT_VIRTUALTABLE
  3860   3868   #  define sqlite3VtabClear(Y)
  3861   3869   #  define sqlite3VtabSync(X,Y) SQLITE_OK
  3862   3870   #  define sqlite3VtabRollback(X)
  3863   3871   #  define sqlite3VtabCommit(X)
  3864   3872   #  define sqlite3VtabInSync(db) 0
  3865         -#  define sqlite3VtabLock(X) 
         3873  +#  define sqlite3VtabLock(X)
  3866   3874   #  define sqlite3VtabUnlock(X)
  3867   3875   #  define sqlite3VtabUnlockList(X)
  3868   3876   #  define sqlite3VtabSavepoint(X, Y, Z) SQLITE_OK
  3869   3877   #  define sqlite3GetVTable(X,Y)  ((VTable*)0)
  3870   3878   #else
  3871   3879      void sqlite3VtabClear(sqlite3 *db, Table*);
  3872   3880      void sqlite3VtabDisconnect(sqlite3 *db, Table *p);
................................................................................
  3916   3924   #define sqlite3WithDelete(x,y)
  3917   3925   #endif
  3918   3926   
  3919   3927   /* Declarations for functions in fkey.c. All of these are replaced by
  3920   3928   ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
  3921   3929   ** key functionality is available. If OMIT_TRIGGER is defined but
  3922   3930   ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In
  3923         -** this case foreign keys are parsed, but no other functionality is 
         3931  +** this case foreign keys are parsed, but no other functionality is
  3924   3932   ** provided (enforcement of FK constraints requires the triggers sub-system).
  3925   3933   */
  3926   3934   #if !defined(SQLITE_OMIT_FOREIGN_KEY) && !defined(SQLITE_OMIT_TRIGGER)
  3927   3935     void sqlite3FkCheck(Parse*, Table*, int, int, int*, int);
  3928   3936     void sqlite3FkDropTable(Parse*, SrcList *, Table*);
  3929   3937     void sqlite3FkActions(Parse*, Table*, ExprList*, int, int*, int);
  3930   3938     int sqlite3FkRequired(Parse*, Table*, int*, int);
................................................................................
  4020   4028   #ifdef SQLITE_DEBUG
  4021   4029     void sqlite3ParserTrace(FILE*, char *);
  4022   4030   #endif
  4023   4031   
  4024   4032   /*
  4025   4033   ** If the SQLITE_ENABLE IOTRACE exists then the global variable
  4026   4034   ** sqlite3IoTrace is a pointer to a printf-like routine used to
  4027         -** print I/O tracing messages. 
         4035  +** print I/O tracing messages.
  4028   4036   */
  4029   4037   #ifdef SQLITE_ENABLE_IOTRACE
  4030   4038   # define IOTRACE(A)  if( sqlite3IoTrace ){ sqlite3IoTrace A; }
  4031   4039     void sqlite3VdbeIOTraceSql(Vdbe*);
  4032   4040   SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);
  4033   4041   #else
  4034   4042   # define IOTRACE(A)
................................................................................
  4054   4062   ** Perhaps the most important point is the difference between MEMTYPE_HEAP
  4055   4063   ** and MEMTYPE_LOOKASIDE.  If an allocation is MEMTYPE_LOOKASIDE, that means
  4056   4064   ** it might have been allocated by lookaside, except the allocation was
  4057   4065   ** too large or lookaside was already full.  It is important to verify
  4058   4066   ** that allocations that might have been satisfied by lookaside are not
  4059   4067   ** passed back to non-lookaside free() routines.  Asserts such as the
  4060   4068   ** example above are placed on the non-lookaside free() routines to verify
  4061         -** this constraint. 
         4069  +** this constraint.
  4062   4070   **
  4063   4071   ** All of this is no-op for a production build.  It only comes into
  4064   4072   ** play when the SQLITE_MEMDEBUG compile-time option is used.
  4065   4073   */
  4066   4074   #ifdef SQLITE_MEMDEBUG
  4067   4075     void sqlite3MemdebugSetType(void*,u8);
  4068   4076     int sqlite3MemdebugHasType(void*,u8);