Fossil SCM

Update the built-in SQLite to the latest 3.27.0 beta for testing.

drh 2019-02-05 20:54 trunk
Commit 1dbf923cbee25c6a1246dc406f5e03ed742d7515632598f2ab96b7df9f663317
3 files changed +87 -1 +225 -131 +3 -1
+87 -1
--- src/shell.c
+++ src/shell.c
@@ -4167,11 +4167,12 @@
41674167
memtraceFree,
41684168
memtraceRealloc,
41694169
memtraceSize,
41704170
memtraceRoundup,
41714171
memtraceInit,
4172
- memtraceShutdown
4172
+ memtraceShutdown,
4173
+ 0
41734174
};
41744175
41754176
/* Begin tracing memory allocations to out. */
41764177
int sqlite3MemTraceActivate(FILE *out){
41774178
int rc = SQLITE_OK;
@@ -8708,10 +8709,13 @@
87088709
int cMode; /* temporary output mode for the current query */
87098710
int normalMode; /* Output mode before ".explain on" */
87108711
int writableSchema; /* True if PRAGMA writable_schema=ON */
87118712
int showHeader; /* True to show column names in List or Column mode */
87128713
int nCheck; /* Number of ".check" commands run */
8714
+ unsigned nProgress; /* Number of progress callbacks encountered */
8715
+ unsigned mxProgress; /* Maximum progress callbacks before failing */
8716
+ unsigned flgProgress; /* Flags for the progress callback */
87138717
unsigned shellFlgs; /* Various flags */
87148718
sqlite3_int64 szMax; /* --maxsize argument to .open */
87158719
char *zDestTable; /* Name of destination table when MODE_Insert */
87168720
char *zTempFile; /* Temporary file that might need deleting */
87178721
char zTestcase[30]; /* Name of current test case */
@@ -8762,10 +8766,17 @@
87628766
*/
87638767
#define SHELL_TRACE_PLAIN 0 /* Show input SQL text */
87648768
#define SHELL_TRACE_EXPANDED 1 /* Show expanded SQL text */
87658769
#define SHELL_TRACE_NORMALIZED 2 /* Show normalized SQL text */
87668770
8771
+/* Bits in the ShellState.flgProgress variable */
8772
+#define SHELL_PROGRESS_QUIET 0x01 /* Omit announcing every progress callback */
8773
+#define SHELL_PROGRESS_RESET 0x02 /* Reset the count when the progres
8774
+ ** callback limit is reached, and for each
8775
+ ** top-level SQL statement */
8776
+#define SHELL_PROGRESS_ONCE 0x04 /* Cancel the --limit after firing once */
8777
+
87678778
/*
87688779
** These are the allowed shellFlgs values
87698780
*/
87708781
#define SHFLG_Pagecache 0x00000001 /* The --pagecache option is used */
87718782
#define SHFLG_Lookaside 0x00000002 /* Lookaside memory is used */
@@ -9462,10 +9473,30 @@
94629473
eqp_render_level(p, 0);
94639474
eqp_reset(p);
94649475
}
94659476
}
94669477
9478
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
9479
+/*
9480
+** Progress handler callback.
9481
+*/
9482
+static int progress_handler(void *pClientData) {
9483
+ ShellState *p = (ShellState*)pClientData;
9484
+ p->nProgress++;
9485
+ if( p->nProgress>=p->mxProgress && p->mxProgress>0 ){
9486
+ raw_printf(p->out, "Progress limit reached (%u)\n", p->nProgress);
9487
+ if( p->flgProgress & SHELL_PROGRESS_RESET ) p->nProgress = 0;
9488
+ if( p->flgProgress & SHELL_PROGRESS_ONCE ) p->mxProgress = 0;
9489
+ return 1;
9490
+ }
9491
+ if( (p->flgProgress & SHELL_PROGRESS_QUIET)==0 ){
9492
+ raw_printf(p->out, "Progress %u\n", p->nProgress);
9493
+ }
9494
+ return 0;
9495
+}
9496
+#endif /* SQLITE_OMIT_PROGRESS_CALLBACK */
9497
+
94679498
/*
94689499
** This is the callback routine that the shell
94699500
** invokes for each row of a query result.
94709501
*/
94719502
static int shell_callback(
@@ -11148,10 +11179,17 @@
1114811179
" --readonly Open FILE readonly",
1114911180
" --zip FILE is a ZIP archive",
1115011181
".output ?FILE? Send output to FILE or stdout if FILE is omitted",
1115111182
" If FILE begins with '|' then open it as a pipe.",
1115211183
".print STRING... Print literal STRING",
11184
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
11185
+ ".progress N Invoke progress handler after every N opcodes",
11186
+ " --limit N Interrupt after N progress callbacks",
11187
+ " --once Do no more than one progress interrupt",
11188
+ " --quiet|-q No output except at interrupts",
11189
+ " --reset Reset the count for each input and interrupt",
11190
+#endif
1115311191
".prompt MAIN CONTINUE Replace the standard prompts",
1115411192
".quit Exit this program",
1115511193
".read FILE Read input from FILE",
1115611194
".restore ?DB? FILE Restore content of DB (default \"main\") from FILE",
1115711195
".save FILE Write in-memory database into FILE",
@@ -14680,10 +14718,56 @@
1468014718
utf8_printf(p->out, "%s", azArg[i]);
1468114719
}
1468214720
raw_printf(p->out, "\n");
1468314721
}else
1468414722
14723
+#ifndef SQLITE_OMIT_PROGRESS_CALLBACK
14724
+ if( c=='p' && n>=3 && strncmp(azArg[0], "progress", n)==0 ){
14725
+ int i;
14726
+ int nn = 0;
14727
+ p->flgProgress = 0;
14728
+ p->mxProgress = 0;
14729
+ p->nProgress = 0;
14730
+ for(i=1; i<nArg; i++){
14731
+ const char *z = azArg[i];
14732
+ if( z[0]=='-' ){
14733
+ z++;
14734
+ if( z[0]=='-' ) z++;
14735
+ if( strcmp(z,"quiet")==0 || strcmp(z,"q")==0 ){
14736
+ p->flgProgress |= SHELL_PROGRESS_QUIET;
14737
+ continue;
14738
+ }
14739
+ if( strcmp(z,"reset")==0 ){
14740
+ p->flgProgress |= SHELL_PROGRESS_RESET;
14741
+ continue;
14742
+ }
14743
+ if( strcmp(z,"once")==0 ){
14744
+ p->flgProgress |= SHELL_PROGRESS_ONCE;
14745
+ continue;
14746
+ }
14747
+ if( strcmp(z,"limit")==0 ){
14748
+ if( i+1>=nArg ){
14749
+ utf8_printf(stderr, "Error: missing argument on --limit\n");
14750
+ rc = 1;
14751
+ goto meta_command_exit;
14752
+ }else{
14753
+ p->mxProgress = (int)integerValue(azArg[++i]);
14754
+ }
14755
+ continue;
14756
+ }
14757
+ utf8_printf(stderr, "Error: unknown option: \"%s\"\n", azArg[i]);
14758
+ rc = 1;
14759
+ goto meta_command_exit;
14760
+ }else{
14761
+ nn = (int)integerValue(z);
14762
+ }
14763
+ }
14764
+ open_db(p, 0);
14765
+ sqlite3_progress_handler(p->db, nn, progress_handler, p);
14766
+ }else
14767
+#endif /* SQLITE_OMIT_PROGRESS_CALLBACK */
14768
+
1468514769
if( c=='p' && strncmp(azArg[0], "prompt", n)==0 ){
1468614770
if( nArg >= 2) {
1468714771
strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);
1468814772
}
1468914773
if( nArg >= 3) {
@@ -16015,10 +16099,11 @@
1601516099
int rc;
1601616100
char *zErrMsg = 0;
1601716101
1601816102
open_db(p, 0);
1601916103
if( ShellHasFlag(p,SHFLG_Backslash) ) resolve_backslashes(zSql);
16104
+ if( p->flgProgress & SHELL_PROGRESS_RESET ) p->nProgress = 0;
1602016105
BEGIN_TIMER;
1602116106
rc = shell_exec(p, zSql, &zErrMsg);
1602216107
END_TIMER;
1602316108
if( rc || zErrMsg ){
1602416109
char zPrefix[100];
@@ -16277,10 +16362,11 @@
1627716362
" -list set output mode to 'list'\n"
1627816363
" -lookaside SIZE N use N entries of SZ bytes for lookaside memory\n"
1627916364
#if defined(SQLITE_ENABLE_DESERIALIZE)
1628016365
" -maxsize N maximum size for a --deserialize database\n"
1628116366
#endif
16367
+ " -memtrace trace all memory allocations and deallocations\n"
1628216368
" -mmap N default mmap size set to N\n"
1628316369
#ifdef SQLITE_ENABLE_MULTIPLEX
1628416370
" -multiplex enable the multiplexor VFS\n"
1628516371
#endif
1628616372
" -newline SEP set output row separator. Default: '\\n'\n"
1628716373
--- src/shell.c
+++ src/shell.c
@@ -4167,11 +4167,12 @@
4167 memtraceFree,
4168 memtraceRealloc,
4169 memtraceSize,
4170 memtraceRoundup,
4171 memtraceInit,
4172 memtraceShutdown
 
4173 };
4174
4175 /* Begin tracing memory allocations to out. */
4176 int sqlite3MemTraceActivate(FILE *out){
4177 int rc = SQLITE_OK;
@@ -8708,10 +8709,13 @@
8708 int cMode; /* temporary output mode for the current query */
8709 int normalMode; /* Output mode before ".explain on" */
8710 int writableSchema; /* True if PRAGMA writable_schema=ON */
8711 int showHeader; /* True to show column names in List or Column mode */
8712 int nCheck; /* Number of ".check" commands run */
 
 
 
8713 unsigned shellFlgs; /* Various flags */
8714 sqlite3_int64 szMax; /* --maxsize argument to .open */
8715 char *zDestTable; /* Name of destination table when MODE_Insert */
8716 char *zTempFile; /* Temporary file that might need deleting */
8717 char zTestcase[30]; /* Name of current test case */
@@ -8762,10 +8766,17 @@
8762 */
8763 #define SHELL_TRACE_PLAIN 0 /* Show input SQL text */
8764 #define SHELL_TRACE_EXPANDED 1 /* Show expanded SQL text */
8765 #define SHELL_TRACE_NORMALIZED 2 /* Show normalized SQL text */
8766
 
 
 
 
 
 
 
8767 /*
8768 ** These are the allowed shellFlgs values
8769 */
8770 #define SHFLG_Pagecache 0x00000001 /* The --pagecache option is used */
8771 #define SHFLG_Lookaside 0x00000002 /* Lookaside memory is used */
@@ -9462,10 +9473,30 @@
9462 eqp_render_level(p, 0);
9463 eqp_reset(p);
9464 }
9465 }
9466
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9467 /*
9468 ** This is the callback routine that the shell
9469 ** invokes for each row of a query result.
9470 */
9471 static int shell_callback(
@@ -11148,10 +11179,17 @@
11148 " --readonly Open FILE readonly",
11149 " --zip FILE is a ZIP archive",
11150 ".output ?FILE? Send output to FILE or stdout if FILE is omitted",
11151 " If FILE begins with '|' then open it as a pipe.",
11152 ".print STRING... Print literal STRING",
 
 
 
 
 
 
 
11153 ".prompt MAIN CONTINUE Replace the standard prompts",
11154 ".quit Exit this program",
11155 ".read FILE Read input from FILE",
11156 ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE",
11157 ".save FILE Write in-memory database into FILE",
@@ -14680,10 +14718,56 @@
14680 utf8_printf(p->out, "%s", azArg[i]);
14681 }
14682 raw_printf(p->out, "\n");
14683 }else
14684
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14685 if( c=='p' && strncmp(azArg[0], "prompt", n)==0 ){
14686 if( nArg >= 2) {
14687 strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);
14688 }
14689 if( nArg >= 3) {
@@ -16015,10 +16099,11 @@
16015 int rc;
16016 char *zErrMsg = 0;
16017
16018 open_db(p, 0);
16019 if( ShellHasFlag(p,SHFLG_Backslash) ) resolve_backslashes(zSql);
 
16020 BEGIN_TIMER;
16021 rc = shell_exec(p, zSql, &zErrMsg);
16022 END_TIMER;
16023 if( rc || zErrMsg ){
16024 char zPrefix[100];
@@ -16277,10 +16362,11 @@
16277 " -list set output mode to 'list'\n"
16278 " -lookaside SIZE N use N entries of SZ bytes for lookaside memory\n"
16279 #if defined(SQLITE_ENABLE_DESERIALIZE)
16280 " -maxsize N maximum size for a --deserialize database\n"
16281 #endif
 
16282 " -mmap N default mmap size set to N\n"
16283 #ifdef SQLITE_ENABLE_MULTIPLEX
16284 " -multiplex enable the multiplexor VFS\n"
16285 #endif
16286 " -newline SEP set output row separator. Default: '\\n'\n"
16287
--- src/shell.c
+++ src/shell.c
@@ -4167,11 +4167,12 @@
4167 memtraceFree,
4168 memtraceRealloc,
4169 memtraceSize,
4170 memtraceRoundup,
4171 memtraceInit,
4172 memtraceShutdown,
4173 0
4174 };
4175
4176 /* Begin tracing memory allocations to out. */
4177 int sqlite3MemTraceActivate(FILE *out){
4178 int rc = SQLITE_OK;
@@ -8708,10 +8709,13 @@
8709 int cMode; /* temporary output mode for the current query */
8710 int normalMode; /* Output mode before ".explain on" */
8711 int writableSchema; /* True if PRAGMA writable_schema=ON */
8712 int showHeader; /* True to show column names in List or Column mode */
8713 int nCheck; /* Number of ".check" commands run */
8714 unsigned nProgress; /* Number of progress callbacks encountered */
8715 unsigned mxProgress; /* Maximum progress callbacks before failing */
8716 unsigned flgProgress; /* Flags for the progress callback */
8717 unsigned shellFlgs; /* Various flags */
8718 sqlite3_int64 szMax; /* --maxsize argument to .open */
8719 char *zDestTable; /* Name of destination table when MODE_Insert */
8720 char *zTempFile; /* Temporary file that might need deleting */
8721 char zTestcase[30]; /* Name of current test case */
@@ -8762,10 +8766,17 @@
8766 */
8767 #define SHELL_TRACE_PLAIN 0 /* Show input SQL text */
8768 #define SHELL_TRACE_EXPANDED 1 /* Show expanded SQL text */
8769 #define SHELL_TRACE_NORMALIZED 2 /* Show normalized SQL text */
8770
8771 /* Bits in the ShellState.flgProgress variable */
8772 #define SHELL_PROGRESS_QUIET 0x01 /* Omit announcing every progress callback */
8773 #define SHELL_PROGRESS_RESET 0x02 /* Reset the count when the progres
8774 ** callback limit is reached, and for each
8775 ** top-level SQL statement */
8776 #define SHELL_PROGRESS_ONCE 0x04 /* Cancel the --limit after firing once */
8777
8778 /*
8779 ** These are the allowed shellFlgs values
8780 */
8781 #define SHFLG_Pagecache 0x00000001 /* The --pagecache option is used */
8782 #define SHFLG_Lookaside 0x00000002 /* Lookaside memory is used */
@@ -9462,10 +9473,30 @@
9473 eqp_render_level(p, 0);
9474 eqp_reset(p);
9475 }
9476 }
9477
9478 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
9479 /*
9480 ** Progress handler callback.
9481 */
9482 static int progress_handler(void *pClientData) {
9483 ShellState *p = (ShellState*)pClientData;
9484 p->nProgress++;
9485 if( p->nProgress>=p->mxProgress && p->mxProgress>0 ){
9486 raw_printf(p->out, "Progress limit reached (%u)\n", p->nProgress);
9487 if( p->flgProgress & SHELL_PROGRESS_RESET ) p->nProgress = 0;
9488 if( p->flgProgress & SHELL_PROGRESS_ONCE ) p->mxProgress = 0;
9489 return 1;
9490 }
9491 if( (p->flgProgress & SHELL_PROGRESS_QUIET)==0 ){
9492 raw_printf(p->out, "Progress %u\n", p->nProgress);
9493 }
9494 return 0;
9495 }
9496 #endif /* SQLITE_OMIT_PROGRESS_CALLBACK */
9497
9498 /*
9499 ** This is the callback routine that the shell
9500 ** invokes for each row of a query result.
9501 */
9502 static int shell_callback(
@@ -11148,10 +11179,17 @@
11179 " --readonly Open FILE readonly",
11180 " --zip FILE is a ZIP archive",
11181 ".output ?FILE? Send output to FILE or stdout if FILE is omitted",
11182 " If FILE begins with '|' then open it as a pipe.",
11183 ".print STRING... Print literal STRING",
11184 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
11185 ".progress N Invoke progress handler after every N opcodes",
11186 " --limit N Interrupt after N progress callbacks",
11187 " --once Do no more than one progress interrupt",
11188 " --quiet|-q No output except at interrupts",
11189 " --reset Reset the count for each input and interrupt",
11190 #endif
11191 ".prompt MAIN CONTINUE Replace the standard prompts",
11192 ".quit Exit this program",
11193 ".read FILE Read input from FILE",
11194 ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE",
11195 ".save FILE Write in-memory database into FILE",
@@ -14680,10 +14718,56 @@
14718 utf8_printf(p->out, "%s", azArg[i]);
14719 }
14720 raw_printf(p->out, "\n");
14721 }else
14722
14723 #ifndef SQLITE_OMIT_PROGRESS_CALLBACK
14724 if( c=='p' && n>=3 && strncmp(azArg[0], "progress", n)==0 ){
14725 int i;
14726 int nn = 0;
14727 p->flgProgress = 0;
14728 p->mxProgress = 0;
14729 p->nProgress = 0;
14730 for(i=1; i<nArg; i++){
14731 const char *z = azArg[i];
14732 if( z[0]=='-' ){
14733 z++;
14734 if( z[0]=='-' ) z++;
14735 if( strcmp(z,"quiet")==0 || strcmp(z,"q")==0 ){
14736 p->flgProgress |= SHELL_PROGRESS_QUIET;
14737 continue;
14738 }
14739 if( strcmp(z,"reset")==0 ){
14740 p->flgProgress |= SHELL_PROGRESS_RESET;
14741 continue;
14742 }
14743 if( strcmp(z,"once")==0 ){
14744 p->flgProgress |= SHELL_PROGRESS_ONCE;
14745 continue;
14746 }
14747 if( strcmp(z,"limit")==0 ){
14748 if( i+1>=nArg ){
14749 utf8_printf(stderr, "Error: missing argument on --limit\n");
14750 rc = 1;
14751 goto meta_command_exit;
14752 }else{
14753 p->mxProgress = (int)integerValue(azArg[++i]);
14754 }
14755 continue;
14756 }
14757 utf8_printf(stderr, "Error: unknown option: \"%s\"\n", azArg[i]);
14758 rc = 1;
14759 goto meta_command_exit;
14760 }else{
14761 nn = (int)integerValue(z);
14762 }
14763 }
14764 open_db(p, 0);
14765 sqlite3_progress_handler(p->db, nn, progress_handler, p);
14766 }else
14767 #endif /* SQLITE_OMIT_PROGRESS_CALLBACK */
14768
14769 if( c=='p' && strncmp(azArg[0], "prompt", n)==0 ){
14770 if( nArg >= 2) {
14771 strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);
14772 }
14773 if( nArg >= 3) {
@@ -16015,10 +16099,11 @@
16099 int rc;
16100 char *zErrMsg = 0;
16101
16102 open_db(p, 0);
16103 if( ShellHasFlag(p,SHFLG_Backslash) ) resolve_backslashes(zSql);
16104 if( p->flgProgress & SHELL_PROGRESS_RESET ) p->nProgress = 0;
16105 BEGIN_TIMER;
16106 rc = shell_exec(p, zSql, &zErrMsg);
16107 END_TIMER;
16108 if( rc || zErrMsg ){
16109 char zPrefix[100];
@@ -16277,10 +16362,11 @@
16362 " -list set output mode to 'list'\n"
16363 " -lookaside SIZE N use N entries of SZ bytes for lookaside memory\n"
16364 #if defined(SQLITE_ENABLE_DESERIALIZE)
16365 " -maxsize N maximum size for a --deserialize database\n"
16366 #endif
16367 " -memtrace trace all memory allocations and deallocations\n"
16368 " -mmap N default mmap size set to N\n"
16369 #ifdef SQLITE_ENABLE_MULTIPLEX
16370 " -multiplex enable the multiplexor VFS\n"
16371 #endif
16372 " -newline SEP set output row separator. Default: '\\n'\n"
16373
+225 -131
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1162,11 +1162,11 @@
11621162
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11631163
** [sqlite_version()] and [sqlite_source_id()].
11641164
*/
11651165
#define SQLITE_VERSION "3.27.0"
11661166
#define SQLITE_VERSION_NUMBER 3027000
1167
-#define SQLITE_SOURCE_ID "2019-02-01 15:06:27 4ca9d5d53d41d08fbce29f9da8cc0948df9c4c3136210af88b499cf889b5ccb8"
1167
+#define SQLITE_SOURCE_ID "2019-02-05 20:51:41 4d0a949fd92e19fbf243a2e3a1a7c2cdb111f9a6943949d2420dd846bc7d9285"
11681168
11691169
/*
11701170
** CAPI3REF: Run-Time Library Version Numbers
11711171
** KEYWORDS: sqlite3_version sqlite3_sourceid
11721172
**
@@ -4466,10 +4466,12 @@
44664466
** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and
44674467
** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
44684468
** is not a database file pathname pointer that SQLite passed into the xOpen
44694469
** VFS method, then the behavior of this routine is undefined and probably
44704470
** undesirable.
4471
+**
4472
+** See the [URI filename] documentation for additional information.
44714473
*/
44724474
SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
44734475
SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
44744476
SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
44754477
@@ -14556,10 +14558,11 @@
1455614558
SQLITE_PRIVATE i64 sqlite3BtreeOffset(BtCursor*);
1455714559
#endif
1455814560
SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);
1455914561
SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
1456014562
SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
14563
+SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor*);
1456114564
1456214565
SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
1456314566
SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
1456414567
SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*);
1456514568
@@ -18772,10 +18775,15 @@
1877218775
SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*);
1877318776
SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*);
1877418777
SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
1877518778
SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*,
1877618779
sqlite3_vfs**,char**,char **);
18780
+#ifdef SQLITE_HAS_CODEC
18781
+SQLITE_PRIVATE int sqlite3CodecQueryParameters(sqlite3*,const char*,const char*);
18782
+#else
18783
+# define sqlite3CodecQueryParameters(A,B,C) 0
18784
+#endif
1877718785
SQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3*,const char*);
1877818786
1877918787
#ifdef SQLITE_UNTESTABLE
1878018788
# define sqlite3FaultSim(X) SQLITE_OK
1878118789
#else
@@ -27323,10 +27331,31 @@
2732327331
static char *getTextArg(PrintfArguments *p){
2732427332
if( p->nArg<=p->nUsed ) return 0;
2732527333
return (char*)sqlite3_value_text(p->apArg[p->nUsed++]);
2732627334
}
2732727335
27336
+/*
27337
+** Allocate memory for a temporary buffer needed for printf rendering.
27338
+**
27339
+** If the requested size of the temp buffer is larger than the size
27340
+** of the output buffer in pAccum, then cause an SQLITE_TOOBIG error.
27341
+** Do the size check before the memory allocation to prevent rogue
27342
+** SQL from requesting large allocations using the precision or width
27343
+** field of the printf() function.
27344
+*/
27345
+static char *printfTempBuf(sqlite3_str *pAccum, sqlite3_int64 n){
27346
+ char *z;
27347
+ if( n>pAccum->nAlloc && n>pAccum->mxAlloc ){
27348
+ setStrAccumError(pAccum, SQLITE_TOOBIG);
27349
+ return 0;
27350
+ }
27351
+ z = sqlite3DbMallocRaw(pAccum->db, n);
27352
+ if( z==0 ){
27353
+ setStrAccumError(pAccum, SQLITE_NOMEM);
27354
+ }
27355
+ return z;
27356
+}
2732827357
2732927358
/*
2733027359
** On machines with a small stack size, you can redefine the
2733127360
** SQLITE_PRINT_BUF_SIZE to be something smaller, if desired.
2733227361
*/
@@ -27405,10 +27434,13 @@
2740527434
}
2740627435
/* Find out what flags are present */
2740727436
flag_leftjustify = flag_prefix = cThousand =
2740827437
flag_alternateform = flag_altform2 = flag_zeropad = 0;
2740927438
done = 0;
27439
+ width = 0;
27440
+ flag_long = 0;
27441
+ precision = -1;
2741027442
do{
2741127443
switch( c ){
2741227444
case '-': flag_leftjustify = 1; break;
2741327445
case '+': flag_prefix = '+'; break;
2741427446
case ' ': flag_prefix = ' '; break;
@@ -27415,84 +27447,97 @@
2741527447
case '#': flag_alternateform = 1; break;
2741627448
case '!': flag_altform2 = 1; break;
2741727449
case '0': flag_zeropad = 1; break;
2741827450
case ',': cThousand = ','; break;
2741927451
default: done = 1; break;
27452
+ case 'l': {
27453
+ flag_long = 1;
27454
+ c = *++fmt;
27455
+ if( c=='l' ){
27456
+ c = *++fmt;
27457
+ flag_long = 2;
27458
+ }
27459
+ done = 1;
27460
+ break;
27461
+ }
27462
+ case '1': case '2': case '3': case '4': case '5':
27463
+ case '6': case '7': case '8': case '9': {
27464
+ unsigned wx = c - '0';
27465
+ while( (c = *++fmt)>='0' && c<='9' ){
27466
+ wx = wx*10 + c - '0';
27467
+ }
27468
+ testcase( wx>0x7fffffff );
27469
+ width = wx & 0x7fffffff;
27470
+#ifdef SQLITE_PRINTF_PRECISION_LIMIT
27471
+ if( width>SQLITE_PRINTF_PRECISION_LIMIT ){
27472
+ width = SQLITE_PRINTF_PRECISION_LIMIT;
27473
+ }
27474
+#endif
27475
+ if( c!='.' && c!='l' ){
27476
+ done = 1;
27477
+ }else{
27478
+ fmt--;
27479
+ }
27480
+ break;
27481
+ }
27482
+ case '*': {
27483
+ if( bArgList ){
27484
+ width = (int)getIntArg(pArgList);
27485
+ }else{
27486
+ width = va_arg(ap,int);
27487
+ }
27488
+ if( width<0 ){
27489
+ flag_leftjustify = 1;
27490
+ width = width >= -2147483647 ? -width : 0;
27491
+ }
27492
+#ifdef SQLITE_PRINTF_PRECISION_LIMIT
27493
+ if( width>SQLITE_PRINTF_PRECISION_LIMIT ){
27494
+ width = SQLITE_PRINTF_PRECISION_LIMIT;
27495
+ }
27496
+#endif
27497
+ if( (c = fmt[1])!='.' && c!='l' ){
27498
+ c = *++fmt;
27499
+ done = 1;
27500
+ }
27501
+ break;
27502
+ }
27503
+ case '.': {
27504
+ c = *++fmt;
27505
+ if( c=='*' ){
27506
+ if( bArgList ){
27507
+ precision = (int)getIntArg(pArgList);
27508
+ }else{
27509
+ precision = va_arg(ap,int);
27510
+ }
27511
+ if( precision<0 ){
27512
+ precision = precision >= -2147483647 ? -precision : -1;
27513
+ }
27514
+ c = *++fmt;
27515
+ }else{
27516
+ unsigned px = 0;
27517
+ while( c>='0' && c<='9' ){
27518
+ px = px*10 + c - '0';
27519
+ c = *++fmt;
27520
+ }
27521
+ testcase( px>0x7fffffff );
27522
+ precision = px & 0x7fffffff;
27523
+ }
27524
+#ifdef SQLITE_PRINTF_PRECISION_LIMIT
27525
+ if( precision>SQLITE_PRINTF_PRECISION_LIMIT ){
27526
+ precision = SQLITE_PRINTF_PRECISION_LIMIT;
27527
+ }
27528
+#endif
27529
+ if( c=='l' ){
27530
+ --fmt;
27531
+ }else{
27532
+ done = 1;
27533
+ }
27534
+ break;
27535
+ }
2742027536
}
2742127537
}while( !done && (c=(*++fmt))!=0 );
27422
- /* Get the field width */
27423
- if( c=='*' ){
27424
- if( bArgList ){
27425
- width = (int)getIntArg(pArgList);
27426
- }else{
27427
- width = va_arg(ap,int);
27428
- }
27429
- if( width<0 ){
27430
- flag_leftjustify = 1;
27431
- width = width >= -2147483647 ? -width : 0;
27432
- }
27433
- c = *++fmt;
27434
- }else{
27435
- unsigned wx = 0;
27436
- while( c>='0' && c<='9' ){
27437
- wx = wx*10 + c - '0';
27438
- c = *++fmt;
27439
- }
27440
- testcase( wx>0x7fffffff );
27441
- width = wx & 0x7fffffff;
27442
- }
27443
- assert( width>=0 );
27444
-#ifdef SQLITE_PRINTF_PRECISION_LIMIT
27445
- if( width>SQLITE_PRINTF_PRECISION_LIMIT ){
27446
- width = SQLITE_PRINTF_PRECISION_LIMIT;
27447
- }
27448
-#endif
27449
-
27450
- /* Get the precision */
27451
- if( c=='.' ){
27452
- c = *++fmt;
27453
- if( c=='*' ){
27454
- if( bArgList ){
27455
- precision = (int)getIntArg(pArgList);
27456
- }else{
27457
- precision = va_arg(ap,int);
27458
- }
27459
- c = *++fmt;
27460
- if( precision<0 ){
27461
- precision = precision >= -2147483647 ? -precision : -1;
27462
- }
27463
- }else{
27464
- unsigned px = 0;
27465
- while( c>='0' && c<='9' ){
27466
- px = px*10 + c - '0';
27467
- c = *++fmt;
27468
- }
27469
- testcase( px>0x7fffffff );
27470
- precision = px & 0x7fffffff;
27471
- }
27472
- }else{
27473
- precision = -1;
27474
- }
27475
- assert( precision>=(-1) );
27476
-#ifdef SQLITE_PRINTF_PRECISION_LIMIT
27477
- if( precision>SQLITE_PRINTF_PRECISION_LIMIT ){
27478
- precision = SQLITE_PRINTF_PRECISION_LIMIT;
27479
- }
27480
-#endif
27481
-
27482
-
27483
- /* Get the conversion type modifier */
27484
- if( c=='l' ){
27485
- flag_long = 1;
27486
- c = *++fmt;
27487
- if( c=='l' ){
27488
- flag_long = 2;
27489
- c = *++fmt;
27490
- }
27491
- }else{
27492
- flag_long = 0;
27493
- }
27538
+
2749427539
/* Fetch the info entry for the field */
2749527540
infop = &fmtinfo[0];
2749627541
xtype = etINVALID;
2749727542
for(idx=0; idx<ArraySize(fmtinfo); idx++){
2749827543
if( c==fmtinfo[idx].fmttype ){
@@ -27573,16 +27618,15 @@
2757327618
}
2757427619
if( precision<etBUFSIZE-10-etBUFSIZE/3 ){
2757527620
nOut = etBUFSIZE;
2757627621
zOut = buf;
2757727622
}else{
27578
- u64 n = (u64)precision + 10 + precision/3;
27579
- zOut = zExtra = sqlite3Malloc( n );
27580
- if( zOut==0 ){
27581
- setStrAccumError(pAccum, SQLITE_NOMEM);
27582
- return;
27583
- }
27623
+ u64 n;
27624
+ n = (u64)precision + 10;
27625
+ if( cThousand ) n += precision/3;
27626
+ zOut = zExtra = printfTempBuf(pAccum, n);
27627
+ if( zOut==0 ) return;
2758427628
nOut = (int)n;
2758527629
}
2758627630
bufpt = &zOut[nOut-1];
2758727631
if( xtype==etORDINAL ){
2758827632
static const char zOrd[] = "thstndrd";
@@ -27697,16 +27741,16 @@
2769727741
if( xtype==etEXP ){
2769827742
e2 = 0;
2769927743
}else{
2770027744
e2 = exp;
2770127745
}
27702
- if( MAX(e2,0)+(i64)precision+(i64)width > etBUFSIZE - 15 ){
27703
- bufpt = zExtra
27704
- = sqlite3Malloc( MAX(e2,0)+(i64)precision+(i64)width+15 );
27705
- if( bufpt==0 ){
27706
- setStrAccumError(pAccum, SQLITE_NOMEM);
27707
- return;
27746
+ {
27747
+ i64 szBufNeeded; /* Size of a temporary buffer needed */
27748
+ szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+15;
27749
+ if( szBufNeeded > etBUFSIZE ){
27750
+ bufpt = zExtra = printfTempBuf(pAccum, szBufNeeded);
27751
+ if( bufpt==0 ) return;
2770827752
}
2770927753
}
2771027754
zOut = bufpt;
2771127755
nsd = 16 + flag_altform2*10;
2771227756
flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
@@ -27926,15 +27970,12 @@
2792627970
}
2792727971
}
2792827972
needQuote = !isnull && xtype==etSQLESCAPE2;
2792927973
n += i + 3;
2793027974
if( n>etBUFSIZE ){
27931
- bufpt = zExtra = sqlite3Malloc( n );
27932
- if( bufpt==0 ){
27933
- setStrAccumError(pAccum, SQLITE_NOMEM);
27934
- return;
27935
- }
27975
+ bufpt = zExtra = printfTempBuf(pAccum, n);
27976
+ if( bufpt==0 ) return;
2793627977
}else{
2793727978
bufpt = buf;
2793827979
}
2793927980
j = 0;
2794027981
if( needQuote ) bufpt[j++] = q;
@@ -67525,10 +67566,29 @@
6752567566
assert( cursorHoldsMutex(pCur) );
6752667567
assert( pCur->eState==CURSOR_VALID );
6752767568
getCellInfo(pCur);
6752867569
return pCur->info.nPayload;
6752967570
}
67571
+
67572
+/*
67573
+** Return an upper bound on the size of any record for the table
67574
+** that the cursor is pointing into.
67575
+**
67576
+** This is an optimization. Everything will still work if this
67577
+** routine always returns 2147483647 (which is the largest record
67578
+** that SQLite can handle) or more. But returning a smaller value might
67579
+** prevent large memory allocations when trying to interpret a
67580
+** corrupt datrabase.
67581
+**
67582
+** The current implementation merely returns the size of the underlying
67583
+** database file.
67584
+*/
67585
+SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor *pCur){
67586
+ assert( cursorHoldsMutex(pCur) );
67587
+ assert( pCur->eState==CURSOR_VALID );
67588
+ return pCur->pBt->pageSize * (sqlite3_int64)pCur->pBt->nPage;
67589
+}
6753067590
6753167591
/*
6753267592
** Given the page number of an overflow page in the database (parameter
6753367593
** ovfl), this function finds the page number of the next page in the
6753467594
** linked list of overflow pages. If possible, it uses the auto-vacuum
@@ -75268,10 +75328,13 @@
7526875328
u32 amt, /* Number of bytes to return. */
7526975329
Mem *pMem /* OUT: Return data in this Mem structure. */
7527075330
){
7527175331
int rc;
7527275332
pMem->flags = MEM_Null;
75333
+ if( sqlite3BtreeMaxRecordSize(pCur)<offset+amt ){
75334
+ return SQLITE_CORRUPT_BKPT;
75335
+ }
7527375336
if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+1)) ){
7527475337
rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);
7527575338
if( rc==SQLITE_OK ){
7527675339
pMem->z[amt] = 0; /* Overrun area used when reading malformed records */
7527775340
pMem->flags = MEM_Blob;
@@ -101539,18 +101602,20 @@
101539101602
if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune;
101540101603
switch( pExpr->op ){
101541101604
case TK_ISNOT:
101542101605
case TK_NOT:
101543101606
case TK_ISNULL:
101607
+ case TK_NOTNULL:
101544101608
case TK_IS:
101545101609
case TK_OR:
101546101610
case TK_CASE:
101547101611
case TK_IN:
101548101612
case TK_FUNCTION:
101549101613
testcase( pExpr->op==TK_ISNOT );
101550101614
testcase( pExpr->op==TK_NOT );
101551101615
testcase( pExpr->op==TK_ISNULL );
101616
+ testcase( pExpr->op==TK_NOTNULL );
101552101617
testcase( pExpr->op==TK_IS );
101553101618
testcase( pExpr->op==TK_OR );
101554101619
testcase( pExpr->op==TK_CASE );
101555101620
testcase( pExpr->op==TK_IN );
101556101621
testcase( pExpr->op==TK_FUNCTION );
@@ -105763,12 +105828,12 @@
105763105828
return;
105764105829
}
105765105830
assert( pVfs );
105766105831
flags |= SQLITE_OPEN_MAIN_DB;
105767105832
rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
105768
- sqlite3_free( zPath );
105769105833
db->nDb++;
105834
+ pNew->zDbSName = sqlite3DbStrDup(db, zName);
105770105835
}
105771105836
db->noSharedCache = 0;
105772105837
if( rc==SQLITE_CONSTRAINT ){
105773105838
rc = SQLITE_ERROR;
105774105839
zErrDyn = sqlite3MPrintf(db, "database is already attached");
@@ -105792,11 +105857,10 @@
105792105857
PAGER_SYNCHRONOUS_FULL | (db->flags & PAGER_FLAGS_MASK));
105793105858
#endif
105794105859
sqlite3BtreeLeave(pNew->pBt);
105795105860
}
105796105861
pNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;
105797
- if( !REOPEN_AS_MEMDB(db) ) pNew->zDbSName = sqlite3DbStrDup(db, zName);
105798105862
if( rc==SQLITE_OK && pNew->zDbSName==0 ){
105799105863
rc = SQLITE_NOMEM_BKPT;
105800105864
}
105801105865
105802105866
@@ -105820,19 +105884,23 @@
105820105884
zKey = (char *)sqlite3_value_blob(argv[2]);
105821105885
rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
105822105886
break;
105823105887
105824105888
case SQLITE_NULL:
105825
- /* No key specified. Use the key from the main database */
105826
- sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
105827
- if( nKey || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){
105828
- rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
105889
+ /* No key specified. Use the key from URI filename, or if none,
105890
+ ** use the key from the main database. */
105891
+ if( sqlite3CodecQueryParameters(db, zName, zPath)==0 ){
105892
+ sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
105893
+ if( nKey || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){
105894
+ rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
105895
+ }
105829105896
}
105830105897
break;
105831105898
}
105832105899
}
105833105900
#endif
105901
+ sqlite3_free( zPath );
105834105902
105835105903
/* If the file was opened successfully, read the schema for the new database.
105836105904
** If this fails, or if opening the file failed, then close the file and
105837105905
** remove the entry from the db->aDb[] array. i.e. put everything back the
105838105906
** way we found it.
@@ -118594,11 +118662,11 @@
118594118662
if( zSql==0 ) zSql = "";
118595118663
118596118664
sqlite3_mutex_enter(db->mutex);
118597118665
sqlite3Error(db, SQLITE_OK);
118598118666
while( rc==SQLITE_OK && zSql[0] ){
118599
- int nCol;
118667
+ int nCol = 0;
118600118668
char **azVals = 0;
118601118669
118602118670
pStmt = 0;
118603118671
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
118604118672
assert( rc==SQLITE_OK || pStmt==0 );
@@ -118608,13 +118676,11 @@
118608118676
if( !pStmt ){
118609118677
/* this happens for a comment or white-space */
118610118678
zSql = zLeftover;
118611118679
continue;
118612118680
}
118613
-
118614118681
callbackIsInit = 0;
118615
- nCol = sqlite3_column_count(pStmt);
118616118682
118617118683
while( 1 ){
118618118684
int i;
118619118685
rc = sqlite3_step(pStmt);
118620118686
@@ -118621,10 +118687,11 @@
118621118687
/* Invoke the callback function if required */
118622118688
if( xCallback && (SQLITE_ROW==rc ||
118623118689
(SQLITE_DONE==rc && !callbackIsInit
118624118690
&& db->flags&SQLITE_NullCallback)) ){
118625118691
if( !callbackIsInit ){
118692
+ nCol = sqlite3_column_count(pStmt);
118626118693
azCols = sqlite3DbMallocRaw(db, (2*nCol+1)*sizeof(const char*));
118627118694
if( azCols==0 ){
118628118695
goto exec_out;
118629118696
}
118630118697
for(i=0; i<nCol; i++){
@@ -120404,17 +120471,15 @@
120404120471
/* ColNames: */ 0, 0,
120405120472
/* iArg: */ SQLITE_CountRows },
120406120473
#endif
120407120474
#endif
120408120475
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN
120409
-#if !defined(SQLITE_OMIT_DEPRECATED)
120410120476
{/* zName: */ "data_store_directory",
120411120477
/* ePragTyp: */ PragTyp_DATA_STORE_DIRECTORY,
120412120478
/* ePragFlg: */ PragFlg_NoColumns1,
120413120479
/* ColNames: */ 0, 0,
120414120480
/* iArg: */ 0 },
120415
-#endif
120416120481
#endif
120417120482
#if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
120418120483
{/* zName: */ "data_version",
120419120484
/* ePragTyp: */ PragTyp_HEADER_VALUE,
120420120485
/* ePragFlg: */ PragFlg_ReadOnly|PragFlg_Result0,
@@ -120787,19 +120852,15 @@
120787120852
{/* zName: */ "temp_store",
120788120853
/* ePragTyp: */ PragTyp_TEMP_STORE,
120789120854
/* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
120790120855
/* ColNames: */ 0, 0,
120791120856
/* iArg: */ 0 },
120792
-#endif
120793
-#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
120794
-#if !defined(SQLITE_OMIT_DEPRECATED)
120795120857
{/* zName: */ "temp_store_directory",
120796120858
/* ePragTyp: */ PragTyp_TEMP_STORE_DIRECTORY,
120797120859
/* ePragFlg: */ PragFlg_NoColumns1,
120798120860
/* ColNames: */ 0, 0,
120799120861
/* iArg: */ 0 },
120800
-#endif
120801120862
#endif
120802120863
#if defined(SQLITE_HAS_CODEC)
120803120864
{/* zName: */ "textkey",
120804120865
/* ePragTyp: */ PragTyp_KEY,
120805120866
/* ePragFlg: */ 0,
@@ -134945,10 +135006,11 @@
134945135006
for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
134946135007
VTable *pVTab = db->aVTrans[i];
134947135008
const sqlite3_module *pMod = pVTab->pMod->pModule;
134948135009
if( pVTab->pVtab && pMod->iVersion>=2 ){
134949135010
int (*xMethod)(sqlite3_vtab *, int);
135011
+ sqlite3VtabLock(pVTab);
134950135012
switch( op ){
134951135013
case SAVEPOINT_BEGIN:
134952135014
xMethod = pMod->xSavepoint;
134953135015
pVTab->iSavepoint = iSavepoint+1;
134954135016
break;
@@ -134960,10 +135022,11 @@
134960135022
break;
134961135023
}
134962135024
if( xMethod && pVTab->iSavepoint>iSavepoint ){
134963135025
rc = xMethod(pVTab->pVtab, iSavepoint);
134964135026
}
135027
+ sqlite3VtabUnlock(pVTab);
134965135028
}
134966135029
}
134967135030
}
134968135031
return rc;
134969135032
}
@@ -153130,11 +153193,11 @@
153130153193
){
153131153194
sqlite3 *db; /* The database connection */
153132153195
int i; /* Next unread byte of zSql[] */
153133153196
int n; /* length of current token */
153134153197
int tokenType; /* type of current token */
153135
- int prevType; /* Previous non-whitespace token */
153198
+ int prevType = 0; /* Previous non-whitespace token */
153136153199
int nParen; /* Number of nested levels of parentheses */
153137153200
int iStartIN; /* Start of RHS of IN operator in z[] */
153138153201
int nParenAtIN; /* Value of nParent at start of RHS of IN operator */
153139153202
int j; /* Bytes of normalized SQL generated so far */
153140153203
sqlite3_str *pStr; /* The normalized SQL string under construction */
@@ -156574,10 +156637,44 @@
156574156637
*pFlags = flags;
156575156638
*pzFile = zFile;
156576156639
return rc;
156577156640
}
156578156641
156642
+#if defined(SQLITE_HAS_CODEC)
156643
+/*
156644
+** Process URI filename query parameters relevant to the SQLite Encryption
156645
+** Extension. Return true if any of the relevant query parameters are
156646
+** seen and return false if not.
156647
+*/
156648
+SQLITE_PRIVATE int sqlite3CodecQueryParameters(
156649
+ sqlite3 *db, /* Database connection */
156650
+ const char *zDb, /* Which schema is being created/attached */
156651
+ const char *zUri /* URI filename */
156652
+){
156653
+ const char *zKey;
156654
+ if( (zKey = sqlite3_uri_parameter(zUri, "hexkey"))!=0 && zKey[0] ){
156655
+ u8 iByte;
156656
+ int i;
156657
+ char zDecoded[40];
156658
+ for(i=0, iByte=0; i<sizeof(zDecoded)*2 && sqlite3Isxdigit(zKey[i]); i++){
156659
+ iByte = (iByte<<4) + sqlite3HexToInt(zKey[i]);
156660
+ if( (i&1)!=0 ) zDecoded[i/2] = iByte;
156661
+ }
156662
+ sqlite3_key_v2(db, zDb, zDecoded, i/2);
156663
+ return 1;
156664
+ }else if( (zKey = sqlite3_uri_parameter(zUri, "key"))!=0 ){
156665
+ sqlite3_key_v2(db, zDb, zKey, sqlite3Strlen30(zKey));
156666
+ return 1;
156667
+ }else if( (zKey = sqlite3_uri_parameter(zUri, "textkey"))!=0 ){
156668
+ sqlite3_key_v2(db, zDb, zKey, -1);
156669
+ return 1;
156670
+ }else{
156671
+ return 0;
156672
+ }
156673
+}
156674
+#endif
156675
+
156579156676
156580156677
/*
156581156678
** This routine does the work of opening a database on behalf of
156582156679
** sqlite3_open() and sqlite3_open16(). The database filename "zFilename"
156583156680
** is UTF-8 encoded.
@@ -156919,29 +157016,16 @@
156919157016
void *pArg = sqlite3GlobalConfig.pSqllogArg;
156920157017
sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0);
156921157018
}
156922157019
#endif
156923157020
#if defined(SQLITE_HAS_CODEC)
156924
- if( rc==SQLITE_OK ){
156925
- const char *zKey;
156926
- if( (zKey = sqlite3_uri_parameter(zOpen, "hexkey"))!=0 && zKey[0] ){
156927
- u8 iByte;
156928
- int i;
156929
- char zDecoded[40];
156930
- for(i=0, iByte=0; i<sizeof(zDecoded)*2 && sqlite3Isxdigit(zKey[i]); i++){
156931
- iByte = (iByte<<4) + sqlite3HexToInt(zKey[i]);
156932
- if( (i&1)!=0 ) zDecoded[i/2] = iByte;
156933
- }
156934
- sqlite3_key_v2(db, 0, zDecoded, i/2);
156935
- }else if( (zKey = sqlite3_uri_parameter(zOpen, "key"))!=0 ){
156936
- sqlite3_key_v2(db, 0, zKey, sqlite3Strlen30(zKey));
156937
- }
156938
- }
157021
+ if( rc==SQLITE_OK ) sqlite3CodecQueryParameters(db, 0, zOpen);
156939157022
#endif
156940157023
sqlite3_free(zOpen);
156941157024
return rc & 0xff;
156942157025
}
157026
+
156943157027
156944157028
/*
156945157029
** Open a new database handle.
156946157030
*/
156947157031
SQLITE_API int sqlite3_open(
@@ -175558,15 +175642,18 @@
175558175642
assert( rc==SQLITE_OK || pCsr==0 );
175559175643
if( pCsr ){
175560175644
int iFirst = 0;
175561175645
pPhrase->pList = pCsr;
175562175646
fts3GetDeltaPosition(&pCsr, &iFirst);
175563
- assert( iFirst>=0 );
175564
- pPhrase->pHead = pCsr;
175565
- pPhrase->pTail = pCsr;
175566
- pPhrase->iHead = iFirst;
175567
- pPhrase->iTail = iFirst;
175647
+ if( iFirst<0 ){
175648
+ rc = FTS_CORRUPT_VTAB;
175649
+ }else{
175650
+ pPhrase->pHead = pCsr;
175651
+ pPhrase->pTail = pCsr;
175652
+ pPhrase->iHead = iFirst;
175653
+ pPhrase->iTail = iFirst;
175654
+ }
175568175655
}else{
175569175656
assert( rc!=SQLITE_OK || (
175570175657
pPhrase->pList==0 && pPhrase->pHead==0 && pPhrase->pTail==0
175571175658
));
175572175659
}
@@ -212324,10 +212411,11 @@
212324212411
if( writer.bFirstRowidInPage ){
212325212412
fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */
212326212413
pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);
212327212414
writer.bFirstRowidInPage = 0;
212328212415
fts5WriteDlidxAppend(p, &writer, iRowid);
212416
+ if( p->rc!=SQLITE_OK ) break;
212329212417
}else{
212330212418
pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta);
212331212419
}
212332212420
assert( pBuf->n<=pBuf->nSpace );
212333212421
@@ -212555,15 +212643,17 @@
212555212643
i64 iDelta,
212556212644
Fts5Iter *pMulti,
212557212645
Fts5Buffer *pBuf
212558212646
){
212559212647
int nData = pMulti->base.nData;
212648
+ int nByte = nData + 9 + 9 + FTS5_DATA_ZERO_PADDING;
212560212649
assert( nData>0 );
212561
- if( p->rc==SQLITE_OK && 0==fts5BufferGrow(&p->rc, pBuf, nData+9+9) ){
212650
+ if( p->rc==SQLITE_OK && 0==fts5BufferGrow(&p->rc, pBuf, nByte) ){
212562212651
fts5BufferSafeAppendVarint(pBuf, iDelta);
212563212652
fts5BufferSafeAppendVarint(pBuf, nData*2);
212564212653
fts5BufferSafeAppendBlob(pBuf, pMulti->base.pData, nData);
212654
+ memset(&pBuf->p[pBuf->n], 0, FTS5_DATA_ZERO_PADDING);
212565212655
}
212566212656
}
212567212657
212568212658
212569212659
static void fts5DoclistIterNext(Fts5DoclistIter *pIter){
@@ -214199,10 +214289,14 @@
214199214289
fts5DecodePoslist(&rc, &s, &a[4], iOff-4);
214200214290
214201214291
/* Decode any more doclist data that appears on the page before the
214202214292
** first term. */
214203214293
nDoclist = (iTermOff ? iTermOff : szLeaf) - iOff;
214294
+ if( nDoclist+iOff>n ){
214295
+ rc = FTS5_CORRUPT;
214296
+ goto decode_out;
214297
+ }
214204214298
fts5DecodeDoclist(&rc, &s, &a[iOff], nDoclist);
214205214299
214206214300
while( iPgidxOff<n && rc==SQLITE_OK ){
214207214301
int bFirst = (iPgidxOff==szLeaf); /* True for first term on page */
214208214302
int nByte; /* Bytes of data */
@@ -214617,11 +214711,11 @@
214617214711
p->ts.iSavepoint = iSavepoint-1;
214618214712
break;
214619214713
214620214714
case FTS5_ROLLBACKTO:
214621214715
assert( p->ts.eState==1 );
214622
- assert( iSavepoint>=0 );
214716
+ assert( iSavepoint>=-1 );
214623214717
assert( iSavepoint<=p->ts.iSavepoint );
214624214718
p->ts.iSavepoint = iSavepoint;
214625214719
break;
214626214720
}
214627214721
}
@@ -216977,11 +217071,11 @@
216977217071
int nArg, /* Number of args */
216978217072
sqlite3_value **apUnused /* Function arguments */
216979217073
){
216980217074
assert( nArg==0 );
216981217075
UNUSED_PARAM2(nArg, apUnused);
216982
- sqlite3_result_text(pCtx, "fts5: 2019-02-01 15:06:27 4ca9d5d53d41d08fbce29f9da8cc0948df9c4c3136210af88b499cf889b5ccb8", -1, SQLITE_TRANSIENT);
217076
+ sqlite3_result_text(pCtx, "fts5: 2019-02-05 19:52:39 2f468da4e9fb3edb5e902fa5d3c528726d1fb64d749d29e558ba3243c76bcb95", -1, SQLITE_TRANSIENT);
216983217077
}
216984217078
216985217079
/*
216986217080
** Return true if zName is the extension on one of the shadow tables used
216987217081
** by this module.
@@ -221741,12 +221835,12 @@
221741221835
}
221742221836
#endif /* SQLITE_CORE */
221743221837
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
221744221838
221745221839
/************** End of stmt.c ************************************************/
221746
-#if __LINE__!=221746
221840
+#if __LINE__!=221840
221747221841
#undef SQLITE_SOURCE_ID
221748
-#define SQLITE_SOURCE_ID "2019-02-01 15:06:27 4ca9d5d53d41d08fbce29f9da8cc0948df9c4c3136210af88b499cf889b5alt2"
221842
+#define SQLITE_SOURCE_ID "2019-02-05 20:51:41 4d0a949fd92e19fbf243a2e3a1a7c2cdb111f9a6943949d2420dd846bc7dalt2"
221749221843
#endif
221750221844
/* Return the source-id for this library */
221751221845
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
221752221846
/************************** End of sqlite3.c ******************************/
221753221847
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1162,11 +1162,11 @@
1162 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1163 ** [sqlite_version()] and [sqlite_source_id()].
1164 */
1165 #define SQLITE_VERSION "3.27.0"
1166 #define SQLITE_VERSION_NUMBER 3027000
1167 #define SQLITE_SOURCE_ID "2019-02-01 15:06:27 4ca9d5d53d41d08fbce29f9da8cc0948df9c4c3136210af88b499cf889b5ccb8"
1168
1169 /*
1170 ** CAPI3REF: Run-Time Library Version Numbers
1171 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1172 **
@@ -4466,10 +4466,12 @@
4466 ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and
4467 ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
4468 ** is not a database file pathname pointer that SQLite passed into the xOpen
4469 ** VFS method, then the behavior of this routine is undefined and probably
4470 ** undesirable.
 
 
4471 */
4472 SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
4473 SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
4474 SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
4475
@@ -14556,10 +14558,11 @@
14556 SQLITE_PRIVATE i64 sqlite3BtreeOffset(BtCursor*);
14557 #endif
14558 SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);
14559 SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
14560 SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
 
