Fossil SCM

Latest upstream sqlite3 shell.c, primarily to squelch warnings on cygwin.

stephan 2025-03-06 07:49 trunk
Commit 4d34e18c213827effeafd3c7f05aa0ac1ca8ddb90b49f8453e503c54dd47aca4
1 file changed +81 -37
+81 -37
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -234,10 +234,12 @@
234234
235235
/* ctype macros that work with signed characters */
236236
#define IsSpace(X) isspace((unsigned char)X)
237237
#define IsDigit(X) isdigit((unsigned char)X)
238238
#define ToLower(X) (char)tolower((unsigned char)X)
239
+#define IsAlnum(X) isalnum((unsigned char)X)
240
+#define IsAlpha(X) isalpha((unsigned char)X)
239241
240242
#if defined(_WIN32) || defined(WIN32)
241243
#if SQLITE_OS_WINRT
242244
#include <intrin.h>
243245
#endif
@@ -1506,13 +1508,13 @@
15061508
** Return '"' if quoting is required. Return 0 if no quoting is required.
15071509
*/
15081510
static char quoteChar(const char *zName){
15091511
int i;
15101512
if( zName==0 ) return '"';
1511
- if( !isalpha((unsigned char)zName[0]) && zName[0]!='_' ) return '"';
1513
+ if( !IsAlpha(zName[0]) && zName[0]!='_' ) return '"';
15121514
for(i=0; zName[i]; i++){
1513
- if( !isalnum((unsigned char)zName[i]) && zName[i]!='_' ) return '"';
1515
+ if( !IsAlnum(zName[i]) && zName[i]!='_' ) return '"';
15141516
}
15151517
return sqlite3_keyword_check(zName, i) ? '"' : 0;
15161518
}
15171519
15181520
/*
@@ -2425,11 +2427,11 @@
24252427
** content in cases where the content starts
24262428
** with a digit.
24272429
**
24282430
** typeof(Y)='blob' The hash is taken over prefix "Bnnn:" followed
24292431
** by the binary content of the blob. The "nnn"
2430
-** in the prefix is the mimimum-length decimal
2432
+** in the prefix is the minimum-length decimal
24312433
** representation of the byte-length of the blob.
24322434
**
24332435
** According to the rules above, all of the following SELECT statements
24342436
** should return TRUE:
24352437
**
@@ -3646,11 +3648,11 @@
36463648
**
36473649
** UINT works like BINARY for text, except that embedded strings
36483650
** of digits compare in numeric order.
36493651
**
36503652
** * Leading zeros are handled properly, in the sense that
3651
-** they do not mess of the maginitude comparison of embedded
3653
+** they do not mess of the magnitude comparison of embedded
36523654
** strings of digits. "x00123y" is equal to "x123y".
36533655
**
36543656
** * Only unsigned integers are recognized. Plus and minus
36553657
** signs are ignored. Decimal points and exponential notation
36563658
** are ignored.
@@ -3752,10 +3754,13 @@
37523754
** warnings. */
37533755
#ifndef UNUSED_PARAMETER
37543756
# define UNUSED_PARAMETER(X) (void)(X)
37553757
#endif
37563758
3759
+#ifndef IsSpace
3760
+#define IsSpace(X) isspace((unsigned char)X)
3761
+#endif
37573762
37583763
/* A decimal object */
37593764
typedef struct Decimal Decimal;
37603765
struct Decimal {
37613766
char sign; /* 0 for positive, 1 for negative */
@@ -3801,11 +3806,11 @@
38013806
p->isNull = 0;
38023807
p->nDigit = 0;
38033808
p->nFrac = 0;
38043809
p->a = sqlite3_malloc64( n+1 );
38053810
if( p->a==0 ) goto new_from_text_failed;
3806
- for(i=0; isspace(zIn[i]); i++){}
3811
+ for(i=0; IsSpace(zIn[i]); i++){}
38073812
if( zIn[i]=='-' ){
38083813
p->sign = 1;
38093814
i++;
38103815
}else if( zIn[i]=='+' ){
38113816
i++;
@@ -4456,11 +4461,11 @@
44564461
}
44574462
decimal_free(pA);
44584463
decimal_free(pB);
44594464
}
44604465
4461
-/* Aggregate funcion: decimal_sum(X)
4466
+/* Aggregate function: decimal_sum(X)
44624467
**
44634468
** Works like sum() except that it uses decimal arithmetic for unlimited
44644469
** precision.
44654470
*/
44664471
static void decimalSumStep(
@@ -4817,11 +4822,11 @@
48174822
}
48184823
48194824
/*
48204825
** Generate an error for a percentile function.
48214826
**
4822
-** The error format string must have exactly one occurrance of "%%s()"
4827
+** The error format string must have exactly one occurrence of "%%s()"
48234828
** (with two '%' characters). That substring will be replaced by the name
48244829
** of the function.
48254830
*/
48264831
static void percentError(sqlite3_context *pCtx, const char *zFormat, ...){
48274832
PercentileFunc *pFunc = (PercentileFunc*)sqlite3_user_data(pCtx);
@@ -5957,11 +5962,11 @@
59575962
** number format:
59585963
**
59595964
** WITH c(name,bin) AS (VALUES
59605965
** ('minimum positive value', x'0000000000000001'),
59615966
** ('maximum subnormal value', x'000fffffffffffff'),
5962
-** ('mininum positive nornal value', x'0010000000000000'),
5967
+** ('minimum positive normal value', x'0010000000000000'),
59635968
** ('maximum value', x'7fefffffffffffff'))
59645969
** SELECT c.name, decimal_mul(ieee754_mantissa(c.bin),pow2.v)
59655970
** FROM pow2, c WHERE pow2.x=ieee754_exponent(c.bin);
59665971
**
59675972
*/
@@ -6344,11 +6349,11 @@
63446349
* 2 for UBSAN's satisfaction (and hypothetical 1's complement ALUs.) */
63456350
smBase += (mxI64/2) * smStep;
63466351
smBase += (mxI64 - mxI64/2) * smStep;
63476352
}
63486353
/* Under UBSAN (or on 1's complement machines), must do this last term
6349
- * in steps to avoid the dreaded (and harmless) signed multiply overlow. */
6354
+ * in steps to avoid the dreaded (and harmless) signed multiply overflow. */
63506355
if( ix>=2 ){
63516356
sqlite3_int64 ix2 = (sqlite3_int64)ix/2;
63526357
smBase += ix2*smStep;
63536358
ix -= ix2;
63546359
}
@@ -9024,10 +9029,15 @@
90249029
#include <assert.h>
90259030
#include <string.h>
90269031
#include <ctype.h>
90279032
90289033
#ifndef SQLITE_OMIT_VIRTUALTABLE
9034
+
9035
+#ifndef IsAlnum
9036
+#define IsAlnum(X) isalnum((unsigned char)X)
9037
+#endif
9038
+
90299039
90309040
/* completion_vtab is a subclass of sqlite3_vtab which will
90319041
** serve as the underlying representation of a completion virtual table
90329042
*/
90339043
typedef struct completion_vtab completion_vtab;
@@ -9361,11 +9371,11 @@
93619371
if( pCur->zLine==0 ) return SQLITE_NOMEM;
93629372
}
93639373
}
93649374
if( pCur->zLine!=0 && pCur->zPrefix==0 ){
93659375
int i = pCur->nLine;
9366
- while( i>0 && (isalnum(pCur->zLine[i-1]) || pCur->zLine[i-1]=='_') ){
9376
+ while( i>0 && (IsAlnum(pCur->zLine[i-1]) || pCur->zLine[i-1]=='_') ){
93679377
i--;
93689378
}
93699379
pCur->nPrefix = pCur->nLine - i;
93709380
if( pCur->nPrefix>0 ){
93719381
pCur->zPrefix = sqlite3_mprintf("%.*s", pCur->nPrefix, pCur->zLine + i);
@@ -14768,11 +14778,11 @@
1476814778
/* Register the auth callback with dbv */
1476914779
if( rc==SQLITE_OK ){
1477014780
sqlite3_set_authorizer(pNew->dbv, idxAuthCallback, (void*)pNew);
1477114781
}
1477214782
14773
- /* If an error has occurred, free the new object and reutrn NULL. Otherwise,
14783
+ /* If an error has occurred, free the new object and return NULL. Otherwise,
1477414784
** return the new sqlite3expert handle. */
1477514785
if( rc!=SQLITE_OK ){
1477614786
sqlite3_expert_destroy(pNew);
1477714787
pNew = 0;
1477814788
}
@@ -16290,11 +16300,11 @@
1629016300
**
1629116301
** PRAGMA vfstrace('+all');
1629216302
**
1629316303
** Individual APIs can be enabled or disabled by name, with or without
1629416304
** the initial "x" character. For example, to set up for tracing lock
16295
-** primatives only:
16305
+** primitives only:
1629616306
**
1629716307
** PRAGMA vfstrace('-all, +Lock,Unlock,ShmLock');
1629816308
**
1629916309
** The argument to the vfstrace pragma ignores capitalization and any
1630016310
** characters other than alphabetics, '+', and '-'.
@@ -21241,41 +21251,57 @@
2124121251
** function is called.
2124221252
*/
2124321253
static void recoverStep(sqlite3_recover *p){
2124421254
assert( p && p->errCode==SQLITE_OK );
2124521255
switch( p->eState ){
21246
- case RECOVER_STATE_INIT:
21256
+ case RECOVER_STATE_INIT: {
21257
+ int bUseWrapper = 1;
2124721258
/* This is the very first call to sqlite3_recover_step() on this object.
2124821259
*/
2124921260
recoverSqlCallback(p, "BEGIN");
2125021261
recoverSqlCallback(p, "PRAGMA writable_schema = on");
21262
+ recoverSqlCallback(p, "PRAGMA foreign_keys = off");
2125121263
2125221264
recoverEnterMutex();
21253
- recoverInstallWrapper(p);
2125421265
2125521266
/* Open the output database. And register required virtual tables and
2125621267
** user functions with the new handle. */
2125721268
recoverOpenOutput(p);
2125821269
21259
- /* Open transactions on both the input and output databases. */
21260
- sqlite3_file_control(p->dbIn, p->zDb, SQLITE_FCNTL_RESET_CACHE, 0);
21261
- recoverExec(p, p->dbIn, "PRAGMA writable_schema = on");
21262
- recoverExec(p, p->dbIn, "BEGIN");
21263
- if( p->errCode==SQLITE_OK ) p->bCloseTransaction = 1;
21264
- recoverExec(p, p->dbIn, "SELECT 1 FROM sqlite_schema");
21265
- recoverTransferSettings(p);
21266
- recoverOpenRecovery(p);
21267
- recoverCacheSchema(p);
21268
-
21269
- recoverUninstallWrapper(p);
21270
+ /* Attempt to open a transaction and read page 1 of the input database.
21271
+ ** Two attempts may be made - one with a wrapper installed to ensure
21272
+ ** that the database header is sane, and then if that attempt returns
21273
+ ** SQLITE_NOTADB, then again with no wrapper. The second attempt is
21274
+ ** required for encrypted databases. */
21275
+ if( p->errCode==SQLITE_OK ){
21276
+ do{
21277
+ p->errCode = SQLITE_OK;
21278
+ if( bUseWrapper ) recoverInstallWrapper(p);
21279
+
21280
+ /* Open a transaction on the input database. */
21281
+ sqlite3_file_control(p->dbIn, p->zDb, SQLITE_FCNTL_RESET_CACHE, 0);
21282
+ recoverExec(p, p->dbIn, "PRAGMA writable_schema = on");
21283
+ recoverExec(p, p->dbIn, "BEGIN");
21284
+ if( p->errCode==SQLITE_OK ) p->bCloseTransaction = 1;
21285
+ recoverExec(p, p->dbIn, "SELECT 1 FROM sqlite_schema");
21286
+ recoverTransferSettings(p);
21287
+ recoverOpenRecovery(p);
21288
+ recoverCacheSchema(p);
21289
+
21290
+ if( bUseWrapper ) recoverUninstallWrapper(p);
21291
+ }while( p->errCode==SQLITE_NOTADB
21292
+ && (bUseWrapper--)
21293
+ && SQLITE_OK==sqlite3_exec(p->dbIn, "ROLLBACK", 0, 0, 0)
21294
+ );
21295
+ }
21296
+
2127021297
recoverLeaveMutex();
21271
-
2127221298
recoverExec(p, p->dbOut, "BEGIN");
21273
-
2127421299
recoverWriteSchema1(p);
2127521300
p->eState = RECOVER_STATE_WRITING;
2127621301
break;
21302
+ }
2127721303
2127821304
case RECOVER_STATE_WRITING: {
2127921305
if( p->w1.pTbls==0 ){
2128021306
recoverWriteDataInit(p);
2128121307
}
@@ -21711,17 +21737,18 @@
2171121737
#define SHELL_PROGRESS_RESET 0x02 /* Reset the count when the progress
2171221738
** callback limit is reached, and for each
2171321739
** top-level SQL statement */
2171421740
#define SHELL_PROGRESS_ONCE 0x04 /* Cancel the --limit after firing once */
2171521741
21716
-/* Allowed values for ShellState.eEscMode
21742
+/* Allowed values for ShellState.eEscMode. The default value should
21743
+** be 0, so to change the default, reorder the names.
2171721744
*/
21718
-#define SHELL_ESC_SYMBOL 0 /* Substitute U+2400 graphics */
21719
-#define SHELL_ESC_ASCII 1 /* Substitute ^Y for X where Y=X+0x40 */
21745
+#define SHELL_ESC_ASCII 0 /* Substitute ^Y for X where Y=X+0x40 */
21746
+#define SHELL_ESC_SYMBOL 1 /* Substitute U+2400 graphics */
2172021747
#define SHELL_ESC_OFF 2 /* Send characters verbatim */
2172121748
21722
-static const char *shell_EscModeNames[] = { "symbol", "ascii", "off" };
21749
+static const char *shell_EscModeNames[] = { "ascii", "symbol", "off" };
2172321750
2172421751
/*
2172521752
** These are the allowed shellFlgs values
2172621753
*/
2172721754
#define SHFLG_Pagecache 0x00000001 /* The --pagecache option is used */
@@ -22902,18 +22929,22 @@
2290222929
int j;
2290322930
int nParen = 0;
2290422931
char cEnd = 0;
2290522932
char c;
2290622933
int nLine = 0;
22934
+ int isIndex;
22935
+ int isWhere = 0;
2290722936
assert( nArg==1 );
2290822937
if( azArg[0]==0 ) break;
2290922938
if( sqlite3_strlike("CREATE VIEW%", azArg[0], 0)==0
2291022939
|| sqlite3_strlike("CREATE TRIG%", azArg[0], 0)==0
2291122940
){
2291222941
sqlite3_fprintf(p->out, "%s;\n", azArg[0]);
2291322942
break;
2291422943
}
22944
+ isIndex = sqlite3_strlike("CREATE INDEX%", azArg[0], 0)==0
22945
+ || sqlite3_strlike("CREATE UNIQUE INDEX%", azArg[0], 0)==0;
2291522946
z = sqlite3_mprintf("%s", azArg[0]);
2291622947
shell_check_oom(z);
2291722948
j = 0;
2291822949
for(i=0; IsSpace(z[i]); i++){}
2291922950
for(; (c = z[i])!=0; i++){
@@ -22939,18 +22970,30 @@
2293922970
cEnd = '\n';
2294022971
}else if( c=='(' ){
2294122972
nParen++;
2294222973
}else if( c==')' ){
2294322974
nParen--;
22944
- if( nLine>0 && nParen==0 && j>0 ){
22975
+ if( nLine>0 && nParen==0 && j>0 && !isWhere ){
2294522976
printSchemaLineN(p->out, z, j, "\n");
2294622977
j = 0;
2294722978
}
22979
+ }else if( (c=='w' || c=='W')
22980
+ && nParen==0 && isIndex
22981
+ && sqlite3_strnicmp("WHERE",&z[i],5)==0
22982
+ && !IsAlnum(z[i+5]) && z[i+5]!='_' ){
22983
+ isWhere = 1;
22984
+ }else if( isWhere && (c=='A' || c=='a')
22985
+ && nParen==0
22986
+ && sqlite3_strnicmp("AND",&z[i],3)==0
22987
+ && !IsAlnum(z[i+3]) && z[i+3]!='_' ){
22988
+ printSchemaLineN(p->out, z, j, "\n ");
22989
+ j = 0;
2294822990
}
2294922991
z[j++] = c;
2295022992
if( nParen==1 && cEnd==0
2295122993
&& (c=='(' || c=='\n' || (c==',' && !wsToEol(z+i+1)))
22994
+ && !isWhere
2295222995
){
2295322996
if( c=='\n' ) j--;
2295422997
printSchemaLineN(p->out, z, j, "\n ");
2295522998
j = 0;
2295622999
nLine++;
@@ -24150,15 +24193,15 @@
2415024193
i++;
2415124194
}
2415224195
if( n>=mxWidth && bWordWrap ){
2415324196
/* Perhaps try to back up to a better place to break the line */
2415424197
for(k=i; k>i/2; k--){
24155
- if( isspace(z[k-1]) ) break;
24198
+ if( IsSpace(z[k-1]) ) break;
2415624199
}
2415724200
if( k<=i/2 ){
2415824201
for(k=i; k>i/2; k--){
24159
- if( isalnum(z[k-1])!=isalnum(z[k]) && (z[k]&0xc0)!=0x80 ) break;
24202
+ if( IsAlnum(z[k-1])!=IsAlnum(z[k]) && (z[k]&0xc0)!=0x80 ) break;
2416024203
}
2416124204
}
2416224205
if( k<=i/2 ){
2416324206
k = i;
2416424207
}else{
@@ -26088,11 +26131,11 @@
2608826131
#if HAVE_LINENOISE==2
2608926132
UNUSED_PARAMETER(pUserData);
2609026133
#endif
2609126134
if( nLine>(i64)sizeof(zBuf)-30 ) return;
2609226135
if( zLine[0]=='.' || zLine[0]=='#') return;
26093
- for(i=nLine-1; i>=0 && (isalnum(zLine[i]) || zLine[i]=='_'); i--){}
26136
+ for(i=nLine-1; i>=0 && (IsAlnum(zLine[i]) || zLine[i]=='_'); i--){}
2609426137
if( i==nLine-1 ) return;
2609526138
iStart = i+1;
2609626139
memcpy(zBuf, zLine, iStart);
2609726140
zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
2609826141
" FROM completion(%Q,%Q) ORDER BY 1",
@@ -28328,10 +28371,11 @@
2832828371
sqlite3_recover_config(p, 789, (void*)zRecoveryDb); /* Debug use only */
2832928372
sqlite3_recover_config(p, SQLITE_RECOVER_LOST_AND_FOUND, (void*)zLAF);
2833028373
sqlite3_recover_config(p, SQLITE_RECOVER_ROWIDS, (void*)&bRowids);
2833128374
sqlite3_recover_config(p, SQLITE_RECOVER_FREELIST_CORRUPT,(void*)&bFreelist);
2833228375
28376
+ sqlite3_fprintf(pState->out, ".dbconfig defensive off\n");
2833328377
sqlite3_recover_run(p);
2833428378
if( sqlite3_recover_errcode(p)!=SQLITE_OK ){
2833528379
const char *zErr = sqlite3_recover_errmsg(p);
2833628380
int errCode = sqlite3_recover_errcode(p);
2833728381
sqlite3_fprintf(stderr,"sql error: %s (%d)\n", zErr, errCode);
@@ -32419,11 +32463,11 @@
3241932463
/*
3242032464
** The CLI needs a working sqlite3_complete() to work properly. So error
3242132465
** out of the build if compiling with SQLITE_OMIT_COMPLETE.
3242232466
*/
3242332467
#ifdef SQLITE_OMIT_COMPLETE
32424
-# error the CLI application is imcompatable with SQLITE_OMIT_COMPLETE.
32468
+# error the CLI application is incompatable with SQLITE_OMIT_COMPLETE.
3242532469
#endif
3242632470
3242732471
/*
3242832472
** Return true if zSql is a complete SQL statement. Return false if it
3242932473
** ends in the middle of a string literal or C-style comment.
@@ -32598,11 +32642,11 @@
3259832642
UNUSED_PARAMETER(in);
3259932643
UNUSED_PARAMETER(isContinuation);
3260032644
if(!z || !*z){
3260132645
return 0;
3260232646
}
32603
- while(*z && isspace(*z)) ++z;
32647
+ while(*z && IsSpace(*z)) ++z;
3260432648
zBegin = z;
3260532649
for(; *z && '\n'!=*z; ++nZ, ++z){}
3260632650
if(nZ>0 && '\r'==zBegin[nZ-1]){
3260732651
--nZ;
3260832652
}
3260932653
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -234,10 +234,12 @@
234
235 /* ctype macros that work with signed characters */
236 #define IsSpace(X) isspace((unsigned char)X)
237 #define IsDigit(X) isdigit((unsigned char)X)
238 #define ToLower(X) (char)tolower((unsigned char)X)
 
 
239
240 #if defined(_WIN32) || defined(WIN32)
241 #if SQLITE_OS_WINRT
242 #include <intrin.h>
243 #endif
@@ -1506,13 +1508,13 @@
1506 ** Return '"' if quoting is required. Return 0 if no quoting is required.
1507 */
1508 static char quoteChar(const char *zName){
1509 int i;
1510 if( zName==0 ) return '"';
1511 if( !isalpha((unsigned char)zName[0]) && zName[0]!='_' ) return '"';
1512 for(i=0; zName[i]; i++){
1513 if( !isalnum((unsigned char)zName[i]) && zName[i]!='_' ) return '"';
1514 }
1515 return sqlite3_keyword_check(zName, i) ? '"' : 0;
1516 }
1517
1518 /*
@@ -2425,11 +2427,11 @@
2425 ** content in cases where the content starts
2426 ** with a digit.
2427 **
2428 ** typeof(Y)='blob' The hash is taken over prefix "Bnnn:" followed
2429 ** by the binary content of the blob. The "nnn"
2430 ** in the prefix is the mimimum-length decimal
2431 ** representation of the byte-length of the blob.
2432 **
2433 ** According to the rules above, all of the following SELECT statements
2434 ** should return TRUE:
2435 **
@@ -3646,11 +3648,11 @@
3646 **
3647 ** UINT works like BINARY for text, except that embedded strings
3648 ** of digits compare in numeric order.
3649 **
3650 ** * Leading zeros are handled properly, in the sense that
3651 ** they do not mess of the maginitude comparison of embedded
3652 ** strings of digits. "x00123y" is equal to "x123y".
3653 **
3654 ** * Only unsigned integers are recognized. Plus and minus
3655 ** signs are ignored. Decimal points and exponential notation
3656 ** are ignored.
@@ -3752,10 +3754,13 @@
3752 ** warnings. */
3753 #ifndef UNUSED_PARAMETER
3754 # define UNUSED_PARAMETER(X) (void)(X)
3755 #endif
3756
 
 
 
3757
3758 /* A decimal object */
3759 typedef struct Decimal Decimal;
3760 struct Decimal {
3761 char sign; /* 0 for positive, 1 for negative */
@@ -3801,11 +3806,11 @@
3801 p->isNull = 0;
3802 p->nDigit = 0;
3803 p->nFrac = 0;
3804 p->a = sqlite3_malloc64( n+1 );
3805 if( p->a==0 ) goto new_from_text_failed;
3806 for(i=0; isspace(zIn[i]); i++){}
3807 if( zIn[i]=='-' ){
3808 p->sign = 1;
3809 i++;
3810 }else if( zIn[i]=='+' ){
3811 i++;
@@ -4456,11 +4461,11 @@
4456 }
4457 decimal_free(pA);
4458 decimal_free(pB);
4459 }
4460
4461 /* Aggregate funcion: decimal_sum(X)
4462 **
4463 ** Works like sum() except that it uses decimal arithmetic for unlimited
4464 ** precision.
4465 */
4466 static void decimalSumStep(
@@ -4817,11 +4822,11 @@
4817 }
4818
4819 /*
4820 ** Generate an error for a percentile function.
4821 **
4822 ** The error format string must have exactly one occurrance of "%%s()"
4823 ** (with two '%' characters). That substring will be replaced by the name
4824 ** of the function.
4825 */
4826 static void percentError(sqlite3_context *pCtx, const char *zFormat, ...){
4827 PercentileFunc *pFunc = (PercentileFunc*)sqlite3_user_data(pCtx);
@@ -5957,11 +5962,11 @@
5957 ** number format:
5958 **
5959 ** WITH c(name,bin) AS (VALUES
5960 ** ('minimum positive value', x'0000000000000001'),
5961 ** ('maximum subnormal value', x'000fffffffffffff'),
5962 ** ('mininum positive nornal value', x'0010000000000000'),
5963 ** ('maximum value', x'7fefffffffffffff'))
5964 ** SELECT c.name, decimal_mul(ieee754_mantissa(c.bin),pow2.v)
5965 ** FROM pow2, c WHERE pow2.x=ieee754_exponent(c.bin);
5966 **
5967 */
@@ -6344,11 +6349,11 @@
6344 * 2 for UBSAN's satisfaction (and hypothetical 1's complement ALUs.) */
6345 smBase += (mxI64/2) * smStep;
6346 smBase += (mxI64 - mxI64/2) * smStep;
6347 }
6348 /* Under UBSAN (or on 1's complement machines), must do this last term
6349 * in steps to avoid the dreaded (and harmless) signed multiply overlow. */
6350 if( ix>=2 ){
6351 sqlite3_int64 ix2 = (sqlite3_int64)ix/2;
6352 smBase += ix2*smStep;
6353 ix -= ix2;
6354 }
@@ -9024,10 +9029,15 @@
9024 #include <assert.h>
9025 #include <string.h>
9026 #include <ctype.h>
9027
9028 #ifndef SQLITE_OMIT_VIRTUALTABLE
 
 
 
 
 
9029
9030 /* completion_vtab is a subclass of sqlite3_vtab which will
9031 ** serve as the underlying representation of a completion virtual table
9032 */
9033 typedef struct completion_vtab completion_vtab;
@@ -9361,11 +9371,11 @@
9361 if( pCur->zLine==0 ) return SQLITE_NOMEM;
9362 }
9363 }
9364 if( pCur->zLine!=0 && pCur->zPrefix==0 ){
9365 int i = pCur->nLine;
9366 while( i>0 && (isalnum(pCur->zLine[i-1]) || pCur->zLine[i-1]=='_') ){
9367 i--;
9368 }
9369 pCur->nPrefix = pCur->nLine - i;
9370 if( pCur->nPrefix>0 ){
9371 pCur->zPrefix = sqlite3_mprintf("%.*s", pCur->nPrefix, pCur->zLine + i);
@@ -14768,11 +14778,11 @@
14768 /* Register the auth callback with dbv */
14769 if( rc==SQLITE_OK ){
14770 sqlite3_set_authorizer(pNew->dbv, idxAuthCallback, (void*)pNew);
14771 }
14772
14773 /* If an error has occurred, free the new object and reutrn NULL. Otherwise,
14774 ** return the new sqlite3expert handle. */
14775 if( rc!=SQLITE_OK ){
14776 sqlite3_expert_destroy(pNew);
14777 pNew = 0;
14778 }
@@ -16290,11 +16300,11 @@
16290 **
16291 ** PRAGMA vfstrace('+all');
16292 **
16293 ** Individual APIs can be enabled or disabled by name, with or without
16294 ** the initial "x" character. For example, to set up for tracing lock
16295 ** primatives only:
16296 **
16297 ** PRAGMA vfstrace('-all, +Lock,Unlock,ShmLock');
16298 **
16299 ** The argument to the vfstrace pragma ignores capitalization and any
16300 ** characters other than alphabetics, '+', and '-'.
@@ -21241,41 +21251,57 @@
21241 ** function is called.
21242 */
21243 static void recoverStep(sqlite3_recover *p){
21244 assert( p && p->errCode==SQLITE_OK );
21245 switch( p->eState ){
21246 case RECOVER_STATE_INIT:
 
21247 /* This is the very first call to sqlite3_recover_step() on this object.
21248 */
21249 recoverSqlCallback(p, "BEGIN");
21250 recoverSqlCallback(p, "PRAGMA writable_schema = on");
 
21251
21252 recoverEnterMutex();
21253 recoverInstallWrapper(p);
21254
21255 /* Open the output database. And register required virtual tables and
21256 ** user functions with the new handle. */
21257 recoverOpenOutput(p);
21258
21259 /* Open transactions on both the input and output databases. */
21260 sqlite3_file_control(p->dbIn, p->zDb, SQLITE_FCNTL_RESET_CACHE, 0);
21261 recoverExec(p, p->dbIn, "PRAGMA writable_schema = on");
21262 recoverExec(p, p->dbIn, "BEGIN");
21263 if( p->errCode==SQLITE_OK ) p->bCloseTransaction = 1;
21264 recoverExec(p, p->dbIn, "SELECT 1 FROM sqlite_schema");
21265 recoverTransferSettings(p);
21266 recoverOpenRecovery(p);
21267 recoverCacheSchema(p);
21268
21269 recoverUninstallWrapper(p);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21270 recoverLeaveMutex();
21271
21272 recoverExec(p, p->dbOut, "BEGIN");
21273
21274 recoverWriteSchema1(p);
21275 p->eState = RECOVER_STATE_WRITING;
21276 break;
 
21277
21278 case RECOVER_STATE_WRITING: {
21279 if( p->w1.pTbls==0 ){
21280 recoverWriteDataInit(p);
21281 }
@@ -21711,17 +21737,18 @@
21711 #define SHELL_PROGRESS_RESET 0x02 /* Reset the count when the progress
21712 ** callback limit is reached, and for each
21713 ** top-level SQL statement */
21714 #define SHELL_PROGRESS_ONCE 0x04 /* Cancel the --limit after firing once */
21715
21716 /* Allowed values for ShellState.eEscMode
 
21717 */
21718 #define SHELL_ESC_SYMBOL 0 /* Substitute U+2400 graphics */
21719 #define SHELL_ESC_ASCII 1 /* Substitute ^Y for X where Y=X+0x40 */
21720 #define SHELL_ESC_OFF 2 /* Send characters verbatim */
21721
21722 static const char *shell_EscModeNames[] = { "symbol", "ascii", "off" };
21723
21724 /*
21725 ** These are the allowed shellFlgs values
21726 */
21727 #define SHFLG_Pagecache 0x00000001 /* The --pagecache option is used */
@@ -22902,18 +22929,22 @@
22902 int j;
22903 int nParen = 0;
22904 char cEnd = 0;
22905 char c;
22906 int nLine = 0;
 
 
22907 assert( nArg==1 );
22908 if( azArg[0]==0 ) break;
22909 if( sqlite3_strlike("CREATE VIEW%", azArg[0], 0)==0
22910 || sqlite3_strlike("CREATE TRIG%", azArg[0], 0)==0
22911 ){
22912 sqlite3_fprintf(p->out, "%s;\n", azArg[0]);
22913 break;
22914 }
 
 
22915 z = sqlite3_mprintf("%s", azArg[0]);
22916 shell_check_oom(z);
22917 j = 0;
22918 for(i=0; IsSpace(z[i]); i++){}
22919 for(; (c = z[i])!=0; i++){
@@ -22939,18 +22970,30 @@
22939 cEnd = '\n';
22940 }else if( c=='(' ){
22941 nParen++;
22942 }else if( c==')' ){
22943 nParen--;
22944 if( nLine>0 && nParen==0 && j>0 ){
22945 printSchemaLineN(p->out, z, j, "\n");
22946 j = 0;
22947 }
 
 
 
 
 
 
 
 
 
 
 
22948 }
22949 z[j++] = c;
22950 if( nParen==1 && cEnd==0
22951 && (c=='(' || c=='\n' || (c==',' && !wsToEol(z+i+1)))
 
22952 ){
22953 if( c=='\n' ) j--;
22954 printSchemaLineN(p->out, z, j, "\n ");
22955 j = 0;
22956 nLine++;
@@ -24150,15 +24193,15 @@
24150 i++;
24151 }
24152 if( n>=mxWidth && bWordWrap ){
24153 /* Perhaps try to back up to a better place to break the line */
24154 for(k=i; k>i/2; k--){
24155 if( isspace(z[k-1]) ) break;
24156 }
24157 if( k<=i/2 ){
24158 for(k=i; k>i/2; k--){
24159 if( isalnum(z[k-1])!=isalnum(z[k]) && (z[k]&0xc0)!=0x80 ) break;
24160 }
24161 }
24162 if( k<=i/2 ){
24163 k = i;
24164 }else{
@@ -26088,11 +26131,11 @@
26088 #if HAVE_LINENOISE==2
26089 UNUSED_PARAMETER(pUserData);
26090 #endif
26091 if( nLine>(i64)sizeof(zBuf)-30 ) return;
26092 if( zLine[0]=='.' || zLine[0]=='#') return;
26093 for(i=nLine-1; i>=0 && (isalnum(zLine[i]) || zLine[i]=='_'); i--){}
26094 if( i==nLine-1 ) return;
26095 iStart = i+1;
26096 memcpy(zBuf, zLine, iStart);
26097 zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
26098 " FROM completion(%Q,%Q) ORDER BY 1",
@@ -28328,10 +28371,11 @@
28328 sqlite3_recover_config(p, 789, (void*)zRecoveryDb); /* Debug use only */
28329 sqlite3_recover_config(p, SQLITE_RECOVER_LOST_AND_FOUND, (void*)zLAF);
28330 sqlite3_recover_config(p, SQLITE_RECOVER_ROWIDS, (void*)&bRowids);
28331 sqlite3_recover_config(p, SQLITE_RECOVER_FREELIST_CORRUPT,(void*)&bFreelist);
28332
 
28333 sqlite3_recover_run(p);
28334 if( sqlite3_recover_errcode(p)!=SQLITE_OK ){
28335 const char *zErr = sqlite3_recover_errmsg(p);
28336 int errCode = sqlite3_recover_errcode(p);
28337 sqlite3_fprintf(stderr,"sql error: %s (%d)\n", zErr, errCode);
@@ -32419,11 +32463,11 @@
32419 /*
32420 ** The CLI needs a working sqlite3_complete() to work properly. So error
32421 ** out of the build if compiling with SQLITE_OMIT_COMPLETE.
32422 */
32423 #ifdef SQLITE_OMIT_COMPLETE
32424 # error the CLI application is imcompatable with SQLITE_OMIT_COMPLETE.
32425 #endif
32426
32427 /*
32428 ** Return true if zSql is a complete SQL statement. Return false if it
32429 ** ends in the middle of a string literal or C-style comment.
@@ -32598,11 +32642,11 @@
32598 UNUSED_PARAMETER(in);
32599 UNUSED_PARAMETER(isContinuation);
32600 if(!z || !*z){
32601 return 0;
32602 }
32603 while(*z && isspace(*z)) ++z;
32604 zBegin = z;
32605 for(; *z && '\n'!=*z; ++nZ, ++z){}
32606 if(nZ>0 && '\r'==zBegin[nZ-1]){
32607 --nZ;
32608 }
32609
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -234,10 +234,12 @@
234
235 /* ctype macros that work with signed characters */
236 #define IsSpace(X) isspace((unsigned char)X)
237 #define IsDigit(X) isdigit((unsigned char)X)
238 #define ToLower(X) (char)tolower((unsigned char)X)
239 #define IsAlnum(X) isalnum((unsigned char)X)
240 #define IsAlpha(X) isalpha((unsigned char)X)
241
242 #if defined(_WIN32) || defined(WIN32)
243 #if SQLITE_OS_WINRT
244 #include <intrin.h>
245 #endif
@@ -1506,13 +1508,13 @@
1508 ** Return '"' if quoting is required. Return 0 if no quoting is required.
1509 */
1510 static char quoteChar(const char *zName){
1511 int i;
1512 if( zName==0 ) return '"';
1513 if( !IsAlpha(zName[0]) && zName[0]!='_' ) return '"';
1514 for(i=0; zName[i]; i++){
1515 if( !IsAlnum(zName[i]) && zName[i]!='_' ) return '"';
1516 }
1517 return sqlite3_keyword_check(zName, i) ? '"' : 0;
1518 }
1519
1520 /*
@@ -2425,11 +2427,11 @@
2427 ** content in cases where the content starts
2428 ** with a digit.
2429 **
2430 ** typeof(Y)='blob' The hash is taken over prefix "Bnnn:" followed
2431 ** by the binary content of the blob. The "nnn"
2432 ** in the prefix is the minimum-length decimal
2433 ** representation of the byte-length of the blob.
2434 **
2435 ** According to the rules above, all of the following SELECT statements
2436 ** should return TRUE:
2437 **
@@ -3646,11 +3648,11 @@
3648 **
3649 ** UINT works like BINARY for text, except that embedded strings
3650 ** of digits compare in numeric order.
3651 **
3652 ** * Leading zeros are handled properly, in the sense that
3653 ** they do not mess of the magnitude comparison of embedded
3654 ** strings of digits. "x00123y" is equal to "x123y".
3655 **
3656 ** * Only unsigned integers are recognized. Plus and minus
3657 ** signs are ignored. Decimal points and exponential notation
3658 ** are ignored.
@@ -3752,10 +3754,13 @@
3754 ** warnings. */
3755 #ifndef UNUSED_PARAMETER
3756 # define UNUSED_PARAMETER(X) (void)(X)
3757 #endif
3758
3759 #ifndef IsSpace
3760 #define IsSpace(X) isspace((unsigned char)X)
3761 #endif
3762
3763 /* A decimal object */
3764 typedef struct Decimal Decimal;
3765 struct Decimal {
3766 char sign; /* 0 for positive, 1 for negative */
@@ -3801,11 +3806,11 @@
3806 p->isNull = 0;
3807 p->nDigit = 0;
3808 p->nFrac = 0;
3809 p->a = sqlite3_malloc64( n+1 );
3810 if( p->a==0 ) goto new_from_text_failed;
3811 for(i=0; IsSpace(zIn[i]); i++){}
3812 if( zIn[i]=='-' ){
3813 p->sign = 1;
3814 i++;
3815 }else if( zIn[i]=='+' ){
3816 i++;
@@ -4456,11 +4461,11 @@
4461 }
4462 decimal_free(pA);
4463 decimal_free(pB);
4464 }
4465
4466 /* Aggregate function: decimal_sum(X)
4467 **
4468 ** Works like sum() except that it uses decimal arithmetic for unlimited
4469 ** precision.
4470 */
4471 static void decimalSumStep(
@@ -4817,11 +4822,11 @@
4822 }
4823
4824 /*
4825 ** Generate an error for a percentile function.
4826 **
4827 ** The error format string must have exactly one occurrence of "%%s()"
4828 ** (with two '%' characters). That substring will be replaced by the name
4829 ** of the function.
4830 */
4831 static void percentError(sqlite3_context *pCtx, const char *zFormat, ...){
4832 PercentileFunc *pFunc = (PercentileFunc*)sqlite3_user_data(pCtx);
@@ -5957,11 +5962,11 @@
5962 ** number format:
5963 **
5964 ** WITH c(name,bin) AS (VALUES
5965 ** ('minimum positive value', x'0000000000000001'),
5966 ** ('maximum subnormal value', x'000fffffffffffff'),
5967 ** ('minimum positive normal value', x'0010000000000000'),
5968 ** ('maximum value', x'7fefffffffffffff'))
5969 ** SELECT c.name, decimal_mul(ieee754_mantissa(c.bin),pow2.v)
5970 ** FROM pow2, c WHERE pow2.x=ieee754_exponent(c.bin);
5971 **
5972 */
@@ -6344,11 +6349,11 @@
6349 * 2 for UBSAN's satisfaction (and hypothetical 1's complement ALUs.) */
6350 smBase += (mxI64/2) * smStep;
6351 smBase += (mxI64 - mxI64/2) * smStep;
6352 }
6353 /* Under UBSAN (or on 1's complement machines), must do this last term
6354 * in steps to avoid the dreaded (and harmless) signed multiply overflow. */
6355 if( ix>=2 ){
6356 sqlite3_int64 ix2 = (sqlite3_int64)ix/2;
6357 smBase += ix2*smStep;
6358 ix -= ix2;
6359 }
@@ -9024,10 +9029,15 @@
9029 #include <assert.h>
9030 #include <string.h>
9031 #include <ctype.h>
9032
9033 #ifndef SQLITE_OMIT_VIRTUALTABLE
9034
9035 #ifndef IsAlnum
9036 #define IsAlnum(X) isalnum((unsigned char)X)
9037 #endif
9038
9039
9040 /* completion_vtab is a subclass of sqlite3_vtab which will
9041 ** serve as the underlying representation of a completion virtual table
9042 */
9043 typedef struct completion_vtab completion_vtab;
@@ -9361,11 +9371,11 @@
9371 if( pCur->zLine==0 ) return SQLITE_NOMEM;
9372 }
9373 }
9374 if( pCur->zLine!=0 && pCur->zPrefix==0 ){
9375 int i = pCur->nLine;
9376 while( i>0 && (IsAlnum(pCur->zLine[i-1]) || pCur->zLine[i-1]=='_') ){
9377 i--;
9378 }
9379 pCur->nPrefix = pCur->nLine - i;
9380 if( pCur->nPrefix>0 ){
9381 pCur->zPrefix = sqlite3_mprintf("%.*s", pCur->nPrefix, pCur->zLine + i);
@@ -14768,11 +14778,11 @@
14778 /* Register the auth callback with dbv */
14779 if( rc==SQLITE_OK ){
14780 sqlite3_set_authorizer(pNew->dbv, idxAuthCallback, (void*)pNew);
14781 }
14782
14783 /* If an error has occurred, free the new object and return NULL. Otherwise,
14784 ** return the new sqlite3expert handle. */
14785 if( rc!=SQLITE_OK ){
14786 sqlite3_expert_destroy(pNew);
14787 pNew = 0;
14788 }
@@ -16290,11 +16300,11 @@
16300 **
16301 ** PRAGMA vfstrace('+all');
16302 **
16303 ** Individual APIs can be enabled or disabled by name, with or without
16304 ** the initial "x" character. For example, to set up for tracing lock
16305 ** primitives only:
16306 **
16307 ** PRAGMA vfstrace('-all, +Lock,Unlock,ShmLock');
16308 **
16309 ** The argument to the vfstrace pragma ignores capitalization and any
16310 ** characters other than alphabetics, '+', and '-'.
@@ -21241,41 +21251,57 @@
21251 ** function is called.
21252 */
21253 static void recoverStep(sqlite3_recover *p){
21254 assert( p && p->errCode==SQLITE_OK );
21255 switch( p->eState ){
21256 case RECOVER_STATE_INIT: {
21257 int bUseWrapper = 1;
21258 /* This is the very first call to sqlite3_recover_step() on this object.
21259 */
21260 recoverSqlCallback(p, "BEGIN");
21261 recoverSqlCallback(p, "PRAGMA writable_schema = on");
21262 recoverSqlCallback(p, "PRAGMA foreign_keys = off");
21263
21264 recoverEnterMutex();
 
21265
21266 /* Open the output database. And register required virtual tables and
21267 ** user functions with the new handle. */
21268 recoverOpenOutput(p);
21269
21270 /* Attempt to open a transaction and read page 1 of the input database.
21271 ** Two attempts may be made - one with a wrapper installed to ensure
21272 ** that the database header is sane, and then if that attempt returns
21273 ** SQLITE_NOTADB, then again with no wrapper. The second attempt is
21274 ** required for encrypted databases. */
21275 if( p->errCode==SQLITE_OK ){
21276 do{
21277 p->errCode = SQLITE_OK;
21278 if( bUseWrapper ) recoverInstallWrapper(p);
21279
21280 /* Open a transaction on the input database. */
21281 sqlite3_file_control(p->dbIn, p->zDb, SQLITE_FCNTL_RESET_CACHE, 0);
21282 recoverExec(p, p->dbIn, "PRAGMA writable_schema = on");
21283 recoverExec(p, p->dbIn, "BEGIN");
21284 if( p->errCode==SQLITE_OK ) p->bCloseTransaction = 1;
21285 recoverExec(p, p->dbIn, "SELECT 1 FROM sqlite_schema");
21286 recoverTransferSettings(p);
21287 recoverOpenRecovery(p);
21288 recoverCacheSchema(p);
21289
21290 if( bUseWrapper ) recoverUninstallWrapper(p);
21291 }while( p->errCode==SQLITE_NOTADB
21292 && (bUseWrapper--)
21293 && SQLITE_OK==sqlite3_exec(p->dbIn, "ROLLBACK", 0, 0, 0)
21294 );
21295 }
21296
21297 recoverLeaveMutex();
 
21298 recoverExec(p, p->dbOut, "BEGIN");
 
21299 recoverWriteSchema1(p);
21300 p->eState = RECOVER_STATE_WRITING;
21301 break;
21302 }
21303
21304 case RECOVER_STATE_WRITING: {
21305 if( p->w1.pTbls==0 ){
21306 recoverWriteDataInit(p);
21307 }
@@ -21711,17 +21737,18 @@
21737 #define SHELL_PROGRESS_RESET 0x02 /* Reset the count when the progress
21738 ** callback limit is reached, and for each
21739 ** top-level SQL statement */
21740 #define SHELL_PROGRESS_ONCE 0x04 /* Cancel the --limit after firing once */
21741
21742 /* Allowed values for ShellState.eEscMode. The default value should
21743 ** be 0, so to change the default, reorder the names.
21744 */
21745 #define SHELL_ESC_ASCII 0 /* Substitute ^Y for X where Y=X+0x40 */
21746 #define SHELL_ESC_SYMBOL 1 /* Substitute U+2400 graphics */
21747 #define SHELL_ESC_OFF 2 /* Send characters verbatim */
21748
21749 static const char *shell_EscModeNames[] = { "ascii", "symbol", "off" };
21750
21751 /*
21752 ** These are the allowed shellFlgs values
21753 */
21754 #define SHFLG_Pagecache 0x00000001 /* The --pagecache option is used */
@@ -22902,18 +22929,22 @@
22929 int j;
22930 int nParen = 0;
22931 char cEnd = 0;
22932 char c;
22933 int nLine = 0;
22934 int isIndex;
22935 int isWhere = 0;
22936 assert( nArg==1 );
22937 if( azArg[0]==0 ) break;
22938 if( sqlite3_strlike("CREATE VIEW%", azArg[0], 0)==0
22939 || sqlite3_strlike("CREATE TRIG%", azArg[0], 0)==0
22940 ){
22941 sqlite3_fprintf(p->out, "%s;\n", azArg[0]);
22942 break;
22943 }
22944 isIndex = sqlite3_strlike("CREATE INDEX%", azArg[0], 0)==0
22945 || sqlite3_strlike("CREATE UNIQUE INDEX%", azArg[0], 0)==0;
22946 z = sqlite3_mprintf("%s", azArg[0]);
22947 shell_check_oom(z);
22948 j = 0;
22949 for(i=0; IsSpace(z[i]); i++){}
22950 for(; (c = z[i])!=0; i++){
@@ -22939,18 +22970,30 @@
22970 cEnd = '\n';
22971 }else if( c=='(' ){
22972 nParen++;
22973 }else if( c==')' ){
22974 nParen--;
22975 if( nLine>0 && nParen==0 && j>0 && !isWhere ){
22976 printSchemaLineN(p->out, z, j, "\n");
22977 j = 0;
22978 }
22979 }else if( (c=='w' || c=='W')
22980 && nParen==0 && isIndex
22981 && sqlite3_strnicmp("WHERE",&z[i],5)==0
22982 && !IsAlnum(z[i+5]) && z[i+5]!='_' ){
22983 isWhere = 1;
22984 }else if( isWhere && (c=='A' || c=='a')
22985 && nParen==0
22986 && sqlite3_strnicmp("AND",&z[i],3)==0
22987 && !IsAlnum(z[i+3]) && z[i+3]!='_' ){
22988 printSchemaLineN(p->out, z, j, "\n ");
22989 j = 0;
22990 }
22991 z[j++] = c;
22992 if( nParen==1 && cEnd==0
22993 && (c=='(' || c=='\n' || (c==',' && !wsToEol(z+i+1)))
22994 && !isWhere
22995 ){
22996 if( c=='\n' ) j--;
22997 printSchemaLineN(p->out, z, j, "\n ");
22998 j = 0;
22999 nLine++;
@@ -24150,15 +24193,15 @@
24193 i++;
24194 }
24195 if( n>=mxWidth && bWordWrap ){
24196 /* Perhaps try to back up to a better place to break the line */
24197 for(k=i; k>i/2; k--){
24198 if( IsSpace(z[k-1]) ) break;
24199 }
24200 if( k<=i/2 ){
24201 for(k=i; k>i/2; k--){
24202 if( IsAlnum(z[k-1])!=IsAlnum(z[k]) && (z[k]&0xc0)!=0x80 ) break;
24203 }
24204 }
24205 if( k<=i/2 ){
24206 k = i;
24207 }else{
@@ -26088,11 +26131,11 @@
26131 #if HAVE_LINENOISE==2
26132 UNUSED_PARAMETER(pUserData);
26133 #endif
26134 if( nLine>(i64)sizeof(zBuf)-30 ) return;
26135 if( zLine[0]=='.' || zLine[0]=='#') return;
26136 for(i=nLine-1; i>=0 && (IsAlnum(zLine[i]) || zLine[i]=='_'); i--){}
26137 if( i==nLine-1 ) return;
26138 iStart = i+1;
26139 memcpy(zBuf, zLine, iStart);
26140 zSql = sqlite3_mprintf("SELECT DISTINCT candidate COLLATE nocase"
26141 " FROM completion(%Q,%Q) ORDER BY 1",
@@ -28328,10 +28371,11 @@
28371 sqlite3_recover_config(p, 789, (void*)zRecoveryDb); /* Debug use only */
28372 sqlite3_recover_config(p, SQLITE_RECOVER_LOST_AND_FOUND, (void*)zLAF);
28373 sqlite3_recover_config(p, SQLITE_RECOVER_ROWIDS, (void*)&bRowids);
28374 sqlite3_recover_config(p, SQLITE_RECOVER_FREELIST_CORRUPT,(void*)&bFreelist);
28375
28376 sqlite3_fprintf(pState->out, ".dbconfig defensive off\n");
28377 sqlite3_recover_run(p);
28378 if( sqlite3_recover_errcode(p)!=SQLITE_OK ){
28379 const char *zErr = sqlite3_recover_errmsg(p);
28380 int errCode = sqlite3_recover_errcode(p);
28381 sqlite3_fprintf(stderr,"sql error: %s (%d)\n", zErr, errCode);
@@ -32419,11 +32463,11 @@
32463 /*
32464 ** The CLI needs a working sqlite3_complete() to work properly. So error
32465 ** out of the build if compiling with SQLITE_OMIT_COMPLETE.
32466 */
32467 #ifdef SQLITE_OMIT_COMPLETE
32468 # error the CLI application is incompatable with SQLITE_OMIT_COMPLETE.
32469 #endif
32470
32471 /*
32472 ** Return true if zSql is a complete SQL statement. Return false if it
32473 ** ends in the middle of a string literal or C-style comment.
@@ -32598,11 +32642,11 @@
32642 UNUSED_PARAMETER(in);
32643 UNUSED_PARAMETER(isContinuation);
32644 if(!z || !*z){
32645 return 0;
32646 }
32647 while(*z && IsSpace(*z)) ++z;
32648 zBegin = z;
32649 for(; *z && '\n'!=*z; ++nZ, ++z){}
32650 if(nZ>0 && '\r'==zBegin[nZ-1]){
32651 --nZ;
32652 }
32653

Keyboard Shortcuts

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