Fossil SCM

Merge the latest trunk version of SQLite, including the new CLI prompt enhancement. Configure the prompt to be "FossilSQL REPONAME>" for the "fossil sql" command.

drh 2026-04-12 00:01 trunk
Commit 3361df86b3ba75322d997ad86f1ab87e353b62cedd1a0d612b83248b559332cf
+2 -2
--- extsrc/qrf.h
+++ extsrc/qrf.h
@@ -7,12 +7,12 @@
77
** May you do good and not evil.
88
** May you find forgiveness for yourself and forgive others.
99
** May you share freely, never taking more than you give.
1010
**
1111
*************************************************************************
12
-** Header file for the Result-Format or "resfmt" utility library for SQLite.
13
-** See the README.md documentation for additional information.
12
+** Header file for the Query Result-Format or "qrf" utility library for
13
+** SQLite. See the README.md documentation for additional information.
1414
*/
1515
#ifndef SQLITE_QRF_H
1616
#define SQLITE_QRF_H
1717
#ifdef __cplusplus
1818
extern "C" {
1919
--- extsrc/qrf.h
+++ extsrc/qrf.h
@@ -7,12 +7,12 @@
7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give.
10 **
11 *************************************************************************
12 ** Header file for the Result-Format or "resfmt" utility library for SQLite.
13 ** See the README.md documentation for additional information.
14 */
15 #ifndef SQLITE_QRF_H
16 #define SQLITE_QRF_H
17 #ifdef __cplusplus
18 extern "C" {
19
--- extsrc/qrf.h
+++ extsrc/qrf.h
@@ -7,12 +7,12 @@
7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give.
10 **
11 *************************************************************************
12 ** Header file for the Query Result-Format or "qrf" utility library for
13 ** SQLite. See the README.md documentation for additional information.
14 */
15 #ifndef SQLITE_QRF_H
16 #define SQLITE_QRF_H
17 #ifdef __cplusplus
18 extern "C" {
19
+463 -270
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -682,12 +682,12 @@
682682
** May you do good and not evil.
683683
** May you find forgiveness for yourself and forgive others.
684684
** May you share freely, never taking more than you give.
685685
**
686686
*************************************************************************
687
-** Header file for the Result-Format or "resfmt" utility library for SQLite.
688
-** See the README.md documentation for additional information.
687
+** Header file for the Query Result-Format or "qrf" utility library for
688
+** SQLite. See the README.md documentation for additional information.
689689
*/
690690
#ifndef SQLITE_QRF_H
691691
#define SQLITE_QRF_H
692692
#ifdef __cplusplus
693693
extern "C" {
@@ -886,21 +886,23 @@
886886
** May you do good and not evil.
887887
** May you find forgiveness for yourself and forgive others.
888888
** May you share freely, never taking more than you give.
889889
**
890890
*************************************************************************
891
-** Implementation of the Result-Format or "qrf" utility library for SQLite.
892
-** See the qrf.md documentation for additional information.
891
+** Implementation of the Query Result-Format or "qrf" utility library for
892
+** SQLite. See the README.md documentation for additional information.
893893
*/
894894
#ifndef SQLITE_QRF_H
895895
#include "qrf.h"
896896
#endif
897897
#include <string.h>
898898
#include <assert.h>
899899
#include <stdint.h>
900900
901
+#ifndef SQLITE_AMALGAMATION
901902
/* typedef sqlite3_int64 i64; */
903
+#endif
902904
903905
/* A single line in the EQP output */
904906
typedef struct qrfEQPGraphRow qrfEQPGraphRow;
905907
struct qrfEQPGraphRow {
906908
int iEqpId; /* ID for this row */
@@ -3676,19 +3678,21 @@
36763678
break;
36773679
}
36783680
case QRF_STYLE_Eqp: {
36793681
int expMode = sqlite3_stmt_isexplain(p->pStmt);
36803682
if( expMode!=2 ){
3681
- sqlite3_stmt_explain(p->pStmt, 2);
3683
+ int rc = sqlite3_stmt_explain(p->pStmt, 2);
3684
+ if( rc ){ qrfError(p, SQLITE_ERROR, sqlite3_errstr(rc)); }
36823685
p->expMode = expMode+1;
36833686
}
36843687
break;
36853688
}
36863689
case QRF_STYLE_Explain: {
36873690
int expMode = sqlite3_stmt_isexplain(p->pStmt);
36883691
if( expMode!=1 ){
3689
- sqlite3_stmt_explain(p->pStmt, 1);
3692
+ int rc = sqlite3_stmt_explain(p->pStmt, 1);
3693
+ if( rc ){ qrfError(p, SQLITE_ERROR, sqlite3_errstr(rc)); }
36903694
p->expMode = expMode+1;
36913695
}
36923696
break;
36933697
}
36943698
}
@@ -3843,10 +3847,11 @@
38433847
){
38443848
Qrf qrf; /* The new Qrf being created */
38453849
38463850
if( pStmt==0 ) return SQLITE_OK; /* No-op */
38473851
if( pSpec==0 ) return SQLITE_MISUSE;
3852
+ if( sqlite3_stmt_busy(pStmt) ) return SQLITE_BUSY;
38483853
qrfInitialize(&qrf, pStmt, pSpec, pzErr);
38493854
switch( qrf.spec.eStyle ){
38503855
case QRF_STYLE_Box:
38513856
case QRF_STYLE_Column:
38523857
case QRF_STYLE_Markdown:
@@ -23628,11 +23633,10 @@
2362823633
/* Flags for Mode.mFlags */
2362923634
#define MFLG_ECHO 0x01 /* Echo inputs to output */
2363023635
#define MFLG_CRLF 0x02 /* Use CR/LF output line endings */
2363123636
#define MFLG_HDR 0x04 /* .header used to change headers on/off */
2363223637
23633
-
2363423638
/*
2363523639
** State information about the database connection is contained in an
2363623640
** instance of the following structure.
2363723641
*/
2363823642
typedef struct ShellState ShellState;
@@ -23670,14 +23674,13 @@
2367023674
unsigned nTestErr; /* Number of test cases that failed */
2367123675
sqlite3_int64 szMax; /* --maxsize argument to .open */
2367223676
char *zDestTable; /* Name of destination table when MODE_Insert */
2367323677
char *zTempFile; /* Temporary file that might need deleting */
2367423678
char *zErrPrefix; /* Alternative error message prefix */
23675
- char zTestcase[30]; /* Name of current test case */
23676
- char outfile[FILENAME_MAX]; /* Filename for *out */
2367723679
sqlite3_stmt *pStmt; /* Current statement if any. */
2367823680
FILE *pLog; /* Write log output here */
23681
+ char *azPrompt[2]; /* Main and continuation prompt strings */
2367923682
Mode mode; /* Current display mode */
2368023683
Mode modePrior; /* Backup */
2368123684
struct SavedMode { /* Ability to define custom mode configurations */
2368223685
char *zTag; /* Name of this saved mode */
2368323686
Mode mode; /* The saved mode */
@@ -23685,10 +23688,11 @@
2368523688
int nSavedModes; /* Number of saved .mode settings */
2368623689
struct AuxDb { /* Storage space for auxiliary database connections */
2368723690
sqlite3 *db; /* Connection pointer */
2368823691
const char *zDbFilename; /* Filename used to open the connection */
2368923692
char *zFreeOnClose; /* Free this memory allocation on close */
23693
+ int mFlgs; /* 0x001: Use zDbFilenaem for prompt */
2369023694
#if defined(SQLITE_ENABLE_SESSION)
2369123695
int nSession; /* Number of active sessions */
2369223696
OpenSession aSession[4]; /* Array of sessions. [0] is in focus. */
2369323697
#endif
2369423698
} aAuxDb[5], /* Array of all database connections */
@@ -23711,10 +23715,12 @@
2371123715
const char * zInput; /* Input string from wasm/JS proxy */
2371223716
const char * zPos; /* Cursor pos into zInput */
2371323717
const char * zDefaultDbName; /* Default name for db file */
2371423718
} wasm;
2371523719
#endif
23720
+ char zTestcase[30]; /* Name of current test case */
23721
+ char outfile[FILENAME_MAX]; /* Filename for *out */
2371623722
};
2371723723
2371823724
#ifdef SQLITE_SHELL_FIDDLE
2371923725
static ShellState shellState;
2372023726
#endif
@@ -23947,20 +23953,10 @@
2394723953
** This is the name of our program. It is set in main(), used
2394823954
** in a number of other places, mostly for error messages.
2394923955
*/
2395023956
static char *Argv0;
2395123957
23952
-/*
23953
-** Prompt strings. Initialized in main. Settable with
23954
-** .prompt main continue
23955
-*/
23956
-#define PROMPT_LEN_MAX 128
23957
-/* First line prompt. default: "sqlite> " */
23958
-static char mainPrompt[PROMPT_LEN_MAX];
23959
-/* Continuation prompt. default: " ...> " */
23960
-static char continuePrompt[PROMPT_LEN_MAX];
23961
-
2396223958
/*
2396323959
** Write I/O traces to the following stream.
2396423960
*/
2396523961
#ifdef SQLITE_ENABLE_IOTRACE
2396623962
static FILE *iotrace = 0;
@@ -24070,118 +24066,10 @@
2407024066
(void)gettimeofday(&sNow,0);
2407124067
return ((i64)sNow.tv_sec)*1000000 + sNow.tv_usec;
2407224068
#endif
2407324069
}
2407424070
24075
-
24076
-
24077
-/* This is variant of the standard-library strncpy() routine with the
24078
-** one change that the destination string is always zero-terminated, even
24079
-** if there is no zero-terminator in the first n-1 characters of the source
24080
-** string.
24081
-*/
24082
-static char *shell_strncpy(char *dest, const char *src, size_t n){
24083
- size_t i;
24084
- for(i=0; i<n-1 && src[i]!=0; i++) dest[i] = src[i];
24085
- dest[i] = 0;
24086
- return dest;
24087
-}
24088
-
24089
-/*
24090
-** strcpy() workalike to squelch an unwarranted link-time warning
24091
-** from OpenBSD.
24092
-*/
24093
-static void shell_strcpy(char *dest, const char *src){
24094
- while( (*(dest++) = *(src++))!=0 ){}
24095
-}
24096
-
24097
-/*
24098
-** Optionally disable dynamic continuation prompt.
24099
-** Unless disabled, the continuation prompt shows open SQL lexemes if any,
24100
-** or open parentheses level if non-zero, or continuation prompt as set.
24101
-** This facility interacts with the scanner and process_input() where the
24102
-** below 5 macros are used.
24103
-*/
24104
-#ifdef SQLITE_OMIT_DYNAPROMPT
24105
-# define CONTINUATION_PROMPT continuePrompt
24106
-# define CONTINUE_PROMPT_RESET
24107
-# define CONTINUE_PROMPT_AWAITS(p,s)
24108
-# define CONTINUE_PROMPT_AWAITC(p,c)
24109
-# define CONTINUE_PAREN_INCR(p,n)
24110
-# define CONTINUE_PROMPT_PSTATE 0
24111
-typedef void *t_NoDynaPrompt;
24112
-# define SCAN_TRACKER_REFTYPE t_NoDynaPrompt
24113
-#else
24114
-# define CONTINUATION_PROMPT dynamicContinuePrompt()
24115
-# define CONTINUE_PROMPT_RESET \
24116
- do {setLexemeOpen(&dynPrompt,0,0); trackParenLevel(&dynPrompt,0);} while(0)
24117
-# define CONTINUE_PROMPT_AWAITS(p,s) \
24118
- if(p && stdin_is_interactive) setLexemeOpen(p, s, 0)
24119
-# define CONTINUE_PROMPT_AWAITC(p,c) \
24120
- if(p && stdin_is_interactive) setLexemeOpen(p, 0, c)
24121
-# define CONTINUE_PAREN_INCR(p,n) \
24122
- if(p && stdin_is_interactive) (trackParenLevel(p,n))
24123
-# define CONTINUE_PROMPT_PSTATE (&dynPrompt)
24124
-typedef struct DynaPrompt *t_DynaPromptRef;
24125
-# define SCAN_TRACKER_REFTYPE t_DynaPromptRef
24126
-
24127
-static struct DynaPrompt {
24128
- char dynamicPrompt[PROMPT_LEN_MAX];
24129
- char acAwait[2];
24130
- int inParenLevel;
24131
- char *zScannerAwaits;
24132
-} dynPrompt = { {0}, {0}, 0, 0 };
24133
-
24134
-/* Record parenthesis nesting level change, or force level to 0. */
24135
-static void trackParenLevel(struct DynaPrompt *p, int ni){
24136
- p->inParenLevel += ni;
24137
- if( ni==0 ) p->inParenLevel = 0;
24138
- p->zScannerAwaits = 0;
24139
-}
24140
-
24141
-/* Record that a lexeme is opened, or closed with args==0. */
24142
-static void setLexemeOpen(struct DynaPrompt *p, char *s, char c){
24143
- if( s!=0 || c==0 ){
24144
- p->zScannerAwaits = s;
24145
- p->acAwait[0] = 0;
24146
- }else{
24147
- p->acAwait[0] = c;
24148
- p->zScannerAwaits = p->acAwait;
24149
- }
24150
-}
24151
-
24152
-/* Upon demand, derive the continuation prompt to display. */
24153
-static char *dynamicContinuePrompt(void){
24154
- if( continuePrompt[0]==0
24155
- || (dynPrompt.zScannerAwaits==0 && dynPrompt.inParenLevel == 0) ){
24156
- return continuePrompt;
24157
- }else{
24158
- if( dynPrompt.zScannerAwaits ){
24159
- size_t ncp = strlen(continuePrompt);
24160
- size_t ndp = strlen(dynPrompt.zScannerAwaits);
24161
- if( ndp > ncp-3 ) return continuePrompt;
24162
- shell_strcpy(dynPrompt.dynamicPrompt, dynPrompt.zScannerAwaits);
24163
- while( ndp<3 ) dynPrompt.dynamicPrompt[ndp++] = ' ';
24164
- shell_strncpy(dynPrompt.dynamicPrompt+3, continuePrompt+3,
24165
- PROMPT_LEN_MAX-4);
24166
- }else{
24167
- if( dynPrompt.inParenLevel>9 ){
24168
- shell_strncpy(dynPrompt.dynamicPrompt, "(..", 4);
24169
- }else if( dynPrompt.inParenLevel<0 ){
24170
- shell_strncpy(dynPrompt.dynamicPrompt, ")x!", 4);
24171
- }else{
24172
- shell_strncpy(dynPrompt.dynamicPrompt, "(x.", 4);
24173
- dynPrompt.dynamicPrompt[2] = (char)('0'+dynPrompt.inParenLevel);
24174
- }
24175
- shell_strncpy(dynPrompt.dynamicPrompt+3, continuePrompt+3,
24176
- PROMPT_LEN_MAX-4);
24177
- }
24178
- }
24179
- return dynPrompt.dynamicPrompt;
24180
-}
24181
-#endif /* !defined(SQLITE_OMIT_DYNAPROMPT) */
24182
-
2418324071
/* Indicate out-of-memory and exit. */
2418424072
static void shell_out_of_memory(void){
2418524073
eputz("Error: out of memory\n");
2418624074
cli_exit(1);
2418724075
}
@@ -24296,34 +24184,299 @@
2429624184
break;
2429724185
}
2429824186
}
2429924187
return zLine;
2430024188
}
24189
+
24190
+/*
24191
+** The default prompts.
24192
+*/
24193
+#ifndef SQLITE_PS1
24194
+# define SQLITE_PS1 "SQLite /f> "
24195
+#endif
24196
+#ifndef SQLITE_PS2
24197
+# define SQLITE_PS2 "/B.../H> "
24198
+#endif
24199
+
24200
+/*
24201
+** Return the raw (unexpanded) prompt string. This will be the
24202
+** first of the following that exist:
24203
+**
24204
+** * The prompt string specified by the ".prompt" command.
24205
+** * The value of the SQLITE_PS1 (or SQLITE_PS2) environment variable.
24206
+** * The default prompt string.
24207
+**
24208
+** The main prompt is returned if the argument is zero and the
24209
+** continuation prompt is returned if the argument is 1.
24210
+*/
24211
+static const char *prompt_string(ShellState *p, int bContinue){
24212
+ const char *zPS;
24213
+ assert( bContinue==0 || bContinue==1 );
24214
+ if( p->azPrompt[bContinue] ){
24215
+ return p->azPrompt[bContinue];
24216
+ }
24217
+#ifndef SQLITE_SHELL_FIDDLE
24218
+ zPS = getenv(bContinue ? "SQLITE_PS2" : "SQLITE_PS1");
24219
+ if( zPS ) return zPS;
24220
+#endif
24221
+ if( bContinue ){
24222
+ return SQLITE_PS2;
24223
+ }else{
24224
+ return SQLITE_PS1;
24225
+ }
24226
+}
24227
+
24228
+/*
24229
+** Return the name of the open database file, to be used for prompt
24230
+** expansion purposes.
24231
+*/
24232
+static const char *prompt_filename(ShellState *p){
24233
+ sqlite3_filename pFN;
24234
+ const char *zFN = 0;
24235
+ if( p->pAuxDb->mFlgs & 0x01 ){
24236
+ zFN = p->pAuxDb->zDbFilename;
24237
+ }else if( p->db && (pFN = sqlite3_db_filename(p->db,0))!=0 ){
24238
+ zFN = sqlite3_filename_database(pFN);
24239
+ }
24240
+ if( zFN==0 || zFN[0]==0 ){
24241
+ zFN = "in-memory";
24242
+ }
24243
+ return zFN;
24244
+}
24245
+
24246
+/*
24247
+** Expand escapes in the given input prompt string. Return the
24248
+** expanded prompt in memory obtained from sqlite3_malloc(). The
24249
+** caller is responsible for freeing the memory.
24250
+**
24251
+** Early prototypes use U+005c '\\' as the escape character. But
24252
+** that is an escape character for shells and C and many other languages,
24253
+** which can lead to nested quoting problems and confusion. The
24254
+** U+0025 '%' character was also tried, and that works pretty well on
24255
+** unix, but % is special to many formats on Windows. So now we
24256
+** use a forward-slash, U+002f '/', which seems to pass through
24257
+** every shell and "make" without issue.
24258
+*/
24259
+static char *expand_prompt(
24260
+ ShellState *p, /* The current shell state */
24261
+ const char *zPrior, /* Prior input lines not yet processed */
24262
+ const char *zPrompt /* Prompt string to be expanded */
24263
+){
24264
+ sqlite3_str *pOut = sqlite3_str_new(0);
24265
+ int i;
24266
+ char c;
24267
+ int onoff = 1;
24268
+ int idxSpace = -1;
24269
+ for(i=0; zPrompt[i]; i++){
24270
+ if( zPrompt[i]!='/' ) continue;
24271
+ if( i>0 ){
24272
+ if( onoff ) sqlite3_str_append(pOut, zPrompt, i);
24273
+ zPrompt += i;
24274
+ i = 0;
24275
+ }
24276
+ /* At this point zPrompt[0] is a / character and all prior
24277
+ ** characters have already been loaded into pOut. Process the
24278
+ ** escape sequence that zPrompt points to. */
24279
+ c = zPrompt[1];
24280
+ if( c==0 ){
24281
+ /* / at the end of a line is silently ignored */
24282
+ break;
24283
+ }
24284
+ if( c=='/' ){
24285
+ /* // maps into a single / */
24286
+ zPrompt++;
24287
+ continue;
24288
+ }
24289
+ if( c>='0' && c<='7' ){
24290
+ /* /nnn becomes a single byte given by octal nnn */
24291
+ int v = c - '0';
24292
+ while( i<=2 && zPrompt[i+1]>='0' && zPrompt[i+1]<='7' ){
24293
+ v = v*8 + zPrompt[++i] - '0';
24294
+ }
24295
+ if( onoff ) sqlite3_str_appendchar(pOut, 1, v);
24296
+ zPrompt += i+1;
24297
+ i = -1;
24298
+ continue;
24299
+ }
24300
+ if( c=='e' ){
24301
+ /* /e is shorthand for /033 which is U+001B "Escape" */
24302
+ if( onoff ) sqlite3_str_append(pOut, "\033", 1);
24303
+ zPrompt += 2;
24304
+ i = -1;
24305
+ continue;
24306
+ }
24307
+
24308
+ /* The intent of the following codes it to provide alternative
24309
+ ** text displays depending on whether or not the connection is
24310
+ ** currently in a transaction. Example 1: Show a "*" before the ">"
24311
+ ** like psql: (Note: We encode the "*" as /052 to avoid closing
24312
+ ** out this comment.)
24313
+ **
24314
+ ** .prompt 'sqlite/x/052/;> '
24315
+ **
24316
+ ** Example 2: Show database filename is blue if not in a transaction,
24317
+ ** or red if within a transaction:
24318
+ **
24319
+ ** .prompt '/e[1;/x31/:34/;m~f>/e[0m '
24320
+ */
24321
+ if( c==':' ){
24322
+ /* toggle display on/off */
24323
+ onoff = !onoff;
24324
+ zPrompt += 2;
24325
+ i = -1;
24326
+ continue;
24327
+ }
24328
+ if( c==';' ){
24329
+ /* Turn display on */
24330
+ onoff = 1;
24331
+ zPrompt += 2;
24332
+ i = -1;
24333
+ continue;
24334
+ }
24335
+ if( c=='x' ){
24336
+ /* /x turns display off not in a transaction, on if in txn */
24337
+ onoff = p->db && !sqlite3_get_autocommit(p->db);
24338
+ zPrompt += 2;
24339
+ i = -1;
24340
+ continue;
24341
+ }
24342
+
24343
+ if( c=='f' || c=='F' || c=='~' ){
24344
+ /* /f becomes the tail of the database filename */
24345
+ /* /F becomes the full pathname */
24346
+ /* /~ becomes the full pathname relative to $HOME */
24347
+ if( onoff ){
24348
+ const char *zFN = prompt_filename(p);
24349
+ if( c=='f' ){
24350
+#ifdef _WIN32
24351
+ const char *zTail = strrchr(zFN,'\\');
24352
+#else
24353
+ const char *zTail = strrchr(zFN,'/');
24354
+#endif
24355
+ if( zTail && zTail[1] ) zFN = &zTail[1];
24356
+ }else if( c=='~' ){
24357
+ const char *zHOME = getenv("HOME");
24358
+ size_t nHOME = zHOME ? strlen(zHOME) : 0;
24359
+ if( nHOME<strlen(zFN)
24360
+ && zHOME!=0 && zFN!=0 /* <--- these silence compiler warnings */
24361
+ && memcmp(zHOME,zFN,nHOME)==0
24362
+ ){
24363
+ sqlite3_str_append(pOut,"~",1);
24364
+ zFN += nHOME;
24365
+ }
24366
+ }
24367
+ sqlite3_str_appendall(pOut, zFN);
24368
+ }
24369
+ zPrompt += 2;
24370
+ i = -1;
24371
+ continue;
24372
+ }
24373
+
24374
+ if( c=='H' ){
24375
+ /* /H becomes text needed to terminate current input */
24376
+ if( onoff ){
24377
+ sqlite3_int64 R = zPrior ? sqlite3_incomplete(zPrior) : 0;
24378
+ int cc = (R>>16)&0xff;
24379
+ int nParen = R>>32;
24380
+ int eSemi = (R>>8)&0xff;
24381
+ if( cc==0 ){
24382
+ /* no-op */
24383
+ }else if( cc=='-' ){
24384
+ sqlite3_str_append(pOut,"\\n",3);
24385
+ }else if( cc=='/' ){
24386
+ sqlite3_str_append(pOut,"*/",2);
24387
+ }else{
24388
+ sqlite3_str_appendchar(pOut, 1, cc);
24389
+ }
24390
+ if( nParen>0 ){
24391
+ sqlite3_str_appendf(pOut, "%.*c",nParen,')');
24392
+ }
24393
+ if( eSemi==1 ){
24394
+ sqlite3_str_append(pOut, ";", 1);
24395
+ }else if( eSemi==2 ){
24396
+ sqlite3_str_append(pOut, "END;", 4);
24397
+ }else if( eSemi==3 ){
24398
+ sqlite3_str_append(pOut, ";END;", 5);
24399
+ }
24400
+ }
24401
+ zPrompt += 2;
24402
+ i = -1;
24403
+ continue;
24404
+ }
24405
+
24406
+ if( c=='B' ){
24407
+ /* /B is a no-op for the main prompt. For the continuation prompt,
24408
+ ** /B expands to zero or more spaces to make the continuation prompt
24409
+ ** at least as wide as the main prompt. */
24410
+ if( onoff ) idxSpace = sqlite3_str_length(pOut);
24411
+ zPrompt += 2;
24412
+ i = -1;
24413
+ continue;
24414
+ }
24415
+
24416
+ /* No match to a known escape. Generate an error. */
24417
+ if( onoff ) sqlite3_str_appendf(pOut,"UNKNOWN(\"/%c\")",c);
24418
+ zPrompt += 2;
24419
+ i = -1;
24420
+ }
24421
+ if( i>0 && onoff ){
24422
+ sqlite3_str_append(pOut, zPrompt, i);
24423
+ }
24424
+
24425
+ /* Expand the /B, if there is one and if this is a continuation prompt */
24426
+ if( idxSpace>=0 && zPrior!=0 && zPrior[0]!=0 ){
24427
+ char *zOther = expand_prompt(p, 0, prompt_string(p,0));
24428
+ size_t wOther = sqlite3_qrf_wcswidth(zOther);
24429
+ size_t wThis = sqlite3_qrf_wcswidth(sqlite3_str_value(pOut));
24430
+ sqlite3_free(zOther);
24431
+ if( wOther>wThis ){
24432
+ char *z;
24433
+ int len;
24434
+ size_t nNew = wOther - wThis;
24435
+ assert( nNew>0 && nNew<0x7fffffff );
24436
+ sqlite3_str_appendchar(pOut, (int)nNew, ' ');
24437
+ len = sqlite3_str_length(pOut);
24438
+ if( len>idxSpace ){
24439
+ z = sqlite3_str_value(pOut);
24440
+ memmove(z+idxSpace+nNew, z+idxSpace, len-nNew-idxSpace);
24441
+ memset(z+idxSpace, ' ', nNew);
24442
+ }
24443
+ }
24444
+ }
24445
+
24446
+ return sqlite3_str_finish(pOut);
24447
+}
2430124448
2430224449
/*
2430324450
** Retrieve a single line of input text.
2430424451
**
2430524452
** If in==0 then read from standard input and prompt before each line.
24306
-** If isContinuation is true, then a continuation prompt is appropriate.
24307
-** If isContinuation is zero, then the main prompt should be used.
24453
+** If bContinue is true, then a continuation prompt is appropriate.
24454
+** If bContinue is zero, then the main prompt should be used.
2430824455
**
2430924456
** If zPrior is not NULL then it is a buffer from a prior call to this
2431024457
** routine that can be reused.
2431124458
**
2431224459
** The result is stored in space obtained from malloc() and must either
2431324460
** be freed by the caller or else passed back into this routine via the
2431424461
** zPrior argument for reuse.
2431524462
*/
2431624463
#ifndef SQLITE_SHELL_FIDDLE
24317
-static char *one_input_line(ShellState *p, char *zPrior, int isContinuation){
24318
- char *zPrompt;
24464
+static char *one_input_line(
24465
+ ShellState *p, /* Shell state */
24466
+ char *zPrior, /* Just the previous line */
24467
+ const char *zAll, /* All statement text accumulated so far */
24468
+ int bContinue /* True for a continuation prompt */
24469
+){
2431924470
char *zResult;
2432024471
FILE *in = p->in;
2432124472
if( in!=0 ){
2432224473
zResult = local_getline(zPrior, in);
2432324474
}else{
24324
- zPrompt = isContinuation ? CONTINUATION_PROMPT : mainPrompt;
24475
+ const char *zBase = prompt_string(p, bContinue!=0);
24476
+ char *zPrompt = expand_prompt(p, zAll, zBase);
24477
+ shell_check_oom(zPrompt);
2432524478
#if SHELL_USE_LOCAL_GETLINE
2432624479
sputz(stdout, zPrompt);
2432724480
fflush(stdout);
2432824481
do{
2432924482
zResult = local_getline(zPrior, stdin);
@@ -24340,10 +24493,11 @@
2434024493
if( seenInterrupt==0 ) break;
2434124494
zResult = shell_readline("");
2434224495
}
2434324496
if( zResult && *zResult ) shell_add_history(zResult);
2434424497
#endif
24498
+ sqlite3_free(zPrompt);
2434524499
}
2434624500
return zResult;
2434724501
}
2434824502
#endif /* !SQLITE_SHELL_FIDDLE */
2434924503
@@ -24660,10 +24814,58 @@
2466024814
}
2466124815
}
2466224816
sqlite3_result_value(pCtx, apVal[0]);
2466324817
}
2466424818
24819
+/*
24820
+** SQL function: shell_prompt_test(PROMPT)
24821
+** shell_prompt_test(PROMPT,PRIOR)
24822
+** shell_prompt_test(PROMPT,PRIOR,FILENAME)
24823
+**
24824
+** Return the shell prompt, with escapes expanded, for testing purposes.
24825
+** The first argument is the raw (unexpanded) prompt string. Or if the
24826
+** first argument is NULL, then use whatever prompt string is currently
24827
+** configured. If the second argument exists and is not NULL, then the
24828
+** second argument is understood to be prior incomplete text and a
24829
+** continuation prompt is generated. If a third argument is provided,
24830
+** it is assumed to be the full pathname of the database file.
24831
+*/
24832
+static void shellExpandPrompt(
24833
+ sqlite3_context *pCtx,
24834
+ int nVal,
24835
+ sqlite3_value **apVal
24836
+){
24837
+ ShellState *p = (ShellState*)sqlite3_user_data(pCtx);
24838
+ const char *zPrompt;
24839
+ const char *zPrior;
24840
+ const char *zSavedDbFile;
24841
+ int mSavedFlgs;
24842
+ const char *zFName;
24843
+ char *zRes;
24844
+
24845
+ if( nVal<2
24846
+ || (zPrior = (const char*)sqlite3_value_text(apVal[1]))==0
24847
+ || zPrior[0]==0
24848
+ ){
24849
+ zPrior = 0;
24850
+ }
24851
+ zPrompt = (const char*)sqlite3_value_text(apVal[0]);
24852
+ if( zPrompt==0 ){
24853
+ zPrompt = prompt_string(p, zPrior!=0);
24854
+ }
24855
+ zSavedDbFile = p->pAuxDb->zDbFilename;
24856
+ mSavedFlgs = p->pAuxDb->mFlgs;
24857
+ if( nVal>=3 && (zFName = (const char*)sqlite3_value_text(apVal[2]))!=0 ){
24858
+ p->pAuxDb->zDbFilename = zFName;
24859
+ p->pAuxDb->mFlgs |= 0x001;
24860
+ }
24861
+ zRes = expand_prompt(p, zPrior, zPrompt);
24862
+ p->pAuxDb->zDbFilename = zSavedDbFile;
24863
+ p->pAuxDb->mFlgs = mSavedFlgs;
24864
+ sqlite3_result_text(pCtx, zRes, -1, SQLITE_TRANSIENT);
24865
+ sqlite3_free(zRes);
24866
+}
2466524867
2466624868
/************************* BEGIN PERFORMANCE TIMER *****************************/
2466724869
#if !defined(_WIN32) && !defined(WIN32) && !defined(__minux)
2466824870
#include <sys/time.h>
2466924871
#include <sys/resource.h>
@@ -27137,11 +27339,14 @@
2713727339
" --once Do no more than one progress interrupt",
2713827340
" --quiet|-q No output except at interrupts",
2713927341
" --reset Reset the count for each input and interrupt",
2714027342
" --timeout S Halt after running for S seconds",
2714127343
#endif
27142
- ".prompt MAIN CONTINUE Replace the standard prompts",
27344
+ ".prompt MAIN CONTINUE Replace the standard prompts",
27345
+ " --reset Revert to default prompts",
27346
+ " --show Show the current prompt strings",
27347
+ " -- No more options. Subsequent args are prompts",
2714327348
#ifndef SQLITE_SHELL_FIDDLE
2714427349
".quit Stop interpreting input stream, exit if primary.",
2714527350
".read FILE Read input from FILE or command output",
2714627351
" If FILE begins with \"|\", it is a command that generates the input.",
2714727352
#endif
@@ -27934,10 +28139,35 @@
2793428139
** the database fails to open, print an error message and exit.
2793528140
*/
2793628141
static void open_db(ShellState *p, int openFlags){
2793728142
if( p->db==0 ){
2793828143
const char *zDbFilename = p->pAuxDb->zDbFilename;
28144
+ const char *zHOME; /* Value of HOME environment variable */
28145
+ char *zToFree = 0; /* Filename with ~/ prefix expansion */
28146
+
28147
+ /* If the zDbFilename does not exist and begins with ~/ then replace
28148
+ ** the ~ with the home directory.
28149
+ */
28150
+ if( zDbFilename && zDbFilename[0]=='~'
28151
+#ifdef _WIN32
28152
+ && (zDbFilename[1]=='/' || zDbFilename[1]=='\\')
28153
+#else
28154
+ && zDbFilename[1]=='/'
28155
+#endif
28156
+ && access(zDbFilename,0)!=0
28157
+ && (zHOME = getenv("HOME"))!=0 && zHOME[0]!=0
28158
+ ){
28159
+ size_t nHOME = strlen(zHOME);
28160
+ size_t nFN = strlen(zDbFilename);
28161
+ zToFree = malloc(nHOME+nFN+1);
28162
+ if( zToFree ){
28163
+ memcpy(zToFree, zHOME, nHOME);
28164
+ memcpy(zToFree+nHOME, zDbFilename+1, nFN);
28165
+ zDbFilename = zToFree;
28166
+ }
28167
+ }
28168
+
2793928169
if( p->openMode==SHELL_OPEN_UNSPEC ){
2794028170
if( zDbFilename==0 || zDbFilename[0]==0 ){
2794128171
p->openMode = SHELL_OPEN_NORMAL;
2794228172
}else{
2794328173
p->openMode = (u8)deduceDatabaseType(zDbFilename,
@@ -28067,10 +28297,17 @@
2806728297
sqlite3_create_function(p->db, "edit", 1, SQLITE_UTF8, 0,
2806828298
editFunc, 0, 0);
2806928299
sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
2807028300
editFunc, 0, 0);
2807128301
#endif
28302
+ sqlite3_create_function(p->db, "shell_prompt_test", 1, SQLITE_UTF8,
28303
+ p, shellExpandPrompt, 0, 0);
28304
+ sqlite3_create_function(p->db, "shell_prompt_test", 2, SQLITE_UTF8,
28305
+ p, shellExpandPrompt, 0, 0);
28306
+ sqlite3_create_function(p->db, "shell_prompt_test", 3, SQLITE_UTF8,
28307
+ p, shellExpandPrompt, 0, 0);
28308
+
2807228309
2807328310
if( p->openMode==SHELL_OPEN_ZIPFILE ){
2807428311
char *zSql = sqlite3_mprintf(
2807528312
"CREATE VIRTUAL TABLE zip USING zipfile(%Q);", zDbFilename);
2807628313
shell_check_oom(zSql);
@@ -28100,10 +28337,11 @@
2810028337
if( p->szMax>0 ){
2810128338
sqlite3_file_control(p->db, "main", SQLITE_FCNTL_SIZE_LIMIT, &p->szMax);
2810228339
}
2810328340
}
2810428341
#endif
28342
+ free(zToFree);
2810528343
}
2810628344
if( p->db!=0 ){
2810728345
#ifndef SQLITE_OMIT_AUTHORIZATION
2810828346
if( p->bSafeModePersist ){
2810928347
sqlite3_set_authorizer(p->db, safeModeAuth, p);
@@ -33894,16 +34132,43 @@
3389434132
sqlite3_progress_handler(p->db, nn, progress_handler, p);
3389534133
}else
3389634134
#endif /* SQLITE_OMIT_PROGRESS_CALLBACK */
3389734135
3389834136
if( c=='p' && cli_strncmp(azArg[0], "prompt", n)==0 ){
33899
- if( nArg >= 2) {
33900
- shell_strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);
33901
- }
33902
- if( nArg >= 3) {
33903
- shell_strncpy(continuePrompt,azArg[2],(int)ArraySize(continuePrompt)-1);
33904
- }
34137
+ int i;
34138
+ int cnt = 0;
34139
+ int noOpt = 0;
34140
+ for(i=1; i<nArg; i++){
34141
+ const char *z = azArg[i];
34142
+ if( z[0]=='-' && !noOpt ){
34143
+ if( z[1]=='-' ) z++;
34144
+ if( strcmp(z,"-reset")==0 ){
34145
+ free(p->azPrompt[0]);
34146
+ free(p->azPrompt[1]);
34147
+ memset(p->azPrompt, 0, sizeof(p->azPrompt));
34148
+ }else
34149
+ if( strcmp(z,"-show")==0 ){
34150
+ cli_printf(stdout,"Main prompt: '%s'\n", prompt_string(p, 0));
34151
+ cli_printf(stdout,"Continuation: '%s'\n", prompt_string(p, 1));
34152
+ }else
34153
+ if( strcmp(z,"-")==0 ){
34154
+ noOpt = 1;
34155
+ }else
34156
+ {
34157
+ dotCmdError(p, i, "unknown option", 0);
34158
+ rc = 1;
34159
+ goto meta_command_exit;
34160
+ }
34161
+ }else if( cnt>1 ){
34162
+ dotCmdError(p, i, "extra argument", 0);
34163
+ rc = 1;
34164
+ goto meta_command_exit;
34165
+ }else{
34166
+ free(p->azPrompt[cnt]);
34167
+ p->azPrompt[cnt] = strdup(z);
34168
+ }
34169
+ }
3390534170
}else
3390634171
3390734172
#ifndef SQLITE_SHELL_FIDDLE
3390834173
if( c=='q' && cli_strncmp(azArg[0], "quit", n)==0 ){
3390934174
rc = 2;
@@ -35532,124 +35797,49 @@
3553235797
p->bSafeMode = p->bSafeModePersist;
3553335798
p->dot.nArg = 0;
3553435799
return rc;
3553535800
}
3553635801
35537
-/* Line scan result and intermediate states (supporting scan resumption)
35538
-*/
35539
-#ifndef CHAR_BIT
35540
-# define CHAR_BIT 8
35541
-#endif
35542
-typedef enum {
35543
- QSS_HasDark = 1<<CHAR_BIT, QSS_EndingSemi = 2<<CHAR_BIT,
35544
- QSS_CharMask = (1<<CHAR_BIT)-1, QSS_ScanMask = 3<<CHAR_BIT,
35545
- QSS_Start = 0
35546
-} QuickScanState;
35547
-#define QSS_SETV(qss, newst) ((newst) | ((qss) & QSS_ScanMask))
35548
-#define QSS_INPLAIN(qss) (((qss)&QSS_CharMask)==QSS_Start)
35549
-#define QSS_PLAINWHITE(qss) (((qss)&~QSS_EndingSemi)==QSS_Start)
35550
-#define QSS_PLAINDARK(qss) (((qss)&~QSS_EndingSemi)==QSS_HasDark)
35551
-#define QSS_SEMITERM(qss) (((qss)&~QSS_HasDark)==QSS_EndingSemi)
35552
-
35553
-/*
35554
-** Scan line for classification to guide shell's handling.
35555
-** The scan is resumable for subsequent lines when prior
35556
-** return values are passed as the 2nd argument.
35557
-*/
35558
-static QuickScanState quickscan(char *zLine, QuickScanState qss,
35559
- SCAN_TRACKER_REFTYPE pst){
35560
- char cin;
35561
- char cWait = (char)qss; /* intentional narrowing loss */
35562
- if( cWait==0 ){
35563
- PlainScan:
35564
- while( (cin = *zLine++)!=0 ){
35565
- if( IsSpace(cin) )
35566
- continue;
35567
- switch (cin){
35568
- case '-':
35569
- if( *zLine!='-' )
35570
- break;
35571
- while((cin = *++zLine)!=0 )
35572
- if( cin=='\n')
35573
- goto PlainScan;
35574
- return qss;
35575
- case ';':
35576
- qss |= QSS_EndingSemi;
35577
- continue;
35578
- case '/':
35579
- if( *zLine=='*' ){
35580
- ++zLine;
35581
- cWait = '*';
35582
- CONTINUE_PROMPT_AWAITS(pst, "/*");
35583
- qss = QSS_SETV(qss, cWait);
35584
- goto TermScan;
35585
- }
35586
- break;
35587
- case '[':
35588
- cin = ']';
35589
- deliberate_fall_through; /* FALLTHRU */
35590
- case '`': case '\'': case '"':
35591
- cWait = cin;
35592
- qss = QSS_HasDark | cWait;
35593
- CONTINUE_PROMPT_AWAITC(pst, cin);
35594
- goto TermScan;
35595
- case '(':
35596
- CONTINUE_PAREN_INCR(pst, 1);
35597
- break;
35598
- case ')':
35599
- CONTINUE_PAREN_INCR(pst, -1);
35600
- break;
35601
- default:
35602
- break;
35603
- }
35604
- qss = (qss & ~QSS_EndingSemi) | QSS_HasDark;
35605
- }
35606
- }else{
35607
- TermScan:
35608
- while( (cin = *zLine++)!=0 ){
35609
- if( cin==cWait ){
35610
- switch( cWait ){
35611
- case '*':
35612
- if( *zLine != '/' )
35613
- continue;
35614
- ++zLine;
35615
- CONTINUE_PROMPT_AWAITC(pst, 0);
35616
- qss = QSS_SETV(qss, 0);
35617
- goto PlainScan;
35618
- case '`': case '\'': case '"':
35619
- if(*zLine==cWait){
35620
- /* Swallow doubled end-delimiter.*/
35621
- ++zLine;
35622
- continue;
35623
- }
35624
- deliberate_fall_through; /* FALLTHRU */
35625
- case ']':
35626
- CONTINUE_PROMPT_AWAITC(pst, 0);
35627
- qss = QSS_SETV(qss, 0);
35628
- goto PlainScan;
35629
- default: assert(0);
35630
- }
35631
- }
35632
- }
35633
- }
35634
- return qss;
35802
+/*
35803
+** Test to see if a line consists entirely of whitespace.
35804
+*/
35805
+static int line_is_all_whitespace(const char *z){
35806
+ for(; *z; z++){
35807
+ if( IsSpace(z[0]) ) continue;
35808
+ if( *z=='/' && z[1]=='*' ){
35809
+ z += 2;
35810
+ while( *z && (*z!='*' || z[1]!='/') ){ z++; }
35811
+ if( *z==0 ) return 0;
35812
+ z++;
35813
+ continue;
35814
+ }
35815
+ if( *z=='-' && z[1]=='-' ){
35816
+ z += 2;
35817
+ while( *z && *z!='\n' ){ z++; }
35818
+ if( *z==0 ) return 1;
35819
+ continue;
35820
+ }
35821
+ return 0;
35822
+ }
35823
+ return 1;
3563535824
}
3563635825
3563735826
/*
3563835827
** Return TRUE if the line typed in is an SQL command terminator other
3563935828
** than a semi-colon. The SQL Server style "go" command is understood
3564035829
** as is the Oracle "/".
3564135830
*/
35642
-static int line_is_command_terminator(char *zLine){
35831
+static int line_is_command_terminator(const char *zLine){
3564335832
while( IsSpace(zLine[0]) ){ zLine++; };
35644
- if( zLine[0]=='/' )
35645
- zLine += 1; /* Oracle */
35646
- else if ( ToLower(zLine[0])=='g' && ToLower(zLine[1])=='o' )
35647
- zLine += 2; /* SQL Server */
35648
- else
35649
- return 0;
35650
- return quickscan(zLine, QSS_Start, 0)==QSS_Start;
35833
+ if( zLine[0]=='/' && line_is_all_whitespace(&zLine[1]) ){
35834
+ return 1; /* Oracle */
35835
+ }
35836
+ if( ToLower(zLine[0])=='g' && ToLower(zLine[1])=='o'
35837
+ && line_is_all_whitespace(&zLine[2]) ){
35838
+ return 1; /* SQL Server */
35839
+ }
35840
+ return 0;
3565135841
}
3565235842
3565335843
/*
3565435844
** The CLI needs a working sqlite3_complete() to work properly. So error
3565535845
** out of the build if compiling with SQLITE_OMIT_COMPLETE.
@@ -35833,20 +36023,25 @@
3583336023
/*
3583436024
** Alternate one_input_line() impl for wasm mode. This is not in the primary
3583536025
** impl because we need the global shellState and cannot access it from that
3583636026
** function without moving lots of code around (creating a larger/messier diff).
3583736027
*/
35838
-static char *one_input_line(ShellState *p, char *zPrior, int isContinuation){
36028
+static char *one_input_line(
36029
+ ShellState *p, /* Shell state */
36030
+ char *zPrior, /* Just the prior line of text */
36031
+ const char *zAll, /* All accumulated statement text */
36032
+ int bContinue /* True if this is an accumulation */
36033
+){
3583936034
/* Parse the next line from shellState.wasm.zInput. */
3584036035
const char *zBegin = shellState.wasm.zPos;
3584136036
const char *z = zBegin;
3584236037
char *zLine = 0;
3584336038
i64 nZ = 0;
3584436039
FILE *in = p->in;
3584536040
3584636041
UNUSED_PARAMETER(in);
35847
- UNUSED_PARAMETER(isContinuation);
36042
+ UNUSED_PARAMETER(bContinue);
3584836043
if(!z || !*z){
3584936044
return 0;
3585036045
}
3585136046
while(*z && IsSpace(*z)) ++z;
3585236047
zBegin = z;
@@ -35878,12 +36073,12 @@
3587836073
i64 nLine; /* Length of current line */
3587936074
i64 nSql = 0; /* Bytes of zSql[] used */
3588036075
i64 nAlloc = 0; /* Allocated zSql[] space */
3588136076
int rc; /* Error code */
3588236077
int errCnt = 0; /* Number of errors seen */
36078
+ int hasSemi = 0; /* Input line contains a semicolon */
3588336079
i64 startline = 0; /* Line number for start of current input */
35884
- QuickScanState qss = QSS_Start; /* Accumulated line status (so far) */
3588536080
const char *saved_zInFile; /* Prior value of p->zInFile */
3588636081
i64 saved_lineno; /* Prior value of p->lineno */
3588736082
3588836083
if( p->inputNesting==MAX_INPUT_NESTING ){
3588936084
/* This will be more informative in a later version. */
@@ -35894,14 +36089,13 @@
3589436089
++p->inputNesting;
3589536090
saved_zInFile = p->zInFile;
3589636091
p->zInFile = zSrc;
3589736092
saved_lineno = p->lineno;
3589836093
p->lineno = 0;
35899
- CONTINUE_PROMPT_RESET;
3590036094
while( errCnt==0 || !bail_on_error || (p->in==0 && stdin_is_interactive) ){
3590136095
fflush(p->out);
35902
- zLine = one_input_line(p, zLine, nSql>0);
36096
+ zLine = one_input_line(p, zLine, zSql, nSql>0);
3590336097
if( zLine==0 ){
3590436098
/* End of input */
3590536099
if( p->in==0 && stdin_is_interactive ) cli_puts("\n", p->out);
3590636100
break;
3590736101
}
@@ -35908,37 +36102,31 @@
3590836102
if( seenInterrupt ){
3590936103
if( p->in!=0 ) break;
3591036104
seenInterrupt = 0;
3591136105
}
3591236106
p->lineno++;
35913
- if( QSS_INPLAIN(qss)
35914
- && line_is_command_terminator(zLine)
35915
- && line_is_complete(zSql, nSql) ){
35916
- memcpy(zLine,";",2);
35917
- }
35918
- qss = quickscan(zLine, qss, CONTINUE_PROMPT_PSTATE);
35919
- if( QSS_PLAINWHITE(qss) && nSql==0 ){
36107
+ if( nSql==0 && line_is_all_whitespace(zLine) ){
3592036108
/* Just swallow single-line whitespace */
3592136109
echo_group_input(p, zLine);
35922
- qss = QSS_Start;
3592336110
continue;
3592436111
}
3592536112
if( zLine && (zLine[0]=='.' || zLine[0]=='#') && nSql==0 ){
35926
- CONTINUE_PROMPT_RESET;
3592736113
echo_group_input(p, zLine);
3592836114
if( zLine[0]=='.' ){
3592936115
rc = do_meta_command(zLine, p);
3593036116
if( rc==2 ){ /* exit requested */
3593136117
break;
3593236118
}else if( rc ){
3593336119
errCnt++;
3593436120
}
3593536121
}
35936
- qss = QSS_Start;
3593736122
continue;
3593836123
}
35939
- /* No single-line dispositions remain; accumulate line(s). */
36124
+ if( line_is_command_terminator(zLine) && line_is_complete(zSql, nSql) ){
36125
+ memcpy(zLine,";",2);
36126
+ }
36127
+ hasSemi = strchr(zLine,';')!=0;
3594036128
nLine = strlen(zLine);
3594136129
if( nSql+nLine+2>=nAlloc ){
3594236130
/* Grow buffer by half-again increments when big. */
3594336131
nAlloc = nSql+(nSql>>1)+nLine+100;
3594436132
zSql = realloc(zSql, nAlloc);
@@ -35962,14 +36150,14 @@
3596236150
cli_printf(stderr, "%s:%lld: Input SQL is too big: %s bytes\n",
3596336151
zSrc, startline, zSize);
3596436152
nSql = 0;
3596536153
errCnt++;
3596636154
break;
35967
- }else if( nSql && QSS_SEMITERM(qss) && sqlite3_complete(zSql) ){
36155
+ }
36156
+ if( nSql && hasSemi && sqlite3_complete(zSql) ){
3596836157
echo_group_input(p, zSql);
3596936158
errCnt += runOneSqlLine(p, zSql, p->zInFile, startline);
35970
- CONTINUE_PROMPT_RESET;
3597136159
nSql = 0;
3597236160
if( p->nPopOutput ){
3597336161
output_reset(p);
3597436162
p->nPopOutput = 0;
3597536163
}else{
@@ -35978,22 +36166,19 @@
3597836166
if( p->nPopMode ){
3597936167
modePop(p);
3598036168
p->nPopMode = 0;
3598136169
}
3598236170
p->bSafeMode = p->bSafeModePersist;
35983
- qss = QSS_Start;
35984
- }else if( nSql && QSS_PLAINWHITE(qss) ){
36171
+ }else if( nSql && line_is_all_whitespace(zSql) ){
3598536172
echo_group_input(p, zSql);
3598636173
nSql = 0;
35987
- qss = QSS_Start;
3598836174
}
3598936175
}
3599036176
if( nSql ){
3599136177
/* This may be incomplete. Let the SQL parser deal with that. */
3599236178
echo_group_input(p, zSql);
3599336179
errCnt += runOneSqlLine(p, zSql, p->zInFile, startline);
35994
- CONTINUE_PROMPT_RESET;
3599536180
}
3599636181
free(zSql);
3599736182
free(zLine);
3599836183
--p->inputNesting;
3599936184
p->zInFile = saved_zInFile;
@@ -36277,12 +36462,10 @@
3627736462
#if !defined(SQLITE_SHELL_FIDDLE)
3627836463
verify_uninitialized();
3627936464
#endif
3628036465
sqlite3_config(SQLITE_CONFIG_URI, 1);
3628136466
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
36282
- sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
36283
- sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> ");
3628436467
}
3628536468
3628636469
/*
3628736470
** Output text to the console in a font that attracts extra attention.
3628836471
*/
@@ -36334,11 +36517,12 @@
3633436517
** memory. https://sqlite.org/forum/forumpost/310cb231b07c80d1.
3633536518
** Testing this: if we (inadvertently) remove the
3633636519
** sqlite3_reset_auto_extension() call from main(), most shell tests
3633736520
** will fail because of a leak message in their output. */
3633836521
static int auto_ext_leak_tester(
36339
- sqlite3 *db, const char **pzErrMsg,
36522
+ sqlite3 *db,
36523
+ char **pzErrMsg,
3634036524
const struct sqlite3_api_routines *pThunk
3634136525
){
3634236526
(void)db; (void)pzErrMsg; (void)pThunk;
3634336527
return SQLITE_OK;
3634436528
}
@@ -37012,10 +37196,13 @@
3701237196
rc = runOneSqlLine(&data, azCmd[i], "cmdline", aiCmd[i]);
3701337197
if( data.nPopMode ){
3701437198
modePop(&data);
3701537199
data.nPopMode = 0;
3701637200
}
37201
+ if( rc ){
37202
+ goto shell_main_exit;
37203
+ }
3701737204
}
3701837205
if( data.nPopOutput && azCmd[i][0]!='.' ){
3701937206
output_reset(&data);
3702037207
data.nPopOutput = 0;
3702137208
}else{
@@ -37111,10 +37298,12 @@
3711137298
free(data.zNonce);
3711237299
free(data.dot.zCopy);
3711337300
free(data.dot.azArg);
3711437301
free(data.dot.aiOfst);
3711537302
free(data.dot.abQuot);
37303
+ free(data.azPrompt[0]);
37304
+ free(data.azPrompt[1]);
3711637305
if( data.nTestRun ){
3711737306
sqlite3_fprintf(stdout, "%d test%s run with %d error%s\n",
3711837307
data.nTestRun, data.nTestRun==1 ? "" : "s",
3711937308
data.nTestErr, data.nTestErr==1 ? "" : "s");
3712037309
fflush(stdout);
@@ -37270,7 +37459,11 @@
3727037459
shellState.wasm.zPos = zSql;
3727137460
process_input(&shellState, "<stdin>");
3727237461
shellState.wasm.zInput = shellState.wasm.zPos = 0;
3727337462
}
3727437463
}
37464
+
37465
+char *fiddle_get_prompt(void){
37466
+ return expand_prompt(&shellState, 0, prompt_string(&shellState,0));
37467
+}
3727537468
#endif /* SQLITE_SHELL_FIDDLE */
3727637469
/************************* End src/shell.c.in ******************/
3727737470
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -682,12 +682,12 @@
682 ** May you do good and not evil.
683 ** May you find forgiveness for yourself and forgive others.
684 ** May you share freely, never taking more than you give.
685 **
686 *************************************************************************
687 ** Header file for the Result-Format or "resfmt" utility library for SQLite.
688 ** See the README.md documentation for additional information.
689 */
690 #ifndef SQLITE_QRF_H
691 #define SQLITE_QRF_H
692 #ifdef __cplusplus
693 extern "C" {
@@ -886,21 +886,23 @@
886 ** May you do good and not evil.
887 ** May you find forgiveness for yourself and forgive others.
888 ** May you share freely, never taking more than you give.
889 **
890 *************************************************************************
891 ** Implementation of the Result-Format or "qrf" utility library for SQLite.
892 ** See the qrf.md documentation for additional information.
893 */
894 #ifndef SQLITE_QRF_H
895 #include "qrf.h"
896 #endif
897 #include <string.h>
898 #include <assert.h>
899 #include <stdint.h>
900
 
901 /* typedef sqlite3_int64 i64; */
 
902
903 /* A single line in the EQP output */
904 typedef struct qrfEQPGraphRow qrfEQPGraphRow;
905 struct qrfEQPGraphRow {
906 int iEqpId; /* ID for this row */
@@ -3676,19 +3678,21 @@
3676 break;
3677 }
3678 case QRF_STYLE_Eqp: {
3679 int expMode = sqlite3_stmt_isexplain(p->pStmt);
3680 if( expMode!=2 ){
3681 sqlite3_stmt_explain(p->pStmt, 2);
 
3682 p->expMode = expMode+1;
3683 }
3684 break;
3685 }
3686 case QRF_STYLE_Explain: {
3687 int expMode = sqlite3_stmt_isexplain(p->pStmt);
3688 if( expMode!=1 ){
3689 sqlite3_stmt_explain(p->pStmt, 1);
 
3690 p->expMode = expMode+1;
3691 }
3692 break;
3693 }
3694 }
@@ -3843,10 +3847,11 @@
3843 ){
3844 Qrf qrf; /* The new Qrf being created */
3845
3846 if( pStmt==0 ) return SQLITE_OK; /* No-op */
3847 if( pSpec==0 ) return SQLITE_MISUSE;
 
3848 qrfInitialize(&qrf, pStmt, pSpec, pzErr);
3849 switch( qrf.spec.eStyle ){
3850 case QRF_STYLE_Box:
3851 case QRF_STYLE_Column:
3852 case QRF_STYLE_Markdown:
@@ -23628,11 +23633,10 @@
23628 /* Flags for Mode.mFlags */
23629 #define MFLG_ECHO 0x01 /* Echo inputs to output */
23630 #define MFLG_CRLF 0x02 /* Use CR/LF output line endings */
23631 #define MFLG_HDR 0x04 /* .header used to change headers on/off */
23632
23633
23634 /*
23635 ** State information about the database connection is contained in an
23636 ** instance of the following structure.
23637 */
23638 typedef struct ShellState ShellState;
@@ -23670,14 +23674,13 @@
23670 unsigned nTestErr; /* Number of test cases that failed */
23671 sqlite3_int64 szMax; /* --maxsize argument to .open */
23672 char *zDestTable; /* Name of destination table when MODE_Insert */
23673 char *zTempFile; /* Temporary file that might need deleting */
23674 char *zErrPrefix; /* Alternative error message prefix */
23675 char zTestcase[30]; /* Name of current test case */
23676 char outfile[FILENAME_MAX]; /* Filename for *out */
23677 sqlite3_stmt *pStmt; /* Current statement if any. */
23678 FILE *pLog; /* Write log output here */
 
23679 Mode mode; /* Current display mode */
23680 Mode modePrior; /* Backup */
23681 struct SavedMode { /* Ability to define custom mode configurations */
23682 char *zTag; /* Name of this saved mode */
23683 Mode mode; /* The saved mode */
@@ -23685,10 +23688,11 @@
23685 int nSavedModes; /* Number of saved .mode settings */
23686 struct AuxDb { /* Storage space for auxiliary database connections */
23687 sqlite3 *db; /* Connection pointer */
23688 const char *zDbFilename; /* Filename used to open the connection */
23689 char *zFreeOnClose; /* Free this memory allocation on close */
 
23690 #if defined(SQLITE_ENABLE_SESSION)
23691 int nSession; /* Number of active sessions */
23692 OpenSession aSession[4]; /* Array of sessions. [0] is in focus. */
23693 #endif
23694 } aAuxDb[5], /* Array of all database connections */
@@ -23711,10 +23715,12 @@
23711 const char * zInput; /* Input string from wasm/JS proxy */
23712 const char * zPos; /* Cursor pos into zInput */
23713 const char * zDefaultDbName; /* Default name for db file */
23714 } wasm;
23715 #endif
 
 
23716 };
23717
23718 #ifdef SQLITE_SHELL_FIDDLE
23719 static ShellState shellState;
23720 #endif
@@ -23947,20 +23953,10 @@
23947 ** This is the name of our program. It is set in main(), used
23948 ** in a number of other places, mostly for error messages.
23949 */
23950 static char *Argv0;
23951
23952 /*
23953 ** Prompt strings. Initialized in main. Settable with
23954 ** .prompt main continue
23955 */
23956 #define PROMPT_LEN_MAX 128
23957 /* First line prompt. default: "sqlite> " */
23958 static char mainPrompt[PROMPT_LEN_MAX];
23959 /* Continuation prompt. default: " ...> " */
23960 static char continuePrompt[PROMPT_LEN_MAX];
23961
23962 /*
23963 ** Write I/O traces to the following stream.
23964 */
23965 #ifdef SQLITE_ENABLE_IOTRACE
23966 static FILE *iotrace = 0;
@@ -24070,118 +24066,10 @@
24070 (void)gettimeofday(&sNow,0);
24071 return ((i64)sNow.tv_sec)*1000000 + sNow.tv_usec;
24072 #endif
24073 }
24074
24075
24076
24077 /* This is variant of the standard-library strncpy() routine with the
24078 ** one change that the destination string is always zero-terminated, even
24079 ** if there is no zero-terminator in the first n-1 characters of the source
24080 ** string.
24081 */
24082 static char *shell_strncpy(char *dest, const char *src, size_t n){
24083 size_t i;
24084 for(i=0; i<n-1 && src[i]!=0; i++) dest[i] = src[i];
24085 dest[i] = 0;
24086 return dest;
24087 }
24088
24089 /*
24090 ** strcpy() workalike to squelch an unwarranted link-time warning
24091 ** from OpenBSD.
24092 */
24093 static void shell_strcpy(char *dest, const char *src){
24094 while( (*(dest++) = *(src++))!=0 ){}
24095 }
24096
24097 /*
24098 ** Optionally disable dynamic continuation prompt.
24099 ** Unless disabled, the continuation prompt shows open SQL lexemes if any,
24100 ** or open parentheses level if non-zero, or continuation prompt as set.
24101 ** This facility interacts with the scanner and process_input() where the
24102 ** below 5 macros are used.
24103 */
24104 #ifdef SQLITE_OMIT_DYNAPROMPT
24105 # define CONTINUATION_PROMPT continuePrompt
24106 # define CONTINUE_PROMPT_RESET
24107 # define CONTINUE_PROMPT_AWAITS(p,s)
24108 # define CONTINUE_PROMPT_AWAITC(p,c)
24109 # define CONTINUE_PAREN_INCR(p,n)
24110 # define CONTINUE_PROMPT_PSTATE 0
24111 typedef void *t_NoDynaPrompt;
24112 # define SCAN_TRACKER_REFTYPE t_NoDynaPrompt
24113 #else
24114 # define CONTINUATION_PROMPT dynamicContinuePrompt()
24115 # define CONTINUE_PROMPT_RESET \
24116 do {setLexemeOpen(&dynPrompt,0,0); trackParenLevel(&dynPrompt,0);} while(0)
24117 # define CONTINUE_PROMPT_AWAITS(p,s) \
24118 if(p && stdin_is_interactive) setLexemeOpen(p, s, 0)
24119 # define CONTINUE_PROMPT_AWAITC(p,c) \
24120 if(p && stdin_is_interactive) setLexemeOpen(p, 0, c)
24121 # define CONTINUE_PAREN_INCR(p,n) \
24122 if(p && stdin_is_interactive) (trackParenLevel(p,n))
24123 # define CONTINUE_PROMPT_PSTATE (&dynPrompt)
24124 typedef struct DynaPrompt *t_DynaPromptRef;
24125 # define SCAN_TRACKER_REFTYPE t_DynaPromptRef
24126
24127 static struct DynaPrompt {
24128 char dynamicPrompt[PROMPT_LEN_MAX];
24129 char acAwait[2];
24130 int inParenLevel;
24131 char *zScannerAwaits;
24132 } dynPrompt = { {0}, {0}, 0, 0 };
24133
24134 /* Record parenthesis nesting level change, or force level to 0. */
24135 static void trackParenLevel(struct DynaPrompt *p, int ni){
24136 p->inParenLevel += ni;
24137 if( ni==0 ) p->inParenLevel = 0;
24138 p->zScannerAwaits = 0;
24139 }
24140
24141 /* Record that a lexeme is opened, or closed with args==0. */
24142 static void setLexemeOpen(struct DynaPrompt *p, char *s, char c){
24143 if( s!=0 || c==0 ){
24144 p->zScannerAwaits = s;
24145 p->acAwait[0] = 0;
24146 }else{
24147 p->acAwait[0] = c;
24148 p->zScannerAwaits = p->acAwait;
24149 }
24150 }
24151
24152 /* Upon demand, derive the continuation prompt to display. */
24153 static char *dynamicContinuePrompt(void){
24154 if( continuePrompt[0]==0
24155 || (dynPrompt.zScannerAwaits==0 && dynPrompt.inParenLevel == 0) ){
24156 return continuePrompt;
24157 }else{
24158 if( dynPrompt.zScannerAwaits ){
24159 size_t ncp = strlen(continuePrompt);
24160 size_t ndp = strlen(dynPrompt.zScannerAwaits);
24161 if( ndp > ncp-3 ) return continuePrompt;
24162 shell_strcpy(dynPrompt.dynamicPrompt, dynPrompt.zScannerAwaits);
24163 while( ndp<3 ) dynPrompt.dynamicPrompt[ndp++] = ' ';
24164 shell_strncpy(dynPrompt.dynamicPrompt+3, continuePrompt+3,
24165 PROMPT_LEN_MAX-4);
24166 }else{
24167 if( dynPrompt.inParenLevel>9 ){
24168 shell_strncpy(dynPrompt.dynamicPrompt, "(..", 4);
24169 }else if( dynPrompt.inParenLevel<0 ){
24170 shell_strncpy(dynPrompt.dynamicPrompt, ")x!", 4);
24171 }else{
24172 shell_strncpy(dynPrompt.dynamicPrompt, "(x.", 4);
24173 dynPrompt.dynamicPrompt[2] = (char)('0'+dynPrompt.inParenLevel);
24174 }
24175 shell_strncpy(dynPrompt.dynamicPrompt+3, continuePrompt+3,
24176 PROMPT_LEN_MAX-4);
24177 }
24178 }
24179 return dynPrompt.dynamicPrompt;
24180 }
24181 #endif /* !defined(SQLITE_OMIT_DYNAPROMPT) */
24182
24183 /* Indicate out-of-memory and exit. */
24184 static void shell_out_of_memory(void){
24185 eputz("Error: out of memory\n");
24186 cli_exit(1);
24187 }
@@ -24296,34 +24184,299 @@
24296 break;
24297 }
24298 }
24299 return zLine;
24300 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24301
24302 /*
24303 ** Retrieve a single line of input text.
24304 **
24305 ** If in==0 then read from standard input and prompt before each line.
24306 ** If isContinuation is true, then a continuation prompt is appropriate.
24307 ** If isContinuation is zero, then the main prompt should be used.
24308 **
24309 ** If zPrior is not NULL then it is a buffer from a prior call to this
24310 ** routine that can be reused.
24311 **
24312 ** The result is stored in space obtained from malloc() and must either
24313 ** be freed by the caller or else passed back into this routine via the
24314 ** zPrior argument for reuse.
24315 */
24316 #ifndef SQLITE_SHELL_FIDDLE
24317 static char *one_input_line(ShellState *p, char *zPrior, int isContinuation){
24318 char *zPrompt;
 
 
 
 
24319 char *zResult;
24320 FILE *in = p->in;
24321 if( in!=0 ){
24322 zResult = local_getline(zPrior, in);
24323 }else{
24324 zPrompt = isContinuation ? CONTINUATION_PROMPT : mainPrompt;
 
 
24325 #if SHELL_USE_LOCAL_GETLINE
24326 sputz(stdout, zPrompt);
24327 fflush(stdout);
24328 do{
24329 zResult = local_getline(zPrior, stdin);
@@ -24340,10 +24493,11 @@
24340 if( seenInterrupt==0 ) break;
24341 zResult = shell_readline("");
24342 }
24343 if( zResult && *zResult ) shell_add_history(zResult);
24344 #endif
 
24345 }
24346 return zResult;
24347 }
24348 #endif /* !SQLITE_SHELL_FIDDLE */
24349
@@ -24660,10 +24814,58 @@
24660 }
24661 }
24662 sqlite3_result_value(pCtx, apVal[0]);
24663 }
24664
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24665
24666 /************************* BEGIN PERFORMANCE TIMER *****************************/
24667 #if !defined(_WIN32) && !defined(WIN32) && !defined(__minux)
24668 #include <sys/time.h>
24669 #include <sys/resource.h>
@@ -27137,11 +27339,14 @@
27137 " --once Do no more than one progress interrupt",
27138 " --quiet|-q No output except at interrupts",
27139 " --reset Reset the count for each input and interrupt",
27140 " --timeout S Halt after running for S seconds",
27141 #endif
27142 ".prompt MAIN CONTINUE Replace the standard prompts",
 
 
 
27143 #ifndef SQLITE_SHELL_FIDDLE
27144 ".quit Stop interpreting input stream, exit if primary.",
27145 ".read FILE Read input from FILE or command output",
27146 " If FILE begins with \"|\", it is a command that generates the input.",
27147 #endif
@@ -27934,10 +28139,35 @@
27934 ** the database fails to open, print an error message and exit.
27935 */
27936 static void open_db(ShellState *p, int openFlags){
27937 if( p->db==0 ){
27938 const char *zDbFilename = p->pAuxDb->zDbFilename;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27939 if( p->openMode==SHELL_OPEN_UNSPEC ){
27940 if( zDbFilename==0 || zDbFilename[0]==0 ){
27941 p->openMode = SHELL_OPEN_NORMAL;
27942 }else{
27943 p->openMode = (u8)deduceDatabaseType(zDbFilename,
@@ -28067,10 +28297,17 @@
28067 sqlite3_create_function(p->db, "edit", 1, SQLITE_UTF8, 0,
28068 editFunc, 0, 0);
28069 sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
28070 editFunc, 0, 0);
28071 #endif
 
 
 
 
 
 
 
28072
28073 if( p->openMode==SHELL_OPEN_ZIPFILE ){
28074 char *zSql = sqlite3_mprintf(
28075 "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", zDbFilename);
28076 shell_check_oom(zSql);
@@ -28100,10 +28337,11 @@
28100 if( p->szMax>0 ){
28101 sqlite3_file_control(p->db, "main", SQLITE_FCNTL_SIZE_LIMIT, &p->szMax);
28102 }
28103 }
28104 #endif
 
28105 }
28106 if( p->db!=0 ){
28107 #ifndef SQLITE_OMIT_AUTHORIZATION
28108 if( p->bSafeModePersist ){
28109 sqlite3_set_authorizer(p->db, safeModeAuth, p);
@@ -33894,16 +34132,43 @@
33894 sqlite3_progress_handler(p->db, nn, progress_handler, p);
33895 }else
33896 #endif /* SQLITE_OMIT_PROGRESS_CALLBACK */
33897
33898 if( c=='p' && cli_strncmp(azArg[0], "prompt", n)==0 ){
33899 if( nArg >= 2) {
33900 shell_strncpy(mainPrompt,azArg[1],(int)ArraySize(mainPrompt)-1);
33901 }
33902 if( nArg >= 3) {
33903 shell_strncpy(continuePrompt,azArg[2],(int)ArraySize(continuePrompt)-1);
33904 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33905 }else
33906
33907 #ifndef SQLITE_SHELL_FIDDLE
33908 if( c=='q' && cli_strncmp(azArg[0], "quit", n)==0 ){
33909 rc = 2;
@@ -35532,124 +35797,49 @@
35532 p->bSafeMode = p->bSafeModePersist;
35533 p->dot.nArg = 0;
35534 return rc;
35535 }
35536
35537 /* Line scan result and intermediate states (supporting scan resumption)
35538 */
35539 #ifndef CHAR_BIT
35540 # define CHAR_BIT 8
35541 #endif
35542 typedef enum {
35543 QSS_HasDark = 1<<CHAR_BIT, QSS_EndingSemi = 2<<CHAR_BIT,
35544 QSS_CharMask = (1<<CHAR_BIT)-1, QSS_ScanMask = 3<<CHAR_BIT,
35545 QSS_Start = 0
35546 } QuickScanState;
35547 #define QSS_SETV(qss, newst) ((newst) | ((qss) & QSS_ScanMask))
35548 #define QSS_INPLAIN(qss) (((qss)&QSS_CharMask)==QSS_Start)
35549 #define QSS_PLAINWHITE(qss) (((qss)&~QSS_EndingSemi)==QSS_Start)
35550 #define QSS_PLAINDARK(qss) (((qss)&~QSS_EndingSemi)==QSS_HasDark)
35551 #define QSS_SEMITERM(qss) (((qss)&~QSS_HasDark)==QSS_EndingSemi)
35552
35553 /*
35554 ** Scan line for classification to guide shell's handling.
35555 ** The scan is resumable for subsequent lines when prior
35556 ** return values are passed as the 2nd argument.
35557 */
35558 static QuickScanState quickscan(char *zLine, QuickScanState qss,
35559 SCAN_TRACKER_REFTYPE pst){
35560 char cin;
35561 char cWait = (char)qss; /* intentional narrowing loss */
35562 if( cWait==0 ){
35563 PlainScan:
35564 while( (cin = *zLine++)!=0 ){
35565 if( IsSpace(cin) )
35566 continue;
35567 switch (cin){
35568 case '-':
35569 if( *zLine!='-' )
35570 break;
35571 while((cin = *++zLine)!=0 )
35572 if( cin=='\n')
35573 goto PlainScan;
35574 return qss;
35575 case ';':
35576 qss |= QSS_EndingSemi;
35577 continue;
35578 case '/':
35579 if( *zLine=='*' ){
35580 ++zLine;
35581 cWait = '*';
35582 CONTINUE_PROMPT_AWAITS(pst, "/*");
35583 qss = QSS_SETV(qss, cWait);
35584 goto TermScan;
35585 }
35586 break;
35587 case '[':
35588 cin = ']';
35589 deliberate_fall_through; /* FALLTHRU */
35590 case '`': case '\'': case '"':
35591 cWait = cin;
35592 qss = QSS_HasDark | cWait;
35593 CONTINUE_PROMPT_AWAITC(pst, cin);
35594 goto TermScan;
35595 case '(':
35596 CONTINUE_PAREN_INCR(pst, 1);
35597 break;
35598 case ')':
35599 CONTINUE_PAREN_INCR(pst, -1);
35600 break;
35601 default:
35602 break;
35603 }
35604 qss = (qss & ~QSS_EndingSemi) | QSS_HasDark;
35605 }
35606 }else{
35607 TermScan:
35608 while( (cin = *zLine++)!=0 ){
35609 if( cin==cWait ){
35610 switch( cWait ){
35611 case '*':
35612 if( *zLine != '/' )
35613 continue;
35614 ++zLine;
35615 CONTINUE_PROMPT_AWAITC(pst, 0);
35616 qss = QSS_SETV(qss, 0);
35617 goto PlainScan;
35618 case '`': case '\'': case '"':
35619 if(*zLine==cWait){
35620 /* Swallow doubled end-delimiter.*/
35621 ++zLine;
35622 continue;
35623 }
35624 deliberate_fall_through; /* FALLTHRU */
35625 case ']':
35626 CONTINUE_PROMPT_AWAITC(pst, 0);
35627 qss = QSS_SETV(qss, 0);
35628 goto PlainScan;
35629 default: assert(0);
35630 }
35631 }
35632 }
35633 }
35634 return qss;
35635 }
35636
35637 /*
35638 ** Return TRUE if the line typed in is an SQL command terminator other
35639 ** than a semi-colon. The SQL Server style "go" command is understood
35640 ** as is the Oracle "/".
35641 */
35642 static int line_is_command_terminator(char *zLine){
35643 while( IsSpace(zLine[0]) ){ zLine++; };
35644 if( zLine[0]=='/' )
35645 zLine += 1; /* Oracle */
35646 else if ( ToLower(zLine[0])=='g' && ToLower(zLine[1])=='o' )
35647 zLine += 2; /* SQL Server */
35648 else
35649 return 0;
35650 return quickscan(zLine, QSS_Start, 0)==QSS_Start;
 
35651 }
35652
35653 /*
35654 ** The CLI needs a working sqlite3_complete() to work properly. So error
35655 ** out of the build if compiling with SQLITE_OMIT_COMPLETE.
@@ -35833,20 +36023,25 @@
35833 /*
35834 ** Alternate one_input_line() impl for wasm mode. This is not in the primary
35835 ** impl because we need the global shellState and cannot access it from that
35836 ** function without moving lots of code around (creating a larger/messier diff).
35837 */
35838 static char *one_input_line(ShellState *p, char *zPrior, int isContinuation){
 
 
 
 
 
35839 /* Parse the next line from shellState.wasm.zInput. */
35840 const char *zBegin = shellState.wasm.zPos;
35841 const char *z = zBegin;
35842 char *zLine = 0;
35843 i64 nZ = 0;
35844 FILE *in = p->in;
35845
35846 UNUSED_PARAMETER(in);
35847 UNUSED_PARAMETER(isContinuation);
35848 if(!z || !*z){
35849 return 0;
35850 }
35851 while(*z && IsSpace(*z)) ++z;
35852 zBegin = z;
@@ -35878,12 +36073,12 @@
35878 i64 nLine; /* Length of current line */
35879 i64 nSql = 0; /* Bytes of zSql[] used */
35880 i64 nAlloc = 0; /* Allocated zSql[] space */
35881 int rc; /* Error code */
35882 int errCnt = 0; /* Number of errors seen */
 
35883 i64 startline = 0; /* Line number for start of current input */
35884 QuickScanState qss = QSS_Start; /* Accumulated line status (so far) */
35885 const char *saved_zInFile; /* Prior value of p->zInFile */
35886 i64 saved_lineno; /* Prior value of p->lineno */
35887
35888 if( p->inputNesting==MAX_INPUT_NESTING ){
35889 /* This will be more informative in a later version. */
@@ -35894,14 +36089,13 @@
35894 ++p->inputNesting;
35895 saved_zInFile = p->zInFile;
35896 p->zInFile = zSrc;
35897 saved_lineno = p->lineno;
35898 p->lineno = 0;
35899 CONTINUE_PROMPT_RESET;
35900 while( errCnt==0 || !bail_on_error || (p->in==0 && stdin_is_interactive) ){
35901 fflush(p->out);
35902 zLine = one_input_line(p, zLine, nSql>0);
35903 if( zLine==0 ){
35904 /* End of input */
35905 if( p->in==0 && stdin_is_interactive ) cli_puts("\n", p->out);
35906 break;
35907 }
@@ -35908,37 +36102,31 @@
35908 if( seenInterrupt ){
35909 if( p->in!=0 ) break;
35910 seenInterrupt = 0;
35911 }
35912 p->lineno++;
35913 if( QSS_INPLAIN(qss)
35914 && line_is_command_terminator(zLine)
35915 && line_is_complete(zSql, nSql) ){
35916 memcpy(zLine,";",2);
35917 }
35918 qss = quickscan(zLine, qss, CONTINUE_PROMPT_PSTATE);
35919 if( QSS_PLAINWHITE(qss) && nSql==0 ){
35920 /* Just swallow single-line whitespace */
35921 echo_group_input(p, zLine);
35922 qss = QSS_Start;
35923 continue;
35924 }
35925 if( zLine && (zLine[0]=='.' || zLine[0]=='#') && nSql==0 ){
35926 CONTINUE_PROMPT_RESET;
35927 echo_group_input(p, zLine);
35928 if( zLine[0]=='.' ){
35929 rc = do_meta_command(zLine, p);
35930 if( rc==2 ){ /* exit requested */
35931 break;
35932 }else if( rc ){
35933 errCnt++;
35934 }
35935 }
35936 qss = QSS_Start;
35937 continue;
35938 }
35939 /* No single-line dispositions remain; accumulate line(s). */
 
 
 
35940 nLine = strlen(zLine);
35941 if( nSql+nLine+2>=nAlloc ){
35942 /* Grow buffer by half-again increments when big. */
35943 nAlloc = nSql+(nSql>>1)+nLine+100;
35944 zSql = realloc(zSql, nAlloc);
@@ -35962,14 +36150,14 @@
35962 cli_printf(stderr, "%s:%lld: Input SQL is too big: %s bytes\n",
35963 zSrc, startline, zSize);
35964 nSql = 0;
35965 errCnt++;
35966 break;
35967 }else if( nSql && QSS_SEMITERM(qss) && sqlite3_complete(zSql) ){
 
35968 echo_group_input(p, zSql);
35969 errCnt += runOneSqlLine(p, zSql, p->zInFile, startline);
35970 CONTINUE_PROMPT_RESET;
35971 nSql = 0;
35972 if( p->nPopOutput ){
35973 output_reset(p);
35974 p->nPopOutput = 0;
35975 }else{
@@ -35978,22 +36166,19 @@
35978 if( p->nPopMode ){
35979 modePop(p);
35980 p->nPopMode = 0;
35981 }
35982 p->bSafeMode = p->bSafeModePersist;
35983 qss = QSS_Start;
35984 }else if( nSql && QSS_PLAINWHITE(qss) ){
35985 echo_group_input(p, zSql);
35986 nSql = 0;
35987 qss = QSS_Start;
35988 }
35989 }
35990 if( nSql ){
35991 /* This may be incomplete. Let the SQL parser deal with that. */
35992 echo_group_input(p, zSql);
35993 errCnt += runOneSqlLine(p, zSql, p->zInFile, startline);
35994 CONTINUE_PROMPT_RESET;
35995 }
35996 free(zSql);
35997 free(zLine);
35998 --p->inputNesting;
35999 p->zInFile = saved_zInFile;
@@ -36277,12 +36462,10 @@
36277 #if !defined(SQLITE_SHELL_FIDDLE)
36278 verify_uninitialized();
36279 #endif
36280 sqlite3_config(SQLITE_CONFIG_URI, 1);
36281 sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
36282 sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
36283 sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> ");
36284 }
36285
36286 /*
36287 ** Output text to the console in a font that attracts extra attention.
36288 */
@@ -36334,11 +36517,12 @@
36334 ** memory. https://sqlite.org/forum/forumpost/310cb231b07c80d1.
36335 ** Testing this: if we (inadvertently) remove the
36336 ** sqlite3_reset_auto_extension() call from main(), most shell tests
36337 ** will fail because of a leak message in their output. */
36338 static int auto_ext_leak_tester(
36339 sqlite3 *db, const char **pzErrMsg,
 
36340 const struct sqlite3_api_routines *pThunk
36341 ){
36342 (void)db; (void)pzErrMsg; (void)pThunk;
36343 return SQLITE_OK;
36344 }
@@ -37012,10 +37196,13 @@
37012 rc = runOneSqlLine(&data, azCmd[i], "cmdline", aiCmd[i]);
37013 if( data.nPopMode ){
37014 modePop(&data);
37015 data.nPopMode = 0;
37016 }
 
 
 
37017 }
37018 if( data.nPopOutput && azCmd[i][0]!='.' ){
37019 output_reset(&data);
37020 data.nPopOutput = 0;
37021 }else{
@@ -37111,10 +37298,12 @@
37111 free(data.zNonce);
37112 free(data.dot.zCopy);
37113 free(data.dot.azArg);
37114 free(data.dot.aiOfst);
37115 free(data.dot.abQuot);
 
 
37116 if( data.nTestRun ){
37117 sqlite3_fprintf(stdout, "%d test%s run with %d error%s\n",
37118 data.nTestRun, data.nTestRun==1 ? "" : "s",
37119 data.nTestErr, data.nTestErr==1 ? "" : "s");
37120 fflush(stdout);
@@ -37270,7 +37459,11 @@
37270 shellState.wasm.zPos = zSql;
37271 process_input(&shellState, "<stdin>");
37272 shellState.wasm.zInput = shellState.wasm.zPos = 0;
37273 }
37274 }
 
 
 
 
37275 #endif /* SQLITE_SHELL_FIDDLE */
37276 /************************* End src/shell.c.in ******************/
37277
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -682,12 +682,12 @@
682 ** May you do good and not evil.
683 ** May you find forgiveness for yourself and forgive others.
684 ** May you share freely, never taking more than you give.
685 **
686 *************************************************************************
687 ** Header file for the Query Result-Format or "qrf" utility library for
688 ** SQLite. See the README.md documentation for additional information.
689 */
690 #ifndef SQLITE_QRF_H
691 #define SQLITE_QRF_H
692 #ifdef __cplusplus
693 extern "C" {
@@ -886,21 +886,23 @@
886 ** May you do good and not evil.
887 ** May you find forgiveness for yourself and forgive others.
888 ** May you share freely, never taking more than you give.
889 **
890 *************************************************************************
891 ** Implementation of the Query Result-Format or "qrf" utility library for
892 ** SQLite. See the README.md documentation for additional information.
893 */
894 #ifndef SQLITE_QRF_H
895 #include "qrf.h"
896 #endif
897 #include <string.h>
898 #include <assert.h>
899 #include <stdint.h>
900
901 #ifndef SQLITE_AMALGAMATION
902 /* typedef sqlite3_int64 i64; */
903 #endif
904
905 /* A single line in the EQP output */
906 typedef struct qrfEQPGraphRow qrfEQPGraphRow;
907 struct qrfEQPGraphRow {
908 int iEqpId; /* ID for this row */
@@ -3676,19 +3678,21 @@
3678 break;
3679 }
3680 case QRF_STYLE_Eqp: {
3681 int expMode = sqlite3_stmt_isexplain(p->pStmt);
3682 if( expMode!=2 ){
3683 int rc = sqlite3_stmt_explain(p->pStmt, 2);
3684 if( rc ){ qrfError(p, SQLITE_ERROR, sqlite3_errstr(rc)); }
3685 p->expMode = expMode+1;
3686 }
3687 break;
3688 }
3689 case QRF_STYLE_Explain: {
3690 int expMode = sqlite3_stmt_isexplain(p->pStmt);
3691 if( expMode!=1 ){
3692 int rc = sqlite3_stmt_explain(p->pStmt, 1);
3693 if( rc ){ qrfError(p, SQLITE_ERROR, sqlite3_errstr(rc)); }
3694 p->expMode = expMode+1;
3695 }
3696 break;
3697 }
3698 }
@@ -3843,10 +3847,11 @@
3847 ){
3848 Qrf qrf; /* The new Qrf being created */
3849
3850 if( pStmt==0 ) return SQLITE_OK; /* No-op */
3851 if( pSpec==0 ) return SQLITE_MISUSE;
3852 if( sqlite3_stmt_busy(pStmt) ) return SQLITE_BUSY;
3853 qrfInitialize(&qrf, pStmt, pSpec, pzErr);
3854 switch( qrf.spec.eStyle ){
3855 case QRF_STYLE_Box:
3856 case QRF_STYLE_Column:
3857 case QRF_STYLE_Markdown:
@@ -23628,11 +23633,10 @@
23633 /* Flags for Mode.mFlags */
23634 #define MFLG_ECHO 0x01 /* Echo inputs to output */
23635 #define MFLG_CRLF 0x02 /* Use CR/LF output line endings */
23636 #define MFLG_HDR 0x04 /* .header used to change headers on/off */
23637
 
23638 /*
23639 ** State information about the database connection is contained in an
23640 ** instance of the following structure.
23641 */
23642 typedef struct ShellState ShellState;
@@ -23670,14 +23674,13 @@
23674 unsigned nTestErr; /* Number of test cases that failed */
23675 sqlite3_int64 szMax; /* --maxsize argument to .open */
23676 char *zDestTable; /* Name of destination table when MODE_Insert */
23677 char *zTempFile; /* Temporary file that might need deleting */
23678 char *zErrPrefix; /* Alternative error message prefix */
 
 
23679 sqlite3_stmt *pStmt; /* Current statement if any. */
23680 FILE *pLog; /* Write log output here */
23681 char *azPrompt[2]; /* Main and continuation prompt strings */
23682 Mode mode; /* Current display mode */
23683 Mode modePrior; /* Backup */
23684 struct SavedMode { /* Ability to define custom mode configurations */
23685 char *zTag; /* Name of this saved mode */
23686 Mode mode; /* The saved mode */
@@ -23685,10 +23688,11 @@
23688 int nSavedModes; /* Number of saved .mode settings */
23689 struct AuxDb { /* Storage space for auxiliary database connections */
23690 sqlite3 *db; /* Connection pointer */
23691 const char *zDbFilename; /* Filename used to open the connection */
23692 char *zFreeOnClose; /* Free this memory allocation on close */
23693 int mFlgs; /* 0x001: Use zDbFilenaem for prompt */
23694 #if defined(SQLITE_ENABLE_SESSION)
23695 int nSession; /* Number of active sessions */
23696 OpenSession aSession[4]; /* Array of sessions. [0] is in focus. */
23697 #endif
23698 } aAuxDb[5], /* Array of all database connections */
@@ -23711,10 +23715,12 @@
23715 const char * zInput; /* Input string from wasm/JS proxy */
23716 const char * zPos; /* Cursor pos into zInput */
23717 const char * zDefaultDbName; /* Default name for db file */
23718 } wasm;
23719 #endif
23720 char zTestcase[30]; /* Name of current test case */
23721 char outfile[FILENAME_MAX]; /* Filename for *out */
23722 };
23723
23724 #ifdef SQLITE_SHELL_FIDDLE
23725 static ShellState shellState;
23726 #endif
@@ -23947,20 +23953,10 @@
23953 ** This is the name of our program. It is set in main(), used
23954 ** in a number of other places, mostly for error messages.
23955 */
23956 static char *Argv0;
23957
 
 
 
 
 
 
 
 
 
 
23958 /*
23959 ** Write I/O traces to the following stream.
23960 */
23961 #ifdef SQLITE_ENABLE_IOTRACE
23962 static FILE *iotrace = 0;
@@ -24070,118 +24066,10 @@
24066 (void)gettimeofday(&sNow,0);
24067 return ((i64)sNow.tv_sec)*1000000 + sNow.tv_usec;
24068 #endif
24069 }
24070
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24071 /* Indicate out-of-memory and exit. */
24072 static void shell_out_of_memory(void){
24073 eputz("Error: out of memory\n");
24074 cli_exit(1);
24075 }
@@ -24296,34 +24184,299 @@
24184 break;
24185 }
24186 }
24187 return zLine;
24188 }
24189
24190 /*
24191 ** The default prompts.
24192 */
24193 #ifndef SQLITE_PS1
24194 # define SQLITE_PS1 "SQLite /f> "
24195 #endif
24196 #ifndef SQLITE_PS2
24197 # define SQLITE_PS2 "/B.../H> "
24198 #endif
24199
24200 /*
24201 ** Return the raw (unexpanded) prompt string. This will be the
24202 ** first of the following that exist:
24203 **
24204 ** * The prompt string specified by the ".prompt" command.
24205 ** * The value of the SQLITE_PS1 (or SQLITE_PS2) environment variable.
24206 ** * The default prompt string.
24207 **
24208 ** The main prompt is returned if the argument is zero and the
24209 ** continuation prompt is returned if the argument is 1.
24210 */
24211 static const char *prompt_string(ShellState *p, int bContinue){
24212 const char *zPS;
24213 assert( bContinue==0 || bContinue==1 );
24214 if( p->azPrompt[bContinue] ){
24215 return p->azPrompt[bContinue];
24216 }
24217 #ifndef SQLITE_SHELL_FIDDLE
24218 zPS = getenv(bContinue ? "SQLITE_PS2" : "SQLITE_PS1");
24219 if( zPS ) return zPS;
24220 #endif
24221 if( bContinue ){
24222 return SQLITE_PS2;
24223 }else{
24224 return SQLITE_PS1;
24225 }
24226 }
24227
24228 /*
24229 ** Return the name of the open database file, to be used for prompt
24230 ** expansion purposes.
24231 */
24232 static const char *prompt_filename(ShellState *p){
24233 sqlite3_filename pFN;
24234 const char *zFN = 0;
24235 if( p->pAuxDb->mFlgs & 0x01 ){
24236 zFN = p->pAuxDb->zDbFilename;
24237 }else if( p->db && (pFN = sqlite3_db_filename(p->db,0))!=0 ){
24238 zFN = sqlite3_filename_database(pFN);
24239 }
24240 if( zFN==0 || zFN[0]==0 ){
24241 zFN = "in-memory";
24242 }
24243 return zFN;
24244 }
24245
24246 /*
24247 ** Expand escapes in the given input prompt string. Return the
24248 ** expanded prompt in memory obtained from sqlite3_malloc(). The
24249 ** caller is responsible for freeing the memory.
24250 **
24251 ** Early prototypes use U+005c '\\' as the escape character. But
24252 ** that is an escape character for shells and C and many other languages,
24253 ** which can lead to nested quoting problems and confusion. The
24254 ** U+0025 '%' character was also tried, and that works pretty well on
24255 ** unix, but % is special to many formats on Windows. So now we
24256 ** use a forward-slash, U+002f '/', which seems to pass through
24257 ** every shell and "make" without issue.
24258 */
24259 static char *expand_prompt(
24260 ShellState *p, /* The current shell state */
24261 const char *zPrior, /* Prior input lines not yet processed */
24262 const char *zPrompt /* Prompt string to be expanded */
24263 ){
24264 sqlite3_str *pOut = sqlite3_str_new(0);
24265 int i;
24266 char c;
24267 int onoff = 1;
24268 int idxSpace = -1;
24269 for(i=0; zPrompt[i]; i++){
24270 if( zPrompt[i]!='/' ) continue;
24271 if( i>0 ){
24272 if( onoff ) sqlite3_str_append(pOut, zPrompt, i);
24273 zPrompt += i;
24274 i = 0;
24275 }
24276 /* At this point zPrompt[0] is a / character and all prior
24277 ** characters have already been loaded into pOut. Process the
24278 ** escape sequence that zPrompt points to. */
24279 c = zPrompt[1];
24280 if( c==0 ){
24281 /* / at the end of a line is silently ignored */
24282 break;
24283 }
24284 if( c=='/' ){
24285 /* // maps into a single / */
24286 zPrompt++;
24287 continue;
24288 }
24289 if( c>='0' && c<='7' ){
24290 /* /nnn becomes a single byte given by octal nnn */
24291 int v = c - '0';
24292 while( i<=2 && zPrompt[i+1]>='0' && zPrompt[i+1]<='7' ){
24293 v = v*8 + zPrompt[++i] - '0';
24294 }
24295 if( onoff ) sqlite3_str_appendchar(pOut, 1, v);
24296 zPrompt += i+1;
24297 i = -1;
24298 continue;
24299 }
24300 if( c=='e' ){
24301 /* /e is shorthand for /033 which is U+001B "Escape" */
24302 if( onoff ) sqlite3_str_append(pOut, "\033", 1);
24303 zPrompt += 2;
24304 i = -1;
24305 continue;
24306 }
24307
24308 /* The intent of the following codes it to provide alternative
24309 ** text displays depending on whether or not the connection is
24310 ** currently in a transaction. Example 1: Show a "*" before the ">"
24311 ** like psql: (Note: We encode the "*" as /052 to avoid closing
24312 ** out this comment.)
24313 **
24314 ** .prompt 'sqlite/x/052/;> '
24315 **
24316 ** Example 2: Show database filename is blue if not in a transaction,
24317 ** or red if within a transaction:
24318 **
24319 ** .prompt '/e[1;/x31/:34/;m~f>/e[0m '
24320 */
24321 if( c==':' ){
24322 /* toggle display on/off */
24323 onoff = !onoff;
24324 zPrompt += 2;
24325 i = -1;
24326 continue;
24327 }
24328 if( c==';' ){
24329 /* Turn display on */
24330 onoff = 1;
24331 zPrompt += 2;
24332 i = -1;
24333 continue;
24334 }
24335 if( c=='x' ){
24336 /* /x turns display off not in a transaction, on if in txn */
24337 onoff = p->db && !sqlite3_get_autocommit(p->db);
24338 zPrompt += 2;
24339 i = -1;
24340 continue;
24341 }
24342
24343 if( c=='f' || c=='F' || c=='~' ){
24344 /* /f becomes the tail of the database filename */
24345 /* /F becomes the full pathname */
24346 /* /~ becomes the full pathname relative to $HOME */
24347 if( onoff ){
24348 const char *zFN = prompt_filename(p);
24349 if( c=='f' ){
24350 #ifdef _WIN32
24351 const char *zTail = strrchr(zFN,'\\');
24352 #else
24353 const char *zTail = strrchr(zFN,'/');
24354 #endif
24355 if( zTail && zTail[1] ) zFN = &zTail[1];
24356 }else if( c=='~' ){
24357 const char *zHOME = getenv("HOME");
24358 size_t nHOME = zHOME ? strlen(zHOME) : 0;
24359 if( nHOME<strlen(zFN)
24360 && zHOME!=0 && zFN!=0 /* <--- these silence compiler warnings */
24361 && memcmp(zHOME,zFN,nHOME)==0
24362 ){
24363 sqlite3_str_append(pOut,"~",1);
24364 zFN += nHOME;
24365 }
24366 }
24367 sqlite3_str_appendall(pOut, zFN);
24368 }
24369 zPrompt += 2;
24370 i = -1;
24371 continue;
24372 }
24373
24374 if( c=='H' ){
24375 /* /H becomes text needed to terminate current input */
24376 if( onoff ){
24377 sqlite3_int64 R = zPrior ? sqlite3_incomplete(zPrior) : 0;
24378 int cc = (R>>16)&0xff;
24379 int nParen = R>>32;
24380 int eSemi = (R>>8)&0xff;
24381 if( cc==0 ){
24382 /* no-op */
24383 }else if( cc=='-' ){
24384 sqlite3_str_append(pOut,"\\n",3);
24385 }else if( cc=='/' ){
24386 sqlite3_str_append(pOut,"*/",2);
24387 }else{
24388 sqlite3_str_appendchar(pOut, 1, cc);
24389 }
24390 if( nParen>0 ){
24391 sqlite3_str_appendf(pOut, "%.*c",nParen,')');
24392 }
24393 if( eSemi==1 ){
24394 sqlite3_str_append(pOut, ";", 1);
24395 }else if( eSemi==2 ){
24396 sqlite3_str_append(pOut, "END;", 4);
24397 }else if( eSemi==3 ){
24398 sqlite3_str_append(pOut, ";END;", 5);
24399 }
24400 }
24401 zPrompt += 2;
24402 i = -1;
24403 continue;
24404 }
24405
24406 if( c=='B' ){
24407 /* /B is a no-op for the main prompt. For the continuation prompt,
24408 ** /B expands to zero or more spaces to make the continuation prompt
24409 ** at least as wide as the main prompt. */
24410 if( onoff ) idxSpace = sqlite3_str_length(pOut);
24411 zPrompt += 2;
24412 i = -1;
24413 continue;
24414 }
24415
24416 /* No match to a known escape. Generate an error. */
24417 if( onoff ) sqlite3_str_appendf(pOut,"UNKNOWN(\"/%c\")",c);
24418 zPrompt += 2;
24419 i = -1;
24420 }
24421 if( i>0 && onoff ){
24422 sqlite3_str_append(pOut, zPrompt, i);
24423 }
24424
24425 /* Expand the /B, if there is one and if this is a continuation prompt */
24426 if( idxSpace>=0 && zPrior!=0 && zPrior[0]!=0 ){
24427 char *zOther = expand_prompt(p, 0, prompt_string(p,0));
24428 size_t wOther = sqlite3_qrf_wcswidth(zOther);
24429 size_t wThis = sqlite3_qrf_wcswidth(sqlite3_str_value(pOut));
24430 sqlite3_free(zOther);
24431 if( wOther>wThis ){
24432 char *z;
24433 int len;
24434 size_t nNew = wOther - wThis;
24435 assert( nNew>0 && nNew<0x7fffffff );
24436 sqlite3_str_appendchar(pOut, (int)nNew, ' ');
24437 len = sqlite3_str_length(pOut);
24438 if( len>idxSpace ){
24439 z = sqlite3_str_value(pOut);
24440 memmove(z+idxSpace+nNew, z+idxSpace, len-nNew-idxSpace);
24441 memset(z+idxSpace, ' ', nNew);
24442 }
24443 }
24444 }
24445
24446 return sqlite3_str_finish(pOut);
24447 }
24448
24449 /*
24450 ** Retrieve a single line of input text.
24451 **
24452 ** If in==0 then read from standard input and prompt before each line.
24453 ** If bContinue is true, then a continuation prompt is appropriate.
24454 ** If bContinue is zero, then the main prompt should be used.
24455 **
24456 ** If zPrior is not NULL then it is a buffer from a prior call to this
24457 ** routine that can be reused.
24458 **
24459 ** The result is stored in space obtained from malloc() and must either
24460 ** be freed by the caller or else passed back into this routine via the
24461 ** zPrior argument for reuse.
24462 */
24463 #ifndef SQLITE_SHELL_FIDDLE
24464 static char *one_input_line(
24465 ShellState *p, /* Shell state */
24466 char *zPrior, /* Just the previous line */
24467 const char *zAll, /* All statement text accumulated so far */
24468 int bContinue /* True for a continuation prompt */
24469 ){
24470 char *zResult;
24471 FILE *in = p->in;
24472 if( in!=0 ){
24473 zResult = local_getline(zPrior, in);
24474 }else{
24475 const char *zBase = prompt_string(p, bContinue!=0);
24476 char *zPrompt = expand_prompt(p, zAll, zBase);
24477 shell_check_oom(zPrompt);
24478 #if SHELL_USE_LOCAL_GETLINE
24479 sputz(stdout, zPrompt);
24480 fflush(stdout);
24481 do{
24482 zResult = local_getline(zPrior, stdin);
@@ -24340,10 +24493,11 @@
24493 if( seenInterrupt==0 ) break;
24494 zResult = shell_readline("");
24495 }
24496 if( zResult && *zResult ) shell_add_history(zResult);
24497 #endif
24498 sqlite3_free(zPrompt);
24499 }
24500 return zResult;
24501 }
24502 #endif /* !SQLITE_SHELL_FIDDLE */
24503
@@ -24660,10 +24814,58 @@
24814 }
24815 }
24816 sqlite3_result_value(pCtx, apVal[0]);
24817 }
24818
24819 /*
24820 ** SQL function: shell_prompt_test(PROMPT)
24821 ** shell_prompt_test(PROMPT,PRIOR)
24822 ** shell_prompt_test(PROMPT,PRIOR,FILENAME)
24823 **
24824 ** Return the shell prompt, with escapes expanded, for testing purposes.
24825 ** The first argument is the raw (unexpanded) prompt string. Or if the
24826 ** first argument is NULL, then use whatever prompt string is currently
24827 ** configured. If the second argument exists and is not NULL, then the
24828 ** second argument is understood to be prior incomplete text and a
24829 ** continuation prompt is generated. If a third argument is provided,
24830 ** it is assumed to be the full pathname of the database file.
24831 */
24832 static void shellExpandPrompt(
24833 sqlite3_context *pCtx,
24834 int nVal,
24835 sqlite3_value **apVal
24836 ){
24837 ShellState *p = (ShellState*)sqlite3_user_data(pCtx);
24838 const char *zPrompt;
24839 const char *zPrior;
24840 const char *zSavedDbFile;
24841 int mSavedFlgs;
24842 const char *zFName;
24843 char *zRes;
24844
24845 if( nVal<2
24846 || (zPrior = (const char*)sqlite3_value_text(apVal[1]))==0
24847 || zPrior[0]==0
24848 ){
24849 zPrior = 0;
24850 }
24851 zPrompt = (const char*)sqlite3_value_text(apVal[0]);
24852 if( zPrompt==0 ){
24853 zPrompt = prompt_string(p, zPrior!=0);
24854 }
24855 zSavedDbFile = p->pAuxDb->zDbFilename;
24856 mSavedFlgs = p->pAuxDb->mFlgs;
24857 if( nVal>=3 && (zFName = (const char*)sqlite3_value_text(apVal[2]))!=0 ){
24858 p->pAuxDb->zDbFilename = zFName;
24859 p->pAuxDb->mFlgs |= 0x001;
24860 }
24861 zRes = expand_prompt(p, zPrior, zPrompt);
24862 p->pAuxDb->zDbFilename = zSavedDbFile;
24863 p->pAuxDb->mFlgs = mSavedFlgs;
24864 sqlite3_result_text(pCtx, zRes, -1, SQLITE_TRANSIENT);
24865 sqlite3_free(zRes);
24866 }
24867
24868 /************************* BEGIN PERFORMANCE TIMER *****************************/
24869 #if !defined(_WIN32) && !defined(WIN32) && !defined(__minux)
24870 #include <sys/time.h>
24871 #include <sys/resource.h>
@@ -27137,11 +27339,14 @@
27339 " --once Do no more than one progress interrupt",
27340 " --quiet|-q No output except at interrupts",
27341 " --reset Reset the count for each input and interrupt",
27342 " --timeout S Halt after running for S seconds",
27343 #endif
27344 ".prompt MAIN CONTINUE Replace the standard prompts",
27345 " --reset Revert to default prompts",
27346 " --show Show the current prompt strings",
27347 " -- No more options. Subsequent args are prompts",
27348 #ifndef SQLITE_SHELL_FIDDLE
27349 ".quit Stop interpreting input stream, exit if primary.",
27350 ".read FILE Read input from FILE or command output",
27351 " If FILE begins with \"|\", it is a command that generates the input.",
27352 #endif
@@ -27934,10 +28139,35 @@
28139 ** the database fails to open, print an error message and exit.
28140 */
28141 static void open_db(ShellState *p, int openFlags){
28142 if( p->db==0 ){
28143 const char *zDbFilename = p->pAuxDb->zDbFilename;
28144 const char *zHOME; /* Value of HOME environment variable */
28145 char *zToFree = 0; /* Filename with ~/ prefix expansion */
28146
28147 /* If the zDbFilename does not exist and begins with ~/ then replace
28148 ** the ~ with the home directory.
28149 */
28150 if( zDbFilename && zDbFilename[0]=='~'
28151 #ifdef _WIN32
28152 && (zDbFilename[1]=='/' || zDbFilename[1]=='\\')
28153 #else
28154 && zDbFilename[1]=='/'
28155 #endif
28156 && access(zDbFilename,0)!=0
28157 && (zHOME = getenv("HOME"))!=0 && zHOME[0]!=0
28158 ){
28159 size_t nHOME = strlen(zHOME);
28160 size_t nFN = strlen(zDbFilename);
28161 zToFree = malloc(nHOME+nFN+1);
28162 if( zToFree ){
28163 memcpy(zToFree, zHOME, nHOME);
28164 memcpy(zToFree+nHOME, zDbFilename+1, nFN);
28165 zDbFilename = zToFree;
28166 }
28167 }
28168
28169 if( p->openMode==SHELL_OPEN_UNSPEC ){
28170 if( zDbFilename==0 || zDbFilename[0]==0 ){
28171 p->openMode = SHELL_OPEN_NORMAL;
28172 }else{
28173 p->openMode = (u8)deduceDatabaseType(zDbFilename,
@@ -28067,10 +28297,17 @@
28297 sqlite3_create_function(p->db, "edit", 1, SQLITE_UTF8, 0,
28298 editFunc, 0, 0);
28299 sqlite3_create_function(p->db, "edit", 2, SQLITE_UTF8, 0,
28300 editFunc, 0, 0);
28301 #endif
28302 sqlite3_create_function(p->db, "shell_prompt_test", 1, SQLITE_UTF8,
28303 p, shellExpandPrompt, 0, 0);
28304 sqlite3_create_function(p->db, "shell_prompt_test", 2, SQLITE_UTF8,
28305 p, shellExpandPrompt, 0, 0);
28306 sqlite3_create_function(p->db, "shell_prompt_test", 3, SQLITE_UTF8,
28307 p, shellExpandPrompt, 0, 0);
28308
28309
28310 if( p->openMode==SHELL_OPEN_ZIPFILE ){
28311 char *zSql = sqlite3_mprintf(
28312 "CREATE VIRTUAL TABLE zip USING zipfile(%Q);", zDbFilename);
28313 shell_check_oom(zSql);
@@ -28100,10 +28337,11 @@
28337 if( p->szMax>0 ){
28338 sqlite3_file_control(p->db, "main", SQLITE_FCNTL_SIZE_LIMIT, &p->szMax);
28339 }
28340 }
28341 #endif
28342 free(zToFree);
28343 }
28344 if( p->db!=0 ){
28345 #ifndef SQLITE_OMIT_AUTHORIZATION
28346 if( p->bSafeModePersist ){
28347 sqlite3_set_authorizer(p->db, safeModeAuth, p);
@@ -33894,16 +34132,43 @@
34132 sqlite3_progress_handler(p->db, nn, progress_handler, p);
34133 }else
34134 #endif /* SQLITE_OMIT_PROGRESS_CALLBACK */
34135
34136 if( c=='p' && cli_strncmp(azArg[0], "prompt", n)==0 ){
34137 int i;
34138 int cnt = 0;
34139 int noOpt = 0;
34140 for(i=1; i<nArg; i++){
34141 const char *z = azArg[i];
34142 if( z[0]=='-' && !noOpt ){
34143 if( z[1]=='-' ) z++;
34144 if( strcmp(z,"-reset")==0 ){
34145 free(p->azPrompt[0]);
34146 free(p->azPrompt[1]);
34147 memset(p->azPrompt, 0, sizeof(p->azPrompt));
34148 }else
34149 if( strcmp(z,"-show")==0 ){
34150 cli_printf(stdout,"Main prompt: '%s'\n", prompt_string(p, 0));
34151 cli_printf(stdout,"Continuation: '%s'\n", prompt_string(p, 1));
34152 }else
34153 if( strcmp(z,"-")==0 ){
34154 noOpt = 1;
34155 }else
34156 {
34157 dotCmdError(p, i, "unknown option", 0);
34158 rc = 1;
34159 goto meta_command_exit;
34160 }
34161 }else if( cnt>1 ){
34162 dotCmdError(p, i, "extra argument", 0);
34163 rc = 1;
34164 goto meta_command_exit;
34165 }else{
34166 free(p->azPrompt[cnt]);
34167 p->azPrompt[cnt] = strdup(z);
34168 }
34169 }
34170 }else
34171
34172 #ifndef SQLITE_SHELL_FIDDLE
34173 if( c=='q' && cli_strncmp(azArg[0], "quit", n)==0 ){
34174 rc = 2;
@@ -35532,124 +35797,49 @@
35797 p->bSafeMode = p->bSafeModePersist;
35798 p->dot.nArg = 0;
35799 return rc;
35800 }
35801
35802 /*
35803 ** Test to see if a line consists entirely of whitespace.
35804 */
35805 static int line_is_all_whitespace(const char *z){
35806 for(; *z; z++){
35807 if( IsSpace(z[0]) ) continue;
35808 if( *z=='/' && z[1]=='*' ){
35809 z += 2;
35810 while( *z && (*z!='*' || z[1]!='/') ){ z++; }
35811 if( *z==0 ) return 0;
35812 z++;
35813 continue;
35814 }
35815 if( *z=='-' && z[1]=='-' ){
35816 z += 2;
35817 while( *z && *z!='\n' ){ z++; }
35818 if( *z==0 ) return 1;
35819 continue;
35820 }
35821 return 0;
35822 }
35823 return 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35824 }
35825
35826 /*
35827 ** Return TRUE if the line typed in is an SQL command terminator other
35828 ** than a semi-colon. The SQL Server style "go" command is understood
35829 ** as is the Oracle "/".
35830 */
35831 static int line_is_command_terminator(const char *zLine){
35832 while( IsSpace(zLine[0]) ){ zLine++; };
35833 if( zLine[0]=='/' && line_is_all_whitespace(&zLine[1]) ){
35834 return 1; /* Oracle */
35835 }
35836 if( ToLower(zLine[0])=='g' && ToLower(zLine[1])=='o'
35837 && line_is_all_whitespace(&zLine[2]) ){
35838 return 1; /* SQL Server */
35839 }
35840 return 0;
35841 }
35842
35843 /*
35844 ** The CLI needs a working sqlite3_complete() to work properly. So error
35845 ** out of the build if compiling with SQLITE_OMIT_COMPLETE.
@@ -35833,20 +36023,25 @@
36023 /*
36024 ** Alternate one_input_line() impl for wasm mode. This is not in the primary
36025 ** impl because we need the global shellState and cannot access it from that
36026 ** function without moving lots of code around (creating a larger/messier diff).
36027 */
36028 static char *one_input_line(
36029 ShellState *p, /* Shell state */
36030 char *zPrior, /* Just the prior line of text */
36031 const char *zAll, /* All accumulated statement text */
36032 int bContinue /* True if this is an accumulation */
36033 ){
36034 /* Parse the next line from shellState.wasm.zInput. */
36035 const char *zBegin = shellState.wasm.zPos;
36036 const char *z = zBegin;
36037 char *zLine = 0;
36038 i64 nZ = 0;
36039 FILE *in = p->in;
36040
36041 UNUSED_PARAMETER(in);
36042 UNUSED_PARAMETER(bContinue);
36043 if(!z || !*z){
36044 return 0;
36045 }
36046 while(*z && IsSpace(*z)) ++z;
36047 zBegin = z;
@@ -35878,12 +36073,12 @@
36073 i64 nLine; /* Length of current line */
36074 i64 nSql = 0; /* Bytes of zSql[] used */
36075 i64 nAlloc = 0; /* Allocated zSql[] space */
36076 int rc; /* Error code */
36077 int errCnt = 0; /* Number of errors seen */
36078 int hasSemi = 0; /* Input line contains a semicolon */
36079 i64 startline = 0; /* Line number for start of current input */
 
36080 const char *saved_zInFile; /* Prior value of p->zInFile */
36081 i64 saved_lineno; /* Prior value of p->lineno */
36082
36083 if( p->inputNesting==MAX_INPUT_NESTING ){
36084 /* This will be more informative in a later version. */
@@ -35894,14 +36089,13 @@
36089 ++p->inputNesting;
36090 saved_zInFile = p->zInFile;
36091 p->zInFile = zSrc;
36092 saved_lineno = p->lineno;
36093 p->lineno = 0;
 
36094 while( errCnt==0 || !bail_on_error || (p->in==0 && stdin_is_interactive) ){
36095 fflush(p->out);
36096 zLine = one_input_line(p, zLine, zSql, nSql>0);
36097 if( zLine==0 ){
36098 /* End of input */
36099 if( p->in==0 && stdin_is_interactive ) cli_puts("\n", p->out);
36100 break;
36101 }
@@ -35908,37 +36102,31 @@
36102 if( seenInterrupt ){
36103 if( p->in!=0 ) break;
36104 seenInterrupt = 0;
36105 }
36106 p->lineno++;
36107 if( nSql==0 && line_is_all_whitespace(zLine) ){
 
 
 
 
 
 
36108 /* Just swallow single-line whitespace */
36109 echo_group_input(p, zLine);
 
36110 continue;
36111 }
36112 if( zLine && (zLine[0]=='.' || zLine[0]=='#') && nSql==0 ){
 
36113 echo_group_input(p, zLine);
36114 if( zLine[0]=='.' ){
36115 rc = do_meta_command(zLine, p);
36116 if( rc==2 ){ /* exit requested */
36117 break;
36118 }else if( rc ){
36119 errCnt++;
36120 }
36121 }
 
36122 continue;
36123 }
36124 if( line_is_command_terminator(zLine) && line_is_complete(zSql, nSql) ){
36125 memcpy(zLine,";",2);
36126 }
36127 hasSemi = strchr(zLine,';')!=0;
36128 nLine = strlen(zLine);
36129 if( nSql+nLine+2>=nAlloc ){
36130 /* Grow buffer by half-again increments when big. */
36131 nAlloc = nSql+(nSql>>1)+nLine+100;
36132 zSql = realloc(zSql, nAlloc);
@@ -35962,14 +36150,14 @@
36150 cli_printf(stderr, "%s:%lld: Input SQL is too big: %s bytes\n",
36151 zSrc, startline, zSize);
36152 nSql = 0;
36153 errCnt++;
36154 break;
36155 }
36156 if( nSql && hasSemi && sqlite3_complete(zSql) ){
36157 echo_group_input(p, zSql);
36158 errCnt += runOneSqlLine(p, zSql, p->zInFile, startline);
 
36159 nSql = 0;
36160 if( p->nPopOutput ){
36161 output_reset(p);
36162 p->nPopOutput = 0;
36163 }else{
@@ -35978,22 +36166,19 @@
36166 if( p->nPopMode ){
36167 modePop(p);
36168 p->nPopMode = 0;
36169 }
36170 p->bSafeMode = p->bSafeModePersist;
36171 }else if( nSql && line_is_all_whitespace(zSql) ){
 
36172 echo_group_input(p, zSql);
36173 nSql = 0;
 
36174 }
36175 }
36176 if( nSql ){
36177 /* This may be incomplete. Let the SQL parser deal with that. */
36178 echo_group_input(p, zSql);
36179 errCnt += runOneSqlLine(p, zSql, p->zInFile, startline);
 
36180 }
36181 free(zSql);
36182 free(zLine);
36183 --p->inputNesting;
36184 p->zInFile = saved_zInFile;
@@ -36277,12 +36462,10 @@
36462 #if !defined(SQLITE_SHELL_FIDDLE)
36463 verify_uninitialized();
36464 #endif
36465 sqlite3_config(SQLITE_CONFIG_URI, 1);
36466 sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
 
 
36467 }
36468
36469 /*
36470 ** Output text to the console in a font that attracts extra attention.
36471 */
@@ -36334,11 +36517,12 @@
36517 ** memory. https://sqlite.org/forum/forumpost/310cb231b07c80d1.
36518 ** Testing this: if we (inadvertently) remove the
36519 ** sqlite3_reset_auto_extension() call from main(), most shell tests
36520 ** will fail because of a leak message in their output. */
36521 static int auto_ext_leak_tester(
36522 sqlite3 *db,
36523 char **pzErrMsg,
36524 const struct sqlite3_api_routines *pThunk
36525 ){
36526 (void)db; (void)pzErrMsg; (void)pThunk;
36527 return SQLITE_OK;
36528 }
@@ -37012,10 +37196,13 @@
37196 rc = runOneSqlLine(&data, azCmd[i], "cmdline", aiCmd[i]);
37197 if( data.nPopMode ){
37198 modePop(&data);
37199 data.nPopMode = 0;
37200 }
37201 if( rc ){
37202 goto shell_main_exit;
37203 }
37204 }
37205 if( data.nPopOutput && azCmd[i][0]!='.' ){
37206 output_reset(&data);
37207 data.nPopOutput = 0;
37208 }else{
@@ -37111,10 +37298,12 @@
37298 free(data.zNonce);
37299 free(data.dot.zCopy);
37300 free(data.dot.azArg);
37301 free(data.dot.aiOfst);
37302 free(data.dot.abQuot);
37303 free(data.azPrompt[0]);
37304 free(data.azPrompt[1]);
37305 if( data.nTestRun ){
37306 sqlite3_fprintf(stdout, "%d test%s run with %d error%s\n",
37307 data.nTestRun, data.nTestRun==1 ? "" : "s",
37308 data.nTestErr, data.nTestErr==1 ? "" : "s");
37309 fflush(stdout);
@@ -37270,7 +37459,11 @@
37459 shellState.wasm.zPos = zSql;
37460 process_input(&shellState, "<stdin>");
37461 shellState.wasm.zInput = shellState.wasm.zPos = 0;
37462 }
37463 }
37464
37465 char *fiddle_get_prompt(void){
37466 return expand_prompt(&shellState, 0, prompt_string(&shellState,0));
37467 }
37468 #endif /* SQLITE_SHELL_FIDDLE */
37469 /************************* End src/shell.c.in ******************/
37470
+207 -54
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.53.0. By combining all the individual C code files into this
3
+** version 3.54.0. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -16,11 +16,11 @@
1616
** if you want a wrapper to interface SQLite with your choice of programming
1717
** language. The code for the "sqlite3" command-line shell is also in a
1818
** separate file. This file contains only code for the core SQLite library.
1919
**
2020
** The content in this amalgamation comes from Fossil check-in
21
-** c8121593fa455cd43b3878f8b65ebac47c07 with changes in files:
21
+** 79a8d3edf8207d72f0c4650272ee239a1c77 with changes in files:
2222
**
2323
**
2424
*/
2525
#ifndef SQLITE_AMALGAMATION
2626
#define SQLITE_CORE 1
@@ -465,16 +465,16 @@
465465
**
466466
** See also: [sqlite3_libversion()],
467467
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468468
** [sqlite_version()] and [sqlite_source_id()].
469469
*/
470
-#define SQLITE_VERSION "3.53.0"
471
-#define SQLITE_VERSION_NUMBER 3053000
472
-#define SQLITE_SOURCE_ID "2026-04-07 09:15:21 c8121593fa455cd43b3878f8b65ebac47c07dab4b8ce081aa34b14fc9440afbc"
470
+#define SQLITE_VERSION "3.54.0"
471
+#define SQLITE_VERSION_NUMBER 3054000
472
+#define SQLITE_SOURCE_ID "2026-04-11 23:58:15 79a8d3edf8207d72f0c4650272ee239a1c7783a07f907fbf0cf5a7ad99b27a2a"
473473
#define SQLITE_SCM_BRANCH "trunk"
474474
#define SQLITE_SCM_TAGS ""
475
-#define SQLITE_SCM_DATETIME "2026-04-07T09:15:21.538Z"
475
+#define SQLITE_SCM_DATETIME "2026-04-11T23:58:15.898Z"
476476
477477
/*
478478
** CAPI3REF: Run-Time Library Version Numbers
479479
** KEYWORDS: sqlite3_version sqlite3_sourceid
480480
**
@@ -3279,39 +3279,51 @@
32793279
** CAPI3REF: Determine If An SQL Statement Is Complete
32803280
**
32813281
** These routines are useful during command-line input to determine if the
32823282
** currently entered text seems to form a complete SQL statement or
32833283
** if additional input is needed before sending the text into
3284
-** SQLite for parsing. ^These routines return 1 if the input string
3285
-** appears to be a complete SQL statement. ^A statement is judged to be
3284
+** SQLite for parsing. ^The sqlite3_complete(X) and sqlite3_complete16(X)
3285
+** routines return 1 if the input string X appears to be a complete SQL
3286
+** statement. ^A statement is judged to be
32863287
** complete if it ends with a semicolon token and is not a prefix of a
32873288
** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within
32883289
** string literals or quoted identifier names or comments are not
32893290
** independent tokens (they are part of the token in which they are
32903291
** embedded) and thus do not count as a statement terminator. ^Whitespace
32913292
** and comments that follow the final semicolon are ignored.
32923293
**
3293
-** ^These routines return 0 if the statement is incomplete. ^If a
3294
-** memory allocation fails, then SQLITE_NOMEM is returned.
3294
+** ^The sqlite3_complete(X) and sqlite3_complete16(X) routines return 0
3295
+** if the statement is incomplete. ^If a memory allocation fails, then
3296
+** SQLITE_NOMEM is returned.
32953297
**
3296
-** ^These routines do not parse the SQL statements and thus
3297
-** will not detect syntactically incorrect SQL.
3298
+** The [sqlite3_incomplete(X)] routine is similar to [sqlite3_complete(X)]
3299
+** except that sqlite3_incomplete(X) returns 0 if the input X is complete
3300
+** and non-zero if X is incomplete. The non-zero return from
3301
+** sqlite3_incomplete(X) contains additional information about what is
3302
+** needed to complete the input X. The sqlite3_incomplete(X) interface
3303
+** is only available for UTF-8 text.
3304
+**
3305
+** ^None of these routines do a full parse the SQL statements and thus
3306
+** will not detect syntactically incorrect SQL. They only determine if
3307
+** input text has properly terminated comments, string literals, and
3308
+** quoted identifiers, and if the statement ends with a semicolon.
32983309
**
32993310
** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
33003311
** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
33013312
** automatically by sqlite3_complete16(). If that initialization fails,
33023313
** then the return value from sqlite3_complete16() will be non-zero
33033314
** regardless of whether or not the input SQL is complete.)^
33043315
**
3305
-** The input to [sqlite3_complete()] must be a zero-terminated
3306
-** UTF-8 string.
3316
+** The X input to [sqlite3_complete(X)] and [sqlite3_incomplete(X)
3317
+** must be a zero-terminated UTF-8 string.
33073318
**
33083319
** The input to [sqlite3_complete16()] must be a zero-terminated
33093320
** UTF-16 string in native byte order.
33103321
*/
33113322
SQLITE_API int sqlite3_complete(const char *sql);
33123323
SQLITE_API int sqlite3_complete16(const void *sql);
3324
+SQLITE_API sqlite3_int64 sqlite3_incomplete(const char *sql);
33133325
33143326
/*
33153327
** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
33163328
** KEYWORDS: {busy-handler callback} {busy handler}
33173329
** METHOD: sqlite3
@@ -7934,11 +7946,11 @@
79347946
** entry point were as follows:
79357947
**
79367948
** <blockquote><pre>
79377949
** &nbsp; int xEntryPoint(
79387950
** &nbsp; sqlite3 *db,
7939
-** &nbsp; const char **pzErrMsg,
7951
+** &nbsp; char **pzErrMsg,
79407952
** &nbsp; const struct sqlite3_api_routines *pThunk
79417953
** &nbsp; );
79427954
** </pre></blockquote>)^
79437955
**
79447956
** If the xEntryPoint routine encounters an error, it should make *pzErrMsg
@@ -32511,11 +32523,11 @@
3251132523
if( pAccum->accError ) return 0;
3251232524
if( n>pAccum->nAlloc && n>pAccum->mxAlloc ){
3251332525
sqlite3StrAccumSetError(pAccum, SQLITE_TOOBIG);
3251432526
return 0;
3251532527
}
32516
- z = sqlite3DbMallocRaw(pAccum->db, n);
32528
+ z = sqlite3_malloc(n);
3251732529
if( z==0 ){
3251832530
sqlite3StrAccumSetError(pAccum, SQLITE_NOMEM);
3251932531
}
3252032532
return z;
3252132533
}
@@ -32967,17 +32979,33 @@
3296732979
e2 = 0;
3296832980
}else{
3296932981
e2 = s.iDP - 1;
3297032982
}
3297132983
32972
- szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+8;
32984
+ szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+10;
3297332985
if( cThousand && e2>0 ) szBufNeeded += (e2+2)/3;
32974
- if( sqlite3StrAccumEnlargeIfNeeded(pAccum, szBufNeeded) ){
32975
- width = length = 0;
32976
- break;
32986
+ if( szBufNeeded + pAccum->nChar >= pAccum->nAlloc ){
32987
+ if( pAccum->mxAlloc==0 && pAccum->accError==0 ){
32988
+ /* Unable to allocate space in pAccum, perhaps because it
32989
+ ** is coming from sqlite3_snprintf() or similar. We'll have
32990
+ ** to render into temporary space and the memcpy() it over. */
32991
+ bufpt = sqlite3_malloc(szBufNeeded);
32992
+ if( bufpt==0 ){
32993
+ sqlite3StrAccumSetError(pAccum, SQLITE_NOMEM);
32994
+ return;
32995
+ }
32996
+ zExtra = bufpt;
32997
+ }else if( sqlite3StrAccumEnlarge(pAccum, szBufNeeded)<szBufNeeded ){
32998
+ width = length = 0;
32999
+ break;
33000
+ }else{
33001
+ bufpt = pAccum->zText + pAccum->nChar;
33002
+ }
33003
+ }else{
33004
+ bufpt = pAccum->zText + pAccum->nChar;
3297733005
}
32978
- bufpt = zOut = pAccum->zText + pAccum->nChar;
33006
+ zOut = bufpt;
3297933007
3298033008
flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
3298133009
/* The sign in front of the number */
3298233010
if( prefix ){
3298333011
*(bufpt++) = prefix;
@@ -33074,18 +33102,26 @@
3307433102
memmove(zOut+nPad+adj, zOut+adj, length-adj);
3307533103
memset(zOut+adj, '0', nPad);
3307633104
}
3307733105
length = width;
3307833106
}
33079
- pAccum->nChar += length;
33080
- zOut[length] = 0;
33081
-
33082
- /* Floating point conversions render directly into the output
33083
- ** buffer. Hence, don't just break out of the switch(). Bypass the
33084
- ** output buffer writing that occurs after the switch() by continuing
33085
- ** to the next character in the format string. */
33086
- continue;
33107
+
33108
+ if( zExtra==0 ){
33109
+ /* The result is being rendered directory into pAccum. This
33110
+ ** is the command and fast case */
33111
+ pAccum->nChar += length;
33112
+ zOut[length] = 0;
33113
+ continue;
33114
+ }else{
33115
+ /* We were unable to render directly into pAccum because we
33116
+ ** couldn't allocate sufficient memory. We need to memcpy()
33117
+ ** the rendering (or some prefix thereof) into the output
33118
+ ** buffer. */
33119
+ bufpt[0] = 0;
33120
+ bufpt = zExtra;
33121
+ break;
33122
+ }
3308733123
}
3308833124
case etSIZE:
3308933125
if( !bArgList ){
3309033126
*(va_arg(ap,int*)) = pAccum->nChar;
3309133127
}
@@ -33128,11 +33164,11 @@
3312833164
if( nPrior > precision-1 ) nPrior = precision - 1;
3312933165
nCopyBytes = length*nPrior;
3313033166
if( sqlite3StrAccumEnlargeIfNeeded(pAccum, nCopyBytes) ){
3313133167
break;
3313233168
}
33133
- sqlite3_str_append(pAccum,
33169
+ sqlite3_str_append(pAccum,
3313433170
&pAccum->zText[pAccum->nChar-nCopyBytes], nCopyBytes);
3313533171
precision -= nPrior;
3313633172
nPrior *= 2;
3313733173
}
3313833174
}
@@ -36351,11 +36387,18 @@
3635136387
*/
3635236388
/* #include "sqliteInt.h" */
3635336389
/* #include <stdarg.h> */
3635436390
#ifndef SQLITE_OMIT_FLOATING_POINT
3635536391
#include <math.h>
36392
+
36393
+/* Work around a bug in older Microsoft compilers
36394
+** Forum post 2026-04-10T06:33:11z */
36395
+#if !defined(INFINITY) && defined(_MSC_VER)
36396
+# define INFINITY HUGE_VAL
3635636397
#endif
36398
+
36399
+#endif /* SQLITE_OMIT_FLOATING_POINT */
3635736400
3635836401
/*
3635936402
** Calls to sqlite3FaultSim() are used to simulate a failure during testing,
3636036403
** or to bypass normal error detection during testing in order to let
3636136404
** execute proceed further downstream.
@@ -46782,11 +46825,26 @@
4678246825
** sqlite3_uri_parameter(). */
4678346826
assert( (flags & SQLITE_OPEN_URI) || zName[strlen(zName)+1]==0 );
4678446827
4678546828
}else if( !zName ){
4678646829
/* If zName is NULL, the upper layer is requesting a temp file. */
46787
- assert(isDelete && !isNewJrnl);
46830
+ assert( isDelete );
46831
+ assert( !isNewJrnl );
46832
+ assert( isExclusive );
46833
+ assert( isReadWrite );
46834
+#if defined(__linux__) && defined(O_TMPFILE)
46835
+ /* On systems that support O_TMPFILE, use that flag to create a more
46836
+ ** secure temporary file that cannot be accessed by other processes
46837
+ */
46838
+ zName = unixTempFileDir();
46839
+ if( zName
46840
+ && (fd = robust_open(zName, O_RDWR|O_CREAT|O_EXCL|O_TMPFILE, 0600))>=0
46841
+ ){
46842
+ rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);
46843
+ goto open_finished;
46844
+ }
46845
+#endif
4678846846
rc = unixGetTempname(pVfs->mxPathname, zTmpname);
4678946847
if( rc!=SQLITE_OK ){
4679046848
return rc;
4679146849
}
4679246850
zName = zTmpname;
@@ -93142,16 +93200,16 @@
9314293200
UnpackedRecord *p, /* Index key being deleted */
9314393201
int *piRes /* 0 for a match, non-zero for not a match */
9314493202
){
9314593203
u8 *aRec = 0;
9314693204
u32 nRec = 0;
93147
- Mem mem;
93205
+ Mem m;
9314893206
int rc = SQLITE_OK;
9314993207
93150
- memset(&mem, 0, sizeof(mem));
93151
- mem.enc = p->pKeyInfo->enc;
93152
- mem.db = p->pKeyInfo->db;
93208
+ memset(&m, 0, sizeof(m));
93209
+ m.enc = p->pKeyInfo->enc;
93210
+ m.db = p->pKeyInfo->db;
9315393211
nRec = sqlite3BtreePayloadSize(pCur);
9315493212
if( nRec>0x7fffffff ){
9315593213
return SQLITE_CORRUPT_BKPT;
9315693214
}
9315793215
@@ -93189,13 +93247,13 @@
9318993247
idxHdr += getVarint32(&aRec[idxHdr], iSerial);
9319093248
nSerial = sqlite3VdbeSerialTypeLen(iSerial);
9319193249
if( (idxRec+nSerial)>nRec ){
9319293250
rc = SQLITE_CORRUPT_BKPT;
9319393251
}else{
93194
- sqlite3VdbeSerialGet(&aRec[idxRec], iSerial, &mem);
93195
- if( vdbeSkipField(mask, ii, &p->aMem[ii], &mem, bInt)==0 ){
93196
- res = sqlite3MemCompare(&mem, &p->aMem[ii], p->pKeyInfo->aColl[ii]);
93252
+ sqlite3VdbeSerialGet(&aRec[idxRec], iSerial, &m);
93253
+ if( vdbeSkipField(mask, ii, &p->aMem[ii], &m, bInt)==0 ){
93254
+ res = sqlite3MemCompare(&m, &p->aMem[ii], p->pKeyInfo->aColl[ii]);
9319793255
if( res!=0 ) break;
9319893256
}
9319993257
}
9320093258
idxRec += sqlite3VdbeSerialTypeLen(iSerial);
9320193259
}
@@ -142568,10 +142626,12 @@
142568142626
/* Version 3.52.0 and later */
142569142627
void (*str_truncate)(sqlite3_str*,int);
142570142628
void (*str_free)(sqlite3_str*);
142571142629
int (*carray_bind)(sqlite3_stmt*,int,void*,int,int,void(*)(void*));
142572142630
int (*carray_bind_v2)(sqlite3_stmt*,int,void*,int,int,void(*)(void*),void*);
142631
+ /* Version 3.54.0 and later */
142632
+ sqlite3_int64 (*incomplete)(const char*);
142573142633
};
142574142634
142575142635
/*
142576142636
** This is the function signature used for all extension entry points. It
142577142637
** is also defined in the file "loadext.c".
@@ -142911,10 +142971,12 @@
142911142971
/* Version 3.52.0 and later */
142912142972
#define sqlite3_str_truncate sqlite3_api->str_truncate
142913142973
#define sqlite3_str_free sqlite3_api->str_free
142914142974
#define sqlite3_carray_bind sqlite3_api->carray_bind
142915142975
#define sqlite3_carray_bind_v2 sqlite3_api->carray_bind_v2
142976
+/* Version 3.54.0 and later */
142977
+#define sqlite3_incomplete sqlite3_api->incomplete
142916142978
#endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
142917142979
142918142980
#if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
142919142981
/* This case when the file really is being compiled as a loadable
142920142982
** extension */
@@ -143443,15 +143505,16 @@
143443143505
/* Version 3.52.0 and later */
143444143506
sqlite3_str_truncate,
143445143507
sqlite3_str_free,
143446143508
#ifdef SQLITE_ENABLE_CARRAY
143447143509
sqlite3_carray_bind,
143448
- sqlite3_carray_bind_v2
143510
+ sqlite3_carray_bind_v2,
143449143511
#else
143512
+ 0,
143450143513
0,
143451
- 0
143452143514
#endif
143515
+ sqlite3_incomplete
143453143516
};
143454143517
143455143518
/* True if x is the directory separator character
143456143519
*/
143457143520
#if SQLITE_OS_WIN
@@ -186736,15 +186799,54 @@
186736186799
#define tkTRIGGER 6
186737186800
#define tkEND 7
186738186801
#endif
186739186802
186740186803
/*
186741
-** Return TRUE if the given SQL string ends in a semicolon.
186804
+** Return zero if the given SQL string is complete - if all comments,
186805
+** string and blob literals, and quoted identifiers have been closed and
186806
+** if the entire string ends with ";" and possible with ";END;" if the
186807
+** string is a CREATE TRIGGER statement. A non-zero return indicates
186808
+** that the string is incomplete. Bits of the return value indicate
186809
+** what is missing and is needed to close out the statement.
186742186810
**
186743186811
** Special handling is require for CREATE TRIGGER statements.
186744186812
** Whenever the CREATE TRIGGER keywords are seen, the statement
186745186813
** must end with ";END;".
186814
+**
186815
+** Let the return code be a value R. R is split up into various
186816
+** subfields, at byte boundaries:
186817
+**
186818
+** R = 0xwwwwwwww00xxyyzz
186819
+**
186820
+** In other words, zz is the least significant byte, yy is the next
186821
+** most significant byte, xx is the third byte, wwwwwwww is a 32-bit
186822
+** value from the middle.
186823
+**
186824
+** zz == SQLITE_OK Input is complete
186825
+** zz == SQLITE_ERROR Input is incomplete
186826
+** zz == SQLITE_MISUSE Input is a NULL pointer
186827
+** zz != 0 New values for zz may be added in the future
186828
+**
186829
+** yy == 0x01 Need a semicolon at the end
186830
+** yy == 0x02 Need "END" and a semicolon
186831
+** yy == 0x03 Need semicolon, "END", and semicolon
186832
+** yy != 0 New values for yy may be added in the future
186833
+**
186834
+** xx == '\'' Incomplete string or blob literal
186835
+** xx == '"' Incomplete quoted identifier
186836
+** xx == '`' Incompelte MySQL-style quoted identifier
186837
+** xx == ']' Incomplete SQLServer-style quoted identifer
186838
+** xx == '-' Incomplete SQL-style comment
186839
+** xx == '/' Incomplete C-style comment
186840
+** xx != 0 New values of xx may be added in the future
186841
+**
186842
+** wwwwwwww Interpret as a signed integer, the number
186843
+** of unmatched "(". Negative means there are
186844
+** more ")" and "(".
186845
+**
186846
+** ((R>>24)&0xff)!=0 New uses for the 4th byte may be added
186847
+** in the future
186746186848
**
186747186849
** This implementation uses a state machine with 8 states:
186748186850
**
186749186851
** (0) INVALID We have not yet seen a non-whitespace character.
186750186852
**
@@ -186788,13 +186890,15 @@
186788186890
**
186789186891
** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
186790186892
** to recognize the end of a trigger can be omitted. All we have to do
186791186893
** is look for a semicolon that is not part of an string or comment.
186792186894
*/
186793
-SQLITE_API int sqlite3_complete(const char *zSql){
186895
+SQLITE_API sqlite3_int64 sqlite3_incomplete(const char *zSql){
186794186896
u8 state = 0; /* Current state, using numbers defined in header comment */
186795186897
u8 token; /* Value of the next token */
186898
+ u8 pending = 0; /* unmatched structure character */
186899
+ int nParen = 0; /* Nested parentheses */
186796186900
186797186901
#ifndef SQLITE_OMIT_TRIGGER
186798186902
/* A complex statement machine used to detect the end of a CREATE TRIGGER
186799186903
** statement. This is the normal case.
186800186904
*/
@@ -186820,15 +186924,25 @@
186820186924
/* 0 INVALID: */ { 1, 0, 2, },
186821186925
/* 1 START: */ { 1, 1, 2, },
186822186926
/* 2 NORMAL: */ { 1, 2, 2, },
186823186927
};
186824186928
#endif /* SQLITE_OMIT_TRIGGER */
186929
+ /* Mapping state number to yy value for the return */
186930
+ static const u8 statemap[8] = {
186931
+ /* 0 INVALID */ 1,
186932
+ /* 1 START */ 0,
186933
+ /* 2 NORMAL */ 1,
186934
+ /* 3 EXPLAIN */ 1,
186935
+ /* 4 CREATE */ 1,
186936
+ /* 5 TRIGGER */ 3,
186937
+ /* 6 SEMI */ 2,
186938
+ /* 7 END */ 1,
186939
+ };
186825186940
186826186941
#ifdef SQLITE_ENABLE_API_ARMOR
186827186942
if( zSql==0 ){
186828
- (void)SQLITE_MISUSE_BKPT;
186829
- return 0;
186943
+ return SQLITE_MISUSE_BKPT;
186830186944
}
186831186945
#endif
186832186946
186833186947
while( *zSql ){
186834186948
switch( *zSql ){
@@ -186849,11 +186963,14 @@
186849186963
token = tkOTHER;
186850186964
break;
186851186965
}
186852186966
zSql += 2;
186853186967
while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; }
186854
- if( zSql[0]==0 ) return 0;
186968
+ if( zSql[0]==0 ){
186969
+ pending = '/';
186970
+ goto incomplete_finish;
186971
+ }
186855186972
zSql++;
186856186973
token = tkWS;
186857186974
break;
186858186975
}
186859186976
case '-': { /* SQL-style comments from "--" to end of line */
@@ -186860,28 +186977,47 @@
186860186977
if( zSql[1]!='-' ){
186861186978
token = tkOTHER;
186862186979
break;
186863186980
}
186864186981
while( *zSql && *zSql!='\n' ){ zSql++; }
186865
- if( *zSql==0 ) return state==1;
186982
+ if( *zSql==0 ){
186983
+ if( state!=1 ) pending = '-';
186984
+ goto incomplete_finish;
186985
+ }
186866186986
token = tkWS;
186867186987
break;
186868186988
}
186869186989
case '[': { /* Microsoft-style identifiers in [...] */
186870186990
zSql++;
186871186991
while( *zSql && *zSql!=']' ){ zSql++; }
186872
- if( *zSql==0 ) return 0;
186992
+ if( *zSql==0 ){
186993
+ pending = ']';
186994
+ goto incomplete_finish;
186995
+ }
186873186996
token = tkOTHER;
186874186997
break;
186875186998
}
186876186999
case '`': /* Grave-accent quoted symbols used by MySQL */
186877187000
case '"': /* single- and double-quoted strings */
186878187001
case '\'': {
186879187002
int c = *zSql;
186880187003
zSql++;
186881187004
while( *zSql && *zSql!=c ){ zSql++; }
186882
- if( *zSql==0 ) return 0;
187005
+ if( *zSql==0 ){
187006
+ pending = c;
187007
+ goto incomplete_finish;
187008
+ }
187009
+ token = tkOTHER;
187010
+ break;
187011
+ }
187012
+ case '(': {
187013
+ nParen++;
187014
+ token = tkOTHER;
187015
+ break;
187016
+ }
187017
+ case ')': {
187018
+ nParen--;
186883187019
token = tkOTHER;
186884187020
break;
186885187021
}
186886187022
default: {
186887187023
#ifdef SQLITE_EBCDIC
@@ -186944,11 +187080,19 @@
186944187080
}
186945187081
}
186946187082
state = trans[state][token];
186947187083
zSql++;
186948187084
}
186949
- return state==1;
187085
+incomplete_finish:
187086
+ if( state==1 ) nParen = 0;
187087
+ return (i64)((((u64)nParen)<<32) |
187088
+ ((u64)pending<<16) |
187089
+ ((u64)statemap[state]<<8) |
187090
+ (state!=1));
187091
+}
187092
+SQLITE_API int sqlite3_complete(const char *zSql){
187093
+ return sqlite3_incomplete(zSql)==0;
186950187094
}
186951187095
186952187096
#ifndef SQLITE_OMIT_UTF16
186953187097
/*
186954187098
** This routine is the same as the sqlite3_complete() routine described
@@ -186966,11 +187110,11 @@
186966187110
#endif
186967187111
pVal = sqlite3ValueNew(0);
186968187112
sqlite3ValueSetStr(pVal, -1, zSql, SQLITE_UTF16NATIVE, SQLITE_STATIC);
186969187113
zSql8 = sqlite3ValueText(pVal, SQLITE_UTF8);
186970187114
if( zSql8 ){
186971
- rc = sqlite3_complete(zSql8);
187115
+ rc = sqlite3_incomplete(zSql8)==0;
186972187116
}else{
186973187117
rc = SQLITE_NOMEM_BKPT;
186974187118
}
186975187119
sqlite3ValueFree(pVal);
186976187120
return rc & 0xff;
@@ -233667,10 +233811,11 @@
233667233811
** Return the number of bytes read.
233668233812
*/
233669233813
static int sessionVarintGetSafe(const u8 *aBuf, int nBuf, int *piVal){
233670233814
u8 aCopy[9];
233671233815
const u8 *aRead = aBuf;
233816
+ memset(aCopy, 0, sizeof(aCopy));
233672233817
if( nBuf<sizeof(aCopy) ){
233673233818
memcpy(aCopy, aBuf, nBuf);
233674233819
aRead = aCopy;
233675233820
}
233676233821
return getVarint32(aRead, *piVal);
@@ -236997,25 +237142,29 @@
236997237142
SessionInput *pIn, /* Input data */
236998237143
int nCol, /* Number of columns in record */
236999237144
int *pnByte /* OUT: Size of record in bytes */
237000237145
){
237001237146
int rc = SQLITE_OK;
237002
- int nByte = 0;
237147
+ i64 nByte = 0;
237003237148
int i;
237004237149
for(i=0; rc==SQLITE_OK && i<nCol; i++){
237005237150
int eType;
237006237151
rc = sessionInputBuffer(pIn, nByte + 10);
237007237152
if( rc==SQLITE_OK ){
237008237153
eType = pIn->aData[pIn->iNext + nByte++];
237009237154
if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){
237010237155
int n;
237011
- nByte += sessionVarintGet(&pIn->aData[pIn->iNext+nByte], &n);
237156
+ int nRem = pIn->nData - (pIn->iNext + nByte);
237157
+ nByte += sessionVarintGetSafe(&pIn->aData[pIn->iNext+nByte], nRem, &n);
237012237158
nByte += n;
237013237159
rc = sessionInputBuffer(pIn, nByte);
237014237160
}else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
237015237161
nByte += 8;
237016237162
}
237163
+ }
237164
+ if( (pIn->iNext+nByte)>pIn->nData ){
237165
+ rc = SQLITE_CORRUPT_BKPT;
237017237166
}
237018237167
}
237019237168
*pnByte = nByte;
237020237169
return rc;
237021237170
}
@@ -239028,10 +239177,14 @@
239028239177
239029239178
/*
239030239179
** This function is called to merge two changes to the same row together as
239031239180
** part of an sqlite3changeset_concat() operation. A new change object is
239032239181
** allocated and a pointer to it stored in *ppNew.
239182
+**
239183
+** Because they have been vetted by sqlite3changegroup_add() or similar,
239184
+** both the aRec[] change and the pExist change are safe to use without
239185
+** checking for buffer overflows.
239033239186
*/
239034239187
static int sessionChangeMerge(
239035239188
SessionTable *pTab, /* Table structure */
239036239189
int bRebase, /* True for a rebase hash-table */
239037239190
int bPatchset, /* True for patchsets */
@@ -239168,11 +239321,11 @@
239168239321
pNew->op = SQLITE_UPDATE;
239169239322
if( bPatchset ){
239170239323
memcpy(aCsr, aRec, nRec);
239171239324
aCsr += nRec;
239172239325
}else{
239173
- if( 0==sessionMergeUpdate(&aCsr, pTab, bPatchset, aExist, 0,aRec,0) ){
239326
+ if( 0==sessionMergeUpdate(&aCsr, pTab, bPatchset, aExist,0,aRec,0) ){
239174239327
sqlite3_free(pNew);
239175239328
pNew = 0;
239176239329
}
239177239330
}
239178239331
}else if( op2==SQLITE_UPDATE ){ /* UPDATE + UPDATE */
@@ -263211,11 +263364,11 @@
263211263364
int nArg, /* Number of args */
263212263365
sqlite3_value **apUnused /* Function arguments */
263213263366
){
263214263367
assert( nArg==0 );
263215263368
UNUSED_PARAM2(nArg, apUnused);
263216
- sqlite3_result_text(pCtx, "fts5: 2026-04-07 09:15:21 c8121593fa455cd43b3878f8b65ebac47c07dab4b8ce081aa34b14fc9440afbc", -1, SQLITE_TRANSIENT);
263369
+ sqlite3_result_text(pCtx, "fts5: 2026-04-11 22:18:05 6fa0216a19c2f165110121227d3f9b9119369f8cd61f9c6d13eaa1ae42a60d60", -1, SQLITE_TRANSIENT);
263217263370
}
263218263371
263219263372
/*
263220263373
** Implementation of fts5_locale(LOCALE, TEXT) function.
263221263374
**
263222263375
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.53.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** c8121593fa455cd43b3878f8b65ebac47c07 with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -465,16 +465,16 @@
465 **
466 ** See also: [sqlite3_libversion()],
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.53.0"
471 #define SQLITE_VERSION_NUMBER 3053000
472 #define SQLITE_SOURCE_ID "2026-04-07 09:15:21 c8121593fa455cd43b3878f8b65ebac47c07dab4b8ce081aa34b14fc9440afbc"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2026-04-07T09:15:21.538Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -3279,39 +3279,51 @@
3279 ** CAPI3REF: Determine If An SQL Statement Is Complete
3280 **
3281 ** These routines are useful during command-line input to determine if the
3282 ** currently entered text seems to form a complete SQL statement or
3283 ** if additional input is needed before sending the text into
3284 ** SQLite for parsing. ^These routines return 1 if the input string
3285 ** appears to be a complete SQL statement. ^A statement is judged to be
 
3286 ** complete if it ends with a semicolon token and is not a prefix of a
3287 ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within
3288 ** string literals or quoted identifier names or comments are not
3289 ** independent tokens (they are part of the token in which they are
3290 ** embedded) and thus do not count as a statement terminator. ^Whitespace
3291 ** and comments that follow the final semicolon are ignored.
3292 **
3293 ** ^These routines return 0 if the statement is incomplete. ^If a
3294 ** memory allocation fails, then SQLITE_NOMEM is returned.
 
3295 **
3296 ** ^These routines do not parse the SQL statements and thus
3297 ** will not detect syntactically incorrect SQL.
 
 
 
 
 
 
 
 
 
3298 **
3299 ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
3300 ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
3301 ** automatically by sqlite3_complete16(). If that initialization fails,
3302 ** then the return value from sqlite3_complete16() will be non-zero
3303 ** regardless of whether or not the input SQL is complete.)^
3304 **
3305 ** The input to [sqlite3_complete()] must be a zero-terminated
3306 ** UTF-8 string.
3307 **
3308 ** The input to [sqlite3_complete16()] must be a zero-terminated
3309 ** UTF-16 string in native byte order.
3310 */
3311 SQLITE_API int sqlite3_complete(const char *sql);
3312 SQLITE_API int sqlite3_complete16(const void *sql);
 
3313
3314 /*
3315 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
3316 ** KEYWORDS: {busy-handler callback} {busy handler}
3317 ** METHOD: sqlite3
@@ -7934,11 +7946,11 @@
7934 ** entry point were as follows:
7935 **
7936 ** <blockquote><pre>
7937 ** &nbsp; int xEntryPoint(
7938 ** &nbsp; sqlite3 *db,
7939 ** &nbsp; const char **pzErrMsg,
7940 ** &nbsp; const struct sqlite3_api_routines *pThunk
7941 ** &nbsp; );
7942 ** </pre></blockquote>)^
7943 **
7944 ** If the xEntryPoint routine encounters an error, it should make *pzErrMsg
@@ -32511,11 +32523,11 @@
32511 if( pAccum->accError ) return 0;
32512 if( n>pAccum->nAlloc && n>pAccum->mxAlloc ){
32513 sqlite3StrAccumSetError(pAccum, SQLITE_TOOBIG);
32514 return 0;
32515 }
32516 z = sqlite3DbMallocRaw(pAccum->db, n);
32517 if( z==0 ){
32518 sqlite3StrAccumSetError(pAccum, SQLITE_NOMEM);
32519 }
32520 return z;
32521 }
@@ -32967,17 +32979,33 @@
32967 e2 = 0;
32968 }else{
32969 e2 = s.iDP - 1;
32970 }
32971
32972 szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+8;
32973 if( cThousand && e2>0 ) szBufNeeded += (e2+2)/3;
32974 if( sqlite3StrAccumEnlargeIfNeeded(pAccum, szBufNeeded) ){
32975 width = length = 0;
32976 break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32977 }
32978 bufpt = zOut = pAccum->zText + pAccum->nChar;
32979
32980 flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
32981 /* The sign in front of the number */
32982 if( prefix ){
32983 *(bufpt++) = prefix;
@@ -33074,18 +33102,26 @@
33074 memmove(zOut+nPad+adj, zOut+adj, length-adj);
33075 memset(zOut+adj, '0', nPad);
33076 }
33077 length = width;
33078 }
33079 pAccum->nChar += length;
33080 zOut[length] = 0;
33081
33082 /* Floating point conversions render directly into the output
33083 ** buffer. Hence, don't just break out of the switch(). Bypass the
33084 ** output buffer writing that occurs after the switch() by continuing
33085 ** to the next character in the format string. */
33086 continue;
 
 
 
 
 
 
 
 
33087 }
33088 case etSIZE:
33089 if( !bArgList ){
33090 *(va_arg(ap,int*)) = pAccum->nChar;
33091 }
@@ -33128,11 +33164,11 @@
33128 if( nPrior > precision-1 ) nPrior = precision - 1;
33129 nCopyBytes = length*nPrior;
33130 if( sqlite3StrAccumEnlargeIfNeeded(pAccum, nCopyBytes) ){
33131 break;
33132 }
33133 sqlite3_str_append(pAccum,
33134 &pAccum->zText[pAccum->nChar-nCopyBytes], nCopyBytes);
33135 precision -= nPrior;
33136 nPrior *= 2;
33137 }
33138 }
@@ -36351,11 +36387,18 @@
36351 */
36352 /* #include "sqliteInt.h" */
36353 /* #include <stdarg.h> */
36354 #ifndef SQLITE_OMIT_FLOATING_POINT
36355 #include <math.h>
 
 
 
 
 
