sqllogictest
Check-in [0756e950c1]
Not logged in

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

Overview
Comment:Update the built-in SQLite to the first 3.25.0 release candidate.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:0756e950c1d0ae5d648be8d5e4218d2cac83e57e
User & Date: drh 2018-09-12 14:31:18
Context
2018-11-27
22:13
Update the built-in SQLite to the latest 3.26.0 beta. check-in: 7ecd9f43d7 user: drh tags: trunk
2018-09-12
14:31
Update the built-in SQLite to the first 3.25.0 release candidate. check-in: 0756e950c1 user: drh tags: trunk
2018-05-30
01:40
Update the built-in SQLite to the first 3.24.0 beta. check-in: f50f35585d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/sqlite3.c.

more than 10,000 changes

Changes to src/sqlite3.h.

   119    119   ** been edited in any way since it was last checked in, then the last
   120    120   ** four hexadecimal digits of the hash may be modified.
   121    121   **
   122    122   ** See also: [sqlite3_libversion()],
   123    123   ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
   124    124   ** [sqlite_version()] and [sqlite_source_id()].
   125    125   */
   126         -#define SQLITE_VERSION        "3.24.0"
   127         -#define SQLITE_VERSION_NUMBER 3024000
   128         -#define SQLITE_SOURCE_ID      "2018-05-30 01:14:20 86ee267ee86f5264774a9f215b1158aeaa2d605e77c205731b5ee3945d7de4c2"
          126  +#define SQLITE_VERSION        "3.25.0"
          127  +#define SQLITE_VERSION_NUMBER 3025000
          128  +#define SQLITE_SOURCE_ID      "2018-09-12 08:51:48 572de7e4e33562c72cd90790b267ba389370f21ddcaebc4db609fd76ae9b7ada"
   129    129   
   130    130   /*
   131    131   ** CAPI3REF: Run-Time Library Version Numbers
   132    132   ** KEYWORDS: sqlite3_version sqlite3_sourceid
   133    133   **
   134    134   ** These interfaces provide the same information as the [SQLITE_VERSION],
   135    135   ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros
................................................................................
   468    468   ** on a per database connection basis using the
   469    469   ** [sqlite3_extended_result_codes()] API.  Or, the extended code for
   470    470   ** the most recent error can be obtained using
   471    471   ** [sqlite3_extended_errcode()].
   472    472   */
   473    473   #define SQLITE_ERROR_MISSING_COLLSEQ   (SQLITE_ERROR | (1<<8))
   474    474   #define SQLITE_ERROR_RETRY             (SQLITE_ERROR | (2<<8))
          475  +#define SQLITE_ERROR_SNAPSHOT          (SQLITE_ERROR | (3<<8))
   475    476   #define SQLITE_IOERR_READ              (SQLITE_IOERR | (1<<8))
   476    477   #define SQLITE_IOERR_SHORT_READ        (SQLITE_IOERR | (2<<8))
   477    478   #define SQLITE_IOERR_WRITE             (SQLITE_IOERR | (3<<8))
   478    479   #define SQLITE_IOERR_FSYNC             (SQLITE_IOERR | (4<<8))
   479    480   #define SQLITE_IOERR_DIR_FSYNC         (SQLITE_IOERR | (5<<8))
   480    481   #define SQLITE_IOERR_TRUNCATE          (SQLITE_IOERR | (6<<8))
   481    482   #define SQLITE_IOERR_FSTAT             (SQLITE_IOERR | (7<<8))
................................................................................
   507    508   #define SQLITE_LOCKED_VTAB             (SQLITE_LOCKED |  (2<<8))
   508    509   #define SQLITE_BUSY_RECOVERY           (SQLITE_BUSY   |  (1<<8))
   509    510   #define SQLITE_BUSY_SNAPSHOT           (SQLITE_BUSY   |  (2<<8))
   510    511   #define SQLITE_CANTOPEN_NOTEMPDIR      (SQLITE_CANTOPEN | (1<<8))
   511    512   #define SQLITE_CANTOPEN_ISDIR          (SQLITE_CANTOPEN | (2<<8))
   512    513   #define SQLITE_CANTOPEN_FULLPATH       (SQLITE_CANTOPEN | (3<<8))
   513    514   #define SQLITE_CANTOPEN_CONVPATH       (SQLITE_CANTOPEN | (4<<8))
          515  +#define SQLITE_CANTOPEN_DIRTYWAL       (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
   514    516   #define SQLITE_CORRUPT_VTAB            (SQLITE_CORRUPT | (1<<8))
   515    517   #define SQLITE_CORRUPT_SEQUENCE        (SQLITE_CORRUPT | (2<<8))
   516    518   #define SQLITE_READONLY_RECOVERY       (SQLITE_READONLY | (1<<8))
   517    519   #define SQLITE_READONLY_CANTLOCK       (SQLITE_READONLY | (2<<8))
   518    520   #define SQLITE_READONLY_ROLLBACK       (SQLITE_READONLY | (3<<8))
   519    521   #define SQLITE_READONLY_DBMOVED        (SQLITE_READONLY | (4<<8))
   520    522   #define SQLITE_READONLY_CANTINIT       (SQLITE_READONLY | (5<<8))
