better-sqlite3-multiple-ciphers 7.5.1-beta.3 → 7.5.1

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/README.md CHANGED
@@ -17,10 +17,10 @@ The fastest and simplest library for SQLite3 in Node.js. This particular fork su
17
17
  ## Current versions
18
18
 
19
19
  - ### Stable
20
- - **better-sqlite3-multiple-ciphers** - [`7.5.0`](https://github.com/m4heshd/better-sqlite3-multiple-ciphers/releases/tag/v7.5.0)
21
- - **better-sqlite3** - [`7.5.0`](https://github.com/JoshuaWise/better-sqlite3/releases/tag/v7.5.0)
22
- - **SQLite** - [`3.37.2`](https://www.sqlite.org/draft/releaselog/3_37_2.html)
23
- - **SQLite3 Multiple Ciphers** - [`1.3.7`](https://github.com/utelle/SQLite3MultipleCiphers/releases/tag/v1.3.7)
20
+ - **better-sqlite3-multiple-ciphers** - [`7.5.1`](https://github.com/m4heshd/better-sqlite3-multiple-ciphers/releases/tag/v7.5.1)
21
+ - **better-sqlite3** - [`7.5.1`](https://github.com/JoshuaWise/better-sqlite3/releases/tag/v7.5.1)
22
+ - **SQLite** - [`3.38.2`](https://www.sqlite.org/draft/releaselog/3_38_2.html)
23
+ - **SQLite3 Multiple Ciphers** - [`1.3.10`](https://github.com/utelle/SQLite3MultipleCiphers/releases/tag/v1.3.10)
24
24
 
25
25
  - ### Beta
26
26
  - **better-sqlite3-multiple-ciphers** - [`7.5.1-beta.3`](https://github.com/m4heshd/better-sqlite3-multiple-ciphers/releases/tag/v7.5.1-beta.3)
package/deps/copy.js ADDED
@@ -0,0 +1,26 @@
1
+ 'use strict';
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+
5
+ const dest = process.argv[2];
6
+ const source = path.resolve(path.sep, process.argv[3] || path.join(__dirname, 'sqlite3'));
7
+ const files = [
8
+ { filename: 'sqlite3.c', optional: false },
9
+ { filename: 'sqlite3.h', optional: false },
10
+ ];
11
+
12
+ if (process.argv[3]) {
13
+ // Support "_HAVE_SQLITE_CONFIG_H" in custom builds.
14
+ files.push({ filename: 'config.h', optional: true });
15
+ } else {
16
+ // Required for some tests.
17
+ files.push({ filename: 'sqlite3ext.h', optional: false });
18
+ }
19
+
20
+ for (const { filename, optional } of files) {
21
+ if (optional && !fs.existsSync(path.join(source, filename))) {
22
+ continue;
23
+ }
24
+ fs.accessSync(path.join(source, filename));
25
+ fs.copyFileSync(path.join(source, filename), path.join(dest, filename));
26
+ }
package/deps/download.sh CHANGED
@@ -1,111 +1,111 @@
1
- #!/usr/bin/env bash
2
-
3
- # ===
4
- # This script defines and generates the bundled SQLite3 unit (sqlite3.c).
5
- #
6
- # The following steps are taken:
7
- # 1. populate the shell environment with the defined compile-time options.
8
- # 2. download and extract the SQLite3 source code into a temporary directory.
9
- # 3. run "sh configure" and "make sqlite3.c" within the source directory.
10
- # 4. copy the generated amalgamation into the output directory (./sqlite3).
11
- # 5. export the defined compile-time options to a gyp file (./defines.gypi).
12
- # 6. update the docs (../docs/compilation.md) with details of this distribution.
13
- #
14
- # When a user builds better-sqlite3, the following steps are taken:
15
- # 1. node-gyp loads the previously exported compile-time options (defines.gypi).
16
- # 2. the symlink.js script creates symlinks to the bundled amalgamation.
17
- # 3. node-gyp compiles the symlinked sqlite3.c along with better_sqlite3.cpp.
18
- # 4. node-gyp links the two resulting binaries to generate better_sqlite3.node.
19
- # ===
20
-
21
- YEAR="2022"
22
- VERSION="3370200"
23
-
24
- DEFINES="
25
- SQLITE_DQS=0
26
- SQLITE_LIKE_DOESNT_MATCH_BLOBS
27
- SQLITE_THREADSAFE=2
28
- SQLITE_USE_URI=0
29
- SQLITE_DEFAULT_MEMSTATUS=0
30
- SQLITE_OMIT_DEPRECATED
31
- SQLITE_OMIT_GET_TABLE
32
- SQLITE_OMIT_TCL_VARIABLE
33
- SQLITE_OMIT_PROGRESS_CALLBACK
34
- SQLITE_OMIT_SHARED_CACHE
35
- SQLITE_TRACE_SIZE_LIMIT=32
36
- SQLITE_DEFAULT_CACHE_SIZE=-16000
37
- SQLITE_DEFAULT_FOREIGN_KEYS=1
38
- SQLITE_DEFAULT_WAL_SYNCHRONOUS=1
39
- SQLITE_ENABLE_MATH_FUNCTIONS
40
- SQLITE_ENABLE_DESERIALIZE
41
- SQLITE_ENABLE_COLUMN_METADATA
42
- SQLITE_ENABLE_UPDATE_DELETE_LIMIT
43
- SQLITE_ENABLE_STAT4
44
- SQLITE_ENABLE_FTS3_PARENTHESIS
45
- SQLITE_ENABLE_FTS3
46
- SQLITE_ENABLE_FTS4
47
- SQLITE_ENABLE_FTS5
48
- SQLITE_ENABLE_JSON1
49
- SQLITE_ENABLE_RTREE
50
- SQLITE_ENABLE_GEOPOLY
51
- SQLITE_INTROSPECTION_PRAGMAS
52
- SQLITE_SOUNDEX
53
- HAVE_STDINT_H=1
54
- HAVE_INT8_T=1
55
- HAVE_INT16_T=1
56
- HAVE_INT32_T=1
57
- HAVE_UINT8_T=1
58
- HAVE_UINT16_T=1
59
- HAVE_UINT32_T=1
60
- SQLITE_USER_AUTHENTICATION=0
61
- "
62
-
63
- # ========== START SCRIPT ========== #
64
-
65
- echo "setting up environment..."
66
- DEPS="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
67
- TEMP="$DEPS/temp"
68
- OUTPUT="$DEPS/sqlite3"
69
- rm -rf "$TEMP"
70
- rm -rf "$OUTPUT"
71
- mkdir -p "$TEMP"
72
- mkdir -p "$OUTPUT"
73
- export CFLAGS=`echo $(echo "$DEFINES" | sed -e "/^\s*$/d" -e "s/^/-D/")`
74
-
75
- echo "downloading source..."
76
- curl -#f "https://www.sqlite.org/$YEAR/sqlite-src-$VERSION.zip" > "$TEMP/source.zip" || exit 1
77
-
78
- echo "extracting source..."
79
- unzip "$TEMP/source.zip" -d "$TEMP" > /dev/null || exit 1
80
- cd "$TEMP/sqlite-src-$VERSION" || exit 1
81
-
82
- echo "configuring amalgamation..."
83
- sh configure > /dev/null || exit 1
84
-
85
- echo "building amalgamation..."
86
- make sqlite3.c > /dev/null || exit 1
87
-
88
- echo "copying amalgamation..."
89
- cp sqlite3.c sqlite3.h sqlite3ext.h "$OUTPUT/" || exit 1
90
-
91
- echo "updating gyp configs..."
92
- GYP="$DEPS/defines.gypi"
93
- printf "# THIS FILE IS AUTOMATICALLY GENERATED (DO NOT EDIT)\n\n{\n 'defines': [\n" > "$GYP"
94
- printf "$DEFINES" | sed -e "/^\s*$/d" -e "s/\(.*\)/ '\1',/" >> "$GYP"
95
- printf " ],\n}\n" >> "$GYP"
96
-
97
- echo "updating docs..."
98
- DOCS="$DEPS/../docs/compilation.md"
99
- MAJOR=`expr "${VERSION:0:1}" + 0`
100
- MINOR=`expr "${VERSION:1:2}" + 0`
101
- PATCH=`expr "${VERSION:3:2}" + 0`
102
- sed -Ei "" -e "s/version [0-9]+\.[0-9]+\.[0-9]+/version $MAJOR.$MINOR.$PATCH/g" "$DOCS"
103
- sed -i "" -e "/^SQLITE_/,\$d" "$DOCS"
104
- printf "$DEFINES" | sed -e "/^\s*$/d" >> "$DOCS"
105
- printf "\`\`\`\n" >> "$DOCS"
106
-
107
- echo "cleaning up..."
108
- cd - > /dev/null || exit 1
109
- rm -rf "$TEMP"
110
-
111
- echo "done!"
1
+ #!/usr/bin/env bash
2
+
3
+ # ===
4
+ # This script defines and generates the bundled SQLite3 unit (sqlite3.c).
5
+ #
6
+ # The following steps are taken:
7
+ # 1. populate the shell environment with the defined compile-time options.
8
+ # 2. download and extract the SQLite3 source code into a temporary directory.
9
+ # 3. run "sh configure" and "make sqlite3.c" within the source directory.
10
+ # 4. copy the generated amalgamation into the output directory (./sqlite3).
11
+ # 5. export the defined compile-time options to a gyp file (./defines.gypi).
12
+ # 6. update the docs (../docs/compilation.md) with details of this distribution.
13
+ #
14
+ # When a user builds better-sqlite3, the following steps are taken:
15
+ # 1. node-gyp loads the previously exported compile-time options (defines.gypi).
16
+ # 2. the copy.js script copies the bundled amalgamation into the build folder.
17
+ # 3. node-gyp compiles the copied sqlite3.c along with better_sqlite3.cpp.
18
+ # 4. node-gyp links the two resulting binaries to generate better_sqlite3.node.
19
+ # ===
20
+
21
+ YEAR="2022"
22
+ VERSION="3380200"
23
+
24
+ DEFINES="
25
+ SQLITE_DQS=0
26
+ SQLITE_LIKE_DOESNT_MATCH_BLOBS
27
+ SQLITE_THREADSAFE=2
28
+ SQLITE_USE_URI=0
29
+ SQLITE_DEFAULT_MEMSTATUS=0
30
+ SQLITE_OMIT_DEPRECATED
31
+ SQLITE_OMIT_GET_TABLE
32
+ SQLITE_OMIT_TCL_VARIABLE
33
+ SQLITE_OMIT_PROGRESS_CALLBACK
34
+ SQLITE_OMIT_SHARED_CACHE
35
+ SQLITE_TRACE_SIZE_LIMIT=32
36
+ SQLITE_DEFAULT_CACHE_SIZE=-16000
37
+ SQLITE_DEFAULT_FOREIGN_KEYS=1
38
+ SQLITE_DEFAULT_WAL_SYNCHRONOUS=1
39
+ SQLITE_ENABLE_MATH_FUNCTIONS
40
+ SQLITE_ENABLE_DESERIALIZE
41
+ SQLITE_ENABLE_COLUMN_METADATA
42
+ SQLITE_ENABLE_UPDATE_DELETE_LIMIT
43
+ SQLITE_ENABLE_STAT4
44
+ SQLITE_ENABLE_FTS3_PARENTHESIS
45
+ SQLITE_ENABLE_FTS3
46
+ SQLITE_ENABLE_FTS4
47
+ SQLITE_ENABLE_FTS5
48
+ SQLITE_ENABLE_JSON1
49
+ SQLITE_ENABLE_RTREE
50
+ SQLITE_ENABLE_GEOPOLY
51
+ SQLITE_INTROSPECTION_PRAGMAS
52
+ SQLITE_SOUNDEX
53
+ HAVE_STDINT_H=1
54
+ HAVE_INT8_T=1
55
+ HAVE_INT16_T=1
56
+ HAVE_INT32_T=1
57
+ HAVE_UINT8_T=1
58
+ HAVE_UINT16_T=1
59
+ HAVE_UINT32_T=1
60
+ SQLITE_USER_AUTHENTICATION=0
61
+ "
62
+
63
+ # ========== START SCRIPT ========== #
64
+
65
+ echo "setting up environment..."
66
+ DEPS="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
67
+ TEMP="$DEPS/temp"
68
+ OUTPUT="$DEPS/sqlite3"
69
+ rm -rf "$TEMP"
70
+ rm -rf "$OUTPUT"
71
+ mkdir -p "$TEMP"
72
+ mkdir -p "$OUTPUT"
73
+ export CFLAGS=`echo $(echo "$DEFINES" | sed -e "/^\s*$/d" -e "s/^/-D/")`
74
+
75
+ echo "downloading source..."
76
+ curl -#f "https://www.sqlite.org/$YEAR/sqlite-src-$VERSION.zip" > "$TEMP/source.zip" || exit 1
77
+
78
+ echo "extracting source..."
79
+ unzip "$TEMP/source.zip" -d "$TEMP" > /dev/null || exit 1
80
+ cd "$TEMP/sqlite-src-$VERSION" || exit 1
81
+
82
+ echo "configuring amalgamation..."
83
+ sh configure > /dev/null || exit 1
84
+
85
+ echo "building amalgamation..."
86
+ make sqlite3.c > /dev/null || exit 1
87
+
88
+ echo "copying amalgamation..."
89
+ cp sqlite3.c sqlite3.h sqlite3ext.h "$OUTPUT/" || exit 1
90
+
91
+ echo "updating gyp configs..."
92
+ GYP="$DEPS/defines.gypi"
93
+ printf "# THIS FILE IS AUTOMATICALLY GENERATED (DO NOT EDIT)\n\n{\n 'defines': [\n" > "$GYP"
94
+ printf "$DEFINES" | sed -e "/^\s*$/d" -e "s/\(.*\)/ '\1',/" >> "$GYP"
95
+ printf " ],\n}\n" >> "$GYP"
96
+
97
+ echo "updating docs..."
98
+ DOCS="$DEPS/../docs/compilation.md"
99
+ MAJOR=`expr "${VERSION:0:1}" + 0`
100
+ MINOR=`expr "${VERSION:1:2}" + 0`
101
+ PATCH=`expr "${VERSION:3:2}" + 0`
102
+ sed -Ei "" -e "s/version [0-9]+\.[0-9]+\.[0-9]+/version $MAJOR.$MINOR.$PATCH/g" "$DOCS"
103
+ sed -i "" -e "/^SQLITE_/,\$d" "$DOCS"
104
+ printf "$DEFINES" | sed -e "/^\s*$/d" >> "$DOCS"
105
+ printf "\`\`\`\n" >> "$DOCS"
106
+
107
+ echo "cleaning up..."
108
+ cd - > /dev/null || exit 1
109
+ rm -rf "$TEMP"
110
+
111
+ echo "done!"
package/deps/setup.ps1 CHANGED
@@ -2,7 +2,7 @@
2
2
  $ErrorActionPreference = "Stop"
3
3
 
4
4
  # SQLite Info
5
- $SQLITEMC_VER = "v1.3.9"
5
+ $SQLITEMC_VER = "v1.3.10"
6
6
  $API_URL = "https://api.github.com/repos/utelle/SQLite3MultipleCiphers/releases/tags/" + $SQLITEMC_VER
7
7
 
8
8
  # Paths
@@ -92,7 +92,7 @@ extern SQLITE_API LPWSTR sqlite3_win32_utf8_to_unicode(const char*);
92
92
  /*** Begin of #include "sqlite3patched.c" ***/
93
93
  /******************************************************************************
94
94
  ** This file is an amalgamation of many separate C source files from SQLite
95
- ** version 3.38.1. By combining all the individual C code files into this
95
+ ** version 3.38.2. By combining all the individual C code files into this
96
96
  ** single large file, the entire code can be compiled as a single translation
97
97
  ** unit. This allows many compilers to do optimizations that would not be
98
98
  ** possible if the files were compiled separately. Performance improvements
@@ -544,9 +544,9 @@ extern "C" {
544
544
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
545
545
  ** [sqlite_version()] and [sqlite_source_id()].
546
546
  */
547
- #define SQLITE_VERSION "3.38.1"
548
- #define SQLITE_VERSION_NUMBER 3038001
549
- #define SQLITE_SOURCE_ID "2022-03-12 13:37:29 38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547a8cbc"
547
+ #define SQLITE_VERSION "3.38.2"
548
+ #define SQLITE_VERSION_NUMBER 3038002
549
+ #define SQLITE_SOURCE_ID "2022-03-26 13:51:10 d33c709cc0af66bc5b6dc6216eba9f1f0b40960b9ae83694c986fbf4c1d6f08f"
550
550
 
551
551
  /*
552
552
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -39790,11 +39790,17 @@ static int unixShmLock(
39790
39790
  int flags /* What to do with the lock */
39791
39791
  ){
39792
39792
  unixFile *pDbFd = (unixFile*)fd; /* Connection holding shared memory */
39793
- unixShm *p = pDbFd->pShm; /* The shared memory being locked */
39794
- unixShmNode *pShmNode = p->pShmNode; /* The underlying file iNode */
39793
+ unixShm *p; /* The shared memory being locked */
39794
+ unixShmNode *pShmNode; /* The underlying file iNode */
39795
39795
  int rc = SQLITE_OK; /* Result code */
39796
39796
  u16 mask; /* Mask of locks to take or release */
39797
- int *aLock = pShmNode->aLock;
39797
+ int *aLock;
39798
+
39799
+ p = pDbFd->pShm;
39800
+ if( p==0 ) return SQLITE_IOERR_SHMLOCK;
39801
+ pShmNode = p->pShmNode;
39802
+ if( NEVER(pShmNode==0) ) return SQLITE_IOERR_SHMLOCK;
39803
+ aLock = pShmNode->aLock;
39798
39804
 
39799
39805
  assert( pShmNode==pDbFd->pInode->pShmNode );
39800
39806
  assert( pShmNode->pInode==pDbFd->pInode );
@@ -47082,10 +47088,14 @@ static int winShmLock(
47082
47088
  winFile *pDbFd = (winFile*)fd; /* Connection holding shared memory */
47083
47089
  winShm *p = pDbFd->pShm; /* The shared memory being locked */
47084
47090
  winShm *pX; /* For looping over all siblings */
47085
- winShmNode *pShmNode = p->pShmNode;
47091
+ winShmNode *pShmNode;
47086
47092
  int rc = SQLITE_OK; /* Result code */
47087
47093
  u16 mask; /* Mask of locks to take or release */
47088
47094
 
47095
+ if( p==0 ) return SQLITE_IOERR_SHMLOCK;
47096
+ pShmNode = p->pShmNode;
47097
+ if( NEVER(pShmNode==0) ) return SQLITE_IOERR_SHMLOCK;
47098
+
47089
47099
  assert( ofst>=0 && ofst+n<=SQLITE_SHM_NLOCK );
47090
47100
  assert( n>=1 );
47091
47101
  assert( flags==(SQLITE_SHM_LOCK | SQLITE_SHM_SHARED)
@@ -75092,24 +75102,6 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
75092
75102
  assert( (flags & (BTREE_SAVEPOSITION|BTREE_APPEND|BTREE_PREFORMAT))==flags );
75093
75103
  assert( (flags & BTREE_PREFORMAT)==0 || seekResult || pCur->pKeyInfo==0 );
75094
75104
 
75095
- if( pCur->eState==CURSOR_FAULT ){
75096
- assert( pCur->skipNext!=SQLITE_OK );
75097
- return pCur->skipNext;
75098
- }
75099
-
75100
- assert( cursorOwnsBtShared(pCur) );
75101
- assert( (pCur->curFlags & BTCF_WriteFlag)!=0
75102
- && pBt->inTransaction==TRANS_WRITE
75103
- && (pBt->btsFlags & BTS_READ_ONLY)==0 );
75104
- assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );
75105
-
75106
- /* Assert that the caller has been consistent. If this cursor was opened
75107
- ** expecting an index b-tree, then the caller should be inserting blob
75108
- ** keys with no associated data. If the cursor was opened expecting an
75109
- ** intkey table, the caller should be inserting integer keys with a
75110
- ** blob of associated data. */
75111
- assert( (flags & BTREE_PREFORMAT) || (pX->pKey==0)==(pCur->pKeyInfo==0) );
75112
-
75113
75105
  /* Save the positions of any other cursors open on this table.
75114
75106
  **
75115
75107
  ** In some cases, the call to btreeMoveto() below is a no-op. For
@@ -75134,6 +75126,24 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
75134
75126
  }
75135
75127
  }
75136
75128
 
75129
+ if( pCur->eState>=CURSOR_REQUIRESEEK ){
75130
+ rc = moveToRoot(pCur);
75131
+ if( rc && rc!=SQLITE_EMPTY ) return rc;
75132
+ }
75133
+
75134
+ assert( cursorOwnsBtShared(pCur) );
75135
+ assert( (pCur->curFlags & BTCF_WriteFlag)!=0
75136
+ && pBt->inTransaction==TRANS_WRITE
75137
+ && (pBt->btsFlags & BTS_READ_ONLY)==0 );
75138
+ assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );
75139
+
75140
+ /* Assert that the caller has been consistent. If this cursor was opened
75141
+ ** expecting an index b-tree, then the caller should be inserting blob
75142
+ ** keys with no associated data. If the cursor was opened expecting an
75143
+ ** intkey table, the caller should be inserting integer keys with a
75144
+ ** blob of associated data. */
75145
+ assert( (flags & BTREE_PREFORMAT) || (pX->pKey==0)==(pCur->pKeyInfo==0) );
75146
+
75137
75147
  if( pCur->pKeyInfo==0 ){
75138
75148
  assert( pX->pKey==0 );
75139
75149
  /* If this is an insert into a table b-tree, invalidate any incrblob
@@ -75222,8 +75232,7 @@ SQLITE_PRIVATE int sqlite3BtreeInsert(
75222
75232
  }
75223
75233
  }
75224
75234
  assert( pCur->eState==CURSOR_VALID
75225
- || (pCur->eState==CURSOR_INVALID && loc)
75226
- || CORRUPT_DB );
75235
+ || (pCur->eState==CURSOR_INVALID && loc) );
75227
75236
 
75228
75237
  pPage = pCur->pPage;
75229
75238
  assert( pPage->intKey || pX->nKey>=0 || (flags & BTREE_PREFORMAT) );
@@ -75510,12 +75519,16 @@ SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor *pCur, u8 flags){
75510
75519
  assert( hasSharedCacheTableLock(p, pCur->pgnoRoot, pCur->pKeyInfo!=0, 2) );
75511
75520
  assert( !hasReadConflicts(p, pCur->pgnoRoot) );
75512
75521
  assert( (flags & ~(BTREE_SAVEPOSITION | BTREE_AUXDELETE))==0 );
75513
- if( pCur->eState==CURSOR_REQUIRESEEK ){
75514
- rc = btreeRestoreCursorPosition(pCur);
75515
- assert( rc!=SQLITE_OK || CORRUPT_DB || pCur->eState==CURSOR_VALID );
75516
- if( rc || pCur->eState!=CURSOR_VALID ) return rc;
75522
+ if( pCur->eState!=CURSOR_VALID ){
75523
+ if( pCur->eState>=CURSOR_REQUIRESEEK ){
75524
+ rc = btreeRestoreCursorPosition(pCur);
75525
+ assert( rc!=SQLITE_OK || CORRUPT_DB || pCur->eState==CURSOR_VALID );
75526
+ if( rc || pCur->eState!=CURSOR_VALID ) return rc;
75527
+ }else{
75528
+ return SQLITE_CORRUPT_BKPT;
75529
+ }
75517
75530
  }
75518
- assert( CORRUPT_DB || pCur->eState==CURSOR_VALID );
75531
+ assert( pCur->eState==CURSOR_VALID );
75519
75532
 
75520
75533
  iCellDepth = pCur->iPage;
75521
75534
  iCellIdx = pCur->ix;
@@ -125202,7 +125215,7 @@ SQLITE_PRIVATE void sqlite3TableAffinity(Vdbe *v, Table *pTab, int iReg){
125202
125215
  }
125203
125216
 
125204
125217
  for(i=j=0; i<pTab->nCol; i++){
125205
- assert( pTab->aCol[i].affinity!=0 );
125218
+ assert( pTab->aCol[i].affinity!=0 || sqlite3VdbeParser(v)->nErr>0 );
125206
125219
  if( (pTab->aCol[i].colFlags & COLFLAG_VIRTUAL)==0 ){
125207
125220
  zColAff[j++] = pTab->aCol[i].affinity;
125208
125221
  }
@@ -133643,7 +133656,7 @@ SQLITE_PRIVATE int sqlite3InitOne(sqlite3 *db, int iDb, char **pzErrMsg, u32 mFl
133643
133656
  sqlite3ResetAllSchemasOfConnection(db);
133644
133657
  pDb = &db->aDb[iDb];
133645
133658
  }else
133646
- if( rc==SQLITE_OK || (db->flags&SQLITE_NoSchemaError)){
133659
+ if( rc==SQLITE_OK || ((db->flags&SQLITE_NoSchemaError) && rc!=SQLITE_NOMEM)){
133647
133660
  /* Hack: If the SQLITE_NoSchemaError flag is set, then consider
133648
133661
  ** the schema loaded, even if errors (other than OOM) occurred. In
133649
133662
  ** this situation the current sqlite3_prepare() operation will fail,
@@ -146389,6 +146402,7 @@ SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
146389
146402
 
146390
146403
  sqlite3ParseObjectInit(&sParse, db);
146391
146404
  sParse.eParseMode = PARSE_MODE_DECLARE_VTAB;
146405
+ sParse.disableTriggers = 1;
146392
146406
  /* We should never be able to reach this point while loading the
146393
146407
  ** schema. Nevertheless, defend against that (turn off db->init.busy)
146394
146408
  ** in case a bug arises. */
@@ -154686,8 +154700,17 @@ static void whereLoopOutputAdjust(
154686
154700
  /* If there are extra terms in the WHERE clause not used by an index
154687
154701
  ** that depend only on the table being scanned, and that will tend to
154688
154702
  ** cause many rows to be omitted, then mark that table as
154689
- ** "self-culling". */
154690
- pLoop->wsFlags |= WHERE_SELFCULL;
154703
+ ** "self-culling".
154704
+ **
154705
+ ** 2022-03-24: Self-culling only applies if either the extra terms
154706
+ ** are straight comparison operators that are non-true with NULL
154707
+ ** operand, or if the loop is not a LEFT JOIN.
154708
+ */
154709
+ if( (pTerm->eOperator & 0x3f)!=0
154710
+ || (pWC->pWInfo->pTabList->a[pLoop->iTab].fg.jointype & JT_LEFT)==0
154711
+ ){
154712
+ pLoop->wsFlags |= WHERE_SELFCULL;
154713
+ }
154691
154714
  }
154692
154715
  if( pTerm->truthProb<=0 ){
154693
154716
  /* If a truth probability is specified using the likelihood() hints,
@@ -157986,6 +158009,26 @@ whereBeginError:
157986
158009
  }
157987
158010
  #endif
157988
158011
 
158012
+ #ifdef SQLITE_DEBUG
158013
+ /*
158014
+ ** Return true if cursor iCur is opened by instruction k of the
158015
+ ** bytecode. Used inside of assert() only.
158016
+ */
158017
+ static int cursorIsOpen(Vdbe *v, int iCur, int k){
158018
+ while( k>=0 ){
158019
+ VdbeOp *pOp = sqlite3VdbeGetOp(v,k--);
158020
+ if( pOp->p1!=iCur ) continue;
158021
+ if( pOp->opcode==OP_Close ) return 0;
158022
+ if( pOp->opcode==OP_OpenRead ) return 1;
158023
+ if( pOp->opcode==OP_OpenWrite ) return 1;
158024
+ if( pOp->opcode==OP_OpenDup ) return 1;
158025
+ if( pOp->opcode==OP_OpenAutoindex ) return 1;
158026
+ if( pOp->opcode==OP_OpenEphemeral ) return 1;
158027
+ }
158028
+ return 0;
158029
+ }
158030
+ #endif /* SQLITE_DEBUG */
158031
+
157989
158032
  /*
157990
158033
  ** Generate the end of the WHERE loop. See comments on
157991
158034
  ** sqlite3WhereBegin() for additional information.
@@ -158238,14 +158281,15 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
158238
158281
  ){
158239
158282
  int x = pOp->p2;
158240
158283
  assert( pIdx->pTable==pTab );
158284
+ #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
158285
+ if( pOp->opcode==OP_Offset ){
158286
+ /* Do not need to translate the column number */
158287
+ }else
158288
+ #endif
158241
158289
  if( !HasRowid(pTab) ){
158242
158290
  Index *pPk = sqlite3PrimaryKeyIndex(pTab);
158243
158291
  x = pPk->aiColumn[x];
158244
158292
  assert( x>=0 );
158245
- #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
158246
- }else if( pOp->opcode==OP_Offset ){
158247
- /* Do not need to translate the column number */
158248
- #endif
158249
158293
  }else{
158250
158294
  testcase( x!=sqlite3StorageColumnToTable(pTab,x) );
158251
158295
  x = sqlite3StorageColumnToTable(pTab,x);
@@ -158255,9 +158299,22 @@ SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo *pWInfo){
158255
158299
  pOp->p2 = x;
158256
158300
  pOp->p1 = pLevel->iIdxCur;
158257
158301
  OpcodeRewriteTrace(db, k, pOp);
158302
+ }else{
158303
+ /* Unable to translate the table reference into an index
158304
+ ** reference. Verify that this is harmless - that the
158305
+ ** table being referenced really is open.
158306
+ */
158307
+ #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
158308
+ assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
158309
+ || cursorIsOpen(v,pOp->p1,k)
158310
+ || pOp->opcode==OP_Offset
158311
+ );
158312
+ #else
158313
+ assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0
158314
+ || cursorIsOpen(v,pOp->p1,k)
158315
+ );
158316
+ #endif
158258
158317
  }
158259
- assert( (pLoop->wsFlags & WHERE_IDX_ONLY)==0 || x>=0
158260
- || pWInfo->eOnePass );
158261
158318
  }else if( pOp->opcode==OP_Rowid ){
158262
158319
  pOp->p1 = pLevel->iIdxCur;
158263
158320
  pOp->opcode = OP_IdxRowid;
@@ -234485,7 +234542,7 @@ static void fts5SourceIdFunc(
234485
234542
  ){
234486
234543
  assert( nArg==0 );
234487
234544
  UNUSED_PARAM2(nArg, apUnused);
234488
- sqlite3_result_text(pCtx, "fts5: 2022-03-12 13:37:29 38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547a8cbc", -1, SQLITE_TRANSIENT);
234545
+ sqlite3_result_text(pCtx, "fts5: 2022-03-26 13:51:10 d33c709cc0af66bc5b6dc6216eba9f1f0b40960b9ae83694c986fbf4c1d6f08f", -1, SQLITE_TRANSIENT);
234489
234546
  }
234490
234547
 
234491
234548
  /*
@@ -239614,9 +239671,9 @@ SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
239614
239671
 
239615
239672
  #define SQLITE3MC_VERSION_MAJOR 1
239616
239673
  #define SQLITE3MC_VERSION_MINOR 3
239617
- #define SQLITE3MC_VERSION_RELEASE 9
239674
+ #define SQLITE3MC_VERSION_RELEASE 10
239618
239675
  #define SQLITE3MC_VERSION_SUBRELEASE 0
239619
- #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.3.9"
239676
+ #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.3.10"
239620
239677
 
239621
239678
  #endif /* SQLITE3MC_VERSION_H_ */
239622
239679
  /*** End of #include "sqlite3mc_version.h" ***/
@@ -239775,9 +239832,9 @@ extern "C" {
239775
239832
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
239776
239833
  ** [sqlite_version()] and [sqlite_source_id()].
239777
239834
  */
239778
- #define SQLITE_VERSION "3.38.1"
239779
- #define SQLITE_VERSION_NUMBER 3038001
239780
- #define SQLITE_SOURCE_ID "2022-03-12 13:37:29 38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547a8cbc"
239835
+ #define SQLITE_VERSION "3.38.2"
239836
+ #define SQLITE_VERSION_NUMBER 3038002
239837
+ #define SQLITE_SOURCE_ID "2022-03-26 13:51:10 d33c709cc0af66bc5b6dc6216eba9f1f0b40960b9ae83694c986fbf4c1d6f08f"
239781
239838
 
239782
239839
  /*
239783
239840
  ** CAPI3REF: Run-Time Library Version Numbers
@@ -262304,6 +262361,26 @@ sqlite3mcFileControlPragma(sqlite3* db, const char* zDbName, int op, void* pArg)
262304
262361
  ((char**)pArg)[0] = sqlite3_mprintf("ok");
262305
262362
  }
262306
262363
  }
262364
+ else if (sqlite3StrICmp(pragmaName, "hexkey") == 0)
262365
+ {
262366
+ int nValue = sqlite3Strlen30(pragmaValue);
262367
+ if (((nValue & 1) == 0) && (sqlite3mcIsHexKey(pragmaValue, nValue) != 0))
262368
+ {
262369
+ char* zHexKey = sqlite3_malloc(nValue/2);
262370
+ sqlite3mcConvertHex2Bin(pragmaValue, nValue, zHexKey);
262371
+ rc = sqlite3_key_v2(db, zDbName, zHexKey, nValue/2);
262372
+ sqlite3_free(zHexKey);
262373
+ if (rc == SQLITE_OK)
262374
+ {
262375
+ ((char**)pArg)[0] = sqlite3_mprintf("ok");
262376
+ }
262377
+ }
262378
+ else
262379
+ {
262380
+ rc = SQLITE_ERROR;
262381
+ ((char**)pArg)[0] = sqlite3_mprintf("Malformed hex string");
262382
+ }
262383
+ }
262307
262384
  else if (sqlite3StrICmp(pragmaName, "rekey") == 0)
262308
262385
  {
262309
262386
  rc = sqlite3_rekey_v2(db, zDbName, pragmaValue, -1);
@@ -262323,6 +262400,37 @@ sqlite3mcFileControlPragma(sqlite3* db, const char* zDbName, int op, void* pArg)
262323
262400
  }
262324
262401
  }
262325
262402
  }
262403
+ else if (sqlite3StrICmp(pragmaName, "hexrekey") == 0)
262404
+ {
262405
+ int nValue = sqlite3Strlen30(pragmaValue);
262406
+ if (((nValue & 1) == 0) && (sqlite3mcIsHexKey(pragmaValue, nValue) != 0))
262407
+ {
262408
+ char* zHexKey = sqlite3_malloc(nValue/2);
262409
+ sqlite3mcConvertHex2Bin(pragmaValue, nValue, zHexKey);
262410
+ rc = sqlite3_rekey_v2(db, zDbName, zHexKey, nValue/2);
262411
+ sqlite3_free(zHexKey);
262412
+ if (rc == SQLITE_OK)
262413
+ {
262414
+ ((char**)pArg)[0] = sqlite3_mprintf("ok");
262415
+ }
262416
+ else
262417
+ {
262418
+ if (db->pErr)
262419
+ {
262420
+ const char* z = (const char*)sqlite3_value_text(db->pErr);
262421
+ if (z && sqlite3Strlen30(z) > 0)
262422
+ {
262423
+ ((char**)pArg)[0] = sqlite3_mprintf(z);
262424
+ }
262425
+ }
262426
+ }
262427
+ }
262428
+ else
262429
+ {
262430
+ rc = SQLITE_ERROR;
262431
+ ((char**)pArg)[0] = sqlite3_mprintf("Malformed hex string");
262432
+ }
262433
+ }
262326
262434
  else
262327
262435
  {
262328
262436
  int j;
@@ -262387,13 +262495,15 @@ sqlite3mcCodecQueryParameters(sqlite3* db, const char* zDb, const char* zUri)
262387
262495
  {
262388
262496
  u8 iByte;
262389
262497
  int i;
262390
- char zDecoded[40];
262391
- for (i = 0, iByte = 0; i < sizeof(zDecoded) * 2 && sqlite3Isxdigit(zKey[i]); i++)
262498
+ int nKey = sqlite3Strlen30(zKey);
262499
+ char* zDecoded = sqlite3_malloc(nKey);
262500
+ for (i = 0, iByte = 0; i < nKey && sqlite3Isxdigit(zKey[i]); i++)
262392
262501
  {
262393
262502
  iByte = (iByte << 4) + sqlite3HexToInt(zKey[i]);
262394
- if ((i & 1) != 0) zDecoded[i / 2] = iByte;
262503
+ if ((i & 1) != 0) zDecoded[i/2] = iByte;
262395
262504
  }
262396
- sqlite3_key_v2(db, zDb, zDecoded, i / 2);
262505
+ sqlite3_key_v2(db, zDb, zDecoded, i/2);
262506
+ sqlite3_free(zDecoded);
262397
262507
  }
262398
262508
  else if ((zKey = sqlite3_uri_parameter(zUri, "key")) != 0)
262399
262509
  {
@@ -262547,7 +262657,7 @@ sqlite3mcBtreeSetPageSize(Btree* p, int pageSize, int nReserve, int iFix)
262547
262657
  ** Change 4: Call sqlite3mcBtreeSetPageSize instead of sqlite3BtreeSetPageSize for main database
262548
262658
  ** (sqlite3mcBtreeSetPageSize allows to reduce the number of reserved bytes)
262549
262659
  **
262550
- ** This code is generated by the script rekeyvacuum.sh from SQLite version 3.38.1 amalgamation.
262660
+ ** This code is generated by the script rekeyvacuum.sh from SQLite version 3.38.2 amalgamation.
262551
262661
  */
262552
262662
  SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3mcRunVacuumForRekey(
262553
262663
  char **pzErrMsg, /* Write error message here */
@@ -267303,6 +267413,15 @@ SQLITE_EXTENSION_INIT1
267303
267413
  #include <stdio.h>
267304
267414
  #include <math.h>
267305
267415
 
267416
+ #ifdef SQLITE_HAVE_ZLIB
267417
+ #include <zlib.h>
267418
+ #define fopen gzopen
267419
+ #define fclose gzclose
267420
+ #define fread gzfread
267421
+ #define fseek gzseek
267422
+ #define ftell gztell
267423
+ #endif
267424
+
267306
267425
  #ifndef SQLITE_OMIT_VIRTUALTABLE
267307
267426
 
267308
267427
  /*
@@ -267334,7 +267453,11 @@ SQLITE_EXTENSION_INIT1
267334
267453
  typedef struct VsvReader VsvReader;
267335
267454
  struct VsvReader
267336
267455
  {
267456
+ #ifdef SQLITE_HAVE_ZLIB
267457
+ gzFile in; /* Read the VSV text from this compressed input stream */
267458
+ #else
267337
267459
  FILE *in; /* Read the VSV text from this input stream */
267460
+ #endif
267338
267461
  char *z; /* Accumulated text for a field */
267339
267462
  int n; /* Number of bytes in z */
267340
267463
  int nAlloc; /* Space allocated for z[] */
@@ -268234,6 +268357,7 @@ static int vsvtabConnect(
268234
268357
  }
268235
268358
  else if (nCol<0)
268236
268359
  {
268360
+ nCol = 0;
268237
268361
  do
268238
268362
  {
268239
268363
  vsv_read_one_field(&sRdr);
@@ -31,9 +31,9 @@
31
31
 
32
32
  #define SQLITE3MC_VERSION_MAJOR 1
33
33
  #define SQLITE3MC_VERSION_MINOR 3
34
- #define SQLITE3MC_VERSION_RELEASE 9
34
+ #define SQLITE3MC_VERSION_RELEASE 10
35
35
  #define SQLITE3MC_VERSION_SUBRELEASE 0
36
- #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.3.9"
36
+ #define SQLITE3MC_VERSION_STRING "SQLite3 Multiple Ciphers 1.3.10"
37
37
 
38
38
  #endif /* SQLITE3MC_VERSION_H_ */
39
39
  /*** End of #include "sqlite3mc_version.h" ***/
@@ -192,9 +192,9 @@ extern "C" {
192
192
  ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
193
193
  ** [sqlite_version()] and [sqlite_source_id()].
194
194
  */
195
- #define SQLITE_VERSION "3.38.1"
196
- #define SQLITE_VERSION_NUMBER 3038001
197
- #define SQLITE_SOURCE_ID "2022-03-12 13:37:29 38c210fdd258658321c85ec9c01a072fda3ada94540e3239d29b34dc547a8cbc"
195
+ #define SQLITE_VERSION "3.38.2"
196
+ #define SQLITE_VERSION_NUMBER 3038002
197
+ #define SQLITE_SOURCE_ID "2022-03-26 13:51:10 d33c709cc0af66bc5b6dc6216eba9f1f0b40960b9ae83694c986fbf4c1d6f08f"
198
198
 
199
199
  /*
200
200
  ** CAPI3REF: Run-Time Library Version Numbers
package/deps/sqlite3.gyp CHANGED
@@ -14,7 +14,7 @@
14
14
  'conditions': [
15
15
  ['sqlite3 == ""', {
16
16
  'actions': [{
17
- 'action_name': 'symlink_builtin_sqlite3',
17
+ 'action_name': 'copy_builtin_sqlite3',
18
18
  'inputs': [
19
19
  'sqlite3/sqlite3.c',
20
20
  'sqlite3/sqlite3.h',
@@ -25,11 +25,11 @@
25
25
  '<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.h',
26
26
  '<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3ext.h',
27
27
  ],
28
- 'action': ['node', 'symlink.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3', '', 'sqlite3.c', 'sqlite3.h', 'sqlite3ext.h'],
28
+ 'action': ['node', 'copy.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3', '', 'sqlite3.c', 'sqlite3.h', 'sqlite3ext.h'],
29
29
  }],
30
30
  }, {
31
31
  'actions': [{
32
- 'action_name': 'symlink_custom_sqlite3',
32
+ 'action_name': 'copy_custom_sqlite3',
33
33
  'inputs': [
34
34
  '<(sqlite3)/sqlite3.c',
35
35
  '<(sqlite3)/sqlite3.h',
@@ -38,7 +38,7 @@
38
38
  '<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.c',
39
39
  '<(SHARED_INTERMEDIATE_DIR)/sqlite3/sqlite3.h',
40
40
  ],
41
- 'action': ['node', 'symlink.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3', '<(sqlite3)', 'sqlite3.c', 'sqlite3.h'],
41
+ 'action': ['node', 'copy.js', '<(SHARED_INTERMEDIATE_DIR)/sqlite3', '<(sqlite3)', 'sqlite3.c', 'sqlite3.h'],
42
42
  }],
43
43
  }],
44
44
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-sqlite3-multiple-ciphers",
3
- "version": "7.5.1-beta.3",
3
+ "version": "7.5.1",
4
4
  "description": "better-sqlite3 with multiple-cipher encryption support",
5
5
  "homepage": "https://github.com/m4heshd/better-sqlite3-multiple-ciphers",
6
6
  "author": "Mahesh Bandara Wijerathna (m4heshd) <m4heshd@gmail.com>",
package/deps/symlink.js DELETED
@@ -1,19 +0,0 @@
1
- 'use strict';
2
- const path = require('path');
3
- const fs = require('fs');
4
-
5
- const dest = process.argv[2];
6
- const source = path.resolve(path.sep, process.argv[3] || path.join(__dirname, 'sqlite3'));
7
- const filenames = process.argv.slice(4).map(str => path.basename(str));
8
-
9
- /*
10
- This creates symlinks inside the <$2> directory, linking to files inside the
11
- directory specified by the absolute path <$3>. If no path <$3> is provided,
12
- the default path of "./deps/sqlite3" is used. The basenames of the files to
13
- link are specified by <$4...>.
14
- */
15
-
16
- for (const filename of filenames) {
17
- fs.accessSync(path.join(source, filename));
18
- fs.symlinkSync(path.join(source, filename), path.join(dest, filename), 'file');
19
- }