36356 #endif
 
 
36357
36358 /*
36359 ** Calls to sqlite3FaultSim() are used to simulate a failure during testing,
36360 ** or to bypass normal error detection during testing in order to let
36361 ** execute proceed further downstream.
@@ -46782,11 +46825,26 @@
46782 ** sqlite3_uri_parameter(). */
46783 assert( (flags & SQLITE_OPEN_URI) || zName[strlen(zName)+1]==0 );
46784
46785 }else if( !zName ){
46786 /* If zName is NULL, the upper layer is requesting a temp file. */
46787 assert(isDelete && !isNewJrnl);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46788 rc = unixGetTempname(pVfs->mxPathname, zTmpname);
46789 if( rc!=SQLITE_OK ){
46790 return rc;
46791 }
46792 zName = zTmpname;
@@ -93142,16 +93200,16 @@
93142 UnpackedRecord *p, /* Index key being deleted */
93143 int *piRes /* 0 for a match, non-zero for not a match */
93144 ){
93145 u8 *aRec = 0;
93146 u32 nRec = 0;
93147 Mem mem;
93148 int rc = SQLITE_OK;
93149
93150 memset(&mem, 0, sizeof(mem));
93151 mem.enc = p->pKeyInfo->enc;
93152 mem.db = p->pKeyInfo->db;
93153 nRec = sqlite3BtreePayloadSize(pCur);
93154 if( nRec>0x7fffffff ){
93155 return SQLITE_CORRUPT_BKPT;
93156 }
93157
@@ -93189,13 +93247,13 @@
93189 idxHdr += getVarint32(&aRec[idxHdr], iSerial);
93190 nSerial = sqlite3VdbeSerialTypeLen(iSerial);
93191 if( (idxRec+nSerial)>nRec ){
93192 rc = SQLITE_CORRUPT_BKPT;
93193 }else{
93194 sqlite3VdbeSerialGet(&aRec[idxRec], iSerial, &mem);
93195 if( vdbeSkipField(mask, ii, &p->aMem[ii], &mem, bInt)==0 ){
93196 res = sqlite3MemCompare(&mem, &p->aMem[ii], p->pKeyInfo->aColl[ii]);
93197 if( res!=0 ) break;
93198 }
93199 }
93200 idxRec += sqlite3VdbeSerialTypeLen(iSerial);
93201 }
@@ -142568,10 +142626,12 @@
142568 /* Version 3.52.0 and later */
142569 void (*str_truncate)(sqlite3_str*,int);
142570 void (*str_free)(sqlite3_str*);
142571 int (*carray_bind)(sqlite3_stmt*,int,void*,int,int,void(*)(void*));
142572 int (*carray_bind_v2)(sqlite3_stmt*,int,void*,int,int,void(*)(void*),void*);
 
 
142573 };
142574
142575 /*
142576 ** This is the function signature used for all extension entry points. It
142577 ** is also defined in the file "loadext.c".
@@ -142911,10 +142971,12 @@
142911 /* Version 3.52.0 and later */
142912 #define sqlite3_str_truncate sqlite3_api->str_truncate
142913 #define sqlite3_str_free sqlite3_api->str_free
142914 #define sqlite3_carray_bind sqlite3_api->carray_bind
142915 #define sqlite3_carray_bind_v2 sqlite3_api->carray_bind_v2
 
 
142916 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
142917
142918 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
142919 /* This case when the file really is being compiled as a loadable
142920 ** extension */
@@ -143443,15 +143505,16 @@
143443 /* Version 3.52.0 and later */
143444 sqlite3_str_truncate,
143445 sqlite3_str_free,
143446 #ifdef SQLITE_ENABLE_CARRAY
143447 sqlite3_carray_bind,
143448 sqlite3_carray_bind_v2
143449 #else
 