................................................................................
   882    884   ** is not changed but instead the prior value of that setting is written
   883    885   ** into the array entry, allowing the current retry settings to be
   884    886   ** interrogated.  The zDbName parameter is ignored.
   885    887   **
   886    888   ** <li>[[SQLITE_FCNTL_PERSIST_WAL]]
   887    889   ** ^The [SQLITE_FCNTL_PERSIST_WAL] opcode is used to set or query the
   888    890   ** persistent [WAL | Write Ahead Log] setting.  By default, the auxiliary
   889         -** write ahead log and shared memory files used for transaction control
          891  +** write ahead log ([WAL file]) and shared memory
          892  +** files used for transaction control
   890    893   ** are automatically deleted when the latest connection to the database
   891    894   ** closes.  Setting persistent WAL mode causes those files to persist after
   892    895   ** close.  Persisting the files is useful when other processes that do not
   893    896   ** have write permission on the directory containing the database file want
   894    897   ** to read the database file, as the WAL and shared memory files must exist
   895    898   ** in order for the database to be readable.  The fourth parameter to
   896    899   ** [sqlite3_file_control()] for this opcode should be a pointer to an integer.
................................................................................
  1068   1071   ** a prior successful call to [SQLITE_FCNTL_BEGIN_ATOMIC_WRITE].
  1069   1072   **
  1070   1073   ** <li>[[SQLITE_FCNTL_LOCK_TIMEOUT]]
  1071   1074   ** The [SQLITE_FCNTL_LOCK_TIMEOUT] opcode causes attempts to obtain
  1072   1075   ** a file lock using the xLock or xShmLock methods of the VFS to wait
  1073   1076   ** for up to M milliseconds before failing, where M is the single 
  1074   1077   ** unsigned integer parameter.
         1078  +**
         1079  +** <li>[[SQLITE_FCNTL_DATA_VERSION]]
         1080  +** The [SQLITE_FCNTL_DATA_VERSION] opcode is used to detect changes to
         1081  +** a database file.  The argument is a pointer to a 32-bit unsigned integer.
         1082  +** The "data version" for the pager is written into the pointer.  The
         1083  +** "data version" changes whenever any change occurs to the corresponding
         1084  +** database file, either through SQL statements on the same database
         1085  +** connection, or through transactions committed by separate database
         1086  +** connections possibly in other processes. The [sqlite3_total_changes()]
         1087  +** interface can be used to find if any database on the connection has changed,
         1088  +** but that interface response to changes on TEMP as well as MAIN and does
         1089  +** not provide a mechanism to detect changes to MAIN only.  Also, the
         1090  +** [sqlite3_total_changes()] interface response to internal changes only and
         1091  +** omits changes made by other database connections.  The
         1092  +** [PRAGMA data_version] command provide a mechanism to detect changes to
         1093  +** a single attached database that occur due to other database connections,
         1094  +** but omits changes implemented by the database connection for which it is
         1095  +** called.  This file control is the only mechanism to detect changes that
         1096  +** happen either internally or externally on a single database.
  1075   1097   ** </ul>
  1076   1098   */
  1077   1099   #define SQLITE_FCNTL_LOCKSTATE               1
  1078   1100   #define SQLITE_FCNTL_GET_LOCKPROXYFILE       2
  1079   1101   #define SQLITE_FCNTL_SET_LOCKPROXYFILE       3
  1080   1102   #define SQLITE_FCNTL_LAST_ERRNO              4
  1081   1103   #define SQLITE_FCNTL_SIZE_HINT               5
................................................................................
  1103   1125   #define SQLITE_FCNTL_JOURNAL_POINTER        28
  1104   1126   #define SQLITE_FCNTL_WIN32_GET_HANDLE       29
  1105   1127   #define SQLITE_FCNTL_PDB                    30
  1106   1128   #define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE     31
  1107   1129   #define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE    32
  1108   1130   #define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE  33
  1109   1131   #define SQLITE_FCNTL_LOCK_TIMEOUT           34
         1132  +#define SQLITE_FCNTL_DATA_VERSION           35
  1110   1133   
  1111   1134   /* deprecated names */
  1112   1135   #define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
  1113   1136   #define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
  1114   1137   #define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO
  1115   1138   
  1116   1139   
................................................................................
  2117   2140   **
  2118   2141   ** <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
  2119   2142   ** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
  2120   2143   ** [VACUUM] in order to reset a database back to an empty database
  2121   2144   ** with no schema and no content. The following process works even for
  2122   2145   ** a badly corrupted database file:
  2123   2146   ** <ol>
         2147  +** <li> If the database connection is newly opened, make sure it has read the
         2148  +**      database schema by preparing then discarding some query against the
         2149  +**      database, or calling sqlite3_table_column_metadata(), ignoring any
         2150  +**      errors.  This step is only necessary if the application desires to keep
         2151  +**      the database in WAL mode after the reset if it was in WAL mode before
         2152  +**      the reset.  
  2124   2153   ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
  2125   2154   ** <li> [sqlite3_exec](db, "[VACUUM]", 0, 0, 0);
  2126   2155   ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
  2127   2156   ** </ol>
  2128   2157   ** Because resetting a database is destructive and irreversible, the
  2129   2158   ** process requires the use of this obscure API and multiple steps to help
  2130   2159   ** ensure that it does not happen by accident.