14561
14562 SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
14563 SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
14564 SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*);
14565
@@ -18772,10 +18775,15 @@
18772 SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*);
18773 SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*);
18774 SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
18775 SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*,
18776 sqlite3_vfs**,char**,char **);
 
 
 
 
 
18777 SQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3*,const char*);
18778
18779 #ifdef SQLITE_UNTESTABLE
18780 # define sqlite3FaultSim(X) SQLITE_OK
18781 #else
@@ -27323,10 +27331,31 @@
27323 static char *getTextArg(PrintfArguments *p){
27324 if( p->nArg<=p->nUsed ) return 0;
27325 return (char*)sqlite3_value_text(p->apArg[p->nUsed++]);
27326 }
27327
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27328
27329 /*
27330 ** On machines with a small stack size, you can redefine the
27331 ** SQLITE_PRINT_BUF_SIZE to be something smaller, if desired.
27332 */
@@ -27405,10 +27434,13 @@
27405 }
27406 /* Find out what flags are present */
27407 flag_leftjustify = flag_prefix = cThousand =
27408 flag_alternateform = flag_altform2 = flag_zeropad = 0;
27409 done = 0;
 
 
 
27410 do{
27411 switch( c ){
27412 case '-': flag_leftjustify = 1; break;
27413 case '+': flag_prefix = '+'; break;
27414 case ' ': flag_prefix = ' '; break;
@@ -27415,84 +27447,97 @@
27415 case '#': flag_alternateform = 1; break;
27416 case '!': flag_altform2 = 1; break;
27417 case '0': flag_zeropad = 1; break;
27418 case ',': cThousand = ','; break;
27419 default: done = 1; break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27420 }
27421 }while( !done && (c=(*++fmt))!=0 );
27422 /* Get the field width */
27423 if( c=='*' ){
27424 if( bArgList ){
27425 width = (int)getIntArg(pArgList);
27426 }else{
27427 width = va_arg(ap,int);
27428 }
27429 if( width<0 ){
27430 flag_leftjustify = 1;
27431 width = width >= -2147483647 ? -width : 0;
27432 }
27433 c = *++fmt;
27434 }else{
27435 unsigned wx = 0;
27436 while( c>='0' && c<='9' ){
27437 wx = wx*10 + c - '0';
27438 c = *++fmt;
27439 }
27440 testcase( wx>0x7fffffff );
27441 width = wx & 0x7fffffff;
27442 }
27443 assert( width>=0 );
27444 #ifdef SQLITE_PRINTF_PRECISION_LIMIT
27445 if( width>SQLITE_PRINTF_PRECISION_LIMIT ){
27446 width = SQLITE_PRINTF_PRECISION_LIMIT;
27447 }
27448 #endif
27449
27450 /* Get the precision */
27451 if( c=='.' ){
27452 c = *++fmt;
27453 if( c=='*' ){
27454 if( bArgList ){
27455 precision = (int)getIntArg(pArgList);
27456 }else{
27457 precision = va_arg(ap,int);
27458 }
27459 c = *++fmt;
27460 if( precision<0 ){
27461 precision = precision >= -2147483647 ? -precision : -1;
27462 }
27463 }else{
27464 unsigned px = 0;
27465 while( c>='0' && c<='9' ){
27466 px = px*10 + c - '0';
27467 c = *++fmt;
27468 }
27469 testcase( px>0x7fffffff );
27470 precision = px & 0x7fffffff;
27471 }
27472 }else{
27473 precision = -1;
27474 }
27475 assert( precision>=(-1) );
27476 #ifdef SQLITE_PRINTF_PRECISION_LIMIT
27477 if( precision>SQLITE_PRINTF_PRECISION_LIMIT ){
27478 precision = SQLITE_PRINTF_PRECISION_LIMIT;
27479 }
27480 #endif
27481
27482
27483 /* Get the conversion type modifier */
27484 if( c=='l' ){
27485 flag_long = 1;
27486 c = *++fmt;
27487 if( c=='l' ){
27488 flag_long = 2;
27489 c = *++fmt;
27490 }
27491 }else{
27492 flag_long = 0;
27493 }
27494 /* Fetch the info entry for the field */
27495 infop = &fmtinfo[0];
27496 xtype = etINVALID;
27497 for(idx=0; idx<ArraySize(fmtinfo); idx++){
27498 if( c==fmtinfo[idx].fmttype ){
@@ -27573,16 +27618,15 @@
27573 }
27574 if( precision<etBUFSIZE-10-etBUFSIZE/3 ){
27575 nOut = etBUFSIZE;
27576 zOut = buf;
27577 }else{
27578 u64 n = (u64)precision + 10 + precision/3;
27579 zOut = zExtra = sqlite3Malloc( n );
27580 if( zOut==0 ){
27581 setStrAccumError(pAccum, SQLITE_NOMEM);
27582 return;
27583 }
27584 nOut = (int)n;
27585 }
27586 bufpt = &zOut[nOut-1];
27587 if( xtype==etORDINAL ){
27588 static const char zOrd[] = "thstndrd";
@@ -27697,16 +27741,16 @@
27697 if( xtype==etEXP ){
27698 e2 = 0;
27699 }else{
27700 e2 = exp;
27701 }
27702 if( MAX(e2,0)+(i64)precision+(i64)width > etBUFSIZE - 15 ){
27703 bufpt = zExtra
27704 = sqlite3Malloc( MAX(e2,0)+(i64)precision+(i64)width+15 );
27705 if( bufpt==0 ){
27706 setStrAccumError(pAccum, SQLITE_NOMEM);
27707 return;
27708 }
27709 }
27710 zOut = bufpt;
27711 nsd = 16 + flag_altform2*10;
27712 flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
@@ -27926,15 +27970,12 @@
27926 }
27927 }
27928 needQuote = !isnull && xtype==etSQLESCAPE2;
27929 n += i + 3;
27930 if( n>etBUFSIZE ){
27931 bufpt = zExtra = sqlite3Malloc( n );
27932 if( bufpt==0 ){
27933 setStrAccumError(pAccum, SQLITE_NOMEM);
27934 return;
27935 }
27936 }else{
27937 bufpt = buf;
27938 }
27939 j = 0;
27940 if( needQuote ) bufpt[j++] = q;
@@ -67525,10 +67566,29 @@
67525 assert( cursorHoldsMutex(pCur) );
67526 assert( pCur->eState==CURSOR_VALID );
67527 getCellInfo(pCur);
67528 return pCur->info.nPayload;
67529 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67530
67531 /*
67532 ** Given the page number of an overflow page in the database (parameter
67533 ** ovfl), this function finds the page number of the next page in the
67534 ** linked list of overflow pages. If possible, it uses the auto-vacuum
@@ -75268,10 +75328,13 @@
75268 u32 amt, /* Number of bytes to return. */
75269 Mem *pMem /* OUT: Return data in this Mem structure. */
75270 ){
75271 int rc;
75272 pMem->flags = MEM_Null;
 
 
 
75273 if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+1)) ){
75274 rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);
75275 if( rc==SQLITE_OK ){
75276 pMem->z[amt] = 0; /* Overrun area used when reading malformed records */
75277 pMem->flags = MEM_Blob;
@@ -101539,18 +101602,20 @@
101539 if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune;
101540 switch( pExpr->op ){
101541 case TK_ISNOT:
101542 case TK_NOT:
101543 case TK_ISNULL:
 
101544 case TK_IS:
101545 case TK_OR:
101546 case TK_CASE:
101547 case TK_IN:
101548 case TK_FUNCTION:
101549 testcase( pExpr->op==TK_ISNOT );
101550 testcase( pExpr->op==TK_NOT );
101551 testcase( pExpr->op==TK_ISNULL );
 
101552 testcase( pExpr->op==TK_IS );
101553 testcase( pExpr->op==TK_OR );
101554 testcase( pExpr->op==TK_CASE );
101555 testcase( pExpr->op==TK_IN );
101556 testcase( pExpr->op==TK_FUNCTION );
@@ -105763,12 +105828,12 @@
105763 return;
105764 }
105765 assert( pVfs );
105766 flags |= SQLITE_OPEN_MAIN_DB;
105767 rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
105768 sqlite3_free( zPath );
105769 db->nDb++;
 
105770 }
105771 db->noSharedCache = 0;
105772 if( rc==SQLITE_CONSTRAINT ){
105773 rc = SQLITE_ERROR;
105774 zErrDyn = sqlite3MPrintf(db, "database is already attached");
@@ -105792,11 +105857,10 @@
105792 PAGER_SYNCHRONOUS_FULL | (db->flags & PAGER_FLAGS_MASK));
105793 #endif
105794 sqlite3BtreeLeave(pNew->pBt);
105795 }
105796 pNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;
105797 if( !REOPEN_AS_MEMDB(db) ) pNew->zDbSName = sqlite3DbStrDup(db, zName);
105798 if( rc==SQLITE_OK && pNew->zDbSName==0 ){
105799 rc = SQLITE_NOMEM_BKPT;
105800 }
105801
105802
@@ -105820,19 +105884,23 @@
105820 zKey = (char *)sqlite3_value_blob(argv[2]);
105821 rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
105822 break;
105823
105824 case SQLITE_NULL:
105825 /* No key specified. Use the key from the main database */
105826 sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
105827 if( nKey || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){
105828 rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
 
 
 
105829 }
105830 break;
105831 }
105832 }
105833 #endif
 