143450 0,
143451 0
143452 #endif
 
143453 };
143454
143455 /* True if x is the directory separator character
143456 */
143457 #if SQLITE_OS_WIN
@@ -186736,15 +186799,54 @@
186736 #define tkTRIGGER 6
186737 #define tkEND 7
186738 #endif
186739
186740 /*
186741 ** Return TRUE if the given SQL string ends in a semicolon.
 
 
 
 
 
186742 **
186743 ** Special handling is require for CREATE TRIGGER statements.
186744 ** Whenever the CREATE TRIGGER keywords are seen, the statement
186745 ** must end with ";END;".
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186746 **
186747 ** This implementation uses a state machine with 8 states:
186748 **
186749 ** (0) INVALID We have not yet seen a non-whitespace character.
186750 **
@@ -186788,13 +186890,15 @@
186788 **
186789 ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
186790 ** to recognize the end of a trigger can be omitted. All we have to do
186791 ** is look for a semicolon that is not part of an string or comment.
186792 */
186793 SQLITE_API int sqlite3_complete(const char *zSql){
186794 u8 state = 0; /* Current state, using numbers defined in header comment */
186795 u8 token; /* Value of the next token */
 
 
186796
186797 #ifndef SQLITE_OMIT_TRIGGER
186798 /* A complex statement machine used to detect the end of a CREATE TRIGGER
186799 ** statement. This is the normal case.
186800 */
@@ -186820,15 +186924,25 @@
186820 /* 0 INVALID: */ { 1, 0, 2, },
186821 /* 1 START: */ { 1, 1, 2, },
186822 /* 2 NORMAL: */ { 1, 2, 2, },
186823 };
186824 #endif /* SQLITE_OMIT_TRIGGER */
 
 
 
 
 
 
 
 
 
 
 
