@op-engineering/op-sqlite 2.0.16 → 2.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/cpp/sqlite3.h CHANGED
@@ -145,11 +145,11 @@ extern "C" {
145
145
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
146
146
  ** [sqlite_version()] and [sqlite_source_id()].
147
147
  */
148
- #define SQLITE_VERSION "3.44.0"
149
- #define SQLITE_VERSION_NUMBER 3044000
148
+ #define SQLITE_VERSION "3.45.1"
149
+ #define SQLITE_VERSION_NUMBER 3045001
150
150
  #define SQLITE_SOURCE_ID \
151
- "2023-11-01 11:23:50 " \
152
- "17129ba1ff7f0daf37100ee82d507aef7827cf38de1866e2633096ae6ad81301"
151
+ "2024-01-30 16:01:20 " \
152
+ "e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257cc467a"
153
153
 
154
154
  /*
155
155
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -3954,15 +3954,17 @@ SQLITE_API void sqlite3_free_filename(sqlite3_filename);
3954
3954
  ** </ul>
3955
3955
  **
3956
3956
  ** ^The sqlite3_errmsg() and sqlite3_errmsg16() return English-language
3957
- ** text that describes the error, as either UTF-8 or UTF-16 respectively.
3957
+ ** text that describes the error, as either UTF-8 or UTF-16 respectively,
3958
+ ** or NULL if no error message is available.
3958
3959
  ** (See how SQLite handles [invalid UTF] for exceptions to this rule.)
3959
3960
  ** ^(Memory to hold the error message string is managed internally.
3960
3961
  ** The application does not need to worry about freeing the result.
3961
3962
  ** However, the error string might be overwritten or deallocated by
3962
3963
  ** subsequent calls to other SQLite interface functions.)^
3963
3964
  **
3964
- ** ^The sqlite3_errstr() interface returns the English-language text
3965
- ** that describes the [result code], as UTF-8.
3965
+ ** ^The sqlite3_errstr(E) interface returns the English-language text
3966
+ ** that describes the [result code] E, as UTF-8, or NULL if E is not an
3967
+ ** result code for which a text error message is available.
3966
3968
  ** ^(Memory to hold the error message string is managed internally
3967
3969
  ** and must not be freed by the application)^.
3968
3970
  **
@@ -5556,13 +5558,27 @@ SQLITE_API int sqlite3_create_window_function(
5556
5558
  ** </dd>
5557
5559
  **
5558
5560
  ** [[SQLITE_SUBTYPE]] <dt>SQLITE_SUBTYPE</dt><dd>
5559
- ** The SQLITE_SUBTYPE flag indicates to SQLite that a function may call
5561
+ ** The SQLITE_SUBTYPE flag indicates to SQLite that a function might call
5560
5562
  ** [sqlite3_value_subtype()] to inspect the sub-types of its arguments.
5561
- ** Specifying this flag makes no difference for scalar or aggregate user
5562
- ** functions. However, if it is not specified for a user-defined window
5563
- ** function, then any sub-types belonging to arguments passed to the window
5564
- ** function may be discarded before the window function is called (i.e.
5565
- ** sqlite3_value_subtype() will always return 0).
5563
+ ** This flag instructs SQLite to omit some corner-case optimizations that
5564
+ ** might disrupt the operation of the [sqlite3_value_subtype()] function,
5565
+ ** causing it to return zero rather than the correct subtype().
5566
+ ** SQL functions that invokes [sqlite3_value_subtype()] should have this
5567
+ ** property. If the SQLITE_SUBTYPE property is omitted, then the return
5568
+ ** value from [sqlite3_value_subtype()] might sometimes be zero even though
5569
+ ** a non-zero subtype was specified by the function argument expression.
5570
+ **
5571
+ ** [[SQLITE_RESULT_SUBTYPE]] <dt>SQLITE_RESULT_SUBTYPE</dt><dd>
5572
+ ** The SQLITE_RESULT_SUBTYPE flag indicates to SQLite that a function might call
5573
+ ** [sqlite3_result_subtype()] to cause a sub-type to be associated with its
5574
+ ** result.
5575
+ ** Every function that invokes [sqlite3_result_subtype()] should have this
5576
+ ** property. If it does not, then the call to [sqlite3_result_subtype()]
5577
+ ** might become a no-op if the function is used as term in an
5578
+ ** [expression index]. On the other hand, SQL functions that never invoke
5579
+ ** [sqlite3_result_subtype()] should avoid setting this property, as the
5580
+ ** purpose of this property is to disable certain optimizations that are
5581
+ ** incompatible with subtypes.
5566
5582
  ** </dd>
5567
5583
  ** </dl>
5568
5584
  */
@@ -5570,6 +5586,7 @@ SQLITE_API int sqlite3_create_window_function(
5570
5586
  #define SQLITE_DIRECTONLY 0x000080000
5571
5587
  #define SQLITE_SUBTYPE 0x000100000
5572
5588
  #define SQLITE_INNOCUOUS 0x000200000
5589
+ #define SQLITE_RESULT_SUBTYPE 0x001000000
5573
5590
 
5574
5591
  /*
5575
5592
  ** CAPI3REF: Deprecated Functions
@@ -5769,6 +5786,12 @@ SQLITE_API int sqlite3_value_encoding(sqlite3_value *);
5769
5786
  ** information can be used to pass a limited amount of context from
5770
5787
  ** one SQL function to another. Use the [sqlite3_result_subtype()]
5771
5788
  ** routine to set the subtype for the return value of an SQL function.
5789
+ **
5790
+ ** Every [application-defined SQL function] that invoke this interface
5791
+ ** should include the [SQLITE_SUBTYPE] property in the text
5792
+ ** encoding argument when the function is [sqlite3_create_function|registered].
5793
+ ** If the [SQLITE_SUBTYPE] property is omitted, then sqlite3_value_subtype()
5794
+ ** might return zero instead of the upstream subtype in some corner cases.
5772
5795
  */
5773
5796
  SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *);
5774
5797
 
@@ -5901,14 +5924,22 @@ SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *);
5901
5924
  ** <li> ^(when sqlite3_set_auxdata() is invoked again on the same
5902
5925
  ** parameter)^, or