105834
105835 /* If the file was opened successfully, read the schema for the new database.
105836 ** If this fails, or if opening the file failed, then close the file and
105837 ** remove the entry from the db->aDb[] array. i.e. put everything back the
105838 ** way we found it.
@@ -118594,11 +118662,11 @@
118594 if( zSql==0 ) zSql = "";
118595
118596 sqlite3_mutex_enter(db->mutex);
118597 sqlite3Error(db, SQLITE_OK);
118598 while( rc==SQLITE_OK && zSql[0] ){
118599 int nCol;
118600 char **azVals = 0;
118601
118602 pStmt = 0;
118603 rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
118604 assert( rc==SQLITE_OK || pStmt==0 );
@@ -118608,13 +118676,11 @@
118608 if( !pStmt ){
118609 /* this happens for a comment or white-space */
118610 zSql = zLeftover;
118611 continue;
118612 }
118613
118614 callbackIsInit = 0;
118615 nCol = sqlite3_column_count(pStmt);
118616
118617 while( 1 ){
118618 int i;
118619 rc = sqlite3_step(pStmt);
118620
@@ -118621,10 +118687,11 @@
118621 /* Invoke the callback function if required */
118622 if( xCallback && (SQLITE_ROW==rc ||
118623 (SQLITE_DONE==rc && !callbackIsInit
118624 && db->flags&SQLITE_NullCallback)) ){
118625 if( !callbackIsInit ){
 
118626 azCols = sqlite3DbMallocRaw(db, (2*nCol+1)*sizeof(const char*));
118627 if( azCols==0 ){
118628 goto exec_out;
118629 }
118630 for(i=0; i<nCol; i++){
@@ -120404,17 +120471,15 @@
120404 /* ColNames: */ 0, 0,
120405 /* iArg: */ SQLITE_CountRows },
120406 #endif
120407 #endif
120408 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN
120409 #if !defined(SQLITE_OMIT_DEPRECATED)
120410 {/* zName: */ "data_store_directory",
120411 /* ePragTyp: */ PragTyp_DATA_STORE_DIRECTORY,
120412 /* ePragFlg: */ PragFlg_NoColumns1,
120413 /* ColNames: */ 0, 0,
120414 /* iArg: */ 0 },
120415 #endif
120416 #endif
120417 #if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
120418 {/* zName: */ "data_version",
120419 /* ePragTyp: */ PragTyp_HEADER_VALUE,
120420 /* ePragFlg: */ PragFlg_ReadOnly|PragFlg_Result0,
@@ -120787,19 +120852,15 @@
120787 {/* zName: */ "temp_store",
120788 /* ePragTyp: */ PragTyp_TEMP_STORE,
120789 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
120790 /* ColNames: */ 0, 0,
120791 /* iArg: */ 0 },
120792 #endif
120793 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
120794 #if !defined(SQLITE_OMIT_DEPRECATED)
120795 {/* zName: */ "temp_store_directory",
120796 /* ePragTyp: */ PragTyp_TEMP_STORE_DIRECTORY,
120797 /* ePragFlg: */ PragFlg_NoColumns1,
120798 /* ColNames: */ 0, 0,
120799 /* iArg: */ 0 },
120800 #endif
120801 #endif
120802 #if defined(SQLITE_HAS_CODEC)
120803 {/* zName: */ "textkey",
120804 /* ePragTyp: */ PragTyp_KEY,
120805 /* ePragFlg: */ 0,
@@ -134945,10 +135006,11 @@
134945 for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
134946 VTable *pVTab = db->aVTrans[i];
134947 const sqlite3_module *pMod = pVTab->pMod->pModule;
134948 if( pVTab->pVtab && pMod->iVersion>=2 ){
134949 int (*xMethod)(sqlite3_vtab *, int);
 
134950 switch( op ){
134951 case SAVEPOINT_BEGIN:
134952 xMethod = pMod->xSavepoint;
134953 pVTab->iSavepoint = iSavepoint+1;
134954 break;
@@ -134960,10 +135022,11 @@
134960 break;
134961 }
134962 if( xMethod && pVTab->iSavepoint>iSavepoint ){
134963 rc = xMethod(pVTab->pVtab, iSavepoint);
134964 }
 
134965 }
134966 }
134967 }
134968 return rc;
134969 }
@@ -153130,11 +153193,11 @@
153130 ){
153131 sqlite3 *db; /* The database connection */
153132 int i; /* Next unread byte of zSql[] */
153133 int n; /* length of current token */
153134 int tokenType; /* type of current token */
153135 int prevType; /* Previous non-whitespace token */
153136 int nParen; /* Number of nested levels of parentheses */
153137 int iStartIN; /* Start of RHS of IN operator in z[] */
153138 int nParenAtIN; /* Value of nParent at start of RHS of IN operator */
153139 int j; /* Bytes of normalized SQL generated so far */
153140 sqlite3_str *pStr; /* The normalized SQL string under construction */
@@ -156574,10 +156637,44 @@
156574 *pFlags = flags;
156575 *pzFile = zFile;
156576 return rc;
156577 }
156578
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156579
156580 /*
156581 ** This routine does the work of opening a database on behalf of
156582 ** sqlite3_open() and sqlite3_open16(). The database filename "zFilename"
156583 ** is UTF-8 encoded.
@@ -156919,29 +157016,16 @@
156919 void *pArg = sqlite3GlobalConfig.pSqllogArg;
156920 sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0);
156921 }
156922 #endif
156923 #if defined(SQLITE_HAS_CODEC)
156924 if( rc==SQLITE_OK ){
156925 const char *zKey;
156926 if( (zKey = sqlite3_uri_parameter(zOpen, "hexkey"))!=0 && zKey[0] ){
156927 u8 iByte;
156928 int i;
156929 char zDecoded[40];
156930 for(i=0, iByte=0; i<sizeof(zDecoded)*2 && sqlite3Isxdigit(zKey[i]); i++){
156931 iByte = (iByte<<4) + sqlite3HexToInt(zKey[i]);
156932 if( (i&1)!=0 ) zDecoded[i/2] = iByte;
156933 }
156934 sqlite3_key_v2(db, 0, zDecoded, i/2);
156935 }else if( (zKey = sqlite3_uri_parameter(zOpen, "key"))!=0 ){
156936 sqlite3_key_v2(db, 0, zKey, sqlite3Strlen30(zKey));
156937 }
156938 }
156939 #endif
156940 sqlite3_free(zOpen);
156941 return rc & 0xff;
156942 }
 
156943
156944 /*
156945 ** Open a new database handle.
156946 */
156947 SQLITE_API int sqlite3_open(
@@ -175558,15 +175642,18 @@
175558 assert( rc==SQLITE_OK || pCsr==0 );
175559 if( pCsr ){
175560 int iFirst = 0;
175561 pPhrase->pList = pCsr;
175562 fts3GetDeltaPosition(&pCsr, &iFirst);
175563 assert( iFirst>=0 );
175564 pPhrase->pHead = pCsr;
175565 pPhrase->pTail = pCsr;
175566 pPhrase->iHead = iFirst;
175567 pPhrase->iTail = iFirst;
 
 
 
175568 }else{
175569 assert( rc!=SQLITE_OK || (
175570 pPhrase->pList==0 && pPhrase->pHead==0 && pPhrase->pTail==0
175571 ));
175572 }
@@ -212324,10 +212411,11 @@
212324 if( writer.bFirstRowidInPage ){
212325 fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */
212326 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);
212327 writer.bFirstRowidInPage = 0;
212328 fts5WriteDlidxAppend(p, &writer, iRowid);
 
212329 }else{
212330 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta);
212331 }
212332 assert( pBuf->n<=pBuf->nSpace );
212333
@@ -212555,15 +212643,17 @@
212555 i64 iDelta,
212556 Fts5Iter *pMulti,
212557 Fts5Buffer *pBuf
212558 ){
212559 int nData = pMulti->base.nData;
 
212560 assert( nData>0 );
212561 if( p->rc==SQLITE_OK && 0==fts5BufferGrow(&p->rc, pBuf, nData+9+9) ){
212562 fts5BufferSafeAppendVarint(pBuf, iDelta);
212563 fts5BufferSafeAppendVarint(pBuf, nData*2);
212564 fts5BufferSafeAppendBlob(pBuf, pMulti->base.pData, nData);
 
212565 }
212566 }
212567
212568
212569 static void fts5DoclistIterNext(Fts5DoclistIter *pIter){
@@ -214199,10 +214289,14 @@
214199 fts5DecodePoslist(&rc, &s, &a[4], iOff-4);
214200
214201 /* Decode any more doclist data that appears on the page before the
214202 ** first term. */
214203 nDoclist = (iTermOff ? iTermOff : szLeaf) - iOff;
 
 
 
 
214204 fts5DecodeDoclist(&rc, &s, &a[iOff], nDoclist);
214205
214206 while( iPgidxOff<n && rc==SQLITE_OK ){
214207 int bFirst = (iPgidxOff==szLeaf); /* True for first term on page */
214208 int nByte; /* Bytes of data */
@@ -214617,11 +214711,11 @@
214617 p->ts.iSavepoint = iSavepoint-1;
214618 break;
214619
214620 case FTS5_ROLLBACKTO:
214621 assert( p->ts.eState==1 );
214622 assert( iSavepoint>=0 );
214623 assert( iSavepoint<=p->ts.iSavepoint );
214624 p->ts.iSavepoint = iSavepoint;
214625 break;
214626 }
214627 }
@@ -216977,11 +217071,11 @@
216977 int nArg, /* Number of args */
216978 sqlite3_value **apUnused /* Function arguments */
216979 ){
216980 assert( nArg==0 );
216981 UNUSED_PARAM2(nArg, apUnused);
216982 sqlite3_result_text(pCtx, "fts5: 2019-02-01 15:06:27 4ca9d5d53d41d08fbce29f9da8cc0948df9c4c3136210af88b499cf889b5ccb8", -1, SQLITE_TRANSIENT);
216983 }
216984
216985 /*
216986 ** Return true if zName is the extension on one of the shadow tables used
216987 ** by this module.
@@ -221741,12 +221835,12 @@
221741 }
221742 #endif /* SQLITE_CORE */
221743 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
221744
221745 /************** End of stmt.c ************************************************/
221746 #if __LINE__!=221746
221747 #undef SQLITE_SOURCE_ID
221748 #define SQLITE_SOURCE_ID "2019-02-01 15:06:27 4ca9d5d53d41d08fbce29f9da8cc0948df9c4c3136210af88b499cf889b5alt2"
221749 #endif
221750 /* Return the source-id for this library */
221751 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
221752 /************************** End of sqlite3.c ******************************/
221753
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1162,11 +1162,11 @@
1162 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1163 ** [sqlite_version()] and [sqlite_source_id()].
1164 */
1165 #define SQLITE_VERSION "3.27.0"
1166 #define SQLITE_VERSION_NUMBER 3027000
1167 #define SQLITE_SOURCE_ID "2019-02-05 20:51:41 4d0a949fd92e19fbf243a2e3a1a7c2cdb111f9a6943949d2420dd846bc7d9285"
1168
1169 /*
1170 ** CAPI3REF: Run-Time Library Version Numbers
1171 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1172 **
@@ -4466,10 +4466,12 @@
4466 ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and
4467 ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
4468 ** is not a database file pathname pointer that SQLite passed into the xOpen
4469 ** VFS method, then the behavior of this routine is undefined and probably
4470 ** undesirable.
4471 **
4472 ** See the [URI filename] documentation for additional information.
4473 */
4474 SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
4475 SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
4476 SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
4477
@@ -14556,10 +14558,11 @@
14558 SQLITE_PRIVATE i64 sqlite3BtreeOffset(BtCursor*);
14559 #endif
14560 SQLITE_PRIVATE int sqlite3BtreePayload(BtCursor*, u32 offset, u32 amt, void*);
14561 SQLITE_PRIVATE const void *sqlite3BtreePayloadFetch(BtCursor*, u32 *pAmt);
14562 SQLITE_PRIVATE u32 sqlite3BtreePayloadSize(BtCursor*);
14563 SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor*);
14564
14565 SQLITE_PRIVATE char *sqlite3BtreeIntegrityCheck(Btree*, int *aRoot, int nRoot, int, int*);
14566 SQLITE_PRIVATE struct Pager *sqlite3BtreePager(Btree*);
14567 SQLITE_PRIVATE i64 sqlite3BtreeRowCountEst(BtCursor*);
14568
@@ -18772,10 +18775,15 @@
18775 SQLITE_PRIVATE void sqlite3AddDefaultValue(Parse*,Expr*,const char*,const char*);
18776 SQLITE_PRIVATE void sqlite3AddCollateType(Parse*, Token*);
18777 SQLITE_PRIVATE void sqlite3EndTable(Parse*,Token*,Token*,u8,Select*);
18778 SQLITE_PRIVATE int sqlite3ParseUri(const char*,const char*,unsigned int*,
18779 sqlite3_vfs**,char**,char **);
18780 #ifdef SQLITE_HAS_CODEC
18781 SQLITE_PRIVATE int sqlite3CodecQueryParameters(sqlite3*,const char*,const char*);
18782 #else
18783 # define sqlite3CodecQueryParameters(A,B,C) 0
18784 #endif
18785 SQLITE_PRIVATE Btree *sqlite3DbNameToBtree(sqlite3*,const char*);
18786
18787 #ifdef SQLITE_UNTESTABLE
18788 # define sqlite3FaultSim(X) SQLITE_OK
18789 #else
@@ -27323,10 +27331,31 @@
27331 static char *getTextArg(PrintfArguments *p){
27332 if( p->nArg<=p->nUsed ) return 0;
27333 return (char*)sqlite3_value_text(p->apArg[p->nUsed++]);
27334 }
27335
27336 /*
27337 ** Allocate memory for a temporary buffer needed for printf rendering.
27338 **
27339 ** If the requested size of the temp buffer is larger than the size
27340 ** of the output buffer in pAccum, then cause an SQLITE_TOOBIG error.
27341 ** Do the size check before the memory allocation to prevent rogue
27342 ** SQL from requesting large allocations using the precision or width
27343 ** field of the printf() function.
27344 */
27345 static char *printfTempBuf(sqlite3_str *pAccum, sqlite3_int64 n){
27346 char *z;
27347 if( n>pAccum->nAlloc && n>pAccum->mxAlloc ){
27348 setStrAccumError(pAccum, SQLITE_TOOBIG);
27349 return 0;
27350 }
27351 z = sqlite3DbMallocRaw(pAccum->db, n);
27352 if( z==0 ){
27353 setStrAccumError(pAccum, SQLITE_NOMEM);
27354 }
27355 return z;
27356 }
27357
27358 /*
27359 ** On machines with a small stack size, you can redefine the
27360 ** SQLITE_PRINT_BUF_SIZE to be something smaller, if desired.
27361 */
@@ -27405,10 +27434,13 @@
27434 }
27435 /* Find out what flags are present */
27436 flag_leftjustify = flag_prefix = cThousand =
27437 flag_alternateform = flag_altform2 = flag_zeropad = 0;
27438 done = 0;
27439 width = 0;
27440 flag_long = 0;
27441 precision = -1;
27442 do{
27443 switch( c ){
27444 case '-': flag_leftjustify = 1; break;
27445 case '+': flag_prefix = '+'; break;
27446 case ' ': flag_prefix = ' '; break;
@@ -27415,84 +27447,97 @@
27447 case '#': flag_alternateform = 1; break;
27448 case '!': flag_altform2 = 1; break;
27449 case '0': flag_zeropad = 1; break;
27450 case ',': cThousand = ','; break;
27451 default: done = 1; break;
27452 case 'l': {
27453 flag_long = 1;
27454 c = *++fmt;
27455 if( c=='l' ){
27456 c = *++fmt;
27457 flag_long = 2;
27458 }
27459 done = 1;
27460 break;
27461 }
27462 case '1': case '2': case '3': case '4': case '5':
27463 case '6': case '7': case '8': case '9': {
27464 unsigned wx = c - '0';
27465 while( (c = *++fmt)>='0' && c<='9' ){
27466 wx = wx*10 + c - '0';
27467 }
27468 testcase( wx>0x7fffffff );
27469 width = wx & 0x7fffffff;
27470 #ifdef SQLITE_PRINTF_PRECISION_LIMIT
27471 if( width>SQLITE_PRINTF_PRECISION_LIMIT ){
27472 width = SQLITE_PRINTF_PRECISION_LIMIT;
27473 }
27474 #endif
27475 if( c!='.' && c!='l' ){
27476 done = 1;
27477 }else{
27478 fmt--;
27479 }
27480 break;
27481 }
27482 case '*': {
27483 if( bArgList ){
27484 width = (int)getIntArg(pArgList);
27485 }else{
27486 width = va_arg(ap,int);
27487 }
27488 if( width<0 ){
27489 flag_leftjustify = 1;
27490 width = width >= -2147483647 ? -width : 0;
27491 }
27492 #ifdef SQLITE_PRINTF_PRECISION_LIMIT
27493 if( width>SQLITE_PRINTF_PRECISION_LIMIT ){
27494 width = SQLITE_PRINTF_PRECISION_LIMIT;
27495 }
27496 #endif
27497 if( (c = fmt[1])!='.' && c!='l' ){
27498 c = *++fmt;
27499 done = 1;
27500 }
27501 break;
27502 }
27503 case '.': {
27504 c = *++fmt;
27505 if( c=='*' ){
27506 if( bArgList ){
27507 precision = (int)getIntArg(pArgList);
27508 }else{
27509 precision = va_arg(ap,int);
27510 }
27511 if( precision<0 ){
27512 precision = precision >= -2147483647 ? -precision : -1;
27513 }
27514 c = *++fmt;
27515 }else{
27516 unsigned px = 0;
27517 while( c>='0' && c<='9' ){
27518 px = px*10 + c - '0';
27519 c = *++fmt;
27520 }
27521 testcase( px>0x7fffffff );
27522 precision = px & 0x7fffffff;
27523 }
27524 #ifdef SQLITE_PRINTF_PRECISION_LIMIT
27525 if( precision>SQLITE_PRINTF_PRECISION_LIMIT ){
27526 precision = SQLITE_PRINTF_PRECISION_LIMIT;
27527 }
27528 #endif
27529 if( c=='l' ){
27530 --fmt;
27531 }else{
27532 done = 1;
27533 }
27534 break;
27535 }
27536 }
27537 }while( !done && (c=(*++fmt))!=0 );
27538
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27539 /* Fetch the info entry for the field */
27540 infop = &fmtinfo[0];
27541 xtype = etINVALID;
27542 for(idx=0; idx<ArraySize(fmtinfo); idx++){
27543 if( c==fmtinfo[idx].fmttype ){
@@ -27573,16 +27618,15 @@
27618 }
27619 if( precision<etBUFSIZE-10-etBUFSIZE/3 ){
27620 nOut = etBUFSIZE;
27621 zOut = buf;
27622 }else{
27623 u64 n;
27624 n = (u64)precision + 10;
27625 if( cThousand ) n += precision/3;
27626 zOut = zExtra = printfTempBuf(pAccum, n);
27627 if( zOut==0 ) return;
 
27628 nOut = (int)n;
27629 }
27630 bufpt = &zOut[nOut-1];
27631 if( xtype==etORDINAL ){
27632 static const char zOrd[] = "thstndrd";
@@ -27697,16 +27741,16 @@
27741 if( xtype==etEXP ){
27742 e2 = 0;
27743 }else{
27744 e2 = exp;
27745 }
27746 {
27747 i64 szBufNeeded; /* Size of a temporary buffer needed */
27748 szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+15;
27749 if( szBufNeeded > etBUFSIZE ){
27750 bufpt = zExtra = printfTempBuf(pAccum, szBufNeeded);
27751 if( bufpt==0 ) return;
27752 }
27753 }
27754 zOut = bufpt;
27755 nsd = 16 + flag_altform2*10;
27756 flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
@@ -27926,15 +27970,12 @@
27970 }
27971 }
27972 needQuote = !isnull && xtype==etSQLESCAPE2;
27973 n += i + 3;
27974 if( n>etBUFSIZE ){
27975 bufpt = zExtra = printfTempBuf(pAccum, n);
27976 if( bufpt==0 ) return;
 
 
 
27977 }else{
27978 bufpt = buf;
27979 }
27980 j = 0;
27981 if( needQuote ) bufpt[j++] = q;
@@ -67525,10 +67566,29 @@
67566 assert( cursorHoldsMutex(pCur) );
67567 assert( pCur->eState==CURSOR_VALID );
67568 getCellInfo(pCur);
67569 return pCur->info.nPayload;
67570 }
67571
67572 /*
67573 ** Return an upper bound on the size of any record for the table
67574 ** that the cursor is pointing into.
67575 **
67576 ** This is an optimization. Everything will still work if this
67577 ** routine always returns 2147483647 (which is the largest record
67578 ** that SQLite can handle) or more. But returning a smaller value might
67579 ** prevent large memory allocations when trying to interpret a
67580 ** corrupt datrabase.
67581 **
67582 ** The current implementation merely returns the size of the underlying
67583 ** database file.
67584 */
67585 SQLITE_PRIVATE sqlite3_int64 sqlite3BtreeMaxRecordSize(BtCursor *pCur){
67586 assert( cursorHoldsMutex(pCur) );
67587 assert( pCur->eState==CURSOR_VALID );
67588 return pCur->pBt->pageSize * (sqlite3_int64)pCur->pBt->nPage;
67589 }
67590
67591 /*
67592 ** Given the page number of an overflow page in the database (parameter
67593 ** ovfl), this function finds the page number of the next page in the
67594 ** linked list of overflow pages. If possible, it uses the auto-vacuum
@@ -75268,10 +75328,13 @@
75328 u32 amt, /* Number of bytes to return. */
75329 Mem *pMem /* OUT: Return data in this Mem structure. */
75330 ){
75331 int rc;
75332 pMem->flags = MEM_Null;
75333 if( sqlite3BtreeMaxRecordSize(pCur)<offset+amt ){
75334 return SQLITE_CORRUPT_BKPT;
75335 }
75336 if( SQLITE_OK==(rc = sqlite3VdbeMemClearAndResize(pMem, amt+1)) ){
75337 rc = sqlite3BtreePayload(pCur, offset, amt, pMem->z);
75338 if( rc==SQLITE_OK ){
75339 pMem->z[amt] = 0; /* Overrun area used when reading malformed records */
75340 pMem->flags = MEM_Blob;
@@ -101539,18 +101602,20 @@
101602 if( ExprHasProperty(pExpr, EP_FromJoin) ) return WRC_Prune;
101603 switch( pExpr->op ){
101604 case TK_ISNOT:
101605 case TK_NOT:
101606 case TK_ISNULL:
101607 case TK_NOTNULL:
101608 case TK_IS:
101609 case TK_OR:
101610 case TK_CASE:
101611 case TK_IN:
101612 case TK_FUNCTION:
101613 testcase( pExpr->op==TK_ISNOT );
101614 testcase( pExpr->op==TK_NOT );
101615 testcase( pExpr->op==TK_ISNULL );
101616 testcase( pExpr->op==TK_NOTNULL );
101617 testcase( pExpr->op==TK_IS );
101618 testcase( pExpr->op==TK_OR );
101619 testcase( pExpr->op==TK_CASE );
101620 testcase( pExpr->op==TK_IN );
101621 testcase( pExpr->op==TK_FUNCTION );
@@ -105763,12 +105828,12 @@
105828 return;
105829 }
105830 assert( pVfs );
105831 flags |= SQLITE_OPEN_MAIN_DB;
105832 rc = sqlite3BtreeOpen(pVfs, zPath, db, &pNew->pBt, 0, flags);
 
105833 db->nDb++;
105834 pNew->zDbSName = sqlite3DbStrDup(db, zName);
105835 }
105836 db->noSharedCache = 0;
105837 if( rc==SQLITE_CONSTRAINT ){
105838 rc = SQLITE_ERROR;
105839 zErrDyn = sqlite3MPrintf(db, "database is already attached");
@@ -105792,11 +105857,10 @@
105857 PAGER_SYNCHRONOUS_FULL | (db->flags & PAGER_FLAGS_MASK));
105858 #endif
105859 sqlite3BtreeLeave(pNew->pBt);
105860 }
105861 pNew->safety_level = SQLITE_DEFAULT_SYNCHRONOUS+1;
 
105862 if( rc==SQLITE_OK && pNew->zDbSName==0 ){
105863 rc = SQLITE_NOMEM_BKPT;
105864 }
105865
105866
@@ -105820,19 +105884,23 @@
105884 zKey = (char *)sqlite3_value_blob(argv[2]);
105885 rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
105886 break;
105887
105888 case SQLITE_NULL:
105889 /* No key specified. Use the key from URI filename, or if none,
105890 ** use the key from the main database. */
105891 if( sqlite3CodecQueryParameters(db, zName, zPath)==0 ){
105892 sqlite3CodecGetKey(db, 0, (void**)&zKey, &nKey);
105893 if( nKey || sqlite3BtreeGetOptimalReserve(db->aDb[0].pBt)>0 ){
105894 rc = sqlite3CodecAttach(db, db->nDb-1, zKey, nKey);
105895 }
105896 }
105897 break;
105898 }
105899 }
105900 #endif
105901 sqlite3_free( zPath );
105902
105903 /* If the file was opened successfully, read the schema for the new database.
105904 ** If this fails, or if opening the file failed, then close the file and
105905 ** remove the entry from the db->aDb[] array. i.e. put everything back the
105906 ** way we found it.
@@ -118594,11 +118662,11 @@
118662 if( zSql==0 ) zSql = "";
118663
118664 sqlite3_mutex_enter(db->mutex);
118665 sqlite3Error(db, SQLITE_OK);
118666 while( rc==SQLITE_OK && zSql[0] ){
118667 int nCol = 0;
118668 char **azVals = 0;
118669
118670 pStmt = 0;
118671 rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, &zLeftover);
118672 assert( rc==SQLITE_OK || pStmt==0 );
@@ -118608,13 +118676,11 @@
118676 if( !pStmt ){
118677 /* this happens for a comment or white-space */
118678 zSql = zLeftover;
118679 continue;
118680 }
 