................................................................................
  2265   2294   ** ^This means that if the changes() SQL function (or similar) is used
  2266   2295   ** by the first INSERT, UPDATE or DELETE statement within a trigger, it 
  2267   2296   ** returns the value as set when the calling statement began executing.
  2268   2297   ** ^If it is used by the second or subsequent such statement within a trigger 
  2269   2298   ** program, the value returned reflects the number of rows modified by the 
  2270   2299   ** previous INSERT, UPDATE or DELETE statement within the same trigger.
  2271   2300   **
  2272         -** See also the [sqlite3_total_changes()] interface, the
  2273         -** [count_changes pragma], and the [changes() SQL function].
  2274         -**
  2275   2301   ** If a separate thread makes changes on the same database connection
  2276   2302   ** while [sqlite3_changes()] is running then the value returned
  2277   2303   ** is unpredictable and not meaningful.
         2304  +**
         2305  +** See also:
         2306  +** <ul>
         2307  +** <li> the [sqlite3_total_changes()] interface
         2308  +** <li> the [count_changes pragma]
         2309  +** <li> the [changes() SQL function]
         2310  +** <li> the [data_version pragma]
         2311  +** </ul>
  2278   2312   */
  2279   2313   SQLITE_API int sqlite3_changes(sqlite3*);
  2280   2314   
  2281   2315   /*
  2282   2316   ** CAPI3REF: Total Number Of Rows Modified
  2283   2317   ** METHOD: sqlite3
  2284   2318   **
................................................................................
  2288   2322   ** part of trigger programs. ^Executing any other type of SQL statement
  2289   2323   ** does not affect the value returned by sqlite3_total_changes().
  2290   2324   ** 
  2291   2325   ** ^Changes made as part of [foreign key actions] are included in the
  2292   2326   ** count, but those made as part of REPLACE constraint resolution are
  2293   2327   ** not. ^Changes to a view that are intercepted by INSTEAD OF triggers 
  2294   2328   ** are not counted.
         2329  +**
         2330  +** This the [sqlite3_total_changes(D)] interface only reports the number
         2331  +** of rows that changed due to SQL statement run against database
         2332  +** connection D.  Any changes by other database connections are ignored.
         2333  +** To detect changes against a database file from other database
         2334  +** connections use the [PRAGMA data_version] command or the
         2335  +** [SQLITE_FCNTL_DATA_VERSION] [file control].
  2295   2336   ** 
  2296         -** See also the [sqlite3_changes()] interface, the
  2297         -** [count_changes pragma], and the [total_changes() SQL function].
  2298         -**
  2299   2337   ** If a separate thread makes changes on the same database connection
  2300   2338   ** while [sqlite3_total_changes()] is running then the value
  2301   2339   ** returned is unpredictable and not meaningful.
         2340  +**
         2341  +** See also:
         2342  +** <ul>
         2343  +** <li> the [sqlite3_changes()] interface
         2344  +** <li> the [count_changes pragma]
         2345  +** <li> the [changes() SQL function]
         2346  +** <li> the [data_version pragma]
         2347  +** <li> the [SQLITE_FCNTL_DATA_VERSION] [file control]
         2348  +** </ul>
  2302   2349   */
  2303   2350   SQLITE_API int sqlite3_total_changes(sqlite3*);
  2304   2351   
  2305   2352   /*
  2306   2353   ** CAPI3REF: Interrupt A Long-Running Query
  2307   2354   ** METHOD: sqlite3
  2308   2355   **
................................................................................
  3350   3397   ** CAPI3REF: Error Codes And Messages
  3351   3398   ** METHOD: sqlite3
  3352   3399   **
  3353   3400   ** ^If the most recent sqlite3_* API call associated with 
  3354   3401   ** [database connection] D failed, then the sqlite3_errcode(D) interface
  3355   3402   ** returns the numeric [result code] or [extended result code] for that
  3356   3403   ** API call.
  3357         -** If the most recent API call was successful,
  3358         -** then the return value from sqlite3_errcode() is undefined.
  3359   3404   ** ^The sqlite3_extended_errcode()
  3360   3405   ** interface is the same except that it always returns the 
  3361   3406   ** [extended result code] even when extended result codes are
  3362   3407   ** disabled.
         3408  +**
         3409  +** The values returned by sqlite3_errcode() and/or
         3410  +** sqlite3_extended_errcode() might change with each API call.
         3411  +** Except, there are some interfaces that are guaranteed to never
         3412  +** change the value of the error code.  The error-code preserving
         3413  +** interfaces are:
         3414  +**
         3415  +** <ul>
         3416  +** <li> sqlite3_errcode()
         3417  +** <li> sqlite3_extended_errcode()
         3418  +** <li> sqlite3_errmsg()
         3419  +** <li> sqlite3_errmsg16()
         3420  +** </ul>
  3363   3421   **
  3364   3422   ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
  3365   3423   ** text that describes the error, as either UTF-8 or UTF-16 respectively.
  3366   3424   ** ^(Memory to hold the error message string is managed internally.
  3367   3425   ** The application does not need to worry about freeing the result.
  3368   3426   ** However, the error string might be overwritten or deallocated by
  3369   3427   ** subsequent calls to other SQLite interface functions.)^
................................................................................
  4510   4568   ** ^The pointers returned are valid until a type conversion occurs as
  4511   4569   ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
  4512   4570   ** [sqlite3_finalize()] is called.  ^The memory space used to hold strings
  4513   4571   ** and BLOBs is freed automatically.  Do not pass the pointers returned
  4514   4572   ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
  4515   4573   ** [sqlite3_free()].
  4516   4574   **
  4517         -** ^(If a memory allocation error occurs during the evaluation of any
  4518         -** of these routines, a default value is returned.  The default value
  4519         -** is either the integer 0, the floating point number 0.0, or a NULL
  4520         -** pointer.  Subsequent calls to [sqlite3_errcode()] will return
  4521         -** [SQLITE_NOMEM].)^
         4575  +** As long as the input parameters are correct, these routines will only
         4576  +** fail if an out-of-memory error occurs during a format conversion.
         4577  +** Only the following subset of interfaces are subject to out-of-memory
         4578  +** errors:
         4579  +**
         4580  +** <ul>
         4581  +** <li> sqlite3_column_blob()
         4582  +** <li> sqlite3_column_text()
         4583  +** <li> sqlite3_column_text16()
         4584  +** <li> sqlite3_column_bytes()
         4585  +** <li> sqlite3_column_bytes16()
         4586  +** </ul>
         4587  +**
         4588  +** If an out-of-memory error occurs, then the return value from these
         4589  +** routines is the same as if the column had contained an SQL NULL value.
         4590  +** Valid SQL NULL returns can be distinguished from out-of-memory errors
         4591  +** by invoking the [sqlite3_errcode()] immediately after the suspect
         4592  +** return value is obtained and before any
         4593  +** other SQLite interface is called on the same [database connection].
  4522   4594   */
  4523   4595   SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
  4524   4596   SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
  4525   4597   SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
  4526   4598   SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
  4527   4599   SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
  4528   4600   SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
