SQLite Android Bindings
Check-in [5efce2bd32]
Not logged in

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

Overview
Comment:Update this project to 3.25.0.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 5efce2bd32e3782cd5289070168a3ee33709238c
User & Date: dan 2018-09-18 19:25:26
Context
2018-09-18
19:41
Cherrypick SQLite commit e41e50fe into this project. Also add -DSQLITE_ENABLE_BATCH_ATOMIC_WRITE in Android.mk. check-in: a113b9be83 user: dan tags: trunk
19:25
Update this project to 3.25.0. check-in: 5efce2bd32 user: dan tags: trunk
2018-09-04
17:24
Upgrade gradle version to 3.1.4. check-in: 193bea893f user: dan tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to sqlite3/build.gradle.

    37     37   dependencies {
    38     38       compile fileTree(include: ['*.jar'], dir: 'libs')
    39     39       androidTestCompile 'com.android.support:support-annotations:24.0.0'
    40     40       androidTestCompile 'com.android.support.test:runner:0.5'
    41     41       androidTestCompile 'com.android.support.test:rules:0.5'
    42     42       testCompile 'junit:junit:4.12'
    43     43   }
           44  +
           45  +allprojects {
           46  +    repositories {
           47  +        // The order in which you list these repositories matter.
           48  +        google()
           49  +        jcenter()
           50  +    }
           51  +}

Changes to sqlite3/src/main/jni/sqlite/sqlite3.c.

more than 10,000 changes

Changes to sqlite3/src/main/jni/sqlite/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-06-04 19:24:41 c7ee0833225bfd8c5ec2f9bf62b97c4e04d03bd9566366d5221ac8fb199a87ca"
          126  +#define SQLITE_VERSION        "3.25.0"
          127  +#define SQLITE_VERSION_NUMBER 3025000
          128  +#define SQLITE_SOURCE_ID      "2018-09-15 04:01:47 b63af6c3bd33152742648d5d2e8dc5d5fcbcdd27df409272b6aea00a6f761760"
   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 responds 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 responds 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 on which it is
         1095  +** called.  This file control is the only mechanism to detect changes that
         1096  +** happen either internally or externally and that are associated with
         1097  +** a particular attached database.
  1075   1098   ** </ul>
  1076   1099   */
  1077   1100   #define SQLITE_FCNTL_LOCKSTATE               1
  1078   1101   #define SQLITE_FCNTL_GET_LOCKPROXYFILE       2
  1079   1102   #define SQLITE_FCNTL_SET_LOCKPROXYFILE       3
  1080   1103   #define SQLITE_FCNTL_LAST_ERRNO              4
  1081   1104   #define SQLITE_FCNTL_SIZE_HINT               5
................................................................................
  1103   1126   #define SQLITE_FCNTL_JOURNAL_POINTER        28
  1104   1127   #define SQLITE_FCNTL_WIN32_GET_HANDLE       29
  1105   1128   #define SQLITE_FCNTL_PDB                    30
  1106   1129   #define SQLITE_FCNTL_BEGIN_ATOMIC_WRITE     31
  1107   1130   #define SQLITE_FCNTL_COMMIT_ATOMIC_WRITE    32
  1108   1131   #define SQLITE_FCNTL_ROLLBACK_ATOMIC_WRITE  33
  1109   1132   #define SQLITE_FCNTL_LOCK_TIMEOUT           34
         1133  +#define SQLITE_FCNTL_DATA_VERSION           35
  1110   1134   
  1111   1135   /* deprecated names */
  1112   1136   #define SQLITE_GET_LOCKPROXYFILE      SQLITE_FCNTL_GET_LOCKPROXYFILE
  1113   1137   #define SQLITE_SET_LOCKPROXYFILE      SQLITE_FCNTL_SET_LOCKPROXYFILE
  1114   1138   #define SQLITE_LAST_ERRNO             SQLITE_FCNTL_LAST_ERRNO
  1115   1139   
  1116   1140   