118681 callbackIsInit = 0;
 
118682
118683 while( 1 ){
118684 int i;
118685 rc = sqlite3_step(pStmt);
118686
@@ -118621,10 +118687,11 @@
118687 /* Invoke the callback function if required */
118688 if( xCallback && (SQLITE_ROW==rc ||
118689 (SQLITE_DONE==rc && !callbackIsInit
118690 && db->flags&SQLITE_NullCallback)) ){
118691 if( !callbackIsInit ){
118692 nCol = sqlite3_column_count(pStmt);
118693 azCols = sqlite3DbMallocRaw(db, (2*nCol+1)*sizeof(const char*));
118694 if( azCols==0 ){
118695 goto exec_out;
118696 }
118697 for(i=0; i<nCol; i++){
@@ -120404,17 +120471,15 @@
120471 /* ColNames: */ 0, 0,
120472 /* iArg: */ SQLITE_CountRows },
120473 #endif
120474 #endif
120475 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) && SQLITE_OS_WIN
 
120476 {/* zName: */ "data_store_directory",
120477 /* ePragTyp: */ PragTyp_DATA_STORE_DIRECTORY,
120478 /* ePragFlg: */ PragFlg_NoColumns1,
120479 /* ColNames: */ 0, 0,
120480 /* iArg: */ 0 },
 
120481 #endif
120482 #if !defined(SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS)
120483 {/* zName: */ "data_version",
120484 /* ePragTyp: */ PragTyp_HEADER_VALUE,
120485 /* ePragFlg: */ PragFlg_ReadOnly|PragFlg_Result0,
@@ -120787,19 +120852,15 @@
120852 {/* zName: */ "temp_store",
120853 /* ePragTyp: */ PragTyp_TEMP_STORE,
120854 /* ePragFlg: */ PragFlg_Result0|PragFlg_NoColumns1,
120855 /* ColNames: */ 0, 0,
120856 /* iArg: */ 0 },
 
 
 
120857 {/* zName: */ "temp_store_directory",
120858 /* ePragTyp: */ PragTyp_TEMP_STORE_DIRECTORY,
120859 /* ePragFlg: */ PragFlg_NoColumns1,
120860 /* ColNames: */ 0, 0,
120861 /* iArg: */ 0 },
 
120862 #endif
120863 #if defined(SQLITE_HAS_CODEC)
120864 {/* zName: */ "textkey",
120865 /* ePragTyp: */ PragTyp_KEY,
120866 /* ePragFlg: */ 0,
@@ -134945,10 +135006,11 @@
135006 for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
135007 VTable *pVTab = db->aVTrans[i];
135008 const sqlite3_module *pMod = pVTab->pMod->pModule;
135009 if( pVTab->pVtab && pMod->iVersion>=2 ){
135010 int (*xMethod)(sqlite3_vtab *, int);
135011 sqlite3VtabLock(pVTab);
135012 switch( op ){
135013 case SAVEPOINT_BEGIN:
135014 xMethod = pMod->xSavepoint;
135015 pVTab->iSavepoint = iSavepoint+1;
135016 break;
@@ -134960,10 +135022,11 @@
135022 break;
135023 }
135024 if( xMethod && pVTab->iSavepoint>iSavepoint ){
135025 rc = xMethod(pVTab->pVtab, iSavepoint);
135026 }
135027 sqlite3VtabUnlock(pVTab);
135028 }
135029 }
135030 }
135031 return rc;
135032 }
@@ -153130,11 +153193,11 @@
153193 ){
153194 sqlite3 *db; /* The database connection */
153195 int i; /* Next unread byte of zSql[] */
153196 int n; /* length of current token */
153197 int tokenType; /* type of current token */
153198 int prevType = 0; /* Previous non-whitespace token */
153199 int nParen; /* Number of nested levels of parentheses */
153200 int iStartIN; /* Start of RHS of IN operator in z[] */
153201 int nParenAtIN; /* Value of nParent at start of RHS of IN operator */
153202 int j; /* Bytes of normalized SQL generated so far */
153203 sqlite3_str *pStr; /* The normalized SQL string under construction */
@@ -156574,10 +156637,44 @@
156637 *pFlags = flags;
156638 *pzFile = zFile;
156639 return rc;
156640 }
156641
156642 #if defined(SQLITE_HAS_CODEC)
156643 /*
156644 ** Process URI filename query parameters relevant to the SQLite Encryption
156645 ** Extension. Return true if any of the relevant query parameters are
156646 ** seen and return false if not.
156647 */
156648 SQLITE_PRIVATE int sqlite3CodecQueryParameters(
156649 sqlite3 *db, /* Database connection */
156650 const char *zDb, /* Which schema is being created/attached */
156651 const char *zUri /* URI filename */
156652 ){
156653 const char *zKey;
156654 if( (zKey = sqlite3_uri_parameter(zUri, "hexkey"))!=0 && zKey[0] ){
156655 u8 iByte;
156656 int i;
156657 char zDecoded[40];
156658 for(i=0, iByte=0; i<sizeof(zDecoded)*2 && sqlite3Isxdigit(zKey[i]); i++){
156659 iByte = (iByte<<4) + sqlite3HexToInt(zKey[i]);
156660 if( (i&1)!=0 ) zDecoded[i/2] = iByte;
156661 }
156662 sqlite3_key_v2(db, zDb, zDecoded, i/2);
156663 return 1;
156664 }else if( (zKey = sqlite3_uri_parameter(zUri, "key"))!=0 ){
156665 sqlite3_key_v2(db, zDb, zKey, sqlite3Strlen30(zKey));
156666 return 1;
156667 }else if( (zKey = sqlite3_uri_parameter(zUri, "textkey"))!=0 ){
156668 sqlite3_key_v2(db, zDb, zKey, -1);
156669 return 1;
156670 }else{
156671 return 0;
156672 }
156673 }
156674 #endif
156675
156676
156677 /*
156678 ** This routine does the work of opening a database on behalf of
156679 ** sqlite3_open() and sqlite3_open16(). The database filename "zFilename"
156680 ** is UTF-8 encoded.
@@ -156919,29 +157016,16 @@
157016 void *pArg = sqlite3GlobalConfig.pSqllogArg;
157017 sqlite3GlobalConfig.xSqllog(pArg, db, zFilename, 0);
157018 }
157019 #endif
157020 #if defined(SQLITE_HAS_CODEC)
157021 if( rc==SQLITE_OK ) sqlite3CodecQueryParameters(db, 0, zOpen);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157022 #endif
157023 sqlite3_free(zOpen);
157024 return rc & 0xff;
157025 }
157026
157027
157028 /*
157029 ** Open a new database handle.
157030 */
157031 SQLITE_API int sqlite3_open(
@@ -175558,15 +175642,18 @@
175642 assert( rc==SQLITE_OK || pCsr==0 );
175643 if( pCsr ){
175644 int iFirst = 0;
175645 pPhrase->pList = pCsr;
175646 fts3GetDeltaPosition(&pCsr, &iFirst);
175647 if( iFirst<0 ){
175648 rc = FTS_CORRUPT_VTAB;
175649 }else{
175650 pPhrase->pHead = pCsr;
175651 pPhrase->pTail = pCsr;
175652 pPhrase->iHead = iFirst;
175653 pPhrase->iTail = iFirst;
175654 }
175655 }else{
175656 assert( rc!=SQLITE_OK || (
175657 pPhrase->pList==0 && pPhrase->pHead==0 && pPhrase->pTail==0
175658 ));
175659 }
@@ -212324,10 +212411,11 @@
212411 if( writer.bFirstRowidInPage ){
212412 fts5PutU16(&pBuf->p[0], (u16)pBuf->n); /* first rowid on page */
212413 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iRowid);
212414 writer.bFirstRowidInPage = 0;
212415 fts5WriteDlidxAppend(p, &writer, iRowid);
212416 if( p->rc!=SQLITE_OK ) break;
212417 }else{
212418 pBuf->n += sqlite3Fts5PutVarint(&pBuf->p[pBuf->n], iDelta);
212419 }
212420 assert( pBuf->n<=pBuf->nSpace );
212421
@@ -212555,15 +212643,17 @@
212643 i64 iDelta,
212644 Fts5Iter *pMulti,
212645 Fts5Buffer *pBuf
212646 ){
212647 int nData = pMulti->base.nData;
212648 int nByte = nData + 9 + 9 + FTS5_DATA_ZERO_PADDING;
212649 assert( nData>0 );
212650 if( p->rc==SQLITE_OK && 0==fts5BufferGrow(&p->rc, pBuf, nByte) ){
212651 fts5BufferSafeAppendVarint(pBuf, iDelta);
212652 fts5BufferSafeAppendVarint(pBuf, nData*2);
212653 fts5BufferSafeAppendBlob(pBuf, pMulti->base.pData, nData);
212654 memset(&pBuf->p[pBuf->n], 0, FTS5_DATA_ZERO_PADDING);
212655 }
212656 }
212657
212658
212659 static void fts5DoclistIterNext(Fts5DoclistIter *pIter){
@@ -214199,10 +214289,14 @@
214289 fts5DecodePoslist(&rc, &s, &a[4], iOff-4);
214290
214291 /* Decode any more doclist data that appears on the page before the
214292 ** first term. */
214293 nDoclist = (iTermOff ? iTermOff : szLeaf) - iOff;
214294 if( nDoclist+iOff>n ){
214295 rc = FTS5_CORRUPT;
214296 goto decode_out;
214297 }
214298 fts5DecodeDoclist(&rc, &s, &a[iOff], nDoclist);
214299
214300 while( iPgidxOff<n && rc==SQLITE_OK ){
214301 int bFirst = (iPgidxOff==szLeaf); /* True for first term on page */
214302 int nByte; /* Bytes of data */
@@ -214617,11 +214711,11 @@
214711 p->ts.iSavepoint = iSavepoint-1;
214712 break;
214713
214714 case FTS5_ROLLBACKTO:
214715 assert( p->ts.eState==1 );
214716 assert( iSavepoint>=-1 );
214717 assert( iSavepoint<=p->ts.iSavepoint );
214718 p->ts.iSavepoint = iSavepoint;
214719 break;
214720 }
214721 }
@@ -216977,11 +217071,11 @@
217071 int nArg, /* Number of args */
217072 sqlite3_value **apUnused /* Function arguments */
217073 ){
217074 assert( nArg==0 );
217075 UNUSED_PARAM2(nArg, apUnused);
217076 sqlite3_result_text(pCtx, "fts5: 2019-02-05 19:52:39 2f468da4e9fb3edb5e902fa5d3c528726d1fb64d749d29e558ba3243c76bcb95", -1, SQLITE_TRANSIENT);
217077 }
217078
217079 /*
217080 ** Return true if zName is the extension on one of the shadow tables used
217081 ** by this module.
@@ -221741,12 +221835,12 @@
221835 }
221836 #endif /* SQLITE_CORE */
221837 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
221838
221839 /************** End of stmt.c ************************************************/
221840 #if __LINE__!=221840
221841 #undef SQLITE_SOURCE_ID
221842 #define SQLITE_SOURCE_ID "2019-02-05 20:51:41 4d0a949fd92e19fbf243a2e3a1a7c2cdb111f9a6943949d2420dd846bc7dalt2"
221843 #endif
221844 /* Return the source-id for this library */
221845 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
221846 /************************** End of sqlite3.c ******************************/
221847
+3 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126126
#define SQLITE_VERSION "3.27.0"
127127
#define SQLITE_VERSION_NUMBER 3027000
128
-#define SQLITE_SOURCE_ID "2019-02-01 15:06:27 4ca9d5d53d41d08fbce29f9da8cc0948df9c4c3136210af88b499cf889b5ccb8"
128
+#define SQLITE_SOURCE_ID "2019-02-05 20:51:41 4d0a949fd92e19fbf243a2e3a1a7c2cdb111f9a6943949d2420dd846bc7d9285"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
@@ -3427,10 +3427,12 @@
34273427
** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and
34283428
** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
34293429
** is not a database file pathname pointer that SQLite passed into the xOpen
34303430
** VFS method, then the behavior of this routine is undefined and probably
34313431
** undesirable.
3432
+**
3433
+** See the [URI filename] documentation for additional information.
34323434
*/
34333435
SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
34343436
SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
34353437
SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
34363438
34373439
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.27.0"
127 #define SQLITE_VERSION_NUMBER 3027000
128 #define SQLITE_SOURCE_ID "2019-02-01 15:06:27 4ca9d5d53d41d08fbce29f9da8cc0948df9c4c3136210af88b499cf889b5ccb8"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -3427,10 +3427,12 @@
3427 ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and
3428 ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
3429 ** is not a database file pathname pointer that SQLite passed into the xOpen
3430 ** VFS method, then the behavior of this routine is undefined and probably
3431 ** undesirable.
 
 
3432 */
3433 SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3434 SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3435 SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3436
3437
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.27.0"
127 #define SQLITE_VERSION_NUMBER 3027000
128 #define SQLITE_SOURCE_ID "2019-02-05 20:51:41 4d0a949fd92e19fbf243a2e3a1a7c2cdb111f9a6943949d2420dd846bc7d9285"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -3427,10 +3427,12 @@
3427 ** If F is a NULL pointer, then sqlite3_uri_parameter(F,P) returns NULL and
3428 ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
3429 ** is not a database file pathname pointer that SQLite passed into the xOpen
3430 ** VFS method, then the behavior of this routine is undefined and probably
3431 ** undesirable.
3432 **
3433 ** See the [URI filename] documentation for additional information.
3434 */
3435 SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3436 SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3437 SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3438
3439

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button