5903
5926
  ** <li> ^(during the original sqlite3_set_auxdata() call when a memory
5904
- ** allocation error occurs.)^ </ul>
5927
+ ** allocation error occurs.)^
5928
+ ** <li> ^(during the original sqlite3_set_auxdata() call if the function
5929
+ ** is evaluated during query planning instead of during query execution,
5930
+ ** as sometimes happens with [SQLITE_ENABLE_STAT4].)^ </ul>
5905
5931
  **
5906
- ** Note the last bullet in particular. The destructor X in
5932
+ ** Note the last two bullets in particular. The destructor X in
5907
5933
  ** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
5908
5934
  ** sqlite3_set_auxdata() interface even returns. Hence sqlite3_set_auxdata()
5909
5935
  ** should be called near the end of the function implementation and the
5910
5936
  ** function implementation should not make any use of P after
5911
- ** sqlite3_set_auxdata() has been called.
5937
+ ** sqlite3_set_auxdata() has been called. Furthermore, a call to
5938
+ ** sqlite3_get_auxdata() that occurs immediately after a corresponding call
5939
+ ** to sqlite3_set_auxdata() might still return NULL if an out-of-memory
5940
+ ** condition occurred during the sqlite3_set_auxdata() call or if the
5941
+ ** function is being evaluated during query planning rather than during
5942
+ ** query execution.
5912
5943
  **
5913
5944
  ** ^(In practice, auxiliary data is preserved between function calls for
5914
5945
  ** function parameters that are compile-time constants, including literal
@@ -6190,6 +6221,20 @@ SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *, sqlite3_uint64 n);
6190
6221
  ** higher order bits are discarded.
6191
6222
  ** The number of subtype bytes preserved by SQLite might increase
6192
6223
  ** in future releases of SQLite.
6224
+ **
6225
+ ** Every [application-defined SQL function] that invokes this interface
6226
+ ** should include the [SQLITE_RESULT_SUBTYPE] property in its
6227
+ ** text encoding argument when the SQL function is
6228
+ ** [sqlite3_create_function|registered]. If the [SQLITE_RESULT_SUBTYPE]
6229
+ ** property is omitted from the function that invokes sqlite3_result_subtype(),
6230
+ ** then in some cases the sqlite3_result_subtype() might fail to set
6231
+ ** the result subtype.
6232
+ **
6233
+ ** If SQLite is compiled with -DSQLITE_STRICT_SUBTYPE=1, then any
6234
+ ** SQL function that invokes the sqlite3_result_subtype() interface
6235
+ ** and that does not have the SQLITE_RESULT_SUBTYPE property will raise
6236
+ ** an error. Future versions of SQLite might enable -DSQLITE_STRICT_SUBTYPE=1
6237
+ ** by default.
6193
6238
  */