................................................................................
  4591   4663   ** KEYWORDS: {function creation routines}
  4592   4664   ** KEYWORDS: {application-defined SQL function}
  4593   4665   ** KEYWORDS: {application-defined SQL functions}
  4594   4666   ** METHOD: sqlite3
  4595   4667   **
  4596   4668   ** ^These functions (collectively known as "function creation routines")
  4597   4669   ** are used to add SQL functions or aggregates or to redefine the behavior
  4598         -** of existing SQL functions or aggregates.  The only differences between
  4599         -** these routines are the text encoding expected for
  4600         -** the second parameter (the name of the function being created)
  4601         -** and the presence or absence of a destructor callback for
  4602         -** the application data pointer.
         4670  +** of existing SQL functions or aggregates. The only differences between
         4671  +** the three "sqlite3_create_function*" routines are the text encoding 
         4672  +** expected for the second parameter (the name of the function being 
         4673  +** created) and the presence or absence of a destructor callback for
         4674  +** the application data pointer. Function sqlite3_create_window_function()
         4675  +** is similar, but allows the user to supply the extra callback functions
         4676  +** needed by [aggregate window functions].
  4603   4677   **
  4604   4678   ** ^The first parameter is the [database connection] to which the SQL
  4605   4679   ** function is to be added.  ^If an application uses more than one database
  4606   4680   ** connection then application-defined SQL functions must be added
  4607   4681   ** to each database connection separately.
  4608   4682   **
  4609   4683   ** ^The second parameter is the name of the SQL function to be created or
................................................................................
  4641   4715   ** function that is not deterministic.  The SQLite query planner is able to
  4642   4716   ** perform additional optimizations on deterministic functions, so use
  4643   4717   ** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
  4644   4718   **
  4645   4719   ** ^(The fifth parameter is an arbitrary pointer.  The implementation of the
  4646   4720   ** function can gain access to this pointer using [sqlite3_user_data()].)^
  4647   4721   **
  4648         -** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are
         4722  +** ^The sixth, seventh and eighth parameters passed to the three
         4723  +** "sqlite3_create_function*" functions, xFunc, xStep and xFinal, are
  4649   4724   ** pointers to C-language functions that implement the SQL function or
  4650   4725   ** aggregate. ^A scalar SQL function requires an implementation of the xFunc
  4651   4726   ** callback only; NULL pointers must be passed as the xStep and xFinal
  4652   4727   ** parameters. ^An aggregate SQL function requires an implementation of xStep
  4653   4728   ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
  4654   4729   ** SQL function or aggregate, pass NULL pointers for all three function
  4655   4730   ** callbacks.
  4656   4731   **
  4657         -** ^(If the ninth parameter to sqlite3_create_function_v2() is not NULL,
  4658         -** then it is destructor for the application data pointer. 
  4659         -** The destructor is invoked when the function is deleted, either by being
  4660         -** overloaded or when the database connection closes.)^
  4661         -** ^The destructor is also invoked if the call to
  4662         -** sqlite3_create_function_v2() fails.
  4663         -** ^When the destructor callback of the tenth parameter is invoked, it
  4664         -** is passed a single argument which is a copy of the application data 
  4665         -** pointer which was the fifth parameter to sqlite3_create_function_v2().
         4732  +** ^The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue 
         4733  +** and xInverse) passed to sqlite3_create_window_function are pointers to
         4734  +** C-lanugage callbacks that implement the new function. xStep and xFinal
         4735  +** must both be non-NULL. xValue and xInverse may either both be NULL, in
         4736  +** which case a regular aggregate function is created, or must both be 
         4737  +** non-NULL, in which case the new function may be used as either an aggregate
         4738  +** or aggregate window function. More details regarding the implementation
         4739  +** of aggregate window functions are 
         4740  +** [user-defined window functions|available here].
         4741  +**
         4742  +** ^(If the final parameter to sqlite3_create_function_v2() or
         4743  +** sqlite3_create_window_function() is not NULL, then it is destructor for
         4744  +** the application data pointer. The destructor is invoked when the function 
         4745  +** is deleted, either by being overloaded or when the database connection 
         4746  +** closes.)^ ^The destructor is also invoked if the call to 
         4747  +** sqlite3_create_function_v2() fails.  ^When the destructor callback is
         4748  +** invoked, it is passed a single argument which is a copy of the application
         4749  +** data pointer which was the fifth parameter to sqlite3_create_function_v2().
  4666   4750   **
  4667   4751   ** ^It is permitted to register multiple implementations of the same
  4668   4752   ** functions with the same name but with either differing numbers of
  4669   4753   ** arguments or differing preferred text encodings.  ^SQLite will use
  4670   4754   ** the implementation that most closely matches the way in which the
  4671   4755   ** SQL function is used.  ^A function implementation with a non-negative
  4672   4756   ** nArg parameter is a better match than a function implementation with
