Fossil SCM

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

drh 2024-10-17 16:10 trunk
Commit d0730da076b93045bdbd126a29e6f55c8f3f3caec72ea05e07340c39392715f7
+118 -54
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -350,11 +350,11 @@
350350
** rendering ASCII text in cases where NL-to-CRLF expansion would
351351
** not be correct.)
352352
**
353353
** If the SQLITE_U8TEXT_STDIO option is defined, then use O_U8TEXT
354354
** when appropriate when writing to stdout or stderr. Use O_BINARY
355
-** or O_TEXT (depending on things like the .mode and the .crnl setting
355
+** or O_TEXT (depending on things like the .mode and the .crlf setting
356356
** in the CLI, or other context clues in other applications) for all
357357
** other output channels.
358358
**
359359
** The default behavior, if neither of the above is defined is to
360360
** use O_U8TEXT when writing to the Windows console (or anything
@@ -14068,10 +14068,70 @@
1406814068
}
1406914069
1407014070
return rc;
1407114071
}
1407214072
14073
+/*
14074
+** This function tests if the schema of the main database of database handle
14075
+** db contains an object named zTab. Assuming no error occurs, output parameter
14076
+** (*pbContains) is set to true if zTab exists, or false if it does not.
14077
+**
14078
+** Or, if an error occurs, an SQLite error code is returned. The final value
14079
+** of (*pbContains) is undefined in this case.
14080
+*/
14081
+static int expertDbContainsObject(
14082
+ sqlite3 *db,
14083
+ const char *zTab,
14084
+ int *pbContains /* OUT: True if object exists */
14085
+){
14086
+ const char *zSql = "SELECT 1 FROM sqlite_schema WHERE name = ?";
14087
+ sqlite3_stmt *pSql = 0;
14088
+ int rc = SQLITE_OK;
14089
+ int ret = 0;
14090
+
14091
+ rc = sqlite3_prepare_v2(db, zSql, -1, &pSql, 0);
14092
+ if( rc==SQLITE_OK ){
14093
+ sqlite3_bind_text(pSql, 1, zTab, -1, SQLITE_STATIC);
14094
+ if( SQLITE_ROW==sqlite3_step(pSql) ){
14095
+ ret = 1;
14096
+ }
14097
+ rc = sqlite3_finalize(pSql);
14098
+ }
14099
+
14100
+ *pbContains = ret;
14101
+ return rc;
14102
+}
14103
+
14104
+/*
14105
+** Execute SQL command zSql using database handle db. If no error occurs,
14106
+** set (*pzErr) to NULL and return SQLITE_OK.
14107
+**
14108
+** If an error does occur, return an SQLite error code and set (*pzErr) to
14109
+** point to a buffer containing an English language error message. Except,
14110
+** if the error message begins with "no such module:", then ignore the
14111
+** error and return as if the SQL statement had succeeded.
14112
+**
14113
+** This is used to copy as much of the database schema as possible while
14114
+** ignoring any errors related to missing virtual table modules.
14115
+*/
14116
+static int expertSchemaSql(sqlite3 *db, const char *zSql, char **pzErr){
14117
+ int rc = SQLITE_OK;
14118
+ char *zErr = 0;
14119
+
14120
+ rc = sqlite3_exec(db, zSql, 0, 0, &zErr);
14121
+ if( rc!=SQLITE_OK && zErr ){
14122
+ int nErr = STRLEN(zErr);
14123
+ if( nErr>=15 && memcmp(zErr, "no such module:", 15)==0 ){
14124
+ sqlite3_free(zErr);
14125
+ rc = SQLITE_OK;
14126
+ zErr = 0;
14127
+ }
14128
+ }
14129
+
14130
+ *pzErr = zErr;
14131
+ return rc;
14132
+}
1407314133
1407414134
static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){
1407514135
int rc = idxRegisterVtab(p);
1407614136
sqlite3_stmt *pSchema = 0;
1407714137
@@ -14079,26 +14139,33 @@
1407914139
**
1408014140
** 1) Add an entry to the p->pTable list, and
1408114141
** 2) Create the equivalent virtual table in dbv.
1408214142
*/
1408314143
rc = idxPrepareStmt(p->db, &pSchema, pzErrmsg,
14084
- "SELECT type, name, sql, 1 FROM sqlite_schema "
14144
+ "SELECT type, name, sql, 1, sql LIKE 'create virtual%' "
14145
+ "FROM sqlite_schema "
1408514146
"WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%%' "
1408614147
" UNION ALL "
14087
- "SELECT type, name, sql, 2 FROM sqlite_schema "
14148
+ "SELECT type, name, sql, 2, 0 FROM sqlite_schema "
1408814149
"WHERE type = 'trigger'"
1408914150
" AND tbl_name IN(SELECT name FROM sqlite_schema WHERE type = 'view') "
14090
- "ORDER BY 4, 1"
14151
+ "ORDER BY 4, 5 DESC, 1"
1409114152
);
1409214153
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSchema) ){
1409314154
const char *zType = (const char*)sqlite3_column_text(pSchema, 0);
1409414155
const char *zName = (const char*)sqlite3_column_text(pSchema, 1);
1409514156
const char *zSql = (const char*)sqlite3_column_text(pSchema, 2);
14157
+ int bVirtual = sqlite3_column_int(pSchema, 4);
14158
+ int bExists = 0;
1409614159
1409714160
if( zType==0 || zName==0 ) continue;
14098
- if( zType[0]=='v' || zType[1]=='r' ){
14099
- if( zSql ) rc = sqlite3_exec(p->dbv, zSql, 0, 0, pzErrmsg);
14161
+ rc = expertDbContainsObject(p->dbv, zName, &bExists);
14162
+ if( rc || bExists ) continue;
14163
+
14164
+ if( zType[0]=='v' || zType[1]=='r' || bVirtual ){
14165
+ /* A view. Or a trigger on a view. */
14166
+ if( zSql ) rc = expertSchemaSql(p->dbv, zSql, pzErrmsg);
1410014167
}else{
1410114168
IdxTable *pTab;
1410214169
rc = idxGetTableInfo(p->db, zName, &pTab, pzErrmsg);
1410314170
if( rc==SQLITE_OK ){
1410414171
int i;
@@ -14633,16 +14700,22 @@
1463314700
1463414701
/* Copy the entire schema of database [db] into [dbm]. */
1463514702
if( rc==SQLITE_OK ){
1463614703
sqlite3_stmt *pSql = 0;
1463714704
rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg,
14638
- "SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'"
14639
- " AND sql NOT LIKE 'CREATE VIRTUAL %%' ORDER BY rowid"
14705
+ "SELECT sql, name "
14706
+ " FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'"
14707
+ " ORDER BY rowid"
1464014708
);
1464114709
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
1464214710
const char *zSql = (const char*)sqlite3_column_text(pSql, 0);
14643
- if( zSql ) rc = sqlite3_exec(pNew->dbm, zSql, 0, 0, pzErrmsg);
14711
+ const char *zName = (const char*)sqlite3_column_text(pSql, 1);
14712
+ int bExists = 0;
14713
+ rc = expertDbContainsObject(pNew->dbm, zName, &bExists);
14714
+ if( rc==SQLITE_OK && zSql && bExists==0 ){
14715
+ rc = expertSchemaSql(pNew->dbm, zSql, pzErrmsg);
14716
+ }
1464414717
}
1464514718
idxFinalize(&rc, pSql);
1464614719
}
1464714720
1464814721
/* Create the vtab schema */
@@ -19072,11 +19145,11 @@
1907219145
}while( strstr(z,zBuf)!=0 );
1907319146
return zBuf;
1907419147
}
1907519148
1907619149
/*
19077
-** Implementation of scalar SQL function "escape_crnl". The argument passed to
19150
+** Implementation of scalar SQL function "escape_crlf". The argument passed to
1907819151
** this function is the output of built-in function quote(). If the first
1907919152
** character of the input is "'", indicating that the value passed to quote()
1908019153
** was a text value, then this function searches the input for "\n" and "\r"
1908119154
** characters and adds a wrapper similar to the following:
1908219155
**
@@ -19083,11 +19156,11 @@
1908319156
** replace(replace(<input>, '\n', char(10), '\r', char(13));
1908419157
**
1908519158
** Or, if the first character of the input is not "'", then a copy of the input
1908619159
** is returned.
1908719160
*/
19088
-static void recoverEscapeCrnl(
19161
+static void recoverEscapeCrlf(
1908919162
sqlite3_context *context,
1909019163
int argc,
1909119164
sqlite3_value **argv
1909219165
){
1909319166
const char *zText = (const char*)sqlite3_value_text(argv[0]);
@@ -19298,11 +19371,11 @@
1929819371
void (*xFunc)(sqlite3_context*,int,sqlite3_value **);
1929919372
} aFunc[] = {
1930019373
{ "getpage", 1, recoverGetPage },
1930119374
{ "page_is_used", 1, recoverPageIsUsed },
1930219375
{ "read_i32", 2, recoverReadI32 },
19303
- { "escape_crnl", 1, recoverEscapeCrnl },
19376
+ { "escape_crlf", 1, recoverEscapeCrlf },
1930419377
};
1930519378
1930619379
const int flags = SQLITE_OPEN_URI|SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE;
1930719380
sqlite3 *db = 0; /* New database handle */
1930819381
int ii; /* For iterating through aFunc[] */
@@ -19651,11 +19724,11 @@
1965119724
assert( pTab->aCol[ii].iField>=0 && pTab->aCol[ii].iBind>=1 );
1965219725
zSql = recoverMPrintf(p, "%z%s%Q", zSql, zSep, pTab->aCol[ii].zCol);
1965319726
1965419727
if( bSql ){
1965519728
zBind = recoverMPrintf(p,
19656
- "%z%sescape_crnl(quote(?%d))", zBind, zSqlSep, pTab->aCol[ii].iBind
19729
+ "%z%sescape_crlf(quote(?%d))", zBind, zSqlSep, pTab->aCol[ii].iBind
1965719730
);
1965819731
zSqlSep = "||', '||";
1965919732
}else{
1966019733
zBind = recoverMPrintf(p, "%z%s?%d", zBind, zSep, pTab->aCol[ii].iBind);
1966119734
}
@@ -21268,11 +21341,11 @@
2126821341
u8 nEqpLevel; /* Depth of the EQP output graph */
2126921342
u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
2127021343
u8 bSafeMode; /* True to prohibit unsafe operations */
2127121344
u8 bSafeModePersist; /* The long-term value of bSafeMode */
2127221345
u8 eRestoreState; /* See comments above doAutoDetectRestore() */
21273
- u8 crnlMode; /* Do NL-to-CRLF translations when enabled (maybe) */
21346
+ u8 crlfMode; /* Do NL-to-CRLF translations when enabled (maybe) */
2127421347
ColModeOpts cmOpts; /* Option values affecting columnar mode output */
2127521348
unsigned statsOn; /* True to display memory stats before each finalize */
2127621349
unsigned mEqpLines; /* Mask of vertical lines in the EQP output graph */
2127721350
int inputNesting; /* Track nesting level of .read and other redirects */
2127821351
int outCount; /* Revert to stdout when reaching zero */
@@ -21449,11 +21522,11 @@
2144921522
#define SEP_Column "|"
2145021523
#define SEP_Row "\n"
2145121524
#define SEP_Tab "\t"
2145221525
#define SEP_Space " "
2145321526
#define SEP_Comma ","
21454
-#define SEP_CrLf "\n" /* Use ".crnl on" to get \r\n line endings */
21527
+#define SEP_CrLf "\r\n"
2145521528
#define SEP_Unit "\x1F"
2145621529
#define SEP_Record "\x1E"
2145721530
2145821531
/*
2145921532
** Limit input nesting via .read or any other input redirect.
@@ -21534,11 +21607,11 @@
2153421607
char *zTempFile = 0;
2153521608
sqlite3 *db;
2153621609
char *zCmd = 0;
2153721610
int bBin;
2153821611
int rc;
21539
- int hasCRNL = 0;
21612
+ int hasCRLF = 0;
2154021613
FILE *f = 0;
2154121614
sqlite3_int64 sz;
2154221615
sqlite3_int64 x;
2154321616
unsigned char *p = 0;
2154421617
@@ -21579,11 +21652,11 @@
2157921652
if( bBin ){
2158021653
x = fwrite(sqlite3_value_blob(argv[0]), 1, (size_t)sz, f);
2158121654
}else{
2158221655
const char *z = (const char*)sqlite3_value_text(argv[0]);
2158321656
/* Remember whether or not the value originally contained \r\n */
21584
- if( z && strstr(z,"\r\n")!=0 ) hasCRNL = 1;
21657
+ if( z && strstr(z,"\r\n")!=0 ) hasCRLF = 1;
2158521658
x = fwrite(sqlite3_value_text(argv[0]), 1, (size_t)sz, f);
2158621659
}
2158721660
fclose(f);
2158821661
f = 0;
2158921662
if( x!=sz ){
@@ -21624,11 +21697,11 @@
2162421697
}
2162521698
if( bBin ){
2162621699
sqlite3_result_blob64(context, p, sz, sqlite3_free);
2162721700
}else{
2162821701
sqlite3_int64 i, j;
21629
- if( hasCRNL ){
21702
+ if( hasCRLF ){
2163021703
/* If the original contains \r\n then do no conversions back to \n */
2163121704
}else{
2163221705
/* If the file did not originally contain \r\n then convert any new
2163321706
** \r\n back into \n */
2163421707
p[sz] = 0;
@@ -21669,17 +21742,19 @@
2166921742
}
2167021743
2167121744
/*
2167221745
** Set output mode to text or binary for Windows.
2167321746
*/
21674
-static void setCrnlMode(ShellState *p){
21747
+static void setCrlfMode(ShellState *p){
2167521748
#ifdef _WIN32
21676
- if( p->crnlMode ){
21749
+ if( p->crlfMode ){
2167721750
sqlite3_fsetmode(p->out, _O_TEXT);
2167821751
}else{
2167921752
sqlite3_fsetmode(p->out, _O_BINARY);
2168021753
}
21754
+#else
21755
+ UNUSED_PARAMETER(p);
2168121756
#endif
2168221757
}
2168321758
2168421759
/*
2168521760
** Output the given string as a hex-encoded blob (eg. X'1234' )
@@ -21758,11 +21833,11 @@
2175821833
}
2175921834
z++;
2176021835
}
2176121836
sqlite3_fputs("'", out);
2176221837
}
21763
- setCrnlMode(p);
21838
+ setCrlfMode(p);
2176421839
}
2176521840
2176621841
/*
2176721842
** Output the given string as a quoted string using SQL quoting conventions.
2176821843
** Additionallly , escape the "\n" and "\r" characters so that they do not
@@ -21826,11 +21901,11 @@
2182621901
}
2182721902
if( nNL ){
2182821903
sqlite3_fprintf(out, ",'%s',char(10))", zNL);
2182921904
}
2183021905
}
21831
- setCrnlMode(p);
21906
+ setCrlfMode(p);
2183221907
}
2183321908
2183421909
/*
2183521910
** Find earliest of chars within s specified in zAny.
2183621911
** With ns == ~0, is like strpbrk(s,zAny) and s must be 0-terminated.
@@ -22615,27 +22690,19 @@
2261522690
sqlite3_fsetmode(p->out, _O_BINARY);
2261622691
if( p->cnt++==0 && p->showHeader ){
2261722692
for(i=0; i<nArg; i++){
2261822693
output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1);
2261922694
}
22620
- if( p->crnlMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){
22621
- sqlite3_fputs("\r\n", p->out);
22622
- }else{
22623
- sqlite3_fputs(p->rowSeparator, p->out);
22624
- }
22695
+ sqlite3_fputs(p->rowSeparator, p->out);
2262522696
}
2262622697
if( nArg>0 ){
2262722698
for(i=0; i<nArg; i++){
2262822699
output_csv(p, azArg[i], i<nArg-1);
2262922700
}
22630
- if( p->crnlMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){
22631
- sqlite3_fputs("\r\n", p->out);
22632
- }else{
22633
- sqlite3_fputs(p->rowSeparator, p->out);
22634
- }
22701
+ sqlite3_fputs(p->rowSeparator, p->out);
2263522702
}
22636
- setCrnlMode(p);
22703
+ setCrlfMode(p);
2263722704
break;
2263822705
}
2263922706
case MODE_Insert: {
2264022707
if( azArg==0 ) break;
2264122708
sqlite3_fprintf(p->out, "INSERT INTO %s",p->zDestTable);
@@ -24589,11 +24656,11 @@
2458924656
if( zType==0 ) return 0;
2459024657
dataOnly = (p->shellFlgs & SHFLG_DumpDataOnly)!=0;
2459124658
noSys = (p->shellFlgs & SHFLG_DumpNoSys)!=0;
2459224659
2459324660
if( cli_strcmp(zTable, "sqlite_sequence")==0 && !noSys ){
24594
- if( !dataOnly ) sqlite3_fputs("DELETE FROM sqlite_sequence;\n", p->out);
24661
+ /* no-op */
2459524662
}else if( sqlite3_strglob("sqlite_stat?", zTable)==0 && !noSys ){
2459624663
if( !dataOnly ) sqlite3_fputs("ANALYZE sqlite_schema;\n", p->out);
2459724664
}else if( cli_strncmp(zTable, "sqlite_", 7)==0 ){
2459824665
return 0;
2459924666
}else if( dataOnly ){
@@ -24774,11 +24841,11 @@
2477424841
#ifndef SQLITE_SHELL_FIDDLE
2477524842
".check GLOB Fail if output since .testcase does not match",
2477624843
".clone NEWDB Clone data into NEWDB from the existing database",
2477724844
#endif
2477824845
".connection [close] [#] Open or close an auxiliary database connection",
24779
- ".crnl on|off Translate \\n to \\r\\n sometimes. Default OFF",
24846
+ ".crlf ?on|off? Whether or not to use \\r\\n line endings",
2478024847
".databases List names and files of attached databases",
2478124848
".dbconfig ?op? ?val? List or change sqlite3_db_config() options",
2478224849
#if SQLITE_SHELL_HAVE_RECOVER
2478324850
".dbinfo ?DB? Show status information about the database",
2478424851
#endif
@@ -26255,11 +26322,11 @@
2625526322
static void output_redir(ShellState *p, FILE *pfNew){
2625626323
if( p->out != stdout ){
2625726324
sqlite3_fputs("Output already redirected.\n", stderr);
2625826325
}else{
2625926326
p->out = pfNew;
26260
- setCrnlMode(p);
26327
+ setCrlfMode(p);
2626126328
if( p->mode==MODE_Www ){
2626226329
sqlite3_fputs(
2626326330
"<!DOCTYPE html>\n"
2626426331
"<HTML><BODY><PRE>\n",
2626526332
p->out
@@ -26311,11 +26378,11 @@
2631126378
}
2631226379
#endif /* !defined(SQLITE_NOHAVE_SYSTEM) */
2631326380
}
2631426381
p->outfile[0] = 0;
2631526382
p->out = stdout;
26316
- setCrnlMode(p);
26383
+ setCrlfMode(p);
2631726384
}
2631826385
#else
2631926386
# define output_redir(SS,pfO)
2632026387
# define output_reset(SS)
2632126388
#endif
@@ -28264,11 +28331,11 @@
2826428331
eputz("Usage: .bail on|off\n");
2826528332
rc = 1;
2826628333
}
2826728334
}else
2826828335
28269
- /* Undocumented. Legacy only. See "crnl" below */
28336
+ /* Undocumented. Legacy only. See "crlf" below */
2827028337
if( c=='b' && n>=3 && cli_strncmp(azArg[0], "binary", n)==0 ){
2827128338
eputz("The \".binary\" command is deprecated.\n");
2827228339
rc = 1;
2827328340
}else
2827428341
@@ -28392,18 +28459,22 @@
2839228459
eputz("Usage: .connection [close] [CONNECTION-NUMBER]\n");
2839328460
rc = 1;
2839428461
}
2839528462
}else
2839628463
28397
- if( c=='c' && n==4 && cli_strncmp(azArg[0], "crnl", n)==0 ){
28464
+ if( c=='c' && n==4
28465
+ && (cli_strncmp(azArg[0], "crlf", n)==0
28466
+ || cli_strncmp(azArg[0], "crnl",n)==0)
28467
+ ){
2839828468
if( nArg==2 ){
28399
- p->crnlMode = booleanValue(azArg[1]);
28400
- setCrnlMode(p);
28401
- }else{
28402
- sqlite3_fprintf(stderr, "crnl is currently %s\n",
28403
- p->crnlMode ? "ON" : "OFF");
28469
+#ifdef _WIN32
28470
+ p->crlfMode = booleanValue(azArg[1]);
28471
+#else
28472
+ p->crlfMode = 0;
28473
+#endif
2840428474
}
28475
+ sqlite3_fprintf(stderr, "crlf is %s\n", p->crlfMode ? "ON" : "OFF");
2840528476
}else
2840628477
2840728478
if( c=='d' && n>1 && cli_strncmp(azArg[0], "databases", n)==0 ){
2840828479
char **azName = 0;
2840928480
int nName = 0;
@@ -32419,10 +32490,13 @@
3241932490
*/
3242032491
static void main_init(ShellState *data) {
3242132492
memset(data, 0, sizeof(*data));
3242232493
data->normalMode = data->cMode = data->mode = MODE_List;
3242332494
data->autoExplain = 1;
32495
+#ifdef _WIN32
32496
+ data->crlfMode = 1;
32497
+#endif
3242432498
data->pAuxDb = &data->aAuxDb[0];
3242532499
memcpy(data->colSeparator,SEP_Column, 2);
3242632500
memcpy(data->rowSeparator,SEP_Row, 2);
3242732501
data->showHeader = 0;
3242832502
data->shellFlgs = SHFLG_Lookaside;
@@ -32432,20 +32506,10 @@
3243232506
#endif
3243332507
sqlite3_config(SQLITE_CONFIG_URI, 1);
3243432508
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
3243532509
sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
3243632510
sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> ");
32437
-
32438
- /* By default, come up in O_BINARY mode. That way, the default output is
32439
- ** the same for Windows and non-Windows systems. Use the ".crnl on"
32440
- ** command to change into O_TEXT mode to do automatic NL-to-CRLF
32441
- ** conversions on output for Windows.
32442
- **
32443
- ** End-of-line marks on CVS output is CRLF when in .crnl is on and
32444
- ** NL when .crnl is off.
32445
- */
32446
- data->crnlMode = 0;
3244732511
}
3244832512
3244932513
/*
3245032514
** Output text to the console in a font that attracts extra attention.
3245132515
*/
3245232516
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -350,11 +350,11 @@
350 ** rendering ASCII text in cases where NL-to-CRLF expansion would
351 ** not be correct.)
352 **
353 ** If the SQLITE_U8TEXT_STDIO option is defined, then use O_U8TEXT
354 ** when appropriate when writing to stdout or stderr. Use O_BINARY
355 ** or O_TEXT (depending on things like the .mode and the .crnl setting
356 ** in the CLI, or other context clues in other applications) for all
357 ** other output channels.
358 **
359 ** The default behavior, if neither of the above is defined is to
360 ** use O_U8TEXT when writing to the Windows console (or anything
@@ -14068,10 +14068,70 @@
14068 }
14069
14070 return rc;
14071 }
14072
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14073
14074 static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){
14075 int rc = idxRegisterVtab(p);
14076 sqlite3_stmt *pSchema = 0;
14077
@@ -14079,26 +14139,33 @@
14079 **
14080 ** 1) Add an entry to the p->pTable list, and
14081 ** 2) Create the equivalent virtual table in dbv.
14082 */
14083 rc = idxPrepareStmt(p->db, &pSchema, pzErrmsg,
14084 "SELECT type, name, sql, 1 FROM sqlite_schema "
 
14085 "WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%%' "
14086 " UNION ALL "
14087 "SELECT type, name, sql, 2 FROM sqlite_schema "
14088 "WHERE type = 'trigger'"
14089 " AND tbl_name IN(SELECT name FROM sqlite_schema WHERE type = 'view') "
14090 "ORDER BY 4, 1"
14091 );
14092 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSchema) ){
14093 const char *zType = (const char*)sqlite3_column_text(pSchema, 0);
14094 const char *zName = (const char*)sqlite3_column_text(pSchema, 1);
14095 const char *zSql = (const char*)sqlite3_column_text(pSchema, 2);
 
 
14096
14097 if( zType==0 || zName==0 ) continue;
14098 if( zType[0]=='v' || zType[1]=='r' ){
14099 if( zSql ) rc = sqlite3_exec(p->dbv, zSql, 0, 0, pzErrmsg);
 
 
 
 
14100 }else{
14101 IdxTable *pTab;
14102 rc = idxGetTableInfo(p->db, zName, &pTab, pzErrmsg);
14103 if( rc==SQLITE_OK ){
14104 int i;
@@ -14633,16 +14700,22 @@
14633
14634 /* Copy the entire schema of database [db] into [dbm]. */
14635 if( rc==SQLITE_OK ){
14636 sqlite3_stmt *pSql = 0;
14637 rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg,
14638 "SELECT sql FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'"
14639 " AND sql NOT LIKE 'CREATE VIRTUAL %%' ORDER BY rowid"
 
14640 );
14641 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
14642 const char *zSql = (const char*)sqlite3_column_text(pSql, 0);
14643 if( zSql ) rc = sqlite3_exec(pNew->dbm, zSql, 0, 0, pzErrmsg);
 
 
 
 
 
14644 }
14645 idxFinalize(&rc, pSql);
14646 }
14647
14648 /* Create the vtab schema */
@@ -19072,11 +19145,11 @@
19072 }while( strstr(z,zBuf)!=0 );
19073 return zBuf;
19074 }
19075
19076 /*
19077 ** Implementation of scalar SQL function "escape_crnl". The argument passed to
19078 ** this function is the output of built-in function quote(). If the first
19079 ** character of the input is "'", indicating that the value passed to quote()
19080 ** was a text value, then this function searches the input for "\n" and "\r"
19081 ** characters and adds a wrapper similar to the following:
19082 **
@@ -19083,11 +19156,11 @@
19083 ** replace(replace(<input>, '\n', char(10), '\r', char(13));
19084 **
19085 ** Or, if the first character of the input is not "'", then a copy of the input
19086 ** is returned.
19087 */
19088 static void recoverEscapeCrnl(
19089 sqlite3_context *context,
19090 int argc,
19091 sqlite3_value **argv
19092 ){
19093 const char *zText = (const char*)sqlite3_value_text(argv[0]);
@@ -19298,11 +19371,11 @@
19298 void (*xFunc)(sqlite3_context*,int,sqlite3_value **);
19299 } aFunc[] = {
19300 { "getpage", 1, recoverGetPage },
19301 { "page_is_used", 1, recoverPageIsUsed },
19302 { "read_i32", 2, recoverReadI32 },
19303 { "escape_crnl", 1, recoverEscapeCrnl },
19304 };
19305
19306 const int flags = SQLITE_OPEN_URI|SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE;
19307 sqlite3 *db = 0; /* New database handle */
19308 int ii; /* For iterating through aFunc[] */
@@ -19651,11 +19724,11 @@
19651 assert( pTab->aCol[ii].iField>=0 && pTab->aCol[ii].iBind>=1 );
19652 zSql = recoverMPrintf(p, "%z%s%Q", zSql, zSep, pTab->aCol[ii].zCol);
19653
19654 if( bSql ){
19655 zBind = recoverMPrintf(p,
19656 "%z%sescape_crnl(quote(?%d))", zBind, zSqlSep, pTab->aCol[ii].iBind
19657 );
19658 zSqlSep = "||', '||";
19659 }else{
19660 zBind = recoverMPrintf(p, "%z%s?%d", zBind, zSep, pTab->aCol[ii].iBind);
19661 }
@@ -21268,11 +21341,11 @@
21268 u8 nEqpLevel; /* Depth of the EQP output graph */
21269 u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
21270 u8 bSafeMode; /* True to prohibit unsafe operations */
21271 u8 bSafeModePersist; /* The long-term value of bSafeMode */
21272 u8 eRestoreState; /* See comments above doAutoDetectRestore() */
21273 u8 crnlMode; /* Do NL-to-CRLF translations when enabled (maybe) */
21274 ColModeOpts cmOpts; /* Option values affecting columnar mode output */
21275 unsigned statsOn; /* True to display memory stats before each finalize */
21276 unsigned mEqpLines; /* Mask of vertical lines in the EQP output graph */
21277 int inputNesting; /* Track nesting level of .read and other redirects */
21278 int outCount; /* Revert to stdout when reaching zero */
@@ -21449,11 +21522,11 @@
21449 #define SEP_Column "|"
21450 #define SEP_Row "\n"
21451 #define SEP_Tab "\t"
21452 #define SEP_Space " "
21453 #define SEP_Comma ","
21454 #define SEP_CrLf "\n" /* Use ".crnl on" to get \r\n line endings */
21455 #define SEP_Unit "\x1F"
21456 #define SEP_Record "\x1E"
21457
21458 /*
21459 ** Limit input nesting via .read or any other input redirect.
@@ -21534,11 +21607,11 @@
21534 char *zTempFile = 0;
21535 sqlite3 *db;
21536 char *zCmd = 0;
21537 int bBin;
21538 int rc;
21539 int hasCRNL = 0;
21540 FILE *f = 0;
21541 sqlite3_int64 sz;
21542 sqlite3_int64 x;
21543 unsigned char *p = 0;
21544
@@ -21579,11 +21652,11 @@
21579 if( bBin ){
21580 x = fwrite(sqlite3_value_blob(argv[0]), 1, (size_t)sz, f);
21581 }else{
21582 const char *z = (const char*)sqlite3_value_text(argv[0]);
21583 /* Remember whether or not the value originally contained \r\n */
21584 if( z && strstr(z,"\r\n")!=0 ) hasCRNL = 1;
21585 x = fwrite(sqlite3_value_text(argv[0]), 1, (size_t)sz, f);
21586 }
21587 fclose(f);
21588 f = 0;
21589 if( x!=sz ){
@@ -21624,11 +21697,11 @@
21624 }
21625 if( bBin ){
21626 sqlite3_result_blob64(context, p, sz, sqlite3_free);
21627 }else{
21628 sqlite3_int64 i, j;
21629 if( hasCRNL ){
21630 /* If the original contains \r\n then do no conversions back to \n */
21631 }else{
21632 /* If the file did not originally contain \r\n then convert any new
21633 ** \r\n back into \n */
21634 p[sz] = 0;
@@ -21669,17 +21742,19 @@
21669 }
21670
21671 /*
21672 ** Set output mode to text or binary for Windows.
21673 */
21674 static void setCrnlMode(ShellState *p){
21675 #ifdef _WIN32
21676 if( p->crnlMode ){
21677 sqlite3_fsetmode(p->out, _O_TEXT);
21678 }else{
21679 sqlite3_fsetmode(p->out, _O_BINARY);
21680 }
 
 
21681 #endif
21682 }
21683
21684 /*
21685 ** Output the given string as a hex-encoded blob (eg. X'1234' )
@@ -21758,11 +21833,11 @@
21758 }
21759 z++;
21760 }
21761 sqlite3_fputs("'", out);
21762 }
21763 setCrnlMode(p);
21764 }
21765
21766 /*
21767 ** Output the given string as a quoted string using SQL quoting conventions.
21768 ** Additionallly , escape the "\n" and "\r" characters so that they do not
@@ -21826,11 +21901,11 @@
21826 }
21827 if( nNL ){
21828 sqlite3_fprintf(out, ",'%s',char(10))", zNL);
21829 }
21830 }
21831 setCrnlMode(p);
21832 }
21833
21834 /*
21835 ** Find earliest of chars within s specified in zAny.
21836 ** With ns == ~0, is like strpbrk(s,zAny) and s must be 0-terminated.
@@ -22615,27 +22690,19 @@
22615 sqlite3_fsetmode(p->out, _O_BINARY);
22616 if( p->cnt++==0 && p->showHeader ){
22617 for(i=0; i<nArg; i++){
22618 output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1);
22619 }
22620 if( p->crnlMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){
22621 sqlite3_fputs("\r\n", p->out);
22622 }else{
22623 sqlite3_fputs(p->rowSeparator, p->out);
22624 }
22625 }
22626 if( nArg>0 ){
22627 for(i=0; i<nArg; i++){
22628 output_csv(p, azArg[i], i<nArg-1);
22629 }
22630 if( p->crnlMode && cli_strcmp(p->rowSeparator,SEP_CrLf)==0 ){
22631 sqlite3_fputs("\r\n", p->out);
22632 }else{
22633 sqlite3_fputs(p->rowSeparator, p->out);
22634 }
22635 }
22636 setCrnlMode(p);
22637 break;
22638 }
22639 case MODE_Insert: {
22640 if( azArg==0 ) break;
22641 sqlite3_fprintf(p->out, "INSERT INTO %s",p->zDestTable);
@@ -24589,11 +24656,11 @@
24589 if( zType==0 ) return 0;
24590 dataOnly = (p->shellFlgs & SHFLG_DumpDataOnly)!=0;
24591 noSys = (p->shellFlgs & SHFLG_DumpNoSys)!=0;
24592
24593 if( cli_strcmp(zTable, "sqlite_sequence")==0 && !noSys ){
24594 if( !dataOnly ) sqlite3_fputs("DELETE FROM sqlite_sequence;\n", p->out);
24595 }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 && !noSys ){
24596 if( !dataOnly ) sqlite3_fputs("ANALYZE sqlite_schema;\n", p->out);
24597 }else if( cli_strncmp(zTable, "sqlite_", 7)==0 ){
24598 return 0;
24599 }else if( dataOnly ){
@@ -24774,11 +24841,11 @@
24774 #ifndef SQLITE_SHELL_FIDDLE
24775 ".check GLOB Fail if output since .testcase does not match",
24776 ".clone NEWDB Clone data into NEWDB from the existing database",
24777 #endif
24778 ".connection [close] [#] Open or close an auxiliary database connection",
24779 ".crnl on|off Translate \\n to \\r\\n sometimes. Default OFF",
24780 ".databases List names and files of attached databases",
24781 ".dbconfig ?op? ?val? List or change sqlite3_db_config() options",
24782 #if SQLITE_SHELL_HAVE_RECOVER
24783 ".dbinfo ?DB? Show status information about the database",
24784 #endif
@@ -26255,11 +26322,11 @@
26255 static void output_redir(ShellState *p, FILE *pfNew){
26256 if( p->out != stdout ){
26257 sqlite3_fputs("Output already redirected.\n", stderr);
26258 }else{
26259 p->out = pfNew;
26260 setCrnlMode(p);
26261 if( p->mode==MODE_Www ){
26262 sqlite3_fputs(
26263 "<!DOCTYPE html>\n"
26264 "<HTML><BODY><PRE>\n",
26265 p->out
@@ -26311,11 +26378,11 @@
26311 }
26312 #endif /* !defined(SQLITE_NOHAVE_SYSTEM) */
26313 }
26314 p->outfile[0] = 0;
26315 p->out = stdout;
26316 setCrnlMode(p);
26317 }
26318 #else
26319 # define output_redir(SS,pfO)
26320 # define output_reset(SS)
26321 #endif
@@ -28264,11 +28331,11 @@
28264 eputz("Usage: .bail on|off\n");
28265 rc = 1;
28266 }
28267 }else
28268
28269 /* Undocumented. Legacy only. See "crnl" below */
28270 if( c=='b' && n>=3 && cli_strncmp(azArg[0], "binary", n)==0 ){
28271 eputz("The \".binary\" command is deprecated.\n");
28272 rc = 1;
28273 }else
28274
@@ -28392,18 +28459,22 @@
28392 eputz("Usage: .connection [close] [CONNECTION-NUMBER]\n");
28393 rc = 1;
28394 }
28395 }else
28396
28397 if( c=='c' && n==4 && cli_strncmp(azArg[0], "crnl", n)==0 ){
 
 
 
28398 if( nArg==2 ){
28399 p->crnlMode = booleanValue(azArg[1]);
28400 setCrnlMode(p);
28401 }else{
28402 sqlite3_fprintf(stderr, "crnl is currently %s\n",
28403 p->crnlMode ? "ON" : "OFF");
28404 }
 
28405 }else
28406
28407 if( c=='d' && n>1 && cli_strncmp(azArg[0], "databases", n)==0 ){
28408 char **azName = 0;
28409 int nName = 0;
@@ -32419,10 +32490,13 @@
32419 */
32420 static void main_init(ShellState *data) {
32421 memset(data, 0, sizeof(*data));
32422 data->normalMode = data->cMode = data->mode = MODE_List;
32423 data->autoExplain = 1;
 
 
 
32424 data->pAuxDb = &data->aAuxDb[0];
32425 memcpy(data->colSeparator,SEP_Column, 2);
32426 memcpy(data->rowSeparator,SEP_Row, 2);
32427 data->showHeader = 0;
32428 data->shellFlgs = SHFLG_Lookaside;
@@ -32432,20 +32506,10 @@
32432 #endif
32433 sqlite3_config(SQLITE_CONFIG_URI, 1);
32434 sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
32435 sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
32436 sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> ");
32437
32438 /* By default, come up in O_BINARY mode. That way, the default output is
32439 ** the same for Windows and non-Windows systems. Use the ".crnl on"
32440 ** command to change into O_TEXT mode to do automatic NL-to-CRLF
32441 ** conversions on output for Windows.
32442 **
32443 ** End-of-line marks on CVS output is CRLF when in .crnl is on and
32444 ** NL when .crnl is off.
32445 */
32446 data->crnlMode = 0;
32447 }
32448
32449 /*
32450 ** Output text to the console in a font that attracts extra attention.
32451 */
32452
--- extsrc/shell.c
+++ extsrc/shell.c
@@ -350,11 +350,11 @@
350 ** rendering ASCII text in cases where NL-to-CRLF expansion would
351 ** not be correct.)
352 **
353 ** If the SQLITE_U8TEXT_STDIO option is defined, then use O_U8TEXT
354 ** when appropriate when writing to stdout or stderr. Use O_BINARY
355 ** or O_TEXT (depending on things like the .mode and the .crlf setting
356 ** in the CLI, or other context clues in other applications) for all
357 ** other output channels.
358 **
359 ** The default behavior, if neither of the above is defined is to
360 ** use O_U8TEXT when writing to the Windows console (or anything
@@ -14068,10 +14068,70 @@
14068 }
14069
14070 return rc;
14071 }
14072
14073 /*
14074 ** This function tests if the schema of the main database of database handle
14075 ** db contains an object named zTab. Assuming no error occurs, output parameter
14076 ** (*pbContains) is set to true if zTab exists, or false if it does not.
14077 **
14078 ** Or, if an error occurs, an SQLite error code is returned. The final value
14079 ** of (*pbContains) is undefined in this case.
14080 */
14081 static int expertDbContainsObject(
14082 sqlite3 *db,
14083 const char *zTab,
14084 int *pbContains /* OUT: True if object exists */
14085 ){
14086 const char *zSql = "SELECT 1 FROM sqlite_schema WHERE name = ?";
14087 sqlite3_stmt *pSql = 0;
14088 int rc = SQLITE_OK;
14089 int ret = 0;
14090
14091 rc = sqlite3_prepare_v2(db, zSql, -1, &pSql, 0);
14092 if( rc==SQLITE_OK ){
14093 sqlite3_bind_text(pSql, 1, zTab, -1, SQLITE_STATIC);
14094 if( SQLITE_ROW==sqlite3_step(pSql) ){
14095 ret = 1;
14096 }
14097 rc = sqlite3_finalize(pSql);
14098 }
14099
14100 *pbContains = ret;
14101 return rc;
14102 }
14103
14104 /*
14105 ** Execute SQL command zSql using database handle db. If no error occurs,
14106 ** set (*pzErr) to NULL and return SQLITE_OK.
14107 **
14108 ** If an error does occur, return an SQLite error code and set (*pzErr) to
14109 ** point to a buffer containing an English language error message. Except,
14110 ** if the error message begins with "no such module:", then ignore the
14111 ** error and return as if the SQL statement had succeeded.
14112 **
14113 ** This is used to copy as much of the database schema as possible while
14114 ** ignoring any errors related to missing virtual table modules.
14115 */
14116 static int expertSchemaSql(sqlite3 *db, const char *zSql, char **pzErr){
14117 int rc = SQLITE_OK;
14118 char *zErr = 0;
14119
14120 rc = sqlite3_exec(db, zSql, 0, 0, &zErr);
14121 if( rc!=SQLITE_OK && zErr ){
14122 int nErr = STRLEN(zErr);
14123 if( nErr>=15 && memcmp(zErr, "no such module:", 15)==0 ){
14124 sqlite3_free(zErr);
14125 rc = SQLITE_OK;
14126 zErr = 0;
14127 }
14128 }
14129
14130 *pzErr = zErr;
14131 return rc;
14132 }
14133
14134 static int idxCreateVtabSchema(sqlite3expert *p, char **pzErrmsg){
14135 int rc = idxRegisterVtab(p);
14136 sqlite3_stmt *pSchema = 0;
14137
@@ -14079,26 +14139,33 @@
14139 **
14140 ** 1) Add an entry to the p->pTable list, and
14141 ** 2) Create the equivalent virtual table in dbv.
14142 */
14143 rc = idxPrepareStmt(p->db, &pSchema, pzErrmsg,
14144 "SELECT type, name, sql, 1, sql LIKE 'create virtual%' "
14145 "FROM sqlite_schema "
14146 "WHERE type IN ('table','view') AND name NOT LIKE 'sqlite_%%' "
14147 " UNION ALL "
14148 "SELECT type, name, sql, 2, 0 FROM sqlite_schema "
14149 "WHERE type = 'trigger'"
14150 " AND tbl_name IN(SELECT name FROM sqlite_schema WHERE type = 'view') "
14151 "ORDER BY 4, 5 DESC, 1"
14152 );
14153 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSchema) ){
14154 const char *zType = (const char*)sqlite3_column_text(pSchema, 0);
14155 const char *zName = (const char*)sqlite3_column_text(pSchema, 1);
14156 const char *zSql = (const char*)sqlite3_column_text(pSchema, 2);
14157 int bVirtual = sqlite3_column_int(pSchema, 4);
14158 int bExists = 0;
14159
14160 if( zType==0 || zName==0 ) continue;
14161 rc = expertDbContainsObject(p->dbv, zName, &bExists);
14162 if( rc || bExists ) continue;
14163
14164 if( zType[0]=='v' || zType[1]=='r' || bVirtual ){
14165 /* A view. Or a trigger on a view. */
14166 if( zSql ) rc = expertSchemaSql(p->dbv, zSql, pzErrmsg);
14167 }else{
14168 IdxTable *pTab;
14169 rc = idxGetTableInfo(p->db, zName, &pTab, pzErrmsg);
14170 if( rc==SQLITE_OK ){
14171 int i;
@@ -14633,16 +14700,22 @@
14700
14701 /* Copy the entire schema of database [db] into [dbm]. */
14702 if( rc==SQLITE_OK ){
14703 sqlite3_stmt *pSql = 0;
14704 rc = idxPrintfPrepareStmt(pNew->db, &pSql, pzErrmsg,
14705 "SELECT sql, name "
14706 " FROM sqlite_schema WHERE name NOT LIKE 'sqlite_%%'"
14707 " ORDER BY rowid"
14708 );
14709 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pSql) ){
14710 const char *zSql = (const char*)sqlite3_column_text(pSql, 0);
14711 const char *zName = (const char*)sqlite3_column_text(pSql, 1);
14712 int bExists = 0;
14713 rc = expertDbContainsObject(pNew->dbm, zName, &bExists);
14714 if( rc==SQLITE_OK && zSql && bExists==0 ){
14715 rc = expertSchemaSql(pNew->dbm, zSql, pzErrmsg);
14716 }
14717 }
14718 idxFinalize(&rc, pSql);
14719 }
14720
14721 /* Create the vtab schema */
@@ -19072,11 +19145,11 @@
19145 }while( strstr(z,zBuf)!=0 );
19146 return zBuf;
19147 }
19148
19149 /*
19150 ** Implementation of scalar SQL function "escape_crlf". The argument passed to
19151 ** this function is the output of built-in function quote(). If the first
19152 ** character of the input is "'", indicating that the value passed to quote()
19153 ** was a text value, then this function searches the input for "\n" and "\r"
19154 ** characters and adds a wrapper similar to the following:
19155 **
@@ -19083,11 +19156,11 @@
19156 ** replace(replace(<input>, '\n', char(10), '\r', char(13));
19157 **
19158 ** Or, if the first character of the input is not "'", then a copy of the input
19159 ** is returned.
19160 */
19161 static void recoverEscapeCrlf(
19162 sqlite3_context *context,
19163 int argc,
19164 sqlite3_value **argv
19165 ){
19166 const char *zText = (const char*)sqlite3_value_text(argv[0]);
@@ -19298,11 +19371,11 @@
19371 void (*xFunc)(sqlite3_context*,int,sqlite3_value **);
19372 } aFunc[] = {
19373 { "getpage", 1, recoverGetPage },
19374 { "page_is_used", 1, recoverPageIsUsed },
19375 { "read_i32", 2, recoverReadI32 },
19376 { "escape_crlf", 1, recoverEscapeCrlf },
19377 };
19378
19379 const int flags = SQLITE_OPEN_URI|SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE;
19380 sqlite3 *db = 0; /* New database handle */
19381 int ii; /* For iterating through aFunc[] */
@@ -19651,11 +19724,11 @@
19724 assert( pTab->aCol[ii].iField>=0 && pTab->aCol[ii].iBind>=1 );
19725 zSql = recoverMPrintf(p, "%z%s%Q", zSql, zSep, pTab->aCol[ii].zCol);
19726
19727 if( bSql ){
19728 zBind = recoverMPrintf(p,
19729 "%z%sescape_crlf(quote(?%d))", zBind, zSqlSep, pTab->aCol[ii].iBind
19730 );
19731 zSqlSep = "||', '||";
19732 }else{
19733 zBind = recoverMPrintf(p, "%z%s?%d", zBind, zSep, pTab->aCol[ii].iBind);
19734 }
@@ -21268,11 +21341,11 @@
21341 u8 nEqpLevel; /* Depth of the EQP output graph */
21342 u8 eTraceType; /* SHELL_TRACE_* value for type of trace */
21343 u8 bSafeMode; /* True to prohibit unsafe operations */
21344 u8 bSafeModePersist; /* The long-term value of bSafeMode */
21345 u8 eRestoreState; /* See comments above doAutoDetectRestore() */
21346 u8 crlfMode; /* Do NL-to-CRLF translations when enabled (maybe) */
21347 ColModeOpts cmOpts; /* Option values affecting columnar mode output */
21348 unsigned statsOn; /* True to display memory stats before each finalize */
21349 unsigned mEqpLines; /* Mask of vertical lines in the EQP output graph */
21350 int inputNesting; /* Track nesting level of .read and other redirects */
21351 int outCount; /* Revert to stdout when reaching zero */
@@ -21449,11 +21522,11 @@
21522 #define SEP_Column "|"
21523 #define SEP_Row "\n"
21524 #define SEP_Tab "\t"
21525 #define SEP_Space " "
21526 #define SEP_Comma ","
21527 #define SEP_CrLf "\r\n"
21528 #define SEP_Unit "\x1F"
21529 #define SEP_Record "\x1E"
21530
21531 /*
21532 ** Limit input nesting via .read or any other input redirect.
@@ -21534,11 +21607,11 @@
21607 char *zTempFile = 0;
21608 sqlite3 *db;
21609 char *zCmd = 0;
21610 int bBin;
21611 int rc;
21612 int hasCRLF = 0;
21613 FILE *f = 0;
21614 sqlite3_int64 sz;
21615 sqlite3_int64 x;
21616 unsigned char *p = 0;
21617
@@ -21579,11 +21652,11 @@
21652 if( bBin ){
21653 x = fwrite(sqlite3_value_blob(argv[0]), 1, (size_t)sz, f);
21654 }else{
21655 const char *z = (const char*)sqlite3_value_text(argv[0]);
21656 /* Remember whether or not the value originally contained \r\n */
21657 if( z && strstr(z,"\r\n")!=0 ) hasCRLF = 1;
21658 x = fwrite(sqlite3_value_text(argv[0]), 1, (size_t)sz, f);
21659 }
21660 fclose(f);
21661 f = 0;
21662 if( x!=sz ){
@@ -21624,11 +21697,11 @@
21697 }
21698 if( bBin ){
21699 sqlite3_result_blob64(context, p, sz, sqlite3_free);
21700 }else{
21701 sqlite3_int64 i, j;
21702 if( hasCRLF ){
21703 /* If the original contains \r\n then do no conversions back to \n */
21704 }else{
21705 /* If the file did not originally contain \r\n then convert any new
21706 ** \r\n back into \n */
21707 p[sz] = 0;
@@ -21669,17 +21742,19 @@
21742 }
21743
21744 /*
21745 ** Set output mode to text or binary for Windows.
21746 */
21747 static void setCrlfMode(ShellState *p){
21748 #ifdef _WIN32
21749 if( p->crlfMode ){
21750 sqlite3_fsetmode(p->out, _O_TEXT);
21751 }else{
21752 sqlite3_fsetmode(p->out, _O_BINARY);
21753 }
21754 #else
21755 UNUSED_PARAMETER(p);
21756 #endif
21757 }
21758
21759 /*
21760 ** Output the given string as a hex-encoded blob (eg. X'1234' )
@@ -21758,11 +21833,11 @@
21833 }
21834 z++;
21835 }
21836 sqlite3_fputs("'", out);
21837 }
21838 setCrlfMode(p);
21839 }
21840
21841 /*
21842 ** Output the given string as a quoted string using SQL quoting conventions.
21843 ** Additionallly , escape the "\n" and "\r" characters so that they do not
@@ -21826,11 +21901,11 @@
21901 }
21902 if( nNL ){
21903 sqlite3_fprintf(out, ",'%s',char(10))", zNL);
21904 }
21905 }
21906 setCrlfMode(p);
21907 }
21908
21909 /*
21910 ** Find earliest of chars within s specified in zAny.
21911 ** With ns == ~0, is like strpbrk(s,zAny) and s must be 0-terminated.
@@ -22615,27 +22690,19 @@
22690 sqlite3_fsetmode(p->out, _O_BINARY);
22691 if( p->cnt++==0 && p->showHeader ){
22692 for(i=0; i<nArg; i++){
22693 output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1);
22694 }
22695 sqlite3_fputs(p->rowSeparator, p->out);
 
 
 
 
22696 }
22697 if( nArg>0 ){
22698 for(i=0; i<nArg; i++){
22699 output_csv(p, azArg[i], i<nArg-1);
22700 }
22701 sqlite3_fputs(p->rowSeparator, p->out);
 
 
 
 
22702 }
22703 setCrlfMode(p);
22704 break;
22705 }
22706 case MODE_Insert: {
22707 if( azArg==0 ) break;
22708 sqlite3_fprintf(p->out, "INSERT INTO %s",p->zDestTable);
@@ -24589,11 +24656,11 @@
24656 if( zType==0 ) return 0;
24657 dataOnly = (p->shellFlgs & SHFLG_DumpDataOnly)!=0;
24658 noSys = (p->shellFlgs & SHFLG_DumpNoSys)!=0;
24659
24660 if( cli_strcmp(zTable, "sqlite_sequence")==0 && !noSys ){
24661 /* no-op */
24662 }else if( sqlite3_strglob("sqlite_stat?", zTable)==0 && !noSys ){
24663 if( !dataOnly ) sqlite3_fputs("ANALYZE sqlite_schema;\n", p->out);
24664 }else if( cli_strncmp(zTable, "sqlite_", 7)==0 ){
24665 return 0;
24666 }else if( dataOnly ){
@@ -24774,11 +24841,11 @@
24841 #ifndef SQLITE_SHELL_FIDDLE
24842 ".check GLOB Fail if output since .testcase does not match",
24843 ".clone NEWDB Clone data into NEWDB from the existing database",
24844 #endif
24845 ".connection [close] [#] Open or close an auxiliary database connection",
24846 ".crlf ?on|off? Whether or not to use \\r\\n line endings",
24847 ".databases List names and files of attached databases",
24848 ".dbconfig ?op? ?val? List or change sqlite3_db_config() options",
24849 #if SQLITE_SHELL_HAVE_RECOVER
24850 ".dbinfo ?DB? Show status information about the database",
24851 #endif
@@ -26255,11 +26322,11 @@
26322 static void output_redir(ShellState *p, FILE *pfNew){
26323 if( p->out != stdout ){
26324 sqlite3_fputs("Output already redirected.\n", stderr);
26325 }else{
26326 p->out = pfNew;
26327 setCrlfMode(p);
26328 if( p->mode==MODE_Www ){
26329 sqlite3_fputs(
26330 "<!DOCTYPE html>\n"
26331 "<HTML><BODY><PRE>\n",
26332 p->out
@@ -26311,11 +26378,11 @@
26378 }
26379 #endif /* !defined(SQLITE_NOHAVE_SYSTEM) */
26380 }
26381 p->outfile[0] = 0;
26382 p->out = stdout;
26383 setCrlfMode(p);
26384 }
26385 #else
26386 # define output_redir(SS,pfO)
26387 # define output_reset(SS)
26388 #endif
@@ -28264,11 +28331,11 @@
28331 eputz("Usage: .bail on|off\n");
28332 rc = 1;
28333 }
28334 }else
28335
28336 /* Undocumented. Legacy only. See "crlf" below */
28337 if( c=='b' && n>=3 && cli_strncmp(azArg[0], "binary", n)==0 ){
28338 eputz("The \".binary\" command is deprecated.\n");
28339 rc = 1;
28340 }else
28341
@@ -28392,18 +28459,22 @@
28459 eputz("Usage: .connection [close] [CONNECTION-NUMBER]\n");
28460 rc = 1;
28461 }
28462 }else
28463
28464 if( c=='c' && n==4
28465 && (cli_strncmp(azArg[0], "crlf", n)==0
28466 || cli_strncmp(azArg[0], "crnl",n)==0)
28467 ){
28468 if( nArg==2 ){
28469 #ifdef _WIN32
28470 p->crlfMode = booleanValue(azArg[1]);
28471 #else
28472 p->crlfMode = 0;
28473 #endif
28474 }
28475 sqlite3_fprintf(stderr, "crlf is %s\n", p->crlfMode ? "ON" : "OFF");
28476 }else
28477
28478 if( c=='d' && n>1 && cli_strncmp(azArg[0], "databases", n)==0 ){
28479 char **azName = 0;
28480 int nName = 0;
@@ -32419,10 +32490,13 @@
32490 */
32491 static void main_init(ShellState *data) {
32492 memset(data, 0, sizeof(*data));
32493 data->normalMode = data->cMode = data->mode = MODE_List;
32494 data->autoExplain = 1;
32495 #ifdef _WIN32
32496 data->crlfMode = 1;
32497 #endif
32498 data->pAuxDb = &data->aAuxDb[0];
32499 memcpy(data->colSeparator,SEP_Column, 2);
32500 memcpy(data->rowSeparator,SEP_Row, 2);
32501 data->showHeader = 0;
32502 data->shellFlgs = SHFLG_Lookaside;
@@ -32432,20 +32506,10 @@
32506 #endif
32507 sqlite3_config(SQLITE_CONFIG_URI, 1);
32508 sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
32509 sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
32510 sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> ");
 
 
 
 
 
 
 
 
 
 
32511 }
32512
32513 /*
32514 ** Output text to the console in a font that attracts extra attention.
32515 */
32516
+20 -6
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -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
-** 2db24c5364808008fa503f37ca8ccf5d135e.
21
+** b7814350381a2929e9fa6444867a80437291.
2222
*/
2323
#define SQLITE_CORE 1
2424
#define SQLITE_AMALGAMATION 1
2525
#ifndef SQLITE_PRIVATE
2626
# define SQLITE_PRIVATE static
@@ -462,11 +462,11 @@
462462
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
463463
** [sqlite_version()] and [sqlite_source_id()].
464464
*/
465465
#define SQLITE_VERSION "3.47.0"
466466
#define SQLITE_VERSION_NUMBER 3047000
467
-#define SQLITE_SOURCE_ID "2024-10-11 23:31:37 2db24c5364808008fa503f37ca8ccf5d135e8f6bfac2efb29e509e26f7190470"
467
+#define SQLITE_SOURCE_ID "2024-10-17 13:29:49 b7814350381a2929e9fa6444867a80437291b8bbe59479d4525350b2719bc72c"
468468
469469
/*
470470
** CAPI3REF: Run-Time Library Version Numbers
471471
** KEYWORDS: sqlite3_version sqlite3_sourceid
472472
**
@@ -4546,11 +4546,11 @@
45464546
** If the caller knows that the supplied string is nul-terminated, then
45474547
** there is a small performance advantage to passing an nByte parameter that
45484548
** is the number of bytes in the input string <i>including</i>
45494549
** the nul-terminator.
45504550
** Note that nByte measure the length of the input in bytes, not
4551
-** characters, even for the UTF-16 inferfaces.
4551
+** characters, even for the UTF-16 interfaces.
45524552
**
45534553
** ^If pzTail is not NULL then *pzTail is made to point to the first byte
45544554
** past the end of the first SQL statement in zSql. These routines only
45554555
** compile the first statement in zSql, so *pzTail is left pointing to
45564556
** what remains uncompiled.
@@ -9658,10 +9658,20 @@
96589658
** threads may safely make multiple concurrent calls to sqlite3_backup_step().
96599659
** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
96609660
** APIs are not strictly speaking threadsafe. If they are invoked at the
96619661
** same time as another thread is invoking sqlite3_backup_step() it is
96629662
** possible that they return invalid values.
9663
+**
9664
+** <b>Alternatives To Using The Backup API</b>
9665
+**
9666
+** Other techniques for safely creating a consistent backup of an SQLite
9667
+** database include:
9668
+**
9669
+** <ul>
9670
+** <li> The [VACUUM INTO] command.
9671
+** <li> The [sqlite3_rsync] utility program.
9672
+** </ul>
96639673
*/
96649674
SQLITE_API sqlite3_backup *sqlite3_backup_init(
96659675
sqlite3 *pDest, /* Destination database handle */
96669676
const char *zDestName, /* Destination database name */
96679677
sqlite3 *pSource, /* Source database handle */
@@ -34699,11 +34709,11 @@
3469934709
*/
3470034710
#define READ_UTF8(zIn, zTerm, c) \
3470134711
c = *(zIn++); \
3470234712
if( c>=0xc0 ){ \
3470334713
c = sqlite3Utf8Trans1[c-0xc0]; \
34704
- while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){ \
34714
+ while( zIn<zTerm && (*zIn & 0xc0)==0x80 ){ \
3470534715
c = (c<<6) + (0x3f & *(zIn++)); \
3470634716
} \
3470734717
if( c<0x80 \
3470834718
|| (c&0xFFFFF800)==0xD800 \
3470934719
|| (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \
@@ -41011,11 +41021,15 @@
4101141021
** file by this or any other process. If such a lock is held, set *pResOut
4101241022
** to a non-zero value otherwise *pResOut is set to zero. The return value
4101341023
** is set to SQLITE_OK unless an I/O error occurs during lock checking.
4101441024
*/
4101541025
static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){
41026
+#ifdef SQLITE_DEBUG
4101641027
unixFile *pFile = (unixFile*)id;
41028
+#else
41029
+ UNUSED_PARAMETER(id);
41030
+#endif
4101741031
4101841032
SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
4101941033
4102041034
assert( pFile );
4102141035
assert( pFile->eFileLock<=SHARED_LOCK );
@@ -254849,11 +254863,11 @@
254849254863
int nArg, /* Number of args */
254850254864
sqlite3_value **apUnused /* Function arguments */
254851254865
){
254852254866
assert( nArg==0 );
254853254867
UNUSED_PARAM2(nArg, apUnused);
254854
- sqlite3_result_text(pCtx, "fts5: 2024-10-11 23:31:37 2db24c5364808008fa503f37ca8ccf5d135e8f6bfac2efb29e509e26f7190470", -1, SQLITE_TRANSIENT);
254868
+ sqlite3_result_text(pCtx, "fts5: 2024-10-17 13:29:49 b7814350381a2929e9fa6444867a80437291b8bbe59479d4525350b2719bc72c", -1, SQLITE_TRANSIENT);
254855254869
}
254856254870
254857254871
/*
254858254872
** Implementation of fts5_locale(LOCALE, TEXT) function.
254859254873
**
@@ -256815,11 +256829,11 @@
256815256829
256816256830
#define READ_UTF8(zIn, zTerm, c) \
256817256831
c = *(zIn++); \
256818256832
if( c>=0xc0 ){ \
256819256833
c = sqlite3Utf8Trans1[c-0xc0]; \
256820
- while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){ \
256834
+ while( zIn<zTerm && (*zIn & 0xc0)==0x80 ){ \
256821256835
c = (c<<6) + (0x3f & *(zIn++)); \
256822256836
} \
256823256837
if( c<0x80 \
256824256838
|| (c&0xFFFFF800)==0xD800 \
256825256839
|| (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \
256826256840
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -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 ** 2db24c5364808008fa503f37ca8ccf5d135e.
22 */
23 #define SQLITE_CORE 1
24 #define SQLITE_AMALGAMATION 1
25 #ifndef SQLITE_PRIVATE
26 # define SQLITE_PRIVATE static
@@ -462,11 +462,11 @@
462 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
463 ** [sqlite_version()] and [sqlite_source_id()].
464 */
465 #define SQLITE_VERSION "3.47.0"
466 #define SQLITE_VERSION_NUMBER 3047000
467 #define SQLITE_SOURCE_ID "2024-10-11 23:31:37 2db24c5364808008fa503f37ca8ccf5d135e8f6bfac2efb29e509e26f7190470"
468
469 /*
470 ** CAPI3REF: Run-Time Library Version Numbers
471 ** KEYWORDS: sqlite3_version sqlite3_sourceid
472 **
@@ -4546,11 +4546,11 @@
4546 ** If the caller knows that the supplied string is nul-terminated, then
4547 ** there is a small performance advantage to passing an nByte parameter that
4548 ** is the number of bytes in the input string <i>including</i>
4549 ** the nul-terminator.
4550 ** Note that nByte measure the length of the input in bytes, not
4551 ** characters, even for the UTF-16 inferfaces.
4552 **
4553 ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
4554 ** past the end of the first SQL statement in zSql. These routines only
4555 ** compile the first statement in zSql, so *pzTail is left pointing to
4556 ** what remains uncompiled.
@@ -9658,10 +9658,20 @@
9658 ** threads may safely make multiple concurrent calls to sqlite3_backup_step().
9659 ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
9660 ** APIs are not strictly speaking threadsafe. If they are invoked at the
9661 ** same time as another thread is invoking sqlite3_backup_step() it is
9662 ** possible that they return invalid values.
 
 
 
 
 
 
 
 
 
 
9663 */
9664 SQLITE_API sqlite3_backup *sqlite3_backup_init(
9665 sqlite3 *pDest, /* Destination database handle */
9666 const char *zDestName, /* Destination database name */
9667 sqlite3 *pSource, /* Source database handle */
@@ -34699,11 +34709,11 @@
34699 */
34700 #define READ_UTF8(zIn, zTerm, c) \
34701 c = *(zIn++); \
34702 if( c>=0xc0 ){ \
34703 c = sqlite3Utf8Trans1[c-0xc0]; \
34704 while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){ \
34705 c = (c<<6) + (0x3f & *(zIn++)); \
34706 } \
34707 if( c<0x80 \
34708 || (c&0xFFFFF800)==0xD800 \
34709 || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \
@@ -41011,11 +41021,15 @@
41011 ** file by this or any other process. If such a lock is held, set *pResOut
41012 ** to a non-zero value otherwise *pResOut is set to zero. The return value
41013 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
41014 */
41015 static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){
 
41016 unixFile *pFile = (unixFile*)id;
 
 
 
41017
41018 SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
41019
41020 assert( pFile );
41021 assert( pFile->eFileLock<=SHARED_LOCK );
@@ -254849,11 +254863,11 @@
254849 int nArg, /* Number of args */
254850 sqlite3_value **apUnused /* Function arguments */
254851 ){
254852 assert( nArg==0 );
254853 UNUSED_PARAM2(nArg, apUnused);
254854 sqlite3_result_text(pCtx, "fts5: 2024-10-11 23:31:37 2db24c5364808008fa503f37ca8ccf5d135e8f6bfac2efb29e509e26f7190470", -1, SQLITE_TRANSIENT);
254855 }
254856
254857 /*
254858 ** Implementation of fts5_locale(LOCALE, TEXT) function.
254859 **
@@ -256815,11 +256829,11 @@
256815
256816 #define READ_UTF8(zIn, zTerm, c) \
256817 c = *(zIn++); \
256818 if( c>=0xc0 ){ \
256819 c = sqlite3Utf8Trans1[c-0xc0]; \
256820 while( zIn!=zTerm && (*zIn & 0xc0)==0x80 ){ \
256821 c = (c<<6) + (0x3f & *(zIn++)); \
256822 } \
256823 if( c<0x80 \
256824 || (c&0xFFFFF800)==0xD800 \
256825 || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \
256826
--- extsrc/sqlite3.c
+++ extsrc/sqlite3.c
@@ -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 ** b7814350381a2929e9fa6444867a80437291.
22 */
23 #define SQLITE_CORE 1
24 #define SQLITE_AMALGAMATION 1
25 #ifndef SQLITE_PRIVATE
26 # define SQLITE_PRIVATE static
@@ -462,11 +462,11 @@
462 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
463 ** [sqlite_version()] and [sqlite_source_id()].
464 */
465 #define SQLITE_VERSION "3.47.0"
466 #define SQLITE_VERSION_NUMBER 3047000
467 #define SQLITE_SOURCE_ID "2024-10-17 13:29:49 b7814350381a2929e9fa6444867a80437291b8bbe59479d4525350b2719bc72c"
468
469 /*
470 ** CAPI3REF: Run-Time Library Version Numbers
471 ** KEYWORDS: sqlite3_version sqlite3_sourceid
472 **
@@ -4546,11 +4546,11 @@
4546 ** If the caller knows that the supplied string is nul-terminated, then
4547 ** there is a small performance advantage to passing an nByte parameter that
4548 ** is the number of bytes in the input string <i>including</i>
4549 ** the nul-terminator.
4550 ** Note that nByte measure the length of the input in bytes, not
4551 ** characters, even for the UTF-16 interfaces.
4552 **
4553 ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
4554 ** past the end of the first SQL statement in zSql. These routines only
4555 ** compile the first statement in zSql, so *pzTail is left pointing to
4556 ** what remains uncompiled.
@@ -9658,10 +9658,20 @@
9658 ** threads may safely make multiple concurrent calls to sqlite3_backup_step().
9659 ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
9660 ** APIs are not strictly speaking threadsafe. If they are invoked at the
9661 ** same time as another thread is invoking sqlite3_backup_step() it is
9662 ** possible that they return invalid values.
9663 **
9664 ** <b>Alternatives To Using The Backup API</b>
9665 **
9666 ** Other techniques for safely creating a consistent backup of an SQLite
9667 ** database include:
9668 **
9669 ** <ul>
9670 ** <li> The [VACUUM INTO] command.
9671 ** <li> The [sqlite3_rsync] utility program.
9672 ** </ul>
9673 */
9674 SQLITE_API sqlite3_backup *sqlite3_backup_init(
9675 sqlite3 *pDest, /* Destination database handle */
9676 const char *zDestName, /* Destination database name */
9677 sqlite3 *pSource, /* Source database handle */
@@ -34699,11 +34709,11 @@
34709 */
34710 #define READ_UTF8(zIn, zTerm, c) \
34711 c = *(zIn++); \
34712 if( c>=0xc0 ){ \
34713 c = sqlite3Utf8Trans1[c-0xc0]; \
34714 while( zIn<zTerm && (*zIn & 0xc0)==0x80 ){ \
34715 c = (c<<6) + (0x3f & *(zIn++)); \
34716 } \
34717 if( c<0x80 \
34718 || (c&0xFFFFF800)==0xD800 \
34719 || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \
@@ -41011,11 +41021,15 @@
41021 ** file by this or any other process. If such a lock is held, set *pResOut
41022 ** to a non-zero value otherwise *pResOut is set to zero. The return value
41023 ** is set to SQLITE_OK unless an I/O error occurs during lock checking.
41024 */
41025 static int flockCheckReservedLock(sqlite3_file *id, int *pResOut){
41026 #ifdef SQLITE_DEBUG
41027 unixFile *pFile = (unixFile*)id;
41028 #else
41029 UNUSED_PARAMETER(id);
41030 #endif
41031
41032 SimulateIOError( return SQLITE_IOERR_CHECKRESERVEDLOCK; );
41033
41034 assert( pFile );
41035 assert( pFile->eFileLock<=SHARED_LOCK );
@@ -254849,11 +254863,11 @@
254863 int nArg, /* Number of args */
254864 sqlite3_value **apUnused /* Function arguments */
254865 ){
254866 assert( nArg==0 );
254867 UNUSED_PARAM2(nArg, apUnused);
254868 sqlite3_result_text(pCtx, "fts5: 2024-10-17 13:29:49 b7814350381a2929e9fa6444867a80437291b8bbe59479d4525350b2719bc72c", -1, SQLITE_TRANSIENT);
254869 }
254870
254871 /*
254872 ** Implementation of fts5_locale(LOCALE, TEXT) function.
254873 **
@@ -256815,11 +256829,11 @@
256829
256830 #define READ_UTF8(zIn, zTerm, c) \
256831 c = *(zIn++); \
256832 if( c>=0xc0 ){ \
256833 c = sqlite3Utf8Trans1[c-0xc0]; \
256834 while( zIn<zTerm && (*zIn & 0xc0)==0x80 ){ \
256835 c = (c<<6) + (0x3f & *(zIn++)); \
256836 } \
256837 if( c<0x80 \
256838 || (c&0xFFFFF800)==0xD800 \
256839 || (c&0xFFFFFFFE)==0xFFFE ){ c = 0xFFFD; } \
256840
+12 -2
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147147
** [sqlite_version()] and [sqlite_source_id()].
148148
*/
149149
#define SQLITE_VERSION "3.47.0"
150150
#define SQLITE_VERSION_NUMBER 3047000
151
-#define SQLITE_SOURCE_ID "2024-10-11 23:31:37 2db24c5364808008fa503f37ca8ccf5d135e8f6bfac2efb29e509e26f7190470"
151
+#define SQLITE_SOURCE_ID "2024-10-17 13:29:49 b7814350381a2929e9fa6444867a80437291b8bbe59479d4525350b2719bc72c"
152152
153153
/*
154154
** CAPI3REF: Run-Time Library Version Numbers
155155
** KEYWORDS: sqlite3_version sqlite3_sourceid
156156
**
@@ -4230,11 +4230,11 @@
42304230
** If the caller knows that the supplied string is nul-terminated, then
42314231
** there is a small performance advantage to passing an nByte parameter that
42324232
** is the number of bytes in the input string <i>including</i>
42334233
** the nul-terminator.
42344234
** Note that nByte measure the length of the input in bytes, not
4235
-** characters, even for the UTF-16 inferfaces.
4235
+** characters, even for the UTF-16 interfaces.
42364236
**
42374237
** ^If pzTail is not NULL then *pzTail is made to point to the first byte
42384238
** past the end of the first SQL statement in zSql. These routines only
42394239
** compile the first statement in zSql, so *pzTail is left pointing to
42404240
** what remains uncompiled.
@@ -9342,10 +9342,20 @@
93429342
** threads may safely make multiple concurrent calls to sqlite3_backup_step().
93439343
** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
93449344
** APIs are not strictly speaking threadsafe. If they are invoked at the
93459345
** same time as another thread is invoking sqlite3_backup_step() it is
93469346
** possible that they return invalid values.
9347
+**
9348
+** <b>Alternatives To Using The Backup API</b>
9349
+**
9350
+** Other techniques for safely creating a consistent backup of an SQLite
9351
+** database include:
9352
+**
9353
+** <ul>
9354
+** <li> The [VACUUM INTO] command.
9355
+** <li> The [sqlite3_rsync] utility program.
9356
+** </ul>
93479357
*/
93489358
SQLITE_API sqlite3_backup *sqlite3_backup_init(
93499359
sqlite3 *pDest, /* Destination database handle */
93509360
const char *zDestName, /* Destination database name */
93519361
sqlite3 *pSource, /* Source database handle */
93529362
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.47.0"
150 #define SQLITE_VERSION_NUMBER 3047000
151 #define SQLITE_SOURCE_ID "2024-10-11 23:31:37 2db24c5364808008fa503f37ca8ccf5d135e8f6bfac2efb29e509e26f7190470"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -4230,11 +4230,11 @@
4230 ** If the caller knows that the supplied string is nul-terminated, then
4231 ** there is a small performance advantage to passing an nByte parameter that
4232 ** is the number of bytes in the input string <i>including</i>
4233 ** the nul-terminator.
4234 ** Note that nByte measure the length of the input in bytes, not
4235 ** characters, even for the UTF-16 inferfaces.
4236 **
4237 ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
4238 ** past the end of the first SQL statement in zSql. These routines only
4239 ** compile the first statement in zSql, so *pzTail is left pointing to
4240 ** what remains uncompiled.
@@ -9342,10 +9342,20 @@
9342 ** threads may safely make multiple concurrent calls to sqlite3_backup_step().
9343 ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
9344 ** APIs are not strictly speaking threadsafe. If they are invoked at the
9345 ** same time as another thread is invoking sqlite3_backup_step() it is
9346 ** possible that they return invalid values.
 
 
 
 
 
 
 
 
 
 
9347 */
9348 SQLITE_API sqlite3_backup *sqlite3_backup_init(
9349 sqlite3 *pDest, /* Destination database handle */
9350 const char *zDestName, /* Destination database name */
9351 sqlite3 *pSource, /* Source database handle */
9352
--- extsrc/sqlite3.h
+++ extsrc/sqlite3.h
@@ -146,11 +146,11 @@
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.47.0"
150 #define SQLITE_VERSION_NUMBER 3047000
151 #define SQLITE_SOURCE_ID "2024-10-17 13:29:49 b7814350381a2929e9fa6444867a80437291b8bbe59479d4525350b2719bc72c"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -4230,11 +4230,11 @@
4230 ** If the caller knows that the supplied string is nul-terminated, then
4231 ** there is a small performance advantage to passing an nByte parameter that
4232 ** is the number of bytes in the input string <i>including</i>
4233 ** the nul-terminator.
4234 ** Note that nByte measure the length of the input in bytes, not
4235 ** characters, even for the UTF-16 interfaces.
4236 **
4237 ** ^If pzTail is not NULL then *pzTail is made to point to the first byte
4238 ** past the end of the first SQL statement in zSql. These routines only
4239 ** compile the first statement in zSql, so *pzTail is left pointing to
4240 ** what remains uncompiled.
@@ -9342,10 +9342,20 @@
9342 ** threads may safely make multiple concurrent calls to sqlite3_backup_step().
9343 ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
9344 ** APIs are not strictly speaking threadsafe. If they are invoked at the
9345 ** same time as another thread is invoking sqlite3_backup_step() it is
9346 ** possible that they return invalid values.
9347 **
9348 ** <b>Alternatives To Using The Backup API</b>
9349 **
9350 ** Other techniques for safely creating a consistent backup of an SQLite
9351 ** database include:
9352 **
9353 ** <ul>
9354 ** <li> The [VACUUM INTO] command.
9355 ** <li> The [sqlite3_rsync] utility program.
9356 ** </ul>
9357 */
9358 SQLITE_API sqlite3_backup *sqlite3_backup_init(
9359 sqlite3 *pDest, /* Destination database handle */
9360 const char *zDestName, /* Destination database name */
9361 sqlite3 *pSource, /* Source database handle */
9362

Keyboard Shortcuts

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