Fossil SCM

Update the built-in SQLite to 3.10.0 beta for SQLite testing.

drh 2015-12-31 15:44 trunk
Commit ec8394e166117a54f65af0fd0298a8b7d5e11bc9
3 files changed +114 -59 +176 -80 +1 -1
+114 -59
--- src/shell.c
+++ src/shell.c
@@ -327,10 +327,17 @@
327327
** Threat stdin as an interactive input if the following variable
328328
** is true. Otherwise, assume stdin is connected to a file or pipe.
329329
*/
330330
static int stdin_is_interactive = 1;
331331
332
+/*
333
+** On Windows systems we have to know if standard output is a console
334
+** in order to translate UTF-8 into MBCS. The following variable is
335
+** true if translation is required.
336
+*/
337
+static int stdout_is_console = 1;
338
+
332339
/*
333340
** The following is the open SQLite database. We make a pointer
334341
** to this database a static variable so that it can be accessed
335342
** by the SIGINT handler to interrupt database processing.
336343
*/
@@ -427,10 +434,20 @@
427434
UNUSED_PARAMETER(argc);
428435
UNUSED_PARAMETER(argv);
429436
sqlite3_result_text(context, zShellStatic, -1, SQLITE_STATIC);
430437
}
431438
439
+
440
+/*
441
+** Compute a string length that is limited to what can be stored in
442
+** lower 30 bits of a 32-bit signed integer.
443
+*/
444
+static int strlen30(const char *z){
445
+ const char *z2 = z;
446
+ while( *z2 ){ z2++; }
447
+ return 0x3fffffff & (int)(z2 - z);
448
+}
432449
433450
/*
434451
** This routine reads a line of text from FILE in, stores
435452
** the text in memory obtained from malloc() and returns a pointer
436453
** to the text. NULL is returned at end of file, or if malloc()
@@ -463,10 +480,30 @@
463480
if( n>0 && zLine[n-1]=='\r' ) n--;
464481
zLine[n] = 0;
465482
break;
466483
}
467484
}
485
+#if defined(_WIN32) || defined(WIN32)
486
+ /* For interactive input on Windows systems, translate the
487
+ ** multi-byte characterset characters into UTF-8. */
488
+ if( stdin_is_interactive ){
489
+ extern char *sqlite3_win32_mbcs_to_utf8(const char*);
490
+ char *zTrans = sqlite3_win32_mbcs_to_utf8(zLine);
491
+ if( zTrans ){
492
+ int nTrans = strlen30(zTrans)+1;
493
+ if( nTrans>nLine ){
494
+ zLine = realloc(zLine, nTrans);
495
+ if( zLine==0 ){
496
+ sqlite3_free(zTrans);
497
+ return 0;
498
+ }
499
+ }
500
+ memcpy(zLine, zTrans, nTrans);
501
+ sqlite3_free(zTrans);
502
+ }
503
+ }
504
+#endif /* defined(_WIN32) || defined(WIN32) */
468505
return zLine;
469506
}
470507
471508
/*
472509
** Retrieve a single line of input text.
@@ -500,10 +537,35 @@
500537
#endif
501538
}
502539
return zResult;
503540
}
504541
542
+/*
543
+** Render output like fprintf(). Except, if the output is going to the
544
+** console and if this is running on a Windows machine, translate the
545
+** output from UTF-8 into MBCS.
546
+*/
547
+#if defined(_WIN32) || defined(WIN32)
548
+void utf8_printf(FILE *out, const char *zFormat, ...){
549
+ va_list ap;
550
+ va_start(ap, zFormat);
551
+ if( stdout_is_console && out==stdout ){
552
+ extern char *sqlite3_win32_utf8_to_mbcs(const char*);
553
+ char *z1 = sqlite3_vmprintf(zFormat, ap);
554
+ char *z2 = sqlite3_win32_utf8_to_mbcs(z1);
555
+ sqlite3_free(z1);
556
+ fputs(z2, out);
557
+ sqlite3_free(z2);
558
+ }else{
559
+ vfprintf(out, zFormat, ap);
560
+ }
561
+ va_end(ap);
562
+}
563
+#else
564
+# define utf8_printf fprintf
565
+#endif
566
+
505567
/*
506568
** Shell output mode information from before ".explain on",
507569
** saved so that it can be restored by ".explain off"
508570
*/
509571
typedef struct SavedModeInfo SavedModeInfo;
@@ -605,20 +667,10 @@
605667
/*
606668
** Number of elements in an array
607669
*/
608670
#define ArraySize(X) (int)(sizeof(X)/sizeof(X[0]))
609671
610
-/*
611
-** Compute a string length that is limited to what can be stored in
612
-** lower 30 bits of a 32-bit signed integer.
613
-*/
614
-static int strlen30(const char *z){
615
- const char *z2 = z;
616
- while( *z2 ){ z2++; }
617
- return 0x3fffffff & (int)(z2 - z);
618
-}
619
-
620672
/*
621673
** A callback for the sqlite3_log() interface.
622674
*/
623675
static void shellLog(void *pArg, int iErrCode, const char *zMsg){
624676
ShellState *p = (ShellState*)pArg;
@@ -647,23 +699,23 @@
647699
setBinaryMode(out);
648700
for(i=0; z[i]; i++){
649701
if( z[i]=='\'' ) nSingle++;
650702
}
651703
if( nSingle==0 ){
652
- fprintf(out,"'%s'",z);
704
+ utf8_printf(out,"'%s'",z);
653705
}else{
654706
fprintf(out,"'");
655707
while( *z ){
656708
for(i=0; z[i] && z[i]!='\''; i++){}
657709
if( i==0 ){
658710
fprintf(out,"''");
659711
z++;
660712
}else if( z[i]=='\'' ){
661
- fprintf(out,"%.*s''",i,z);
713
+ utf8_printf(out,"%.*s''",i,z);
662714
z += i+1;
663715
}else{
664
- fprintf(out,"%s",z);
716
+ utf8_printf(out,"%s",z);
665717
break;
666718
}
667719
}
668720
fprintf(out,"'");
669721
}
@@ -715,11 +767,11 @@
715767
&& z[i]!='>'
716768
&& z[i]!='\"'
717769
&& z[i]!='\'';
718770
i++){}
719771
if( i>0 ){
720
- fprintf(out,"%.*s",i,z);
772
+ utf8_printf(out,"%.*s",i,z);
721773
}
722774
if( z[i]=='<' ){
723775
fprintf(out,"&lt;");
724776
}else if( z[i]=='&' ){
725777
fprintf(out,"&amp;");
@@ -766,11 +818,11 @@
766818
** is only issued if bSep is true.
767819
*/
768820
static void output_csv(ShellState *p, const char *z, int bSep){
769821
FILE *out = p->out;
770822
if( z==0 ){
771
- fprintf(out,"%s",p->nullValue);
823
+ utf8_printf(out,"%s",p->nullValue);
772824
}else{
773825
int i;
774826
int nSep = strlen30(p->colSeparator);
775827
for(i=0; z[i]; i++){
776828
if( needCsvQuote[((unsigned char*)z)[i]]
@@ -786,15 +838,15 @@
786838
if( z[i]=='"' ) putc('"', out);
787839
putc(z[i], out);
788840
}
789841
putc('"', out);
790842
}else{
791
- fprintf(out, "%s", z);
843
+ utf8_printf(out, "%s", z);
792844
}
793845
}
794846
if( bSep ){
795
- fprintf(p->out, "%s", p->colSeparator);
847
+ utf8_printf(p->out, "%s", p->colSeparator);
796848
}
797849
}
798850
799851
#ifdef SIGINT
800852
/*
@@ -828,13 +880,13 @@
828880
if( azArg==0 ) break;
829881
for(i=0; i<nArg; i++){
830882
int len = strlen30(azCol[i] ? azCol[i] : "");
831883
if( len>w ) w = len;
832884
}
833
- if( p->cnt++>0 ) fprintf(p->out, "%s", p->rowSeparator);
885
+ if( p->cnt++>0 ) utf8_printf(p->out, "%s", p->rowSeparator);
834886
for(i=0; i<nArg; i++){
835
- fprintf(p->out,"%*s = %s%s", w, azCol[i],
887
+ utf8_printf(p->out,"%*s = %s%s", w, azCol[i],
836888
azArg[i] ? azArg[i] : p->nullValue, p->rowSeparator);
837889
}
838890
break;
839891
}
840892
case MODE_Explain:
@@ -856,14 +908,14 @@
856908
if( i<ArraySize(p->actualWidth) ){
857909
p->actualWidth[i] = w;
858910
}
859911
if( p->showHeader ){
860912
if( w<0 ){
861
- fprintf(p->out,"%*.*s%s",-w,-w,azCol[i],
913
+ utf8_printf(p->out,"%*.*s%s",-w,-w,azCol[i],
862914
i==nArg-1 ? p->rowSeparator : " ");
863915
}else{
864
- fprintf(p->out,"%-*.*s%s",w,w,azCol[i],
916
+ utf8_printf(p->out,"%-*.*s%s",w,w,azCol[i],
865917
i==nArg-1 ? p->rowSeparator : " ");
866918
}
867919
}
868920
}
869921
if( p->showHeader ){
@@ -873,11 +925,12 @@
873925
w = p->actualWidth[i];
874926
if( w<0 ) w = -w;
875927
}else{
876928
w = 10;
877929
}
878
- fprintf(p->out,"%-*.*s%s",w,w,"-----------------------------------"
930
+ fprintf(p->out,"%-*.*s%s",w,w,
931
+ "----------------------------------------------------------"
879932
"----------------------------------------------------------",
880933
i==nArg-1 ? p->rowSeparator : " ");
881934
}
882935
}
883936
}
@@ -897,15 +950,15 @@
897950
fprintf(p->out, "%*.s", p->aiIndent[p->iIndent], "");
898951
}
899952
p->iIndent++;
900953
}
901954
if( w<0 ){
902
- fprintf(p->out,"%*.*s%s",-w,-w,
955
+ utf8_printf(p->out,"%*.*s%s",-w,-w,
903956
azArg[i] ? azArg[i] : p->nullValue,
904957
i==nArg-1 ? p->rowSeparator : " ");
905958
}else{
906
- fprintf(p->out,"%-*.*s%s",w,w,
959
+ utf8_printf(p->out,"%-*.*s%s",w,w,
907960
azArg[i] ? azArg[i] : p->nullValue,
908961
i==nArg-1 ? p->rowSeparator : " ");
909962
}
910963
}
911964
break;
@@ -912,25 +965,25 @@
912965
}
913966
case MODE_Semi:
914967
case MODE_List: {
915968
if( p->cnt++==0 && p->showHeader ){
916969
for(i=0; i<nArg; i++){
917
- fprintf(p->out,"%s%s",azCol[i],
970
+ utf8_printf(p->out,"%s%s",azCol[i],
918971
i==nArg-1 ? p->rowSeparator : p->colSeparator);
919972
}
920973
}
921974
if( azArg==0 ) break;
922975
for(i=0; i<nArg; i++){
923976
char *z = azArg[i];
924977
if( z==0 ) z = p->nullValue;
925
- fprintf(p->out, "%s", z);
978
+ utf8_printf(p->out, "%s", z);
926979
if( i<nArg-1 ){
927
- fprintf(p->out, "%s", p->colSeparator);
980
+ utf8_printf(p->out, "%s", p->colSeparator);
928981
}else if( p->mode==MODE_Semi ){
929
- fprintf(p->out, ";%s", p->rowSeparator);
982
+ utf8_printf(p->out, ";%s", p->rowSeparator);
930983
}else{
931
- fprintf(p->out, "%s", p->rowSeparator);
984
+ utf8_printf(p->out, "%s", p->rowSeparator);
932985
}
933986
}
934987
break;
935988
}
936989
case MODE_Html: {
@@ -955,48 +1008,48 @@
9551008
}
9561009
case MODE_Tcl: {
9571010
if( p->cnt++==0 && p->showHeader ){
9581011
for(i=0; i<nArg; i++){
9591012
output_c_string(p->out,azCol[i] ? azCol[i] : "");
960
- if(i<nArg-1) fprintf(p->out, "%s", p->colSeparator);
1013
+ if(i<nArg-1) utf8_printf(p->out, "%s", p->colSeparator);
9611014
}
962
- fprintf(p->out, "%s", p->rowSeparator);
1015
+ utf8_printf(p->out, "%s", p->rowSeparator);
9631016
}
9641017
if( azArg==0 ) break;
9651018
for(i=0; i<nArg; i++){
9661019
output_c_string(p->out, azArg[i] ? azArg[i] : p->nullValue);
967
- if(i<nArg-1) fprintf(p->out, "%s", p->colSeparator);
1020
+ if(i<nArg-1) utf8_printf(p->out, "%s", p->colSeparator);
9681021
}
969
- fprintf(p->out, "%s", p->rowSeparator);
1022
+ utf8_printf(p->out, "%s", p->rowSeparator);
9701023
break;
9711024
}
9721025
case MODE_Csv: {
9731026
setBinaryMode(p->out);
9741027
if( p->cnt++==0 && p->showHeader ){
9751028
for(i=0; i<nArg; i++){
9761029
output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1);
9771030
}
978
- fprintf(p->out, "%s", p->rowSeparator);
1031
+ utf8_printf(p->out, "%s", p->rowSeparator);
9791032
}
9801033
if( nArg>0 ){
9811034
for(i=0; i<nArg; i++){
9821035
output_csv(p, azArg[i], i<nArg-1);
9831036
}
984
- fprintf(p->out, "%s", p->rowSeparator);
1037
+ utf8_printf(p->out, "%s", p->rowSeparator);
9851038
}
9861039
setTextMode(p->out);
9871040
break;
9881041
}
9891042
case MODE_Insert: {
9901043
p->cnt++;
9911044
if( azArg==0 ) break;
992
- fprintf(p->out,"INSERT INTO %s",p->zDestTable);
1045
+ utf8_printf(p->out,"INSERT INTO %s",p->zDestTable);
9931046
if( p->showHeader ){
9941047
fprintf(p->out,"(");
9951048
for(i=0; i<nArg; i++){
9961049
char *zSep = i>0 ? ",": "";
997
- fprintf(p->out, "%s%s", zSep, azCol[i]);
1050
+ utf8_printf(p->out, "%s%s", zSep, azCol[i]);
9981051
}
9991052
fprintf(p->out,")");
10001053
}
10011054
fprintf(p->out," VALUES(");
10021055
for(i=0; i<nArg; i++){
@@ -1006,18 +1059,18 @@
10061059
}else if( aiType && aiType[i]==SQLITE_TEXT ){
10071060
if( zSep[0] ) fprintf(p->out,"%s",zSep);
10081061
output_quoted_string(p->out, azArg[i]);
10091062
}else if( aiType && (aiType[i]==SQLITE_INTEGER
10101063
|| aiType[i]==SQLITE_FLOAT) ){
1011
- fprintf(p->out,"%s%s",zSep, azArg[i]);
1064
+ utf8_printf(p->out,"%s%s",zSep, azArg[i]);
10121065
}else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
10131066
const void *pBlob = sqlite3_column_blob(p->pStmt, i);
10141067
int nBlob = sqlite3_column_bytes(p->pStmt, i);
10151068
if( zSep[0] ) fprintf(p->out,"%s",zSep);
10161069
output_hex_blob(p->out, pBlob, nBlob);
10171070
}else if( isNumber(azArg[i], 0) ){
1018
- fprintf(p->out,"%s%s",zSep, azArg[i]);
1071
+ utf8_printf(p->out,"%s%s",zSep, azArg[i]);
10191072
}else{
10201073
if( zSep[0] ) fprintf(p->out,"%s",zSep);
10211074
output_quoted_string(p->out, azArg[i]);
10221075
}
10231076
}
@@ -1025,21 +1078,21 @@
10251078
break;
10261079
}
10271080
case MODE_Ascii: {
10281081
if( p->cnt++==0 && p->showHeader ){
10291082
for(i=0; i<nArg; i++){
1030
- if( i>0 ) fprintf(p->out, "%s", p->colSeparator);
1031
- fprintf(p->out,"%s",azCol[i] ? azCol[i] : "");
1083
+ if( i>0 ) utf8_printf(p->out, "%s", p->colSeparator);
1084
+ utf8_printf(p->out,"%s",azCol[i] ? azCol[i] : "");
10321085
}
1033
- fprintf(p->out, "%s", p->rowSeparator);
1086
+ utf8_printf(p->out, "%s", p->rowSeparator);
10341087
}
10351088
if( azArg==0 ) break;
10361089
for(i=0; i<nArg; i++){
1037
- if( i>0 ) fprintf(p->out, "%s", p->colSeparator);
1038
- fprintf(p->out,"%s",azArg[i] ? azArg[i] : p->nullValue);
1090
+ if( i>0 ) utf8_printf(p->out, "%s", p->colSeparator);
1091
+ utf8_printf(p->out,"%s",azArg[i] ? azArg[i] : p->nullValue);
10391092
}
1040
- fprintf(p->out, "%s", p->rowSeparator);
1093
+ utf8_printf(p->out, "%s", p->rowSeparator);
10411094
break;
10421095
}
10431096
}
10441097
return 0;
10451098
}
@@ -1165,17 +1218,17 @@
11651218
}
11661219
rc = sqlite3_step(pSelect);
11671220
nResult = sqlite3_column_count(pSelect);
11681221
while( rc==SQLITE_ROW ){
11691222
if( zFirstRow ){
1170
- fprintf(p->out, "%s", zFirstRow);
1223
+ utf8_printf(p->out, "%s", zFirstRow);
11711224
zFirstRow = 0;
11721225
}
11731226
z = (const char*)sqlite3_column_text(pSelect, 0);
1174
- fprintf(p->out, "%s", z);
1227
+ utf8_printf(p->out, "%s", z);
11751228
for(i=1; i<nResult; i++){
1176
- fprintf(p->out, ",%s", sqlite3_column_text(pSelect, i));
1229
+ utf8_printf(p->out, ",%s", sqlite3_column_text(pSelect, i));
11771230
}
11781231
if( z==0 ) z = "";
11791232
while( z[0] && (z[0]!='-' || z[1]!='-') ) z++;
11801233
if( z[0] ){
11811234
fprintf(p->out, "\n;\n");
@@ -1359,11 +1412,11 @@
13591412
}
13601413
n++;
13611414
sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit);
13621415
sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EST, (void*)&rEst);
13631416
sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EXPLAIN, (void*)&zExplain);
1364
- fprintf(pArg->out, "Loop %2d: %s\n", n, zExplain);
1417
+ utf8_printf(pArg->out, "Loop %2d: %s\n", n, zExplain);
13651418
rEstLoop *= rEst;
13661419
fprintf(pArg->out,
13671420
" nLoop=%-8lld nRow=%-8lld estRow=%-8lld estRow/Loop=%-8g\n",
13681421
nLoop, nVisit, (sqlite3_int64)(rEstLoop+0.5), rEst
13691422
);
@@ -1520,11 +1573,11 @@
15201573
}
15211574
15221575
/* echo the sql statement if echo on */
15231576
if( pArg && pArg->echoOn ){
15241577
const char *zStmtSql = sqlite3_sql(pStmt);
1525
- fprintf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql);
1578
+ utf8_printf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql);
15261579
}
15271580
15281581
/* Show the EXPLAIN QUERY PLAN if .eqp is on */
15291582
if( pArg && pArg->autoEQP ){
15301583
sqlite3_stmt *pExplain;
@@ -1534,11 +1587,11 @@
15341587
if( rc==SQLITE_OK ){
15351588
while( sqlite3_step(pExplain)==SQLITE_ROW ){
15361589
fprintf(pArg->out,"--EQP-- %d,", sqlite3_column_int(pExplain, 0));
15371590
fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 1));
15381591
fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 2));
1539
- fprintf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3));
1592
+ utf8_printf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3));
15401593
}
15411594
}
15421595
sqlite3_finalize(pExplain);
15431596
sqlite3_free(zEQP);
15441597
}
@@ -1675,15 +1728,15 @@
16751728
}
16761729
zIns = sqlite3_mprintf(
16771730
"INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)"
16781731
"VALUES('table','%q','%q',0,'%q');",
16791732
zTable, zTable, zSql);
1680
- fprintf(p->out, "%s\n", zIns);
1733
+ utf8_printf(p->out, "%s\n", zIns);
16811734
sqlite3_free(zIns);
16821735
return 0;
16831736
}else{
1684
- fprintf(p->out, "%s;\n", zSql);
1737
+ utf8_printf(p->out, "%s;\n", zSql);
16851738
}
16861739
16871740
if( strcmp(zType, "table")==0 ){
16881741
sqlite3_stmt *pTableInfo = 0;
16891742
char *zSelect = 0;
@@ -2124,11 +2177,11 @@
21242177
static void sql_trace_callback(void *pArg, const char *z){
21252178
FILE *f = (FILE*)pArg;
21262179
if( f ){
21272180
int i = (int)strlen(z);
21282181
while( i>0 && z[i-1]==';' ){ i--; }
2129
- fprintf(f, "%.*s;\n", i, z);
2182
+ utf8_printf(f, "%.*s;\n", i, z);
21302183
}
21312184
}
21322185
21332186
/*
21342187
** A no-op routine that runs with the ".breakpoint" doc-command. This is
@@ -2607,11 +2660,11 @@
26072660
}
26082661
for(i=0; i<ArraySize(aQuery); i++){
26092662
char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab);
26102663
int val = db_int(p, zSql);
26112664
sqlite3_free(zSql);
2612
- fprintf(p->out, "%-20s %d\n", aQuery[i].zName, val);
2665
+ utf8_printf(p->out, "%-20s %d\n", aQuery[i].zName, val);
26132666
}
26142667
sqlite3_free(zSchemaTab);
26152668
return 0;
26162669
}
26172670
@@ -3447,11 +3500,11 @@
34473500
34483501
if( c=='p' && n>=3 && strncmp(azArg[0], "print", n)==0 ){
34493502
int i;
34503503
for(i=1; i<nArg; i++){
34513504
if( i>1 ) fprintf(p->out, " ");
3452
- fprintf(p->out, "%s", azArg[i]);
3505
+ utf8_printf(p->out, "%s", azArg[i]);
34533506
}
34543507
fprintf(p->out, "\n");
34553508
}else
34563509
34573510
if( c=='p' && strncmp(azArg[0], "prompt", n)==0 ){
@@ -3641,20 +3694,20 @@
36413694
if( c=='s' && n>=10 && strncmp(azArg[0], "selftest-", 9)==0 ){
36423695
if( strncmp(azArg[0]+9, "boolean", n-9)==0 ){
36433696
int i, v;
36443697
for(i=1; i<nArg; i++){
36453698
v = booleanValue(azArg[i]);
3646
- fprintf(p->out, "%s: %d 0x%x\n", azArg[i], v, v);
3699
+ utf8_printf(p->out, "%s: %d 0x%x\n", azArg[i], v, v);
36473700
}
36483701
}
36493702
if( strncmp(azArg[0]+9, "integer", n-9)==0 ){
36503703
int i; sqlite3_int64 v;
36513704
for(i=1; i<nArg; i++){
36523705
char zBuf[200];
36533706
v = integerValue(azArg[i]);
36543707
sqlite3_snprintf(sizeof(zBuf),zBuf,"%s: %lld 0x%llx\n", azArg[i],v,v);
3655
- fprintf(p->out, "%s", zBuf);
3708
+ utf8_printf(p->out, "%s", zBuf);
36563709
}
36573710
}
36583711
}else
36593712
#endif
36603713
@@ -3824,11 +3877,12 @@
38243877
if( nPrintCol<1 ) nPrintCol = 1;
38253878
nPrintRow = (nRow + nPrintCol - 1)/nPrintCol;
38263879
for(i=0; i<nPrintRow; i++){
38273880
for(j=i; j<nRow; j+=nPrintRow){
38283881
char *zSp = j<nPrintRow ? "" : " ";
3829
- fprintf(p->out, "%s%-*s", zSp, maxlen, azResult[j] ? azResult[j]:"");
3882
+ utf8_printf(p->out, "%s%-*s", zSp, maxlen,
3883
+ azResult[j] ? azResult[j]:"");
38303884
}
38313885
fprintf(p->out, "\n");
38323886
}
38333887
}
38343888
@@ -4545,10 +4599,11 @@
45454599
setBinaryMode(stdin);
45464600
setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */
45474601
Argv0 = argv[0];
45484602
main_init(&data);
45494603
stdin_is_interactive = isatty(0);
4604
+ stdout_is_console = isatty(1);
45504605
45514606
/* Make sure we have a valid signal handler early, before anything
45524607
** else is done.
45534608
*/
45544609
#ifdef SIGINT
45554610
--- src/shell.c
+++ src/shell.c
@@ -327,10 +327,17 @@
327 ** Threat stdin as an interactive input if the following variable
328 ** is true. Otherwise, assume stdin is connected to a file or pipe.
329 */
330 static int stdin_is_interactive = 1;
331
 
 
 
 
 
 
 
332 /*
333 ** The following is the open SQLite database. We make a pointer
334 ** to this database a static variable so that it can be accessed
335 ** by the SIGINT handler to interrupt database processing.
336 */
@@ -427,10 +434,20 @@
427 UNUSED_PARAMETER(argc);
428 UNUSED_PARAMETER(argv);
429 sqlite3_result_text(context, zShellStatic, -1, SQLITE_STATIC);
430 }
431
 
 
 
 
 
 
 
 
 
 
432
433 /*
434 ** This routine reads a line of text from FILE in, stores
435 ** the text in memory obtained from malloc() and returns a pointer
436 ** to the text. NULL is returned at end of file, or if malloc()
@@ -463,10 +480,30 @@
463 if( n>0 && zLine[n-1]=='\r' ) n--;
464 zLine[n] = 0;
465 break;
466 }
467 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
468 return zLine;
469 }
470
471 /*
472 ** Retrieve a single line of input text.
@@ -500,10 +537,35 @@
500 #endif
501 }
502 return zResult;
503 }
504
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
505 /*
506 ** Shell output mode information from before ".explain on",
507 ** saved so that it can be restored by ".explain off"
508 */
509 typedef struct SavedModeInfo SavedModeInfo;
@@ -605,20 +667,10 @@
605 /*
606 ** Number of elements in an array
607 */
608 #define ArraySize(X) (int)(sizeof(X)/sizeof(X[0]))
609
610 /*
611 ** Compute a string length that is limited to what can be stored in
612 ** lower 30 bits of a 32-bit signed integer.
613 */
614 static int strlen30(const char *z){
615 const char *z2 = z;
616 while( *z2 ){ z2++; }
617 return 0x3fffffff & (int)(z2 - z);
618 }
619
620 /*
621 ** A callback for the sqlite3_log() interface.
622 */
623 static void shellLog(void *pArg, int iErrCode, const char *zMsg){
624 ShellState *p = (ShellState*)pArg;
@@ -647,23 +699,23 @@
647 setBinaryMode(out);
648 for(i=0; z[i]; i++){
649 if( z[i]=='\'' ) nSingle++;
650 }
651 if( nSingle==0 ){
652 fprintf(out,"'%s'",z);
653 }else{
654 fprintf(out,"'");
655 while( *z ){
656 for(i=0; z[i] && z[i]!='\''; i++){}
657 if( i==0 ){
658 fprintf(out,"''");
659 z++;
660 }else if( z[i]=='\'' ){
661 fprintf(out,"%.*s''",i,z);
662 z += i+1;
663 }else{
664 fprintf(out,"%s",z);
665 break;
666 }
667 }
668 fprintf(out,"'");
669 }
@@ -715,11 +767,11 @@
715 && z[i]!='>'
716 && z[i]!='\"'
717 && z[i]!='\'';
718 i++){}
719 if( i>0 ){
720 fprintf(out,"%.*s",i,z);
721 }
722 if( z[i]=='<' ){
723 fprintf(out,"&lt;");
724 }else if( z[i]=='&' ){
725 fprintf(out,"&amp;");
@@ -766,11 +818,11 @@
766 ** is only issued if bSep is true.
767 */
768 static void output_csv(ShellState *p, const char *z, int bSep){
769 FILE *out = p->out;
770 if( z==0 ){
771 fprintf(out,"%s",p->nullValue);
772 }else{
773 int i;
774 int nSep = strlen30(p->colSeparator);
775 for(i=0; z[i]; i++){
776 if( needCsvQuote[((unsigned char*)z)[i]]
@@ -786,15 +838,15 @@
786 if( z[i]=='"' ) putc('"', out);
787 putc(z[i], out);
788 }
789 putc('"', out);
790 }else{
791 fprintf(out, "%s", z);
792 }
793 }
794 if( bSep ){
795 fprintf(p->out, "%s", p->colSeparator);
796 }
797 }
798
799 #ifdef SIGINT
800 /*
@@ -828,13 +880,13 @@
828 if( azArg==0 ) break;
829 for(i=0; i<nArg; i++){
830 int len = strlen30(azCol[i] ? azCol[i] : "");
831 if( len>w ) w = len;
832 }
833 if( p->cnt++>0 ) fprintf(p->out, "%s", p->rowSeparator);
834 for(i=0; i<nArg; i++){
835 fprintf(p->out,"%*s = %s%s", w, azCol[i],
836 azArg[i] ? azArg[i] : p->nullValue, p->rowSeparator);
837 }
838 break;
839 }
840 case MODE_Explain:
@@ -856,14 +908,14 @@
856 if( i<ArraySize(p->actualWidth) ){
857 p->actualWidth[i] = w;
858 }
859 if( p->showHeader ){
860 if( w<0 ){
861 fprintf(p->out,"%*.*s%s",-w,-w,azCol[i],
862 i==nArg-1 ? p->rowSeparator : " ");
863 }else{
864 fprintf(p->out,"%-*.*s%s",w,w,azCol[i],
865 i==nArg-1 ? p->rowSeparator : " ");
866 }
867 }
868 }
869 if( p->showHeader ){
@@ -873,11 +925,12 @@
873 w = p->actualWidth[i];
874 if( w<0 ) w = -w;
875 }else{
876 w = 10;
877 }
878 fprintf(p->out,"%-*.*s%s",w,w,"-----------------------------------"
 
879 "----------------------------------------------------------",
880 i==nArg-1 ? p->rowSeparator : " ");
881 }
882 }
883 }
@@ -897,15 +950,15 @@
897 fprintf(p->out, "%*.s", p->aiIndent[p->iIndent], "");
898 }
899 p->iIndent++;
900 }
901 if( w<0 ){
902 fprintf(p->out,"%*.*s%s",-w,-w,
903 azArg[i] ? azArg[i] : p->nullValue,
904 i==nArg-1 ? p->rowSeparator : " ");
905 }else{
906 fprintf(p->out,"%-*.*s%s",w,w,
907 azArg[i] ? azArg[i] : p->nullValue,
908 i==nArg-1 ? p->rowSeparator : " ");
909 }
910 }
911 break;
@@ -912,25 +965,25 @@
912 }
913 case MODE_Semi:
914 case MODE_List: {
915 if( p->cnt++==0 && p->showHeader ){
916 for(i=0; i<nArg; i++){
917 fprintf(p->out,"%s%s",azCol[i],
918 i==nArg-1 ? p->rowSeparator : p->colSeparator);
919 }
920 }
921 if( azArg==0 ) break;
922 for(i=0; i<nArg; i++){
923 char *z = azArg[i];
924 if( z==0 ) z = p->nullValue;
925 fprintf(p->out, "%s", z);
926 if( i<nArg-1 ){
927 fprintf(p->out, "%s", p->colSeparator);
928 }else if( p->mode==MODE_Semi ){
929 fprintf(p->out, ";%s", p->rowSeparator);
930 }else{
931 fprintf(p->out, "%s", p->rowSeparator);
932 }
933 }
934 break;
935 }
936 case MODE_Html: {
@@ -955,48 +1008,48 @@
955 }
956 case MODE_Tcl: {
957 if( p->cnt++==0 && p->showHeader ){
958 for(i=0; i<nArg; i++){
959 output_c_string(p->out,azCol[i] ? azCol[i] : "");
960 if(i<nArg-1) fprintf(p->out, "%s", p->colSeparator);
961 }
962 fprintf(p->out, "%s", p->rowSeparator);
963 }
964 if( azArg==0 ) break;
965 for(i=0; i<nArg; i++){
966 output_c_string(p->out, azArg[i] ? azArg[i] : p->nullValue);
967 if(i<nArg-1) fprintf(p->out, "%s", p->colSeparator);
968 }
969 fprintf(p->out, "%s", p->rowSeparator);
970 break;
971 }
972 case MODE_Csv: {
973 setBinaryMode(p->out);
974 if( p->cnt++==0 && p->showHeader ){
975 for(i=0; i<nArg; i++){
976 output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1);
977 }
978 fprintf(p->out, "%s", p->rowSeparator);
979 }
980 if( nArg>0 ){
981 for(i=0; i<nArg; i++){
982 output_csv(p, azArg[i], i<nArg-1);
983 }
984 fprintf(p->out, "%s", p->rowSeparator);
985 }
986 setTextMode(p->out);
987 break;
988 }
989 case MODE_Insert: {
990 p->cnt++;
991 if( azArg==0 ) break;
992 fprintf(p->out,"INSERT INTO %s",p->zDestTable);
993 if( p->showHeader ){
994 fprintf(p->out,"(");
995 for(i=0; i<nArg; i++){
996 char *zSep = i>0 ? ",": "";
997 fprintf(p->out, "%s%s", zSep, azCol[i]);
998 }
999 fprintf(p->out,")");
1000 }
1001 fprintf(p->out," VALUES(");
1002 for(i=0; i<nArg; i++){
@@ -1006,18 +1059,18 @@
1006 }else if( aiType && aiType[i]==SQLITE_TEXT ){
1007 if( zSep[0] ) fprintf(p->out,"%s",zSep);
1008 output_quoted_string(p->out, azArg[i]);
1009 }else if( aiType && (aiType[i]==SQLITE_INTEGER
1010 || aiType[i]==SQLITE_FLOAT) ){
1011 fprintf(p->out,"%s%s",zSep, azArg[i]);
1012 }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
1013 const void *pBlob = sqlite3_column_blob(p->pStmt, i);
1014 int nBlob = sqlite3_column_bytes(p->pStmt, i);
1015 if( zSep[0] ) fprintf(p->out,"%s",zSep);
1016 output_hex_blob(p->out, pBlob, nBlob);
1017 }else if( isNumber(azArg[i], 0) ){
1018 fprintf(p->out,"%s%s",zSep, azArg[i]);
1019 }else{
1020 if( zSep[0] ) fprintf(p->out,"%s",zSep);
1021 output_quoted_string(p->out, azArg[i]);
1022 }
1023 }
@@ -1025,21 +1078,21 @@
1025 break;
1026 }
1027 case MODE_Ascii: {
1028 if( p->cnt++==0 && p->showHeader ){
1029 for(i=0; i<nArg; i++){
1030 if( i>0 ) fprintf(p->out, "%s", p->colSeparator);
1031 fprintf(p->out,"%s",azCol[i] ? azCol[i] : "");
1032 }
1033 fprintf(p->out, "%s", p->rowSeparator);
1034 }
1035 if( azArg==0 ) break;
1036 for(i=0; i<nArg; i++){
1037 if( i>0 ) fprintf(p->out, "%s", p->colSeparator);
1038 fprintf(p->out,"%s",azArg[i] ? azArg[i] : p->nullValue);
1039 }
1040 fprintf(p->out, "%s", p->rowSeparator);
1041 break;
1042 }
1043 }
1044 return 0;
1045 }
@@ -1165,17 +1218,17 @@
1165 }
1166 rc = sqlite3_step(pSelect);
1167 nResult = sqlite3_column_count(pSelect);
1168 while( rc==SQLITE_ROW ){
1169 if( zFirstRow ){
1170 fprintf(p->out, "%s", zFirstRow);
1171 zFirstRow = 0;
1172 }
1173 z = (const char*)sqlite3_column_text(pSelect, 0);
1174 fprintf(p->out, "%s", z);
1175 for(i=1; i<nResult; i++){
1176 fprintf(p->out, ",%s", sqlite3_column_text(pSelect, i));
1177 }
1178 if( z==0 ) z = "";
1179 while( z[0] && (z[0]!='-' || z[1]!='-') ) z++;
1180 if( z[0] ){
1181 fprintf(p->out, "\n;\n");
@@ -1359,11 +1412,11 @@
1359 }
1360 n++;
1361 sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit);
1362 sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EST, (void*)&rEst);
1363 sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EXPLAIN, (void*)&zExplain);
1364 fprintf(pArg->out, "Loop %2d: %s\n", n, zExplain);
1365 rEstLoop *= rEst;
1366 fprintf(pArg->out,
1367 " nLoop=%-8lld nRow=%-8lld estRow=%-8lld estRow/Loop=%-8g\n",
1368 nLoop, nVisit, (sqlite3_int64)(rEstLoop+0.5), rEst
1369 );
@@ -1520,11 +1573,11 @@
1520 }
1521
1522 /* echo the sql statement if echo on */
1523 if( pArg && pArg->echoOn ){
1524 const char *zStmtSql = sqlite3_sql(pStmt);
1525 fprintf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql);
1526 }
1527
1528 /* Show the EXPLAIN QUERY PLAN if .eqp is on */
1529 if( pArg && pArg->autoEQP ){
1530 sqlite3_stmt *pExplain;
@@ -1534,11 +1587,11 @@
1534 if( rc==SQLITE_OK ){
1535 while( sqlite3_step(pExplain)==SQLITE_ROW ){
1536 fprintf(pArg->out,"--EQP-- %d,", sqlite3_column_int(pExplain, 0));
1537 fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 1));
1538 fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 2));
1539 fprintf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3));
1540 }
1541 }
1542 sqlite3_finalize(pExplain);
1543 sqlite3_free(zEQP);
1544 }
@@ -1675,15 +1728,15 @@
1675 }
1676 zIns = sqlite3_mprintf(
1677 "INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)"
1678 "VALUES('table','%q','%q',0,'%q');",
1679 zTable, zTable, zSql);
1680 fprintf(p->out, "%s\n", zIns);
1681 sqlite3_free(zIns);
1682 return 0;
1683 }else{
1684 fprintf(p->out, "%s;\n", zSql);
1685 }
1686
1687 if( strcmp(zType, "table")==0 ){
1688 sqlite3_stmt *pTableInfo = 0;
1689 char *zSelect = 0;
@@ -2124,11 +2177,11 @@
2124 static void sql_trace_callback(void *pArg, const char *z){
2125 FILE *f = (FILE*)pArg;
2126 if( f ){
2127 int i = (int)strlen(z);
2128 while( i>0 && z[i-1]==';' ){ i--; }
2129 fprintf(f, "%.*s;\n", i, z);
2130 }
2131 }
2132
2133 /*
2134 ** A no-op routine that runs with the ".breakpoint" doc-command. This is
@@ -2607,11 +2660,11 @@
2607 }
2608 for(i=0; i<ArraySize(aQuery); i++){
2609 char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab);
2610 int val = db_int(p, zSql);
2611 sqlite3_free(zSql);
2612 fprintf(p->out, "%-20s %d\n", aQuery[i].zName, val);
2613 }
2614 sqlite3_free(zSchemaTab);
2615 return 0;
2616 }
2617
@@ -3447,11 +3500,11 @@
3447
3448 if( c=='p' && n>=3 && strncmp(azArg[0], "print", n)==0 ){
3449 int i;
3450 for(i=1; i<nArg; i++){
3451 if( i>1 ) fprintf(p->out, " ");
3452 fprintf(p->out, "%s", azArg[i]);
3453 }
3454 fprintf(p->out, "\n");
3455 }else
3456
3457 if( c=='p' && strncmp(azArg[0], "prompt", n)==0 ){
@@ -3641,20 +3694,20 @@
3641 if( c=='s' && n>=10 && strncmp(azArg[0], "selftest-", 9)==0 ){
3642 if( strncmp(azArg[0]+9, "boolean", n-9)==0 ){
3643 int i, v;
3644 for(i=1; i<nArg; i++){
3645 v = booleanValue(azArg[i]);
3646 fprintf(p->out, "%s: %d 0x%x\n", azArg[i], v, v);
3647 }
3648 }
3649 if( strncmp(azArg[0]+9, "integer", n-9)==0 ){
3650 int i; sqlite3_int64 v;
3651 for(i=1; i<nArg; i++){
3652 char zBuf[200];
3653 v = integerValue(azArg[i]);
3654 sqlite3_snprintf(sizeof(zBuf),zBuf,"%s: %lld 0x%llx\n", azArg[i],v,v);
3655 fprintf(p->out, "%s", zBuf);
3656 }
3657 }
3658 }else
3659 #endif
3660
@@ -3824,11 +3877,12 @@
3824 if( nPrintCol<1 ) nPrintCol = 1;
3825 nPrintRow = (nRow + nPrintCol - 1)/nPrintCol;
3826 for(i=0; i<nPrintRow; i++){
3827 for(j=i; j<nRow; j+=nPrintRow){
3828 char *zSp = j<nPrintRow ? "" : " ";
3829 fprintf(p->out, "%s%-*s", zSp, maxlen, azResult[j] ? azResult[j]:"");
 
3830 }
3831 fprintf(p->out, "\n");
3832 }
3833 }
3834
@@ -4545,10 +4599,11 @@
4545 setBinaryMode(stdin);
4546 setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */
4547 Argv0 = argv[0];
4548 main_init(&data);
4549 stdin_is_interactive = isatty(0);
 
4550
4551 /* Make sure we have a valid signal handler early, before anything
4552 ** else is done.
4553 */
4554 #ifdef SIGINT
4555
--- src/shell.c
+++ src/shell.c
@@ -327,10 +327,17 @@
327 ** Threat stdin as an interactive input if the following variable
328 ** is true. Otherwise, assume stdin is connected to a file or pipe.
329 */
330 static int stdin_is_interactive = 1;
331
332 /*
333 ** On Windows systems we have to know if standard output is a console
334 ** in order to translate UTF-8 into MBCS. The following variable is
335 ** true if translation is required.
336 */
337 static int stdout_is_console = 1;
338
339 /*
340 ** The following is the open SQLite database. We make a pointer
341 ** to this database a static variable so that it can be accessed
342 ** by the SIGINT handler to interrupt database processing.
343 */
@@ -427,10 +434,20 @@
434 UNUSED_PARAMETER(argc);
435 UNUSED_PARAMETER(argv);
436 sqlite3_result_text(context, zShellStatic, -1, SQLITE_STATIC);
437 }
438
439
440 /*
441 ** Compute a string length that is limited to what can be stored in
442 ** lower 30 bits of a 32-bit signed integer.
443 */
444 static int strlen30(const char *z){
445 const char *z2 = z;
446 while( *z2 ){ z2++; }
447 return 0x3fffffff & (int)(z2 - z);
448 }
449
450 /*
451 ** This routine reads a line of text from FILE in, stores
452 ** the text in memory obtained from malloc() and returns a pointer
453 ** to the text. NULL is returned at end of file, or if malloc()
@@ -463,10 +480,30 @@
480 if( n>0 && zLine[n-1]=='\r' ) n--;
481 zLine[n] = 0;
482 break;
483 }
484 }
485 #if defined(_WIN32) || defined(WIN32)
486 /* For interactive input on Windows systems, translate the
487 ** multi-byte characterset characters into UTF-8. */
488 if( stdin_is_interactive ){
489 extern char *sqlite3_win32_mbcs_to_utf8(const char*);
490 char *zTrans = sqlite3_win32_mbcs_to_utf8(zLine);
491 if( zTrans ){
492 int nTrans = strlen30(zTrans)+1;
493 if( nTrans>nLine ){
494 zLine = realloc(zLine, nTrans);
495 if( zLine==0 ){
496 sqlite3_free(zTrans);
497 return 0;
498 }
499 }
500 memcpy(zLine, zTrans, nTrans);
501 sqlite3_free(zTrans);
502 }
503 }
504 #endif /* defined(_WIN32) || defined(WIN32) */
505 return zLine;
506 }
507
508 /*
509 ** Retrieve a single line of input text.
@@ -500,10 +537,35 @@
537 #endif
538 }
539 return zResult;
540 }
541
542 /*
543 ** Render output like fprintf(). Except, if the output is going to the
544 ** console and if this is running on a Windows machine, translate the
545 ** output from UTF-8 into MBCS.
546 */
547 #if defined(_WIN32) || defined(WIN32)
548 void utf8_printf(FILE *out, const char *zFormat, ...){
549 va_list ap;
550 va_start(ap, zFormat);
551 if( stdout_is_console && out==stdout ){
552 extern char *sqlite3_win32_utf8_to_mbcs(const char*);
553 char *z1 = sqlite3_vmprintf(zFormat, ap);
554 char *z2 = sqlite3_win32_utf8_to_mbcs(z1);
555 sqlite3_free(z1);
556 fputs(z2, out);
557 sqlite3_free(z2);
558 }else{
559 vfprintf(out, zFormat, ap);
560 }
561 va_end(ap);
562 }
563 #else
564 # define utf8_printf fprintf
565 #endif
566
567 /*
568 ** Shell output mode information from before ".explain on",
569 ** saved so that it can be restored by ".explain off"
570 */
571 typedef struct SavedModeInfo SavedModeInfo;
@@ -605,20 +667,10 @@
667 /*
668 ** Number of elements in an array
669 */
670 #define ArraySize(X) (int)(sizeof(X)/sizeof(X[0]))
671
 
 
 
 
 
 
 
 
 
 
672 /*
673 ** A callback for the sqlite3_log() interface.
674 */
675 static void shellLog(void *pArg, int iErrCode, const char *zMsg){
676 ShellState *p = (ShellState*)pArg;
@@ -647,23 +699,23 @@
699 setBinaryMode(out);
700 for(i=0; z[i]; i++){
701 if( z[i]=='\'' ) nSingle++;
702 }
703 if( nSingle==0 ){
704 utf8_printf(out,"'%s'",z);
705 }else{
706 fprintf(out,"'");
707 while( *z ){
708 for(i=0; z[i] && z[i]!='\''; i++){}
709 if( i==0 ){
710 fprintf(out,"''");
711 z++;
712 }else if( z[i]=='\'' ){
713 utf8_printf(out,"%.*s''",i,z);
714 z += i+1;
715 }else{
716 utf8_printf(out,"%s",z);
717 break;
718 }
719 }
720 fprintf(out,"'");
721 }
@@ -715,11 +767,11 @@
767 && z[i]!='>'
768 && z[i]!='\"'
769 && z[i]!='\'';
770 i++){}
771 if( i>0 ){
772 utf8_printf(out,"%.*s",i,z);
773 }
774 if( z[i]=='<' ){
775 fprintf(out,"&lt;");
776 }else if( z[i]=='&' ){
777 fprintf(out,"&amp;");
@@ -766,11 +818,11 @@
818 ** is only issued if bSep is true.
819 */
820 static void output_csv(ShellState *p, const char *z, int bSep){
821 FILE *out = p->out;
822 if( z==0 ){
823 utf8_printf(out,"%s",p->nullValue);
824 }else{
825 int i;
826 int nSep = strlen30(p->colSeparator);
827 for(i=0; z[i]; i++){
828 if( needCsvQuote[((unsigned char*)z)[i]]
@@ -786,15 +838,15 @@
838 if( z[i]=='"' ) putc('"', out);
839 putc(z[i], out);
840 }
841 putc('"', out);
842 }else{
843 utf8_printf(out, "%s", z);
844 }
845 }
846 if( bSep ){
847 utf8_printf(p->out, "%s", p->colSeparator);
848 }
849 }
850
851 #ifdef SIGINT
852 /*
@@ -828,13 +880,13 @@
880 if( azArg==0 ) break;
881 for(i=0; i<nArg; i++){
882 int len = strlen30(azCol[i] ? azCol[i] : "");
883 if( len>w ) w = len;
884 }
885 if( p->cnt++>0 ) utf8_printf(p->out, "%s", p->rowSeparator);
886 for(i=0; i<nArg; i++){
887 utf8_printf(p->out,"%*s = %s%s", w, azCol[i],
888 azArg[i] ? azArg[i] : p->nullValue, p->rowSeparator);
889 }
890 break;
891 }
892 case MODE_Explain:
@@ -856,14 +908,14 @@
908 if( i<ArraySize(p->actualWidth) ){
909 p->actualWidth[i] = w;
910 }
911 if( p->showHeader ){
912 if( w<0 ){
913 utf8_printf(p->out,"%*.*s%s",-w,-w,azCol[i],
914 i==nArg-1 ? p->rowSeparator : " ");
915 }else{
916 utf8_printf(p->out,"%-*.*s%s",w,w,azCol[i],
917 i==nArg-1 ? p->rowSeparator : " ");
918 }
919 }
920 }
921 if( p->showHeader ){
@@ -873,11 +925,12 @@
925 w = p->actualWidth[i];
926 if( w<0 ) w = -w;
927 }else{
928 w = 10;
929 }
930 fprintf(p->out,"%-*.*s%s",w,w,
931 "----------------------------------------------------------"
932 "----------------------------------------------------------",
933 i==nArg-1 ? p->rowSeparator : " ");
934 }
935 }
936 }
@@ -897,15 +950,15 @@
950 fprintf(p->out, "%*.s", p->aiIndent[p->iIndent], "");
951 }
952 p->iIndent++;
953 }
954 if( w<0 ){
955 utf8_printf(p->out,"%*.*s%s",-w,-w,
956 azArg[i] ? azArg[i] : p->nullValue,
957 i==nArg-1 ? p->rowSeparator : " ");
958 }else{
959 utf8_printf(p->out,"%-*.*s%s",w,w,
960 azArg[i] ? azArg[i] : p->nullValue,
961 i==nArg-1 ? p->rowSeparator : " ");
962 }
963 }
964 break;
@@ -912,25 +965,25 @@
965 }
966 case MODE_Semi:
967 case MODE_List: {
968 if( p->cnt++==0 && p->showHeader ){
969 for(i=0; i<nArg; i++){
970 utf8_printf(p->out,"%s%s",azCol[i],
971 i==nArg-1 ? p->rowSeparator : p->colSeparator);
972 }
973 }
974 if( azArg==0 ) break;
975 for(i=0; i<nArg; i++){
976 char *z = azArg[i];
977 if( z==0 ) z = p->nullValue;
978 utf8_printf(p->out, "%s", z);
979 if( i<nArg-1 ){
980 utf8_printf(p->out, "%s", p->colSeparator);
981 }else if( p->mode==MODE_Semi ){
982 utf8_printf(p->out, ";%s", p->rowSeparator);
983 }else{
984 utf8_printf(p->out, "%s", p->rowSeparator);
985 }
986 }
987 break;
988 }
989 case MODE_Html: {
@@ -955,48 +1008,48 @@
1008 }
1009 case MODE_Tcl: {
1010 if( p->cnt++==0 && p->showHeader ){
1011 for(i=0; i<nArg; i++){
1012 output_c_string(p->out,azCol[i] ? azCol[i] : "");
1013 if(i<nArg-1) utf8_printf(p->out, "%s", p->colSeparator);
1014 }
1015 utf8_printf(p->out, "%s", p->rowSeparator);
1016 }
1017 if( azArg==0 ) break;
1018 for(i=0; i<nArg; i++){
1019 output_c_string(p->out, azArg[i] ? azArg[i] : p->nullValue);
1020 if(i<nArg-1) utf8_printf(p->out, "%s", p->colSeparator);
1021 }
1022 utf8_printf(p->out, "%s", p->rowSeparator);
1023 break;
1024 }
1025 case MODE_Csv: {
1026 setBinaryMode(p->out);
1027 if( p->cnt++==0 && p->showHeader ){
1028 for(i=0; i<nArg; i++){
1029 output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1);
1030 }
1031 utf8_printf(p->out, "%s", p->rowSeparator);
1032 }
1033 if( nArg>0 ){
1034 for(i=0; i<nArg; i++){
1035 output_csv(p, azArg[i], i<nArg-1);
1036 }
1037 utf8_printf(p->out, "%s", p->rowSeparator);
1038 }
1039 setTextMode(p->out);
1040 break;
1041 }
1042 case MODE_Insert: {
1043 p->cnt++;
1044 if( azArg==0 ) break;
1045 utf8_printf(p->out,"INSERT INTO %s",p->zDestTable);
1046 if( p->showHeader ){
1047 fprintf(p->out,"(");
1048 for(i=0; i<nArg; i++){
1049 char *zSep = i>0 ? ",": "";
1050 utf8_printf(p->out, "%s%s", zSep, azCol[i]);
1051 }
1052 fprintf(p->out,")");
1053 }
1054 fprintf(p->out," VALUES(");
1055 for(i=0; i<nArg; i++){
@@ -1006,18 +1059,18 @@
1059 }else if( aiType && aiType[i]==SQLITE_TEXT ){
1060 if( zSep[0] ) fprintf(p->out,"%s",zSep);
1061 output_quoted_string(p->out, azArg[i]);
1062 }else if( aiType && (aiType[i]==SQLITE_INTEGER
1063 || aiType[i]==SQLITE_FLOAT) ){
1064 utf8_printf(p->out,"%s%s",zSep, azArg[i]);
1065 }else if( aiType && aiType[i]==SQLITE_BLOB && p->pStmt ){
1066 const void *pBlob = sqlite3_column_blob(p->pStmt, i);
1067 int nBlob = sqlite3_column_bytes(p->pStmt, i);
1068 if( zSep[0] ) fprintf(p->out,"%s",zSep);
1069 output_hex_blob(p->out, pBlob, nBlob);
1070 }else if( isNumber(azArg[i], 0) ){
1071 utf8_printf(p->out,"%s%s",zSep, azArg[i]);
1072 }else{
1073 if( zSep[0] ) fprintf(p->out,"%s",zSep);
1074 output_quoted_string(p->out, azArg[i]);
1075 }
1076 }
@@ -1025,21 +1078,21 @@
1078 break;
1079 }
1080 case MODE_Ascii: {
1081 if( p->cnt++==0 && p->showHeader ){
1082 for(i=0; i<nArg; i++){
1083 if( i>0 ) utf8_printf(p->out, "%s", p->colSeparator);
1084 utf8_printf(p->out,"%s",azCol[i] ? azCol[i] : "");
1085 }
1086 utf8_printf(p->out, "%s", p->rowSeparator);
1087 }
1088 if( azArg==0 ) break;
1089 for(i=0; i<nArg; i++){
1090 if( i>0 ) utf8_printf(p->out, "%s", p->colSeparator);
1091 utf8_printf(p->out,"%s",azArg[i] ? azArg[i] : p->nullValue);
1092 }
1093 utf8_printf(p->out, "%s", p->rowSeparator);
1094 break;
1095 }
1096 }
1097 return 0;
1098 }
@@ -1165,17 +1218,17 @@
1218 }
1219 rc = sqlite3_step(pSelect);
1220 nResult = sqlite3_column_count(pSelect);
1221 while( rc==SQLITE_ROW ){
1222 if( zFirstRow ){
1223 utf8_printf(p->out, "%s", zFirstRow);
1224 zFirstRow = 0;
1225 }
1226 z = (const char*)sqlite3_column_text(pSelect, 0);
1227 utf8_printf(p->out, "%s", z);
1228 for(i=1; i<nResult; i++){
1229 utf8_printf(p->out, ",%s", sqlite3_column_text(pSelect, i));
1230 }
1231 if( z==0 ) z = "";
1232 while( z[0] && (z[0]!='-' || z[1]!='-') ) z++;
1233 if( z[0] ){
1234 fprintf(p->out, "\n;\n");
@@ -1359,11 +1412,11 @@
1412 }
1413 n++;
1414 sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_NVISIT, (void*)&nVisit);
1415 sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EST, (void*)&rEst);
1416 sqlite3_stmt_scanstatus(p, i, SQLITE_SCANSTAT_EXPLAIN, (void*)&zExplain);
1417 utf8_printf(pArg->out, "Loop %2d: %s\n", n, zExplain);
1418 rEstLoop *= rEst;
1419 fprintf(pArg->out,
1420 " nLoop=%-8lld nRow=%-8lld estRow=%-8lld estRow/Loop=%-8g\n",
1421 nLoop, nVisit, (sqlite3_int64)(rEstLoop+0.5), rEst
1422 );
@@ -1520,11 +1573,11 @@
1573 }
1574
1575 /* echo the sql statement if echo on */
1576 if( pArg && pArg->echoOn ){
1577 const char *zStmtSql = sqlite3_sql(pStmt);
1578 utf8_printf(pArg->out, "%s\n", zStmtSql ? zStmtSql : zSql);
1579 }
1580
1581 /* Show the EXPLAIN QUERY PLAN if .eqp is on */
1582 if( pArg && pArg->autoEQP ){
1583 sqlite3_stmt *pExplain;
@@ -1534,11 +1587,11 @@
1587 if( rc==SQLITE_OK ){
1588 while( sqlite3_step(pExplain)==SQLITE_ROW ){
1589 fprintf(pArg->out,"--EQP-- %d,", sqlite3_column_int(pExplain, 0));
1590 fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 1));
1591 fprintf(pArg->out,"%d,", sqlite3_column_int(pExplain, 2));
1592 utf8_printf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3));
1593 }
1594 }
1595 sqlite3_finalize(pExplain);
1596 sqlite3_free(zEQP);
1597 }
@@ -1675,15 +1728,15 @@
1728 }
1729 zIns = sqlite3_mprintf(
1730 "INSERT INTO sqlite_master(type,name,tbl_name,rootpage,sql)"
1731 "VALUES('table','%q','%q',0,'%q');",
1732 zTable, zTable, zSql);
1733 utf8_printf(p->out, "%s\n", zIns);
1734 sqlite3_free(zIns);
1735 return 0;
1736 }else{
1737 utf8_printf(p->out, "%s;\n", zSql);
1738 }
1739
1740 if( strcmp(zType, "table")==0 ){
1741 sqlite3_stmt *pTableInfo = 0;
1742 char *zSelect = 0;
@@ -2124,11 +2177,11 @@
2177 static void sql_trace_callback(void *pArg, const char *z){
2178 FILE *f = (FILE*)pArg;
2179 if( f ){
2180 int i = (int)strlen(z);
2181 while( i>0 && z[i-1]==';' ){ i--; }
2182 utf8_printf(f, "%.*s;\n", i, z);
2183 }
2184 }
2185
2186 /*
2187 ** A no-op routine that runs with the ".breakpoint" doc-command. This is
@@ -2607,11 +2660,11 @@
2660 }
2661 for(i=0; i<ArraySize(aQuery); i++){
2662 char *zSql = sqlite3_mprintf(aQuery[i].zSql, zSchemaTab);
2663 int val = db_int(p, zSql);
2664 sqlite3_free(zSql);
2665 utf8_printf(p->out, "%-20s %d\n", aQuery[i].zName, val);
2666 }
2667 sqlite3_free(zSchemaTab);
2668 return 0;
2669 }
2670
@@ -3447,11 +3500,11 @@
3500
3501 if( c=='p' && n>=3 && strncmp(azArg[0], "print", n)==0 ){
3502 int i;
3503 for(i=1; i<nArg; i++){
3504 if( i>1 ) fprintf(p->out, " ");
3505 utf8_printf(p->out, "%s", azArg[i]);
3506 }
3507 fprintf(p->out, "\n");
3508 }else
3509
3510 if( c=='p' && strncmp(azArg[0], "prompt", n)==0 ){
@@ -3641,20 +3694,20 @@
3694 if( c=='s' && n>=10 && strncmp(azArg[0], "selftest-", 9)==0 ){
3695 if( strncmp(azArg[0]+9, "boolean", n-9)==0 ){
3696 int i, v;
3697 for(i=1; i<nArg; i++){
3698 v = booleanValue(azArg[i]);
3699 utf8_printf(p->out, "%s: %d 0x%x\n", azArg[i], v, v);
3700 }
3701 }
3702 if( strncmp(azArg[0]+9, "integer", n-9)==0 ){
3703 int i; sqlite3_int64 v;
3704 for(i=1; i<nArg; i++){
3705 char zBuf[200];
3706 v = integerValue(azArg[i]);
3707 sqlite3_snprintf(sizeof(zBuf),zBuf,"%s: %lld 0x%llx\n", azArg[i],v,v);
3708 utf8_printf(p->out, "%s", zBuf);
3709 }
3710 }
3711 }else
3712 #endif
3713
@@ -3824,11 +3877,12 @@
3877 if( nPrintCol<1 ) nPrintCol = 1;
3878 nPrintRow = (nRow + nPrintCol - 1)/nPrintCol;
3879 for(i=0; i<nPrintRow; i++){
3880 for(j=i; j<nRow; j+=nPrintRow){
3881 char *zSp = j<nPrintRow ? "" : " ";
3882 utf8_printf(p->out, "%s%-*s", zSp, maxlen,
3883 azResult[j] ? azResult[j]:"");
3884 }
3885 fprintf(p->out, "\n");
3886 }
3887 }
3888
@@ -4545,10 +4599,11 @@
4599 setBinaryMode(stdin);
4600 setvbuf(stderr, 0, _IONBF, 0); /* Make sure stderr is unbuffered */
4601 Argv0 = argv[0];
4602 main_init(&data);
4603 stdin_is_interactive = isatty(0);
4604 stdout_is_console = isatty(1);
4605
4606 /* Make sure we have a valid signal handler early, before anything
4607 ** else is done.
4608 */
4609 #ifdef SIGINT
4610
+176 -80
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -325,11 +325,11 @@
325325
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
326326
** [sqlite_version()] and [sqlite_source_id()].
327327
*/
328328
#define SQLITE_VERSION "3.10.0"
329329
#define SQLITE_VERSION_NUMBER 3010000
330
-#define SQLITE_SOURCE_ID "2015-12-24 14:53:27 7c7b7f26306b6aa6ff35b871ad756f43f5db9838"
330
+#define SQLITE_SOURCE_ID "2015-12-31 15:34:03 9c392c1019ee15f27c8e05b41246d2844f91f6c0"
331331
332332
/*
333333
** CAPI3REF: Run-Time Library Version Numbers
334334
** KEYWORDS: sqlite3_version, sqlite3_sourceid
335335
**
@@ -12317,11 +12317,11 @@
1231712317
char *zDflt; /* Original text of the default value */
1231812318
char *zType; /* Data type for this column */
1231912319
char *zColl; /* Collating sequence. If NULL, use the default */
1232012320
u8 notNull; /* An OE_ code for handling a NOT NULL constraint */
1232112321
char affinity; /* One of the SQLITE_AFF_... values */
12322
- u8 szEst; /* Estimated size of this column. INT==1 */
12322
+ u8 szEst; /* Estimated size of value in this column. sizeof(INT)==1 */
1232312323
u8 colFlags; /* Boolean properties. See COLFLAG_ defines below */
1232412324
};
1232512325
1232612326
/* Allowed values for Column.colFlags:
1232712327
*/
@@ -12727,11 +12727,11 @@
1272712727
Table *pTable; /* The SQL table being indexed */
1272812728
char *zColAff; /* String defining the affinity of each column */
1272912729
Index *pNext; /* The next index associated with the same table */
1273012730
Schema *pSchema; /* Schema containing this index */
1273112731
u8 *aSortOrder; /* for each column: True==DESC, False==ASC */
12732
- char **azColl; /* Array of collation sequence names for index */
12732
+ const char **azColl; /* Array of collation sequence names for index */
1273312733
Expr *pPartIdxWhere; /* WHERE clause for partial indices */
1273412734
ExprList *aColExpr; /* Column expressions */
1273512735
int tnum; /* DB Page containing root of this index */
1273612736
LogEst szIdxRow; /* Estimated average row size in bytes */
1273712737
u16 nKeyCol; /* Number of columns forming the key */
@@ -14143,11 +14143,15 @@
1414314143
SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);
1414414144
SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);
1414514145
SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
1414614146
SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16);
1414714147
SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
14148
-SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table*, Column*);
14148
+#if SQLITE_ENABLE_HIDDEN_COLUMNS
14149
+SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table*, Column*);
14150
+#else
14151
+# define sqlite3ColumnPropertiesFromName(T,C) /* no-op */
14152
+#endif
1414914153
SQLITE_PRIVATE void sqlite3AddColumn(Parse*,Token*);
1415014154
SQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int);
1415114155
SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
1415214156
SQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*);
1415314157
SQLITE_PRIVATE void sqlite3AddColumnType(Parse*,Token*);
@@ -14494,10 +14498,11 @@
1449414498
SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8);
1449514499
SQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);
1449614500
SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
1449714501
#ifndef SQLITE_AMALGAMATION
1449814502
SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[];
14503
+SQLITE_PRIVATE const char sqlite3StrBINARY[];
1449914504
SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[];
1450014505
SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[];
1450114506
SQLITE_PRIVATE const Token sqlite3IntTokens[];
1450214507
SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config;
1450314508
SQLITE_PRIVATE SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;
@@ -15099,10 +15104,15 @@
1509915104
** from the comments following the "case OP_xxxx:" statements in
1510015105
** the vdbe.c file.
1510115106
*/
1510215107
SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;
1510315108
15109
+/*
15110
+** Name of the default collating sequence
15111
+*/
15112
+SQLITE_PRIVATE const char sqlite3StrBINARY[] = "BINARY";
15113
+
1510415114
/************** End of global.c **********************************************/
1510515115
/************** Begin file ctime.c *******************************************/
1510615116
/*
1510715117
** 2010 February 23
1510815118
**
@@ -54551,11 +54561,10 @@
5455154561
struct CellInfo {
5455254562
i64 nKey; /* The key for INTKEY tables, or nPayload otherwise */
5455354563
u8 *pPayload; /* Pointer to the start of payload */
5455454564
u32 nPayload; /* Bytes of payload */
5455554565
u16 nLocal; /* Amount of payload held locally, not on overflow */
54556
- u16 iOverflow; /* Offset to overflow page number. Zero if no overflow */
5455754566
u16 nSize; /* Size of the cell content on the main b-tree page */
5455854567
};
5455954568
5456054569
/*
5456154570
** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than
@@ -56132,12 +56141,11 @@
5613256141
if( surplus <= maxLocal ){
5613356142
pInfo->nLocal = (u16)surplus;
5613456143
}else{
5613556144
pInfo->nLocal = (u16)minLocal;
5613656145
}
56137
- pInfo->iOverflow = (u16)(&pInfo->pPayload[pInfo->nLocal] - pCell);
56138
- pInfo->nSize = pInfo->iOverflow + 4;
56146
+ pInfo->nSize = (u16)(&pInfo->pPayload[pInfo->nLocal] - pCell) + 4;
5613956147
}
5614056148
5614156149
/*
5614256150
** The following routines are implementations of the MemPage.xParseCell()
5614356151
** method.
@@ -56165,11 +56173,10 @@
5616556173
UNUSED_PARAMETER(pPage);
5616656174
#endif
5616756175
pInfo->nSize = 4 + getVarint(&pCell[4], (u64*)&pInfo->nKey);
5616856176
pInfo->nPayload = 0;
5616956177
pInfo->nLocal = 0;
56170
- pInfo->iOverflow = 0;
5617156178
pInfo->pPayload = 0;
5617256179
return;
5617356180
}
5617456181
static void btreeParseCellPtr(
5617556182
MemPage *pPage, /* Page containing the cell */
@@ -56235,11 +56242,10 @@
5623556242
** on the local page. No overflow is required.
5623656243
*/
5623756244
pInfo->nSize = nPayload + (u16)(pIter - pCell);
5623856245
if( pInfo->nSize<4 ) pInfo->nSize = 4;
5623956246
pInfo->nLocal = (u16)nPayload;
56240
- pInfo->iOverflow = 0;
5624156247
}else{
5624256248
btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo);
5624356249
}
5624456250
}
5624556251
static void btreeParseCellPtrIndex(
@@ -56274,11 +56280,10 @@
5627456280
** on the local page. No overflow is required.
5627556281
*/
5627656282
pInfo->nSize = nPayload + (u16)(pIter - pCell);
5627756283
if( pInfo->nSize<4 ) pInfo->nSize = 4;
5627856284
pInfo->nLocal = (u16)nPayload;
56279
- pInfo->iOverflow = 0;
5628056285
}else{
5628156286
btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo);
5628256287
}
5628356288
}
5628456289
static void btreeParseCell(
@@ -56390,12 +56395,12 @@
5639056395
static void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){
5639156396
CellInfo info;
5639256397
if( *pRC ) return;
5639356398
assert( pCell!=0 );
5639456399
pPage->xParseCell(pPage, pCell, &info);
56395
- if( info.iOverflow ){
56396
- Pgno ovfl = get4byte(&pCell[info.iOverflow]);
56400
+ if( info.nLocal<info.nPayload ){
56401
+ Pgno ovfl = get4byte(&pCell[info.nSize-4]);
5639756402
ptrmapPut(pPage->pBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, pRC);
5639856403
}
5639956404
}
5640056405
#endif
5640156406
@@ -58429,15 +58434,15 @@
5842958434
for(i=0; i<nCell; i++){
5843058435
u8 *pCell = findCell(pPage, i);
5843158436
if( eType==PTRMAP_OVERFLOW1 ){
5843258437
CellInfo info;
5843358438
pPage->xParseCell(pPage, pCell, &info);
58434
- if( info.iOverflow
58435
- && pCell+info.iOverflow+3<=pPage->aData+pPage->maskPage
58436
- && iFrom==get4byte(&pCell[info.iOverflow])
58439
+ if( info.nLocal<info.nPayload
58440
+ && pCell+info.nSize-1<=pPage->aData+pPage->maskPage
58441
+ && iFrom==get4byte(pCell+info.nSize-4)
5843758442
){
58438
- put4byte(&pCell[info.iOverflow], iTo);
58443
+ put4byte(pCell+info.nSize-4, iTo);
5843958444
break;
5844058445
}
5844158446
}else{
5844258447
if( get4byte(pCell)==iFrom ){
5844358448
put4byte(pCell, iTo);
@@ -61075,17 +61080,17 @@
6107561080
u32 ovflPageSize;
6107661081
6107761082
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
6107861083
pPage->xParseCell(pPage, pCell, &info);
6107961084
*pnSize = info.nSize;
61080
- if( info.iOverflow==0 ){
61085
+ if( info.nLocal==info.nPayload ){
6108161086
return SQLITE_OK; /* No overflow pages. Return without doing anything */
6108261087
}
61083
- if( pCell+info.iOverflow+3 > pPage->aData+pPage->maskPage ){
61088
+ if( pCell+info.nSize-1 > pPage->aData+pPage->maskPage ){
6108461089
return SQLITE_CORRUPT_BKPT; /* Cell extends past end of page */
6108561090
}
61086
- ovflPgno = get4byte(&pCell[info.iOverflow]);
61091
+ ovflPgno = get4byte(pCell + info.nSize - 4);
6108761092
assert( pBt->usableSize > 4 );
6108861093
ovflPageSize = pBt->usableSize - 4;
6108961094
nOvfl = (info.nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize;
6109061095
assert( nOvfl>0 ||
6109161096
(CORRUPT_DB && (info.nPayload + ovflPageSize)<ovflPageSize)
@@ -61230,11 +61235,10 @@
6123061235
pPage->xParseCell(pPage, pCell, &info);
6123161236
assert( nHeader=(int)(info.pPayload - pCell) );
6123261237
assert( info.nKey==nKey );
6123361238
assert( *pnSize == info.nSize );
6123461239
assert( spaceLeft == info.nLocal );
61235
- assert( pPrior == &pCell[info.iOverflow] );
6123661240
}
6123761241
#endif
6123861242
6123961243
/* Write the payload into the local Cell and any extra into overflow pages */
6124061244
while( nPayload>0 ){
@@ -61940,12 +61944,12 @@
6194061944
CellInfo info;
6194161945
u8 *z;
6194261946
6194361947
z = findCell(pPage, j);
6194461948
pPage->xParseCell(pPage, z, &info);
61945
- if( info.iOverflow ){
61946
- Pgno ovfl = get4byte(&z[info.iOverflow]);
61949
+ if( info.nLocal<info.nPayload ){
61950
+ Pgno ovfl = get4byte(&z[info.nSize-4]);
6194761951
ptrmapGet(pBt, ovfl, &e, &n);
6194861952
assert( n==pPage->pgno && e==PTRMAP_OVERFLOW1 );
6194961953
}
6195061954
if( !pPage->leaf ){
6195161955
Pgno child = get4byte(z);
@@ -64247,13 +64251,13 @@
6424764251
6424864252
/* Check the content overflow list */
6424964253
if( info.nPayload>info.nLocal ){
6425064254
int nPage; /* Number of pages on the overflow chain */
6425164255
Pgno pgnoOvfl; /* First page of the overflow chain */
64252
- assert( pc + info.iOverflow <= usableSize );
64256
+ assert( pc + info.nSize - 4 <= usableSize );
6425364257
nPage = (info.nPayload - info.nLocal + usableSize - 5)/(usableSize - 4);
64254
- pgnoOvfl = get4byte(&pCell[info.iOverflow]);
64258
+ pgnoOvfl = get4byte(&pCell[info.nSize - 4]);
6425564259
#ifndef SQLITE_OMIT_AUTOVACUUM
6425664260
if( pBt->autoVacuum ){
6425764261
checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage);
6425864262
}
6425964263
#endif
@@ -71031,11 +71035,11 @@
7103171035
}
7103271036
if( (f2 & MEM_Str)==0 ){
7103371037
return -1;
7103471038
}
7103571039
71036
- assert( pMem1->enc==pMem2->enc );
71040
+ assert( pMem1->enc==pMem2->enc || pMem1->db->mallocFailed );
7103771041
assert( pMem1->enc==SQLITE_UTF8 ||
7103871042
pMem1->enc==SQLITE_UTF16LE || pMem1->enc==SQLITE_UTF16BE );
7103971043
7104071044
/* The collation sequence must be defined at this point, even if
7104171045
** the user deletes the collation sequence after the vdbe program is
@@ -75667,42 +75671,41 @@
7566775671
}
7566875672
}else{
7566975673
/* Neither operand is NULL. Do a comparison. */
7567075674
affinity = pOp->p5 & SQLITE_AFF_MASK;
7567175675
if( affinity>=SQLITE_AFF_NUMERIC ){
75672
- if( (pIn1->flags & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
75676
+ if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
7567375677
applyNumericAffinity(pIn1,0);
7567475678
}
75675
- if( (pIn3->flags & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
75679
+ if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
7567675680
applyNumericAffinity(pIn3,0);
7567775681
}
7567875682
}else if( affinity==SQLITE_AFF_TEXT ){
75679
- if( (pIn1->flags & MEM_Str)==0 && (pIn1->flags & (MEM_Int|MEM_Real))!=0 ){
75683
+ if( (flags1 & MEM_Str)==0 && (flags1 & (MEM_Int|MEM_Real))!=0 ){
7568075684
testcase( pIn1->flags & MEM_Int );
7568175685
testcase( pIn1->flags & MEM_Real );
7568275686
sqlite3VdbeMemStringify(pIn1, encoding, 1);
7568375687
testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
7568475688
flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
7568575689
}
75686
- if( (pIn3->flags & MEM_Str)==0 && (pIn3->flags & (MEM_Int|MEM_Real))!=0 ){
75690
+ if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){
7568775691
testcase( pIn3->flags & MEM_Int );
7568875692
testcase( pIn3->flags & MEM_Real );
7568975693
sqlite3VdbeMemStringify(pIn3, encoding, 1);
7569075694
testcase( (flags3&MEM_Dyn) != (pIn3->flags&MEM_Dyn) );
7569175695
flags3 = (pIn3->flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask);
7569275696
}
7569375697
}
7569475698
assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
75695
- if( pIn1->flags & MEM_Zero ){
75699
+ if( flags1 & MEM_Zero ){
7569675700
sqlite3VdbeMemExpandBlob(pIn1);
7569775701
flags1 &= ~MEM_Zero;
7569875702
}
75699
- if( pIn3->flags & MEM_Zero ){
75703
+ if( flags3 & MEM_Zero ){
7570075704
sqlite3VdbeMemExpandBlob(pIn3);
7570175705
flags3 &= ~MEM_Zero;
7570275706
}
75703
- if( db->mallocFailed ) goto no_mem;
7570475707
res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
7570575708
}
7570675709
switch( pOp->opcode ){
7570775710
case OP_Eq: res = res==0; break;
7570875711
case OP_Ne: res = res!=0; break;
@@ -94733,19 +94736,19 @@
9473394736
}
9473494737
9473594738
/* Set properties of a table column based on the (magical)
9473694739
** name of the column.
9473794740
*/
94738
-SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){
9473994741
#if SQLITE_ENABLE_HIDDEN_COLUMNS
94742
+SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){
9474094743
if( sqlite3_strnicmp(pCol->zName, "__hidden__", 10)==0 ){
9474194744
pCol->colFlags |= COLFLAG_HIDDEN;
9474294745
}else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){
9474394746
pTab->tabFlags |= TF_OOOHidden;
9474494747
}
94748
+}
9474594749
#endif
94746
-}
9474794750
9474894751
9474994752
/*
9475094753
** Add a new column to the table currently being constructed.
9475194754
**
@@ -95321,11 +95324,11 @@
9532195324
assert( pIdx->isResized==0 );
9532295325
nByte = (sizeof(char*) + sizeof(i16) + 1)*N;
9532395326
zExtra = sqlite3DbMallocZero(db, nByte);
9532495327
if( zExtra==0 ) return SQLITE_NOMEM;
9532595328
memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn);
95326
- pIdx->azColl = (char**)zExtra;
95329
+ pIdx->azColl = (const char**)zExtra;
9532795330
zExtra += sizeof(char*)*N;
9532895331
memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn);
9532995332
pIdx->aiColumn = (i16*)zExtra;
9533095333
zExtra += sizeof(i16)*N;
9533195334
memcpy(zExtra, pIdx->aSortOrder, pIdx->nColumn);
@@ -95502,11 +95505,11 @@
9550295505
if( resizeIndexObject(db, pPk, pTab->nCol) ) return;
9550395506
for(i=0, j=nPk; i<pTab->nCol; i++){
9550495507
if( !hasColumn(pPk->aiColumn, j, i) ){
9550595508
assert( j<pPk->nColumn );
9550695509
pPk->aiColumn[j] = i;
95507
- pPk->azColl[j] = "BINARY";
95510
+ pPk->azColl[j] = sqlite3StrBINARY;
9550895511
j++;
9550995512
}
9551095513
}
9551195514
assert( pPk->nColumn==j );
9551295515
assert( pTab->nCol==j );
@@ -96552,11 +96555,11 @@
9655296555
sizeof(i16)*nCol + /* Index.aiColumn */
9655396556
sizeof(u8)*nCol); /* Index.aSortOrder */
9655496557
p = sqlite3DbMallocZero(db, nByte + nExtra);
9655596558
if( p ){
9655696559
char *pExtra = ((char*)p)+ROUND8(sizeof(Index));
96557
- p->azColl = (char**)pExtra; pExtra += ROUND8(sizeof(char*)*nCol);
96560
+ p->azColl = (const char**)pExtra; pExtra += ROUND8(sizeof(char*)*nCol);
9655896561
p->aiRowLogEst = (LogEst*)pExtra; pExtra += sizeof(LogEst)*(nCol+1);
9655996562
p->aiColumn = (i16*)pExtra; pExtra += sizeof(i16)*nCol;
9656096563
p->aSortOrder = (u8*)pExtra;
9656196564
p->nColumn = nCol;
9656296565
p->nKeyCol = nCol - 1;
@@ -96829,11 +96832,11 @@
9682996832
** index key.
9683096833
*/
9683196834
for(i=0, pListItem=pList->a; i<pList->nExpr; i++, pListItem++){
9683296835
Expr *pCExpr; /* The i-th index expression */
9683396836
int requestedSortOrder; /* ASC or DESC on the i-th expression */
96834
- char *zColl; /* Collation sequence name */
96837
+ const char *zColl; /* Collation sequence name */
9683596838
9683696839
sqlite3StringToId(pListItem->pExpr);
9683796840
sqlite3ResolveSelfReference(pParse, pTab, NC_IdxExpr, pListItem->pExpr, 0);
9683896841
if( pParse->nErr ) goto exit_create_index;
9683996842
pCExpr = sqlite3ExprSkipCollate(pListItem->pExpr);
@@ -96875,11 +96878,11 @@
9687596878
zExtra += nColl;
9687696879
nExtra -= nColl;
9687796880
}else if( j>=0 ){
9687896881
zColl = pTab->aCol[j].zColl;
9687996882
}
96880
- if( !zColl ) zColl = "BINARY";
96883
+ if( !zColl ) zColl = sqlite3StrBINARY;
9688196884
if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){
9688296885
goto exit_create_index;
9688396886
}
9688496887
pIndex->azColl[i] = zColl;
9688596888
requestedSortOrder = pListItem->sortOrder & sortOrderMask;
@@ -96904,11 +96907,11 @@
9690496907
}
9690596908
}
9690696909
assert( i==pIndex->nColumn );
9690796910
}else{
9690896911
pIndex->aiColumn[i] = XN_ROWID;
96909
- pIndex->azColl[i] = "BINARY";
96912
+ pIndex->azColl[i] = sqlite3StrBINARY;
9691096913
}
9691196914
sqlite3DefaultRowEst(pIndex);
9691296915
if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex);
9691396916
9691496917
if( pTab==pParse->pNewTable ){
@@ -98028,13 +98031,12 @@
9802898031
pKey = sqlite3KeyInfoAlloc(pParse->db, nCol, 0);
9802998032
}
9803098033
if( pKey ){
9803198034
assert( sqlite3KeyInfoIsWriteable(pKey) );
9803298035
for(i=0; i<nCol; i++){
98033
- char *zColl = pIdx->azColl[i];
98034
- assert( zColl!=0 );
98035
- pKey->aColl[i] = strcmp(zColl,"BINARY")==0 ? 0 :
98036
+ const char *zColl = pIdx->azColl[i];
98037
+ pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :
9803698038
sqlite3LocateCollSeq(pParse, zColl);
9803798039
pKey->aSortOrder[i] = pIdx->aSortOrder[i];
9803898040
}
9803998041
if( pParse->nErr ){
9804098042
sqlite3KeyInfoUnref(pKey);
@@ -100240,11 +100242,11 @@
100240100242
continue;
100241100243
}
100242100244
}
100243100245
c2 = Utf8Read(zString);
100244100246
if( c==c2 ) continue;
100245
- if( noCase && c<0x80 && c2<0x80 && sqlite3Tolower(c)==sqlite3Tolower(c2) ){
100247
+ if( noCase && sqlite3Tolower(c)==sqlite3Tolower(c2) ){
100246100248
continue;
100247100249
}
100248100250
if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue;
100249100251
return 0;
100250100252
}
@@ -101559,22 +101561,20 @@
101559101561
** index matches those columns. Also, check that the index uses
101560101562
** the default collation sequences for each column. */
101561101563
int i, j;
101562101564
for(i=0; i<nCol; i++){
101563101565
i16 iCol = pIdx->aiColumn[i]; /* Index of column in parent tbl */
101564
- char *zDfltColl; /* Def. collation for column */
101566
+ const char *zDfltColl; /* Def. collation for column */
101565101567
char *zIdxCol; /* Name of indexed column */
101566101568
101567101569
if( iCol<0 ) break; /* No foreign keys against expression indexes */
101568101570
101569101571
/* If the index uses a collation sequence that is different from
101570101572
** the default collation sequence for the column, this index is
101571101573
** unusable. Bail out early in this case. */
101572101574
zDfltColl = pParent->aCol[iCol].zColl;
101573
- if( !zDfltColl ){
101574
- zDfltColl = "BINARY";
101575
- }
101575
+ if( !zDfltColl ) zDfltColl = sqlite3StrBINARY;
101576101576
if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break;
101577101577
101578101578
zIdxCol = pParent->aCol[iCol].zName;
101579101579
for(j=0; j<nCol; j++){
101580101580
if( sqlite3StrICmp(pFKey->aCol[j].zCol, zIdxCol)==0 ){
@@ -104432,24 +104432,10 @@
104432104432
SQLITE_API int sqlite3_xferopt_count;
104433104433
#endif /* SQLITE_TEST */
104434104434
104435104435
104436104436
#ifndef SQLITE_OMIT_XFER_OPT
104437
-/*
104438
-** Check to collation names to see if they are compatible.
104439
-*/
104440
-static int xferCompatibleCollation(const char *z1, const char *z2){
104441
- if( z1==0 ){
104442
- return z2==0;
104443
- }
104444
- if( z2==0 ){
104445
- return 0;
104446
- }
104447
- return sqlite3StrICmp(z1, z2)==0;
104448
-}
104449
-
104450
-
104451104437
/*
104452104438
** Check to see if index pSrc is compatible as a source of data
104453104439
** for index pDest in an insert transfer optimization. The rules
104454104440
** for a compatible index:
104455104441
**
@@ -104481,11 +104467,11 @@
104481104467
}
104482104468
}
104483104469
if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){
104484104470
return 0; /* Different sort orders */
104485104471
}
104486
- if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){
104472
+ if( sqlite3_stricmp(pSrc->azColl[i],pDest->azColl[i])!=0 ){
104487104473
return 0; /* Different collating sequences */
104488104474
}
104489104475
}
104490104476
if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
104491104477
return 0; /* Different WHERE clauses */
@@ -104642,11 +104628,11 @@
104642104628
}
104643104629
#endif
104644104630
if( pDestCol->affinity!=pSrcCol->affinity ){
104645104631
return 0; /* Affinity must be the same on all columns */
104646104632
}
104647
- if( !xferCompatibleCollation(pDestCol->zColl, pSrcCol->zColl) ){
104633
+ if( sqlite3_stricmp(pDestCol->zColl, pSrcCol->zColl)!=0 ){
104648104634
return 0; /* Collating sequence must be the same on all columns */
104649104635
}
104650104636
if( pDestCol->notNull && !pSrcCol->notNull ){
104651104637
return 0; /* tab2 must be NOT NULL if tab1 is */
104652104638
}
@@ -104789,13 +104775,14 @@
104789104775
** BINARY, this optimization is disabled. This is because the user
104790104776
** might change the definition of a collation sequence and then run
104791104777
** a VACUUM command. In that case keys may not be written in strictly
104792104778
** sorted order. */
104793104779
for(i=0; i<pSrcIdx->nColumn; i++){
104794
- char *zColl = pSrcIdx->azColl[i];
104795
- assert( zColl!=0 );
104796
- if( sqlite3_stricmp("BINARY", zColl) ) break;
104780
+ const char *zColl = pSrcIdx->azColl[i];
104781
+ assert( sqlite3_stricmp(sqlite3StrBINARY, zColl)!=0
104782
+ || sqlite3StrBINARY==zColl );
104783
+ if( sqlite3_stricmp(sqlite3StrBINARY, zColl) ) break;
104797104784
}
104798104785
if( i==pSrcIdx->nColumn ){
104799104786
idxInsFlags = OPFLAG_USESEEKRESULT;
104800104787
sqlite3VdbeAddOp3(v, OP_Last, iDest, 0, -1);
104801104788
}
@@ -119292,11 +119279,11 @@
119292119279
** terms in the WHERE clause that are useful to the query planner.
119293119280
*/
119294119281
struct WhereScan {
119295119282
WhereClause *pOrigWC; /* Original, innermost WhereClause */
119296119283
WhereClause *pWC; /* WhereClause currently being scanned */
119297
- char *zCollName; /* Required collating sequence, if not NULL */
119284
+ const char *zCollName; /* Required collating sequence, if not NULL */
119298119285
Expr *pIdxExpr; /* Search for this index expression */
119299119286
char idxaff; /* Must match this affinity, if zCollName!=NULL */
119300119287
unsigned char nEquiv; /* Number of entries in aEquiv[] */
119301119288
unsigned char iEquiv; /* Next unused slot in aEquiv[] */
119302119289
u32 opMask; /* Acceptable operators */
@@ -123278,11 +123265,11 @@
123278123265
if( (idxCols & cMask)==0 ){
123279123266
Expr *pX = pTerm->pExpr;
123280123267
idxCols |= cMask;
123281123268
pIdx->aiColumn[n] = pTerm->u.leftColumn;
123282123269
pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);
123283
- pIdx->azColl[n] = pColl ? pColl->zName : "BINARY";
123270
+ pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;
123284123271
n++;
123285123272
}
123286123273
}
123287123274
}
123288123275
assert( (u32)n==pLoop->u.btree.nEq );
@@ -123290,24 +123277,24 @@
123290123277
/* Add additional columns needed to make the automatic index into
123291123278
** a covering index */
123292123279
for(i=0; i<mxBitCol; i++){
123293123280
if( extraCols & MASKBIT(i) ){
123294123281
pIdx->aiColumn[n] = i;
123295
- pIdx->azColl[n] = "BINARY";
123282
+ pIdx->azColl[n] = sqlite3StrBINARY;
123296123283
n++;
123297123284
}
123298123285
}
123299123286
if( pSrc->colUsed & MASKBIT(BMS-1) ){
123300123287
for(i=BMS-1; i<pTable->nCol; i++){
123301123288
pIdx->aiColumn[n] = i;
123302
- pIdx->azColl[n] = "BINARY";
123289
+ pIdx->azColl[n] = sqlite3StrBINARY;
123303123290
n++;
123304123291
}
123305123292
}
123306123293
assert( n==nKeyCol );
123307123294
pIdx->aiColumn[n] = XN_ROWID;
123308
- pIdx->azColl[n] = "BINARY";
123295
+ pIdx->azColl[n] = sqlite3StrBINARY;
123309123296
123310123297
/* Create the automatic index */
123311123298
assert( pLevel->iIdxCur>=0 );
123312123299
pLevel->iIdxCur = pParse->nTab++;
123313123300
sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1);
@@ -134858,22 +134845,22 @@
134858134845
** conversions. The only error that can occur here is a malloc() failure.
134859134846
**
134860134847
** EVIDENCE-OF: R-52786-44878 SQLite defines three built-in collating
134861134848
** functions:
134862134849
*/
134863
- createCollation(db, "BINARY", SQLITE_UTF8, 0, binCollFunc, 0);
134864
- createCollation(db, "BINARY", SQLITE_UTF16BE, 0, binCollFunc, 0);
134865
- createCollation(db, "BINARY", SQLITE_UTF16LE, 0, binCollFunc, 0);
134850
+ createCollation(db, sqlite3StrBINARY, SQLITE_UTF8, 0, binCollFunc, 0);
134851
+ createCollation(db, sqlite3StrBINARY, SQLITE_UTF16BE, 0, binCollFunc, 0);
134852
+ createCollation(db, sqlite3StrBINARY, SQLITE_UTF16LE, 0, binCollFunc, 0);
134866134853
createCollation(db, "NOCASE", SQLITE_UTF8, 0, nocaseCollatingFunc, 0);
134867134854
createCollation(db, "RTRIM", SQLITE_UTF8, (void*)1, binCollFunc, 0);
134868134855
if( db->mallocFailed ){
134869134856
goto opendb_out;
134870134857
}
134871134858
/* EVIDENCE-OF: R-08308-17224 The default collating function for all
134872134859
** strings is BINARY.
134873134860
*/
134874
- db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 0);
134861
+ db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, sqlite3StrBINARY, 0);
134875134862
assert( db->pDfltColl!=0 );
134876134863
134877134864
/* Parse the filename/URI argument. */
134878134865
db->openFlags = flags;
134879134866
rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
@@ -135369,11 +135356,11 @@
135369135356
}else{
135370135357
zDataType = "INTEGER";
135371135358
primarykey = 1;
135372135359
}
135373135360
if( !zCollSeq ){
135374
- zCollSeq = "BINARY";
135361
+ zCollSeq = sqlite3StrBINARY;
135375135362
}
135376135363
135377135364
error_out:
135378135365
sqlite3BtreeLeaveAll(db);
135379135366
@@ -135977,11 +135964,10 @@
135977135964
*/
135978135965
SQLITE_API void SQLITE_STDCALL sqlite3_snapshot_free(sqlite3_snapshot *pSnapshot){
135979135966
sqlite3_free(pSnapshot);
135980135967
}
135981135968
#endif /* SQLITE_ENABLE_SNAPSHOT */
135982
-
135983135969
135984135970
/************** End of main.c ************************************************/
135985135971
/************** Begin file notify.c ******************************************/
135986135972
/*
135987135973
** 2009 March 3
@@ -166098,11 +166084,11 @@
166098166084
sqlite3_result_int(ctx, sqlite3_value_subtype(argv[0])==JSON_SUBTYPE);
166099166085
}
166100166086
#endif /* SQLITE_DEBUG */
166101166087
166102166088
/****************************************************************************
166103
-** SQL function implementations
166089
+** Scalar SQL function implementations
166104166090
****************************************************************************/
166105166091
166106166092
/*
166107166093
** Implementation of the json_array(VALUE,...) function. Return a JSON
166108166094
** array that contains all values given in arguments. Or if any argument
@@ -166430,10 +166416,106 @@
166430166416
rc = 1;
166431166417
}
166432166418
jsonParseReset(&x);
166433166419
sqlite3_result_int(ctx, rc);
166434166420
}
166421
+
166422
+
166423
+/****************************************************************************
166424
+** Aggregate SQL function implementations
166425
+****************************************************************************/
166426
+/*
166427
+** json_group_array(VALUE)
166428
+**
166429
+** Return a JSON array composed of all values in the aggregate.
166430
+*/
166431
+static void jsonArrayStep(
166432
+ sqlite3_context *ctx,
166433
+ int argc,
166434
+ sqlite3_value **argv
166435
+){
166436
+ JsonString *pStr;
166437
+ pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
166438
+ if( pStr ){
166439
+ if( pStr->zBuf==0 ){
166440
+ jsonInit(pStr, ctx);
166441
+ jsonAppendChar(pStr, '[');
166442
+ }else{
166443
+ jsonAppendChar(pStr, ',');
166444
+ pStr->pCtx = ctx;
166445
+ }
166446
+ jsonAppendValue(pStr, argv[0]);
166447
+ }
166448
+}
166449
+static void jsonArrayFinal(sqlite3_context *ctx){
166450
+ JsonString *pStr;
166451
+ pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
166452
+ if( pStr ){
166453
+ pStr->pCtx = ctx;
166454
+ jsonAppendChar(pStr, ']');
166455
+ if( pStr->bErr ){
166456
+ sqlite3_result_error_nomem(ctx);
166457
+ if( !pStr->bStatic ) sqlite3_free(pStr->zBuf);
166458
+ }else{
166459
+ sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,
166460
+ pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);
166461
+ pStr->bStatic = 1;
166462
+ }
166463
+ }else{
166464
+ sqlite3_result_text(ctx, "[]", 2, SQLITE_STATIC);
166465
+ }
166466
+ sqlite3_result_subtype(ctx, JSON_SUBTYPE);
166467
+}
166468
+
166469
+/*
166470
+** json_group_obj(NAME,VALUE)
166471
+**
166472
+** Return a JSON object composed of all names and values in the aggregate.
166473
+*/
166474
+static void jsonObjectStep(
166475
+ sqlite3_context *ctx,
166476
+ int argc,
166477
+ sqlite3_value **argv
166478
+){
166479
+ JsonString *pStr;
166480
+ const char *z;
166481
+ u32 n;
166482
+ pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
166483
+ if( pStr ){
166484
+ if( pStr->zBuf==0 ){
166485
+ jsonInit(pStr, ctx);
166486
+ jsonAppendChar(pStr, '{');
166487
+ }else{
166488
+ jsonAppendChar(pStr, ',');
166489
+ pStr->pCtx = ctx;
166490
+ }
166491
+ z = (const char*)sqlite3_value_text(argv[0]);
166492
+ n = (u32)sqlite3_value_bytes(argv[0]);
166493
+ jsonAppendString(pStr, z, n);
166494
+ jsonAppendChar(pStr, ':');
166495
+ jsonAppendValue(pStr, argv[1]);
166496
+ }
166497
+}
166498
+static void jsonObjectFinal(sqlite3_context *ctx){
166499
+ JsonString *pStr;
166500
+ pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
166501
+ if( pStr ){
166502
+ jsonAppendChar(pStr, '}');
166503
+ if( pStr->bErr ){
166504
+ sqlite3_result_error_nomem(ctx);
166505
+ if( !pStr->bStatic ) sqlite3_free(pStr->zBuf);
166506
+ }else{
166507
+ sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,
166508
+ pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);
166509
+ pStr->bStatic = 1;
166510
+ }
166511
+ }else{
166512
+ sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC);
166513
+ }
166514
+ sqlite3_result_subtype(ctx, JSON_SUBTYPE);
166515
+}
166516
+
166435166517
166436166518
#ifndef SQLITE_OMIT_VIRTUALTABLE
166437166519
/****************************************************************************
166438166520
** The json_each virtual table
166439166521
****************************************************************************/
@@ -166929,10 +167011,19 @@
166929167011
/* DEBUG and TESTING functions */
166930167012
{ "json_parse", 1, 0, jsonParseFunc },
166931167013
{ "json_test1", 1, 0, jsonTest1Func },
166932167014
#endif
166933167015
};
167016
+ static const struct {
167017
+ const char *zName;
167018
+ int nArg;
167019
+ void (*xStep)(sqlite3_context*,int,sqlite3_value**);
167020
+ void (*xFinal)(sqlite3_context*);
167021
+ } aAgg[] = {
167022
+ { "json_group_array", 1, jsonArrayStep, jsonArrayFinal },
167023
+ { "json_group_object", 2, jsonObjectStep, jsonObjectFinal },
167024
+ };
166934167025
#ifndef SQLITE_OMIT_VIRTUALTABLE
166935167026
static const struct {
166936167027
const char *zName;
166937167028
sqlite3_module *pModule;
166938167029
} aMod[] = {
@@ -166944,10 +167035,15 @@
166944167035
rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,
166945167036
SQLITE_UTF8 | SQLITE_DETERMINISTIC,
166946167037
(void*)&aFunc[i].flag,
166947167038
aFunc[i].xFunc, 0, 0);
166948167039
}
167040
+ for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
167041
+ rc = sqlite3_create_function(db, aAgg[i].zName, aAgg[i].nArg,
167042
+ SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
167043
+ 0, aAgg[i].xStep, aAgg[i].xFinal);
167044
+ }
166949167045
#ifndef SQLITE_OMIT_VIRTUALTABLE
166950167046
for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){
166951167047
rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);
166952167048
}
166953167049
#endif
@@ -182141,11 +182237,11 @@
182141182237
sqlite3_context *pCtx, /* Function call context */
182142182238
int nArg, /* Number of args */
182143182239
sqlite3_value **apVal /* Function arguments */
182144182240
){
182145182241
assert( nArg==0 );
182146
- sqlite3_result_text(pCtx, "fts5: 2015-12-23 16:42:27 5d44d4a6cf5c6b983cbd846d9bc34251df8f4bc5", -1, SQLITE_TRANSIENT);
182242
+ sqlite3_result_text(pCtx, "fts5: 2015-12-30 14:06:22 0a99a8c4facf65ec67d8d86108c9a3f723f7cbd6", -1, SQLITE_TRANSIENT);
182147182243
}
182148182244
182149182245
static int fts5Init(sqlite3 *db){
182150182246
static const sqlite3_module fts5Mod = {
182151182247
/* iVersion */ 2,
182152182248
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -325,11 +325,11 @@
325 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
326 ** [sqlite_version()] and [sqlite_source_id()].
327 */
328 #define SQLITE_VERSION "3.10.0"
329 #define SQLITE_VERSION_NUMBER 3010000
330 #define SQLITE_SOURCE_ID "2015-12-24 14:53:27 7c7b7f26306b6aa6ff35b871ad756f43f5db9838"
331
332 /*
333 ** CAPI3REF: Run-Time Library Version Numbers
334 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
335 **
@@ -12317,11 +12317,11 @@
12317 char *zDflt; /* Original text of the default value */
12318 char *zType; /* Data type for this column */
12319 char *zColl; /* Collating sequence. If NULL, use the default */
12320 u8 notNull; /* An OE_ code for handling a NOT NULL constraint */
12321 char affinity; /* One of the SQLITE_AFF_... values */
12322 u8 szEst; /* Estimated size of this column. INT==1 */
12323 u8 colFlags; /* Boolean properties. See COLFLAG_ defines below */
12324 };
12325
12326 /* Allowed values for Column.colFlags:
12327 */
@@ -12727,11 +12727,11 @@
12727 Table *pTable; /* The SQL table being indexed */
12728 char *zColAff; /* String defining the affinity of each column */
12729 Index *pNext; /* The next index associated with the same table */
12730 Schema *pSchema; /* Schema containing this index */
12731 u8 *aSortOrder; /* for each column: True==DESC, False==ASC */
12732 char **azColl; /* Array of collation sequence names for index */
12733 Expr *pPartIdxWhere; /* WHERE clause for partial indices */
12734 ExprList *aColExpr; /* Column expressions */
12735 int tnum; /* DB Page containing root of this index */
12736 LogEst szIdxRow; /* Estimated average row size in bytes */
12737 u16 nKeyCol; /* Number of columns forming the key */
@@ -14143,11 +14143,15 @@
14143 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);
14144 SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);
14145 SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
14146 SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16);
14147 SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
14148 SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table*, Column*);
 
 
 
 
14149 SQLITE_PRIVATE void sqlite3AddColumn(Parse*,Token*);
14150 SQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int);
14151 SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
14152 SQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*);
14153 SQLITE_PRIVATE void sqlite3AddColumnType(Parse*,Token*);
@@ -14494,10 +14498,11 @@
14494 SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8);
14495 SQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);
14496 SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
14497 #ifndef SQLITE_AMALGAMATION
14498 SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[];
 
