extralite-bundle 2.1 → 2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -146,9 +146,9 @@ extern "C" {
146
146
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147
147
  ** [sqlite_version()] and [sqlite_source_id()].
148
148
  */
149
- #define SQLITE_VERSION "3.42.0"
150
- #define SQLITE_VERSION_NUMBER 3042000
151
- #define SQLITE_SOURCE_ID "2023-05-16 12:36:15 831d0fb2836b71c9bc51067c49fee4b8f18047814f2ff22d817d25195cf350b0"
149
+ #define SQLITE_VERSION "3.44.0"
150
+ #define SQLITE_VERSION_NUMBER 3044000
151
+ #define SQLITE_SOURCE_ID "2023-11-01 11:23:50 17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301"
152
152
 
153
153
  /*
154
154
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -528,6 +528,7 @@ SQLITE_API int sqlite3_exec(
528
528
  #define SQLITE_IOERR_ROLLBACK_ATOMIC (SQLITE_IOERR | (31<<8))
529
529
  #define SQLITE_IOERR_DATA (SQLITE_IOERR | (32<<8))
530
530
  #define SQLITE_IOERR_CORRUPTFS (SQLITE_IOERR | (33<<8))
531
+ #define SQLITE_IOERR_IN_PAGE (SQLITE_IOERR | (34<<8))
531
532
  #define SQLITE_LOCKED_SHAREDCACHE (SQLITE_LOCKED | (1<<8))
532
533
  #define SQLITE_LOCKED_VTAB (SQLITE_LOCKED | (2<<8))
533
534
  #define SQLITE_BUSY_RECOVERY (SQLITE_BUSY | (1<<8))
@@ -1190,7 +1191,7 @@ struct sqlite3_io_methods {
1190
1191
  ** by clients within the current process, only within other processes.
1191
1192
  **
1192
1193
  ** <li>[[SQLITE_FCNTL_CKSM_FILE]]
1193
- ** The [SQLITE_FCNTL_CKSM_FILE] opcode is for use interally by the
1194
+ ** The [SQLITE_FCNTL_CKSM_FILE] opcode is for use internally by the
1194
1195
  ** [checksum VFS shim] only.
1195
1196
  **
1196
1197
  ** <li>[[SQLITE_FCNTL_RESET_CACHE]]
@@ -2126,7 +2127,7 @@ struct sqlite3_mem_methods {
2126
2127
  ** is stored in each sorted record and the required column values loaded
2127
2128
  ** from the database as records are returned in sorted order. The default
2128
2129
  ** value for this option is to never use this optimization. Specifying a
2129
- ** negative value for this option restores the default behaviour.
2130
+ ** negative value for this option restores the default behavior.
2130
2131
  ** This option is only available if SQLite is compiled with the
2131
2132
  ** [SQLITE_ENABLE_SORTER_REFERENCES] compile-time option.
2132
2133
  **
@@ -2301,7 +2302,7 @@ struct sqlite3_mem_methods {
2301
2302
  ** database handle, SQLite checks if this will mean that there are now no
2302
2303
  ** connections at all to the database. If so, it performs a checkpoint
2303
2304
  ** operation before closing the connection. This option may be used to
2304
- ** override this behaviour. The first parameter passed to this operation
2305
+ ** override this behavior. The first parameter passed to this operation
2305
2306
  ** is an integer - positive to disable checkpoints-on-close, or zero (the
2306
2307
  ** default) to enable them, and negative to leave the setting unchanged.
2307
2308
  ** The second parameter is a pointer to an integer
@@ -2454,7 +2455,7 @@ struct sqlite3_mem_methods {
2454
2455
  ** the [VACUUM] command will fail with an obscure error when attempting to
2455
2456
  ** process a table with generated columns and a descending index. This is
2456
2457
  ** not considered a bug since SQLite versions 3.3.0 and earlier do not support
2457
- ** either generated columns or decending indexes.
2458
+ ** either generated columns or descending indexes.
2458
2459
  ** </dd>
2459
2460
  **
2460
2461
  ** [[SQLITE_DBCONFIG_STMT_SCANSTATUS]]
@@ -2735,6 +2736,7 @@ SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3*);
2735
2736
  **
2736
2737
  ** ^The [sqlite3_is_interrupted(D)] interface can be used to determine whether
2737
2738
  ** or not an interrupt is currently in effect for [database connection] D.
2739
+ ** It returns 1 if an interrupt is currently in effect, or 0 otherwise.
2738
2740
  */
2739
2741
  SQLITE_API void sqlite3_interrupt(sqlite3*);
2740
2742
  SQLITE_API int sqlite3_is_interrupted(sqlite3*);
@@ -3388,8 +3390,10 @@ SQLITE_API SQLITE_DEPRECATED void *sqlite3_profile(sqlite3*,
3388
3390
  ** M argument should be the bitwise OR-ed combination of
3389
3391
  ** zero or more [SQLITE_TRACE] constants.
3390
3392
  **
3391
- ** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides
3392
- ** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().
3393
+ ** ^Each call to either sqlite3_trace(D,X,P) or sqlite3_trace_v2(D,M,X,P)
3394
+ ** overrides (cancels) all prior calls to sqlite3_trace(D,X,P) or
3395
+ ** sqlite3_trace_v2(D,M,X,P) for the [database connection] D. Each
3396
+ ** database connection may have at most one trace callback.
3393
3397
  **
3394
3398
  ** ^The X callback is invoked whenever any of the events identified by
3395
3399
  ** mask M occur. ^The integer return value from the callback is currently
@@ -3758,7 +3762,7 @@ SQLITE_API int sqlite3_open_v2(
3758
3762
  ** as F) must be one of:
3759
3763
  ** <ul>
3760
3764
  ** <li> A database filename pointer created by the SQLite core and
3761
- ** passed into the xOpen() method of a VFS implemention, or
3765
+ ** passed into the xOpen() method of a VFS implementation, or
3762
3766
  ** <li> A filename obtained from [sqlite3_db_filename()], or
3763
3767
  ** <li> A new filename constructed using [sqlite3_create_filename()].
3764
3768
  ** </ul>
@@ -3871,7 +3875,7 @@ SQLITE_API sqlite3_file *sqlite3_database_file_object(const char*);
3871
3875
  /*
3872
3876
  ** CAPI3REF: Create and Destroy VFS Filenames
3873
3877
  **
3874
- ** These interfces are provided for use by [VFS shim] implementations and
3878
+ ** These interfaces are provided for use by [VFS shim] implementations and
3875
3879
  ** are not useful outside of that context.
3876
3880
  **
3877
3881
  ** The sqlite3_create_filename(D,J,W,N,P) allocates memory to hold a version of
@@ -3951,6 +3955,7 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename);
3951
3955
  **
3952
3956
  ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
3953
3957
  ** text that describes the error, as either UTF-8 or UTF-16 respectively.
3958
+ ** (See how SQLite handles [invalid UTF] for exceptions to this rule.)
3954
3959
  ** ^(Memory to hold the error message string is managed internally.
3955
3960
  ** The application does not need to worry about freeing the result.
3956
3961
  ** However, the error string might be overwritten or deallocated by
@@ -4418,6 +4423,41 @@ SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
4418
4423
  */
4419
4424
  SQLITE_API int sqlite3_stmt_isexplain(sqlite3_stmt *pStmt);
4420
4425
 
4426
+ /*
4427
+ ** CAPI3REF: Change The EXPLAIN Setting For A Prepared Statement
4428
+ ** METHOD: sqlite3_stmt
4429
+ **
4430
+ ** The sqlite3_stmt_explain(S,E) interface changes the EXPLAIN
4431
+ ** setting for [prepared statement] S. If E is zero, then S becomes
4432
+ ** a normal prepared statement. If E is 1, then S behaves as if
4433
+ ** its SQL text began with "[EXPLAIN]". If E is 2, then S behaves as if
4434
+ ** its SQL text began with "[EXPLAIN QUERY PLAN]".
4435
+ **
4436
+ ** Calling sqlite3_stmt_explain(S,E) might cause S to be reprepared.
4437
+ ** SQLite tries to avoid a reprepare, but a reprepare might be necessary
4438
+ ** on the first transition into EXPLAIN or EXPLAIN QUERY PLAN mode.
4439
+ **
4440
+ ** Because of the potential need to reprepare, a call to
4441
+ ** sqlite3_stmt_explain(S,E) will fail with SQLITE_ERROR if S cannot be
4442
+ ** reprepared because it was created using [sqlite3_prepare()] instead of
4443
+ ** the newer [sqlite3_prepare_v2()] or [sqlite3_prepare_v3()] interfaces and
4444
+ ** hence has no saved SQL text with which to reprepare.
4445
+ **
4446
+ ** Changing the explain setting for a prepared statement does not change
4447
+ ** the original SQL text for the statement. Hence, if the SQL text originally
4448
+ ** began with EXPLAIN or EXPLAIN QUERY PLAN, but sqlite3_stmt_explain(S,0)
4449
+ ** is called to convert the statement into an ordinary statement, the EXPLAIN
4450
+ ** or EXPLAIN QUERY PLAN keywords will still appear in the sqlite3_sql(S)
4451
+ ** output, even though the statement now acts like a normal SQL statement.
4452
+ **
4453
+ ** This routine returns SQLITE_OK if the explain mode is successfully
4454
+ ** changed, or an error code if the explain mode could not be changed.
4455
+ ** The explain mode cannot be changed while a statement is active.
4456
+ ** Hence, it is good practice to call [sqlite3_reset(S)]
4457
+ ** immediately prior to calling sqlite3_stmt_explain(S,E).
4458
+ */
4459
+ SQLITE_API int sqlite3_stmt_explain(sqlite3_stmt *pStmt, int eMode);
4460
+
4421
4461
  /*
4422
4462
  ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
4423
4463
  ** METHOD: sqlite3_stmt
@@ -4581,7 +4621,7 @@ typedef struct sqlite3_context sqlite3_context;
4581
4621
  ** with it may be passed. ^It is called to dispose of the BLOB or string even
4582
4622
  ** if the call to the bind API fails, except the destructor is not called if
4583
4623
  ** the third parameter is a NULL pointer or the fourth parameter is negative.
4584
- ** ^ (2) The special constant, [SQLITE_STATIC], may be passsed to indicate that
4624
+ ** ^ (2) The special constant, [SQLITE_STATIC], may be passed to indicate that
4585
4625
  ** the application remains responsible for disposing of the object. ^In this
4586
4626
  ** case, the object and the provided pointer to it must remain valid until
4587
4627
  ** either the prepared statement is finalized or the same SQL parameter is
@@ -5260,20 +5300,33 @@ SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
5260
5300
  ** ^The [sqlite3_reset(S)] interface resets the [prepared statement] S
5261
5301
  ** back to the beginning of its program.
5262
5302
  **
5263
- ** ^If the most recent call to [sqlite3_step(S)] for the
5264
- ** [prepared statement] S returned [SQLITE_ROW] or [SQLITE_DONE],
5265
- ** or if [sqlite3_step(S)] has never before been called on S,
5266
- ** then [sqlite3_reset(S)] returns [SQLITE_OK].
5303
+ ** ^The return code from [sqlite3_reset(S)] indicates whether or not
5304
+ ** the previous evaluation of prepared statement S completed successfully.
5305
+ ** ^If [sqlite3_step(S)] has never before been called on S or if
5306
+ ** [sqlite3_step(S)] has not been called since the previous call
5307
+ ** to [sqlite3_reset(S)], then [sqlite3_reset(S)] will return
5308
+ ** [SQLITE_OK].
5267
5309
  **
5268
5310
  ** ^If the most recent call to [sqlite3_step(S)] for the
5269
5311
  ** [prepared statement] S indicated an error, then
5270
5312
  ** [sqlite3_reset(S)] returns an appropriate [error code].
5313
+ ** ^The [sqlite3_reset(S)] interface might also return an [error code]
5314
+ ** if there were no prior errors but the process of resetting
5315
+ ** the prepared statement caused a new error. ^For example, if an
5316
+ ** [INSERT] statement with a [RETURNING] clause is only stepped one time,
5317
+ ** that one call to [sqlite3_step(S)] might return SQLITE_ROW but
5318
+ ** the overall statement might still fail and the [sqlite3_reset(S)] call
5319
+ ** might return SQLITE_BUSY if locking constraints prevent the
5320
+ ** database change from committing. Therefore, it is important that
5321
+ ** applications check the return code from [sqlite3_reset(S)] even if
5322
+ ** no prior call to [sqlite3_step(S)] indicated a problem.
5271
5323
  **
5272
5324
  ** ^The [sqlite3_reset(S)] interface does not change the values
5273
5325
  ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
5274
5326
  */
5275
5327
  SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
5276
5328
 
5329
+
5277
5330
  /*
5278
5331
  ** CAPI3REF: Create Or Redefine SQL Functions
5279
5332
  ** KEYWORDS: {function creation routines}
@@ -5484,7 +5537,7 @@ SQLITE_API int sqlite3_create_window_function(
5484
5537
  ** [application-defined SQL function]
5485
5538
  ** that has side-effects or that could potentially leak sensitive information.
5486
5539
  ** This will prevent attacks in which an application is tricked
5487
- ** into using a database file that has had its schema surreptiously
5540
+ ** into using a database file that has had its schema surreptitiously
5488
5541
  ** modified to invoke the application-defined function in ways that are
5489
5542
  ** harmful.
5490
5543
  ** <p>
@@ -5828,32 +5881,32 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
5828
5881
  ** METHOD: sqlite3_context
5829
5882
  **
5830
5883
  ** These functions may be used by (non-aggregate) SQL functions to
5831
- ** associate metadata with argument values. If the same value is passed to
5832
- ** multiple invocations of the same SQL function during query execution, under
5833
- ** some circumstances the associated metadata may be preserved. An example
5834
- ** of where this might be useful is in a regular-expression matching
5835
- ** function. The compiled version of the regular expression can be stored as
5836
- ** metadata associated with the pattern string.
5884
+ ** associate auxiliary data with argument values. If the same argument
5885
+ ** value is passed to multiple invocations of the same SQL function during
5886
+ ** query execution, under some circumstances the associated auxiliary data
5887
+ ** might be preserved. An example of where this might be useful is in a
5888
+ ** regular-expression matching function. The compiled version of the regular
5889
+ ** expression can be stored as auxiliary data associated with the pattern string.
5837
5890
  ** Then as long as the pattern string remains the same,
5838
5891
  ** the compiled regular expression can be reused on multiple
5839
5892
  ** invocations of the same function.
5840
5893
  **
5841
- ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the metadata
5894
+ ** ^The sqlite3_get_auxdata(C,N) interface returns a pointer to the auxiliary data
5842
5895
  ** associated by the sqlite3_set_auxdata(C,N,P,X) function with the Nth argument
5843
5896
  ** value to the application-defined function. ^N is zero for the left-most
5844
- ** function argument. ^If there is no metadata
5897
+ ** function argument. ^If there is no auxiliary data
5845
5898
  ** associated with the function argument, the sqlite3_get_auxdata(C,N) interface
5846
5899
  ** returns a NULL pointer.
5847
5900
  **
5848
- ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as metadata for the N-th
5849
- ** argument of the application-defined function. ^Subsequent
5901
+ ** ^The sqlite3_set_auxdata(C,N,P,X) interface saves P as auxiliary data for the
5902
+ ** N-th argument of the application-defined function. ^Subsequent
5850
5903
  ** calls to sqlite3_get_auxdata(C,N) return P from the most recent
5851
- ** sqlite3_set_auxdata(C,N,P,X) call if the metadata is still valid or
5852
- ** NULL if the metadata has been discarded.
5904
+ ** sqlite3_set_auxdata(C,N,P,X) call if the auxiliary data is still valid or
5905
+ ** NULL if the auxiliary data has been discarded.
5853
5906
  ** ^After each call to sqlite3_set_auxdata(C,N,P,X) where X is not NULL,
5854
5907
  ** SQLite will invoke the destructor function X with parameter P exactly
5855
- ** once, when the metadata is discarded.
5856
- ** SQLite is free to discard the metadata at any time, including: <ul>
5908
+ ** once, when the auxiliary data is discarded.
5909
+ ** SQLite is free to discard the auxiliary data at any time, including: <ul>
5857
5910
  ** <li> ^(when the corresponding function parameter changes)^, or
5858
5911
  ** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
5859
5912
  ** SQL statement)^, or
@@ -5869,7 +5922,7 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
5869
5922
  ** function implementation should not make any use of P after
5870
5923
  ** sqlite3_set_auxdata() has been called.
5871
5924
  **
5872
- ** ^(In practice, metadata is preserved between function calls for
5925
+ ** ^(In practice, auxiliary data is preserved between function calls for
5873
5926
  ** function parameters that are compile-time constants, including literal
5874
5927
  ** values and [parameters] and expressions composed from the same.)^
5875
5928
  **
@@ -5879,10 +5932,67 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
5879
5932
  **
5880
5933
  ** These routines must be called from the same thread in which
5881
5934
  ** the SQL function is running.
5935
+ **
5936
+ ** See also: [sqlite3_get_clientdata()] and [sqlite3_set_clientdata()].
5882
5937
  */
5883
5938
  SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
5884
5939
  SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
5885
5940
 
5941
+ /*
5942
+ ** CAPI3REF: Database Connection Client Data
5943
+ ** METHOD: sqlite3
5944
+ **
5945
+ ** These functions are used to associate one or more named pointers
5946
+ ** with a [database connection].
5947
+ ** A call to sqlite3_set_clientdata(D,N,P,X) causes the pointer P
5948
+ ** to be attached to [database connection] D using name N. Subsequent
5949
+ ** calls to sqlite3_get_clientdata(D,N) will return a copy of pointer P
5950
+ ** or a NULL pointer if there were no prior calls to
5951
+ ** sqlite3_set_clientdata() with the same values of D and N.
5952
+ ** Names are compared using strcmp() and are thus case sensitive.
5953
+ **
5954
+ ** If P and X are both non-NULL, then the destructor X is invoked with
5955
+ ** argument P on the first of the following occurrences:
5956
+ ** <ul>
5957
+ ** <li> An out-of-memory error occurs during the call to
5958
+ ** sqlite3_set_clientdata() which attempts to register pointer P.
5959
+ ** <li> A subsequent call to sqlite3_set_clientdata(D,N,P,X) is made
5960
+ ** with the same D and N parameters.
5961
+ ** <li> The database connection closes. SQLite does not make any guarantees
5962
+ ** about the order in which destructors are called, only that all
5963
+ ** destructors will be called exactly once at some point during the
5964
+ ** database connection closing process.
5965
+ ** </ul>
5966
+ **
5967
+ ** SQLite does not do anything with client data other than invoke
5968
+ ** destructors on the client data at the appropriate time. The intended
5969
+ ** use for client data is to provide a mechanism for wrapper libraries
5970
+ ** to store additional information about an SQLite database connection.
5971
+ **
5972
+ ** There is no limit (other than available memory) on the number of different
5973
+ ** client data pointers (with different names) that can be attached to a
5974
+ ** single database connection. However, the implementation is optimized
5975
+ ** for the case of having only one or two different client data names.
5976
+ ** Applications and wrapper libraries are discouraged from using more than
5977
+ ** one client data name each.
5978
+ **
5979
+ ** There is no way to enumerate the client data pointers
5980
+ ** associated with a database connection. The N parameter can be thought
5981
+ ** of as a secret key such that only code that knows the secret key is able
5982
+ ** to access the associated data.
5983
+ **
5984
+ ** Security Warning: These interfaces should not be exposed in scripting
5985
+ ** languages or in other circumstances where it might be possible for an
5986
+ ** an attacker to invoke them. Any agent that can invoke these interfaces
5987
+ ** can probably also take control of the process.
5988
+ **
5989
+ ** Database connection client data is only available for SQLite
5990
+ ** version 3.44.0 ([dateof:3.44.0]) and later.
5991
+ **
5992
+ ** See also: [sqlite3_set_auxdata()] and [sqlite3_get_auxdata()].
5993
+ */
5994
+ SQLITE_API void *sqlite3_get_clientdata(sqlite3*,const char*);
5995
+ SQLITE_API int sqlite3_set_clientdata(sqlite3*, const char*, void*, void(*)(void*));
5886
5996
 
5887
5997
  /*
5888
5998
  ** CAPI3REF: Constants Defining Special Destructor Behavior
@@ -6515,7 +6625,7 @@ SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
6515
6625
  SQLITE_API int sqlite3_txn_state(sqlite3*,const char *zSchema);
6516
6626
 
6517
6627
  /*
6518
- ** CAPI3REF: Allowed return values from [sqlite3_txn_state()]
6628
+ ** CAPI3REF: Allowed return values from sqlite3_txn_state()
6519
6629
  ** KEYWORDS: {transaction state}
6520
6630
  **
6521
6631
  ** These constants define the current transaction state of a database file.
@@ -6647,7 +6757,7 @@ SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
6647
6757
  ** ^Each call to the sqlite3_autovacuum_pages() interface overrides all
6648
6758
  ** previous invocations for that database connection. ^If the callback
6649
6759
  ** argument (C) to sqlite3_autovacuum_pages(D,C,P,X) is a NULL pointer,
6650
- ** then the autovacuum steps callback is cancelled. The return value
6760
+ ** then the autovacuum steps callback is canceled. The return value
6651
6761
  ** from sqlite3_autovacuum_pages() is normally SQLITE_OK, but might
6652
6762
  ** be some other error code if something goes wrong. The current
6653
6763
  ** implementation will only return SQLITE_OK or SQLITE_MISUSE, but other
@@ -7166,6 +7276,10 @@ struct sqlite3_module {
7166
7276
  /* The methods above are in versions 1 and 2 of the sqlite_module object.
7167
7277
  ** Those below are for version 3 and greater. */
7168
7278
  int (*xShadowName)(const char*);
7279
+ /* The methods above are in versions 1 through 3 of the sqlite_module object.
7280
+ ** Those below are for version 4 and greater. */
7281
+ int (*xIntegrity)(sqlite3_vtab *pVTab, const char *zSchema,
7282
+ const char *zTabName, int mFlags, char **pzErr);
7169
7283
  };
7170
7284
 
7171
7285
  /*
@@ -7653,7 +7767,7 @@ SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
7653
7767
  ** code is returned and the transaction rolled back.
7654
7768
  **
7655
7769
  ** Calling this function with an argument that is not a NULL pointer or an
7656
- ** open blob handle results in undefined behaviour. ^Calling this routine
7770
+ ** open blob handle results in undefined behavior. ^Calling this routine
7657
7771
  ** with a null pointer (such as would be returned by a failed call to
7658
7772
  ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
7659
7773
  ** is passed a valid open blob handle, the values returned by the
@@ -8133,6 +8247,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
8133
8247
  #define SQLITE_TESTCTRL_PRNG_SAVE 5
8134
8248
  #define SQLITE_TESTCTRL_PRNG_RESTORE 6
8135
8249
  #define SQLITE_TESTCTRL_PRNG_RESET 7 /* NOT USED */
8250
+ #define SQLITE_TESTCTRL_FK_NO_ACTION 7
8136
8251
  #define SQLITE_TESTCTRL_BITVEC_TEST 8
8137
8252
  #define SQLITE_TESTCTRL_FAULT_INSTALL 9
8138
8253
  #define SQLITE_TESTCTRL_BENIGN_MALLOC_HOOKS 10
@@ -8161,7 +8276,8 @@ SQLITE_API int sqlite3_test_control(int op, ...);
8161
8276
  #define SQLITE_TESTCTRL_TRACEFLAGS 31
8162
8277
  #define SQLITE_TESTCTRL_TUNE 32
8163
8278
  #define SQLITE_TESTCTRL_LOGEST 33
8164
- #define SQLITE_TESTCTRL_LAST 33 /* Largest TESTCTRL */
8279
+ #define SQLITE_TESTCTRL_USELONGDOUBLE 34
8280
+ #define SQLITE_TESTCTRL_LAST 34 /* Largest TESTCTRL */
8165
8281
 
8166
8282
  /*
8167
8283
  ** CAPI3REF: SQL Keyword Checking
@@ -9617,7 +9733,7 @@ SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
9617
9733
  ** [[SQLITE_VTAB_DIRECTONLY]]<dt>SQLITE_VTAB_DIRECTONLY</dt>
9618
9734
  ** <dd>Calls of the form
9619
9735
  ** [sqlite3_vtab_config](db,SQLITE_VTAB_DIRECTONLY) from within the
9620
- ** the [xConnect] or [xCreate] methods of a [virtual table] implmentation
9736
+ ** the [xConnect] or [xCreate] methods of a [virtual table] implementation
9621
9737
  ** prohibits that virtual table from being used from within triggers and
9622
9738
  ** views.
9623
9739
  ** </dd>
@@ -9807,7 +9923,7 @@ SQLITE_API int sqlite3_vtab_distinct(sqlite3_index_info*);
9807
9923
  ** communicated to the xBestIndex method as a
9808
9924
  ** [SQLITE_INDEX_CONSTRAINT_EQ] constraint.)^ If xBestIndex wants to use
9809
9925
  ** this constraint, it must set the corresponding
9810
- ** aConstraintUsage[].argvIndex to a postive integer. ^(Then, under
9926
+ ** aConstraintUsage[].argvIndex to a positive integer. ^(Then, under
9811
9927
  ** the usual mode of handling IN operators, SQLite generates [bytecode]
9812
9928
  ** that invokes the [xFilter|xFilter() method] once for each value
9813
9929
  ** on the right-hand side of the IN operator.)^ Thus the virtual table
@@ -10236,7 +10352,7 @@ SQLITE_API int sqlite3_db_cacheflush(sqlite3*);
10236
10352
  ** When the [sqlite3_blob_write()] API is used to update a blob column,
10237
10353
  ** the pre-update hook is invoked with SQLITE_DELETE. This is because the
10238
10354
  ** in this case the new values are not available. In this case, when a
10239
- ** callback made with op==SQLITE_DELETE is actuall a write using the
10355
+ ** callback made with op==SQLITE_DELETE is actually a write using the
10240
10356
  ** sqlite3_blob_write() API, the [sqlite3_preupdate_blobwrite()] returns
10241
10357
  ** the index of the column being written. In other cases, where the
10242
10358
  ** pre-update hook is being invoked for some other reason, including a
@@ -10497,6 +10613,13 @@ SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const c
10497
10613
  ** SQLITE_SERIALIZE_NOCOPY bit is set but no contiguous copy
10498
10614
  ** of the database exists.
10499
10615
  **
10616
+ ** After the call, if the SQLITE_SERIALIZE_NOCOPY bit had been set,
10617
+ ** the returned buffer content will remain accessible and unchanged
10618
+ ** until either the next write operation on the connection or when
10619
+ ** the connection is closed, and applications must not modify the
10620
+ ** buffer. If the bit had been clear, the returned buffer will not
10621
+ ** be accessed by SQLite after the call.
10622
+ **
10500
10623
  ** A call to sqlite3_serialize(D,S,P,F) might return NULL even if the
10501
10624
  ** SQLITE_SERIALIZE_NOCOPY bit is omitted from argument F if a memory
10502
10625
  ** allocation error occurs.
@@ -10545,6 +10668,9 @@ SQLITE_API unsigned char *sqlite3_serialize(
10545
10668
  ** SQLite will try to increase the buffer size using sqlite3_realloc64()
10546
10669
  ** if writes on the database cause it to grow larger than M bytes.
10547
10670
  **
10671
+ ** Applications must not modify the buffer P or invalidate it before
10672
+ ** the database connection D is closed.
10673
+ **
10548
10674
  ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the
10549
10675
  ** database is currently in a read transaction or is involved in a backup
10550
10676
  ** operation.
@@ -10553,6 +10679,13 @@ SQLITE_API unsigned char *sqlite3_serialize(
10553
10679
  ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the
10554
10680
  ** function returns SQLITE_ERROR.
10555
10681
  **
10682
+ ** The deserialized database should not be in [WAL mode]. If the database
10683
+ ** is in WAL mode, then any attempt to use the database file will result
10684
+ ** in an [SQLITE_CANTOPEN] error. The application can set the
10685
+ ** [file format version numbers] (bytes 18 and 19) of the input database P
10686
+ ** to 0x01 prior to invoking sqlite3_deserialize(D,S,P,N,M,F) to force the
10687
+ ** database file into rollback mode and work around this limitation.
10688
+ **
10556
10689
  ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
10557
10690
  ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
10558
10691
  ** [sqlite3_free()] is invoked on argument P prior to returning.
@@ -11625,6 +11758,18 @@ SQLITE_API int sqlite3changeset_concat(
11625
11758
  );
11626
11759
 
11627
11760
 
11761
+ /*
11762
+ ** CAPI3REF: Upgrade the Schema of a Changeset/Patchset
11763
+ */
11764
+ SQLITE_API int sqlite3changeset_upgrade(
11765
+ sqlite3 *db,
11766
+ const char *zDb,
11767
+ int nIn, const void *pIn, /* Input changeset */
11768
+ int *pnOut, void **ppOut /* OUT: Inverse of input */
11769
+ );
11770
+
11771
+
11772
+
11628
11773
  /*
11629
11774
  ** CAPI3REF: Changegroup Handle
11630
11775
  **
@@ -11671,6 +11816,38 @@ typedef struct sqlite3_changegroup sqlite3_changegroup;
11671
11816
  */
11672
11817
  SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp);