................................................................................
  2117   2141   **
  2118   2142   ** <dt>SQLITE_DBCONFIG_RESET_DATABASE</dt>
  2119   2143   ** <dd> Set the SQLITE_DBCONFIG_RESET_DATABASE flag and then run
  2120   2144   ** [VACUUM] in order to reset a database back to an empty database
  2121   2145   ** with no schema and no content. The following process works even for
  2122   2146   ** a badly corrupted database file:
  2123   2147   ** <ol>
         2148  +** <li> If the database connection is newly opened, make sure it has read the
         2149  +**      database schema by preparing then discarding some query against the
         2150  +**      database, or calling sqlite3_table_column_metadata(), ignoring any
         2151  +**      errors.  This step is only necessary if the application desires to keep
         2152  +**      the database in WAL mode after the reset if it was in WAL mode before
         2153  +**      the reset.  
  2124   2154   ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 1, 0);
  2125   2155   ** <li> [sqlite3_exec](db, "[VACUUM]", 0, 0, 0);
  2126   2156   ** <li> sqlite3_db_config(db, SQLITE_DBCONFIG_RESET_DATABASE, 0, 0);
  2127   2157   ** </ol>
  2128   2158   ** Because resetting a database is destructive and irreversible, the
  2129   2159   ** process requires the use of this obscure API and multiple steps to help
  2130   2160   ** ensure that it does not happen by accident.
................................................................................
  2265   2295   ** ^This means that if the changes() SQL function (or similar) is used
  2266   2296   ** by the first INSERT, UPDATE or DELETE statement within a trigger, it 
  2267   2297   ** returns the value as set when the calling statement began executing.
  2268   2298   ** ^If it is used by the second or subsequent such statement within a trigger 
  2269   2299   ** program, the value returned reflects the number of rows modified by the 
  2270   2300   ** previous INSERT, UPDATE or DELETE statement within the same trigger.
  2271   2301   **
  2272         -** See also the [sqlite3_total_changes()] interface, the
  2273         -** [count_changes pragma], and the [changes() SQL function].
  2274         -**
  2275   2302   ** If a separate thread makes changes on the same database connection
  2276   2303   ** while [sqlite3_changes()] is running then the value returned
  2277   2304   ** is unpredictable and not meaningful.
         2305  +**
         2306  +** See also:
         2307  +** <ul>
         2308  +** <li> the [sqlite3_total_changes()] interface
         2309  +** <li> the [count_changes pragma]
         2310  +** <li> the [changes() SQL function]
         2311  +** <li> the [data_version pragma]
         2312  +** </ul>
  2278   2313   */
  2279   2314   SQLITE_API int sqlite3_changes(sqlite3*);
  2280   2315   
  2281   2316   /*
  2282   2317   ** CAPI3REF: Total Number Of Rows Modified
  2283   2318   ** METHOD: sqlite3
  2284   2319   **
................................................................................
  2288   2323   ** part of trigger programs. ^Executing any other type of SQL statement
  2289   2324   ** does not affect the value returned by sqlite3_total_changes().
  2290   2325   ** 
  2291   2326   ** ^Changes made as part of [foreign key actions] are included in the
  2292   2327   ** count, but those made as part of REPLACE constraint resolution are
  2293   2328   ** not. ^Changes to a view that are intercepted by INSTEAD OF triggers 
  2294   2329   ** are not counted.
         2330  +**
         2331  +** This the [sqlite3_total_changes(D)] interface only reports the number
         2332  +** of rows that changed due to SQL statement run against database
         2333  +** connection D.  Any changes by other database connections are ignored.
         2334  +** To detect changes against a database file from other database
         2335  +** connections use the [PRAGMA data_version] command or the
         2336  +** [SQLITE_FCNTL_DATA_VERSION] [file control].
  2295   2337   ** 
  2296         -** See also the [sqlite3_changes()] interface, the
  2297         -** [count_changes pragma], and the [total_changes() SQL function].
  2298         -**
  2299   2338   ** If a separate thread makes changes on the same database connection
  2300   2339   ** while [sqlite3_total_changes()] is running then the value
  2301   2340   ** returned is unpredictable and not meaningful.
         2341  +**
         2342  +** See also:
         2343  +** <ul>
         2344  +** <li> the [sqlite3_changes()] interface
         2345  +** <li> the [count_changes pragma]
         2346  +** <li> the [changes() SQL function]
         2347  +** <li> the [data_version pragma]
         2348  +** <li> the [SQLITE_FCNTL_DATA_VERSION] [file control]
         2349  +** </ul>
  2302   2350   */
  2303   2351   SQLITE_API int sqlite3_total_changes(sqlite3*);
  2304   2352   
  2305   2353   /*
  2306   2354   ** CAPI3REF: Interrupt A Long-Running Query
  2307   2355   ** METHOD: sqlite3
  2308   2356   **
................................................................................
  3350   3398   ** CAPI3REF: Error Codes And Messages
  3351   3399   ** METHOD: sqlite3
  3352   3400   **
  3353   3401   ** ^If the most recent sqlite3_* API call associated with 
  3354   3402   ** [database connection] D failed, then the sqlite3_errcode(D) interface
  3355   3403   ** returns the numeric [result code] or [extended result code] for that
  3356   3404   ** API call.
  3357         -** If the most recent API call was successful,
  3358         -** then the return value from sqlite3_errcode() is undefined.
  3359   3405   ** ^The sqlite3_extended_errcode()
  3360   3406   ** interface is the same except that it always returns the 
  3361   3407   ** [extended result code] even when extended result codes are
  3362   3408   ** disabled.
         3409  +**
         3410  +** The values returned by sqlite3_errcode() and/or
         3411  +** sqlite3_extended_errcode() might change with each API call.
         3412  +** Except, there are some interfaces that are guaranteed to never
         3413  +** change the value of the error code.  The error-code preserving
         3414  +** interfaces are:
         3415  +**
         3416  +** <ul>
         3417  +** <li> sqlite3_errcode()
         3418  +** <li> sqlite3_extended_errcode()
         3419  +** <li> sqlite3_errmsg()
         3420  +** <li> sqlite3_errmsg16()
         3421  +** </ul>
  3363   3422   **
  3364   3423   ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
  3365   3424   ** text that describes the error, as either UTF-8 or UTF-16 respectively.
  3366   3425   ** ^(Memory to hold the error message string is managed internally.
  3367   3426   ** The application does not need to worry about freeing the result.
  3368   3427   ** However, the error string might be overwritten or deallocated by
  3369   3428   ** subsequent calls to other SQLite interface functions.)^
................................................................................
  4510   4569   ** ^The pointers returned are valid until a type conversion occurs as
  4511   4570   ** described above, or until [sqlite3_step()] or [sqlite3_reset()] or
  4512   4571   ** [sqlite3_finalize()] is called.  ^The memory space used to hold strings
  4513   4572   ** and BLOBs is freed automatically.  Do not pass the pointers returned
  4514   4573   ** from [sqlite3_column_blob()], [sqlite3_column_text()], etc. into
  4515   4574   ** [sqlite3_free()].
  4516   4575   **
  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].)^
         4576  +** As long as the input parameters are correct, these routines will only
         4577  +** fail if an out-of-memory error occurs during a format conversion.
         4578  +** Only the following subset of interfaces are subject to out-of-memory
         4579  +** errors:
         4580  +**
         4581  +** <ul>
         4582  +** <li> sqlite3_column_blob()
         4583  +** <li> sqlite3_column_text()
         4584  +** <li> sqlite3_column_text16()
         4585  +** <li> sqlite3_column_bytes()
         4586  +** <li> sqlite3_column_bytes16()
         4587  +** </ul>
         4588  +**
         4589  +** If an out-of-memory error occurs, then the return value from these
         4590  +** routines is the same as if the column had contained an SQL NULL value.
         4591  +** Valid SQL NULL returns can be distinguished from out-of-memory errors
         4592  +** by invoking the [sqlite3_errcode()] immediately after the suspect
         4593  +** return value is obtained and before any
         4594  +** other SQLite interface is called on the same [database connection].
  4522   4595   */
  4523   4596   SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
  4524   4597   SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
  4525   4598   SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
  4526   4599   SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
  4527   4600   SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
  4528   4601   SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