14499 SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[];
14500 SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[];
14501 SQLITE_PRIVATE const Token sqlite3IntTokens[];
14502 SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config;
14503 SQLITE_PRIVATE SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;
@@ -15099,10 +15104,15 @@
15099 ** from the comments following the "case OP_xxxx:" statements in
15100 ** the vdbe.c file.
15101 */
15102 SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;
15103
 
 
 
 
 
15104 /************** End of global.c **********************************************/
15105 /************** Begin file ctime.c *******************************************/
15106 /*
15107 ** 2010 February 23
15108 **
@@ -54551,11 +54561,10 @@
54551 struct CellInfo {
54552 i64 nKey; /* The key for INTKEY tables, or nPayload otherwise */
54553 u8 *pPayload; /* Pointer to the start of payload */
54554 u32 nPayload; /* Bytes of payload */
54555 u16 nLocal; /* Amount of payload held locally, not on overflow */
54556 u16 iOverflow; /* Offset to overflow page number. Zero if no overflow */
54557 u16 nSize; /* Size of the cell content on the main b-tree page */
54558 };
54559
54560 /*
54561 ** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than
@@ -56132,12 +56141,11 @@
56132 if( surplus <= maxLocal ){
56133 pInfo->nLocal = (u16)surplus;
56134 }else{
56135 pInfo->nLocal = (u16)minLocal;
56136 }
56137 pInfo->iOverflow = (u16)(&pInfo->pPayload[pInfo->nLocal] - pCell);
56138 pInfo->nSize = pInfo->iOverflow + 4;
56139 }
56140
56141 /*
56142 ** The following routines are implementations of the MemPage.xParseCell()
56143 ** method.
@@ -56165,11 +56173,10 @@
56165 UNUSED_PARAMETER(pPage);
56166 #endif
56167 pInfo->nSize = 4 + getVarint(&pCell[4], (u64*)&pInfo->nKey);
56168 pInfo->nPayload = 0;
56169 pInfo->nLocal = 0;
56170 pInfo->iOverflow = 0;
56171 pInfo->pPayload = 0;
56172 return;
56173 }
56174 static void btreeParseCellPtr(
56175 MemPage *pPage, /* Page containing the cell */
@@ -56235,11 +56242,10 @@
56235 ** on the local page. No overflow is required.
56236 */
56237 pInfo->nSize = nPayload + (u16)(pIter - pCell);
56238 if( pInfo->nSize<4 ) pInfo->nSize = 4;
56239 pInfo->nLocal = (u16)nPayload;
56240 pInfo->iOverflow = 0;
56241 }else{
56242 btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo);
56243 }
56244 }
56245 static void btreeParseCellPtrIndex(
@@ -56274,11 +56280,10 @@
56274 ** on the local page. No overflow is required.
56275 */
56276 pInfo->nSize = nPayload + (u16)(pIter - pCell);
56277 if( pInfo->nSize<4 ) pInfo->nSize = 4;
56278 pInfo->nLocal = (u16)nPayload;
56279 pInfo->iOverflow = 0;
56280 }else{
56281 btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo);
56282 }
56283 }
56284 static void btreeParseCell(
@@ -56390,12 +56395,12 @@
56390 static void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){
56391 CellInfo info;
56392 if( *pRC ) return;
56393 assert( pCell!=0 );
56394 pPage->xParseCell(pPage, pCell, &info);
56395 if( info.iOverflow ){
56396 Pgno ovfl = get4byte(&pCell[info.iOverflow]);
56397 ptrmapPut(pPage->pBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, pRC);
56398 }
56399 }
56400 #endif
56401
@@ -58429,15 +58434,15 @@
58429 for(i=0; i<nCell; i++){
58430 u8 *pCell = findCell(pPage, i);
58431 if( eType==PTRMAP_OVERFLOW1 ){
58432 CellInfo info;
58433 pPage->xParseCell(pPage, pCell, &info);
58434 if( info.iOverflow
58435 && pCell+info.iOverflow+3<=pPage->aData+pPage->maskPage
58436 && iFrom==get4byte(&pCell[info.iOverflow])
58437 ){
58438 put4byte(&pCell[info.iOverflow], iTo);
58439 break;
58440 }
58441 }else{
58442 if( get4byte(pCell)==iFrom ){
58443 put4byte(pCell, iTo);
@@ -61075,17 +61080,17 @@
61075 u32 ovflPageSize;
61076
61077 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
61078 pPage->xParseCell(pPage, pCell, &info);
61079 *pnSize = info.nSize;
61080 if( info.iOverflow==0 ){
61081 return SQLITE_OK; /* No overflow pages. Return without doing anything */
61082 }
61083 if( pCell+info.iOverflow+3 > pPage->aData+pPage->maskPage ){
61084 return SQLITE_CORRUPT_BKPT; /* Cell extends past end of page */
61085 }
61086 ovflPgno = get4byte(&pCell[info.iOverflow]);
61087 assert( pBt->usableSize > 4 );
61088 ovflPageSize = pBt->usableSize - 4;
61089 nOvfl = (info.nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize;
61090 assert( nOvfl>0 ||
61091 (CORRUPT_DB && (info.nPayload + ovflPageSize)<ovflPageSize)
@@ -61230,11 +61235,10 @@
61230 pPage->xParseCell(pPage, pCell, &info);
61231 assert( nHeader=(int)(info.pPayload - pCell) );
61232 assert( info.nKey==nKey );
61233 assert( *pnSize == info.nSize );
61234 assert( spaceLeft == info.nLocal );
61235 assert( pPrior == &pCell[info.iOverflow] );
61236 }
61237 #endif
61238
61239 /* Write the payload into the local Cell and any extra into overflow pages */
61240 while( nPayload>0 ){
@@ -61940,12 +61944,12 @@
61940 CellInfo info;
61941 u8 *z;
61942
61943 z = findCell(pPage, j);
61944 pPage->xParseCell(pPage, z, &info);
61945 if( info.iOverflow ){
61946 Pgno ovfl = get4byte(&z[info.iOverflow]);
61947 ptrmapGet(pBt, ovfl, &e, &n);
61948 assert( n==pPage->pgno && e==PTRMAP_OVERFLOW1 );
61949 }
61950 if( !pPage->leaf ){
61951 Pgno child = get4byte(z);
@@ -64247,13 +64251,13 @@
64247
64248 /* Check the content overflow list */
64249 if( info.nPayload>info.nLocal ){
64250 int nPage; /* Number of pages on the overflow chain */
64251 Pgno pgnoOvfl; /* First page of the overflow chain */
64252 assert( pc + info.iOverflow <= usableSize );
64253 nPage = (info.nPayload - info.nLocal + usableSize - 5)/(usableSize - 4);
64254 pgnoOvfl = get4byte(&pCell[info.iOverflow]);
64255 #ifndef SQLITE_OMIT_AUTOVACUUM
64256 if( pBt->autoVacuum ){
64257 checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage);
64258 }
64259 #endif
@@ -71031,11 +71035,11 @@
71031 }
71032 if( (f2 & MEM_Str)==0 ){
71033 return -1;
71034 }
71035
71036 assert( pMem1->enc==pMem2->enc );
71037 assert( pMem1->enc==SQLITE_UTF8 ||
71038 pMem1->enc==SQLITE_UTF16LE || pMem1->enc==SQLITE_UTF16BE );
71039
71040 /* The collation sequence must be defined at this point, even if
71041 ** the user deletes the collation sequence after the vdbe program is
@@ -75667,42 +75671,41 @@
75667 }
75668 }else{
75669 /* Neither operand is NULL. Do a comparison. */
75670 affinity = pOp->p5 & SQLITE_AFF_MASK;
75671 if( affinity>=SQLITE_AFF_NUMERIC ){
75672 if( (pIn1->flags & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
75673 applyNumericAffinity(pIn1,0);
75674 }
75675 if( (pIn3->flags & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
75676 applyNumericAffinity(pIn3,0);
75677 }
75678 }else if( affinity==SQLITE_AFF_TEXT ){
75679 if( (pIn1->flags & MEM_Str)==0 && (pIn1->flags & (MEM_Int|MEM_Real))!=0 ){
75680 testcase( pIn1->flags & MEM_Int );
75681 testcase( pIn1->flags & MEM_Real );
75682 sqlite3VdbeMemStringify(pIn1, encoding, 1);
75683 testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
75684 flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
75685 }
75686 if( (pIn3->flags & MEM_Str)==0 && (pIn3->flags & (MEM_Int|MEM_Real))!=0 ){
75687 testcase( pIn3->flags & MEM_Int );
75688 testcase( pIn3->flags & MEM_Real );
75689 sqlite3VdbeMemStringify(pIn3, encoding, 1);
75690 testcase( (flags3&MEM_Dyn) != (pIn3->flags&MEM_Dyn) );
75691 flags3 = (pIn3->flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask);
75692 }
75693 }
75694 assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
75695 if( pIn1->flags & MEM_Zero ){
75696 sqlite3VdbeMemExpandBlob(pIn1);
75697 flags1 &= ~MEM_Zero;
75698 }
75699 if( pIn3->flags & MEM_Zero ){
75700 sqlite3VdbeMemExpandBlob(pIn3);
75701 flags3 &= ~MEM_Zero;
75702 }
75703 if( db->mallocFailed ) goto no_mem;
75704 res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
75705 }
75706 switch( pOp->opcode ){
75707 case OP_Eq: res = res==0; break;
75708 case OP_Ne: res = res!=0; break;
@@ -94733,19 +94736,19 @@
94733 }
94734
94735 /* Set properties of a table column based on the (magical)
94736 ** name of the column.
94737 */
94738 SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){
94739 #if SQLITE_ENABLE_HIDDEN_COLUMNS
 
94740 if( sqlite3_strnicmp(pCol->zName, "__hidden__", 10)==0 ){
94741 pCol->colFlags |= COLFLAG_HIDDEN;
94742 }else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){
94743 pTab->tabFlags |= TF_OOOHidden;
94744 }
 
94745 #endif
94746 }
94747
94748
94749 /*
94750 ** Add a new column to the table currently being constructed.
94751 **
@@ -95321,11 +95324,11 @@
95321 assert( pIdx->isResized==0 );
95322 nByte = (sizeof(char*) + sizeof(i16) + 1)*N;
95323 zExtra = sqlite3DbMallocZero(db, nByte);
95324 if( zExtra==0 ) return SQLITE_NOMEM;
95325 memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn);
95326 pIdx->azColl = (char**)zExtra;
95327 zExtra += sizeof(char*)*N;
95328 memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn);
95329 pIdx->aiColumn = (i16*)zExtra;
95330 zExtra += sizeof(i16)*N;
95331 memcpy(zExtra, pIdx->aSortOrder, pIdx->nColumn);
@@ -95502,11 +95505,11 @@
95502 if( resizeIndexObject(db, pPk, pTab->nCol) ) return;
95503 for(i=0, j=nPk; i<pTab->nCol; i++){
95504 if( !hasColumn(pPk->aiColumn, j, i) ){
95505 assert( j<pPk->nColumn );
95506 pPk->aiColumn[j] = i;
95507 pPk->azColl[j] = "BINARY";
95508 j++;
95509 }
95510 }
95511 assert( pPk->nColumn==j );
95512 assert( pTab->nCol==j );
@@ -96552,11 +96555,11 @@
96552 sizeof(i16)*nCol + /* Index.aiColumn */
96553 sizeof(u8)*nCol); /* Index.aSortOrder */
96554 p = sqlite3DbMallocZero(db, nByte + nExtra);
96555 if( p ){
96556 char *pExtra = ((char*)p)+ROUND8(sizeof(Index));
96557 p->azColl = (char**)pExtra; pExtra += ROUND8(sizeof(char*)*nCol);
96558 p->aiRowLogEst = (LogEst*)pExtra; pExtra += sizeof(LogEst)*(nCol+1);
96559 p->aiColumn = (i16*)pExtra; pExtra += sizeof(i16)*nCol;
96560 p->aSortOrder = (u8*)pExtra;
96561 p->nColumn = nCol;
96562 p->nKeyCol = nCol - 1;
@@ -96829,11 +96832,11 @@
96829 ** index key.
96830 */
96831 for(i=0, pListItem=pList->a; i<pList->nExpr; i++, pListItem++){
96832 Expr *pCExpr; /* The i-th index expression */
96833 int requestedSortOrder; /* ASC or DESC on the i-th expression */
96834 char *zColl; /* Collation sequence name */
96835
96836 sqlite3StringToId(pListItem->pExpr);
96837 sqlite3ResolveSelfReference(pParse, pTab, NC_IdxExpr, pListItem->pExpr, 0);
96838 if( pParse->nErr ) goto exit_create_index;
96839 pCExpr = sqlite3ExprSkipCollate(pListItem->pExpr);
@@ -96875,11 +96878,11 @@
96875 zExtra += nColl;
96876 nExtra -= nColl;
96877 }else if( j>=0 ){
96878 zColl = pTab->aCol[j].zColl;
96879 }
96880 if( !zColl ) zColl = "BINARY";
96881 if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){
96882 goto exit_create_index;
96883 }
96884 pIndex->azColl[i] = zColl;
96885 requestedSortOrder = pListItem->sortOrder & sortOrderMask;
@@ -96904,11 +96907,11 @@
96904 }
96905 }
96906 assert( i==pIndex->nColumn );
96907 }else{
96908 pIndex->aiColumn[i] = XN_ROWID;
96909 pIndex->azColl[i] = "BINARY";
96910 }
96911 sqlite3DefaultRowEst(pIndex);
96912 if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex);
96913
96914 if( pTab==pParse->pNewTable ){
@@ -98028,13 +98031,12 @@
98028 pKey = sqlite3KeyInfoAlloc(pParse->db, nCol, 0);
98029 }
98030 if( pKey ){
98031 assert( sqlite3KeyInfoIsWriteable(pKey) );
98032 for(i=0; i<nCol; i++){
98033 char *zColl = pIdx->azColl[i];
98034 assert( zColl!=0 );
98035 pKey->aColl[i] = strcmp(zColl,"BINARY")==0 ? 0 :
98036 sqlite3LocateCollSeq(pParse, zColl);
98037 pKey->aSortOrder[i] = pIdx->aSortOrder[i];
98038 }
98039 if( pParse->nErr ){
98040 sqlite3KeyInfoUnref(pKey);
@@ -100240,11 +100242,11 @@
100240 continue;
100241 }
100242 }
100243 c2 = Utf8Read(zString);
100244 if( c==c2 ) continue;
100245 if( noCase && c<0x80 && c2<0x80 && sqlite3Tolower(c)==sqlite3Tolower(c2) ){
100246 continue;
100247 }
100248 if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue;
100249 return 0;
100250 }
@@ -101559,22 +101561,20 @@
101559 ** index matches those columns. Also, check that the index uses
101560 ** the default collation sequences for each column. */
101561 int i, j;
101562 for(i=0; i<nCol; i++){
101563 i16 iCol = pIdx->aiColumn[i]; /* Index of column in parent tbl */
101564 char *zDfltColl; /* Def. collation for column */
101565 char *zIdxCol; /* Name of indexed column */
101566
101567 if( iCol<0 ) break; /* No foreign keys against expression indexes */
101568
101569 /* If the index uses a collation sequence that is different from
101570 ** the default collation sequence for the column, this index is
101571 ** unusable. Bail out early in this case. */
101572 zDfltColl = pParent->aCol[iCol].zColl;
101573 if( !zDfltColl ){
101574 zDfltColl = "BINARY";
101575 }
101576 if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break;
101577
101578 zIdxCol = pParent->aCol[iCol].zName;
101579 for(j=0; j<nCol; j++){
101580 if( sqlite3StrICmp(pFKey->aCol[j].zCol, zIdxCol)==0 ){
@@ -104432,24 +104432,10 @@
104432 SQLITE_API int sqlite3_xferopt_count;
104433 #endif /* SQLITE_TEST */
104434
104435
104436 #ifndef SQLITE_OMIT_XFER_OPT
104437 /*
104438 ** Check to collation names to see if they are compatible.
104439 */
104440 static int xferCompatibleCollation(const char *z1, const char *z2){
104441 if( z1==0 ){
104442 return z2==0;
104443 }
104444 if( z2==0 ){
104445 return 0;
104446 }
104447 return sqlite3StrICmp(z1, z2)==0;
104448 }
104449
104450
104451 /*
104452 ** Check to see if index pSrc is compatible as a source of data
104453 ** for index pDest in an insert transfer optimization. The rules
104454 ** for a compatible index:
104455 **
@@ -104481,11 +104467,11 @@
104481 }
104482 }
104483 if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){
104484 return 0; /* Different sort orders */
104485 }
104486 if( !xferCompatibleCollation(pSrc->azColl[i],pDest->azColl[i]) ){
104487 return 0; /* Different collating sequences */
104488 }
104489 }
104490 if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
104491 return 0; /* Different WHERE clauses */
@@ -104642,11 +104628,11 @@
104642 }
104643 #endif
104644 if( pDestCol->affinity!=pSrcCol->affinity ){
104645 return 0; /* Affinity must be the same on all columns */
104646 }
104647 if( !xferCompatibleCollation(pDestCol->zColl, pSrcCol->zColl) ){
104648 return 0; /* Collating sequence must be the same on all columns */
104649 }
104650 if( pDestCol->notNull && !pSrcCol->notNull ){
104651 return 0; /* tab2 must be NOT NULL if tab1 is */
104652 }
@@ -104789,13 +104775,14 @@
104789 ** BINARY, this optimization is disabled. This is because the user
104790 ** might change the definition of a collation sequence and then run
104791 ** a VACUUM command. In that case keys may not be written in strictly
104792 ** sorted order. */
104793 for(i=0; i<pSrcIdx->nColumn; i++){
104794 char *zColl = pSrcIdx->azColl[i];
104795 assert( zColl!=0 );
104796 if( sqlite3_stricmp("BINARY", zColl) ) break;
 
104797 }
104798 if( i==pSrcIdx->nColumn ){
104799 idxInsFlags = OPFLAG_USESEEKRESULT;
104800 sqlite3VdbeAddOp3(v, OP_Last, iDest, 0, -1);
104801 }
@@ -119292,11 +119279,11 @@
119292 ** terms in the WHERE clause that are useful to the query planner.
119293 */
119294 struct WhereScan {
119295 WhereClause *pOrigWC; /* Original, innermost WhereClause */
119296 WhereClause *pWC; /* WhereClause currently being scanned */
119297 char *zCollName; /* Required collating sequence, if not NULL */
119298 Expr *pIdxExpr; /* Search for this index expression */
119299 char idxaff; /* Must match this affinity, if zCollName!=NULL */
119300 unsigned char nEquiv; /* Number of entries in aEquiv[] */
119301 unsigned char iEquiv; /* Next unused slot in aEquiv[] */
119302 u32 opMask; /* Acceptable operators */
@@ -123278,11 +123265,11 @@
123278 if( (idxCols & cMask)==0 ){
123279 Expr *pX = pTerm->pExpr;
123280 idxCols |= cMask;
123281 pIdx->aiColumn[n] = pTerm->u.leftColumn;
123282 pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);
123283 pIdx->azColl[n] = pColl ? pColl->zName : "BINARY";
123284 n++;
123285 }
123286 }
123287 }
123288 assert( (u32)n==pLoop->u.btree.nEq );
@@ -123290,24 +123277,24 @@
123290 /* Add additional columns needed to make the automatic index into
123291 ** a covering index */
123292 for(i=0; i<mxBitCol; i++){
123293 if( extraCols & MASKBIT(i) ){
123294 pIdx->aiColumn[n] = i;
123295 pIdx->azColl[n] = "BINARY";
123296 n++;
123297 }
123298 }
123299 if( pSrc->colUsed & MASKBIT(BMS-1) ){
123300 for(i=BMS-1; i<pTable->nCol; i++){
123301 pIdx->aiColumn[n] = i;
123302 pIdx->azColl[n] = "BINARY";
123303 n++;
123304 }
123305 }
123306 assert( n==nKeyCol );
123307 pIdx->aiColumn[n] = XN_ROWID;
123308 pIdx->azColl[n] = "BINARY";
123309
123310 /* Create the automatic index */
123311 assert( pLevel->iIdxCur>=0 );
123312 pLevel->iIdxCur = pParse->nTab++;
123313 sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1);
@@ -134858,22 +134845,22 @@
134858 ** conversions. The only error that can occur here is a malloc() failure.
134859 **
134860 ** EVIDENCE-OF: R-52786-44878 SQLite defines three built-in collating
134861 ** functions:
134862 */
134863 createCollation(db, "BINARY", SQLITE_UTF8, 0, binCollFunc, 0);
134864 createCollation(db, "BINARY", SQLITE_UTF16BE, 0, binCollFunc, 0);
134865 createCollation(db, "BINARY", SQLITE_UTF16LE, 0, binCollFunc, 0);
134866 createCollation(db, "NOCASE", SQLITE_UTF8, 0, nocaseCollatingFunc, 0);
134867 createCollation(db, "RTRIM", SQLITE_UTF8, (void*)1, binCollFunc, 0);
134868 if( db->mallocFailed ){
134869 goto opendb_out;
134870 }
134871 /* EVIDENCE-OF: R-08308-17224 The default collating function for all
134872 ** strings is BINARY.
134873 */
134874 db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, "BINARY", 0);
134875 assert( db->pDfltColl!=0 );
134876
134877 /* Parse the filename/URI argument. */
134878 db->openFlags = flags;
134879 rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
@@ -135369,11 +135356,11 @@
135369 }else{
135370 zDataType = "INTEGER";
135371 primarykey = 1;
135372 }
135373 if( !zCollSeq ){
135374 zCollSeq = "BINARY";
135375 }
135376
135377 error_out:
135378 sqlite3BtreeLeaveAll(db);
135379
@@ -135977,11 +135964,10 @@
135977 */
135978 SQLITE_API void SQLITE_STDCALL sqlite3_snapshot_free(sqlite3_snapshot *pSnapshot){
135979 sqlite3_free(pSnapshot);
135980 }
135981 #endif /* SQLITE_ENABLE_SNAPSHOT */
135982
135983
135984 /************** End of main.c ************************************************/
135985 /************** Begin file notify.c ******************************************/
135986 /*
135987 ** 2009 March 3
@@ -166098,11 +166084,11 @@
166098 sqlite3_result_int(ctx, sqlite3_value_subtype(argv[0])==JSON_SUBTYPE);
166099 }
166100 #endif /* SQLITE_DEBUG */
166101
166102 /****************************************************************************
166103 ** SQL function implementations
166104 ****************************************************************************/
166105
166106 /*
166107 ** Implementation of the json_array(VALUE,...) function. Return a JSON
166108 ** array that contains all values given in arguments. Or if any argument
@@ -166430,10 +166416,106 @@
166430 rc = 1;
166431 }
166432 jsonParseReset(&x);
166433 sqlite3_result_int(ctx, rc);
166434 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166435
166436 #ifndef SQLITE_OMIT_VIRTUALTABLE
166437 /****************************************************************************
166438 ** The json_each virtual table
166439 ****************************************************************************/
@@ -166929,10 +167011,19 @@
166929 /* DEBUG and TESTING functions */
166930 { "json_parse", 1, 0, jsonParseFunc },
166931 { "json_test1", 1, 0, jsonTest1Func },
166932 #endif
166933 };
 
 
 
 
 
 
 
 
 