6194
6239
  SQLITE_API void sqlite3_result_subtype(sqlite3_context *, unsigned int);
6195
6240
 
@@ -7370,17 +7415,17 @@ struct sqlite3_index_info {
7370
7415
  unsigned char op; /* Constraint operator */
7371
7416
  unsigned char usable; /* True if this constraint is usable */
7372
7417
  int iTermOffset; /* Used internally - xBestIndex should ignore */
7373
- } * aConstraint; /* Table of WHERE clause constraints */
7418
+ } *aConstraint; /* Table of WHERE clause constraints */
7374
7419
  int nOrderBy; /* Number of terms in the ORDER BY clause */
7375
7420
  struct sqlite3_index_orderby {
7376
7421
  int iColumn; /* Column number */
7377
7422
  unsigned char desc; /* True for DESC. False for ASC. */
7378
- } * aOrderBy; /* The ORDER BY clause */
7423
+ } *aOrderBy; /* The ORDER BY clause */
7379
7424
  /* Outputs */
7380
7425
  struct sqlite3_index_constraint_usage {
7381
7426
  int argvIndex; /* if >0, constraint is part of argv to xFilter */
7382
7427
  unsigned char omit; /* Do not code a test for this constraint */
7383
- } * aConstraintUsage;
7428
+ } *aConstraintUsage;
7384
7429
  int idxNum; /* Number used to identify the index */
7385
7430
  char *idxStr; /* String, possibly obtained from sqlite3_malloc */
7386
7431
  int needToFreeIdxStr; /* Free idxStr using sqlite3_free() if true */
@@ -7968,9 +8013,11 @@ SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *);
7968
8013
  **
7969
8014
  ** ^(Some systems (for example, Windows 95) do not support the operation
7970
8015
  ** implemented by sqlite3_mutex_try(). On those systems, sqlite3_mutex_try()
7971
- ** will always return SQLITE_BUSY. The SQLite core only ever uses
7972
- ** sqlite3_mutex_try() as an optimization so this is acceptable
7973
- ** behavior.)^
8016
+ ** will always return SQLITE_BUSY. In most cases the SQLite core only uses
8017
+ ** sqlite3_mutex_try() as an optimization, so this is acceptable
8018
+ ** behavior. The exceptions are unix builds that set the
8019
+ ** SQLITE_ENABLE_SETLK_TIMEOUT build option. In that case a working
8020
+ ** sqlite3_mutex_try() is required.)^
7974
8021
  **
7975
8022
  ** ^The sqlite3_mutex_leave() routine exits a mutex that was
7976
8023
  ** previously entered by the same thread. The behavior
@@ -8229,6 +8276,7 @@ SQLITE_API int sqlite3_test_control(int op, ...);
8229
8276
  #define SQLITE_TESTCTRL_ASSERT 12
8230
8277
  #define SQLITE_TESTCTRL_ALWAYS 13
8231
8278
  #define SQLITE_TESTCTRL_RESERVE 14 /* NOT USED */
8279
+ #define SQLITE_TESTCTRL_JSON_SELFCHECK 14
8232
8280
  #define SQLITE_TESTCTRL_OPTIMIZATIONS 15
8233
8281
  #define SQLITE_TESTCTRL_ISKEYWORD 16 /* NOT USED */
8234
8282
  #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 /* NOT USED */