11673
11818
 
11819
+ /*
11820
+ ** CAPI3REF: Add a Schema to a Changegroup
11821
+ ** METHOD: sqlite3_changegroup_schema
11822
+ **
11823
+ ** This method may be used to optionally enforce the rule that the changesets
11824
+ ** added to the changegroup handle must match the schema of database zDb
11825
+ ** ("main", "temp", or the name of an attached database). If
11826
+ ** sqlite3changegroup_add() is called to add a changeset that is not compatible
11827
+ ** with the configured schema, SQLITE_SCHEMA is returned and the changegroup
11828
+ ** object is left in an undefined state.
11829
+ **
11830
+ ** A changeset schema is considered compatible with the database schema in
11831
+ ** the same way as for sqlite3changeset_apply(). Specifically, for each
11832
+ ** table in the changeset, there exists a database table with:
11833
+ **
11834
+ ** <ul>
11835
+ ** <li> The name identified by the changeset, and
11836
+ ** <li> at least as many columns as recorded in the changeset, and
11837
+ ** <li> the primary key columns in the same position as recorded in
11838
+ ** the changeset.
11839
+ ** </ul>
11840
+ **
11841
+ ** The output of the changegroup object always has the same schema as the
11842
+ ** database nominated using this function. In cases where changesets passed
11843
+ ** to sqlite3changegroup_add() have fewer columns than the corresponding table
11844
+ ** in the database schema, these are filled in using the default column
11845
+ ** values from the database schema. This makes it possible to combined
11846
+ ** changesets that have different numbers of columns for a single table
11847
+ ** within a changegroup, provided that they are otherwise compatible.
11848
+ */
11849
+ SQLITE_API int sqlite3changegroup_schema(sqlite3_changegroup*, sqlite3*, const char *zDb);
11850
+
11674
11851
  /*
11675
11852
  ** CAPI3REF: Add A Changeset To A Changegroup
11676
11853
  ** METHOD: sqlite3_changegroup
@@ -11739,13 +11916,18 @@ SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp);
11739
11916
  ** If the new changeset contains changes to a table that is already present
11740
11917
  ** in the changegroup, then the number of columns and the position of the
11741
11918
  ** primary key columns for the table must be consistent. If this is not the
11742
- ** case, this function fails with SQLITE_SCHEMA. If the input changeset
11743
- ** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is
11744
- ** returned. Or, if an out-of-memory condition occurs during processing, this
11745
- ** function returns SQLITE_NOMEM. In all cases, if an error occurs the state
11746
- ** of the final contents of the changegroup is undefined.
11919
+ ** case, this function fails with SQLITE_SCHEMA. Except, if the changegroup
11920
+ ** object has been configured with a database schema using the
11921
+ ** sqlite3changegroup_schema() API, then it is possible to combine changesets
11922
+ ** with different numbers of columns for a single table, provided that
11923
+ ** they are otherwise compatible.
11747
11924
  **
11748
- ** If no error occurs, SQLITE_OK is returned.
11925
+ ** If the input changeset appears to be corrupt and the corruption is
11926
+ ** detected, SQLITE_CORRUPT is returned. Or, if an out-of-memory condition
11927
+ ** occurs during processing, this function returns SQLITE_NOMEM.
11928
+ **
11929
+ ** In all cases, if an error occurs the state of the final contents of the
11930
+ ** changegroup is undefined. If no error occurs, SQLITE_OK is returned.
11749
11931
  */