166934 #ifndef SQLITE_OMIT_VIRTUALTABLE
166935 static const struct {
166936 const char *zName;
166937 sqlite3_module *pModule;
166938 } aMod[] = {
@@ -166944,10 +167035,15 @@
166944 rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,
166945 SQLITE_UTF8 | SQLITE_DETERMINISTIC,
166946 (void*)&aFunc[i].flag,
166947 aFunc[i].xFunc, 0, 0);
166948 }
 
 
 
 
 
166949 #ifndef SQLITE_OMIT_VIRTUALTABLE
166950 for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){
166951 rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);
166952 }
166953 #endif
@@ -182141,11 +182237,11 @@
182141 sqlite3_context *pCtx, /* Function call context */
182142 int nArg, /* Number of args */
182143 sqlite3_value **apVal /* Function arguments */
182144 ){
182145 assert( nArg==0 );
182146 sqlite3_result_text(pCtx, "fts5: 2015-12-23 16:42:27 5d44d4a6cf5c6b983cbd846d9bc34251df8f4bc5", -1, SQLITE_TRANSIENT);
182147 }
182148
182149 static int fts5Init(sqlite3 *db){
182150 static const sqlite3_module fts5Mod = {
182151 /* iVersion */ 2,
182152
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -325,11 +325,11 @@
325 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
326 ** [sqlite_version()] and [sqlite_source_id()].
327 */
328 #define SQLITE_VERSION "3.10.0"
329 #define SQLITE_VERSION_NUMBER 3010000
330 #define SQLITE_SOURCE_ID "2015-12-31 15:34:03 9c392c1019ee15f27c8e05b41246d2844f91f6c0"
331
332 /*
333 ** CAPI3REF: Run-Time Library Version Numbers
334 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
335 **
@@ -12317,11 +12317,11 @@
12317 char *zDflt; /* Original text of the default value */
12318 char *zType; /* Data type for this column */
12319 char *zColl; /* Collating sequence. If NULL, use the default */
12320 u8 notNull; /* An OE_ code for handling a NOT NULL constraint */
12321 char affinity; /* One of the SQLITE_AFF_... values */
12322 u8 szEst; /* Estimated size of value in this column. sizeof(INT)==1 */
12323 u8 colFlags; /* Boolean properties. See COLFLAG_ defines below */
12324 };
12325
12326 /* Allowed values for Column.colFlags:
12327 */
@@ -12727,11 +12727,11 @@
12727 Table *pTable; /* The SQL table being indexed */
12728 char *zColAff; /* String defining the affinity of each column */
12729 Index *pNext; /* The next index associated with the same table */
12730 Schema *pSchema; /* Schema containing this index */
12731 u8 *aSortOrder; /* for each column: True==DESC, False==ASC */
12732 const char **azColl; /* Array of collation sequence names for index */
12733 Expr *pPartIdxWhere; /* WHERE clause for partial indices */
12734 ExprList *aColExpr; /* Column expressions */
12735 int tnum; /* DB Page containing root of this index */
12736 LogEst szIdxRow; /* Estimated average row size in bytes */
12737 u16 nKeyCol; /* Number of columns forming the key */
@@ -14143,11 +14143,15 @@
14143 SQLITE_PRIVATE Table *sqlite3ResultSetOfSelect(Parse*,Select*);
14144 SQLITE_PRIVATE void sqlite3OpenMasterTable(Parse *, int);
14145 SQLITE_PRIVATE Index *sqlite3PrimaryKeyIndex(Table*);
14146 SQLITE_PRIVATE i16 sqlite3ColumnOfIndex(Index*, i16);
14147 SQLITE_PRIVATE void sqlite3StartTable(Parse*,Token*,Token*,int,int,int,int);
14148 #if SQLITE_ENABLE_HIDDEN_COLUMNS
14149 SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table*, Column*);
14150 #else
14151 # define sqlite3ColumnPropertiesFromName(T,C) /* no-op */
14152 #endif
14153 SQLITE_PRIVATE void sqlite3AddColumn(Parse*,Token*);
14154 SQLITE_PRIVATE void sqlite3AddNotNull(Parse*, int);
14155 SQLITE_PRIVATE void sqlite3AddPrimaryKey(Parse*, ExprList*, int, int, int);
14156 SQLITE_PRIVATE void sqlite3AddCheckConstraint(Parse*, Expr*);
14157 SQLITE_PRIVATE void sqlite3AddColumnType(Parse*,Token*);
@@ -14494,10 +14498,11 @@
14498 SQLITE_PRIVATE char *sqlite3Utf16to8(sqlite3 *, const void*, int, u8);
14499 SQLITE_PRIVATE int sqlite3ValueFromExpr(sqlite3 *, Expr *, u8, u8, sqlite3_value **);
14500 SQLITE_PRIVATE void sqlite3ValueApplyAffinity(sqlite3_value *, u8, u8);
14501 #ifndef SQLITE_AMALGAMATION
14502 SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[];
14503 SQLITE_PRIVATE const char sqlite3StrBINARY[];
14504 SQLITE_PRIVATE const unsigned char sqlite3UpperToLower[];
14505 SQLITE_PRIVATE const unsigned char sqlite3CtypeMap[];
14506 SQLITE_PRIVATE const Token sqlite3IntTokens[];
14507 SQLITE_PRIVATE SQLITE_WSD struct Sqlite3Config sqlite3Config;
14508 SQLITE_PRIVATE SQLITE_WSD FuncDefHash sqlite3GlobalFunctions;
@@ -15099,10 +15104,15 @@
15104 ** from the comments following the "case OP_xxxx:" statements in
15105 ** the vdbe.c file.
15106 */
15107 SQLITE_PRIVATE const unsigned char sqlite3OpcodeProperty[] = OPFLG_INITIALIZER;
15108
15109 /*
15110 ** Name of the default collating sequence
15111 */
15112 SQLITE_PRIVATE const char sqlite3StrBINARY[] = "BINARY";
15113
15114 /************** End of global.c **********************************************/
15115 /************** Begin file ctime.c *******************************************/
15116 /*
15117 ** 2010 February 23
15118 **
@@ -54551,11 +54561,10 @@
54561 struct CellInfo {
54562 i64 nKey; /* The key for INTKEY tables, or nPayload otherwise */
54563 u8 *pPayload; /* Pointer to the start of payload */
54564 u32 nPayload; /* Bytes of payload */
54565 u16 nLocal; /* Amount of payload held locally, not on overflow */
 