................................................................................
  4710   4794     int nArg,
  4711   4795     int eTextRep,
  4712   4796     void *pApp,
  4713   4797     void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  4714   4798     void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  4715   4799     void (*xFinal)(sqlite3_context*),
  4716   4800     void(*xDestroy)(void*)
         4801  +);
         4802  +SQLITE_API int sqlite3_create_window_function(
         4803  +  sqlite3 *db,
         4804  +  const char *zFunctionName,
         4805  +  int nArg,
         4806  +  int eTextRep,
         4807  +  void *pApp,
         4808  +  void (*xStep)(sqlite3_context*,int,sqlite3_value**),
         4809  +  void (*xFinal)(sqlite3_context*),
         4810  +  void (*xValue)(sqlite3_context*),
         4811  +  void (*xInverse)(sqlite3_context*,int,sqlite3_value**),
         4812  +  void(*xDestroy)(void*)
  4717   4813   );
  4718   4814   
  4719   4815   /*
  4720   4816   ** CAPI3REF: Text Encodings
  4721   4817   **
  4722   4818   ** These constant define integer codes that represent the various
  4723   4819   ** text encodings supported by SQLite.
................................................................................
  4853   4949   ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
  4854   4950   ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
  4855   4951   ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
  4856   4952   ** or [sqlite3_value_text16()].
  4857   4953   **
  4858   4954   ** These routines must be called from the same thread as
  4859   4955   ** the SQL function that supplied the [sqlite3_value*] parameters.
         4956  +**
         4957  +** As long as the input parameter is correct, these routines can only
         4958  +** fail if an out-of-memory error occurs during a format conversion.
         4959  +** Only the following subset of interfaces are subject to out-of-memory
         4960  +** errors:
         4961  +**
         4962  +** <ul>
         4963  +** <li> sqlite3_value_blob()
         4964  +** <li> sqlite3_value_text()
         4965  +** <li> sqlite3_value_text16()
         4966  +** <li> sqlite3_value_text16le()
         4967  +** <li> sqlite3_value_text16be()
         4968  +** <li> sqlite3_value_bytes()
         4969  +** <li> sqlite3_value_bytes16()
         4970  +** </ul>
         4971  +**
         4972  +** If an out-of-memory error occurs, then the return value from these
         4973  +** routines is the same as if the column had contained an SQL NULL value.
         4974  +** Valid SQL NULL returns can be distinguished from out-of-memory errors
         4975  +** by invoking the [sqlite3_errcode()] immediately after the suspect
         4976  +** return value is obtained and before any
         4977  +** other SQLite interface is called on the same [database connection].
  4860   4978   */
  4861   4979   SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
  4862   4980   SQLITE_API double sqlite3_value_double(sqlite3_value*);
  4863   4981   SQLITE_API int sqlite3_value_int(sqlite3_value*);
  4864   4982   SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
  4865   4983   SQLITE_API void *sqlite3_value_pointer(sqlite3_value*, const char*);
  4866   4984   SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