186825
186826 #ifdef SQLITE_ENABLE_API_ARMOR
186827 if( zSql==0 ){
186828 (void)SQLITE_MISUSE_BKPT;
186829 return 0;
186830 }
186831 #endif
186832
186833 while( *zSql ){
186834 switch( *zSql ){
@@ -186849,11 +186963,14 @@
186849 token = tkOTHER;
186850 break;
186851 }
186852 zSql += 2;
186853 while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; }
186854 if( zSql[0]==0 ) return 0;
 
 
 
186855 zSql++;
186856 token = tkWS;
186857 break;
186858 }
186859 case '-': { /* SQL-style comments from "--" to end of line */
@@ -186860,28 +186977,47 @@
186860 if( zSql[1]!='-' ){
186861 token = tkOTHER;
186862 break;
186863 }
186864 while( *zSql && *zSql!='\n' ){ zSql++; }
186865 if( *zSql==0 ) return state==1;
 
 
 
186866 token = tkWS;
186867 break;
186868 }
186869 case '[': { /* Microsoft-style identifiers in [...] */
186870 zSql++;
186871 while( *zSql && *zSql!=']' ){ zSql++; }
186872 if( *zSql==0 ) return 0;
 
 
 
186873 token = tkOTHER;
186874 break;
186875 }
186876 case '`': /* Grave-accent quoted symbols used by MySQL */
186877 case '"': /* single- and double-quoted strings */
186878 case '\'': {
186879 int c = *zSql;
186880 zSql++;
186881 while( *zSql && *zSql!=c ){ zSql++; }
186882 if( *zSql==0 ) return 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
186883 token = tkOTHER;
186884 break;
186885 }
186886 default: {
186887 #ifdef SQLITE_EBCDIC
@@ -186944,11 +187080,19 @@
186944 }
186945 }
186946 state = trans[state][token];
186947 zSql++;
186948 }
186949 return state==1;
 
 
 
 
 
 
 
 
186950 }
186951
186952 #ifndef SQLITE_OMIT_UTF16
186953 /*
186954 ** This routine is the same as the sqlite3_complete() routine described
@@ -186966,11 +187110,11 @@
186966 #endif
186967 pVal = sqlite3ValueNew(0);
186968 sqlite3ValueSetStr(pVal, -1, zSql, SQLITE_UTF16NATIVE, SQLITE_STATIC);
186969 zSql8 = sqlite3ValueText(pVal, SQLITE_UTF8);
186970 if( zSql8 ){
186971 rc = sqlite3_complete(zSql8);
186972 }else{
186973 rc = SQLITE_NOMEM_BKPT;
186974 }
186975 sqlite3ValueFree(pVal);
186976 return rc & 0xff;
@@ -233667,10 +233811,11 @@
233667 ** Return the number of bytes read.
233668 */
233669 static int sessionVarintGetSafe(const u8 *aBuf, int nBuf, int *piVal){
233670 u8 aCopy[9];
233671 const u8 *aRead = aBuf;
 
233672 if( nBuf<sizeof(aCopy) ){
233673 memcpy(aCopy, aBuf, nBuf);
233674 aRead = aCopy;
233675 }
233676 return getVarint32(aRead, *piVal);
@@ -236997,25 +237142,29 @@
236997 SessionInput *pIn, /* Input data */
236998 int nCol, /* Number of columns in record */
236999 int *pnByte /* OUT: Size of record in bytes */
237000 ){
237001 int rc = SQLITE_OK;
237002 int nByte = 0;
237003 int i;
237004 for(i=0; rc==SQLITE_OK && i<nCol; i++){
237005 int eType;
237006 rc = sessionInputBuffer(pIn, nByte + 10);
237007 if( rc==SQLITE_OK ){
237008 eType = pIn->aData[pIn->iNext + nByte++];
237009 if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){
237010 int n;
237011 nByte += sessionVarintGet(&pIn->aData[pIn->iNext+nByte], &n);
 
237012 nByte += n;
237013 rc = sessionInputBuffer(pIn, nByte);
237014 }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
237015 nByte += 8;
237016 }
 
 
 
237017 }
237018 }
237019 *pnByte = nByte;
237020 return rc;
237021 }
@@ -239028,10 +239177,14 @@
239028
239029 /*
239030 ** This function is called to merge two changes to the same row together as
239031 ** part of an sqlite3changeset_concat() operation. A new change object is
239032 ** allocated and a pointer to it stored in *ppNew.
 
 
 
 
239033 */
239034 static int sessionChangeMerge(
239035 SessionTable *pTab, /* Table structure */
239036 int bRebase, /* True for a rebase hash-table */
239037 int bPatchset, /* True for patchsets */
@@ -239168,11 +239321,11 @@
239168 pNew->op = SQLITE_UPDATE;
239169 if( bPatchset ){
239170 memcpy(aCsr, aRec, nRec);
239171 aCsr += nRec;
239172 }else{
239173 if( 0==sessionMergeUpdate(&aCsr, pTab, bPatchset, aExist, 0,aRec,0) ){
239174 sqlite3_free(pNew);
239175 pNew = 0;
239176 }
239177 }
239178 }else if( op2==SQLITE_UPDATE ){ /* UPDATE + UPDATE */
@@ -263211,11 +263364,11 @@
263211 int nArg, /* Number of args */
263212 sqlite3_value **apUnused /* Function arguments */
263213 ){
263214 assert( nArg==0 );
263215 UNUSED_PARAM2(nArg, apUnused);
263216 sqlite3_result_text(pCtx, "fts5: 2026-04-07 09:15:21 c8121593fa455cd43b3878f8b65ebac47c07dab4b8ce081aa34b14fc9440afbc", -1, SQLITE_TRANSIENT);
263217 }
263218
263219 /*
263220 ** Implementation of fts5_locale(LOCALE, TEXT) function.
263221 **
263222
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.54.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -16,11 +16,11 @@
16 ** if you want a wrapper to interface SQLite with your choice of programming
17 ** language. The code for the "sqlite3" command-line shell is also in a
18 ** separate file. This file contains only code for the core SQLite library.
19 **
20 ** The content in this amalgamation comes from Fossil check-in
21 ** 79a8d3edf8207d72f0c4650272ee239a1c77 with changes in files:
22 **
23 **
24 */
25 #ifndef SQLITE_AMALGAMATION
26 #define SQLITE_CORE 1
@@ -465,16 +465,16 @@
465 **
466 ** See also: [sqlite3_libversion()],
467 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
468 ** [sqlite_version()] and [sqlite_source_id()].
469 */
470 #define SQLITE_VERSION "3.54.0"
471 #define SQLITE_VERSION_NUMBER 3054000
472 #define SQLITE_SOURCE_ID "2026-04-11 23:58:15 79a8d3edf8207d72f0c4650272ee239a1c7783a07f907fbf0cf5a7ad99b27a2a"
473 #define SQLITE_SCM_BRANCH "trunk"
474 #define SQLITE_SCM_TAGS ""
475 #define SQLITE_SCM_DATETIME "2026-04-11T23:58:15.898Z"
476
477 /*
478 ** CAPI3REF: Run-Time Library Version Numbers
479 ** KEYWORDS: sqlite3_version sqlite3_sourceid
480 **
@@ -3279,39 +3279,51 @@
3279 ** CAPI3REF: Determine If An SQL Statement Is Complete
3280 **
3281 ** These routines are useful during command-line input to determine if the
3282 ** currently entered text seems to form a complete SQL statement or
3283 ** if additional input is needed before sending the text into
3284 ** SQLite for parsing. ^The sqlite3_complete(X) and sqlite3_complete16(X)
3285 ** routines return 1 if the input string X appears to be a complete SQL
3286 ** statement. ^A statement is judged to be
3287 ** complete if it ends with a semicolon token and is not a prefix of a
3288 ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within
3289 ** string literals or quoted identifier names or comments are not
3290 ** independent tokens (they are part of the token in which they are
3291 ** embedded) and thus do not count as a statement terminator. ^Whitespace
3292 ** and comments that follow the final semicolon are ignored.
3293 **
3294 ** ^The sqlite3_complete(X) and sqlite3_complete16(X) routines return 0
3295 ** if the statement is incomplete. ^If a memory allocation fails, then
3296 ** SQLITE_NOMEM is returned.
3297 **
3298 ** The [sqlite3_incomplete(X)] routine is similar to [sqlite3_complete(X)]
3299 ** except that sqlite3_incomplete(X) returns 0 if the input X is complete
3300 ** and non-zero if X is incomplete. The non-zero return from
3301 ** sqlite3_incomplete(X) contains additional information about what is
3302 ** needed to complete the input X. The sqlite3_incomplete(X) interface
3303 ** is only available for UTF-8 text.
3304 **
3305 ** ^None of these routines do a full parse the SQL statements and thus
3306 ** will not detect syntactically incorrect SQL. They only determine if
3307 ** input text has properly terminated comments, string literals, and
3308 ** quoted identifiers, and if the statement ends with a semicolon.
3309 **
3310 ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
3311 ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
3312 ** automatically by sqlite3_complete16(). If that initialization fails,
3313 ** then the return value from sqlite3_complete16() will be non-zero
3314 ** regardless of whether or not the input SQL is complete.)^
3315 **
3316 ** The X input to [sqlite3_complete(X)] and [sqlite3_incomplete(X)
3317 ** must be a zero-terminated UTF-8 string.
3318 **
3319 ** The input to [sqlite3_complete16()] must be a zero-terminated
3320 ** UTF-16 string in native byte order.
3321 */
3322 SQLITE_API int sqlite3_complete(const char *sql);
3323 SQLITE_API int sqlite3_complete16(const void *sql);
3324 SQLITE_API sqlite3_int64 sqlite3_incomplete(const char *sql);
3325
3326 /*
3327 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
3328 ** KEYWORDS: {busy-handler callback} {busy handler}
3329 ** METHOD: sqlite3
@@ -7934,11 +7946,11 @@
7946 ** entry point were as follows:
7947 **
7948 ** <blockquote><pre>
7949 ** &nbsp; int xEntryPoint(
7950 ** &nbsp; sqlite3 *db,
7951 ** &nbsp; char **pzErrMsg,
7952 ** &nbsp; const struct sqlite3_api_routines *pThunk
7953 ** &nbsp; );
7954 ** </pre></blockquote>)^
7955 **
7956 ** If the xEntryPoint routine encounters an error, it should make *pzErrMsg
@@ -32511,11 +32523,11 @@
32523 if( pAccum->accError ) return 0;
32524 if( n>pAccum->nAlloc && n>pAccum->mxAlloc ){
32525 sqlite3StrAccumSetError(pAccum, SQLITE_TOOBIG);
32526 return 0;
32527 }
32528 z = sqlite3_malloc(n);
32529 if( z==0 ){
32530 sqlite3StrAccumSetError(pAccum, SQLITE_NOMEM);
32531 }
32532 return z;
32533 }
@@ -32967,17 +32979,33 @@
32979 e2 = 0;
32980 }else{
32981 e2 = s.iDP - 1;
32982 }
32983
32984 szBufNeeded = MAX(e2,0)+(i64)precision+(i64)width+10;
32985 if( cThousand && e2>0 ) szBufNeeded += (e2+2)/3;
32986 if( szBufNeeded + pAccum->nChar >= pAccum->nAlloc ){
32987 if( pAccum->mxAlloc==0 && pAccum->accError==0 ){
32988 /* Unable to allocate space in pAccum, perhaps because it
32989 ** is coming from sqlite3_snprintf() or similar. We'll have
32990 ** to render into temporary space and the memcpy() it over. */
32991 bufpt = sqlite3_malloc(szBufNeeded);
32992 if( bufpt==0 ){
32993 sqlite3StrAccumSetError(pAccum, SQLITE_NOMEM);
32994 return;
32995 }
32996 zExtra = bufpt;
32997 }else if( sqlite3StrAccumEnlarge(pAccum, szBufNeeded)<szBufNeeded ){
32998 width = length = 0;
32999 break;
33000 }else{
33001 bufpt = pAccum->zText + pAccum->nChar;
33002 }
33003 }else{
33004 bufpt = pAccum->zText + pAccum->nChar;
33005 }
33006 zOut = bufpt;
33007
33008 flag_dp = (precision>0 ?1:0) | flag_alternateform | flag_altform2;
33009 /* The sign in front of the number */
33010 if( prefix ){
33011 *(bufpt++) = prefix;
@@ -33074,18 +33102,26 @@
33102 memmove(zOut+nPad+adj, zOut+adj, length-adj);
33103 memset(zOut+adj, '0', nPad);
33104 }
33105 length = width;
33106 }
33107
33108 if( zExtra==0 ){
33109 /* The result is being rendered directory into pAccum. This
33110 ** is the command and fast case */
33111 pAccum->nChar += length;
33112 zOut[length] = 0;
33113 continue;
33114 }else{
33115 /* We were unable to render directly into pAccum because we
33116 ** couldn't allocate sufficient memory. We need to memcpy()
33117 ** the rendering (or some prefix thereof) into the output
33118 ** buffer. */
33119 bufpt[0] = 0;
33120 bufpt = zExtra;
33121 break;
33122 }
33123 }
33124 case etSIZE:
33125 if( !bArgList ){
33126 *(va_arg(ap,int*)) = pAccum->nChar;
33127 }
@@ -33128,11 +33164,11 @@
33164 if( nPrior > precision-1 ) nPrior = precision - 1;
33165 nCopyBytes = length*nPrior;
33166 if( sqlite3StrAccumEnlargeIfNeeded(pAccum, nCopyBytes) ){
33167 break;
33168 }
33169 sqlite3_str_append(pAccum,
33170 &pAccum->zText[pAccum->nChar-nCopyBytes], nCopyBytes);
33171 precision -= nPrior;
33172 nPrior *= 2;
33173 }
33174 }
@@ -36351,11 +36387,18 @@
36387 */
36388 /* #include "sqliteInt.h" */
36389 /* #include <stdarg.h> */
36390 #ifndef SQLITE_OMIT_FLOATING_POINT
36391 #include <math.h>
36392
36393 /* Work around a bug in older Microsoft compilers
36394 ** Forum post 2026-04-10T06:33:11z */
36395 #if !defined(INFINITY) && defined(_MSC_VER)
36396 # define INFINITY HUGE_VAL
36397 #endif
36398
36399 #endif /* SQLITE_OMIT_FLOATING_POINT */
36400
36401 /*
36402 ** Calls to sqlite3FaultSim() are used to simulate a failure during testing,
36403 ** or to bypass normal error detection during testing in order to let
36404 ** execute proceed further downstream.
@@ -46782,11 +46825,26 @@
46825 ** sqlite3_uri_parameter(). */
46826 assert( (flags & SQLITE_OPEN_URI) || zName[strlen(zName)+1]==0 );
46827
46828 }else if( !zName ){
46829 /* If zName is NULL, the upper layer is requesting a temp file. */
46830 assert( isDelete );
46831 assert( !isNewJrnl );
46832 assert( isExclusive );
46833 assert( isReadWrite );
46834 #if defined(__linux__) && defined(O_TMPFILE)
46835 /* On systems that support O_TMPFILE, use that flag to create a more
46836 ** secure temporary file that cannot be accessed by other processes
46837 */
46838 zName = unixTempFileDir();
46839 if( zName
46840 && (fd = robust_open(zName, O_RDWR|O_CREAT|O_EXCL|O_TMPFILE, 0600))>=0
46841 ){
46842 rc = fillInUnixFile(pVfs, fd, pFile, zPath, ctrlFlags);
46843 goto open_finished;
46844 }
46845 #endif
46846 rc = unixGetTempname(pVfs->mxPathname, zTmpname);
46847 if( rc!=SQLITE_OK ){
46848 return rc;
46849 }
46850 zName = zTmpname;
@@ -93142,16 +93200,16 @@
93200 UnpackedRecord *p, /* Index key being deleted */
93201 int *piRes /* 0 for a match, non-zero for not a match */
93202 ){
93203 u8 *aRec = 0;
93204 u32 nRec = 0;
93205 Mem m;
93206 int rc = SQLITE_OK;
93207
93208 memset(&m, 0, sizeof(m));
93209 m.enc = p->pKeyInfo->enc;
93210 m.db = p->pKeyInfo->db;
93211 nRec = sqlite3BtreePayloadSize(pCur);
93212 if( nRec>0x7fffffff ){
93213 return SQLITE_CORRUPT_BKPT;
93214 }
93215
@@ -93189,13 +93247,13 @@
93247 idxHdr += getVarint32(&aRec[idxHdr], iSerial);
93248 nSerial = sqlite3VdbeSerialTypeLen(iSerial);
93249 if( (idxRec+nSerial)>nRec ){
93250 rc = SQLITE_CORRUPT_BKPT;
93251 }else{
93252 sqlite3VdbeSerialGet(&aRec[idxRec], iSerial, &m);
93253 if( vdbeSkipField(mask, ii, &p->aMem[ii], &m, bInt)==0 ){
93254 res = sqlite3MemCompare(&m, &p->aMem[ii], p->pKeyInfo->aColl[ii]);
93255 if( res!=0 ) break;
93256 }
93257 }
93258 idxRec += sqlite3VdbeSerialTypeLen(iSerial);
93259 }
@@ -142568,10 +142626,12 @@
142626 /* Version 3.52.0 and later */
142627 void (*str_truncate)(sqlite3_str*,int);
142628 void (*str_free)(sqlite3_str*);
142629 int (*carray_bind)(sqlite3_stmt*,int,void*,int,int,void(*)(void*));
142630 int (*carray_bind_v2)(sqlite3_stmt*,int,void*,int,int,void(*)(void*),void*);
142631 /* Version 3.54.0 and later */
142632 sqlite3_int64 (*incomplete)(const char*);
142633 };
142634
142635 /*
142636 ** This is the function signature used for all extension entry points. It
142637 ** is also defined in the file "loadext.c".
@@ -142911,10 +142971,12 @@
142971 /* Version 3.52.0 and later */
142972 #define sqlite3_str_truncate sqlite3_api->str_truncate
142973 #define sqlite3_str_free sqlite3_api->str_free
142974 #define sqlite3_carray_bind sqlite3_api->carray_bind
142975 #define sqlite3_carray_bind_v2 sqlite3_api->carray_bind_v2
142976 /* Version 3.54.0 and later */
142977 #define sqlite3_incomplete sqlite3_api->incomplete
142978 #endif /* !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION) */
142979
142980 #if !defined(SQLITE_CORE) && !defined(SQLITE_OMIT_LOAD_EXTENSION)
142981 /* This case when the file really is being compiled as a loadable
142982 ** extension */
@@ -143443,15 +143505,16 @@
143505 /* Version 3.52.0 and later */
143506 sqlite3_str_truncate,
143507 sqlite3_str_free,
143508 #ifdef SQLITE_ENABLE_CARRAY
143509 sqlite3_carray_bind,
143510 sqlite3_carray_bind_v2,
143511 #else
143512 0,
143513 0,
 