54566 u16 nSize; /* Size of the cell content on the main b-tree page */
54567 };
54568
54569 /*
54570 ** Maximum depth of an SQLite B-Tree structure. Any B-Tree deeper than
@@ -56132,12 +56141,11 @@
56141 if( surplus <= maxLocal ){
56142 pInfo->nLocal = (u16)surplus;
56143 }else{
56144 pInfo->nLocal = (u16)minLocal;
56145 }
56146 pInfo->nSize = (u16)(&pInfo->pPayload[pInfo->nLocal] - pCell) + 4;
 
56147 }
56148
56149 /*
56150 ** The following routines are implementations of the MemPage.xParseCell()
56151 ** method.
@@ -56165,11 +56173,10 @@
56173 UNUSED_PARAMETER(pPage);
56174 #endif
56175 pInfo->nSize = 4 + getVarint(&pCell[4], (u64*)&pInfo->nKey);
56176 pInfo->nPayload = 0;
56177 pInfo->nLocal = 0;
 
56178 pInfo->pPayload = 0;
56179 return;
56180 }
56181 static void btreeParseCellPtr(
56182 MemPage *pPage, /* Page containing the cell */
@@ -56235,11 +56242,10 @@
56242 ** on the local page. No overflow is required.
56243 */
56244 pInfo->nSize = nPayload + (u16)(pIter - pCell);
56245 if( pInfo->nSize<4 ) pInfo->nSize = 4;
56246 pInfo->nLocal = (u16)nPayload;
 