................................................................................
  4591   4664   ** KEYWORDS: {function creation routines}
  4592   4665   ** KEYWORDS: {application-defined SQL function}
  4593   4666   ** KEYWORDS: {application-defined SQL functions}
  4594   4667   ** METHOD: sqlite3
  4595   4668   **
  4596   4669   ** ^These functions (collectively known as "function creation routines")
  4597   4670   ** 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.
         4671  +** of existing SQL functions or aggregates. The only differences between
         4672  +** the three "sqlite3_create_function*" routines are the text encoding 
         4673  +** expected for the second parameter (the name of the function being 
         4674  +** created) and the presence or absence of a destructor callback for
         4675  +** the application data pointer. Function sqlite3_create_window_function()
         4676  +** is similar, but allows the user to supply the extra callback functions
         4677  +** needed by [aggregate window functions].
  4603   4678   **
  4604   4679   ** ^The first parameter is the [database connection] to which the SQL
  4605   4680   ** function is to be added.  ^If an application uses more than one database
  4606   4681   ** connection then application-defined SQL functions must be added
  4607   4682   ** to each database connection separately.
  4608   4683   **
  4609   4684   ** ^The second parameter is the name of the SQL function to be created or
................................................................................
  4641   4716   ** function that is not deterministic.  The SQLite query planner is able to
  4642   4717   ** perform additional optimizations on deterministic functions, so use
  4643   4718   ** of the [SQLITE_DETERMINISTIC] flag is recommended where possible.
  4644   4719   **
  4645   4720   ** ^(The fifth parameter is an arbitrary pointer.  The implementation of the
  4646   4721   ** function can gain access to this pointer using [sqlite3_user_data()].)^
  4647   4722   **
  4648         -** ^The sixth, seventh and eighth parameters, xFunc, xStep and xFinal, are
         4723  +** ^The sixth, seventh and eighth parameters passed to the three
         4724  +** "sqlite3_create_function*" functions, xFunc, xStep and xFinal, are
  4649   4725   ** pointers to C-language functions that implement the SQL function or
  4650   4726   ** aggregate. ^A scalar SQL function requires an implementation of the xFunc
  4651   4727   ** callback only; NULL pointers must be passed as the xStep and xFinal
  4652   4728   ** parameters. ^An aggregate SQL function requires an implementation of xStep
  4653   4729   ** and xFinal and NULL pointer must be passed for xFunc. ^To delete an existing
  4654   4730   ** SQL function or aggregate, pass NULL pointers for all three function
  4655   4731   ** callbacks.
  4656   4732   **
  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().
         4733  +** ^The sixth, seventh, eighth and ninth parameters (xStep, xFinal, xValue 
         4734  +** and xInverse) passed to sqlite3_create_window_function are pointers to
         4735  +** C-language callbacks that implement the new function. xStep and xFinal
         4736  +** must both be non-NULL. xValue and xInverse may either both be NULL, in
         4737  +** which case a regular aggregate function is created, or must both be 
         4738  +** non-NULL, in which case the new function may be used as either an aggregate
         4739  +** or aggregate window function. More details regarding the implementation
         4740  +** of aggregate window functions are 
         4741  +** [user-defined window functions|available here].
         4742  +**
         4743  +** ^(If the final parameter to sqlite3_create_function_v2() or
         4744  +** sqlite3_create_window_function() is not NULL, then it is destructor for
         4745  +** the application data pointer. The destructor is invoked when the function 
         4746  +** is deleted, either by being overloaded or when the database connection 
         4747  +** closes.)^ ^The destructor is also invoked if the call to 
         4748  +** sqlite3_create_function_v2() fails.  ^When the destructor callback is
         4749  +** invoked, it is passed a single argument which is a copy of the application
         4750  +** data pointer which was the fifth parameter to sqlite3_create_function_v2().
  4666   4751   **
  4667   4752   ** ^It is permitted to register multiple implementations of the same
  4668   4753   ** functions with the same name but with either differing numbers of
  4669   4754   ** arguments or differing preferred text encodings.  ^SQLite will use
  4670   4755   ** the implementation that most closely matches the way in which the
  4671   4756   ** SQL function is used.  ^A function implementation with a non-negative
  4672   4757   ** nArg parameter is a better match than a function implementation with