................................................................................
  6319   6437   #define SQLITE_INDEX_CONSTRAINT_GLOB      66
  6320   6438   #define SQLITE_INDEX_CONSTRAINT_REGEXP    67
  6321   6439   #define SQLITE_INDEX_CONSTRAINT_NE        68
  6322   6440   #define SQLITE_INDEX_CONSTRAINT_ISNOT     69
  6323   6441   #define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
  6324   6442   #define SQLITE_INDEX_CONSTRAINT_ISNULL    71
  6325   6443   #define SQLITE_INDEX_CONSTRAINT_IS        72
         6444  +#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
  6326   6445   
  6327   6446   /*
  6328   6447   ** CAPI3REF: Register A Virtual Table Implementation
  6329   6448   ** METHOD: sqlite3
  6330   6449   **
  6331   6450   ** ^These routines are used to register a new [virtual table module] name.
  6332   6451   ** ^Module names must be registered before
................................................................................
  6995   7114   ** routine returns a NULL pointer.
  6996   7115   */
  6997   7116   SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
  6998   7117   
  6999   7118   /*
  7000   7119   ** CAPI3REF: Low-Level Control Of Database Files
  7001   7120   ** METHOD: sqlite3
         7121  +** KEYWORDS: {file control}
  7002   7122   **
  7003   7123   ** ^The [sqlite3_file_control()] interface makes a direct call to the
  7004   7124   ** xFileControl method for the [sqlite3_io_methods] object associated
  7005   7125   ** with a particular database identified by the second argument. ^The
  7006   7126   ** name of the database is "main" for the main database or "temp" for the
  7007   7127   ** TEMP database, or the name that appears after the AS keyword for
  7008   7128   ** databases that are added using the [ATTACH] SQL command.
................................................................................
  7009   7129   ** ^A NULL pointer can be used in place of "main" to refer to the
  7010   7130   ** main database file.
  7011   7131   ** ^The third and fourth parameters to this routine
  7012   7132   ** are passed directly through to the second and third parameters of
  7013   7133   ** the xFileControl method.  ^The return value of the xFileControl
  7014   7134   ** method becomes the return value of this routine.
  7015   7135   **
         7136  +** A few opcodes for [sqlite3_file_control()] are handled directly
         7137  +** by the SQLite core and never invoke the 
         7138  +** sqlite3_io_methods.xFileControl method.
  7016   7139   ** ^The [SQLITE_FCNTL_FILE_POINTER] value for the op parameter causes
  7017   7140   ** a pointer to the underlying [sqlite3_file] object to be written into
  7018         -** the space pointed to by the 4th parameter.  ^The [SQLITE_FCNTL_FILE_POINTER]
  7019         -** case is a short-circuit path which does not actually invoke the
  7020         -** underlying sqlite3_io_methods.xFileControl method.
         7141  +** the space pointed to by the 4th parameter.  The
         7142  +** [SQLITE_FCNTL_JOURNAL_POINTER] works similarly except that it returns
         7143  +** the [sqlite3_file] object associated with the journal file instead of
         7144  +** the main database.  The [SQLITE_FCNTL_VFS_POINTER] opcode returns
         7145  +** a pointer to the underlying [sqlite3_vfs] object for the file.
         7146  +** The [SQLITE_FCNTL_DATA_VERSION] returns the data version counter
         7147  +** from the pager.
  7021   7148   **
  7022   7149   ** ^If the second parameter (zDbName) does not match the name of any
  7023   7150   ** open database file, then SQLITE_ERROR is returned.  ^This error
  7024   7151   ** code is not remembered and will not be recalled by [sqlite3_errcode()]
  7025   7152   ** or [sqlite3_errmsg()].  The underlying xFileControl method might
  7026   7153   ** also return SQLITE_ERROR.  There is no way to distinguish between
  7027   7154   ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
................................................................................
  8832   8959   ** as ENOSPC, EAUTH, EISDIR, and so forth.  
  8833   8960   */
  8834   8961   SQLITE_API int sqlite3_system_errno(sqlite3*);
  8835   8962   
  8836   8963   /*
  8837   8964   ** CAPI3REF: Database Snapshot
  8838   8965   ** KEYWORDS: {snapshot} {sqlite3_snapshot}
  8839         -** EXPERIMENTAL
  8840   8966   **
  8841   8967   ** An instance of the snapshot object records the state of a [WAL mode]
  8842   8968   ** database for some specific point in history.
  8843   8969   **
  8844   8970   ** In [WAL mode], multiple [database connections] that are open on the
  8845   8971   ** same database file can each be reading a different historical version
  8846   8972   ** of the database file.  When a [database connection] begins a read
................................................................................
  8849   8975   ** Subsequent changes to the database from other connections are not seen
  8850   8976   ** by the reader until a new read transaction is started.
  8851   8977   **
  8852   8978   ** The sqlite3_snapshot object records state information about an historical
  8853   8979   ** version of the database file so that it is possible to later open a new read
  8854   8980   ** transaction that sees that historical version of the database rather than
  8855   8981   ** the most recent version.
  8856         -**
  8857         -** The constructor for this object is [sqlite3_snapshot_get()].  The
  8858         -** [sqlite3_snapshot_open()] method causes a fresh read transaction to refer
  8859         -** to an historical snapshot (if possible).  The destructor for 
  8860         -** sqlite3_snapshot objects is [sqlite3_snapshot_free()].
  8861   8982   */
  8862   8983   typedef struct sqlite3_snapshot {
  8863   8984     unsigned char hidden[48];
  8864   8985   } sqlite3_snapshot;
  8865   8986   
  8866   8987   /*
  8867   8988   ** CAPI3REF: Record A Database Snapshot
  8868         -** EXPERIMENTAL
         8989  +** CONSTRUCTOR: sqlite3_snapshot
  8869   8990   **
  8870   8991   ** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
  8871   8992   ** new [sqlite3_snapshot] object that records the current state of
  8872   8993   ** schema S in database connection D.  ^On success, the
  8873   8994   ** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
  8874   8995   ** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
  8875   8996   ** If there is not already a read-transaction open on schema S when
................................................................................
  8877   8998   **
  8878   8999   ** The following must be true for this function to succeed. If any of
  8879   9000   ** the following statements are false when sqlite3_snapshot_get() is
  8880   9001   ** called, SQLITE_ERROR is returned. The final value of *P is undefined
  8881   9002   ** in this case. 
  8882   9003   **
  8883   9004   ** <ul>
  8884         -**   <li> The database handle must be in [autocommit mode].
         9005  +**   <li> The database handle must not be in [autocommit mode].
  8885   9006   **
  8886   9007   **   <li> Schema S of [database connection] D must be a [WAL mode] database.
  8887   9008   **
  8888   9009   **   <li> There must not be a write transaction open on schema S of database
  8889   9010   **        connection D.
  8890   9011   **
  8891   9012   **   <li> One or more transactions must have been written to the current wal
................................................................................
  8900   9021   ** whether or not a read transaction is opened on schema S is undefined.
  8901   9022   **
  8902   9023   ** The [sqlite3_snapshot] object returned from a successful call to
  8903   9024   ** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]
  8904   9025   ** to avoid a memory leak.
  8905   9026   **
  8906   9027   ** The [sqlite3_snapshot_get()] interface is only available when the
  8907         -** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
         9028  +** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
  8908   9029   */
  8909   9030   SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(
  8910   9031     sqlite3 *db,
  8911   9032     const char *zSchema,
  8912   9033     sqlite3_snapshot **ppSnapshot
  8913   9034   );
  8914   9035   
  8915   9036   /*
  8916   9037   ** CAPI3REF: Start a read transaction on an historical snapshot
  8917         -** EXPERIMENTAL
  8918         -**
  8919         -** ^The [sqlite3_snapshot_open(D,S,P)] interface starts a
  8920         -** read transaction for schema S of
  8921         -** [database connection] D such that the read transaction
  8922         -** refers to historical [snapshot] P, rather than the most
  8923         -** recent change to the database.
  8924         -** ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK on success
  8925         -** or an appropriate [error code] if it fails.
  8926         -**
  8927         -** ^In order to succeed, a call to [sqlite3_snapshot_open(D,S,P)] must be
  8928         -** the first operation following the [BEGIN] that takes the schema S
  8929         -** out of [autocommit mode].
  8930         -** ^In other words, schema S must not currently be in
  8931         -** a transaction for [sqlite3_snapshot_open(D,S,P)] to work, but the
  8932         -** database connection D must be out of [autocommit mode].
  8933         -** ^A [snapshot] will fail to open if it has been overwritten by a
  8934         -** [checkpoint].
         9038  +** METHOD: sqlite3_snapshot
         9039  +**
         9040  +** ^The [sqlite3_snapshot_open(D,S,P)] interface either starts a new read 
         9041  +** transaction or upgrades an existing one for schema S of 
         9042  +** [database connection] D such that the read transaction refers to 
         9043  +** historical [snapshot] P, rather than the most recent change to the 
         9044  +** database. ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK 
         9045  +** on success or an appropriate [error code] if it fails.
         9046  +**
         9047  +** ^In order to succeed, the database connection must not be in 
         9048  +** [autocommit mode] when [sqlite3_snapshot_open(D,S,P)] is called. If there
         9049  +** is already a read transaction open on schema S, then the database handle
         9050  +** must have no active statements (SELECT statements that have been passed
         9051  +** to sqlite3_step() but not sqlite3_reset() or sqlite3_finalize()). 
         9052  +** SQLITE_ERROR is returned if either of these conditions is violated, or
         9053  +** if schema S does not exist, or if the snapshot object is invalid.
         9054  +**
         9055  +** ^A call to sqlite3_snapshot_open() will fail to open if the specified
         9056  +** snapshot has been overwritten by a [checkpoint]. In this case 
         9057  +** SQLITE_ERROR_SNAPSHOT is returned.
         9058  +**
         9059  +** If there is already a read transaction open when this function is 
         9060  +** invoked, then the same read transaction remains open (on the same
         9061  +** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_ERROR_SNAPSHOT
         9062  +** is returned. If another error code - for example SQLITE_PROTOCOL or an
         9063  +** SQLITE_IOERR error code - is returned, then the final state of the
         9064  +** read transaction is undefined. If SQLITE_OK is returned, then the 
         9065  +** read transaction is now open on database snapshot P.
         9066  +**
  8935   9067   ** ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the
  8936   9068   ** database connection D does not know that the database file for
  8937   9069   ** schema S is in [WAL mode].  A database connection might not know
  8938   9070   ** that the database file is in [WAL mode] if there has been no prior
  8939   9071   ** I/O on that database connection, or if the database entered [WAL mode] 
  8940   9072   ** after the most recent I/O on the database connection.)^
  8941   9073   ** (Hint: Run "[PRAGMA application_id]" against a newly opened
  8942   9074   ** database connection in order to make it ready to use snapshots.)
  8943   9075   **
  8944   9076   ** The [sqlite3_snapshot_open()] interface is only available when the
  8945         -** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
         9077  +** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
  8946   9078   */
  8947   9079   SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(
  8948   9080     sqlite3 *db,
  8949   9081     const char *zSchema,
  8950   9082     sqlite3_snapshot *pSnapshot
  8951   9083   );
  8952   9084   
  8953   9085   /*
  8954   9086   ** CAPI3REF: Destroy a snapshot
  8955         -** EXPERIMENTAL
         9087  +** DESTRUCTOR: sqlite3_snapshot
  8956   9088   **
  8957   9089   ** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
  8958   9090   ** The application must eventually free every [sqlite3_snapshot] object
  8959   9091   ** using this routine to avoid a memory leak.
  8960   9092   **
  8961   9093   ** The [sqlite3_snapshot_free()] interface is only available when the
  8962         -** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
         9094  +** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
  8963   9095   */
  8964   9096   SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);
  8965   9097   
  8966   9098   /*
  8967   9099   ** CAPI3REF: Compare the ages of two snapshot handles.
  8968         -** EXPERIMENTAL
         9100  +** METHOD: sqlite3_snapshot
  8969   9101   **
  8970   9102   ** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages
  8971   9103   ** of two valid snapshot handles. 
  8972   9104   **
  8973   9105   ** If the two snapshot handles are not associated with the same database 
  8974   9106   ** file, the result of the comparison is undefined. 
  8975   9107   **
................................................................................
  8980   9112   ** clients drops to zero. If either snapshot handle was obtained before the 
  8981   9113   ** wal file was last deleted, the value returned by this function 
  8982   9114   ** is undefined.
  8983   9115   **
  8984   9116   ** Otherwise, this API returns a negative value if P1 refers to an older
  8985   9117   ** snapshot than P2, zero if the two handles refer to the same database
  8986   9118   ** snapshot, and a positive value if P1 is a newer snapshot than P2.
         9119  +**
         9120  +** This interface is only available if SQLite is compiled with the
         9121  +** [SQLITE_ENABLE_SNAPSHOT] option.
  8987   9122   */
  8988   9123   SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(
  8989   9124     sqlite3_snapshot *p1,
  8990   9125     sqlite3_snapshot *p2
  8991   9126   );
  8992   9127   
  8993   9128   /*
  8994   9129   ** CAPI3REF: Recover snapshots from a wal file
  8995         -** EXPERIMENTAL
         9130  +** METHOD: sqlite3_snapshot
  8996   9131   **
  8997         -** If all connections disconnect from a database file but do not perform
  8998         -** a checkpoint, the existing wal file is opened along with the database
  8999         -** file the next time the database is opened. At this point it is only
  9000         -** possible to successfully call sqlite3_snapshot_open() to open the most
  9001         -** recent snapshot of the database (the one at the head of the wal file),
  9002         -** even though the wal file may contain other valid snapshots for which
  9003         -** clients have sqlite3_snapshot handles.
         9132  +** If a [WAL file] remains on disk after all database connections close
         9133  +** (either through the use of the [SQLITE_FCNTL_PERSIST_WAL] [file control]
         9134  +** or because the last process to have the database opened exited without
         9135  +** calling [sqlite3_close()]) and a new connection is subsequently opened
         9136  +** on that database and [WAL file], the [sqlite3_snapshot_open()] interface
         9137  +** will only be able to open the last transaction added to the WAL file
         9138  +** even though the WAL file contains other valid transactions.
  9004   9139   **
  9005         -** This function attempts to scan the wal file associated with database zDb
         9140  +** This function attempts to scan the WAL file associated with database zDb
  9006   9141   ** of database handle db and make all valid snapshots available to
  9007   9142   ** sqlite3_snapshot_open(). It is an error if there is already a read
  9008         -** transaction open on the database, or if the database is not a wal mode
         9143  +** transaction open on the database, or if the database is not a WAL mode
  9009   9144   ** database.
  9010   9145   **
  9011   9146   ** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
         9147  +**
         9148  +** This interface is only available if SQLite is compiled with the
         9149  +** [SQLITE_ENABLE_SNAPSHOT] option.
  9012   9150   */
  9013   9151   SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
  9014   9152   
  9015   9153   /*
  9016   9154   ** CAPI3REF: Serialize a database
  9017   9155   **
  9018   9156   ** The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory
................................................................................
  9034   9172   ** to the contiguous memory representation of the database that SQLite
  9035   9173   ** is currently using for that database, or NULL if the no such contiguous
  9036   9174   ** memory representation of the database exists.  A contiguous memory
  9037   9175   ** representation of the database will usually only exist if there has
  9038   9176   ** been a prior call to [sqlite3_deserialize(D,S,...)] with the same
  9039   9177   ** values of D and S.
  9040   9178   ** The size of the database is written into *P even if the 
  9041         -** SQLITE_SERIALIZE_NOCOPY bit is set but no contigious copy
         9179  +** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy
  9042   9180   ** of the database exists.
  9043   9181   **
  9044   9182   ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
  9045   9183   ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory
  9046   9184   ** allocation error occurs.
  9047   9185   **
  9048   9186   ** This interface is only available if SQLite is compiled with the