143514 #endif
143515 sqlite3_incomplete
143516 };
143517
143518 /* True if x is the directory separator character
143519 */
143520 #if SQLITE_OS_WIN
@@ -186736,15 +186799,54 @@
186799 #define tkTRIGGER 6
186800 #define tkEND 7
186801 #endif
186802
186803 /*
186804 ** Return zero if the given SQL string is complete - if all comments,
186805 ** string and blob literals, and quoted identifiers have been closed and
186806 ** if the entire string ends with ";" and possible with ";END;" if the
186807 ** string is a CREATE TRIGGER statement. A non-zero return indicates
186808 ** that the string is incomplete. Bits of the return value indicate
186809 ** what is missing and is needed to close out the statement.
186810 **
186811 ** Special handling is require for CREATE TRIGGER statements.
186812 ** Whenever the CREATE TRIGGER keywords are seen, the statement
186813 ** must end with ";END;".
186814 **
186815 ** Let the return code be a value R. R is split up into various
186816 ** subfields, at byte boundaries:
186817 **
186818 ** R = 0xwwwwwwww00xxyyzz
186819 **
186820 ** In other words, zz is the least significant byte, yy is the next
186821 ** most significant byte, xx is the third byte, wwwwwwww is a 32-bit
186822 ** value from the middle.
186823 **
186824 ** zz == SQLITE_OK Input is complete
186825 ** zz == SQLITE_ERROR Input is incomplete
186826 ** zz == SQLITE_MISUSE Input is a NULL pointer
186827 ** zz != 0 New values for zz may be added in the future
186828 **
186829 ** yy == 0x01 Need a semicolon at the end
186830 ** yy == 0x02 Need "END" and a semicolon
186831 ** yy == 0x03 Need semicolon, "END", and semicolon
186832 ** yy != 0 New values for yy may be added in the future
186833 **
186834 ** xx == '\'' Incomplete string or blob literal
186835 ** xx == '"' Incomplete quoted identifier
186836 ** xx == '`' Incompelte MySQL-style quoted identifier
186837 ** xx == ']' Incomplete SQLServer-style quoted identifer
186838 ** xx == '-' Incomplete SQL-style comment
186839 ** xx == '/' Incomplete C-style comment
186840 ** xx != 0 New values of xx may be added in the future
186841 **
186842 ** wwwwwwww Interpret as a signed integer, the number
186843 ** of unmatched "(". Negative means there are
186844 ** more ")" and "(".
186845 **
186846 ** ((R>>24)&0xff)!=0 New uses for the 4th byte may be added
186847 ** in the future
186848 **
186849 ** This implementation uses a state machine with 8 states:
186850 **
186851 ** (0) INVALID We have not yet seen a non-whitespace character.
186852 **
@@ -186788,13 +186890,15 @@
186890 **
186891 ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
186892 ** to recognize the end of a trigger can be omitted. All we have to do
186893 ** is look for a semicolon that is not part of an string or comment.
186894 */
186895 SQLITE_API sqlite3_int64 sqlite3_incomplete(const char *zSql){
186896 u8 state = 0; /* Current state, using numbers defined in header comment */
186897 u8 token; /* Value of the next token */
186898 u8 pending = 0; /* unmatched structure character */
186899 int nParen = 0; /* Nested parentheses */
186900
186901 #ifndef SQLITE_OMIT_TRIGGER
186902 /* A complex statement machine used to detect the end of a CREATE TRIGGER
186903 ** statement. This is the normal case.
186904 */
@@ -186820,15 +186924,25 @@
186924 /* 0 INVALID: */ { 1, 0, 2, },
186925 /* 1 START: */ { 1, 1, 2, },
186926 /* 2 NORMAL: */ { 1, 2, 2, },
186927 };
186928 #endif /* SQLITE_OMIT_TRIGGER */
186929 /* Mapping state number to yy value for the return */
186930 static const u8 statemap[8] = {
186931 /* 0 INVALID */ 1,
186932 /* 1 START */ 0,
186933 /* 2 NORMAL */ 1,
186934 /* 3 EXPLAIN */ 1,
186935 /* 4 CREATE */ 1,
186936 /* 5 TRIGGER */ 3,
186937 /* 6 SEMI */ 2,
186938 /* 7 END */ 1,
186939 };
186940
186941 #ifdef SQLITE_ENABLE_API_ARMOR
186942 if( zSql==0 ){
186943 return SQLITE_MISUSE_BKPT;
 
186944 }
186945 #endif
186946
186947 while( *zSql ){
186948 switch( *zSql ){
@@ -186849,11 +186963,14 @@
186963 token = tkOTHER;
186964 break;
186965 }
186966 zSql += 2;
186967 while( zSql[0] && (zSql[0]!='*' || zSql[1]!='/') ){ zSql++; }
186968 if( zSql[0]==0 ){
186969 pending = '/';
186970 goto incomplete_finish;
186971 }
186972 zSql++;
186973 token = tkWS;
186974 break;
186975 }
186976 case '-': { /* SQL-style comments from "--" to end of line */
@@ -186860,28 +186977,47 @@
186977 if( zSql[1]!='-' ){
186978 token = tkOTHER;
186979 break;
186980 }
186981 while( *zSql && *zSql!='\n' ){ zSql++; }
186982 if( *zSql==0 ){
186983 if( state!=1 ) pending = '-';
186984 goto incomplete_finish;
186985 }
186986 token = tkWS;
186987 break;
186988 }
186989 case '[': { /* Microsoft-style identifiers in [...] */
186990 zSql++;
186991 while( *zSql && *zSql!=']' ){ zSql++; }
186992 if( *zSql==0 ){
186993 pending = ']';
186994 goto incomplete_finish;
186995 }
186996 token = tkOTHER;
186997 break;
186998 }
186999 case '`': /* Grave-accent quoted symbols used by MySQL */
187000 case '"': /* single- and double-quoted strings */
187001 case '\'': {
187002 int c = *zSql;
187003 zSql++;
187004 while( *zSql && *zSql!=c ){ zSql++; }
187005 if( *zSql==0 ){
187006 pending = c;
187007 goto incomplete_finish;
187008 }
187009 token = tkOTHER;
187010 break;
187011 }
187012 case '(': {
187013 nParen++;
187014 token = tkOTHER;
187015 break;
187016 }
187017 case ')': {
187018 nParen--;
187019 token = tkOTHER;
187020 break;
187021 }
187022 default: {
187023 #ifdef SQLITE_EBCDIC
@@ -186944,11 +187080,19 @@
187080 }
187081 }
187082 state = trans[state][token];
187083 zSql++;
187084 }
187085 incomplete_finish:
187086 if( state==1 ) nParen = 0;
187087 return (i64)((((u64)nParen)<<32) |
187088 ((u64)pending<<16) |
187089 ((u64)statemap[state]<<8) |
187090 (state!=1));
187091 }
187092 SQLITE_API int sqlite3_complete(const char *zSql){
187093 return sqlite3_incomplete(zSql)==0;
187094 }
187095
187096 #ifndef SQLITE_OMIT_UTF16
187097 /*
187098 ** This routine is the same as the sqlite3_complete() routine described
@@ -186966,11 +187110,11 @@
187110 #endif
187111 pVal = sqlite3ValueNew(0);
187112 sqlite3ValueSetStr(pVal, -1, zSql, SQLITE_UTF16NATIVE, SQLITE_STATIC);
187113 zSql8 = sqlite3ValueText(pVal, SQLITE_UTF8);
187114 if( zSql8 ){
187115 rc = sqlite3_incomplete(zSql8)==0;
187116 }else{
187117 rc = SQLITE_NOMEM_BKPT;
187118 }
187119 sqlite3ValueFree(pVal);
187120 return rc & 0xff;
@@ -233667,10 +233811,11 @@
233811 ** Return the number of bytes read.
233812 */
233813 static int sessionVarintGetSafe(const u8 *aBuf, int nBuf, int *piVal){
233814 u8 aCopy[9];
233815 const u8 *aRead = aBuf;
233816 memset(aCopy, 0, sizeof(aCopy));
233817 if( nBuf<sizeof(aCopy) ){
233818 memcpy(aCopy, aBuf, nBuf);
233819 aRead = aCopy;
233820 }
233821 return getVarint32(aRead, *piVal);
@@ -236997,25 +237142,29 @@
237142 SessionInput *pIn, /* Input data */
237143 int nCol, /* Number of columns in record */
237144 int *pnByte /* OUT: Size of record in bytes */
237145 ){
237146 int rc = SQLITE_OK;
237147 i64 nByte = 0;
237148 int i;
237149 for(i=0; rc==SQLITE_OK && i<nCol; i++){
237150 int eType;
237151 rc = sessionInputBuffer(pIn, nByte + 10);
237152 if( rc==SQLITE_OK ){
237153 eType = pIn->aData[pIn->iNext + nByte++];
237154 if( eType==SQLITE_TEXT || eType==SQLITE_BLOB ){
237155 int n;
237156 int nRem = pIn->nData - (pIn->iNext + nByte);
237157 nByte += sessionVarintGetSafe(&pIn->aData[pIn->iNext+nByte], nRem, &n);
237158 nByte += n;
237159 rc = sessionInputBuffer(pIn, nByte);
237160 }else if( eType==SQLITE_INTEGER || eType==SQLITE_FLOAT ){
237161 nByte += 8;
237162 }
237163 }
237164 if( (pIn->iNext+nByte)>pIn->nData ){
237165 rc = SQLITE_CORRUPT_BKPT;
237166 }
237167 }
237168 *pnByte = nByte;
237169 return rc;
237170 }
@@ -239028,10 +239177,14 @@
239177
239178 /*
239179 ** This function is called to merge two changes to the same row together as
239180 ** part of an sqlite3changeset_concat() operation. A new change object is
239181 ** allocated and a pointer to it stored in *ppNew.
239182 **
239183 ** Because they have been vetted by sqlite3changegroup_add() or similar,
239184 ** both the aRec[] change and the pExist change are safe to use without
239185 ** checking for buffer overflows.
239186 */
239187 static int sessionChangeMerge(
239188 SessionTable *pTab, /* Table structure */
239189 int bRebase, /* True for a rebase hash-table */
239190 int bPatchset, /* True for patchsets */
@@ -239168,11 +239321,11 @@
239321 pNew->op = SQLITE_UPDATE;
239322 if( bPatchset ){
239323 memcpy(aCsr, aRec, nRec);
239324 aCsr += nRec;
239325 }else{
239326 if( 0==sessionMergeUpdate(&aCsr, pTab, bPatchset, aExist,0,aRec,0) ){
239327 sqlite3_free(pNew);
239328 pNew = 0;
239329 }
239330 }
239331 }else if( op2==SQLITE_UPDATE ){ /* UPDATE + UPDATE */
@@ -263211,11 +263364,11 @@
263364 int nArg, /* Number of args */
263365 sqlite3_value **apUnused /* Function arguments */
263366 ){
263367 assert( nArg==0 );
263368 UNUSED_PARAM2(nArg, apUnused);
263369 sqlite3_result_text(pCtx, "fts5: 2026-04-11 22:18:05 6fa0216a19c2f165110121227d3f9b9119369f8cd61f9c6d13eaa1ae42a60d60", -1, SQLITE_TRANSIENT);
263370 }
263371
263372 /*
263373 ** Implementation of fts5_locale(LOCALE, TEXT) function.
263374 **
263375
+25 -13
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -144,16 +144,16 @@
144144
**
145145
** See also: [sqlite3_libversion()],
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149
-#define SQLITE_VERSION "3.53.0"
150
-#define SQLITE_VERSION_NUMBER 3053000
151
-#define SQLITE_SOURCE_ID "2026-04-07 09:15:21 c8121593fa455cd43b3878f8b65ebac47c07dab4b8ce081aa34b14fc9440afbc"
149
+#define SQLITE_VERSION "3.54.0"
150
+#define SQLITE_VERSION_NUMBER 3054000
151
+#define SQLITE_SOURCE_ID "2026-04-11 23:58:15 79a8d3edf8207d72f0c4650272ee239a1c7783a07f907fbf0cf5a7ad99b27a2a"
152152
#define SQLITE_SCM_BRANCH "trunk"
153153
#define SQLITE_SCM_TAGS ""
154
-#define SQLITE_SCM_DATETIME "2026-04-07T09:15:21.538Z"
154
+#define SQLITE_SCM_DATETIME "2026-04-11T23:58:15.898Z"
155155
156156
/*
157157
** CAPI3REF: Run-Time Library Version Numbers
158158
** KEYWORDS: sqlite3_version sqlite3_sourceid
159159
**
@@ -2958,39 +2958,51 @@
29582958
** CAPI3REF: Determine If An SQL Statement Is Complete
29592959
**
29602960
** These routines are useful during command-line input to determine if the
29612961
** currently entered text seems to form a complete SQL statement or
29622962
** if additional input is needed before sending the text into
2963
-** SQLite for parsing. ^These routines return 1 if the input string
2964
-** appears to be a complete SQL statement. ^A statement is judged to be
2963
+** SQLite for parsing. ^The sqlite3_complete(X) and sqlite3_complete16(X)
2964
+** routines return 1 if the input string X appears to be a complete SQL
2965
+** statement. ^A statement is judged to be
29652966
** complete if it ends with a semicolon token and is not a prefix of a
29662967
** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within
29672968
** string literals or quoted identifier names or comments are not
29682969
** independent tokens (they are part of the token in which they are
29692970
** embedded) and thus do not count as a statement terminator. ^Whitespace
29702971
** and comments that follow the final semicolon are ignored.
29712972
**
2972
-** ^These routines return 0 if the statement is incomplete. ^If a
2973
-** memory allocation fails, then SQLITE_NOMEM is returned.
2973
+** ^The sqlite3_complete(X) and sqlite3_complete16(X) routines return 0
2974
+** if the statement is incomplete. ^If a memory allocation fails, then
2975
+** SQLITE_NOMEM is returned.
29742976
**
2975
-** ^These routines do not parse the SQL statements and thus
2976
-** will not detect syntactically incorrect SQL.
2977
+** The [sqlite3_incomplete(X)] routine is similar to [sqlite3_complete(X)]
2978
+** except that sqlite3_incomplete(X) returns 0 if the input X is complete
2979
+** and non-zero if X is incomplete. The non-zero return from
2980
+** sqlite3_incomplete(X) contains additional information about what is
2981
+** needed to complete the input X. The sqlite3_incomplete(X) interface
2982
+** is only available for UTF-8 text.
2983
+**
2984
+** ^None of these routines do a full parse the SQL statements and thus
2985
+** will not detect syntactically incorrect SQL. They only determine if
2986
+** input text has properly terminated comments, string literals, and
2987
+** quoted identifiers, and if the statement ends with a semicolon.
29772988
**
29782989
** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
29792990
** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
29802991
** automatically by sqlite3_complete16(). If that initialization fails,
29812992
** then the return value from sqlite3_complete16() will be non-zero
29822993
** regardless of whether or not the input SQL is complete.)^
29832994
**
2984
-** The input to [sqlite3_complete()] must be a zero-terminated
2985
-** UTF-8 string.
2995
+** The X input to [sqlite3_complete(X)] and [sqlite3_incomplete(X)
2996
+** must be a zero-terminated UTF-8 string.
29862997
**
29872998
** The input to [sqlite3_complete16()] must be a zero-terminated
29882999
** UTF-16 string in native byte order.
29893000
*/
29903001
SQLITE_API int sqlite3_complete(const char *sql);
29913002
SQLITE_API int sqlite3_complete16(const void *sql);
3003
+SQLITE_API sqlite3_int64 sqlite3_incomplete(const char *sql);
29923004
29933005
/*
29943006
** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
29953007
** KEYWORDS: {busy-handler callback} {busy handler}
29963008
** METHOD: sqlite3
@@ -7613,11 +7625,11 @@
76137625
** entry point were as follows:
76147626
**
76157627
** <blockquote><pre>
76167628
** &nbsp; int xEntryPoint(
76177629
** &nbsp; sqlite3 *db,
7618
-** &nbsp; const char **pzErrMsg,
7630
+** &nbsp; char **pzErrMsg,
76197631
** &nbsp; const struct sqlite3_api_routines *pThunk
76207632
** &nbsp; );
76217633
** </pre></blockquote>)^
76227634
**
76237635
** If the xEntryPoint routine encounters an error, it should make *pzErrMsg
76247636
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -144,16 +144,16 @@
144 **
145 ** See also: [sqlite3_libversion()],
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.53.0"
150 #define SQLITE_VERSION_NUMBER 3053000
151 #define SQLITE_SOURCE_ID "2026-04-07 09:15:21 c8121593fa455cd43b3878f8b65ebac47c07dab4b8ce081aa34b14fc9440afbc"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2026-04-07T09:15:21.538Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
@@ -2958,39 +2958,51 @@
2958 ** CAPI3REF: Determine If An SQL Statement Is Complete
2959 **
2960 ** These routines are useful during command-line input to determine if the
2961 ** currently entered text seems to form a complete SQL statement or
2962 ** if additional input is needed before sending the text into
2963 ** SQLite for parsing. ^These routines return 1 if the input string
2964 ** appears to be a complete SQL statement. ^A statement is judged to be
 
2965 ** complete if it ends with a semicolon token and is not a prefix of a
2966 ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within
2967 ** string literals or quoted identifier names or comments are not
2968 ** independent tokens (they are part of the token in which they are
2969 ** embedded) and thus do not count as a statement terminator. ^Whitespace
2970 ** and comments that follow the final semicolon are ignored.
2971 **
2972 ** ^These routines return 0 if the statement is incomplete. ^If a
2973 ** memory allocation fails, then SQLITE_NOMEM is returned.
 
2974 **
2975 ** ^These routines do not parse the SQL statements and thus
2976 ** will not detect syntactically incorrect SQL.
 
 
 
 
 
 
 
 
 
2977 **
2978 ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
2979 ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
2980 ** automatically by sqlite3_complete16(). If that initialization fails,
2981 ** then the return value from sqlite3_complete16() will be non-zero
2982 ** regardless of whether or not the input SQL is complete.)^
2983 **
2984 ** The input to [sqlite3_complete()] must be a zero-terminated
2985 ** UTF-8 string.
2986 **
2987 ** The input to [sqlite3_complete16()] must be a zero-terminated
2988 ** UTF-16 string in native byte order.
2989 */
2990 SQLITE_API int sqlite3_complete(const char *sql);
2991 SQLITE_API int sqlite3_complete16(const void *sql);
 