................................................................................
  4710   4795     int nArg,
  4711   4796     int eTextRep,
  4712   4797     void *pApp,
  4713   4798     void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
  4714   4799     void (*xStep)(sqlite3_context*,int,sqlite3_value**),
  4715   4800     void (*xFinal)(sqlite3_context*),
  4716   4801     void(*xDestroy)(void*)
         4802  +);
         4803  +SQLITE_API int sqlite3_create_window_function(
         4804  +  sqlite3 *db,
         4805  +  const char *zFunctionName,
         4806  +  int nArg,
         4807  +  int eTextRep,
         4808  +  void *pApp,
         4809  +  void (*xStep)(sqlite3_context*,int,sqlite3_value**),
         4810  +  void (*xFinal)(sqlite3_context*),
         4811  +  void (*xValue)(sqlite3_context*),
         4812  +  void (*xInverse)(sqlite3_context*,int,sqlite3_value**),
         4813  +  void(*xDestroy)(void*)
  4717   4814   );
  4718   4815   
  4719   4816   /*
  4720   4817   ** CAPI3REF: Text Encodings
  4721   4818   **
  4722   4819   ** These constant define integer codes that represent the various
  4723   4820   ** text encodings supported by SQLite.
................................................................................
  4853   4950   ** from [sqlite3_value_blob()], [sqlite3_value_text()], or
  4854   4951   ** [sqlite3_value_text16()] can be invalidated by a subsequent call to
  4855   4952   ** [sqlite3_value_bytes()], [sqlite3_value_bytes16()], [sqlite3_value_text()],
  4856   4953   ** or [sqlite3_value_text16()].
  4857   4954   **
  4858   4955   ** These routines must be called from the same thread as
  4859   4956   ** the SQL function that supplied the [sqlite3_value*] parameters.
         4957  +**
         4958  +** As long as the input parameter is correct, these routines can only
         4959  +** fail if an out-of-memory error occurs during a format conversion.
         4960  +** Only the following subset of interfaces are subject to out-of-memory
         4961  +** errors:
         4962  +**
         4963  +** <ul>
         4964  +** <li> sqlite3_value_blob()
         4965  +** <li> sqlite3_value_text()
         4966  +** <li> sqlite3_value_text16()
         4967  +** <li> sqlite3_value_text16le()
         4968  +** <li> sqlite3_value_text16be()
         4969  +** <li> sqlite3_value_bytes()
         4970  +** <li> sqlite3_value_bytes16()
         4971  +** </ul>
         4972  +**
         4973  +** If an out-of-memory error occurs, then the return value from these
         4974  +** routines is the same as if the column had contained an SQL NULL value.
         4975  +** Valid SQL NULL returns can be distinguished from out-of-memory errors
         4976  +** by invoking the [sqlite3_errcode()] immediately after the suspect
         4977  +** return value is obtained and before any
         4978  +** other SQLite interface is called on the same [database connection].
  4860   4979   */
  4861   4980   SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
  4862   4981   SQLITE_API double sqlite3_value_double(sqlite3_value*);
  4863   4982   SQLITE_API int sqlite3_value_int(sqlite3_value*);
  4864   4983   SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
  4865   4984   SQLITE_API void *sqlite3_value_pointer(sqlite3_value*, const char*);
  4866   4985   SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