56247 }else{
56248 btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo);
56249 }
56250 }
56251 static void btreeParseCellPtrIndex(
@@ -56274,11 +56280,10 @@
56280 ** on the local page. No overflow is required.
56281 */
56282 pInfo->nSize = nPayload + (u16)(pIter - pCell);
56283 if( pInfo->nSize<4 ) pInfo->nSize = 4;
56284 pInfo->nLocal = (u16)nPayload;
 
56285 }else{
56286 btreeParseCellAdjustSizeForOverflow(pPage, pCell, pInfo);
56287 }
56288 }
56289 static void btreeParseCell(
@@ -56390,12 +56395,12 @@
56395 static void ptrmapPutOvflPtr(MemPage *pPage, u8 *pCell, int *pRC){
56396 CellInfo info;
56397 if( *pRC ) return;
56398 assert( pCell!=0 );
56399 pPage->xParseCell(pPage, pCell, &info);
56400 if( info.nLocal<info.nPayload ){
56401 Pgno ovfl = get4byte(&pCell[info.nSize-4]);
56402 ptrmapPut(pPage->pBt, ovfl, PTRMAP_OVERFLOW1, pPage->pgno, pRC);
56403 }
56404 }
56405 #endif
56406
@@ -58429,15 +58434,15 @@
58434 for(i=0; i<nCell; i++){
58435 u8 *pCell = findCell(pPage, i);
58436 if( eType==PTRMAP_OVERFLOW1 ){
58437 CellInfo info;
58438 pPage->xParseCell(pPage, pCell, &info);
58439 if( info.nLocal<info.nPayload
58440 && pCell+info.nSize-1<=pPage->aData+pPage->maskPage
58441 && iFrom==get4byte(pCell+info.nSize-4)
58442 ){
58443 put4byte(pCell+info.nSize-4, iTo);
58444 break;
58445 }
58446 }else{
58447 if( get4byte(pCell)==iFrom ){
58448 put4byte(pCell, iTo);
@@ -61075,17 +61080,17 @@
61080 u32 ovflPageSize;
61081
61082 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
61083 pPage->xParseCell(pPage, pCell, &info);
61084 *pnSize = info.nSize;
61085 if( info.nLocal==info.nPayload ){
61086 return SQLITE_OK; /* No overflow pages. Return without doing anything */
61087 }
61088 if( pCell+info.nSize-1 > pPage->aData+pPage->maskPage ){
61089 return SQLITE_CORRUPT_BKPT; /* Cell extends past end of page */
61090 }
61091 ovflPgno = get4byte(pCell + info.nSize - 4);
61092 assert( pBt->usableSize > 4 );
61093 ovflPageSize = pBt->usableSize - 4;
61094 nOvfl = (info.nPayload - info.nLocal + ovflPageSize - 1)/ovflPageSize;
61095 assert( nOvfl>0 ||
61096 (CORRUPT_DB && (info.nPayload + ovflPageSize)<ovflPageSize)
@@ -61230,11 +61235,10 @@
61235 pPage->xParseCell(pPage, pCell, &info);
61236 assert( nHeader=(int)(info.pPayload - pCell) );
61237 assert( info.nKey==nKey );
61238 assert( *pnSize == info.nSize );
61239 assert( spaceLeft == info.nLocal );
 
61240 }
61241 #endif
61242
61243 /* Write the payload into the local Cell and any extra into overflow pages */
61244 while( nPayload>0 ){
@@ -61940,12 +61944,12 @@
61944 CellInfo info;
61945 u8 *z;
61946
61947 z = findCell(pPage, j);
61948 pPage->xParseCell(pPage, z, &info);
61949 if( info.nLocal<info.nPayload ){
61950 Pgno ovfl = get4byte(&z[info.nSize-4]);
61951 ptrmapGet(pBt, ovfl, &e, &n);
61952 assert( n==pPage->pgno && e==PTRMAP_OVERFLOW1 );
61953 }
61954 if( !pPage->leaf ){
61955 Pgno child = get4byte(z);
@@ -64247,13 +64251,13 @@
64251
64252 /* Check the content overflow list */
64253 if( info.nPayload>info.nLocal ){
64254 int nPage; /* Number of pages on the overflow chain */
64255 Pgno pgnoOvfl; /* First page of the overflow chain */
64256 assert( pc + info.nSize - 4 <= usableSize );
64257 nPage = (info.nPayload - info.nLocal + usableSize - 5)/(usableSize - 4);
64258 pgnoOvfl = get4byte(&pCell[info.nSize - 4]);
64259 #ifndef SQLITE_OMIT_AUTOVACUUM
64260 if( pBt->autoVacuum ){
64261 checkPtrmap(pCheck, pgnoOvfl, PTRMAP_OVERFLOW1, iPage);
64262 }
64263 #endif
@@ -71031,11 +71035,11 @@
71035 }
71036 if( (f2 & MEM_Str)==0 ){
71037 return -1;
71038 }
71039
71040 assert( pMem1->enc==pMem2->enc || pMem1->db->mallocFailed );
71041 assert( pMem1->enc==SQLITE_UTF8 ||
71042 pMem1->enc==SQLITE_UTF16LE || pMem1->enc==SQLITE_UTF16BE );
71043
71044 /* The collation sequence must be defined at this point, even if
71045 ** the user deletes the collation sequence after the vdbe program is
@@ -75667,42 +75671,41 @@
75671 }
75672 }else{
75673 /* Neither operand is NULL. Do a comparison. */
75674 affinity = pOp->p5 & SQLITE_AFF_MASK;
75675 if( affinity>=SQLITE_AFF_NUMERIC ){
75676 if( (flags1 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
75677 applyNumericAffinity(pIn1,0);
75678 }
75679 if( (flags3 & (MEM_Int|MEM_Real|MEM_Str))==MEM_Str ){
75680 applyNumericAffinity(pIn3,0);
75681 }
75682 }else if( affinity==SQLITE_AFF_TEXT ){
75683 if( (flags1 & MEM_Str)==0 && (flags1 & (MEM_Int|MEM_Real))!=0 ){
75684 testcase( pIn1->flags & MEM_Int );
75685 testcase( pIn1->flags & MEM_Real );
75686 sqlite3VdbeMemStringify(pIn1, encoding, 1);
75687 testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
75688 flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
75689 }
75690 if( (flags3 & MEM_Str)==0 && (flags3 & (MEM_Int|MEM_Real))!=0 ){
75691 testcase( pIn3->flags & MEM_Int );
75692 testcase( pIn3->flags & MEM_Real );
75693 sqlite3VdbeMemStringify(pIn3, encoding, 1);
75694 testcase( (flags3&MEM_Dyn) != (pIn3->flags&MEM_Dyn) );
75695 flags3 = (pIn3->flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask);
75696 }
75697 }
75698 assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
75699 if( flags1 & MEM_Zero ){
75700 sqlite3VdbeMemExpandBlob(pIn1);
75701 flags1 &= ~MEM_Zero;
75702 }
75703 if( flags3 & MEM_Zero ){
75704 sqlite3VdbeMemExpandBlob(pIn3);
75705 flags3 &= ~MEM_Zero;
75706 }
 
75707 res = sqlite3MemCompare(pIn3, pIn1, pOp->p4.pColl);
75708 }
75709 switch( pOp->opcode ){
75710 case OP_Eq: res = res==0; break;
75711 case OP_Ne: res = res!=0; break;
@@ -94733,19 +94736,19 @@
94736 }
94737
94738 /* Set properties of a table column based on the (magical)
94739 ** name of the column.
94740 */
 
94741 #if SQLITE_ENABLE_HIDDEN_COLUMNS
94742 SQLITE_PRIVATE void sqlite3ColumnPropertiesFromName(Table *pTab, Column *pCol){
94743 if( sqlite3_strnicmp(pCol->zName, "__hidden__", 10)==0 ){
94744 pCol->colFlags |= COLFLAG_HIDDEN;
94745 }else if( pTab && pCol!=pTab->aCol && (pCol[-1].colFlags & COLFLAG_HIDDEN) ){
94746 pTab->tabFlags |= TF_OOOHidden;
94747 }
94748 }
94749 #endif
 
94750
94751
94752 /*
94753 ** Add a new column to the table currently being constructed.
94754 **
@@ -95321,11 +95324,11 @@
95324 assert( pIdx->isResized==0 );
95325 nByte = (sizeof(char*) + sizeof(i16) + 1)*N;
95326 zExtra = sqlite3DbMallocZero(db, nByte);
95327 if( zExtra==0 ) return SQLITE_NOMEM;
95328 memcpy(zExtra, pIdx->azColl, sizeof(char*)*pIdx->nColumn);
95329 pIdx->azColl = (const char**)zExtra;
95330 zExtra += sizeof(char*)*N;
95331 memcpy(zExtra, pIdx->aiColumn, sizeof(i16)*pIdx->nColumn);
95332 pIdx->aiColumn = (i16*)zExtra;
95333 zExtra += sizeof(i16)*N;
95334 memcpy(zExtra, pIdx->aSortOrder, pIdx->nColumn);
@@ -95502,11 +95505,11 @@
95505 if( resizeIndexObject(db, pPk, pTab->nCol) ) return;
95506 for(i=0, j=nPk; i<pTab->nCol; i++){
95507 if( !hasColumn(pPk->aiColumn, j, i) ){
95508 assert( j<pPk->nColumn );
95509 pPk->aiColumn[j] = i;
95510 pPk->azColl[j] = sqlite3StrBINARY;
95511 j++;
95512 }
95513 }
95514 assert( pPk->nColumn==j );
95515 assert( pTab->nCol==j );
@@ -96552,11 +96555,11 @@
96555 sizeof(i16)*nCol + /* Index.aiColumn */
96556 sizeof(u8)*nCol); /* Index.aSortOrder */
96557 p = sqlite3DbMallocZero(db, nByte + nExtra);
96558 if( p ){
96559 char *pExtra = ((char*)p)+ROUND8(sizeof(Index));
96560 p->azColl = (const char**)pExtra; pExtra += ROUND8(sizeof(char*)*nCol);
96561 p->aiRowLogEst = (LogEst*)pExtra; pExtra += sizeof(LogEst)*(nCol+1);
96562 p->aiColumn = (i16*)pExtra; pExtra += sizeof(i16)*nCol;
96563 p->aSortOrder = (u8*)pExtra;
96564 p->nColumn = nCol;
96565 p->nKeyCol = nCol - 1;
@@ -96829,11 +96832,11 @@
96832 ** index key.
96833 */
96834 for(i=0, pListItem=pList->a; i<pList->nExpr; i++, pListItem++){
96835 Expr *pCExpr; /* The i-th index expression */
96836 int requestedSortOrder; /* ASC or DESC on the i-th expression */
96837 const char *zColl; /* Collation sequence name */
96838
96839 sqlite3StringToId(pListItem->pExpr);
96840 sqlite3ResolveSelfReference(pParse, pTab, NC_IdxExpr, pListItem->pExpr, 0);
96841 if( pParse->nErr ) goto exit_create_index;
96842 pCExpr = sqlite3ExprSkipCollate(pListItem->pExpr);
@@ -96875,11 +96878,11 @@
96878 zExtra += nColl;
96879 nExtra -= nColl;
96880 }else if( j>=0 ){
96881 zColl = pTab->aCol[j].zColl;
96882 }
96883 if( !zColl ) zColl = sqlite3StrBINARY;
96884 if( !db->init.busy && !sqlite3LocateCollSeq(pParse, zColl) ){
96885 goto exit_create_index;
96886 }
96887 pIndex->azColl[i] = zColl;
96888 requestedSortOrder = pListItem->sortOrder & sortOrderMask;
@@ -96904,11 +96907,11 @@
96907 }
96908 }
96909 assert( i==pIndex->nColumn );
96910 }else{
96911 pIndex->aiColumn[i] = XN_ROWID;
96912 pIndex->azColl[i] = sqlite3StrBINARY;
96913 }
96914 sqlite3DefaultRowEst(pIndex);
96915 if( pParse->pNewTable==0 ) estimateIndexWidth(pIndex);
96916
96917 if( pTab==pParse->pNewTable ){
@@ -98028,13 +98031,12 @@
98031 pKey = sqlite3KeyInfoAlloc(pParse->db, nCol, 0);
98032 }
98033 if( pKey ){
98034 assert( sqlite3KeyInfoIsWriteable(pKey) );
98035 for(i=0; i<nCol; i++){
98036 const char *zColl = pIdx->azColl[i];
98037 pKey->aColl[i] = zColl==sqlite3StrBINARY ? 0 :
 
98038 sqlite3LocateCollSeq(pParse, zColl);
98039 pKey->aSortOrder[i] = pIdx->aSortOrder[i];
98040 }
98041 if( pParse->nErr ){
98042 sqlite3KeyInfoUnref(pKey);
@@ -100240,11 +100242,11 @@
100242 continue;
100243 }
100244 }
100245 c2 = Utf8Read(zString);
100246 if( c==c2 ) continue;
100247 if( noCase && sqlite3Tolower(c)==sqlite3Tolower(c2) ){
100248 continue;
100249 }
100250 if( c==matchOne && zPattern!=zEscaped && c2!=0 ) continue;
100251 return 0;
100252 }
@@ -101559,22 +101561,20 @@
101561 ** index matches those columns. Also, check that the index uses
101562 ** the default collation sequences for each column. */
101563 int i, j;
101564 for(i=0; i<nCol; i++){
101565 i16 iCol = pIdx->aiColumn[i]; /* Index of column in parent tbl */
101566 const char *zDfltColl; /* Def. collation for column */
101567 char *zIdxCol; /* Name of indexed column */
101568
101569 if( iCol<0 ) break; /* No foreign keys against expression indexes */
101570
101571 /* If the index uses a collation sequence that is different from
101572 ** the default collation sequence for the column, this index is
101573 ** unusable. Bail out early in this case. */
101574 zDfltColl = pParent->aCol[iCol].zColl;
101575 if( !zDfltColl ) zDfltColl = sqlite3StrBINARY;
 
 
101576 if( sqlite3StrICmp(pIdx->azColl[i], zDfltColl) ) break;
101577
101578 zIdxCol = pParent->aCol[iCol].zName;
101579 for(j=0; j<nCol; j++){
101580 if( sqlite3StrICmp(pFKey->aCol[j].zCol, zIdxCol)==0 ){
@@ -104432,24 +104432,10 @@
104432 SQLITE_API int sqlite3_xferopt_count;
104433 #endif /* SQLITE_TEST */
104434
104435
104436 #ifndef SQLITE_OMIT_XFER_OPT
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104437 /*
104438 ** Check to see if index pSrc is compatible as a source of data
104439 ** for index pDest in an insert transfer optimization. The rules
104440 ** for a compatible index:
104441 **
@@ -104481,11 +104467,11 @@
104467 }
104468 }
104469 if( pSrc->aSortOrder[i]!=pDest->aSortOrder[i] ){
104470 return 0; /* Different sort orders */
104471 }
104472 if( sqlite3_stricmp(pSrc->azColl[i],pDest->azColl[i])!=0 ){
104473 return 0; /* Different collating sequences */
104474 }
104475 }
104476 if( sqlite3ExprCompare(pSrc->pPartIdxWhere, pDest->pPartIdxWhere, -1) ){
104477 return 0; /* Different WHERE clauses */
@@ -104642,11 +104628,11 @@
104628 }
104629 #endif
104630 if( pDestCol->affinity!=pSrcCol->affinity ){
104631 return 0; /* Affinity must be the same on all columns */
104632 }
104633 if( sqlite3_stricmp(pDestCol->zColl, pSrcCol->zColl)!=0 ){
104634 return 0; /* Collating sequence must be the same on all columns */
104635 }
104636 if( pDestCol->notNull && !pSrcCol->notNull ){
104637 return 0; /* tab2 must be NOT NULL if tab1 is */
104638 }
@@ -104789,13 +104775,14 @@
104775 ** BINARY, this optimization is disabled. This is because the user
104776 ** might change the definition of a collation sequence and then run
104777 ** a VACUUM command. In that case keys may not be written in strictly
104778 ** sorted order. */
104779 for(i=0; i<pSrcIdx->nColumn; i++){
104780 const char *zColl = pSrcIdx->azColl[i];
104781 assert( sqlite3_stricmp(sqlite3StrBINARY, zColl)!=0
104782 || sqlite3StrBINARY==zColl );
104783 if( sqlite3_stricmp(sqlite3StrBINARY, zColl) ) break;
104784 }
104785 if( i==pSrcIdx->nColumn ){
104786 idxInsFlags = OPFLAG_USESEEKRESULT;
104787 sqlite3VdbeAddOp3(v, OP_Last, iDest, 0, -1);
104788 }
@@ -119292,11 +119279,11 @@
119279 ** terms in the WHERE clause that are useful to the query planner.
119280 */
119281 struct WhereScan {
119282 WhereClause *pOrigWC; /* Original, innermost WhereClause */
119283 WhereClause *pWC; /* WhereClause currently being scanned */
119284 const char *zCollName; /* Required collating sequence, if not NULL */
119285 Expr *pIdxExpr; /* Search for this index expression */
119286 char idxaff; /* Must match this affinity, if zCollName!=NULL */
119287 unsigned char nEquiv; /* Number of entries in aEquiv[] */
119288 unsigned char iEquiv; /* Next unused slot in aEquiv[] */
119289 u32 opMask; /* Acceptable operators */
@@ -123278,11 +123265,11 @@
123265 if( (idxCols & cMask)==0 ){
123266 Expr *pX = pTerm->pExpr;
123267 idxCols |= cMask;
123268 pIdx->aiColumn[n] = pTerm->u.leftColumn;
123269 pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);
123270 pIdx->azColl[n] = pColl ? pColl->zName : sqlite3StrBINARY;
123271 n++;
123272 }
123273 }
123274 }
123275 assert( (u32)n==pLoop->u.btree.nEq );
@@ -123290,24 +123277,24 @@
123277 /* Add additional columns needed to make the automatic index into
123278 ** a covering index */
123279 for(i=0; i<mxBitCol; i++){
123280 if( extraCols & MASKBIT(i) ){
123281 pIdx->aiColumn[n] = i;
123282 pIdx->azColl[n] = sqlite3StrBINARY;
123283 n++;
123284 }
123285 }
123286 if( pSrc->colUsed & MASKBIT(BMS-1) ){
123287 for(i=BMS-1; i<pTable->nCol; i++){
123288 pIdx->aiColumn[n] = i;
123289 pIdx->azColl[n] = sqlite3StrBINARY;
123290 n++;
123291 }
123292 }
123293 assert( n==nKeyCol );
123294 pIdx->aiColumn[n] = XN_ROWID;
123295 pIdx->azColl[n] = sqlite3StrBINARY;
123296
123297 /* Create the automatic index */
123298 assert( pLevel->iIdxCur>=0 );
123299 pLevel->iIdxCur = pParse->nTab++;
123300 sqlite3VdbeAddOp2(v, OP_OpenAutoindex, pLevel->iIdxCur, nKeyCol+1);
@@ -134858,22 +134845,22 @@
134845 ** conversions. The only error that can occur here is a malloc() failure.
134846 **
134847 ** EVIDENCE-OF: R-52786-44878 SQLite defines three built-in collating
134848 ** functions:
134849 */
134850 createCollation(db, sqlite3StrBINARY, SQLITE_UTF8, 0, binCollFunc, 0);
134851 createCollation(db, sqlite3StrBINARY, SQLITE_UTF16BE, 0, binCollFunc, 0);
134852 createCollation(db, sqlite3StrBINARY, SQLITE_UTF16LE, 0, binCollFunc, 0);
134853 createCollation(db, "NOCASE", SQLITE_UTF8, 0, nocaseCollatingFunc, 0);
134854 createCollation(db, "RTRIM", SQLITE_UTF8, (void*)1, binCollFunc, 0);
134855 if( db->mallocFailed ){
134856 goto opendb_out;
134857 }
134858 /* EVIDENCE-OF: R-08308-17224 The default collating function for all
134859 ** strings is BINARY.
134860 */
134861 db->pDfltColl = sqlite3FindCollSeq(db, SQLITE_UTF8, sqlite3StrBINARY, 0);
134862 assert( db->pDfltColl!=0 );
134863
134864 /* Parse the filename/URI argument. */
134865 db->openFlags = flags;
134866 rc = sqlite3ParseUri(zVfs, zFilename, &flags, &db->pVfs, &zOpen, &zErrMsg);
@@ -135369,11 +135356,11 @@
135356 }else{
135357 zDataType = "INTEGER";
135358 primarykey = 1;
135359 }
135360 if( !zCollSeq ){
135361 zCollSeq = sqlite3StrBINARY;
135362 }
135363
135364 error_out:
135365 sqlite3BtreeLeaveAll(db);
135366
@@ -135977,11 +135964,10 @@
135964 */
135965 SQLITE_API void SQLITE_STDCALL sqlite3_snapshot_free(sqlite3_snapshot *pSnapshot){
135966 sqlite3_free(pSnapshot);
135967 }
135968 #endif /* SQLITE_ENABLE_SNAPSHOT */
 
