Skip to content

Commit d7bf7fc

Browse files
committed
Prepare release of version 1.6.0
- Based on SQLite version 3.41.0
1 parent aae1cc7 commit d7bf7fc

22 files changed

+7566
-3208
lines changed

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
dnl Process this script with autoconf to create configure for sqlite3mc library
22
dnl
3-
dnl Copyright (C) 2019-2022 Ulrich Telle <[email protected]>
3+
dnl Copyright (C) 2019-2023 Ulrich Telle <[email protected]>
44
dnl
55
dnl This file is covered by the same licence as the entire SQLite3 Multiple Ciphers package.
66

7-
AC_INIT([sqlite3mc], [1.5.5], [[email protected]])
7+
AC_INIT([sqlite3mc], [1.6.0], [[email protected]])
88

99
dnl This is the version tested with, might work with earlier ones.
1010
AC_PREREQ([2.69])

readme.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ The code was mainly developed under Windows, but was tested under Linux as well.
1010

1111
## Version history
1212

13+
* 1.6.0 - *February 2023*
14+
- Based on SQLite version 3.41.0
15+
- Added automatic VFS shim instantiation (see issue #104)
16+
- Added CMake build support (thanks to @lwttai and @jammerxd)
1317
* 1.5.5 - *December 2022*
1418
- Based on SQLite version 3.40.1
1519
* 1.5.4 - *November 2022*

scripts/patchsqlite3.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,9 @@ die() {
1717
# 1) Intercept VFS pragma handling
1818
# 2) Add handling of KEY parameter in ATTACH statements
1919
sed 's/sqlite3_file_control\(.*SQLITE_FCNTL_PRAGMA\)/sqlite3mcFileControlPragma\1/' "$INPUT" \
20-
| sed '/\#endif \/\* SQLITE3\_H \*\//a \ \n\/\* Function prototypes of SQLite3 Multiple Ciphers \*\/\nSQLITE_PRIVATE int sqlite3mcFileControlPragma(sqlite3*, const char*, int, void*);\nSQLITE_PRIVATE int sqlite3mcHandleAttachKey(sqlite3*, const char*, const char*, sqlite3_value*, char**);\nSQLITE_PRIVATE int sqlite3mcHandleMainKey(sqlite3*, const char*);\ntypedef struct PgHdr PgHdrMC;\nSQLITE_PRIVATE void* sqlite3mcPagerCodec(PgHdrMC* pPg);' \
20+
| sed '/\#endif \/\* SQLITE3\_H \*\//a \ \n\/\* Function prototypes of SQLite3 Multiple Ciphers \*\/\nSQLITE_PRIVATE int sqlite3mcCheckVfs(const char*);\nSQLITE_PRIVATE int sqlite3mcFileControlPragma(sqlite3*, const char*, int, void*);\nSQLITE_PRIVATE int sqlite3mcHandleAttachKey(sqlite3*, const char*, const char*, sqlite3_value*, char**);\nSQLITE_PRIVATE int sqlite3mcHandleMainKey(sqlite3*, const char*);\ntypedef struct PgHdr PgHdrMC;\nSQLITE_PRIVATE void* sqlite3mcPagerCodec(PgHdrMC* pPg);' \
2121
| sed '/pData = pPage->pData;/c \ if( (pData = sqlite3mcPagerCodec(pPage))==0 ) return SQLITE_NOMEM_BKPT;' \
2222
| sed '/pData = p->pData;/c \ if( (pData = sqlite3mcPagerCodec(p))==0 ) return SQLITE_NOMEM;' \
2323
| sed '/sqlite3_free_filename( zPath );/i \\n \/\* Handle KEY parameter. \*\/\n if( rc==SQLITE_OK ){\n rc = sqlite3mcHandleAttachKey(db, zName, zPath, argv[2], &zErrDyn);\n }' \
24+
| sed '/\*ppVfs = sqlite3_vfs_find(zVfs);/i \ \/\* Check VFS. \*\/\n sqlite3mcCheckVfs(zVfs);\n' \
2425
| sed '/sqlite3_free_filename(zOpen);/i \\n \/\* Handle encryption related URI parameters. \*\/\n if( rc==SQLITE_OK ){\n rc = sqlite3mcHandleMainKey(db, zOpen);\n }'

src/carray.c

Lines changed: 41 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
**
2929
** There is an optional third parameter to determine the datatype of
3030
** the C-language array. Allowed values of the third parameter are
31-
** 'int32', 'int64', 'double', 'char*'. Example:
31+
** 'int32', 'int64', 'double', 'char*', 'struct iovec'. Example:
3232
**
3333
** SELECT * FROM carray($ptr,10,'char*');
3434
**
@@ -56,6 +56,14 @@
5656
SQLITE_EXTENSION_INIT1
5757
#include <assert.h>
5858
#include <string.h>
59+
#ifdef _WIN32
60+
struct iovec {
61+
void *iov_base;
62+
size_t iov_len;
63+
};
64+
#else
65+
# include <sys/uio.h>
66+
#endif
5967

6068
/* Allowed values for the mFlags parameter to sqlite3_carray_bind().
6169
** Must exactly match the definitions in carray.h.
@@ -65,6 +73,7 @@ SQLITE_EXTENSION_INIT1
6573
# define CARRAY_INT64 1 /* Data is 64-bit signed integers */
6674
# define CARRAY_DOUBLE 2 /* Data is doubles */
6775
# define CARRAY_TEXT 3 /* Data is char* */
76+
# define CARRAY_BLOB 4 /* Data is struct iovec* */
6877
#endif
6978

7079
#ifndef SQLITE_API
@@ -80,7 +89,8 @@ SQLITE_EXTENSION_INIT1
8089
/*
8190
** Names of allowed datatypes
8291
*/
83-
static const char *azType[] = { "int32", "int64", "double", "char*" };
92+
static const char *azType[] = { "int32", "int64", "double", "char*",
93+
"struct iovec" };
8494

8595
/*
8696
** Structure used to hold the sqlite3_carray_bind() information
@@ -224,6 +234,12 @@ static int carrayColumn(
224234
sqlite3_result_text(ctx, p[pCur->iRowid-1], -1, SQLITE_TRANSIENT);
225235
return SQLITE_OK;
226236
}
237+
case CARRAY_BLOB: {
238+
const struct iovec *p = (struct iovec*)pCur->pPtr;
239+
sqlite3_result_blob(ctx, p[pCur->iRowid-1].iov_base,
240+
(int)p[pCur->iRowid-1].iov_len, SQLITE_TRANSIENT);
241+
return SQLITE_OK;
242+
}
227243
}
228244
}
229245
}
@@ -268,7 +284,7 @@ static int carrayFilter(
268284
if( pBind==0 ) break;
269285
pCur->pPtr = pBind->aData;
270286
pCur->iCnt = pBind->nData;
271-
pCur->eType = pBind->mFlags & 0x03;
287+
pCur->eType = pBind->mFlags & 0x07;
272288
break;
273289
}
274290
case 2:
@@ -431,24 +447,29 @@ SQLITE_API int sqlite3_carray_bind(
431447
pNew->mFlags = mFlags;
432448
if( xDestroy==SQLITE_TRANSIENT ){
433449
sqlite3_int64 sz = nData;
434-
switch( mFlags & 0x03 ){
435-
case CARRAY_INT32: sz *= 4; break;
436-
case CARRAY_INT64: sz *= 8; break;
437-
case CARRAY_DOUBLE: sz *= 8; break;
438-
case CARRAY_TEXT: sz *= sizeof(char*); break;
450+
switch( mFlags & 0x07 ){
451+
case CARRAY_INT32: sz *= 4; break;
452+
case CARRAY_INT64: sz *= 8; break;
453+
case CARRAY_DOUBLE: sz *= 8; break;
454+
case CARRAY_TEXT: sz *= sizeof(char*); break;
455+
case CARRAY_BLOB: sz *= sizeof(struct iovec); break;
439456
}
440-
if( (mFlags & 0x03)==CARRAY_TEXT ){
457+
if( (mFlags & 0x07)==CARRAY_TEXT ){
441458
for(i=0; i<nData; i++){
442459
const char *z = ((char**)aData)[i];
443460
if( z ) sz += strlen(z) + 1;
444461
}
462+
}else if( (mFlags & 0x07)==CARRAY_BLOB ){
463+
for(i=0; i<nData; i++){
464+
sz += ((struct iovec*)aData)[i].iov_len;
465+
}
445466
}
446467
pNew->aData = sqlite3_malloc64( sz );
447468
if( pNew->aData==0 ){
448469
sqlite3_free(pNew);
449470
return SQLITE_NOMEM;
450471
}
451-
if( (mFlags & 0x03)==CARRAY_TEXT ){
472+
if( (mFlags & 0x07)==CARRAY_TEXT ){
452473
char **az = (char**)pNew->aData;
453474
char *z = (char*)&az[nData];
454475
for(i=0; i<nData; i++){
@@ -463,6 +484,16 @@ SQLITE_API int sqlite3_carray_bind(
463484
memcpy(z, zData, n+1);
464485
z += n+1;
465486
}
487+
}else if( (mFlags & 0x07)==CARRAY_BLOB ){
488+
struct iovec *p = (struct iovec*)pNew->aData;
489+
unsigned char *z = (unsigned char*)&p[nData];
490+
for(i=0; i<nData; i++){
491+
size_t n = ((struct iovec*)aData)[i].iov_len;
492+
p[i].iov_len = n;
493+
p[i].iov_base = z;
494+
z += n;
495+
memcpy(p[i].iov_base, ((struct iovec*)aData)[i].iov_base, n);
496+
}
466497
}else{
467498
memcpy(pNew->aData, aData, sz);
468499
}

src/carray.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@ SQLITE_API int sqlite3_carray_bind(
4141
#define CARRAY_INT64 1 /* Data is 64-bit signed integers */
4242
#define CARRAY_DOUBLE 2 /* Data is doubles */
4343
#define CARRAY_TEXT 3 /* Data is char* */
44+
#define CARRAY_BLOB 4 /* Data is struct iovec */
4445

4546
#ifdef __cplusplus
4647
} /* end of the 'extern "C"' block */
4748
#endif
4849

4950
#endif /* ifndef _CARRAY_H */
50-

src/cipher_config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
** Purpose: Configuration of SQLite codecs
44
** Author: Ulrich Telle
55
** Created: 2020-03-02
6-
** Copyright: (c) 2006-2022 Ulrich Telle
6+
** Copyright: (c) 2006-2023 Ulrich Telle
77
** License: MIT
88
*/
99

src/regexp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,7 @@ static void re_bytecode_func(
803803
int i;
804804
int n;
805805
char *z;
806+
(void)argc;
806807

807808
zPattern = (const char*)sqlite3_value_text(argv[0]);
808809
if( zPattern==0 ) return;

src/rekeyvacuum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
** Change 4: Call sqlite3mcBtreeSetPageSize instead of sqlite3BtreeSetPageSize for main database
2828
** (sqlite3mcBtreeSetPageSize allows to reduce the number of reserved bytes)
2929
**
30-
** This code is generated by the script rekeyvacuum.sh from SQLite version 3.40.1 amalgamation.
30+
** This code is generated by the script rekeyvacuum.sh from SQLite version 3.41.0 amalgamation.
3131
*/
3232
SQLITE_PRIVATE SQLITE_NOINLINE int sqlite3mcRunVacuumForRekey(
3333
char **pzErrMsg, /* Write error message here */

src/shathree.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ static void sha3Func(
531531
/* Compute a string using sqlite3_vsnprintf() with a maximum length
532532
** of 50 bytes and add it to the hash.
533533
*/
534-
static void hash_step_vformat(
534+
static void sha3_step_vformat(
535535
SHA3Context *p, /* Add content to this context */
536536
const char *zFormat,
537537
...
@@ -627,7 +627,7 @@ static void sha3QueryFunc(
627627
z = sqlite3_sql(pStmt);
628628
if( z ){
629629
n = (int)strlen(z);
630-
hash_step_vformat(&cx,"S%d:",n);
630+
sha3_step_vformat(&cx,"S%d:",n);
631631
SHA3Update(&cx,(unsigned char*)z,n);
632632
}
633633

@@ -671,14 +671,14 @@ static void sha3QueryFunc(
671671
case SQLITE_TEXT: {
672672
int n2 = sqlite3_column_bytes(pStmt, i);
673673
const unsigned char *z2 = sqlite3_column_text(pStmt, i);
674-
hash_step_vformat(&cx,"T%d:",n2);
674+
sha3_step_vformat(&cx,"T%d:",n2);
675675
SHA3Update(&cx, z2, n2);
676676
break;
677677
}
678678
case SQLITE_BLOB: {
679679
int n2 = sqlite3_column_bytes(pStmt, i);
680680
const unsigned char *z2 = sqlite3_column_blob(pStmt, i);
681-
hash_step_vformat(&cx,"B%d:",n2);
681+
sha3_step_vformat(&cx,"B%d:",n2);
682682
SHA3Update(&cx, z2, n2);
683683
break;
684684
}

0 commit comments

Comments
 (0)