11750
11932
  SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
11751
11933
 
@@ -12010,10 +12192,17 @@ SQLITE_API int sqlite3changeset_apply_v2(
12010
12192
  ** <li>an insert change if all fields of the conflicting row match
12011
12193
  ** the row being inserted.
12012
12194
  ** </ul>
12195
+ **
12196
+ ** <dt>SQLITE_CHANGESETAPPLY_FKNOACTION <dd>
12197
+ ** If this flag it set, then all foreign key constraints in the target
12198
+ ** database behave as if they were declared with "ON UPDATE NO ACTION ON
12199
+ ** DELETE NO ACTION", even if they are actually CASCADE, RESTRICT, SET NULL
12200
+ ** or SET DEFAULT.
12013
12201
  */
12014
12202
  #define SQLITE_CHANGESETAPPLY_NOSAVEPOINT 0x0001
12015
12203
  #define SQLITE_CHANGESETAPPLY_INVERT 0x0002
12016
12204
  #define SQLITE_CHANGESETAPPLY_IGNORENOOP 0x0004
12205
+ #define SQLITE_CHANGESETAPPLY_FKNOACTION 0x0008
12017
12206
 
12018
12207
  /*
12019
12208
  ** CAPI3REF: Constants Passed To The Conflict Handler
@@ -12754,7 +12943,7 @@ struct Fts5PhraseIter {
12754
12943
  ** See xPhraseFirstColumn above.
12755
12944
  */
12756
12945
  struct Fts5ExtensionApi {
12757
- int iVersion; /* Currently always set to 3 */
12946
+ int iVersion; /* Currently always set to 2 */
12758
12947
 
12759
12948
  void *(*xUserData)(Fts5Context*);
12760
12949
 
@@ -12983,8 +13172,8 @@ struct Fts5ExtensionApi {
12983
13172
  ** as separate queries of the FTS index are required for each synonym.
12984
13173
  **
12985
13174
  ** When using methods (2) or (3), it is important that the tokenizer only
12986
- ** provide synonyms when tokenizing document text (method (2)) or query
12987
- ** text (method (3)), not both. Doing so will not cause any errors, but is
13175
+ ** provide synonyms when tokenizing document text (method (3)) or query
13176
+ ** text (method (2)), not both. Doing so will not cause any errors, but is
12988
13177
  ** inefficient.
12989
13178
  */
12990
13179
  typedef struct Fts5Tokenizer Fts5Tokenizer;
@@ -13032,7 +13221,7 @@ struct fts5_api {
13032
13221
  int (*xCreateTokenizer)(
13033
13222
  fts5_api *pApi,
13034
13223
  const char *zName,
13035
- void *pContext,
13224
+ void *pUserData,
13036
13225
  fts5_tokenizer *pTokenizer,
13037
13226
  void (*xDestroy)(void*)
13038
13227
  );
@@ -13041,7 +13230,7 @@ struct fts5_api {
13041
13230
  int (*xFindTokenizer)(
13042
13231
  fts5_api *pApi,
13043
13232
  const char *zName,
13044
- void **ppContext,
13233
+ void **ppUserData,
13045
13234
  fts5_tokenizer *pTokenizer
13046
13235
  );
13047
13236
 
@@ -13049,7 +13238,7 @@ struct fts5_api {
13049
13238
  int (*xCreateFunction)(
13050
13239
  fts5_api *pApi,
13051
13240
  const char *zName,
13052
- void *pContext,
13241
+ void *pUserData,
13053
13242
  fts5_extension_function xFunction,
13054
13243
  void (*xDestroy)(void*)
13055
13244
  );
@@ -1,4 +1,4 @@
1
1
  module Extralite
2
2
  # Extralite version
3
- VERSION = '2.1'
3
+ VERSION = '2.3'
4
4
  end
@@ -212,7 +212,11 @@ module Sequel
212
212
  case type
213
213
  when :select
214
214
  query = conn.prepare(sql, args)
215
- log_connection_yield(sql, conn, log_args){block.call(query.each, query.columns)}
215
+ begin
216
+ log_connection_yield(sql, conn, log_args){block.call(query.each, query.columns)}
217
+ ensure
218
+ query.reset
219
+ end
216
220
  when :insert
217
221
  log_connection_yield(sql, conn, log_args){conn.query(sql, args)}
218
222
  conn.last_insert_rowid
@@ -387,6 +387,13 @@ end
387
387
  db = Extralite::Database.new(':memory:')
388
388
  assert_match /^\#\<Extralite::Database:0x[0-9a-f]+ :memory:\>$/, db.inspect
389
389
  end
390
+
391
+ def test_string_encoding
392
+ db = Extralite::Database.new(':memory:')
393
+ v = db.query_single_value("select 'foo'")
394
+ assert_equal 'foo', v
395
+ assert_equal 'UTF-8', v.encoding.name
396
+ end
390
397
  end
391
398
 
392
399
  class ScenarioTest < MiniTest::Test
@@ -101,4 +101,17 @@ class IteratorTest < MiniTest::Test
101
101
  i = @query.each_ary
102
102
  assert_match /^\#\<Extralite::Iterator:0x[0-9a-f]+ ary\>$/, i.inspect
103
103
  end
104
+
105
+ def test_return_from_block_issue_26
106
+ db = Extralite::Database.new('/tmp/locked.db')
107
+
108
+ λ = ->(sql) {
109
+ db.prepare(sql).each { |r| r.each { |_, v| return v } }
110
+ }
111
+
112
+ 20.times do |i|
113
+ λ.('DROP TABLE IF EXISTS `test1`')
114
+ λ.('CREATE TABLE `test1` (`_id` integer NOT NULL PRIMARY KEY AUTOINCREMENT) STRICT')
115
+ end
116
+ end
104
117
  end