2992
2993 /*
2994 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
2995 ** KEYWORDS: {busy-handler callback} {busy handler}
2996 ** METHOD: sqlite3
@@ -7613,11 +7625,11 @@
7613 ** entry point were as follows:
7614 **
7615 ** <blockquote><pre>
7616 ** &nbsp; int xEntryPoint(
7617 ** &nbsp; sqlite3 *db,
7618 ** &nbsp; const char **pzErrMsg,
7619 ** &nbsp; const struct sqlite3_api_routines *pThunk
7620 ** &nbsp; );
7621 ** </pre></blockquote>)^
7622 **
7623 ** If the xEntryPoint routine encounters an error, it should make *pzErrMsg
7624
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -144,16 +144,16 @@
144 **
145 ** See also: [sqlite3_libversion()],
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.54.0"
150 #define SQLITE_VERSION_NUMBER 3054000
151 #define SQLITE_SOURCE_ID "2026-04-11 23:58:15 79a8d3edf8207d72f0c4650272ee239a1c7783a07f907fbf0cf5a7ad99b27a2a"
152 #define SQLITE_SCM_BRANCH "trunk"
153 #define SQLITE_SCM_TAGS ""
154 #define SQLITE_SCM_DATETIME "2026-04-11T23:58:15.898Z"
155
156 /*
157 ** CAPI3REF: Run-Time Library Version Numbers
158 ** KEYWORDS: sqlite3_version sqlite3_sourceid
159 **
@@ -2958,39 +2958,51 @@
2958 ** CAPI3REF: Determine If An SQL Statement Is Complete
2959 **
2960 ** These routines are useful during command-line input to determine if the
2961 ** currently entered text seems to form a complete SQL statement or
2962 ** if additional input is needed before sending the text into
2963 ** SQLite for parsing. ^The sqlite3_complete(X) and sqlite3_complete16(X)
2964 ** routines return 1 if the input string X appears to be a complete SQL
2965 ** statement. ^A statement is judged to be
2966 ** complete if it ends with a semicolon token and is not a prefix of a
2967 ** well-formed CREATE TRIGGER statement. ^Semicolons that are embedded within
2968 ** string literals or quoted identifier names or comments are not
2969 ** independent tokens (they are part of the token in which they are
2970 ** embedded) and thus do not count as a statement terminator. ^Whitespace
2971 ** and comments that follow the final semicolon are ignored.
2972 **
2973 ** ^The sqlite3_complete(X) and sqlite3_complete16(X) routines return 0
2974 ** if the statement is incomplete. ^If a memory allocation fails, then
2975 ** SQLITE_NOMEM is returned.
2976 **
2977 ** The [sqlite3_incomplete(X)] routine is similar to [sqlite3_complete(X)]
2978 ** except that sqlite3_incomplete(X) returns 0 if the input X is complete
2979 ** and non-zero if X is incomplete. The non-zero return from
2980 ** sqlite3_incomplete(X) contains additional information about what is
2981 ** needed to complete the input X. The sqlite3_incomplete(X) interface
2982 ** is only available for UTF-8 text.
2983 **
2984 ** ^None of these routines do a full parse the SQL statements and thus
2985 ** will not detect syntactically incorrect SQL. They only determine if
2986 ** input text has properly terminated comments, string literals, and
2987 ** quoted identifiers, and if the statement ends with a semicolon.
2988 **
2989 ** ^(If SQLite has not been initialized using [sqlite3_initialize()] prior
2990 ** to invoking sqlite3_complete16() then sqlite3_initialize() is invoked
2991 ** automatically by sqlite3_complete16(). If that initialization fails,
2992 ** then the return value from sqlite3_complete16() will be non-zero
2993 ** regardless of whether or not the input SQL is complete.)^
2994 **
2995 ** The X input to [sqlite3_complete(X)] and [sqlite3_incomplete(X)
2996 ** must be a zero-terminated UTF-8 string.
2997 **
2998 ** The input to [sqlite3_complete16()] must be a zero-terminated
2999 ** UTF-16 string in native byte order.
3000 */
3001 SQLITE_API int sqlite3_complete(const char *sql);
3002 SQLITE_API int sqlite3_complete16(const void *sql);
3003 SQLITE_API sqlite3_int64 sqlite3_incomplete(const char *sql);
3004
3005 /*
3006 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
3007 ** KEYWORDS: {busy-handler callback} {busy handler}
3008 ** METHOD: sqlite3
@@ -7613,11 +7625,11 @@
7625 ** entry point were as follows:
7626 **
7627 ** <blockquote><pre>
7628 ** &nbsp; int xEntryPoint(
7629 ** &nbsp; sqlite3 *db,
7630 ** &nbsp; char **pzErrMsg,
7631 ** &nbsp; const struct sqlite3_api_routines *pThunk
7632 ** &nbsp; );
7633 ** </pre></blockquote>)^
7634 **
7635 ** If the xEntryPoint routine encounters an error, it should make *pzErrMsg
7636
+2 -1
--- src/main.mk
+++ src/main.mk
@@ -702,11 +702,12 @@
702702
-Dmain=sqlite3_shell \
703703
-DSQLITE_SHELL_IS_UTF8=1 \
704704
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
705705
-DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
706706
-DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname \
707
- -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc
707
+ -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc \
708
+ -DSQLITE_PS1=\"FossilSQL/040/~/076/040\"
708709
709710
# Setup the options used to compile the included Pikchr formatter.
710711
PIKCHR_OPTIONS = -DPIKCHR_TOKEN_LIMIT=10000
711712
712713
# The USE_SYSTEM_SQLITE variable may be undefined, set to 0 or 1.
713714
--- src/main.mk
+++ src/main.mk
@@ -702,11 +702,12 @@
702 -Dmain=sqlite3_shell \
703 -DSQLITE_SHELL_IS_UTF8=1 \
704 -DSQLITE_OMIT_LOAD_EXTENSION=1 \
705 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
706 -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname \
707 -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc
 
708
709 # Setup the options used to compile the included Pikchr formatter.
710 PIKCHR_OPTIONS = -DPIKCHR_TOKEN_LIMIT=10000
711
712 # The USE_SYSTEM_SQLITE variable may be undefined, set to 0 or 1.
713
--- src/main.mk
+++ src/main.mk
@@ -702,11 +702,12 @@
702 -Dmain=sqlite3_shell \
703 -DSQLITE_SHELL_IS_UTF8=1 \
704 -DSQLITE_OMIT_LOAD_EXTENSION=1 \
705 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
706 -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname \
707 -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc \
708 -DSQLITE_PS1=\"FossilSQL/040/~/076/040\"
709
710 # Setup the options used to compile the included Pikchr formatter.
711 PIKCHR_OPTIONS = -DPIKCHR_TOKEN_LIMIT=10000
712
713 # The USE_SYSTEM_SQLITE variable may be undefined, set to 0 or 1.
714
--- tools/makemake.tcl
+++ tools/makemake.tcl
@@ -275,10 +275,11 @@
275275
-DSQLITE_SHELL_IS_UTF8=1
276276
-DSQLITE_OMIT_LOAD_EXTENSION=1
277277
-DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE)
278278
-DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname
279279
-DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc
280
+ -DSQLITE_PS1=\\\"FossilSQL/040/~/076/040\\\"
280281
}]
281282
282283
# Options used to compile the included SQLite shell on Windows.
283284
#
284285
set SHELL_WIN32_OPTIONS $SHELL_OPTIONS
@@ -1839,13 +1840,13 @@
18391840
}
18401841
regsub -all {[-]D} [join $SQLITE_WIN32_OPTIONS { }] {/D} MSC_SQLITE_OPTIONS
18411842
set j " \\\n "
18421843
writeln "SQLITE_OPTIONS = [join $MSC_SQLITE_OPTIONS $j]\n"
18431844
1844
-regsub -all {[-]D} [join $SHELL_WIN32_OPTIONS { }] {/D} MSC_SHELL_OPTIONS
18451845
set j " \\\n "
1846
-writeln "SHELL_OPTIONS = [join $MSC_SHELL_OPTIONS $j]\n"
1846
+writeln [string map {-D /D} \
1847
+ "SHELL_OPTIONS = [join $SHELL_WIN32_OPTIONS $j]"]\n
18471848
18481849
regsub -all {[-]D} [join $PIKCHR_OPTIONS { }] {/D} MSC_PIKCHR_OPTIONS
18491850
set j " \\\n "
18501851
writeln "PIKCHR_OPTIONS = [join $MSC_PIKCHR_OPTIONS $j]\n"
18511852
18521853
--- tools/makemake.tcl
+++ tools/makemake.tcl
@@ -275,10 +275,11 @@
275 -DSQLITE_SHELL_IS_UTF8=1
276 -DSQLITE_OMIT_LOAD_EXTENSION=1
277 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE)
278 -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname
279 -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc
 
280 }]
281
282 # Options used to compile the included SQLite shell on Windows.
283 #
284 set SHELL_WIN32_OPTIONS $SHELL_OPTIONS
@@ -1839,13 +1840,13 @@
1839 }
1840 regsub -all {[-]D} [join $SQLITE_WIN32_OPTIONS { }] {/D} MSC_SQLITE_OPTIONS
1841 set j " \\\n "
1842 writeln "SQLITE_OPTIONS = [join $MSC_SQLITE_OPTIONS $j]\n"
1843
1844 regsub -all {[-]D} [join $SHELL_WIN32_OPTIONS { }] {/D} MSC_SHELL_OPTIONS
1845 set j " \\\n "
1846 writeln "SHELL_OPTIONS = [join $MSC_SHELL_OPTIONS $j]\n"
 
1847
1848 regsub -all {[-]D} [join $PIKCHR_OPTIONS { }] {/D} MSC_PIKCHR_OPTIONS
1849 set j " \\\n "
1850 writeln "PIKCHR_OPTIONS = [join $MSC_PIKCHR_OPTIONS $j]\n"
1851
1852
--- tools/makemake.tcl
+++ tools/makemake.tcl
@@ -275,10 +275,11 @@
275 -DSQLITE_SHELL_IS_UTF8=1
276 -DSQLITE_OMIT_LOAD_EXTENSION=1
277 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE)
278 -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname
279 -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc
280 -DSQLITE_PS1=\\\"FossilSQL/040/~/076/040\\\"
281 }]
282
283 # Options used to compile the included SQLite shell on Windows.
284 #
285 set SHELL_WIN32_OPTIONS $SHELL_OPTIONS
@@ -1839,13 +1840,13 @@
1840 }
1841 regsub -all {[-]D} [join $SQLITE_WIN32_OPTIONS { }] {/D} MSC_SQLITE_OPTIONS
1842 set j " \\\n "
1843 writeln "SQLITE_OPTIONS = [join $MSC_SQLITE_OPTIONS $j]\n"
1844
 
1845 set j " \\\n "
1846 writeln [string map {-D /D} \
1847 "SHELL_OPTIONS = [join $SHELL_WIN32_OPTIONS $j]"]\n
1848
1849 regsub -all {[-]D} [join $PIKCHR_OPTIONS { }] {/D} MSC_PIKCHR_OPTIONS
1850 set j " \\\n "
1851 writeln "PIKCHR_OPTIONS = [join $MSC_PIKCHR_OPTIONS $j]\n"
1852
1853
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -28,11 +28,11 @@
2828
TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
2929
LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32 dnsapi
3030
3131
SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_PERCENTILE -DSQLITE_ENABLE_SETLK_TIMEOUT -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP
3232
33
-SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_PERCENTILE -DSQLITE_ENABLE_SETLK_TIMEOUT -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
33
+SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_PERCENTILE -DSQLITE_ENABLE_SETLK_TIMEOUT -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc -DSQLITE_PS1=\"FossilSQL/040/~/076/040\" -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
3434
3535
PIKCHR_OPTIONS = -DPIKCHR_TOKEN_LIMIT=10000
3636
3737
SRC = add_.c ajax_.c alerts_.c allrepo_.c attach_.c backlink_.c backoffice_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c capabilities_.c captcha_.c cgi_.c chat_.c checkin_.c checkout_.c clearsign_.c clone_.c color_.c comformat_.c configure_.c content_.c cookies_.c db_.c delta_.c deltacmd_.c deltafunc_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c etag_.c event_.c export_.c extcgi_.c file_.c fileedit_.c finfo_.c foci_.c forum_.c fshell_.c fusefs_.c fuzz_.c glob_.c graph_.c gzip_.c hname_.c hook_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c interwiki_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c match_.c md5_.c merge_.c merge3_.c moderate_.c name_.c patch_.c path_.c piechart_.c pikchrshow_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c repolist_.c report_.c robot_.c rss_.c schema_.c search_.c security_audit_.c setup_.c setupuser_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c smtp_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c terminal_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c xfer_.c xfersetup_.c xsystem_.c zip_.c
3838
3939
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -28,11 +28,11 @@
28 TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
29 LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32 dnsapi
30
31 SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_PERCENTILE -DSQLITE_ENABLE_SETLK_TIMEOUT -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP
32
33 SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_PERCENTILE -DSQLITE_ENABLE_SETLK_TIMEOUT -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
34
35 PIKCHR_OPTIONS = -DPIKCHR_TOKEN_LIMIT=10000
36
37 SRC = add_.c ajax_.c alerts_.c allrepo_.c attach_.c backlink_.c backoffice_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c capabilities_.c captcha_.c cgi_.c chat_.c checkin_.c checkout_.c clearsign_.c clone_.c color_.c comformat_.c configure_.c content_.c cookies_.c db_.c delta_.c deltacmd_.c deltafunc_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c etag_.c event_.c export_.c extcgi_.c file_.c fileedit_.c finfo_.c foci_.c forum_.c fshell_.c fusefs_.c fuzz_.c glob_.c graph_.c gzip_.c hname_.c hook_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c interwiki_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c match_.c md5_.c merge_.c merge3_.c moderate_.c name_.c patch_.c path_.c piechart_.c pikchrshow_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c repolist_.c report_.c robot_.c rss_.c schema_.c search_.c security_audit_.c setup_.c setupuser_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c smtp_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c terminal_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c xfer_.c xfersetup_.c xsystem_.c zip_.c
38
39
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -28,11 +28,11 @@
28 TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
29 LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32 dnsapi
30
31 SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_PERCENTILE -DSQLITE_ENABLE_SETLK_TIMEOUT -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP
32
33 SHELL_OPTIONS = -DNDEBUG=1 -DSQLITE_DQS=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_MEMSTATUS=0 -DSQLITE_DEFAULT_WAL_SYNCHRONOUS=1 -DSQLITE_LIKE_DOESNT_MATCH_BLOBS -DSQLITE_OMIT_DECLTYPE -DSQLITE_OMIT_DEPRECATED -DSQLITE_OMIT_PROGRESS_CALLBACK -DSQLITE_OMIT_SHARED_CACHE -DSQLITE_OMIT_LOAD_EXTENSION -DSQLITE_MAX_EXPR_DEPTH=0 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS5 -DSQLITE_ENABLE_MATH_FUNCTIONS -DSQLITE_ENABLE_PERCENTILE -DSQLITE_ENABLE_SETLK_TIMEOUT -DSQLITE_ENABLE_STMTVTAB -DSQLITE_HAVE_ZLIB -DSQLITE_ENABLE_DBPAGE_VTAB -DSQLITE_TRUSTED_SCHEMA=0 -DHAVE_USLEEP -Dmain=sqlite3_shell -DSQLITE_SHELL_IS_UTF8=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc -DSQLITE_PS1=\"FossilSQL/040/~/076/040\" -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
34
35 PIKCHR_OPTIONS = -DPIKCHR_TOKEN_LIMIT=10000
36
37 SRC = add_.c ajax_.c alerts_.c allrepo_.c attach_.c backlink_.c backoffice_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c capabilities_.c captcha_.c cgi_.c chat_.c checkin_.c checkout_.c clearsign_.c clone_.c color_.c comformat_.c configure_.c content_.c cookies_.c db_.c delta_.c deltacmd_.c deltafunc_.c descendants_.c diff_.c diffcmd_.c dispatch_.c doc_.c encode_.c etag_.c event_.c export_.c extcgi_.c file_.c fileedit_.c finfo_.c foci_.c forum_.c fshell_.c fusefs_.c fuzz_.c glob_.c graph_.c gzip_.c hname_.c hook_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c interwiki_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c match_.c md5_.c merge_.c merge3_.c moderate_.c name_.c patch_.c path_.c piechart_.c pikchrshow_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c repolist_.c report_.c robot_.c rss_.c schema_.c search_.c security_audit_.c setup_.c setupuser_.c sha1_.c sha1hard_.c sha3_.c shun_.c sitemap_.c skins_.c smtp_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c terminal_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c unversioned_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c xfer_.c xfersetup_.c xsystem_.c zip_.c
38
39
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -2602,10 +2602,11 @@
26022602
-DSQLITE_SHELL_IS_UTF8=1 \
26032603
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
26042604
-DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
26052605
-DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname \
26062606
-DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc \
2607
+ -DSQLITE_PS1=\"FossilSQL/040/~/076/040\" \
26072608
-Daccess=file_access \
26082609
-Dsystem=fossil_system \
26092610
-Dgetenv=fossil_getenv \
26102611
-Dfopen=fossil_fopen
26112612
26122613
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -2602,10 +2602,11 @@
2602 -DSQLITE_SHELL_IS_UTF8=1 \
2603 -DSQLITE_OMIT_LOAD_EXTENSION=1 \
2604 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
2605 -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname \
2606 -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc \
 
2607 -Daccess=file_access \
2608 -Dsystem=fossil_system \
2609 -Dgetenv=fossil_getenv \
2610 -Dfopen=fossil_fopen
2611
2612
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -2602,10 +2602,11 @@
2602 -DSQLITE_SHELL_IS_UTF8=1 \
2603 -DSQLITE_OMIT_LOAD_EXTENSION=1 \
2604 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
2605 -DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname \
2606 -DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc \
2607 -DSQLITE_PS1=\"FossilSQL/040/~/076/040\" \
2608 -Daccess=file_access \
2609 -Dsystem=fossil_system \
2610 -Dgetenv=fossil_getenv \
2611 -Dfopen=fossil_fopen
2612
2613
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -357,10 +357,11 @@
357357
/DSQLITE_SHELL_IS_UTF8=1 \
358358
/DSQLITE_OMIT_LOAD_EXTENSION=1 \
359359
/DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
360360
/DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname \
361361
/DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc \
362
+ /DSQLITE_PS1=\"FossilSQL/040/~/076/040\" \
362363
/Daccess=file_access \
363364
/Dsystem=fossil_system \
364365
/Dgetenv=fossil_getenv \
365366
/Dfopen=fossil_fopen
366367
367368
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -357,10 +357,11 @@
357 /DSQLITE_SHELL_IS_UTF8=1 \
358 /DSQLITE_OMIT_LOAD_EXTENSION=1 \
359 /DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
360 /DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname \
361 /DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc \
 
362 /Daccess=file_access \
363 /Dsystem=fossil_system \
364 /Dgetenv=fossil_getenv \
365 /Dfopen=fossil_fopen
366
367
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -357,10 +357,11 @@
357 /DSQLITE_SHELL_IS_UTF8=1 \
358 /DSQLITE_OMIT_LOAD_EXTENSION=1 \
359 /DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
360 /DSQLITE_SHELL_DBNAME_PROC=sqlcmd_get_dbname \
361 /DSQLITE_SHELL_INIT_PROC=sqlcmd_init_proc \
362 /DSQLITE_PS1=\"FossilSQL/040/~/076/040\" \
363 /Daccess=file_access \
364 /Dsystem=fossil_system \
365 /Dgetenv=fossil_getenv \
366 /Dfopen=fossil_fopen
367
368

Keyboard Shortcuts

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