................................................................................
  6319   6438   #define SQLITE_INDEX_CONSTRAINT_GLOB      66
  6320   6439   #define SQLITE_INDEX_CONSTRAINT_REGEXP    67
  6321   6440   #define SQLITE_INDEX_CONSTRAINT_NE        68
  6322   6441   #define SQLITE_INDEX_CONSTRAINT_ISNOT     69
  6323   6442   #define SQLITE_INDEX_CONSTRAINT_ISNOTNULL 70
  6324   6443   #define SQLITE_INDEX_CONSTRAINT_ISNULL    71
  6325   6444   #define SQLITE_INDEX_CONSTRAINT_IS        72
         6445  +#define SQLITE_INDEX_CONSTRAINT_FUNCTION 150
  6326   6446   
  6327   6447   /*
  6328   6448   ** CAPI3REF: Register A Virtual Table Implementation
  6329   6449   ** METHOD: sqlite3
  6330   6450   **
  6331   6451   ** ^These routines are used to register a new [virtual table module] name.
  6332   6452   ** ^Module names must be registered before
................................................................................
  6995   7115   ** routine returns a NULL pointer.
  6996   7116   */
  6997   7117   SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
  6998   7118   
  6999   7119   /*
  7000   7120   ** CAPI3REF: Low-Level Control Of Database Files
  7001   7121   ** METHOD: sqlite3
         7122  +** KEYWORDS: {file control}
  7002   7123   **
  7003   7124   ** ^The [sqlite3_file_control()] interface makes a direct call to the
  7004   7125   ** xFileControl method for the [sqlite3_io_methods] object associated
  7005   7126   ** with a particular database identified by the second argument. ^The
  7006   7127   ** name of the database is "main" for the main database or "temp" for the
  7007   7128   ** TEMP database, or the name that appears after the AS keyword for
  7008   7129   ** databases that are added using the [ATTACH] SQL command.
................................................................................
  7009   7130   ** ^A NULL pointer can be used in place of "main" to refer to the
  7010   7131   ** main database file.
  7011   7132   ** ^The third and fourth parameters to this routine
  7012   7133   ** are passed directly through to the second and third parameters of
  7013   7134   ** the xFileControl method.  ^The return value of the xFileControl
  7014   7135   ** method becomes the return value of this routine.
  7015   7136   **
         7137  +** A few opcodes for [sqlite3_file_control()] are handled directly
         7138  +** by the SQLite core and never invoke the 
         7139  +** sqlite3_io_methods.xFileControl method.
  7016   7140   ** ^The [SQLITE_FCNTL_FILE_POINTER] value for the op parameter causes
  7017   7141   ** 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.
         7142  +** the space pointed to by the 4th parameter.  The
         7143  +** [SQLITE_FCNTL_JOURNAL_POINTER] works similarly except that it returns
         7144  +** the [sqlite3_file] object associated with the journal file instead of
         7145  +** the main database.  The [SQLITE_FCNTL_VFS_POINTER] opcode returns
         7146  +** a pointer to the underlying [sqlite3_vfs] object for the file.
         7147  +** The [SQLITE_FCNTL_DATA_VERSION] returns the data version counter
         7148  +** from the pager.
  7021   7149   **
  7022   7150   ** ^If the second parameter (zDbName) does not match the name of any
  7023   7151   ** open database file, then SQLITE_ERROR is returned.  ^This error
  7024   7152   ** code is not remembered and will not be recalled by [sqlite3_errcode()]
  7025   7153   ** or [sqlite3_errmsg()].  The underlying xFileControl method might
  7026   7154   ** also return SQLITE_ERROR.  There is no way to distinguish between
  7027   7155   ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
................................................................................
  8832   8960   ** as ENOSPC, EAUTH, EISDIR, and so forth.  
  8833   8961   */
  8834   8962   SQLITE_API int sqlite3_system_errno(sqlite3*);
  8835   8963   
  8836   8964   /*
  8837   8965   ** CAPI3REF: Database Snapshot
  8838   8966   ** KEYWORDS: {snapshot} {sqlite3_snapshot}
  8839         -** EXPERIMENTAL
  8840   8967   **
  8841   8968   ** An instance of the snapshot object records the state of a [WAL mode]
  8842   8969   ** database for some specific point in history.
  8843   8970   **
  8844   8971   ** In [WAL mode], multiple [database connections] that are open on the
  8845   8972   ** same database file can each be reading a different historical version
  8846   8973   ** of the database file.  When a [database connection] begins a read
................................................................................
  8849   8976   ** Subsequent changes to the database from other connections are not seen
  8850   8977   ** by the reader until a new read transaction is started.
  8851   8978   **
  8852   8979   ** The sqlite3_snapshot object records state information about an historical
  8853   8980   ** version of the database file so that it is possible to later open a new read
  8854   8981   ** transaction that sees that historical version of the database rather than
  8855   8982   ** 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   8983   */
  8862   8984   typedef struct sqlite3_snapshot {
  8863   8985     unsigned char hidden[48];
  8864   8986   } sqlite3_snapshot;
  8865   8987   
  8866   8988   /*
  8867   8989   ** CAPI3REF: Record A Database Snapshot
  8868         -** EXPERIMENTAL
         8990  +** CONSTRUCTOR: sqlite3_snapshot
  8869   8991   **
  8870   8992   ** ^The [sqlite3_snapshot_get(D,S,P)] interface attempts to make a
  8871   8993   ** new [sqlite3_snapshot] object that records the current state of
  8872   8994   ** schema S in database connection D.  ^On success, the
  8873   8995   ** [sqlite3_snapshot_get(D,S,P)] interface writes a pointer to the newly
  8874   8996   ** created [sqlite3_snapshot] object into *P and returns SQLITE_OK.
  8875   8997   ** If there is not already a read-transaction open on schema S when
................................................................................
  8877   8999   **
  8878   9000   ** The following must be true for this function to succeed. If any of
  8879   9001   ** the following statements are false when sqlite3_snapshot_get() is
  8880   9002   ** called, SQLITE_ERROR is returned. The final value of *P is undefined
  8881   9003   ** in this case. 
  8882   9004   **
  8883   9005   ** <ul>
  8884         -**   <li> The database handle must be in [autocommit mode].
         9006  +**   <li> The database handle must not be in [autocommit mode].
  8885   9007   **
  8886   9008   **   <li> Schema S of [database connection] D must be a [WAL mode] database.
  8887   9009   **
  8888   9010   **   <li> There must not be a write transaction open on schema S of database
  8889   9011   **        connection D.
  8890   9012   **
  8891   9013   **   <li> One or more transactions must have been written to the current wal
................................................................................
  8900   9022   ** whether or not a read transaction is opened on schema S is undefined.
  8901   9023   **
  8902   9024   ** The [sqlite3_snapshot] object returned from a successful call to
  8903   9025   ** [sqlite3_snapshot_get()] must be freed using [sqlite3_snapshot_free()]
  8904   9026   ** to avoid a memory leak.
  8905   9027   **
  8906   9028   ** The [sqlite3_snapshot_get()] interface is only available when the
  8907         -** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
         9029  +** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
  8908   9030   */
  8909   9031   SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(
  8910   9032     sqlite3 *db,
  8911   9033     const char *zSchema,
  8912   9034     sqlite3_snapshot **ppSnapshot
  8913   9035   );
  8914   9036   
  8915   9037   /*
  8916   9038   ** 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].
         9039  +** METHOD: sqlite3_snapshot
         9040  +**
         9041  +** ^The [sqlite3_snapshot_open(D,S,P)] interface either starts a new read 
         9042  +** transaction or upgrades an existing one for schema S of 
         9043  +** [database connection] D such that the read transaction refers to 
         9044  +** historical [snapshot] P, rather than the most recent change to the 
         9045  +** database. ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK 
         9046  +** on success or an appropriate [error code] if it fails.
         9047  +**
         9048  +** ^In order to succeed, the database connection must not be in 
         9049  +** [autocommit mode] when [sqlite3_snapshot_open(D,S,P)] is called. If there
         9050  +** is already a read transaction open on schema S, then the database handle
         9051  +** must have no active statements (SELECT statements that have been passed
         9052  +** to sqlite3_step() but not sqlite3_reset() or sqlite3_finalize()). 
         9053  +** SQLITE_ERROR is returned if either of these conditions is violated, or
         9054  +** if schema S does not exist, or if the snapshot object is invalid.
         9055  +**
         9056  +** ^A call to sqlite3_snapshot_open() will fail to open if the specified
         9057  +** snapshot has been overwritten by a [checkpoint]. In this case 
         9058  +** SQLITE_ERROR_SNAPSHOT is returned.
         9059  +**
         9060  +** If there is already a read transaction open when this function is 
         9061  +** invoked, then the same read transaction remains open (on the same
         9062  +** database snapshot) if SQLITE_ERROR, SQLITE_BUSY or SQLITE_ERROR_SNAPSHOT
         9063  +** is returned. If another error code - for example SQLITE_PROTOCOL or an
         9064  +** SQLITE_IOERR error code - is returned, then the final state of the
         9065  +** read transaction is undefined. If SQLITE_OK is returned, then the 
         9066  +** read transaction is now open on database snapshot P.
         9067  +**
  8935   9068   ** ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the
  8936   9069   ** database connection D does not know that the database file for
  8937   9070   ** schema S is in [WAL mode].  A database connection might not know
  8938   9071   ** that the database file is in [WAL mode] if there has been no prior
  8939   9072   ** I/O on that database connection, or if the database entered [WAL mode] 
  8940   9073   ** after the most recent I/O on the database connection.)^
  8941   9074   ** (Hint: Run "[PRAGMA application_id]" against a newly opened
  8942   9075   ** database connection in order to make it ready to use snapshots.)
  8943   9076   **
  8944   9077   ** The [sqlite3_snapshot_open()] interface is only available when the
  8945         -** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
         9078  +** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
  8946   9079   */
  8947   9080   SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(
  8948   9081     sqlite3 *db,
  8949   9082     const char *zSchema,
  8950   9083     sqlite3_snapshot *pSnapshot
  8951   9084   );
  8952   9085   
  8953   9086   /*
  8954   9087   ** CAPI3REF: Destroy a snapshot
  8955         -** EXPERIMENTAL
         9088  +** DESTRUCTOR: sqlite3_snapshot
  8956   9089   **
  8957   9090   ** ^The [sqlite3_snapshot_free(P)] interface destroys [sqlite3_snapshot] P.
  8958   9091   ** The application must eventually free every [sqlite3_snapshot] object
  8959   9092   ** using this routine to avoid a memory leak.
  8960   9093   **
  8961   9094   ** The [sqlite3_snapshot_free()] interface is only available when the
  8962         -** SQLITE_ENABLE_SNAPSHOT compile-time option is used.
         9095  +** [SQLITE_ENABLE_SNAPSHOT] compile-time option is used.
  8963   9096   */
  8964   9097   SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot*);
  8965   9098   
  8966   9099   /*
  8967   9100   ** CAPI3REF: Compare the ages of two snapshot handles.
  8968         -** EXPERIMENTAL
         9101  +** METHOD: sqlite3_snapshot
  8969   9102   **
  8970   9103   ** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages
  8971   9104   ** of two valid snapshot handles. 
  8972   9105   **
  8973   9106   ** If the two snapshot handles are not associated with the same database 
  8974   9107   ** file, the result of the comparison is undefined. 
  8975   9108   **
................................................................................
  8980   9113   ** clients drops to zero. If either snapshot handle was obtained before the 
  8981   9114   ** wal file was last deleted, the value returned by this function 
  8982   9115   ** is undefined.
  8983   9116   **
  8984   9117   ** Otherwise, this API returns a negative value if P1 refers to an older
  8985   9118   ** snapshot than P2, zero if the two handles refer to the same database
  8986   9119   ** snapshot, and a positive value if P1 is a newer snapshot than P2.
         9120  +**
         9121  +** This interface is only available if SQLite is compiled with the
         9122  +** [SQLITE_ENABLE_SNAPSHOT] option.
  8987   9123   */
  8988   9124   SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(
  8989   9125     sqlite3_snapshot *p1,
  8990   9126     sqlite3_snapshot *p2
  8991   9127   );
  8992   9128   
  8993   9129   /*
  8994   9130   ** CAPI3REF: Recover snapshots from a wal file
  8995         -** EXPERIMENTAL
         9131  +** METHOD: sqlite3_snapshot
  8996   9132   **
  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.
         9133  +** If a [WAL file] remains on disk after all database connections close
         9134  +** (either through the use of the [SQLITE_FCNTL_PERSIST_WAL] [file control]
         9135  +** or because the last process to have the database opened exited without
         9136  +** calling [sqlite3_close()]) and a new connection is subsequently opened
         9137  +** on that database and [WAL file], the [sqlite3_snapshot_open()] interface
         9138  +** will only be able to open the last transaction added to the WAL file
         9139  +** even though the WAL file contains other valid transactions.
  9004   9140   **
  9005         -** This function attempts to scan the wal file associated with database zDb
         9141  +** This function attempts to scan the WAL file associated with database zDb
  9006   9142   ** of database handle db and make all valid snapshots available to
  9007   9143   ** 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
         9144  +** transaction open on the database, or if the database is not a WAL mode
  9009   9145   ** database.
  9010   9146   **
  9011   9147   ** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
         9148  +**
         9149  +** This interface is only available if SQLite is compiled with the
         9150  +** [SQLITE_ENABLE_SNAPSHOT] option.
  9012   9151   */
  9013   9152   SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb);
  9014   9153   
  9015   9154   /*
  9016   9155   ** CAPI3REF: Serialize a database
  9017   9156   **
  9018   9157   ** The sqlite3_serialize(D,S,P,F) interface returns a pointer to memory
................................................................................
  9115   9254   ** The following are allowed values for 6th argument (the F argument) to
  9116   9255   ** the [sqlite3_deserialize(D,S,P,N,M,F)] interface.
  9117   9256   **
  9118   9257   ** The SQLITE_DESERIALIZE_FREEONCLOSE means that the database serialization
  9119   9258   ** in the P argument is held in memory obtained from [sqlite3_malloc64()]
  9120   9259   ** and that SQLite should take ownership of this memory and automatically
  9121   9260   ** free it when it has finished using it.  Without this flag, the caller
  9122         -** is resposible for freeing any dynamically allocated memory.
         9261  +** is responsible for freeing any dynamically allocated memory.
  9123   9262   **
  9124   9263   ** The SQLITE_DESERIALIZE_RESIZEABLE flag means that SQLite is allowed to
  9125   9264   ** grow the size of the database using calls to [sqlite3_realloc64()].  This
  9126   9265   ** flag should only be used if SQLITE_DESERIALIZE_FREEONCLOSE is also used.
  9127   9266   ** Without this flag, the deserialized database cannot increase in size beyond
  9128   9267   ** the number of bytes specified by the M parameter.
  9129   9268   **
................................................................................
 11293  11432   **            document such as "I won first place" is tokenized, entries are
 11294  11433   **            added to the FTS index for "i", "won", "first", "1st" and
 11295  11434   **            "place".
 11296  11435   **
 11297  11436   **            This way, even if the tokenizer does not provide synonyms
 11298  11437   **            when tokenizing query text (it should not - to do would be
 11299  11438   **            inefficient), it doesn't matter if the user queries for 
 11300         -**            'first + place' or '1st + place', as there are entires in the
        11439  +**            'first + place' or '1st + place', as there are entries in the
 11301  11440   **            FTS index corresponding to both forms of the first token.
 11302  11441   **   </ol>
 11303  11442   **
 11304  11443   **   Whether it is parsing document or query text, any call to xToken that
 11305  11444   **   specifies a <i>tflags</i> argument with the FTS5_TOKEN_COLOCATED bit
 11306  11445   **   is considered to supply a synonym for the previous token. For example,
 11307  11446   **   when parsing the document "I won first place", a tokenizer that supports
................................................................................
 11321  11460   **   There is no limit to the number of synonyms that may be provided for a
 11322  11461   **   single token.
 11323  11462   **
 11324  11463   **   In many cases, method (1) above is the best approach. It does not add 
 11325  11464   **   extra data to the FTS index or require FTS5 to query for multiple terms,
 11326  11465   **   so it is efficient in terms of disk space and query speed. However, it
 11327  11466   **   does not support prefix queries very well. If, as suggested above, the
 11328         -**   token "first" is subsituted for "1st" by the tokenizer, then the query:
        11467  +**   token "first" is substituted for "1st" by the tokenizer, then the query:
 11329  11468   **
 11330  11469   **   <codeblock>
 11331  11470   **     ... MATCH '1s*'</codeblock>
 11332  11471   **
 11333  11472   **   will not match documents that contain the token "1st" (as the tokenizer
 11334  11473   **   will probably not map "1s" to any prefix of "first").
 11335  11474   **