135969
135970 /************** End of main.c ************************************************/
135971 /************** Begin file notify.c ******************************************/
135972 /*
135973 ** 2009 March 3
@@ -166098,11 +166084,11 @@
166084 sqlite3_result_int(ctx, sqlite3_value_subtype(argv[0])==JSON_SUBTYPE);
166085 }
166086 #endif /* SQLITE_DEBUG */
166087
166088 /****************************************************************************
166089 ** Scalar SQL function implementations
166090 ****************************************************************************/
166091
166092 /*
166093 ** Implementation of the json_array(VALUE,...) function. Return a JSON
166094 ** array that contains all values given in arguments. Or if any argument
@@ -166430,10 +166416,106 @@
166416 rc = 1;
166417 }
166418 jsonParseReset(&x);
166419 sqlite3_result_int(ctx, rc);
166420 }
166421
166422
166423 /****************************************************************************
166424 ** Aggregate SQL function implementations
166425 ****************************************************************************/
166426 /*
166427 ** json_group_array(VALUE)
166428 **
166429 ** Return a JSON array composed of all values in the aggregate.
166430 */
166431 static void jsonArrayStep(
166432 sqlite3_context *ctx,
166433 int argc,
166434 sqlite3_value **argv
166435 ){
166436 JsonString *pStr;
166437 pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
166438 if( pStr ){
166439 if( pStr->zBuf==0 ){
166440 jsonInit(pStr, ctx);
166441 jsonAppendChar(pStr, '[');
166442 }else{
166443 jsonAppendChar(pStr, ',');
166444 pStr->pCtx = ctx;
166445 }
166446 jsonAppendValue(pStr, argv[0]);
166447 }
166448 }
166449 static void jsonArrayFinal(sqlite3_context *ctx){
166450 JsonString *pStr;
166451 pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
166452 if( pStr ){
166453 pStr->pCtx = ctx;
166454 jsonAppendChar(pStr, ']');
166455 if( pStr->bErr ){
166456 sqlite3_result_error_nomem(ctx);
166457 if( !pStr->bStatic ) sqlite3_free(pStr->zBuf);
166458 }else{
166459 sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,
166460 pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);
166461 pStr->bStatic = 1;
166462 }
166463 }else{
166464 sqlite3_result_text(ctx, "[]", 2, SQLITE_STATIC);
166465 }
166466 sqlite3_result_subtype(ctx, JSON_SUBTYPE);
166467 }
166468
166469 /*
166470 ** json_group_obj(NAME,VALUE)
166471 **
166472 ** Return a JSON object composed of all names and values in the aggregate.
166473 */
166474 static void jsonObjectStep(
166475 sqlite3_context *ctx,
166476 int argc,
166477 sqlite3_value **argv
166478 ){
166479 JsonString *pStr;
166480 const char *z;
166481 u32 n;
166482 pStr = (JsonString*)sqlite3_aggregate_context(ctx, sizeof(*pStr));
166483 if( pStr ){
166484 if( pStr->zBuf==0 ){
166485 jsonInit(pStr, ctx);
166486 jsonAppendChar(pStr, '{');
166487 }else{
166488 jsonAppendChar(pStr, ',');
166489 pStr->pCtx = ctx;
166490 }
166491 z = (const char*)sqlite3_value_text(argv[0]);
166492 n = (u32)sqlite3_value_bytes(argv[0]);
166493 jsonAppendString(pStr, z, n);
166494 jsonAppendChar(pStr, ':');
166495 jsonAppendValue(pStr, argv[1]);
166496 }
166497 }
166498 static void jsonObjectFinal(sqlite3_context *ctx){
166499 JsonString *pStr;
166500 pStr = (JsonString*)sqlite3_aggregate_context(ctx, 0);
166501 if( pStr ){
166502 jsonAppendChar(pStr, '}');
166503 if( pStr->bErr ){
166504 sqlite3_result_error_nomem(ctx);
166505 if( !pStr->bStatic ) sqlite3_free(pStr->zBuf);
166506 }else{
166507 sqlite3_result_text(ctx, pStr->zBuf, pStr->nUsed,
166508 pStr->bStatic ? SQLITE_TRANSIENT : sqlite3_free);
166509 pStr->bStatic = 1;
166510 }
166511 }else{
166512 sqlite3_result_text(ctx, "{}", 2, SQLITE_STATIC);
166513 }
166514 sqlite3_result_subtype(ctx, JSON_SUBTYPE);
166515 }
166516
166517
166518 #ifndef SQLITE_OMIT_VIRTUALTABLE
166519 /****************************************************************************
166520 ** The json_each virtual table
166521 ****************************************************************************/
@@ -166929,10 +167011,19 @@
167011 /* DEBUG and TESTING functions */
167012 { "json_parse", 1, 0, jsonParseFunc },
167013 { "json_test1", 1, 0, jsonTest1Func },
167014 #endif
167015 };
167016 static const struct {
167017 const char *zName;
167018 int nArg;
167019 void (*xStep)(sqlite3_context*,int,sqlite3_value**);
167020 void (*xFinal)(sqlite3_context*);
167021 } aAgg[] = {
167022 { "json_group_array", 1, jsonArrayStep, jsonArrayFinal },
167023 { "json_group_object", 2, jsonObjectStep, jsonObjectFinal },
167024 };
167025 #ifndef SQLITE_OMIT_VIRTUALTABLE
167026 static const struct {
167027 const char *zName;
167028 sqlite3_module *pModule;
167029 } aMod[] = {
@@ -166944,10 +167035,15 @@
167035 rc = sqlite3_create_function(db, aFunc[i].zName, aFunc[i].nArg,
167036 SQLITE_UTF8 | SQLITE_DETERMINISTIC,
167037 (void*)&aFunc[i].flag,
167038 aFunc[i].xFunc, 0, 0);
167039 }
167040 for(i=0; i<sizeof(aAgg)/sizeof(aAgg[0]) && rc==SQLITE_OK; i++){
167041 rc = sqlite3_create_function(db, aAgg[i].zName, aAgg[i].nArg,
167042 SQLITE_UTF8 | SQLITE_DETERMINISTIC, 0,
167043 0, aAgg[i].xStep, aAgg[i].xFinal);
167044 }
167045 #ifndef SQLITE_OMIT_VIRTUALTABLE
167046 for(i=0; i<sizeof(aMod)/sizeof(aMod[0]) && rc==SQLITE_OK; i++){
167047 rc = sqlite3_create_module(db, aMod[i].zName, aMod[i].pModule, 0);
167048 }
167049 #endif
@@ -182141,11 +182237,11 @@
182237 sqlite3_context *pCtx, /* Function call context */
182238 int nArg, /* Number of args */
182239 sqlite3_value **apVal /* Function arguments */
182240 ){
182241 assert( nArg==0 );
182242 sqlite3_result_text(pCtx, "fts5: 2015-12-30 14:06:22 0a99a8c4facf65ec67d8d86108c9a3f723f7cbd6", -1, SQLITE_TRANSIENT);
182243 }
182244
182245 static int fts5Init(sqlite3 *db){
182246 static const sqlite3_module fts5Mod = {
182247 /* iVersion */ 2,
182248
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -111,11 +111,11 @@
111111
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112112
** [sqlite_version()] and [sqlite_source_id()].
113113
*/
114114
#define SQLITE_VERSION "3.10.0"
115115
#define SQLITE_VERSION_NUMBER 3010000
116
-#define SQLITE_SOURCE_ID "2015-12-24 14:53:27 7c7b7f26306b6aa6ff35b871ad756f43f5db9838"
116
+#define SQLITE_SOURCE_ID "2015-12-31 15:34:03 9c392c1019ee15f27c8e05b41246d2844f91f6c0"
117117
118118
/*
119119
** CAPI3REF: Run-Time Library Version Numbers
120120
** KEYWORDS: sqlite3_version, sqlite3_sourceid
121121
**
122122
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -111,11 +111,11 @@
111 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112 ** [sqlite_version()] and [sqlite_source_id()].
113 */
114 #define SQLITE_VERSION "3.10.0"
115 #define SQLITE_VERSION_NUMBER 3010000
116 #define SQLITE_SOURCE_ID "2015-12-24 14:53:27 7c7b7f26306b6aa6ff35b871ad756f43f5db9838"
117
118 /*
119 ** CAPI3REF: Run-Time Library Version Numbers
120 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
121 **
122
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -111,11 +111,11 @@
111 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112 ** [sqlite_version()] and [sqlite_source_id()].
113 */
114 #define SQLITE_VERSION "3.10.0"
115 #define SQLITE_VERSION_NUMBER 3010000
116 #define SQLITE_SOURCE_ID "2015-12-31 15:34:03 9c392c1019ee15f27c8e05b41246d2844f91f6c0"
117
118 /*
119 ** CAPI3REF: Run-Time Library Version Numbers
120 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
121 **
122

Keyboard Shortcuts

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