@@ -12687,8 +12735,11 @@ struct Fts5PhraseIter {
12687
12735
  ** created with the "columnsize=0" option.
12688
12736
  **
12689
12737
  ** xColumnText:
12690
- ** This function attempts to retrieve the text of column iCol of the
12691
- ** current document. If successful, (*pz) is set to point to a buffer
12738
+ ** If parameter iCol is less than zero, or greater than or equal to the
12739
+ ** number of columns in the table, SQLITE_RANGE is returned.
12740
+ **
12741
+ ** Otherwise, this function attempts to retrieve the text of column iCol of
12742
+ ** the current document. If successful, (*pz) is set to point to a buffer
12692
12743
  ** containing the text in utf-8 encoding, (*pn) is set to the size in bytes
12693
12744
  ** (not characters) of the buffer and SQLITE_OK is returned. Otherwise,
12694
12745
  ** if an error occurs, an SQLite error code is returned and the final values
@@ -12698,8 +12749,10 @@ struct Fts5PhraseIter {
12698
12749
  ** Returns the number of phrases in the current query expression.
12699
12750
  **
12700
12751
  ** xPhraseSize:
12701
- ** Returns the number of tokens in phrase iPhrase of the query. Phrases
12702
- ** are numbered starting from zero.
12752
+ ** If parameter iCol is less than zero, or greater than or equal to the
12753
+ ** number of phrases in the current query, as returned by xPhraseCount,
12754
+ ** 0 is returned. Otherwise, this function returns the number of tokens in
12755
+ ** phrase iPhrase of the query. Phrases are numbered starting from zero.
12703
12756
  **
12704
12757
  ** xInstCount:
12705
12758
  ** Set *pnInst to the total number of occurrences of all phrases within
@@ -12715,12 +12768,13 @@ struct Fts5PhraseIter {
12715
12768
  ** Query for the details of phrase match iIdx within the current row.
12716
12769
  ** Phrase matches are numbered starting from zero, so the iIdx argument
12717
12770
  ** should be greater than or equal to zero and smaller than the value
12718
- ** output by xInstCount().
12771
+ ** output by xInstCount(). If iIdx is less than zero or greater than
12772
+ ** or equal to the value returned by xInstCount(), SQLITE_RANGE is returned.
12719
12773
  **
12720
- ** Usually, output parameter *piPhrase is set to the phrase number, *piCol
12774
+ ** Otherwise, output parameter *piPhrase is set to the phrase number, *piCol
12721
12775
  ** to the column in which it occurs and *piOff the token offset of the
12722
- ** first token of the phrase. Returns SQLITE_OK if successful, or an error
12723
- ** code (i.e. SQLITE_NOMEM) if an error occurs.
12776
+ ** first token of the phrase. SQLITE_OK is returned if successful, or an
12777
+ ** error code (i.e. SQLITE_NOMEM) if an error occurs.
12724
12778
  **
12725
12779
  ** This API can be quite slow if used with an FTS5 table created with the
12726
12780
  ** "detail=none" or "detail=column" option.
@@ -12746,6 +12800,10 @@ struct Fts5PhraseIter {
12746
12800
  ** Invoking Api.xUserData() returns a copy of the pointer passed as
12747
12801
  ** the third argument to pUserData.
12748
12802
  **
12803
+ ** If parameter iPhrase is less than zero, or greater than or equal to
12804
+ ** the number of phrases in the query, as returned by xPhraseCount(),
12805
+ ** this function returns SQLITE_RANGE.
12806
+ **
12749
12807
  ** If the callback function returns any value other than SQLITE_OK, the
12750
12808
  ** query is abandoned and the xQueryPhrase function returns immediately.
12751
12809
  ** If the returned value is SQLITE_DONE, xQueryPhrase returns SQLITE_OK.
@@ -12860,9 +12918,42 @@ struct Fts5PhraseIter {
12860
12918
  **
12861
12919
  ** xPhraseNextColumn()
12862
12920
  ** See xPhraseFirstColumn above.
12921
+ **
12922
+ ** xQueryToken(pFts5, iPhrase, iToken, ppToken, pnToken)
12923
+ ** This is used to access token iToken of phrase iPhrase of the current
12924
+ ** query. Before returning, output parameter *ppToken is set to point
12925
+ ** to a buffer containing the requested token, and *pnToken to the
12926
+ ** size of this buffer in bytes.
12927
+ **
12928
+ ** If iPhrase or iToken are less than zero, or if iPhrase is greater than
12929
+ ** or equal to the number of phrases in the query as reported by
12930
+ ** xPhraseCount(), or if iToken is equal to or greater than the number of
12931
+ ** tokens in the phrase, SQLITE_RANGE is returned and *ppToken and *pnToken
12932
+ are both zeroed.
12933
+ **
12934
+ ** The output text is not a copy of the query text that specified the
12935
+ ** token. It is the output of the tokenizer module. For tokendata=1
12936
+ ** tables, this includes any embedded 0x00 and trailing data.
12937
+ **
12938
+ ** xInstToken(pFts5, iIdx, iToken, ppToken, pnToken)
12939
+ ** This is used to access token iToken of phrase hit iIdx within the
12940
+ ** current row. If iIdx is less than zero or greater than or equal to the
12941
+ ** value returned by xInstCount(), SQLITE_RANGE is returned. Otherwise,
12942
+ ** output variable (*ppToken) is set to point to a buffer containing the
12943
+ ** matching document token, and (*pnToken) to the size of that buffer in
12944
+ ** bytes. This API is not available if the specified token matches a
12945
+ ** prefix query term. In that case both output variables are always set
12946
+ ** to 0.
12947
+ **
12948
+ ** The output text is not a copy of the document text that was tokenized.
12949
+ ** It is the output of the tokenizer module. For tokendata=1 tables, this
12950
+ ** includes any embedded 0x00 and trailing data.
12951
+ **
12952
+ ** This API can be quite slow if used with an FTS5 table created with the
12953
+ ** "detail=none" or "detail=column" option.
12863
12954
  */
12864
12955
  struct Fts5ExtensionApi {
12865
- int iVersion; /* Currently always set to 2 */
12956
+ int iVersion; /* Currently always set to 3 */
12866
12957
 
12867
12958
  void *(*xUserData)(Fts5Context *);
12868
12959
 
@@ -12899,6 +12990,11 @@ struct Fts5ExtensionApi {
12899
12990
  int (*xPhraseFirstColumn)(Fts5Context *, int iPhrase, Fts5PhraseIter *,
12900
12991
  int *);
12901
12992
  void (*xPhraseNextColumn)(Fts5Context *, Fts5PhraseIter *, int *piCol);
12993
+
12994
+ /* Below this point are iVersion>=3 only */
12995
+ int (*xQueryToken)(Fts5Context *, int iPhrase, int iToken,
12996
+ const char **ppToken, int *pnToken);
12997
+ int (*xInstToken)(Fts5Context *, int iIdx, int iToken, const char **, int *);
12902
12998
  };
12903
12999
 
12904
13000
  /*
package/cpp/utils.cpp CHANGED
@@ -210,12 +210,12 @@ BatchResult importSQLFile(std::string dbName, std::string fileLocation) {
210
210
  try {
211
211
  int affectedRows = 0;
212
212
  int commands = 0;
213
- sqlite_execute_literal(dbName, "BEGIN EXCLUSIVE TRANSACTION");
213
+ opsqlite_execute_literal(dbName, "BEGIN EXCLUSIVE TRANSACTION");
214
214
  while (std::getline(sqFile, line, '\n')) {
215
215
  if (!line.empty()) {
216
- BridgeResult result = sqlite_execute_literal(dbName, line);
216
+ BridgeResult result = opsqlite_execute_literal(dbName, line);
217
217
  if (result.type == SQLiteError) {
218
- sqlite_execute_literal(dbName, "ROLLBACK");
218
+ opsqlite_execute_literal(dbName, "ROLLBACK");
219
219
  sqFile.close();
220
220
  return {SQLiteError, result.message, 0, commands};
221
221
  } else {
@@ -225,11 +225,11 @@ BatchResult importSQLFile(std::string dbName, std::string fileLocation) {
225
225
  }
226
226
  }
227
227
  sqFile.close();
228
- sqlite_execute_literal(dbName, "COMMIT");
228
+ opsqlite_execute_literal(dbName, "COMMIT");
229
229
  return {SQLiteOk, "", affectedRows, commands};
230
230
  } catch (...) {
231
231
  sqFile.close();
232
- sqlite_execute_literal(dbName, "ROLLBACK");
232
+ opsqlite_execute_literal(dbName, "ROLLBACK");
233
233
  return {SQLiteError,
234
234
  "[op-sqlite][loadSQLFile] Unexpected error, transaction was "
235
235
  "rolledback",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@op-engineering/op-sqlite",
3
- "version": "2.0.16",
3
+ "version": "2.0.17",
4
4
  "description": "Next generation SQLite for React Native",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",