Fossil SCM

Update the built-in SQLite to the latest trunk version, for testing purposes.

drh 2021-07-21 17:13 trunk
Commit cd90fc91141cc2c203a1b1d30cbac3d7b5055dd8942951426fa65cb25330fbc9
3 files changed +42 -12 +1544 -1168 +62 -13
+42 -12
--- src/shell.c
+++ src/shell.c
@@ -33,10 +33,22 @@
3333
#if (defined(_WIN32) || defined(WIN32)) && !defined(_CRT_SECURE_NO_WARNINGS)
3434
/* This needs to come before any includes for MSVC compiler */
3535
#define _CRT_SECURE_NO_WARNINGS
3636
#endif
3737
38
+/*
39
+** Optionally #include a user-defined header, whereby compilation options
40
+** may be set prior to where they take effect, but after platform setup.
41
+** If SQLITE_CUSTOM_INCLUDE=? is defined, its value names the #include
42
+** file. Note that this macro has a like effect on sqlite3.c compilation.
43
+*/
44
+#ifdef SQLITE_CUSTOM_INCLUDE
45
+# define INC_STRINGIFY_(f) #f
46
+# define INC_STRINGIFY(f) INC_STRINGIFY_(f)
47
+# include INC_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
48
+#endif
49
+
3850
/*
3951
** Determine if we are dealing with WinRT, which provides only a subset of
4052
** the full Win32 API.
4153
*/
4254
#if !defined(SQLITE_OS_WINRT)
@@ -5759,34 +5771,36 @@
57595771
** (2) stop = $value -- constraint exists
57605772
** (4) step = $value -- constraint exists
57615773
** (8) output in descending order
57625774
*/
57635775
static int seriesBestIndex(
5764
- sqlite3_vtab *tabUnused,
5776
+ sqlite3_vtab *pVTab,
57655777
sqlite3_index_info *pIdxInfo
57665778
){
57675779
int i, j; /* Loop over constraints */
57685780
int idxNum = 0; /* The query plan bitmask */
5781
+ int bStartSeen = 0; /* EQ constraint seen on the START column */
57695782
int unusableMask = 0; /* Mask of unusable constraints */
57705783
int nArg = 0; /* Number of arguments that seriesFilter() expects */
57715784
int aIdx[3]; /* Constraints on start, stop, and step */
57725785
const struct sqlite3_index_constraint *pConstraint;
57735786
57745787
/* This implementation assumes that the start, stop, and step columns
57755788
** are the last three columns in the virtual table. */
57765789
assert( SERIES_COLUMN_STOP == SERIES_COLUMN_START+1 );
57775790
assert( SERIES_COLUMN_STEP == SERIES_COLUMN_START+2 );
5778
- (void)tabUnused;
5791
+
57795792
aIdx[0] = aIdx[1] = aIdx[2] = -1;
57805793
pConstraint = pIdxInfo->aConstraint;
57815794
for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
57825795
int iCol; /* 0 for start, 1 for stop, 2 for step */
57835796
int iMask; /* bitmask for those column */
57845797
if( pConstraint->iColumn<SERIES_COLUMN_START ) continue;
57855798
iCol = pConstraint->iColumn - SERIES_COLUMN_START;
57865799
assert( iCol>=0 && iCol<=2 );
57875800
iMask = 1 << iCol;
5801
+ if( iCol==0 ) bStartSeen = 1;
57885802
if( pConstraint->usable==0 ){
57895803
unusableMask |= iMask;
57905804
continue;
57915805
}else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){
57925806
idxNum |= iMask;
@@ -5797,10 +5811,22 @@
57975811
if( (j = aIdx[i])>=0 ){
57985812
pIdxInfo->aConstraintUsage[j].argvIndex = ++nArg;
57995813
pIdxInfo->aConstraintUsage[j].omit = !SQLITE_SERIES_CONSTRAINT_VERIFY;
58005814
}
58015815
}
5816
+ /* The current generate_column() implementation requires at least one
5817
+ ** argument (the START value). Legacy versions assumed START=0 if the
5818
+ ** first argument was omitted. Compile with -DZERO_ARGUMENT_GENERATE_SERIES
5819
+ ** to obtain the legacy behavior */
5820
+#ifndef ZERO_ARGUMENT_GENERATE_SERIES
5821
+ if( !bStartSeen ){
5822
+ sqlite3_free(pVTab->zErrMsg);
5823
+ pVTab->zErrMsg = sqlite3_mprintf(
5824
+ "first argument to \"generate_series()\" missing or unusable");
5825
+ return SQLITE_ERROR;
5826
+ }
5827
+#endif
58025828
if( (unusableMask & ~idxNum)!=0 ){
58035829
/* The start, stop, and step columns are inputs. Therefore if there
58045830
** are unusable constraints on any of start, stop, or step then
58055831
** this plan is unusable */
58065832
return SQLITE_CONSTRAINT;
@@ -9850,15 +9876,17 @@
98509876
int nPk = 0;
98519877
98529878
rc = idxPrintfPrepareStmt(db, &p1, pzErrmsg, "PRAGMA table_xinfo=%Q", zTab);
98539879
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){
98549880
const char *zCol = (const char*)sqlite3_column_text(p1, 1);
9881
+ const char *zColSeq = 0;
98559882
nByte += 1 + STRLEN(zCol);
98569883
rc = sqlite3_table_column_metadata(
9857
- db, "main", zTab, zCol, 0, &zCol, 0, 0, 0
9884
+ db, "main", zTab, zCol, 0, &zColSeq, 0, 0, 0
98589885
);
9859
- nByte += 1 + STRLEN(zCol);
9886
+ if( zColSeq==0 ) zColSeq = "binary";
9887
+ nByte += 1 + STRLEN(zColSeq);
98609888
nCol++;
98619889
nPk += (sqlite3_column_int(p1, 5)>0);
98629890
}
98639891
rc2 = sqlite3_reset(p1);
98649892
if( rc==SQLITE_OK ) rc = rc2;
@@ -9874,23 +9902,25 @@
98749902
}
98759903
98769904
nCol = 0;
98779905
while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){
98789906
const char *zCol = (const char*)sqlite3_column_text(p1, 1);
9907
+ const char *zColSeq = 0;
98799908
int nCopy = STRLEN(zCol) + 1;
98809909
pNew->aCol[nCol].zName = pCsr;
98819910
pNew->aCol[nCol].iPk = (sqlite3_column_int(p1, 5)==1 && nPk==1);
98829911
memcpy(pCsr, zCol, nCopy);
98839912
pCsr += nCopy;
98849913
98859914
rc = sqlite3_table_column_metadata(
9886
- db, "main", zTab, zCol, 0, &zCol, 0, 0, 0
9915
+ db, "main", zTab, zCol, 0, &zColSeq, 0, 0, 0
98879916
);
98889917
if( rc==SQLITE_OK ){
9889
- nCopy = STRLEN(zCol) + 1;
9918
+ if( zColSeq==0 ) zColSeq = "binary";
9919
+ nCopy = STRLEN(zColSeq) + 1;
98909920
pNew->aCol[nCol].zColl = pCsr;
9891
- memcpy(pCsr, zCol, nCopy);
9921
+ memcpy(pCsr, zColSeq, nCopy);
98929922
pCsr += nCopy;
98939923
}
98949924
98959925
nCol++;
98969926
}
@@ -19000,11 +19030,11 @@
1900019030
"SELECT sql FROM"
1900119031
" (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
1900219032
" FROM sqlite_schema UNION ALL"
1900319033
" SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_schema) "
1900419034
"WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' "
19005
- "ORDER BY rowid",
19035
+ "ORDER BY x",
1900619036
callback, &data, 0
1900719037
);
1900819038
if( rc==SQLITE_OK ){
1900919039
sqlite3_stmt *pStmt;
1901019040
rc = sqlite3_prepare_v2(p->db,
@@ -19016,12 +19046,10 @@
1901619046
}
1901719047
if( doStats==0 ){
1901819048
raw_printf(p->out, "/* No STAT tables available */\n");
1901919049
}else{
1902019050
raw_printf(p->out, "ANALYZE sqlite_schema;\n");
19021
- sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_schema'",
19022
- callback, &data, 0);
1902319051
data.cMode = data.mode = MODE_Insert;
1902419052
data.zDestTable = "sqlite_stat1";
1902519053
shell_exec(&data, "SELECT * FROM sqlite_stat1", 0);
1902619054
data.zDestTable = "sqlite_stat4";
1902719055
shell_exec(&data, "SELECT * FROM sqlite_stat4", 0);
@@ -19670,10 +19698,12 @@
1967019698
p->openMode = SHELL_OPEN_APPENDVFS;
1967119699
}else if( optionMatch(z, "readonly") ){
1967219700
p->openMode = SHELL_OPEN_READONLY;
1967319701
}else if( optionMatch(z, "nofollow") ){
1967419702
p->openFlags |= SQLITE_OPEN_NOFOLLOW;
19703
+ }else if( optionMatch(z, "excl") ){
19704
+ p->openFlags |= SQLITE_OPEN_EXCLUSIVE;
1967519705
#ifndef SQLITE_OMIT_DESERIALIZE
1967619706
}else if( optionMatch(z, "deserialize") ){
1967719707
p->openMode = SHELL_OPEN_DESERIALIZE;
1967819708
}else if( optionMatch(z, "hexdb") ){
1967919709
p->openMode = SHELL_OPEN_HEXDB;
@@ -21463,12 +21493,12 @@
2146321493
}else{
2146421494
utf8_printf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db));
2146521495
}
2146621496
return 1;
2146721497
}else if( ShellHasFlag(p, SHFLG_CountChanges) ){
21468
- raw_printf(p->out, "changes: %3d total_changes: %d\n",
21469
- sqlite3_changes(p->db), sqlite3_total_changes(p->db));
21498
+ raw_printf(p->out, "changes: %3lld total_changes: %lld\n",
21499
+ sqlite3_changes64(p->db), sqlite3_total_changes64(p->db));
2147021500
}
2147121501
return 0;
2147221502
}
2147321503
2147421504
2147521505
--- src/shell.c
+++ src/shell.c
@@ -33,10 +33,22 @@
33 #if (defined(_WIN32) || defined(WIN32)) && !defined(_CRT_SECURE_NO_WARNINGS)
34 /* This needs to come before any includes for MSVC compiler */
35 #define _CRT_SECURE_NO_WARNINGS
36 #endif
37
 
 
 
 
 
 
 
 
 
 
 
 
38 /*
39 ** Determine if we are dealing with WinRT, which provides only a subset of
40 ** the full Win32 API.
41 */
42 #if !defined(SQLITE_OS_WINRT)
@@ -5759,34 +5771,36 @@
5759 ** (2) stop = $value -- constraint exists
5760 ** (4) step = $value -- constraint exists
5761 ** (8) output in descending order
5762 */
5763 static int seriesBestIndex(
5764 sqlite3_vtab *tabUnused,
5765 sqlite3_index_info *pIdxInfo
5766 ){
5767 int i, j; /* Loop over constraints */
5768 int idxNum = 0; /* The query plan bitmask */
 
5769 int unusableMask = 0; /* Mask of unusable constraints */
5770 int nArg = 0; /* Number of arguments that seriesFilter() expects */
5771 int aIdx[3]; /* Constraints on start, stop, and step */
5772 const struct sqlite3_index_constraint *pConstraint;
5773
5774 /* This implementation assumes that the start, stop, and step columns
5775 ** are the last three columns in the virtual table. */
5776 assert( SERIES_COLUMN_STOP == SERIES_COLUMN_START+1 );
5777 assert( SERIES_COLUMN_STEP == SERIES_COLUMN_START+2 );
5778 (void)tabUnused;
5779 aIdx[0] = aIdx[1] = aIdx[2] = -1;
5780 pConstraint = pIdxInfo->aConstraint;
5781 for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
5782 int iCol; /* 0 for start, 1 for stop, 2 for step */
5783 int iMask; /* bitmask for those column */
5784 if( pConstraint->iColumn<SERIES_COLUMN_START ) continue;
5785 iCol = pConstraint->iColumn - SERIES_COLUMN_START;
5786 assert( iCol>=0 && iCol<=2 );
5787 iMask = 1 << iCol;
 
5788 if( pConstraint->usable==0 ){
5789 unusableMask |= iMask;
5790 continue;
5791 }else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){
5792 idxNum |= iMask;
@@ -5797,10 +5811,22 @@
5797 if( (j = aIdx[i])>=0 ){
5798 pIdxInfo->aConstraintUsage[j].argvIndex = ++nArg;
5799 pIdxInfo->aConstraintUsage[j].omit = !SQLITE_SERIES_CONSTRAINT_VERIFY;
5800 }
5801 }
 
 
 
 
 
 
 
 
 
 
 
 
5802 if( (unusableMask & ~idxNum)!=0 ){
5803 /* The start, stop, and step columns are inputs. Therefore if there
5804 ** are unusable constraints on any of start, stop, or step then
5805 ** this plan is unusable */
5806 return SQLITE_CONSTRAINT;
@@ -9850,15 +9876,17 @@
9850 int nPk = 0;
9851
9852 rc = idxPrintfPrepareStmt(db, &p1, pzErrmsg, "PRAGMA table_xinfo=%Q", zTab);
9853 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){
9854 const char *zCol = (const char*)sqlite3_column_text(p1, 1);
 
9855 nByte += 1 + STRLEN(zCol);
9856 rc = sqlite3_table_column_metadata(
9857 db, "main", zTab, zCol, 0, &zCol, 0, 0, 0
9858 );
9859 nByte += 1 + STRLEN(zCol);
 
9860 nCol++;
9861 nPk += (sqlite3_column_int(p1, 5)>0);
9862 }
9863 rc2 = sqlite3_reset(p1);
9864 if( rc==SQLITE_OK ) rc = rc2;
@@ -9874,23 +9902,25 @@
9874 }
9875
9876 nCol = 0;
9877 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){
9878 const char *zCol = (const char*)sqlite3_column_text(p1, 1);
 
9879 int nCopy = STRLEN(zCol) + 1;
9880 pNew->aCol[nCol].zName = pCsr;
9881 pNew->aCol[nCol].iPk = (sqlite3_column_int(p1, 5)==1 && nPk==1);
9882 memcpy(pCsr, zCol, nCopy);
9883 pCsr += nCopy;
9884
9885 rc = sqlite3_table_column_metadata(
9886 db, "main", zTab, zCol, 0, &zCol, 0, 0, 0
9887 );
9888 if( rc==SQLITE_OK ){
9889 nCopy = STRLEN(zCol) + 1;
 
9890 pNew->aCol[nCol].zColl = pCsr;
9891 memcpy(pCsr, zCol, nCopy);
9892 pCsr += nCopy;
9893 }
9894
9895 nCol++;
9896 }
@@ -19000,11 +19030,11 @@
19000 "SELECT sql FROM"
19001 " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
19002 " FROM sqlite_schema UNION ALL"
19003 " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_schema) "
19004 "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' "
19005 "ORDER BY rowid",
19006 callback, &data, 0
19007 );
19008 if( rc==SQLITE_OK ){
19009 sqlite3_stmt *pStmt;
19010 rc = sqlite3_prepare_v2(p->db,
@@ -19016,12 +19046,10 @@
19016 }
19017 if( doStats==0 ){
19018 raw_printf(p->out, "/* No STAT tables available */\n");
19019 }else{
19020 raw_printf(p->out, "ANALYZE sqlite_schema;\n");
19021 sqlite3_exec(p->db, "SELECT 'ANALYZE sqlite_schema'",
19022 callback, &data, 0);
19023 data.cMode = data.mode = MODE_Insert;
19024 data.zDestTable = "sqlite_stat1";
19025 shell_exec(&data, "SELECT * FROM sqlite_stat1", 0);
19026 data.zDestTable = "sqlite_stat4";
19027 shell_exec(&data, "SELECT * FROM sqlite_stat4", 0);
@@ -19670,10 +19698,12 @@
19670 p->openMode = SHELL_OPEN_APPENDVFS;
19671 }else if( optionMatch(z, "readonly") ){
19672 p->openMode = SHELL_OPEN_READONLY;
19673 }else if( optionMatch(z, "nofollow") ){
19674 p->openFlags |= SQLITE_OPEN_NOFOLLOW;
 
 
19675 #ifndef SQLITE_OMIT_DESERIALIZE
19676 }else if( optionMatch(z, "deserialize") ){
19677 p->openMode = SHELL_OPEN_DESERIALIZE;
19678 }else if( optionMatch(z, "hexdb") ){
19679 p->openMode = SHELL_OPEN_HEXDB;
@@ -21463,12 +21493,12 @@
21463 }else{
21464 utf8_printf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db));
21465 }
21466 return 1;
21467 }else if( ShellHasFlag(p, SHFLG_CountChanges) ){
21468 raw_printf(p->out, "changes: %3d total_changes: %d\n",
21469 sqlite3_changes(p->db), sqlite3_total_changes(p->db));
21470 }
21471 return 0;
21472 }
21473
21474
21475
--- src/shell.c
+++ src/shell.c
@@ -33,10 +33,22 @@
33 #if (defined(_WIN32) || defined(WIN32)) && !defined(_CRT_SECURE_NO_WARNINGS)
34 /* This needs to come before any includes for MSVC compiler */
35 #define _CRT_SECURE_NO_WARNINGS
36 #endif
37
38 /*
39 ** Optionally #include a user-defined header, whereby compilation options
40 ** may be set prior to where they take effect, but after platform setup.
41 ** If SQLITE_CUSTOM_INCLUDE=? is defined, its value names the #include
42 ** file. Note that this macro has a like effect on sqlite3.c compilation.
43 */
44 #ifdef SQLITE_CUSTOM_INCLUDE
45 # define INC_STRINGIFY_(f) #f
46 # define INC_STRINGIFY(f) INC_STRINGIFY_(f)
47 # include INC_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
48 #endif
49
50 /*
51 ** Determine if we are dealing with WinRT, which provides only a subset of
52 ** the full Win32 API.
53 */
54 #if !defined(SQLITE_OS_WINRT)
@@ -5759,34 +5771,36 @@
5771 ** (2) stop = $value -- constraint exists
5772 ** (4) step = $value -- constraint exists
5773 ** (8) output in descending order
5774 */
5775 static int seriesBestIndex(
5776 sqlite3_vtab *pVTab,
5777 sqlite3_index_info *pIdxInfo
5778 ){
5779 int i, j; /* Loop over constraints */
5780 int idxNum = 0; /* The query plan bitmask */
5781 int bStartSeen = 0; /* EQ constraint seen on the START column */
5782 int unusableMask = 0; /* Mask of unusable constraints */
5783 int nArg = 0; /* Number of arguments that seriesFilter() expects */
5784 int aIdx[3]; /* Constraints on start, stop, and step */
5785 const struct sqlite3_index_constraint *pConstraint;
5786
5787 /* This implementation assumes that the start, stop, and step columns
5788 ** are the last three columns in the virtual table. */
5789 assert( SERIES_COLUMN_STOP == SERIES_COLUMN_START+1 );
5790 assert( SERIES_COLUMN_STEP == SERIES_COLUMN_START+2 );
5791
5792 aIdx[0] = aIdx[1] = aIdx[2] = -1;
5793 pConstraint = pIdxInfo->aConstraint;
5794 for(i=0; i<pIdxInfo->nConstraint; i++, pConstraint++){
5795 int iCol; /* 0 for start, 1 for stop, 2 for step */
5796 int iMask; /* bitmask for those column */
5797 if( pConstraint->iColumn<SERIES_COLUMN_START ) continue;
5798 iCol = pConstraint->iColumn - SERIES_COLUMN_START;
5799 assert( iCol>=0 && iCol<=2 );
5800 iMask = 1 << iCol;
5801 if( iCol==0 ) bStartSeen = 1;
5802 if( pConstraint->usable==0 ){
5803 unusableMask |= iMask;
5804 continue;
5805 }else if( pConstraint->op==SQLITE_INDEX_CONSTRAINT_EQ ){
5806 idxNum |= iMask;
@@ -5797,10 +5811,22 @@
5811 if( (j = aIdx[i])>=0 ){
5812 pIdxInfo->aConstraintUsage[j].argvIndex = ++nArg;
5813 pIdxInfo->aConstraintUsage[j].omit = !SQLITE_SERIES_CONSTRAINT_VERIFY;
5814 }
5815 }
5816 /* The current generate_column() implementation requires at least one
5817 ** argument (the START value). Legacy versions assumed START=0 if the
5818 ** first argument was omitted. Compile with -DZERO_ARGUMENT_GENERATE_SERIES
5819 ** to obtain the legacy behavior */
5820 #ifndef ZERO_ARGUMENT_GENERATE_SERIES
5821 if( !bStartSeen ){
5822 sqlite3_free(pVTab->zErrMsg);
5823 pVTab->zErrMsg = sqlite3_mprintf(
5824 "first argument to \"generate_series()\" missing or unusable");
5825 return SQLITE_ERROR;
5826 }
5827 #endif
5828 if( (unusableMask & ~idxNum)!=0 ){
5829 /* The start, stop, and step columns are inputs. Therefore if there
5830 ** are unusable constraints on any of start, stop, or step then
5831 ** this plan is unusable */
5832 return SQLITE_CONSTRAINT;
@@ -9850,15 +9876,17 @@
9876 int nPk = 0;
9877
9878 rc = idxPrintfPrepareStmt(db, &p1, pzErrmsg, "PRAGMA table_xinfo=%Q", zTab);
9879 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){
9880 const char *zCol = (const char*)sqlite3_column_text(p1, 1);
9881 const char *zColSeq = 0;
9882 nByte += 1 + STRLEN(zCol);
9883 rc = sqlite3_table_column_metadata(
9884 db, "main", zTab, zCol, 0, &zColSeq, 0, 0, 0
9885 );
9886 if( zColSeq==0 ) zColSeq = "binary";
9887 nByte += 1 + STRLEN(zColSeq);
9888 nCol++;
9889 nPk += (sqlite3_column_int(p1, 5)>0);
9890 }
9891 rc2 = sqlite3_reset(p1);
9892 if( rc==SQLITE_OK ) rc = rc2;
@@ -9874,23 +9902,25 @@
9902 }
9903
9904 nCol = 0;
9905 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(p1) ){
9906 const char *zCol = (const char*)sqlite3_column_text(p1, 1);
9907 const char *zColSeq = 0;
9908 int nCopy = STRLEN(zCol) + 1;
9909 pNew->aCol[nCol].zName = pCsr;
9910 pNew->aCol[nCol].iPk = (sqlite3_column_int(p1, 5)==1 && nPk==1);
9911 memcpy(pCsr, zCol, nCopy);
9912 pCsr += nCopy;
9913
9914 rc = sqlite3_table_column_metadata(
9915 db, "main", zTab, zCol, 0, &zColSeq, 0, 0, 0
9916 );
9917 if( rc==SQLITE_OK ){
9918 if( zColSeq==0 ) zColSeq = "binary";
9919 nCopy = STRLEN(zColSeq) + 1;
9920 pNew->aCol[nCol].zColl = pCsr;
9921 memcpy(pCsr, zColSeq, nCopy);
9922 pCsr += nCopy;
9923 }
9924
9925 nCol++;
9926 }
@@ -19000,11 +19030,11 @@
19030 "SELECT sql FROM"
19031 " (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
19032 " FROM sqlite_schema UNION ALL"
19033 " SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_schema) "
19034 "WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' "
19035 "ORDER BY x",
19036 callback, &data, 0
19037 );
19038 if( rc==SQLITE_OK ){
19039 sqlite3_stmt *pStmt;
19040 rc = sqlite3_prepare_v2(p->db,
@@ -19016,12 +19046,10 @@
19046 }
19047 if( doStats==0 ){
19048 raw_printf(p->out, "/* No STAT tables available */\n");
19049 }else{
19050 raw_printf(p->out, "ANALYZE sqlite_schema;\n");
 
 
19051 data.cMode = data.mode = MODE_Insert;
19052 data.zDestTable = "sqlite_stat1";
19053 shell_exec(&data, "SELECT * FROM sqlite_stat1", 0);
19054 data.zDestTable = "sqlite_stat4";
19055 shell_exec(&data, "SELECT * FROM sqlite_stat4", 0);
@@ -19670,10 +19698,12 @@
19698 p->openMode = SHELL_OPEN_APPENDVFS;
19699 }else if( optionMatch(z, "readonly") ){
19700 p->openMode = SHELL_OPEN_READONLY;
19701 }else if( optionMatch(z, "nofollow") ){
19702 p->openFlags |= SQLITE_OPEN_NOFOLLOW;
19703 }else if( optionMatch(z, "excl") ){
19704 p->openFlags |= SQLITE_OPEN_EXCLUSIVE;
19705 #ifndef SQLITE_OMIT_DESERIALIZE
19706 }else if( optionMatch(z, "deserialize") ){
19707 p->openMode = SHELL_OPEN_DESERIALIZE;
19708 }else if( optionMatch(z, "hexdb") ){
19709 p->openMode = SHELL_OPEN_HEXDB;
@@ -21463,12 +21493,12 @@
21493 }else{
21494 utf8_printf(stderr, "%s %s\n", zPrefix, sqlite3_errmsg(p->db));
21495 }
21496 return 1;
21497 }else if( ShellHasFlag(p, SHFLG_CountChanges) ){
21498 raw_printf(p->out, "changes: %3lld total_changes: %lld\n",
21499 sqlite3_changes64(p->db), sqlite3_total_changes64(p->db));
21500 }
21501 return 0;
21502 }
21503
21504
21505
+1544 -1168
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.36.0. By combining all the individual C code files into this
3
+** version 3.37.0. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -20,797 +20,10 @@
2020
#define SQLITE_CORE 1
2121
#define SQLITE_AMALGAMATION 1
2222
#ifndef SQLITE_PRIVATE
2323
# define SQLITE_PRIVATE static
2424
#endif
25
-/************** Begin file ctime.c *******************************************/
26
-/*
27
-** 2010 February 23
28
-**
29
-** The author disclaims copyright to this source code. In place of
30
-** a legal notice, here is a blessing:
31
-**
32
-** May you do good and not evil.
33
-** May you find forgiveness for yourself and forgive others.
34
-** May you share freely, never taking more than you give.
35
-**
36
-*************************************************************************
37
-**
38
-** This file implements routines used to report what compile-time options
39
-** SQLite was built with.
40
-*/
41
-
42
-#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS /* IMP: R-16824-07538 */
43
-
44
-/*
45
-** Include the configuration header output by 'configure' if we're using the
46
-** autoconf-based build
47
-*/
48
-#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
49
-#include "config.h"
50
-#define SQLITECONFIG_H 1
51
-#endif
52
-
53
-/* These macros are provided to "stringify" the value of the define
54
-** for those options in which the value is meaningful. */
55
-#define CTIMEOPT_VAL_(opt) #opt
56
-#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
57
-
58
-/* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This
59
-** option requires a separate macro because legal values contain a single
60
-** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE="100,100") */
61
-#define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
62
-#define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)
63
-
64
-/*
65
-** An array of names of all compile-time options. This array should
66
-** be sorted A-Z.
67
-**
68
-** This array looks large, but in a typical installation actually uses
69
-** only a handful of compile-time options, so most times this array is usually
70
-** rather short and uses little memory space.
71
-*/
72
-static const char * const sqlite3azCompileOpt[] = {
73
-
74
-/*
75
-** BEGIN CODE GENERATED BY tool/mkctime.tcl
76
-*/
77
-#if SQLITE_32BIT_ROWID
78
- "32BIT_ROWID",
79
-#endif
80
-#if SQLITE_4_BYTE_ALIGNED_MALLOC
81
- "4_BYTE_ALIGNED_MALLOC",
82
-#endif
83
-#if SQLITE_64BIT_STATS
84
- "64BIT_STATS",
85
-#endif
86
-#ifdef SQLITE_ALLOW_COVERING_INDEX_SCAN
87
-# if SQLITE_ALLOW_COVERING_INDEX_SCAN != 1
88
- "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN),
89
-# endif
90
-#endif
91
-#if SQLITE_ALLOW_URI_AUTHORITY
92
- "ALLOW_URI_AUTHORITY",
93
-#endif
94
-#ifdef SQLITE_BITMASK_TYPE
95
- "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),
96
-#endif
97
-#if SQLITE_BUG_COMPATIBLE_20160819
98
- "BUG_COMPATIBLE_20160819",
99
-#endif
100
-#if SQLITE_CASE_SENSITIVE_LIKE
101
- "CASE_SENSITIVE_LIKE",
102
-#endif
103
-#if SQLITE_CHECK_PAGES
104
- "CHECK_PAGES",
105
-#endif
106
-#if defined(__clang__) && defined(__clang_major__)
107
- "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
108
- CTIMEOPT_VAL(__clang_minor__) "."
109
- CTIMEOPT_VAL(__clang_patchlevel__),
110
-#elif defined(_MSC_VER)
111
- "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
112
-#elif defined(__GNUC__) && defined(__VERSION__)
113
- "COMPILER=gcc-" __VERSION__,
114
-#endif
115
-#if SQLITE_COVERAGE_TEST
116
- "COVERAGE_TEST",
117
-#endif
118
-#if SQLITE_DEBUG
119
- "DEBUG",
120
-#endif
121
-#if SQLITE_DEFAULT_AUTOMATIC_INDEX
122
- "DEFAULT_AUTOMATIC_INDEX",
123
-#endif
124
-#if SQLITE_DEFAULT_AUTOVACUUM
125
- "DEFAULT_AUTOVACUUM",
126
-#endif
127
-#ifdef SQLITE_DEFAULT_CACHE_SIZE
128
- "DEFAULT_CACHE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE),
129
-#endif
130
-#if SQLITE_DEFAULT_CKPTFULLFSYNC
131
- "DEFAULT_CKPTFULLFSYNC",
132
-#endif
133
-#ifdef SQLITE_DEFAULT_FILE_FORMAT
134
- "DEFAULT_FILE_FORMAT=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT),
135
-#endif
136
-#ifdef SQLITE_DEFAULT_FILE_PERMISSIONS
137
- "DEFAULT_FILE_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS),
138
-#endif
139
-#if SQLITE_DEFAULT_FOREIGN_KEYS
140
- "DEFAULT_FOREIGN_KEYS",
141
-#endif
142
-#ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
143
- "DEFAULT_JOURNAL_SIZE_LIMIT=" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT),
144
-#endif
145
-#ifdef SQLITE_DEFAULT_LOCKING_MODE
146
- "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
147
-#endif
148
-#ifdef SQLITE_DEFAULT_LOOKASIDE
149
- "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE),
150
-#endif
151
-#ifdef SQLITE_DEFAULT_MEMSTATUS
152
-# if SQLITE_DEFAULT_MEMSTATUS != 1
153
- "DEFAULT_MEMSTATUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_MEMSTATUS),
154
-# endif
155
-#endif
156
-#ifdef SQLITE_DEFAULT_MMAP_SIZE
157
- "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
158
-#endif
159
-#ifdef SQLITE_DEFAULT_PAGE_SIZE
160
- "DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE),
161
-#endif
162
-#ifdef SQLITE_DEFAULT_PCACHE_INITSZ
163
- "DEFAULT_PCACHE_INITSZ=" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ),
164
-#endif
165
-#ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS
166
- "DEFAULT_PROXYDIR_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS),
167
-#endif
168
-#if SQLITE_DEFAULT_RECURSIVE_TRIGGERS
169
- "DEFAULT_RECURSIVE_TRIGGERS",
170
-#endif
171
-#ifdef SQLITE_DEFAULT_ROWEST
172
- "DEFAULT_ROWEST=" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST),
173
-#endif
174
-#ifdef SQLITE_DEFAULT_SECTOR_SIZE
175
- "DEFAULT_SECTOR_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE),
176
-#endif
177
-#ifdef SQLITE_DEFAULT_SYNCHRONOUS
178
- "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),
179
-#endif
180
-#ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
181
- "DEFAULT_WAL_AUTOCHECKPOINT=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT),
182
-#endif
183
-#ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS
184
- "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),
185
-#endif
186
-#ifdef SQLITE_DEFAULT_WORKER_THREADS
187
- "DEFAULT_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS),
188
-#endif
189
-#if SQLITE_DIRECT_OVERFLOW_READ
190
- "DIRECT_OVERFLOW_READ",
191
-#endif
192
-#if SQLITE_DISABLE_DIRSYNC
193
- "DISABLE_DIRSYNC",
194
-#endif
195
-#if SQLITE_DISABLE_FTS3_UNICODE
196
- "DISABLE_FTS3_UNICODE",
197
-#endif
198
-#if SQLITE_DISABLE_FTS4_DEFERRED
199
- "DISABLE_FTS4_DEFERRED",
200
-#endif
201
-#if SQLITE_DISABLE_INTRINSIC
202
- "DISABLE_INTRINSIC",
203
-#endif
204
-#if SQLITE_DISABLE_LFS
205
- "DISABLE_LFS",
206
-#endif
207
-#if SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
208
- "DISABLE_PAGECACHE_OVERFLOW_STATS",
209
-#endif
210
-#if SQLITE_DISABLE_SKIPAHEAD_DISTINCT
211
- "DISABLE_SKIPAHEAD_DISTINCT",
212
-#endif
213
-#ifdef SQLITE_ENABLE_8_3_NAMES
214
- "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
215
-#endif
216
-#if SQLITE_ENABLE_API_ARMOR
217
- "ENABLE_API_ARMOR",
218
-#endif
219
-#if SQLITE_ENABLE_ATOMIC_WRITE
220
- "ENABLE_ATOMIC_WRITE",
221
-#endif
222
-#if SQLITE_ENABLE_BATCH_ATOMIC_WRITE
223
- "ENABLE_BATCH_ATOMIC_WRITE",
224
-#endif
225
-#if SQLITE_ENABLE_BYTECODE_VTAB
226
- "ENABLE_BYTECODE_VTAB",
227
-#endif
228
-#ifdef SQLITE_ENABLE_CEROD
229
- "ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD),
230
-#endif
231
-#if SQLITE_ENABLE_COLUMN_METADATA
232
- "ENABLE_COLUMN_METADATA",
233
-#endif
234
-#if SQLITE_ENABLE_COLUMN_USED_MASK
235
- "ENABLE_COLUMN_USED_MASK",
236
-#endif
237
-#if SQLITE_ENABLE_COSTMULT
238
- "ENABLE_COSTMULT",
239
-#endif
240
-#if SQLITE_ENABLE_CURSOR_HINTS
241
- "ENABLE_CURSOR_HINTS",
242
-#endif
243
-#if SQLITE_ENABLE_DBPAGE_VTAB
244
- "ENABLE_DBPAGE_VTAB",
245
-#endif
246
-#if SQLITE_ENABLE_DBSTAT_VTAB
247
- "ENABLE_DBSTAT_VTAB",
248
-#endif
249
-#if SQLITE_ENABLE_EXPENSIVE_ASSERT
250
- "ENABLE_EXPENSIVE_ASSERT",
251
-#endif
252
-#if SQLITE_ENABLE_EXPLAIN_COMMENTS
253
- "ENABLE_EXPLAIN_COMMENTS",
254
-#endif
255
-#if SQLITE_ENABLE_FTS3
256
- "ENABLE_FTS3",
257
-#endif
258
-#if SQLITE_ENABLE_FTS3_PARENTHESIS
259
- "ENABLE_FTS3_PARENTHESIS",
260
-#endif
261
-#if SQLITE_ENABLE_FTS3_TOKENIZER
262
- "ENABLE_FTS3_TOKENIZER",
263
-#endif
264
-#if SQLITE_ENABLE_FTS4
265
- "ENABLE_FTS4",
266
-#endif
267
-#if SQLITE_ENABLE_FTS5
268
- "ENABLE_FTS5",
269
-#endif
270
-#if SQLITE_ENABLE_GEOPOLY
271
- "ENABLE_GEOPOLY",
272
-#endif
273
-#if SQLITE_ENABLE_HIDDEN_COLUMNS
274
- "ENABLE_HIDDEN_COLUMNS",
275
-#endif
276
-#if SQLITE_ENABLE_ICU
277
- "ENABLE_ICU",
278
-#endif
279
-#if SQLITE_ENABLE_IOTRACE
280
- "ENABLE_IOTRACE",
281
-#endif
282
-#if SQLITE_ENABLE_JSON1
283
- "ENABLE_JSON1",
284
-#endif
285
-#if SQLITE_ENABLE_LOAD_EXTENSION
286
- "ENABLE_LOAD_EXTENSION",
287
-#endif
288
-#ifdef SQLITE_ENABLE_LOCKING_STYLE
289
- "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
290
-#endif
291
-#if SQLITE_ENABLE_MATH_FUNCTIONS
292
- "ENABLE_MATH_FUNCTIONS",
293
-#endif
294
-#if SQLITE_ENABLE_MEMORY_MANAGEMENT
295
- "ENABLE_MEMORY_MANAGEMENT",
296
-#endif
297
-#if SQLITE_ENABLE_MEMSYS3
298
- "ENABLE_MEMSYS3",
299
-#endif
300
-#if SQLITE_ENABLE_MEMSYS5
301
- "ENABLE_MEMSYS5",
302
-#endif
303
-#if SQLITE_ENABLE_MULTIPLEX
304
- "ENABLE_MULTIPLEX",
305
-#endif
306
-#if SQLITE_ENABLE_NORMALIZE
307
- "ENABLE_NORMALIZE",
308
-#endif
309
-#if SQLITE_ENABLE_NULL_TRIM
310
- "ENABLE_NULL_TRIM",
311
-#endif
312
-#if SQLITE_ENABLE_OFFSET_SQL_FUNC
313
- "ENABLE_OFFSET_SQL_FUNC",
314
-#endif
315
-#if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
316
- "ENABLE_OVERSIZE_CELL_CHECK",
317
-#endif
318
-#if SQLITE_ENABLE_PREUPDATE_HOOK
319
- "ENABLE_PREUPDATE_HOOK",
320
-#endif
321
-#if SQLITE_ENABLE_QPSG
322
- "ENABLE_QPSG",
323
-#endif
324
-#if SQLITE_ENABLE_RBU
325
- "ENABLE_RBU",
326
-#endif
327
-#if SQLITE_ENABLE_RTREE
328
- "ENABLE_RTREE",
329
-#endif
330
-#if SQLITE_ENABLE_SELECTTRACE
331
- "ENABLE_SELECTTRACE",
332
-#endif
333
-#if SQLITE_ENABLE_SESSION
334
- "ENABLE_SESSION",
335
-#endif
336
-#if SQLITE_ENABLE_SNAPSHOT
337
- "ENABLE_SNAPSHOT",
338
-#endif
339
-#if SQLITE_ENABLE_SORTER_REFERENCES
340
- "ENABLE_SORTER_REFERENCES",
341
-#endif
342
-#if SQLITE_ENABLE_SQLLOG
343
- "ENABLE_SQLLOG",
344
-#endif
345
-#if SQLITE_ENABLE_STAT4
346
- "ENABLE_STAT4",
347
-#endif
348
-#if SQLITE_ENABLE_STMTVTAB
349
- "ENABLE_STMTVTAB",
350
-#endif
351
-#if SQLITE_ENABLE_STMT_SCANSTATUS
352
- "ENABLE_STMT_SCANSTATUS",
353
-#endif
354
-#if SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
355
- "ENABLE_UNKNOWN_SQL_FUNCTION",
356
-#endif
357
-#if SQLITE_ENABLE_UNLOCK_NOTIFY
358
- "ENABLE_UNLOCK_NOTIFY",
359
-#endif
360
-#if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
361
- "ENABLE_UPDATE_DELETE_LIMIT",
362
-#endif
363
-#if SQLITE_ENABLE_URI_00_ERROR
364
- "ENABLE_URI_00_ERROR",
365
-#endif
366
-#if SQLITE_ENABLE_VFSTRACE
367
- "ENABLE_VFSTRACE",
368
-#endif
369
-#if SQLITE_ENABLE_WHERETRACE
370
- "ENABLE_WHERETRACE",
371
-#endif
372
-#if SQLITE_ENABLE_ZIPVFS
373
- "ENABLE_ZIPVFS",
374
-#endif
375
-#if SQLITE_EXPLAIN_ESTIMATED_ROWS
376
- "EXPLAIN_ESTIMATED_ROWS",
377
-#endif
378
-#if SQLITE_EXTRA_IFNULLROW
379
- "EXTRA_IFNULLROW",
380
-#endif
381
-#ifdef SQLITE_EXTRA_INIT
382
- "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT),
383
-#endif
384
-#ifdef SQLITE_EXTRA_SHUTDOWN
385
- "EXTRA_SHUTDOWN=" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN),
386
-#endif
387
-#ifdef SQLITE_FTS3_MAX_EXPR_DEPTH
388
- "FTS3_MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH),
389
-#endif
390
-#if SQLITE_FTS5_ENABLE_TEST_MI
391
- "FTS5_ENABLE_TEST_MI",
392
-#endif
393
-#if SQLITE_FTS5_NO_WITHOUT_ROWID
394
- "FTS5_NO_WITHOUT_ROWID",
395
-#endif
396
-#if HAVE_ISNAN || SQLITE_HAVE_ISNAN
397
- "HAVE_ISNAN",
398
-#endif
399
-#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
400
-# if SQLITE_HOMEGROWN_RECURSIVE_MUTEX != 1
401
- "HOMEGROWN_RECURSIVE_MUTEX=" CTIMEOPT_VAL(SQLITE_HOMEGROWN_RECURSIVE_MUTEX),
402
-# endif
403
-#endif
404
-#if SQLITE_IGNORE_AFP_LOCK_ERRORS
405
- "IGNORE_AFP_LOCK_ERRORS",
406
-#endif
407
-#if SQLITE_IGNORE_FLOCK_LOCK_ERRORS
408
- "IGNORE_FLOCK_LOCK_ERRORS",
409
-#endif
410
-#if SQLITE_INLINE_MEMCPY
411
- "INLINE_MEMCPY",
412
-#endif
413
-#if SQLITE_INT64_TYPE
414
- "INT64_TYPE",
415
-#endif
416
-#ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX
417
- "INTEGRITY_CHECK_ERROR_MAX=" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX),
418
-#endif
419
-#if SQLITE_LIKE_DOESNT_MATCH_BLOBS
420
- "LIKE_DOESNT_MATCH_BLOBS",
421
-#endif
422
-#if SQLITE_LOCK_TRACE
423
- "LOCK_TRACE",
424
-#endif
425
-#if SQLITE_LOG_CACHE_SPILL
426
- "LOG_CACHE_SPILL",
427
-#endif
428
-#ifdef SQLITE_MALLOC_SOFT_LIMIT
429
- "MALLOC_SOFT_LIMIT=" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT),
430
-#endif
431
-#ifdef SQLITE_MAX_ATTACHED
432
- "MAX_ATTACHED=" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED),
433
-#endif
434
-#ifdef SQLITE_MAX_COLUMN
435
- "MAX_COLUMN=" CTIMEOPT_VAL(SQLITE_MAX_COLUMN),
436
-#endif
437
-#ifdef SQLITE_MAX_COMPOUND_SELECT
438
- "MAX_COMPOUND_SELECT=" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT),
439
-#endif
440
-#ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE
441
- "MAX_DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE),
442
-#endif
443
-#ifdef SQLITE_MAX_EXPR_DEPTH
444
- "MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH),
445
-#endif
446
-#ifdef SQLITE_MAX_FUNCTION_ARG
447
- "MAX_FUNCTION_ARG=" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG),
448
-#endif
449
-#ifdef SQLITE_MAX_LENGTH
450
- "MAX_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LENGTH),
451
-#endif
452
-#ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH
453
- "MAX_LIKE_PATTERN_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH),
454
-#endif
455
-#ifdef SQLITE_MAX_MEMORY
456
- "MAX_MEMORY=" CTIMEOPT_VAL(SQLITE_MAX_MEMORY),
457
-#endif
458
-#ifdef SQLITE_MAX_MMAP_SIZE
459
- "MAX_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),
460
-#endif
461
-#ifdef SQLITE_MAX_MMAP_SIZE_
462
- "MAX_MMAP_SIZE_=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_),
463
-#endif
464
-#ifdef SQLITE_MAX_PAGE_COUNT
465
- "MAX_PAGE_COUNT=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT),
466
-#endif
467
-#ifdef SQLITE_MAX_PAGE_SIZE
468
- "MAX_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE),
469
-#endif
470
-#ifdef SQLITE_MAX_SCHEMA_RETRY
471
- "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
472
-#endif
473
-#ifdef SQLITE_MAX_SQL_LENGTH
474
- "MAX_SQL_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH),
475
-#endif
476
-#ifdef SQLITE_MAX_TRIGGER_DEPTH
477
- "MAX_TRIGGER_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH),
478
-#endif
479
-#ifdef SQLITE_MAX_VARIABLE_NUMBER
480
- "MAX_VARIABLE_NUMBER=" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER),
481
-#endif
482
-#ifdef SQLITE_MAX_VDBE_OP
483
- "MAX_VDBE_OP=" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP),
484
-#endif
485
-#ifdef SQLITE_MAX_WORKER_THREADS
486
- "MAX_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS),
487
-#endif
488
-#if SQLITE_MEMDEBUG
489
- "MEMDEBUG",
490
-#endif
491
-#if SQLITE_MIXED_ENDIAN_64BIT_FLOAT
492
- "MIXED_ENDIAN_64BIT_FLOAT",
493
-#endif
494
-#if SQLITE_MMAP_READWRITE
495
- "MMAP_READWRITE",
496
-#endif
497
-#if SQLITE_MUTEX_NOOP
498
- "MUTEX_NOOP",
499
-#endif
500
-#if SQLITE_MUTEX_OMIT
501
- "MUTEX_OMIT",
502
-#endif
503
-#if SQLITE_MUTEX_PTHREADS
504
- "MUTEX_PTHREADS",
505
-#endif
506
-#if SQLITE_MUTEX_W32
507
- "MUTEX_W32",
508
-#endif
509
-#if SQLITE_NEED_ERR_NAME
510
- "NEED_ERR_NAME",
511
-#endif
512
-#if SQLITE_NOINLINE
513
- "NOINLINE",
514
-#endif
515
-#if SQLITE_NO_SYNC
516
- "NO_SYNC",
517
-#endif
518
-#if SQLITE_OMIT_ALTERTABLE
519
- "OMIT_ALTERTABLE",
520
-#endif
521
-#if SQLITE_OMIT_ANALYZE
522
- "OMIT_ANALYZE",
523
-#endif
524
-#if SQLITE_OMIT_ATTACH
525
- "OMIT_ATTACH",
526
-#endif
527
-#if SQLITE_OMIT_AUTHORIZATION
528
- "OMIT_AUTHORIZATION",
529
-#endif
530
-#if SQLITE_OMIT_AUTOINCREMENT
531
- "OMIT_AUTOINCREMENT",
532
-#endif
533
-#if SQLITE_OMIT_AUTOINIT
534
- "OMIT_AUTOINIT",
535
-#endif
536
-#if SQLITE_OMIT_AUTOMATIC_INDEX
537
- "OMIT_AUTOMATIC_INDEX",
538
-#endif
539
-#if SQLITE_OMIT_AUTORESET
540
- "OMIT_AUTORESET",
541
-#endif
542
-#if SQLITE_OMIT_AUTOVACUUM
543
- "OMIT_AUTOVACUUM",
544
-#endif
545
-#if SQLITE_OMIT_BETWEEN_OPTIMIZATION
546
- "OMIT_BETWEEN_OPTIMIZATION",
547
-#endif
548
-#if SQLITE_OMIT_BLOB_LITERAL
549
- "OMIT_BLOB_LITERAL",
550
-#endif
551
-#if SQLITE_OMIT_CAST
552
- "OMIT_CAST",
553
-#endif
554
-#if SQLITE_OMIT_CHECK
555
- "OMIT_CHECK",
556
-#endif
557
-#if SQLITE_OMIT_COMPLETE
558
- "OMIT_COMPLETE",
559
-#endif
560
-#if SQLITE_OMIT_COMPOUND_SELECT
561
- "OMIT_COMPOUND_SELECT",
562
-#endif
563
-#if SQLITE_OMIT_CONFLICT_CLAUSE
564
- "OMIT_CONFLICT_CLAUSE",
565
-#endif
566
-#if SQLITE_OMIT_CTE
567
- "OMIT_CTE",
568
-#endif
569
-#if defined(SQLITE_OMIT_DATETIME_FUNCS) || defined(SQLITE_OMIT_FLOATING_POINT)
570
- "OMIT_DATETIME_FUNCS",
571
-#endif
572
-#if SQLITE_OMIT_DECLTYPE
573
- "OMIT_DECLTYPE",
574
-#endif
575
-#if SQLITE_OMIT_DEPRECATED
576
- "OMIT_DEPRECATED",
577
-#endif
578
-#if SQLITE_OMIT_DESERIALIZE
579
- "OMIT_DESERIALIZE",
580
-#endif
581
-#if SQLITE_OMIT_DISKIO
582
- "OMIT_DISKIO",
583
-#endif
584
-#if SQLITE_OMIT_EXPLAIN
585
- "OMIT_EXPLAIN",
586
-#endif
587
-#if SQLITE_OMIT_FLAG_PRAGMAS
588
- "OMIT_FLAG_PRAGMAS",
589
-#endif
590
-#if SQLITE_OMIT_FLOATING_POINT
591
- "OMIT_FLOATING_POINT",
592
-#endif
593
-#if SQLITE_OMIT_FOREIGN_KEY
594
- "OMIT_FOREIGN_KEY",
595
-#endif
596
-#if SQLITE_OMIT_GET_TABLE
597
- "OMIT_GET_TABLE",
598
-#endif
599
-#if SQLITE_OMIT_HEX_INTEGER
600
- "OMIT_HEX_INTEGER",
601
-#endif
602
-#if SQLITE_OMIT_INCRBLOB
603
- "OMIT_INCRBLOB",
604
-#endif
605
-#if SQLITE_OMIT_INTEGRITY_CHECK
606
- "OMIT_INTEGRITY_CHECK",
607
-#endif
608
-#if SQLITE_OMIT_INTROSPECTION_PRAGMAS
609
- "OMIT_INTROSPECTION_PRAGMAS",
610
-#endif
611
-#if SQLITE_OMIT_LIKE_OPTIMIZATION
612
- "OMIT_LIKE_OPTIMIZATION",
613
-#endif
614
-#if SQLITE_OMIT_LOAD_EXTENSION
615
- "OMIT_LOAD_EXTENSION",
616
-#endif
617
-#if SQLITE_OMIT_LOCALTIME
618
- "OMIT_LOCALTIME",
619
-#endif
620
-#if SQLITE_OMIT_LOOKASIDE
621
- "OMIT_LOOKASIDE",
622
-#endif
623
-#if SQLITE_OMIT_MEMORYDB
624
- "OMIT_MEMORYDB",
625
-#endif
626
-#if SQLITE_OMIT_OR_OPTIMIZATION
627
- "OMIT_OR_OPTIMIZATION",
628
-#endif
629
-#if SQLITE_OMIT_PAGER_PRAGMAS
630
- "OMIT_PAGER_PRAGMAS",
631
-#endif
632
-#if SQLITE_OMIT_PARSER_TRACE
633
- "OMIT_PARSER_TRACE",
634
-#endif
635
-#if SQLITE_OMIT_POPEN
636
- "OMIT_POPEN",
637
-#endif
638
-#if SQLITE_OMIT_PRAGMA
639
- "OMIT_PRAGMA",
640
-#endif
641
-#if SQLITE_OMIT_PROGRESS_CALLBACK
642
- "OMIT_PROGRESS_CALLBACK",
643
-#endif
644
-#if SQLITE_OMIT_QUICKBALANCE
645
- "OMIT_QUICKBALANCE",
646
-#endif
647
-#if SQLITE_OMIT_REINDEX
648
- "OMIT_REINDEX",
649
-#endif
650
-#if SQLITE_OMIT_SCHEMA_PRAGMAS
651
- "OMIT_SCHEMA_PRAGMAS",
652
-#endif
653
-#if SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
654
- "OMIT_SCHEMA_VERSION_PRAGMAS",
655
-#endif
656
-#if SQLITE_OMIT_SHARED_CACHE
657
- "OMIT_SHARED_CACHE",
658
-#endif
659
-#if SQLITE_OMIT_SHUTDOWN_DIRECTORIES
660
- "OMIT_SHUTDOWN_DIRECTORIES",
661
-#endif
662
-#if SQLITE_OMIT_SUBQUERY
663
- "OMIT_SUBQUERY",
664
-#endif
665
-#if SQLITE_OMIT_TCL_VARIABLE
666
- "OMIT_TCL_VARIABLE",
667
-#endif
668
-#if SQLITE_OMIT_TEMPDB
669
- "OMIT_TEMPDB",
670
-#endif
671
-#if SQLITE_OMIT_TEST_CONTROL
672
- "OMIT_TEST_CONTROL",
673
-#endif
674
-#ifdef SQLITE_OMIT_TRACE
675
-# if SQLITE_OMIT_TRACE != 1
676
- "OMIT_TRACE=" CTIMEOPT_VAL(SQLITE_OMIT_TRACE),
677
-# endif
678
-#endif
679
-#if SQLITE_OMIT_TRIGGER
680
- "OMIT_TRIGGER",
681
-#endif
682
-#if SQLITE_OMIT_TRUNCATE_OPTIMIZATION
683
- "OMIT_TRUNCATE_OPTIMIZATION",
684
-#endif
685
-#if SQLITE_OMIT_UTF16
686
- "OMIT_UTF16",
687
-#endif
688
-#if SQLITE_OMIT_VACUUM
689
- "OMIT_VACUUM",
690
-#endif
691
-#if SQLITE_OMIT_VIEW
692
- "OMIT_VIEW",
693
-#endif
694
-#if SQLITE_OMIT_VIRTUALTABLE
695
- "OMIT_VIRTUALTABLE",
696
-#endif
697
-#if SQLITE_OMIT_WAL
698
- "OMIT_WAL",
699
-#endif
700
-#if SQLITE_OMIT_WSD
701
- "OMIT_WSD",
702
-#endif
703
-#if SQLITE_OMIT_XFER_OPT
704
- "OMIT_XFER_OPT",
705
-#endif
706
-#if SQLITE_PCACHE_SEPARATE_HEADER
707
- "PCACHE_SEPARATE_HEADER",
708
-#endif
709
-#if SQLITE_PERFORMANCE_TRACE
710
- "PERFORMANCE_TRACE",
711
-#endif
712
-#ifdef SQLITE_POWERSAFE_OVERWRITE
713
-# if SQLITE_POWERSAFE_OVERWRITE != 1
714
- "POWERSAFE_OVERWRITE=" CTIMEOPT_VAL(SQLITE_POWERSAFE_OVERWRITE),
715
-# endif
716
-#endif
717
-#if SQLITE_PREFER_PROXY_LOCKING
718
- "PREFER_PROXY_LOCKING",
719
-#endif
720
-#if SQLITE_PROXY_DEBUG
721
- "PROXY_DEBUG",
722
-#endif
723
-#if SQLITE_REVERSE_UNORDERED_SELECTS
724
- "REVERSE_UNORDERED_SELECTS",
725
-#endif
726
-#if SQLITE_RTREE_INT_ONLY
727
- "RTREE_INT_ONLY",
728
-#endif
729
-#if SQLITE_SECURE_DELETE
730
- "SECURE_DELETE",
731
-#endif
732
-#if SQLITE_SMALL_STACK
733
- "SMALL_STACK",
734
-#endif
735
-#ifdef SQLITE_SORTER_PMASZ
736
- "SORTER_PMASZ=" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ),
737
-#endif
738
-#if SQLITE_SOUNDEX
739
- "SOUNDEX",
740
-#endif
741
-#ifdef SQLITE_STAT4_SAMPLES
742
- "STAT4_SAMPLES=" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES),
743
-#endif
744
-#ifdef SQLITE_STMTJRNL_SPILL
745
- "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),
746
-#endif
747
-#if SQLITE_SUBSTR_COMPATIBILITY
748
- "SUBSTR_COMPATIBILITY",
749
-#endif
750
-#if (!defined(SQLITE_WIN32_MALLOC) \
751
- && !defined(SQLITE_ZERO_MALLOC) \
752
- && !defined(SQLITE_MEMDEBUG) \
753
- ) || defined(SQLITE_SYSTEM_MALLOC)
754
- "SYSTEM_MALLOC",
755
-#endif
756
-#if SQLITE_TCL
757
- "TCL",
758
-#endif
759
-#ifdef SQLITE_TEMP_STORE
760
- "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
761
-#endif
762
-#if SQLITE_TEST
763
- "TEST",
764
-#endif
765
-#if defined(SQLITE_THREADSAFE)
766
- "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
767
-#elif defined(THREADSAFE)
768
- "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE),
769
-#else
770
- "THREADSAFE=1",
771
-#endif
772
-#if SQLITE_UNLINK_AFTER_CLOSE
773
- "UNLINK_AFTER_CLOSE",
774
-#endif
775
-#if SQLITE_UNTESTABLE
776
- "UNTESTABLE",
777
-#endif
778
-#if SQLITE_USER_AUTHENTICATION
779
- "USER_AUTHENTICATION",
780
-#endif
781
-#if SQLITE_USE_ALLOCA
782
- "USE_ALLOCA",
783
-#endif
784
-#if SQLITE_USE_FCNTL_TRACE
785
- "USE_FCNTL_TRACE",
786
-#endif
787
-#if SQLITE_USE_URI
788
- "USE_URI",
789
-#endif
790
-#if SQLITE_VDBE_COVERAGE
791
- "VDBE_COVERAGE",
792
-#endif
793
-#if SQLITE_WIN32_MALLOC
794
- "WIN32_MALLOC",
795
-#endif
796
-#if SQLITE_ZERO_MALLOC
797
- "ZERO_MALLOC",
798
-#endif
799
-/*
800
-** END CODE GENERATED BY tool/mkctime.tcl
801
-*/
802
-};
803
-
804
-SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){
805
- *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);
806
- return (const char**)sqlite3azCompileOpt;
807
-}
808
-
809
-#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
810
-
811
-/************** End of ctime.c ***********************************************/
81225
/************** Begin file sqliteInt.h ***************************************/
81326
/*
81427
** 2001 September 15
81528
**
81629
** The author disclaims copyright to this source code. In place of
@@ -1071,10 +284,21 @@
1071284
defined(_WIN32) && !defined(_WIN64) && \
1072285
defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION >= 4 && \
1073286
defined(__MSVCRT__)
1074287
# define _USE_32BIT_TIME_T
1075288
#endif
289
+
290
+/* Optionally #include a user-defined header, whereby compilation options
291
+** may be set prior to where they take effect, but after platform setup.
292
+** If SQLITE_CUSTOM_INCLUDE=? is defined, its value names the #include
293
+** file.
294
+*/
295
+#ifdef SQLITE_CUSTOM_INCLUDE
296
+# define INC_STRINGIFY_(f) #f
297
+# define INC_STRINGIFY(f) INC_STRINGIFY_(f)
298
+# include INC_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
299
+#endif
1076300
1077301
/* The public SQLite interface. The _FILE_OFFSET_BITS macro must appear
1078302
** first in QNX. Also, the _USE_32BIT_TIME_T macro must appear first for
1079303
** MinGW.
1080304
*/
@@ -1123,11 +347,34 @@
1123347
extern "C" {
1124348
#endif
1125349
1126350
1127351
/*
1128
-** Provide the ability to override linkage features of the interface.
352
+** Facilitate override of interface linkage and calling conventions.
353
+** Be aware that these macros may not be used within this particular
354
+** translation of the amalgamation and its associated header file.
355
+**
356
+** The SQLITE_EXTERN and SQLITE_API macros are used to instruct the
357
+** compiler that the target identifier should have external linkage.
358
+**
359
+** The SQLITE_CDECL macro is used to set the calling convention for
360
+** public functions that accept a variable number of arguments.
361
+**
362
+** The SQLITE_APICALL macro is used to set the calling convention for
363
+** public functions that accept a fixed number of arguments.
364
+**
365
+** The SQLITE_STDCALL macro is no longer used and is now deprecated.
366
+**
367
+** The SQLITE_CALLBACK macro is used to set the calling convention for
368
+** function pointers.
369
+**
370
+** The SQLITE_SYSAPI macro is used to set the calling convention for
371
+** functions provided by the operating system.
372
+**
373
+** Currently, the SQLITE_CDECL, SQLITE_APICALL, SQLITE_CALLBACK, and
374
+** SQLITE_SYSAPI macros are used only when building for environments
375
+** that require non-default calling conventions.
1129376
*/
1130377
#ifndef SQLITE_EXTERN
1131378
# define SQLITE_EXTERN extern
1132379
#endif
1133380
#ifndef SQLITE_API
@@ -1203,13 +450,13 @@
1203450
**
1204451
** See also: [sqlite3_libversion()],
1205452
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1206453
** [sqlite_version()] and [sqlite_source_id()].
1207454
*/
1208
-#define SQLITE_VERSION "3.36.0"
1209
-#define SQLITE_VERSION_NUMBER 3036000
1210
-#define SQLITE_SOURCE_ID "2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5"
455
+#define SQLITE_VERSION "3.37.0"
456
+#define SQLITE_VERSION_NUMBER 3037000
457
+#define SQLITE_SOURCE_ID "2021-07-21 15:42:05 60695359dc5d3bcba68a68e1842c40f4a01650eb5af408e02fb856fd8245e16d"
1211458
1212459
/*
1213460
** CAPI3REF: Run-Time Library Version Numbers
1214461
** KEYWORDS: sqlite3_version sqlite3_sourceid
1215462
**
@@ -1596,10 +843,11 @@
1596843
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
1597844
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
1598845
#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
1599846
#define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
1600847
#define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8))
848
+#define SQLITE_CANTOPEN_EXISTS (SQLITE_CANTOPEN | (7<<8))
1601849
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
1602850
#define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
1603851
#define SQLITE_CORRUPT_INDEX (SQLITE_CORRUPT | (3<<8))
1604852
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
1605853
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
@@ -3544,15 +2792,18 @@
35442792
35452793
/*
35462794
** CAPI3REF: Count The Number Of Rows Modified
35472795
** METHOD: sqlite3
35482796
**
3549
-** ^This function returns the number of rows modified, inserted or
2797
+** ^These functions return the number of rows modified, inserted or
35502798
** deleted by the most recently completed INSERT, UPDATE or DELETE
35512799
** statement on the database connection specified by the only parameter.
3552
-** ^Executing any other type of SQL statement does not modify the value
3553
-** returned by this function.
2800
+** The two functions are identical except for the type of the return value
2801
+** and that if the number of rows modified by the most recent INSERT, UPDATE
2802
+** or DELETE is greater than the maximum value supported by type "int", then
2803
+** the return value of sqlite3_changes() is undefined. ^Executing any other
2804
+** type of SQL statement does not modify the value returned by these functions.
35542805
**
35552806
** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
35562807
** considered - auxiliary changes caused by [CREATE TRIGGER | triggers],
35572808
** [foreign key actions] or [REPLACE] constraint resolution are not counted.
35582809
**
@@ -3597,20 +2848,25 @@
35972848
** <li> the [changes() SQL function]
35982849
** <li> the [data_version pragma]
35992850
** </ul>
36002851
*/
36012852
SQLITE_API int sqlite3_changes(sqlite3*);
2853
+SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3*);
36022854
36032855
/*
36042856
** CAPI3REF: Total Number Of Rows Modified
36052857
** METHOD: sqlite3
36062858
**
3607
-** ^This function returns the total number of rows inserted, modified or
2859
+** ^These functions return the total number of rows inserted, modified or
36082860
** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
36092861
** since the database connection was opened, including those executed as
3610
-** part of trigger programs. ^Executing any other type of SQL statement
3611
-** does not affect the value returned by sqlite3_total_changes().
2862
+** part of trigger programs. The two functions are identical except for the
2863
+** type of the return value and that if the number of rows modified by the
2864
+** connection exceeds the maximum value supported by type "int", then
2865
+** the return value of sqlite3_total_changes() is undefined. ^Executing
2866
+** any other type of SQL statement does not affect the value returned by
2867
+** sqlite3_total_changes().
36122868
**
36132869
** ^Changes made as part of [foreign key actions] are included in the
36142870
** count, but those made as part of REPLACE constraint resolution are
36152871
** not. ^Changes to a view that are intercepted by INSTEAD OF triggers
36162872
** are not counted.
@@ -3634,10 +2890,11 @@
36342890
** <li> the [data_version pragma]
36352891
** <li> the [SQLITE_FCNTL_DATA_VERSION] [file control]
36362892
** </ul>
36372893
*/
36382894
SQLITE_API int sqlite3_total_changes(sqlite3*);
2895
+SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3*);
36392896
36402897
/*
36412898
** CAPI3REF: Interrupt A Long-Running Query
36422899
** METHOD: sqlite3
36432900
**
@@ -4465,10 +3722,16 @@
44653722
** the default shared cache setting provided by
44663723
** [sqlite3_enable_shared_cache()].)^
44673724
**
44683725
** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt>
44693726
** <dd>The database filename is not allowed to be a symbolic link</dd>
3727
+**
3728
+** [[OPEN_EXCLUSIVE]] ^(<dt>[SQLITE_OPEN_EXCLUSIVE]</dt>
3729
+** <dd>This flag causes the open to fail if the database file already
3730
+** exists. The open will only be success if this flag is used in combination
3731
+** with the SQLITE_OPEN_CREATE and SQLITE_OPEN_READWRITE flags and if
3732
+** the file does not previously exist.</dd>
44703733
** </dl>)^
44713734
**
44723735
** If the 3rd parameter to sqlite3_open_v2() is not one of the
44733736
** required combinations shown above optionally combined with other
44743737
** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]
@@ -5238,16 +4501,21 @@
52384501
**
52394502
** ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P)
52404503
** are managed by SQLite and are automatically freed when the prepared
52414504
** statement is finalized.
52424505
** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
5243
-** is obtained from [sqlite3_malloc()] and must be free by the application
4506
+** is obtained from [sqlite3_malloc()] and must be freed by the application
52444507
** by passing it to [sqlite3_free()].
4508
+**
4509
+** ^The sqlite3_normalized_sql() interface is only available if
4510
+** the [SQLITE_ENABLE_NORMALIZE] compile-time option is defined.
52454511
*/
52464512
SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
52474513
SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
4514
+#ifdef SQLITE_ENABLE_NORMALIZE
52484515
SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
4516
+#endif
52494517
52504518
/*
52514519
** CAPI3REF: Determine If An SQL Statement Writes The Database
52524520
** METHOD: sqlite3_stmt
52534521
**
@@ -10090,12 +9358,13 @@
100909358
** that does not correspond to any valid SQLite error code, the results
100919359
** are undefined.
100929360
**
100939361
** A single database handle may have at most a single write-ahead log callback
100949362
** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any
10095
-** previously registered write-ahead log callback. ^Note that the
10096
-** [sqlite3_wal_autocheckpoint()] interface and the
9363
+** previously registered write-ahead log callback. ^The return value is
9364
+** a copy of the third parameter from the previous call, if any, or 0.
9365
+** ^Note that the [sqlite3_wal_autocheckpoint()] interface and the
100979366
** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
100989367
** overwrite any prior [sqlite3_wal_hook()] settings.
100999368
*/
101009369
SQLITE_API void *sqlite3_wal_hook(
101019370
sqlite3*,
@@ -10957,10 +10226,14 @@
1095710226
** if writes on the database cause it to grow larger than M bytes.
1095810227
**
1095910228
** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the
1096010229
** database is currently in a read transaction or is involved in a backup
1096110230
** operation.
10231
+**
10232
+** It is not possible to deserialized into the TEMP database. If the
10233
+** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the
10234
+** function returns SQLITE_ERROR.
1096210235
**
1096310236
** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
1096410237
** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
1096510238
** [sqlite3_free()] is invoked on argument P prior to returning.
1096610239
**
@@ -13440,11 +12713,11 @@
1344012713
/*
1344112714
** Include the configuration header output by 'configure' if we're using the
1344212715
** autoconf-based build
1344312716
*/
1344412717
#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
13445
-/* #include "config.h" */
12718
+#include "config.h"
1344612719
#define SQLITECONFIG_H 1
1344712720
#endif
1344812721
1344912722
/************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/
1345012723
/************** Begin file sqliteLimit.h *************************************/
@@ -13676,15 +12949,16 @@
1367612949
** places. The following macros try to make this explicit.
1367712950
*/
1367812951
#ifndef __has_extension
1367912952
# define __has_extension(x) 0 /* compatibility with non-clang compilers */
1368012953
#endif
13681
-#if GCC_VERSION>=4007000 || \
13682
- (__has_extension(c_atomic) && __has_extension(c_atomic_store_n))
12954
+#if GCC_VERSION>=4007000 || __has_extension(c_atomic)
12955
+# define SQLITE_ATOMIC_INTRINSICS 1
1368312956
# define AtomicLoad(PTR) __atomic_load_n((PTR),__ATOMIC_RELAXED)
1368412957
# define AtomicStore(PTR,VAL) __atomic_store_n((PTR),(VAL),__ATOMIC_RELAXED)
1368512958
#else
12959
+# define SQLITE_ATOMIC_INTRINSICS 0
1368612960
# define AtomicLoad(PTR) (*(PTR))
1368712961
# define AtomicStore(PTR,VAL) (*(PTR) = (VAL))
1368812962
#endif
1368912963
1369012964
/*
@@ -15349,11 +14623,11 @@
1534914623
*/
1535014624
#define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */
1535114625
#define BTREE_BLOBKEY 2 /* Table has keys only - no data */
1535214626
1535314627
SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*);
15354
-SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, int*);
14628
+SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, i64*);
1535514629
SQLITE_PRIVATE int sqlite3BtreeClearTableOfCursor(BtCursor*);
1535614630
SQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree*, int, int);
1535714631
1535814632
SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);
1535914633
SQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
@@ -15473,16 +14747,20 @@
1547314747
#ifdef SQLITE_ENABLE_CURSOR_HINTS
1547414748
SQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor*, int, ...);
1547514749
#endif
1547614750
1547714751
SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor*);
15478
-SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(
14752
+SQLITE_PRIVATE int sqlite3BtreeTableMoveto(
1547914753
BtCursor*,
15480
- UnpackedRecord *pUnKey,
1548114754
i64 intKey,
1548214755
int bias,
1548314756
int *pRes
14757
+);
14758
+SQLITE_PRIVATE int sqlite3BtreeIndexMoveto(
14759
+ BtCursor*,
14760
+ UnpackedRecord *pUnKey,
14761
+ int *pRes
1548414762
);
1548514763
SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*);
1548614764
SQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor*, int*);
1548714765
SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*, u8 flags);
1548814766
@@ -17110,12 +16388,12 @@
1711016388
u8 mTrace; /* zero or more SQLITE_TRACE flags */
1711116389
u8 noSharedCache; /* True if no shared-cache backends */
1711216390
u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
1711316391
int nextPagesize; /* Pagesize after VACUUM if >0 */
1711416392
u32 magic; /* Magic number for detect library misuse */
17115
- int nChange; /* Value returned by sqlite3_changes() */
17116
- int nTotalChange; /* Value returned by sqlite3_total_changes() */
16393
+ i64 nChange; /* Value returned by sqlite3_changes() */
16394
+ i64 nTotalChange; /* Value returned by sqlite3_total_changes() */
1711716395
int aLimit[SQLITE_N_LIMIT]; /* Limits */
1711816396
int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */
1711916397
struct sqlite3InitInfo { /* Information used during initialization */
1712016398
Pgno newTnum; /* Rootpage of table being initialized */
1712116399
u8 iDb; /* Which db file is being initialized */
@@ -17320,10 +16598,12 @@
1732016598
#define SQLITE_SimplifyJoin 0x00002000 /* Convert LEFT JOIN to JOIN */
1732116599
#define SQLITE_SkipScan 0x00004000 /* Skip-scans */
1732216600
#define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */
1732316601
#define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */
1732416602
#define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */
16603
+#define SQLITE_OmitOrderBy 0x00040000 /* Omit pointless ORDER BY */
16604
+ /* TH3 expects this value ^^^^^^^^^^ to be 0x40000. Coordinate any change */
1732516605
#define SQLITE_AllOpts 0xffffffff /* All optimizations */
1732616606
1732716607
/*
1732816608
** Macros for testing whether or not optimizations are enabled or disabled.
1732916609
*/
@@ -17399,16 +16679,17 @@
1739916679
** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG. And
1740016680
** SQLITE_FUNC_CONSTANT must be the same as SQLITE_DETERMINISTIC. There
1740116681
** are assert() statements in the code to verify this.
1740216682
**
1740316683
** Value constraints (enforced via assert()):
17404
-** SQLITE_FUNC_MINMAX == NC_MinMaxAgg == SF_MinMaxAgg
17405
-** SQLITE_FUNC_LENGTH == OPFLAG_LENGTHARG
17406
-** SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG
17407
-** SQLITE_FUNC_CONSTANT == SQLITE_DETERMINISTIC from the API
17408
-** SQLITE_FUNC_DIRECT == SQLITE_DIRECTONLY from the API
17409
-** SQLITE_FUNC_UNSAFE == SQLITE_INNOCUOUS
16684
+** SQLITE_FUNC_MINMAX == NC_MinMaxAgg == SF_MinMaxAgg
16685
+** SQLITE_FUNC_ANYORDER == NC_OrderAgg == SF_OrderByReqd
16686
+** SQLITE_FUNC_LENGTH == OPFLAG_LENGTHARG
16687
+** SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG
16688
+** SQLITE_FUNC_CONSTANT == SQLITE_DETERMINISTIC from the API
16689
+** SQLITE_FUNC_DIRECT == SQLITE_DIRECTONLY from the API
16690
+** SQLITE_FUNC_UNSAFE == SQLITE_INNOCUOUS
1741016691
** SQLITE_FUNC_ENCMASK depends on SQLITE_UTF* macros in the API
1741116692
*/
1741216693
#define SQLITE_FUNC_ENCMASK 0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */
1741316694
#define SQLITE_FUNC_LIKE 0x0004 /* Candidate for the LIKE optimization */
1741416695
#define SQLITE_FUNC_CASE 0x0008 /* Case-sensitive LIKE-type function */
@@ -17429,10 +16710,11 @@
1742916710
#define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */
1743016711
#define SQLITE_FUNC_DIRECT 0x00080000 /* Not for use in TRIGGERs or VIEWs */
1743116712
#define SQLITE_FUNC_SUBTYPE 0x00100000 /* Result likely to have sub-type */
1743216713
#define SQLITE_FUNC_UNSAFE 0x00200000 /* Function has side effects */
1743316714
#define SQLITE_FUNC_INLINE 0x00400000 /* Functions implemented in-line */
16715
+#define SQLITE_FUNC_ANYORDER 0x08000000 /* count/min/max aggregate */
1743416716
1743516717
/* Identifier numbers for each in-line function */
1743616718
#define INLINEFUNC_coalesce 0
1743716719
#define INLINEFUNC_implies_nonnull_row 1
1743816720
#define INLINEFUNC_expr_implies_expr 2
@@ -18664,35 +17946,37 @@
1866417946
1866517947
/*
1866617948
** Allowed values for the NameContext, ncFlags field.
1866717949
**
1866817950
** Value constraints (all checked via assert()):
18669
-** NC_HasAgg == SF_HasAgg == EP_Agg
18670
-** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX
17951
+** NC_HasAgg == SF_HasAgg == EP_Agg
17952
+** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX
17953
+** NC_OrderAgg == SF_OrderByReqd == SQLITE_FUNC_ANYORDER
1867117954
** NC_HasWin == EP_Win
1867217955
**
1867317956
*/
18674
-#define NC_AllowAgg 0x00001 /* Aggregate functions are allowed here */
18675
-#define NC_PartIdx 0x00002 /* True if resolving a partial index WHERE */
18676
-#define NC_IsCheck 0x00004 /* True if resolving a CHECK constraint */
18677
-#define NC_GenCol 0x00008 /* True for a GENERATED ALWAYS AS clause */
18678
-#define NC_HasAgg 0x00010 /* One or more aggregate functions seen */
18679
-#define NC_IdxExpr 0x00020 /* True if resolving columns of CREATE INDEX */
18680
-#define NC_SelfRef 0x0002e /* Combo: PartIdx, isCheck, GenCol, and IdxExpr */
18681
-#define NC_VarSelect 0x00040 /* A correlated subquery has been seen */
18682
-#define NC_UEList 0x00080 /* True if uNC.pEList is used */
18683
-#define NC_UAggInfo 0x00100 /* True if uNC.pAggInfo is used */
18684
-#define NC_UUpsert 0x00200 /* True if uNC.pUpsert is used */
18685
-#define NC_UBaseReg 0x00400 /* True if uNC.iBaseReg is used */
18686
-#define NC_MinMaxAgg 0x01000 /* min/max aggregates seen. See note above */
18687
-#define NC_Complex 0x02000 /* True if a function or subquery seen */
18688
-#define NC_AllowWin 0x04000 /* Window functions are allowed here */
18689
-#define NC_HasWin 0x08000 /* One or more window functions seen */
18690
-#define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */
18691
-#define NC_InAggFunc 0x20000 /* True if analyzing arguments to an agg func */
18692
-#define NC_FromDDL 0x40000 /* SQL text comes from sqlite_schema */
18693
-#define NC_NoSelect 0x80000 /* Do not descend into sub-selects */
17957
+#define NC_AllowAgg 0x000001 /* Aggregate functions are allowed here */
17958
+#define NC_PartIdx 0x000002 /* True if resolving a partial index WHERE */
17959
+#define NC_IsCheck 0x000004 /* True if resolving a CHECK constraint */
17960
+#define NC_GenCol 0x000008 /* True for a GENERATED ALWAYS AS clause */
17961
+#define NC_HasAgg 0x000010 /* One or more aggregate functions seen */
17962
+#define NC_IdxExpr 0x000020 /* True if resolving columns of CREATE INDEX */
17963
+#define NC_SelfRef 0x00002e /* Combo: PartIdx, isCheck, GenCol, and IdxExpr */
17964
+#define NC_VarSelect 0x000040 /* A correlated subquery has been seen */
17965
+#define NC_UEList 0x000080 /* True if uNC.pEList is used */
17966
+#define NC_UAggInfo 0x000100 /* True if uNC.pAggInfo is used */
17967
+#define NC_UUpsert 0x000200 /* True if uNC.pUpsert is used */
17968
+#define NC_UBaseReg 0x000400 /* True if uNC.iBaseReg is used */
17969
+#define NC_MinMaxAgg 0x001000 /* min/max aggregates seen. See note above */
17970
+#define NC_Complex 0x002000 /* True if a function or subquery seen */
17971
+#define NC_AllowWin 0x004000 /* Window functions are allowed here */
17972
+#define NC_HasWin 0x008000 /* One or more window functions seen */
17973
+#define NC_IsDDL 0x010000 /* Resolving names in a CREATE statement */
17974
+#define NC_InAggFunc 0x020000 /* True if analyzing arguments to an agg func */
17975
+#define NC_FromDDL 0x040000 /* SQL text comes from sqlite_schema */
17976
+#define NC_NoSelect 0x080000 /* Do not descend into sub-selects */
17977
+#define NC_OrderAgg 0x8000000 /* Has an aggregate other than count/min/max */
1869417978
1869517979
/*
1869617980
** An instance of the following object describes a single ON CONFLICT
1869717981
** clause in an upsert.
1869817982
**
@@ -18771,13 +18055,14 @@
1877118055
/*
1877218056
** Allowed values for Select.selFlags. The "SF" prefix stands for
1877318057
** "Select Flag".
1877418058
**
1877518059
** Value constraints (all checked via assert())
18776
-** SF_HasAgg == NC_HasAgg
18777
-** SF_MinMaxAgg == NC_MinMaxAgg == SQLITE_FUNC_MINMAX
18778
-** SF_FixedLimit == WHERE_USE_LIMIT
18060
+** SF_HasAgg == NC_HasAgg
18061
+** SF_MinMaxAgg == NC_MinMaxAgg == SQLITE_FUNC_MINMAX
18062
+** SF_OrderByReqd == NC_OrderAgg == SQLITE_FUNC_ANYORDER
18063
+** SF_FixedLimit == WHERE_USE_LIMIT
1877918064
*/
1878018065
#define SF_Distinct 0x0000001 /* Output should be DISTINCT */
1878118066
#define SF_All 0x0000002 /* Includes the ALL keyword */
1878218067
#define SF_Resolved 0x0000004 /* Identifiers have been resolved */
1878318068
#define SF_Aggregate 0x0000008 /* Contains agg functions or a GROUP BY */
@@ -18798,14 +18083,15 @@
1879818083
#define SF_ComplexResult 0x0040000 /* Result contains subquery or function */
1879918084
#define SF_WhereBegin 0x0080000 /* Really a WhereBegin() call. Debug Only */
1880018085
#define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */
1880118086
#define SF_View 0x0200000 /* SELECT statement is a view */
1880218087
#define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */
18803
-#define SF_UpdateFrom 0x0800000 /* Statement is an UPDATE...FROM */
18088
+#define SF_UFSrcCheck 0x0800000 /* Check pSrc as required by UPDATE...FROM */
1880418089
#define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */
1880518090
#define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */
1880618091
#define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */
18092
+#define SF_OrderByReqd 0x8000000 /* The ORDER BY clause may not be omitted */
1880718093
1880818094
/*
1880918095
** The results of a SELECT can be distributed in several ways, as defined
1881018096
** by one of the following macros. The "SRT" prefix means "SELECT Result
1881118097
** Type".
@@ -19911,10 +19197,11 @@
1991119197
SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
1991219198
SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*);
1991319199
SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*);
1991419200
SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
1991519201
SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
19202
+SQLITE_PRIVATE Select *sqlite3ExprListToValues(Parse*, int, ExprList*);
1991619203
SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int,int);
1991719204
SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
1991819205
SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
1991919206
SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
1992019207
SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
@@ -20329,11 +19616,11 @@
2032919616
SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
2033019617
SQLITE_PRIVATE Expr *sqlite3ExprSkipCollateAndLikely(Expr*);
2033119618
SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
2033219619
SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3*);
2033319620
SQLITE_PRIVATE int sqlite3CheckObjectName(Parse*, const char*,const char*,const char*);
20334
-SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);
19621
+SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, i64);
2033519622
SQLITE_PRIVATE int sqlite3AddInt64(i64*,i64);
2033619623
SQLITE_PRIVATE int sqlite3SubInt64(i64*,i64);
2033719624
SQLITE_PRIVATE int sqlite3MulInt64(i64*,i64);
2033819625
SQLITE_PRIVATE int sqlite3AbsInt32(int);
2033919626
#ifdef SQLITE_ENABLE_8_3_NAMES
@@ -20779,20 +20066,807 @@
2077920066
#endif
2078020067
2078120068
SQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr);
2078220069
SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr);
2078320070
SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr*, int);
20784
-SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int);
20071
+SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int,int);
2078520072
SQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse*, Expr*);
2078620073
2078720074
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
2078820075
SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt);
2078920076
#endif
2079020077
2079120078
#endif /* SQLITEINT_H */
2079220079
2079320080
/************** End of sqliteInt.h *******************************************/
20081
+/************** Begin file ctime.c *******************************************/
20082
+/*
20083
+** 2010 February 23
20084
+**
20085
+** The author disclaims copyright to this source code. In place of
20086
+** a legal notice, here is a blessing:
20087
+**
20088
+** May you do good and not evil.
20089
+** May you find forgiveness for yourself and forgive others.
20090
+** May you share freely, never taking more than you give.
20091
+**
20092
+*************************************************************************
20093
+**
20094
+** This file implements routines used to report what compile-time options
20095
+** SQLite was built with.
20096
+*/
20097
+#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS /* IMP: R-16824-07538 */
20098
+
20099
+/*
20100
+** Include the configuration header output by 'configure' if we're using the
20101
+** autoconf-based build
20102
+*/
20103
+#if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
20104
+/* #include "config.h" */
20105
+#define SQLITECONFIG_H 1
20106
+#endif
20107
+
20108
+/* These macros are provided to "stringify" the value of the define
20109
+** for those options in which the value is meaningful. */
20110
+#define CTIMEOPT_VAL_(opt) #opt
20111
+#define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
20112
+
20113
+/* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This
20114
+** option requires a separate macro because legal values contain a single
20115
+** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE="100,100") */
20116
+#define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
20117
+#define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)
20118
+/* #include "sqliteInt.h" */
20119
+
20120
+/*
20121
+** An array of names of all compile-time options. This array should
20122
+** be sorted A-Z.
20123
+**
20124
+** This array looks large, but in a typical installation actually uses
20125
+** only a handful of compile-time options, so most times this array is usually
20126
+** rather short and uses little memory space.
20127
+*/
20128
+static const char * const sqlite3azCompileOpt[] = {
20129
+
20130
+/*
20131
+** BEGIN CODE GENERATED BY tool/mkctime.tcl
20132
+*/
20133
+#ifdef SQLITE_32BIT_ROWID
20134
+ "32BIT_ROWID",
20135
+#endif
20136
+#ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
20137
+ "4_BYTE_ALIGNED_MALLOC",
20138
+#endif
20139
+#ifdef SQLITE_64BIT_STATS
20140
+ "64BIT_STATS",
20141
+#endif
20142
+#ifdef SQLITE_ALLOW_COVERING_INDEX_SCAN
20143
+# if SQLITE_ALLOW_COVERING_INDEX_SCAN != 1
20144
+ "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN),
20145
+# endif
20146
+#endif
20147
+#ifdef SQLITE_ALLOW_URI_AUTHORITY
20148
+ "ALLOW_URI_AUTHORITY",
20149
+#endif
20150
+#ifdef SQLITE_ATOMIC_INTRINSICS
20151
+ "ATOMIC_INTRINSICS=" CTIMEOPT_VAL(SQLITE_ATOMIC_INTRINSICS),
20152
+#endif
20153
+#ifdef SQLITE_BITMASK_TYPE
20154
+ "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),
20155
+#endif
20156
+#ifdef SQLITE_BUG_COMPATIBLE_20160819
20157
+ "BUG_COMPATIBLE_20160819",
20158
+#endif
20159
+#ifdef SQLITE_CASE_SENSITIVE_LIKE
20160
+ "CASE_SENSITIVE_LIKE",
20161
+#endif
20162
+#ifdef SQLITE_CHECK_PAGES
20163
+ "CHECK_PAGES",
20164
+#endif
20165
+#if defined(__clang__) && defined(__clang_major__)
20166
+ "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
20167
+ CTIMEOPT_VAL(__clang_minor__) "."
20168
+ CTIMEOPT_VAL(__clang_patchlevel__),
20169
+#elif defined(_MSC_VER)
20170
+ "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
20171
+#elif defined(__GNUC__) && defined(__VERSION__)
20172
+ "COMPILER=gcc-" __VERSION__,
20173
+#endif
20174
+#ifdef SQLITE_COVERAGE_TEST
20175
+ "COVERAGE_TEST",
20176
+#endif
20177
+#ifdef SQLITE_DEBUG
20178
+ "DEBUG",
20179
+#endif
20180
+#ifdef SQLITE_DEFAULT_AUTOMATIC_INDEX
20181
+ "DEFAULT_AUTOMATIC_INDEX",
20182
+#endif
20183
+#ifdef SQLITE_DEFAULT_AUTOVACUUM
20184
+ "DEFAULT_AUTOVACUUM",
20185
+#endif
20186
+#ifdef SQLITE_DEFAULT_CACHE_SIZE
20187
+ "DEFAULT_CACHE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE),
20188
+#endif
20189
+#ifdef SQLITE_DEFAULT_CKPTFULLFSYNC
20190
+ "DEFAULT_CKPTFULLFSYNC",
20191
+#endif
20192
+#ifdef SQLITE_DEFAULT_FILE_FORMAT
20193
+ "DEFAULT_FILE_FORMAT=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT),
20194
+#endif
20195
+#ifdef SQLITE_DEFAULT_FILE_PERMISSIONS
20196
+ "DEFAULT_FILE_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS),
20197
+#endif
20198
+#ifdef SQLITE_DEFAULT_FOREIGN_KEYS
20199
+ "DEFAULT_FOREIGN_KEYS",
20200
+#endif
20201
+#ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
20202
+ "DEFAULT_JOURNAL_SIZE_LIMIT=" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT),
20203
+#endif
20204
+#ifdef SQLITE_DEFAULT_LOCKING_MODE
20205
+ "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
20206
+#endif
20207
+#ifdef SQLITE_DEFAULT_LOOKASIDE
20208
+ "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE),
20209
+#endif
20210
+#ifdef SQLITE_DEFAULT_MEMSTATUS
20211
+# if SQLITE_DEFAULT_MEMSTATUS != 1
20212
+ "DEFAULT_MEMSTATUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_MEMSTATUS),
20213
+# endif
20214
+#endif
20215
+#ifdef SQLITE_DEFAULT_MMAP_SIZE
20216
+ "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
20217
+#endif
20218
+#ifdef SQLITE_DEFAULT_PAGE_SIZE
20219
+ "DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE),
20220
+#endif
20221
+#ifdef SQLITE_DEFAULT_PCACHE_INITSZ
20222
+ "DEFAULT_PCACHE_INITSZ=" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ),
20223
+#endif
20224
+#ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS
20225
+ "DEFAULT_PROXYDIR_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS),
20226
+#endif
20227
+#ifdef SQLITE_DEFAULT_RECURSIVE_TRIGGERS
20228
+ "DEFAULT_RECURSIVE_TRIGGERS",
20229
+#endif
20230
+#ifdef SQLITE_DEFAULT_ROWEST
20231
+ "DEFAULT_ROWEST=" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST),
20232
+#endif
20233
+#ifdef SQLITE_DEFAULT_SECTOR_SIZE
20234
+ "DEFAULT_SECTOR_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE),
20235
+#endif
20236
+#ifdef SQLITE_DEFAULT_SYNCHRONOUS
20237
+ "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),
20238
+#endif
20239
+#ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
20240
+ "DEFAULT_WAL_AUTOCHECKPOINT=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT),
20241
+#endif
20242
+#ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS
20243
+ "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),
20244
+#endif
20245
+#ifdef SQLITE_DEFAULT_WORKER_THREADS
20246
+ "DEFAULT_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS),
20247
+#endif
20248
+#ifdef SQLITE_DIRECT_OVERFLOW_READ
20249
+ "DIRECT_OVERFLOW_READ",
20250
+#endif
20251
+#ifdef SQLITE_DISABLE_DIRSYNC
20252
+ "DISABLE_DIRSYNC",
20253
+#endif
20254
+#ifdef SQLITE_DISABLE_FTS3_UNICODE
20255
+ "DISABLE_FTS3_UNICODE",
20256
+#endif
20257
+#ifdef SQLITE_DISABLE_FTS4_DEFERRED
20258
+ "DISABLE_FTS4_DEFERRED",
20259
+#endif
20260
+#ifdef SQLITE_DISABLE_INTRINSIC
20261
+ "DISABLE_INTRINSIC",
20262
+#endif
20263
+#ifdef SQLITE_DISABLE_LFS
20264
+ "DISABLE_LFS",
20265
+#endif
20266
+#ifdef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
20267
+ "DISABLE_PAGECACHE_OVERFLOW_STATS",
20268
+#endif
20269
+#ifdef SQLITE_DISABLE_SKIPAHEAD_DISTINCT
20270
+ "DISABLE_SKIPAHEAD_DISTINCT",
20271
+#endif
20272
+#ifdef SQLITE_ENABLE_8_3_NAMES
20273
+ "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
20274
+#endif
20275
+#ifdef SQLITE_ENABLE_API_ARMOR
20276
+ "ENABLE_API_ARMOR",
20277
+#endif
20278
+#ifdef SQLITE_ENABLE_ATOMIC_WRITE
20279
+ "ENABLE_ATOMIC_WRITE",
20280
+#endif
20281
+#ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE
20282
+ "ENABLE_BATCH_ATOMIC_WRITE",
20283
+#endif
20284
+#ifdef SQLITE_ENABLE_BYTECODE_VTAB
20285
+ "ENABLE_BYTECODE_VTAB",
20286
+#endif
20287
+#ifdef SQLITE_ENABLE_CEROD
20288
+ "ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD),
20289
+#endif
20290
+#ifdef SQLITE_ENABLE_COLUMN_METADATA
20291
+ "ENABLE_COLUMN_METADATA",
20292
+#endif
20293
+#ifdef SQLITE_ENABLE_COLUMN_USED_MASK
20294
+ "ENABLE_COLUMN_USED_MASK",
20295
+#endif
20296
+#ifdef SQLITE_ENABLE_COSTMULT
20297
+ "ENABLE_COSTMULT",
20298
+#endif
20299
+#ifdef SQLITE_ENABLE_CURSOR_HINTS
20300
+ "ENABLE_CURSOR_HINTS",
20301
+#endif
20302
+#ifdef SQLITE_ENABLE_DBPAGE_VTAB
20303
+ "ENABLE_DBPAGE_VTAB",
20304
+#endif
20305
+#ifdef SQLITE_ENABLE_DBSTAT_VTAB
20306
+ "ENABLE_DBSTAT_VTAB",
20307
+#endif
20308
+#ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
20309
+ "ENABLE_EXPENSIVE_ASSERT",
20310
+#endif
20311
+#ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
20312
+ "ENABLE_EXPLAIN_COMMENTS",
20313
+#endif
20314
+#ifdef SQLITE_ENABLE_FTS3
20315
+ "ENABLE_FTS3",
20316
+#endif
20317
+#ifdef SQLITE_ENABLE_FTS3_PARENTHESIS
20318
+ "ENABLE_FTS3_PARENTHESIS",
20319
+#endif
20320
+#ifdef SQLITE_ENABLE_FTS3_TOKENIZER
20321
+ "ENABLE_FTS3_TOKENIZER",
20322
+#endif
20323
+#ifdef SQLITE_ENABLE_FTS4
20324
+ "ENABLE_FTS4",
20325
+#endif
20326
+#ifdef SQLITE_ENABLE_FTS5
20327
+ "ENABLE_FTS5",
20328
+#endif
20329
+#ifdef SQLITE_ENABLE_GEOPOLY
20330
+ "ENABLE_GEOPOLY",
20331
+#endif
20332
+#ifdef SQLITE_ENABLE_HIDDEN_COLUMNS
20333
+ "ENABLE_HIDDEN_COLUMNS",
20334
+#endif
20335
+#ifdef SQLITE_ENABLE_ICU
20336
+ "ENABLE_ICU",
20337
+#endif
20338
+#ifdef SQLITE_ENABLE_IOTRACE
20339
+ "ENABLE_IOTRACE",
20340
+#endif
20341
+#ifdef SQLITE_ENABLE_JSON1
20342
+ "ENABLE_JSON1",
20343
+#endif
20344
+#ifdef SQLITE_ENABLE_LOAD_EXTENSION
20345
+ "ENABLE_LOAD_EXTENSION",
20346
+#endif
20347
+#ifdef SQLITE_ENABLE_LOCKING_STYLE
20348
+ "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
20349
+#endif
20350
+#ifdef SQLITE_ENABLE_MATH_FUNCTIONS
20351
+ "ENABLE_MATH_FUNCTIONS",
20352
+#endif
20353
+#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
20354
+ "ENABLE_MEMORY_MANAGEMENT",
20355
+#endif
20356
+#ifdef SQLITE_ENABLE_MEMSYS3
20357
+ "ENABLE_MEMSYS3",
20358
+#endif
20359
+#ifdef SQLITE_ENABLE_MEMSYS5
20360
+ "ENABLE_MEMSYS5",
20361
+#endif
20362
+#ifdef SQLITE_ENABLE_MULTIPLEX
20363
+ "ENABLE_MULTIPLEX",
20364
+#endif
20365
+#ifdef SQLITE_ENABLE_NORMALIZE
20366
+ "ENABLE_NORMALIZE",
20367
+#endif
20368
+#ifdef SQLITE_ENABLE_NULL_TRIM
20369
+ "ENABLE_NULL_TRIM",
20370
+#endif
20371
+#ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
20372
+ "ENABLE_OFFSET_SQL_FUNC",
20373
+#endif
20374
+#ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK
20375
+ "ENABLE_OVERSIZE_CELL_CHECK",
20376
+#endif
20377
+#ifdef SQLITE_ENABLE_PREUPDATE_HOOK
20378
+ "ENABLE_PREUPDATE_HOOK",
20379
+#endif
20380
+#ifdef SQLITE_ENABLE_QPSG
20381
+ "ENABLE_QPSG",
20382
+#endif
20383
+#ifdef SQLITE_ENABLE_RBU
20384
+ "ENABLE_RBU",
20385
+#endif
20386
+#ifdef SQLITE_ENABLE_RTREE
20387
+ "ENABLE_RTREE",
20388
+#endif
20389
+#ifdef SQLITE_ENABLE_SELECTTRACE
20390
+ "ENABLE_SELECTTRACE",
20391
+#endif
20392
+#ifdef SQLITE_ENABLE_SESSION
20393
+ "ENABLE_SESSION",
20394
+#endif
20395
+#ifdef SQLITE_ENABLE_SNAPSHOT
20396
+ "ENABLE_SNAPSHOT",
20397
+#endif
20398
+#ifdef SQLITE_ENABLE_SORTER_REFERENCES
20399
+ "ENABLE_SORTER_REFERENCES",
20400
+#endif
20401
+#ifdef SQLITE_ENABLE_SQLLOG
20402
+ "ENABLE_SQLLOG",
20403
+#endif
20404
+#ifdef SQLITE_ENABLE_STAT4
20405
+ "ENABLE_STAT4",
20406
+#endif
20407
+#ifdef SQLITE_ENABLE_STMTVTAB
20408
+ "ENABLE_STMTVTAB",
20409
+#endif
20410
+#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
20411
+ "ENABLE_STMT_SCANSTATUS",
20412
+#endif
20413
+#ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
20414
+ "ENABLE_UNKNOWN_SQL_FUNCTION",
20415
+#endif
20416
+#ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
20417
+ "ENABLE_UNLOCK_NOTIFY",
20418
+#endif
20419
+#ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
20420
+ "ENABLE_UPDATE_DELETE_LIMIT",
20421
+#endif
20422
+#ifdef SQLITE_ENABLE_URI_00_ERROR
20423
+ "ENABLE_URI_00_ERROR",
20424
+#endif
20425
+#ifdef SQLITE_ENABLE_VFSTRACE
20426
+ "ENABLE_VFSTRACE",
20427
+#endif
20428
+#ifdef SQLITE_ENABLE_WHERETRACE
20429
+ "ENABLE_WHERETRACE",
20430
+#endif
20431
+#ifdef SQLITE_ENABLE_ZIPVFS
20432
+ "ENABLE_ZIPVFS",
20433
+#endif
20434
+#ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS
20435
+ "EXPLAIN_ESTIMATED_ROWS",
20436
+#endif
20437
+#ifdef SQLITE_EXTRA_IFNULLROW
20438
+ "EXTRA_IFNULLROW",
20439
+#endif
20440
+#ifdef SQLITE_EXTRA_INIT
20441
+ "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT),
20442
+#endif
20443
+#ifdef SQLITE_EXTRA_SHUTDOWN
20444
+ "EXTRA_SHUTDOWN=" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN),
20445
+#endif
20446
+#ifdef SQLITE_FTS3_MAX_EXPR_DEPTH
20447
+ "FTS3_MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH),
20448
+#endif
20449
+#ifdef SQLITE_FTS5_ENABLE_TEST_MI
20450
+ "FTS5_ENABLE_TEST_MI",
20451
+#endif
20452
+#ifdef SQLITE_FTS5_NO_WITHOUT_ROWID
20453
+ "FTS5_NO_WITHOUT_ROWID",
20454
+#endif
20455
+#if HAVE_ISNAN || SQLITE_HAVE_ISNAN
20456
+ "HAVE_ISNAN",
20457
+#endif
20458
+#ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
20459
+# if SQLITE_HOMEGROWN_RECURSIVE_MUTEX != 1
20460
+ "HOMEGROWN_RECURSIVE_MUTEX=" CTIMEOPT_VAL(SQLITE_HOMEGROWN_RECURSIVE_MUTEX),
20461
+# endif
20462
+#endif
20463
+#ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS
20464
+ "IGNORE_AFP_LOCK_ERRORS",
20465
+#endif
20466
+#ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS
20467
+ "IGNORE_FLOCK_LOCK_ERRORS",
20468
+#endif
20469
+#ifdef SQLITE_INLINE_MEMCPY
20470
+ "INLINE_MEMCPY",
20471
+#endif
20472
+#ifdef SQLITE_INT64_TYPE
20473
+ "INT64_TYPE",
20474
+#endif
20475
+#ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX
20476
+ "INTEGRITY_CHECK_ERROR_MAX=" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX),
20477
+#endif
20478
+#ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS
20479
+ "LIKE_DOESNT_MATCH_BLOBS",
20480
+#endif
20481
+#ifdef SQLITE_LOCK_TRACE
20482
+ "LOCK_TRACE",
20483
+#endif
20484
+#ifdef SQLITE_LOG_CACHE_SPILL
20485
+ "LOG_CACHE_SPILL",
20486
+#endif
20487
+#ifdef SQLITE_MALLOC_SOFT_LIMIT
20488
+ "MALLOC_SOFT_LIMIT=" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT),
20489
+#endif
20490
+#ifdef SQLITE_MAX_ATTACHED
20491
+ "MAX_ATTACHED=" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED),
20492
+#endif
20493
+#ifdef SQLITE_MAX_COLUMN
20494
+ "MAX_COLUMN=" CTIMEOPT_VAL(SQLITE_MAX_COLUMN),
20495
+#endif
20496
+#ifdef SQLITE_MAX_COMPOUND_SELECT
20497
+ "MAX_COMPOUND_SELECT=" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT),
20498
+#endif
20499
+#ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE
20500
+ "MAX_DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE),
20501
+#endif
20502
+#ifdef SQLITE_MAX_EXPR_DEPTH
20503
+ "MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH),
20504
+#endif
20505
+#ifdef SQLITE_MAX_FUNCTION_ARG
20506
+ "MAX_FUNCTION_ARG=" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG),
20507
+#endif
20508
+#ifdef SQLITE_MAX_LENGTH
20509
+ "MAX_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LENGTH),
20510
+#endif
20511
+#ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH
20512
+ "MAX_LIKE_PATTERN_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH),
20513
+#endif
20514
+#ifdef SQLITE_MAX_MEMORY
20515
+ "MAX_MEMORY=" CTIMEOPT_VAL(SQLITE_MAX_MEMORY),
20516
+#endif
20517
+#ifdef SQLITE_MAX_MMAP_SIZE
20518
+ "MAX_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),
20519
+#endif
20520
+#ifdef SQLITE_MAX_MMAP_SIZE_
20521
+ "MAX_MMAP_SIZE_=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_),
20522
+#endif
20523
+#ifdef SQLITE_MAX_PAGE_COUNT
20524
+ "MAX_PAGE_COUNT=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT),
20525
+#endif
20526
+#ifdef SQLITE_MAX_PAGE_SIZE
20527
+ "MAX_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE),
20528
+#endif
20529
+#ifdef SQLITE_MAX_SCHEMA_RETRY
20530
+ "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
20531
+#endif
20532
+#ifdef SQLITE_MAX_SQL_LENGTH
20533
+ "MAX_SQL_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH),
20534
+#endif
20535
+#ifdef SQLITE_MAX_TRIGGER_DEPTH
20536
+ "MAX_TRIGGER_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH),
20537
+#endif
20538
+#ifdef SQLITE_MAX_VARIABLE_NUMBER
20539
+ "MAX_VARIABLE_NUMBER=" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER),
20540
+#endif
20541
+#ifdef SQLITE_MAX_VDBE_OP
20542
+ "MAX_VDBE_OP=" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP),
20543
+#endif
20544
+#ifdef SQLITE_MAX_WORKER_THREADS
20545
+ "MAX_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS),
20546
+#endif
20547
+#ifdef SQLITE_MEMDEBUG
20548
+ "MEMDEBUG",
20549
+#endif
20550
+#ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
20551
+ "MIXED_ENDIAN_64BIT_FLOAT",
20552
+#endif
20553
+#ifdef SQLITE_MMAP_READWRITE
20554
+ "MMAP_READWRITE",
20555
+#endif
20556
+#ifdef SQLITE_MUTEX_NOOP
20557
+ "MUTEX_NOOP",
20558
+#endif
20559
+#ifdef SQLITE_MUTEX_OMIT
20560
+ "MUTEX_OMIT",
20561
+#endif
20562
+#ifdef SQLITE_MUTEX_PTHREADS
20563
+ "MUTEX_PTHREADS",
20564
+#endif
20565
+#ifdef SQLITE_MUTEX_W32
20566
+ "MUTEX_W32",
20567
+#endif
20568
+#ifdef SQLITE_NEED_ERR_NAME
20569
+ "NEED_ERR_NAME",
20570
+#endif
20571
+#ifdef SQLITE_NO_SYNC
20572
+ "NO_SYNC",
20573
+#endif
20574
+#ifdef SQLITE_OMIT_ALTERTABLE
20575
+ "OMIT_ALTERTABLE",
20576
+#endif
20577
+#ifdef SQLITE_OMIT_ANALYZE
20578
+ "OMIT_ANALYZE",
20579
+#endif
20580
+#ifdef SQLITE_OMIT_ATTACH
20581
+ "OMIT_ATTACH",
20582
+#endif
20583
+#ifdef SQLITE_OMIT_AUTHORIZATION
20584
+ "OMIT_AUTHORIZATION",
20585
+#endif
20586
+#ifdef SQLITE_OMIT_AUTOINCREMENT
20587
+ "OMIT_AUTOINCREMENT",
20588
+#endif
20589
+#ifdef SQLITE_OMIT_AUTOINIT
20590
+ "OMIT_AUTOINIT",
20591
+#endif
20592
+#ifdef SQLITE_OMIT_AUTOMATIC_INDEX
20593
+ "OMIT_AUTOMATIC_INDEX",
20594
+#endif
20595
+#ifdef SQLITE_OMIT_AUTORESET
20596
+ "OMIT_AUTORESET",
20597
+#endif
20598
+#ifdef SQLITE_OMIT_AUTOVACUUM
20599
+ "OMIT_AUTOVACUUM",
20600
+#endif
20601
+#ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION
20602
+ "OMIT_BETWEEN_OPTIMIZATION",
20603
+#endif
20604
+#ifdef SQLITE_OMIT_BLOB_LITERAL
20605
+ "OMIT_BLOB_LITERAL",
20606
+#endif
20607
+#ifdef SQLITE_OMIT_CAST
20608
+ "OMIT_CAST",
20609
+#endif
20610
+#ifdef SQLITE_OMIT_CHECK
20611
+ "OMIT_CHECK",
20612
+#endif
20613
+#ifdef SQLITE_OMIT_COMPLETE
20614
+ "OMIT_COMPLETE",
20615
+#endif
20616
+#ifdef SQLITE_OMIT_COMPOUND_SELECT
20617
+ "OMIT_COMPOUND_SELECT",
20618
+#endif
20619
+#ifdef SQLITE_OMIT_CONFLICT_CLAUSE
20620
+ "OMIT_CONFLICT_CLAUSE",
20621
+#endif
20622
+#ifdef SQLITE_OMIT_CTE
20623
+ "OMIT_CTE",
20624
+#endif
20625
+#if defined(SQLITE_OMIT_DATETIME_FUNCS) || defined(SQLITE_OMIT_FLOATING_POINT)
20626
+ "OMIT_DATETIME_FUNCS",
20627
+#endif
20628
+#ifdef SQLITE_OMIT_DECLTYPE
20629
+ "OMIT_DECLTYPE",
20630
+#endif
20631
+#ifdef SQLITE_OMIT_DEPRECATED
20632
+ "OMIT_DEPRECATED",
20633
+#endif
20634
+#ifdef SQLITE_OMIT_DESERIALIZE
20635
+ "OMIT_DESERIALIZE",
20636
+#endif
20637
+#ifdef SQLITE_OMIT_DISKIO
20638
+ "OMIT_DISKIO",
20639
+#endif
20640
+#ifdef SQLITE_OMIT_EXPLAIN
20641
+ "OMIT_EXPLAIN",
20642
+#endif
20643
+#ifdef SQLITE_OMIT_FLAG_PRAGMAS
20644
+ "OMIT_FLAG_PRAGMAS",
20645
+#endif
20646
+#ifdef SQLITE_OMIT_FLOATING_POINT
20647
+ "OMIT_FLOATING_POINT",
20648
+#endif
20649
+#ifdef SQLITE_OMIT_FOREIGN_KEY
20650
+ "OMIT_FOREIGN_KEY",
20651
+#endif
20652
+#ifdef SQLITE_OMIT_GET_TABLE
20653
+ "OMIT_GET_TABLE",
20654
+#endif
20655
+#ifdef SQLITE_OMIT_HEX_INTEGER
20656
+ "OMIT_HEX_INTEGER",
20657
+#endif
20658
+#ifdef SQLITE_OMIT_INCRBLOB
20659
+ "OMIT_INCRBLOB",
20660
+#endif
20661
+#ifdef SQLITE_OMIT_INTEGRITY_CHECK
20662
+ "OMIT_INTEGRITY_CHECK",
20663
+#endif
20664
+#ifdef SQLITE_OMIT_INTROSPECTION_PRAGMAS
20665
+ "OMIT_INTROSPECTION_PRAGMAS",
20666
+#endif
20667
+#ifdef SQLITE_OMIT_LIKE_OPTIMIZATION
20668
+ "OMIT_LIKE_OPTIMIZATION",
20669
+#endif
20670
+#ifdef SQLITE_OMIT_LOAD_EXTENSION
20671
+ "OMIT_LOAD_EXTENSION",
20672
+#endif
20673
+#ifdef SQLITE_OMIT_LOCALTIME
20674
+ "OMIT_LOCALTIME",
20675
+#endif
20676
+#ifdef SQLITE_OMIT_LOOKASIDE
20677
+ "OMIT_LOOKASIDE",
20678
+#endif
20679
+#ifdef SQLITE_OMIT_MEMORYDB
20680
+ "OMIT_MEMORYDB",
20681
+#endif
20682
+#ifdef SQLITE_OMIT_OR_OPTIMIZATION
20683
+ "OMIT_OR_OPTIMIZATION",
20684
+#endif
20685
+#ifdef SQLITE_OMIT_PAGER_PRAGMAS
20686
+ "OMIT_PAGER_PRAGMAS",
20687
+#endif
20688
+#ifdef SQLITE_OMIT_PARSER_TRACE
20689
+ "OMIT_PARSER_TRACE",
20690
+#endif
20691
+#ifdef SQLITE_OMIT_POPEN
20692
+ "OMIT_POPEN",
20693
+#endif
20694
+#ifdef SQLITE_OMIT_PRAGMA
20695
+ "OMIT_PRAGMA",
20696
+#endif
20697
+#ifdef SQLITE_OMIT_PROGRESS_CALLBACK
20698
+ "OMIT_PROGRESS_CALLBACK",
20699
+#endif
20700
+#ifdef SQLITE_OMIT_QUICKBALANCE
20701
+ "OMIT_QUICKBALANCE",
20702
+#endif
20703
+#ifdef SQLITE_OMIT_REINDEX
20704
+ "OMIT_REINDEX",
20705
+#endif
20706
+#ifdef SQLITE_OMIT_SCHEMA_PRAGMAS
20707
+ "OMIT_SCHEMA_PRAGMAS",
20708
+#endif
20709
+#ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
20710
+ "OMIT_SCHEMA_VERSION_PRAGMAS",
20711
+#endif
20712
+#ifdef SQLITE_OMIT_SHARED_CACHE
20713
+ "OMIT_SHARED_CACHE",
20714
+#endif
20715
+#ifdef SQLITE_OMIT_SHUTDOWN_DIRECTORIES
20716
+ "OMIT_SHUTDOWN_DIRECTORIES",
20717
+#endif
20718
+#ifdef SQLITE_OMIT_SUBQUERY
20719
+ "OMIT_SUBQUERY",
20720
+#endif
20721
+#ifdef SQLITE_OMIT_TCL_VARIABLE
20722
+ "OMIT_TCL_VARIABLE",
20723
+#endif
20724
+#ifdef SQLITE_OMIT_TEMPDB
20725
+ "OMIT_TEMPDB",
20726
+#endif
20727
+#ifdef SQLITE_OMIT_TEST_CONTROL
20728
+ "OMIT_TEST_CONTROL",
20729
+#endif
20730
+#ifdef SQLITE_OMIT_TRACE
20731
+# if SQLITE_OMIT_TRACE != 1
20732
+ "OMIT_TRACE=" CTIMEOPT_VAL(SQLITE_OMIT_TRACE),
20733
+# endif
20734
+#endif
20735
+#ifdef SQLITE_OMIT_TRIGGER
20736
+ "OMIT_TRIGGER",
20737
+#endif
20738
+#ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
20739
+ "OMIT_TRUNCATE_OPTIMIZATION",
20740
+#endif
20741
+#ifdef SQLITE_OMIT_UTF16
20742
+ "OMIT_UTF16",
20743
+#endif
20744
+#ifdef SQLITE_OMIT_VACUUM
20745
+ "OMIT_VACUUM",
20746
+#endif
20747
+#ifdef SQLITE_OMIT_VIEW
20748
+ "OMIT_VIEW",
20749
+#endif
20750
+#ifdef SQLITE_OMIT_VIRTUALTABLE
20751
+ "OMIT_VIRTUALTABLE",
20752
+#endif
20753
+#ifdef SQLITE_OMIT_WAL
20754
+ "OMIT_WAL",
20755
+#endif
20756
+#ifdef SQLITE_OMIT_WSD
20757
+ "OMIT_WSD",
20758
+#endif
20759
+#ifdef SQLITE_OMIT_XFER_OPT
20760
+ "OMIT_XFER_OPT",
20761
+#endif
20762
+#ifdef SQLITE_PCACHE_SEPARATE_HEADER
20763
+ "PCACHE_SEPARATE_HEADER",
20764
+#endif
20765
+#ifdef SQLITE_PERFORMANCE_TRACE
20766
+ "PERFORMANCE_TRACE",
20767
+#endif
20768
+#ifdef SQLITE_POWERSAFE_OVERWRITE
20769
+# if SQLITE_POWERSAFE_OVERWRITE != 1
20770
+ "POWERSAFE_OVERWRITE=" CTIMEOPT_VAL(SQLITE_POWERSAFE_OVERWRITE),
20771
+# endif
20772
+#endif
20773
+#ifdef SQLITE_PREFER_PROXY_LOCKING
20774
+ "PREFER_PROXY_LOCKING",
20775
+#endif
20776
+#ifdef SQLITE_PROXY_DEBUG
20777
+ "PROXY_DEBUG",
20778
+#endif
20779
+#ifdef SQLITE_REVERSE_UNORDERED_SELECTS
20780
+ "REVERSE_UNORDERED_SELECTS",
20781
+#endif
20782
+#ifdef SQLITE_RTREE_INT_ONLY
20783
+ "RTREE_INT_ONLY",
20784
+#endif
20785
+#ifdef SQLITE_SECURE_DELETE
20786
+ "SECURE_DELETE",
20787
+#endif
20788
+#ifdef SQLITE_SMALL_STACK
20789
+ "SMALL_STACK",
20790
+#endif
20791
+#ifdef SQLITE_SORTER_PMASZ
20792
+ "SORTER_PMASZ=" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ),
20793
+#endif
20794
+#ifdef SQLITE_SOUNDEX
20795
+ "SOUNDEX",
20796
+#endif
20797
+#ifdef SQLITE_STAT4_SAMPLES
20798
+ "STAT4_SAMPLES=" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES),
20799
+#endif
20800
+#ifdef SQLITE_STMTJRNL_SPILL
20801
+ "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),
20802
+#endif
20803
+#ifdef SQLITE_SUBSTR_COMPATIBILITY
20804
+ "SUBSTR_COMPATIBILITY",
20805
+#endif
20806
+#if (!defined(SQLITE_WIN32_MALLOC) \
20807
+ && !defined(SQLITE_ZERO_MALLOC) \
20808
+ && !defined(SQLITE_MEMDEBUG) \
20809
+ ) || defined(SQLITE_SYSTEM_MALLOC)
20810
+ "SYSTEM_MALLOC",
20811
+#endif
20812
+#ifdef SQLITE_TCL
20813
+ "TCL",
20814
+#endif
20815
+#ifdef SQLITE_TEMP_STORE
20816
+ "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
20817
+#endif
20818
+#ifdef SQLITE_TEST
20819
+ "TEST",
20820
+#endif
20821
+#if defined(SQLITE_THREADSAFE)
20822
+ "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
20823
+#elif defined(THREADSAFE)
20824
+ "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE),
20825
+#else
20826
+ "THREADSAFE=1",
20827
+#endif
20828
+#ifdef SQLITE_UNLINK_AFTER_CLOSE
20829
+ "UNLINK_AFTER_CLOSE",
20830
+#endif
20831
+#ifdef SQLITE_UNTESTABLE
20832
+ "UNTESTABLE",
20833
+#endif
20834
+#ifdef SQLITE_USER_AUTHENTICATION
20835
+ "USER_AUTHENTICATION",
20836
+#endif
20837
+#ifdef SQLITE_USE_ALLOCA
20838
+ "USE_ALLOCA",
20839
+#endif
20840
+#ifdef SQLITE_USE_FCNTL_TRACE
20841
+ "USE_FCNTL_TRACE",
20842
+#endif
20843
+#ifdef SQLITE_USE_URI
20844
+ "USE_URI",
20845
+#endif
20846
+#ifdef SQLITE_VDBE_COVERAGE
20847
+ "VDBE_COVERAGE",
20848
+#endif
20849
+#ifdef SQLITE_WIN32_MALLOC
20850
+ "WIN32_MALLOC",
20851
+#endif
20852
+#ifdef SQLITE_ZERO_MALLOC
20853
+ "ZERO_MALLOC",
20854
+#endif
20855
+/*
20856
+** END CODE GENERATED BY tool/mkctime.tcl
20857
+*/
20858
+};
20859
+
20860
+SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){
20861
+ *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);
20862
+ return (const char**)sqlite3azCompileOpt;
20863
+}
20864
+
20865
+#endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
20866
+
20867
+/************** End of ctime.c ***********************************************/
2079420868
/************** Begin file global.c ******************************************/
2079520869
/*
2079620870
** 2008 June 13
2079720871
**
2079820872
** The author disclaims copyright to this source code. In place of
@@ -21342,12 +21416,12 @@
2134221416
int pc; /* Program Counter in parent (calling) frame */
2134321417
int nOp; /* Size of aOp array */
2134421418
int nMem; /* Number of entries in aMem */
2134521419
int nChildMem; /* Number of memory cells for child frame */
2134621420
int nChildCsr; /* Number of cursors for child frame */
21347
- int nChange; /* Statement changes (Vdbe.nChange) */
21348
- int nDbChange; /* Value of db->nChange */
21421
+ i64 nChange; /* Statement changes (Vdbe.nChange) */
21422
+ i64 nDbChange; /* Value of db->nChange */
2134921423
};
2135021424
2135121425
/* Magic number for sanity checking on VdbeFrame objects */
2135221426
#define SQLITE_FRAME_MAGIC 0x879fb71e
2135321427
@@ -21550,11 +21624,11 @@
2155021624
int nMem; /* Number of memory locations currently allocated */
2155121625
int nCursor; /* Number of slots in apCsr[] */
2155221626
u32 cacheCtr; /* VdbeCursor row cache generation counter */
2155321627
int pc; /* The program counter */
2155421628
int rc; /* Value to return */
21555
- int nChange; /* Number of db changes made since last reset */
21629
+ i64 nChange; /* Number of db changes made since last reset */
2155621630
int iStatement; /* Statement number (or 0 if has no opened stmt) */
2155721631
i64 iCurrentTime; /* Value of julianday('now') for this statement */
2155821632
i64 nFkConstraint; /* Number of imm. FK constraints this VM */
2155921633
i64 nStmtDefCons; /* Number of def. constraints when stmt started */
2156021634
i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
@@ -21695,10 +21769,11 @@
2169521769
SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*);
2169621770
#endif
2169721771
SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*);
2169821772
SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
2169921773
SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8);
21774
+SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double);
2170021775
SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem*);
2170121776
SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*);
2170221777
SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);
2170321778
SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull);
2170421779
SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*);
@@ -30077,10 +30152,12 @@
3007730152
sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx",
3007830153
pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed);
3007930154
}
3008030155
if( pItem->fg.jointype & JT_LEFT ){
3008130156
sqlite3_str_appendf(&x, " LEFT-JOIN");
30157
+ }else if( pItem->fg.jointype & JT_CROSS ){
30158
+ sqlite3_str_appendf(&x, " CROSS-JOIN");
3008230159
}
3008330160
if( pItem->fg.fromDDL ){
3008430161
sqlite3_str_appendf(&x, " DDL");
3008530162
}
3008630163
if( pItem->fg.isCte ){
@@ -30632,11 +30709,13 @@
3063230709
sqlite3TreeViewBareExprList(pView, pExpr->x.pList, z);
3063330710
sqlite3_free(z);
3063430711
break;
3063530712
}
3063630713
case TK_SELECT_COLUMN: {
30637
- sqlite3TreeViewLine(pView, "SELECT-COLUMN %d", pExpr->iColumn);
30714
+ sqlite3TreeViewLine(pView, "SELECT-COLUMN %d of [0..%d]%s",
30715
+ pExpr->iColumn, pExpr->iTable-1,
30716
+ pExpr->pRight==pExpr->pLeft ? " (SELECT-owner)" : "");
3063830717
sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0);
3063930718
break;
3064030719
}
3064130720
case TK_IF_NULL_ROW: {
3064230721
sqlite3TreeViewLine(pView, "IF-NULL-ROW %d", pExpr->iTable);
@@ -30648,10 +30727,19 @@
3064830727
sqlite3TreeViewLine(pView, "ERROR");
3064930728
tmp = *pExpr;
3065030729
tmp.op = pExpr->op2;
3065130730
sqlite3TreeViewExpr(pView, &tmp, 0);
3065230731
break;
30732
+ }
30733
+ case TK_ROW: {
30734
+ if( pExpr->iColumn<=0 ){
30735
+ sqlite3TreeViewLine(pView, "First FROM table rowid");
30736
+ }else{
30737
+ sqlite3TreeViewLine(pView, "First FROM table column %d",
30738
+ pExpr->iColumn-1);
30739
+ }
30740
+ break;
3065330741
}
3065430742
default: {
3065530743
sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
3065630744
break;
3065730745
}
@@ -40241,10 +40329,12 @@
4024140329
if( fd<0 ){
4024240330
if( isNewJrnl && errno==EACCES && osAccess(zName, F_OK) ){
4024340331
/* If unable to create a journal because the directory is not
4024440332
** writable, change the error code to indicate that. */
4024540333
rc = SQLITE_READONLY_DIRECTORY;
40334
+ }else if( errno==EEXIST ){
40335
+ rc = SQLITE_CANTOPEN_EXISTS;
4024640336
}else if( errno!=EISDIR && isReadWrite ){
4024740337
/* Failed to open the file for read/write access. Try read-only. */
4024840338
flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
4024940339
openFlags &= ~(O_RDWR|O_CREAT);
4025040340
flags |= SQLITE_OPEN_READONLY;
@@ -49327,11 +49417,12 @@
4932749417
#endif
4932849418
4932949419
sqlite3_mutex_enter(db->mutex);
4933049420
if( zSchema==0 ) zSchema = db->aDb[0].zDbSName;
4933149421
iDb = sqlite3FindDbName(db, zSchema);
49332
- if( iDb<0 ){
49422
+ testcase( iDb==1 );
49423
+ if( iDb<2 && iDb!=0 ){
4933349424
rc = SQLITE_ERROR;
4933449425
goto end_deserialize;
4933549426
}
4933649427
zSql = sqlite3_mprintf("ATTACH x AS %Q", zSchema);
4933749428
if( zSql==0 ){
@@ -66277,19 +66368,17 @@
6627766368
pIdxKey = sqlite3VdbeAllocUnpackedRecord(pKeyInfo);
6627866369
if( pIdxKey==0 ) return SQLITE_NOMEM_BKPT;
6627966370
sqlite3VdbeRecordUnpack(pKeyInfo, (int)nKey, pKey, pIdxKey);
6628066371
if( pIdxKey->nField==0 || pIdxKey->nField>pKeyInfo->nAllField ){
6628166372
rc = SQLITE_CORRUPT_BKPT;
66282
- goto moveto_done;
66373
+ }else{
66374
+ rc = sqlite3BtreeIndexMoveto(pCur, pIdxKey, pRes);
6628366375
}
66376
+ sqlite3DbFree(pCur->pKeyInfo->db, pIdxKey);
6628466377
}else{
6628566378
pIdxKey = 0;
66286
- }
66287
- rc = sqlite3BtreeMovetoUnpacked(pCur, pIdxKey, nKey, bias, pRes);
66288
-moveto_done:
66289
- if( pIdxKey ){
66290
- sqlite3DbFree(pCur->pKeyInfo->db, pIdxKey);
66379
+ rc = sqlite3BtreeTableMoveto(pCur, nKey, bias, pRes);
6629166380
}
6629266381
return rc;
6629366382
}
6629466383
6629566384
/*
@@ -67134,11 +67223,11 @@
6713467223
u8 *pSpace = pageFindSlot(pPage, nByte, &rc);
6713567224
if( pSpace ){
6713667225
int g2;
6713767226
assert( pSpace+nByte<=data+pPage->pBt->usableSize );
6713867227
*pIdx = g2 = (int)(pSpace-data);
67139
- if( NEVER(g2<=gap) ){
67228
+ if( g2<=gap ){
6714067229
return SQLITE_CORRUPT_PAGE(pPage);
6714167230
}else{
6714267231
return SQLITE_OK;
6714367232
}
6714467233
}else if( rc ){
@@ -70871,16 +70960,12 @@
7087170960
rc = SQLITE_OK;
7087270961
}
7087370962
return rc;
7087470963
}
7087570964
70876
-/* Move the cursor so that it points to an entry near the key
70877
-** specified by pIdxKey or intKey. Return a success code.
70878
-**
70879
-** For INTKEY tables, the intKey parameter is used. pIdxKey
70880
-** must be NULL. For index tables, pIdxKey is used and intKey
70881
-** is ignored.
70965
+/* Move the cursor so that it points to an entry in a table (a.k.a INTKEY)
70966
+** table near the key intKey. Return a success code.
7088270967
**
7088370968
** If an exact match is not found, then the cursor is always
7088470969
** left pointing at a leaf page which would hold the entry if it
7088570970
** were present. The cursor might point to an entry that comes
7088670971
** before or after the key.
@@ -70889,43 +70974,36 @@
7088970974
** comparing the key with the entry to which the cursor is
7089070975
** pointing. The meaning of the integer written into
7089170976
** *pRes is as follows:
7089270977
**
7089370978
** *pRes<0 The cursor is left pointing at an entry that
70894
-** is smaller than intKey/pIdxKey or if the table is empty
70979
+** is smaller than intKey or if the table is empty
7089570980
** and the cursor is therefore left point to nothing.
7089670981
**
7089770982
** *pRes==0 The cursor is left pointing at an entry that
70898
-** exactly matches intKey/pIdxKey.
70983
+** exactly matches intKey.
7089970984
**
7090070985
** *pRes>0 The cursor is left pointing at an entry that
70901
-** is larger than intKey/pIdxKey.
70902
-**
70903
-** For index tables, the pIdxKey->eqSeen field is set to 1 if there
70904
-** exists an entry in the table that exactly matches pIdxKey.
70986
+** is larger than intKey.
7090570987
*/
70906
-SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(
70988
+SQLITE_PRIVATE int sqlite3BtreeTableMoveto(
7090770989
BtCursor *pCur, /* The cursor to be moved */
70908
- UnpackedRecord *pIdxKey, /* Unpacked index key */
7090970990
i64 intKey, /* The table key */
7091070991
int biasRight, /* If true, bias the search to the high end */
7091170992
int *pRes /* Write search results here */
7091270993
){
7091370994
int rc;
70914
- RecordCompare xRecordCompare;
7091570995
7091670996
assert( cursorOwnsBtShared(pCur) );
7091770997
assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
7091870998
assert( pRes );
70919
- assert( (pIdxKey==0)==(pCur->pKeyInfo==0) );
70920
- assert( pCur->eState!=CURSOR_VALID || (pIdxKey==0)==(pCur->curIntKey!=0) );
70999
+ assert( pCur->pKeyInfo==0 );
71000
+ assert( pCur->eState!=CURSOR_VALID || pCur->curIntKey!=0 );
7092171001
7092271002
/* If the cursor is already positioned at the point we are trying
7092371003
** to move to, then just return without doing any work */
70924
- if( pIdxKey==0
70925
- && pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0
70926
- ){
71004
+ if( pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0 ){
7092771005
if( pCur->info.nKey==intKey ){
7092871006
*pRes = 0;
7092971007
return SQLITE_OK;
7093071008
}
7093171009
if( pCur->info.nKey<intKey ){
@@ -70956,20 +71034,153 @@
7095671034
7095771035
#ifdef SQLITE_DEBUG
7095871036
pCur->pBtree->nSeek++; /* Performance measurement during testing */
7095971037
#endif
7096071038
70961
- if( pIdxKey ){
70962
- xRecordCompare = sqlite3VdbeFindCompare(pIdxKey);
70963
- pIdxKey->errCode = 0;
70964
- assert( pIdxKey->default_rc==1
70965
- || pIdxKey->default_rc==0
70966
- || pIdxKey->default_rc==-1
70967
- );
70968
- }else{
70969
- xRecordCompare = 0; /* All keys are integers */
70970
- }
71039
+ rc = moveToRoot(pCur);
71040
+ if( rc ){
71041
+ if( rc==SQLITE_EMPTY ){
71042
+ assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );
71043
+ *pRes = -1;
71044
+ return SQLITE_OK;
71045
+ }
71046
+ return rc;
71047
+ }
71048
+ assert( pCur->pPage );
71049
+ assert( pCur->pPage->isInit );
71050
+ assert( pCur->eState==CURSOR_VALID );
71051
+ assert( pCur->pPage->nCell > 0 );
71052
+ assert( pCur->iPage==0 || pCur->apPage[0]->intKey==pCur->curIntKey );
71053
+ assert( pCur->curIntKey );
71054
+
71055
+ for(;;){
71056
+ int lwr, upr, idx, c;
71057
+ Pgno chldPg;
71058
+ MemPage *pPage = pCur->pPage;
71059
+ u8 *pCell; /* Pointer to current cell in pPage */
71060
+
71061
+ /* pPage->nCell must be greater than zero. If this is the root-page
71062
+ ** the cursor would have been INVALID above and this for(;;) loop
71063
+ ** not run. If this is not the root-page, then the moveToChild() routine
71064
+ ** would have already detected db corruption. Similarly, pPage must
71065
+ ** be the right kind (index or table) of b-tree page. Otherwise
71066
+ ** a moveToChild() or moveToRoot() call would have detected corruption. */
71067
+ assert( pPage->nCell>0 );
71068
+ assert( pPage->intKey );
71069
+ lwr = 0;
71070
+ upr = pPage->nCell-1;
71071
+ assert( biasRight==0 || biasRight==1 );
71072
+ idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */
71073
+ pCur->ix = (u16)idx;
71074
+ for(;;){
71075
+ i64 nCellKey;
71076
+ pCell = findCellPastPtr(pPage, idx);
71077
+ if( pPage->intKeyLeaf ){
71078
+ while( 0x80 <= *(pCell++) ){
71079
+ if( pCell>=pPage->aDataEnd ){
71080
+ return SQLITE_CORRUPT_PAGE(pPage);
71081
+ }
71082
+ }
71083
+ }
71084
+ getVarint(pCell, (u64*)&nCellKey);
71085
+ if( nCellKey<intKey ){
71086
+ lwr = idx+1;
71087
+ if( lwr>upr ){ c = -1; break; }
71088
+ }else if( nCellKey>intKey ){
71089
+ upr = idx-1;
71090
+ if( lwr>upr ){ c = +1; break; }
71091
+ }else{
71092
+ assert( nCellKey==intKey );
71093
+ pCur->ix = (u16)idx;
71094
+ if( !pPage->leaf ){
71095
+ lwr = idx;
71096
+ goto moveto_table_next_layer;
71097
+ }else{
71098
+ pCur->curFlags |= BTCF_ValidNKey;
71099
+ pCur->info.nKey = nCellKey;
71100
+ pCur->info.nSize = 0;
71101
+ *pRes = 0;
71102
+ return SQLITE_OK;
71103
+ }
71104
+ }
71105
+ assert( lwr+upr>=0 );
71106
+ idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2; */
71107
+ }
71108
+ assert( lwr==upr+1 || !pPage->leaf );
71109
+ assert( pPage->isInit );
71110
+ if( pPage->leaf ){
71111
+ assert( pCur->ix<pCur->pPage->nCell );
71112
+ pCur->ix = (u16)idx;
71113
+ *pRes = c;
71114
+ rc = SQLITE_OK;
71115
+ goto moveto_table_finish;
71116
+ }
71117
+moveto_table_next_layer:
71118
+ if( lwr>=pPage->nCell ){
71119
+ chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]);
71120
+ }else{
71121
+ chldPg = get4byte(findCell(pPage, lwr));
71122
+ }
71123
+ pCur->ix = (u16)lwr;
71124
+ rc = moveToChild(pCur, chldPg);
71125
+ if( rc ) break;
71126
+ }
71127
+moveto_table_finish:
71128
+ pCur->info.nSize = 0;
71129
+ assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );
71130
+ return rc;
71131
+}
71132
+
71133
+/* Move the cursor so that it points to an entry in an index table
71134
+** near the key pIdxKey. Return a success code.
71135
+**
71136
+** If an exact match is not found, then the cursor is always
71137
+** left pointing at a leaf page which would hold the entry if it
71138
+** were present. The cursor might point to an entry that comes
71139
+** before or after the key.
71140
+**
71141
+** An integer is written into *pRes which is the result of
71142
+** comparing the key with the entry to which the cursor is
71143
+** pointing. The meaning of the integer written into
71144
+** *pRes is as follows:
71145
+**
71146
+** *pRes<0 The cursor is left pointing at an entry that
71147
+** is smaller than pIdxKey or if the table is empty
71148
+** and the cursor is therefore left point to nothing.
71149
+**
71150
+** *pRes==0 The cursor is left pointing at an entry that
71151
+** exactly matches pIdxKey.
71152
+**
71153
+** *pRes>0 The cursor is left pointing at an entry that
71154
+** is larger than pIdxKey.
71155
+**
71156
+** The pIdxKey->eqSeen field is set to 1 if there
71157
+** exists an entry in the table that exactly matches pIdxKey.
71158
+*/
71159
+SQLITE_PRIVATE int sqlite3BtreeIndexMoveto(
71160
+ BtCursor *pCur, /* The cursor to be moved */
71161
+ UnpackedRecord *pIdxKey, /* Unpacked index key */
71162
+ int *pRes /* Write search results here */
71163
+){
71164
+ int rc;
71165
+ RecordCompare xRecordCompare;
71166
+
71167
+ assert( cursorOwnsBtShared(pCur) );
71168
+ assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
71169
+ assert( pRes );
71170
+ assert( pCur->pKeyInfo!=0 );
71171
+
71172
+#ifdef SQLITE_DEBUG
71173
+ pCur->pBtree->nSeek++; /* Performance measurement during testing */
71174
+#endif
71175
+
71176
+ xRecordCompare = sqlite3VdbeFindCompare(pIdxKey);
71177
+ pIdxKey->errCode = 0;
71178
+ assert( pIdxKey->default_rc==1
71179
+ || pIdxKey->default_rc==0
71180
+ || pIdxKey->default_rc==-1
71181
+ );
7097171182
7097271183
rc = moveToRoot(pCur);
7097371184
if( rc ){
7097471185
if( rc==SQLITE_EMPTY ){
7097571186
assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );
@@ -70998,155 +71209,116 @@
7099871209
** a moveToChild() or moveToRoot() call would have detected corruption. */
7099971210
assert( pPage->nCell>0 );
7100071211
assert( pPage->intKey==(pIdxKey==0) );
7100171212
lwr = 0;
7100271213
upr = pPage->nCell-1;
71003
- assert( biasRight==0 || biasRight==1 );
71004
- idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */
71005
- pCur->ix = (u16)idx;
71006
- if( xRecordCompare==0 ){
71007
- for(;;){
71008
- i64 nCellKey;
71009
- pCell = findCellPastPtr(pPage, idx);
71010
- if( pPage->intKeyLeaf ){
71011
- while( 0x80 <= *(pCell++) ){
71012
- if( pCell>=pPage->aDataEnd ){
71013
- return SQLITE_CORRUPT_PAGE(pPage);
71014
- }
71015
- }
71016
- }
71017
- getVarint(pCell, (u64*)&nCellKey);
71018
- if( nCellKey<intKey ){
71019
- lwr = idx+1;
71020
- if( lwr>upr ){ c = -1; break; }
71021
- }else if( nCellKey>intKey ){
71022
- upr = idx-1;
71023
- if( lwr>upr ){ c = +1; break; }
71024
- }else{
71025
- assert( nCellKey==intKey );
71026
- pCur->ix = (u16)idx;
71027
- if( !pPage->leaf ){
71028
- lwr = idx;
71029
- goto moveto_next_layer;
71030
- }else{
71031
- pCur->curFlags |= BTCF_ValidNKey;
71032
- pCur->info.nKey = nCellKey;
71033
- pCur->info.nSize = 0;
71034
- *pRes = 0;
71035
- return SQLITE_OK;
71036
- }
71037
- }
71038
- assert( lwr+upr>=0 );
71039
- idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2; */
71040
- }
71041
- }else{
71042
- for(;;){
71043
- int nCell; /* Size of the pCell cell in bytes */
71044
- pCell = findCellPastPtr(pPage, idx);
71045
-
71046
- /* The maximum supported page-size is 65536 bytes. This means that
71047
- ** the maximum number of record bytes stored on an index B-Tree
71048
- ** page is less than 16384 bytes and may be stored as a 2-byte
71049
- ** varint. This information is used to attempt to avoid parsing
71050
- ** the entire cell by checking for the cases where the record is
71051
- ** stored entirely within the b-tree page by inspecting the first
71052
- ** 2 bytes of the cell.
71053
- */
71054
- nCell = pCell[0];
71055
- if( nCell<=pPage->max1bytePayload ){
71056
- /* This branch runs if the record-size field of the cell is a
71057
- ** single byte varint and the record fits entirely on the main
71058
- ** b-tree page. */
71059
- testcase( pCell+nCell+1==pPage->aDataEnd );
71060
- c = xRecordCompare(nCell, (void*)&pCell[1], pIdxKey);
71061
- }else if( !(pCell[1] & 0x80)
71062
- && (nCell = ((nCell&0x7f)<<7) + pCell[1])<=pPage->maxLocal
71063
- ){
71064
- /* The record-size field is a 2 byte varint and the record
71065
- ** fits entirely on the main b-tree page. */
71066
- testcase( pCell+nCell+2==pPage->aDataEnd );
71067
- c = xRecordCompare(nCell, (void*)&pCell[2], pIdxKey);
71068
- }else{
71069
- /* The record flows over onto one or more overflow pages. In
71070
- ** this case the whole cell needs to be parsed, a buffer allocated
71071
- ** and accessPayload() used to retrieve the record into the
71072
- ** buffer before VdbeRecordCompare() can be called.
71073
- **
71074
- ** If the record is corrupt, the xRecordCompare routine may read
71075
- ** up to two varints past the end of the buffer. An extra 18
71076
- ** bytes of padding is allocated at the end of the buffer in
71077
- ** case this happens. */
71078
- void *pCellKey;
71079
- u8 * const pCellBody = pCell - pPage->childPtrSize;
71080
- const int nOverrun = 18; /* Size of the overrun padding */
71081
- pPage->xParseCell(pPage, pCellBody, &pCur->info);
71082
- nCell = (int)pCur->info.nKey;
71083
- testcase( nCell<0 ); /* True if key size is 2^32 or more */
71084
- testcase( nCell==0 ); /* Invalid key size: 0x80 0x80 0x00 */
71085
- testcase( nCell==1 ); /* Invalid key size: 0x80 0x80 0x01 */
71086
- testcase( nCell==2 ); /* Minimum legal index key size */
71087
- if( nCell<2 || nCell/pCur->pBt->usableSize>pCur->pBt->nPage ){
71088
- rc = SQLITE_CORRUPT_PAGE(pPage);
71089
- goto moveto_finish;
71090
- }
71091
- pCellKey = sqlite3Malloc( nCell+nOverrun );
71092
- if( pCellKey==0 ){
71093
- rc = SQLITE_NOMEM_BKPT;
71094
- goto moveto_finish;
71095
- }
71096
- pCur->ix = (u16)idx;
71097
- rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);
71098
- memset(((u8*)pCellKey)+nCell,0,nOverrun); /* Fix uninit warnings */
71099
- pCur->curFlags &= ~BTCF_ValidOvfl;
71100
- if( rc ){
71101
- sqlite3_free(pCellKey);
71102
- goto moveto_finish;
71103
- }
71104
- c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey);
71105
- sqlite3_free(pCellKey);
71106
- }
71107
- assert(
71108
- (pIdxKey->errCode!=SQLITE_CORRUPT || c==0)
71109
- && (pIdxKey->errCode!=SQLITE_NOMEM || pCur->pBtree->db->mallocFailed)
71110
- );
71111
- if( c<0 ){
71112
- lwr = idx+1;
71113
- }else if( c>0 ){
71114
- upr = idx-1;
71115
- }else{
71116
- assert( c==0 );
71117
- *pRes = 0;
71118
- rc = SQLITE_OK;
71119
- pCur->ix = (u16)idx;
71120
- if( pIdxKey->errCode ) rc = SQLITE_CORRUPT_BKPT;
71121
- goto moveto_finish;
71122
- }
71123
- if( lwr>upr ) break;
71124
- assert( lwr+upr>=0 );
71125
- idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2 */
71126
- }
71214
+ idx = upr>>1; /* idx = (lwr+upr)/2; */
71215
+ pCur->ix = (u16)idx;
71216
+ for(;;){
71217
+ int nCell; /* Size of the pCell cell in bytes */
71218
+ pCell = findCellPastPtr(pPage, idx);
71219
+
71220
+ /* The maximum supported page-size is 65536 bytes. This means that
71221
+ ** the maximum number of record bytes stored on an index B-Tree
71222
+ ** page is less than 16384 bytes and may be stored as a 2-byte
71223
+ ** varint. This information is used to attempt to avoid parsing
71224
+ ** the entire cell by checking for the cases where the record is
71225
+ ** stored entirely within the b-tree page by inspecting the first
71226
+ ** 2 bytes of the cell.
71227
+ */
71228
+ nCell = pCell[0];
71229
+ if( nCell<=pPage->max1bytePayload ){
71230
+ /* This branch runs if the record-size field of the cell is a
71231
+ ** single byte varint and the record fits entirely on the main
71232
+ ** b-tree page. */
71233
+ testcase( pCell+nCell+1==pPage->aDataEnd );
71234
+ c = xRecordCompare(nCell, (void*)&pCell[1], pIdxKey);
71235
+ }else if( !(pCell[1] & 0x80)
71236
+ && (nCell = ((nCell&0x7f)<<7) + pCell[1])<=pPage->maxLocal
71237
+ ){
71238
+ /* The record-size field is a 2 byte varint and the record
71239
+ ** fits entirely on the main b-tree page. */
71240
+ testcase( pCell+nCell+2==pPage->aDataEnd );
71241
+ c = xRecordCompare(nCell, (void*)&pCell[2], pIdxKey);
71242
+ }else{
71243
+ /* The record flows over onto one or more overflow pages. In
71244
+ ** this case the whole cell needs to be parsed, a buffer allocated
71245
+ ** and accessPayload() used to retrieve the record into the
71246
+ ** buffer before VdbeRecordCompare() can be called.
71247
+ **
71248
+ ** If the record is corrupt, the xRecordCompare routine may read
71249
+ ** up to two varints past the end of the buffer. An extra 18
71250
+ ** bytes of padding is allocated at the end of the buffer in
71251
+ ** case this happens. */
71252
+ void *pCellKey;
71253
+ u8 * const pCellBody = pCell - pPage->childPtrSize;
71254
+ const int nOverrun = 18; /* Size of the overrun padding */
71255
+ pPage->xParseCell(pPage, pCellBody, &pCur->info);
71256
+ nCell = (int)pCur->info.nKey;
71257
+ testcase( nCell<0 ); /* True if key size is 2^32 or more */
71258
+ testcase( nCell==0 ); /* Invalid key size: 0x80 0x80 0x00 */
71259
+ testcase( nCell==1 ); /* Invalid key size: 0x80 0x80 0x01 */
71260
+ testcase( nCell==2 ); /* Minimum legal index key size */
71261
+ if( nCell<2 || nCell/pCur->pBt->usableSize>pCur->pBt->nPage ){
71262
+ rc = SQLITE_CORRUPT_PAGE(pPage);
71263
+ goto moveto_index_finish;
71264
+ }
71265
+ pCellKey = sqlite3Malloc( nCell+nOverrun );
71266
+ if( pCellKey==0 ){
71267
+ rc = SQLITE_NOMEM_BKPT;
71268
+ goto moveto_index_finish;
71269
+ }
71270
+ pCur->ix = (u16)idx;
71271
+ rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);
71272
+ memset(((u8*)pCellKey)+nCell,0,nOverrun); /* Fix uninit warnings */
71273
+ pCur->curFlags &= ~BTCF_ValidOvfl;
71274
+ if( rc ){
71275
+ sqlite3_free(pCellKey);
71276
+ goto moveto_index_finish;
71277
+ }
71278
+ c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey);
71279
+ sqlite3_free(pCellKey);
71280
+ }
71281
+ assert(
71282
+ (pIdxKey->errCode!=SQLITE_CORRUPT || c==0)
71283
+ && (pIdxKey->errCode!=SQLITE_NOMEM || pCur->pBtree->db->mallocFailed)
71284
+ );
71285
+ if( c<0 ){
71286
+ lwr = idx+1;
71287
+ }else if( c>0 ){
71288
+ upr = idx-1;
71289
+ }else{
71290
+ assert( c==0 );
71291
+ *pRes = 0;
71292
+ rc = SQLITE_OK;
71293
+ pCur->ix = (u16)idx;
71294
+ if( pIdxKey->errCode ) rc = SQLITE_CORRUPT_BKPT;
71295
+ goto moveto_index_finish;
71296
+ }
71297
+ if( lwr>upr ) break;
71298
+ assert( lwr+upr>=0 );
71299
+ idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2 */
7112771300
}
7112871301
assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) );
7112971302
assert( pPage->isInit );
7113071303
if( pPage->leaf ){
7113171304
assert( pCur->ix<pCur->pPage->nCell );
7113271305
pCur->ix = (u16)idx;
7113371306
*pRes = c;
7113471307
rc = SQLITE_OK;
71135
- goto moveto_finish;
71308
+ goto moveto_index_finish;
7113671309
}
71137
-moveto_next_layer:
7113871310
if( lwr>=pPage->nCell ){
7113971311
chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]);
7114071312
}else{
7114171313
chldPg = get4byte(findCell(pPage, lwr));
7114271314
}
7114371315
pCur->ix = (u16)lwr;
7114471316
rc = moveToChild(pCur, chldPg);
7114571317
if( rc ) break;
7114671318
}
71147
-moveto_finish:
71319
+moveto_index_finish:
7114871320
pCur->info.nSize = 0;
7114971321
assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );
7115071322
return rc;
7115171323
}
7115271324
@@ -73126,10 +73298,11 @@
7312673298
if( rc ){
7312773299
memset(apOld, 0, (i)*sizeof(MemPage*));
7312873300
goto balance_cleanup;
7312973301
}
7313073302
}
73303
+ nMaxCells += apOld[i]->nCell + ArraySize(pParent->apOvfl);
7313173304
if( (i--)==0 ) break;
7313273305
7313373306
if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){
7313473307
apDiv[i] = pParent->apOvfl[0];
7313573308
pgno = get4byte(apDiv[i]);
@@ -73167,11 +73340,10 @@
7316773340
}
7316873341
}
7316973342
7317073343
/* Make nMaxCells a multiple of 4 in order to preserve 8-byte
7317173344
** alignment */
73172
- nMaxCells = nOld*(MX_CELL(pBt) + ArraySize(pParent->apOvfl));
7317373345
nMaxCells = (nMaxCells + 3)&~3;
7317473346
7317573347
/*
7317673348
** Allocate space for memory structures
7317773349
*/
@@ -73450,11 +73622,13 @@
7345073622
if( i<nOld ){
7345173623
pNew = apNew[i] = apOld[i];
7345273624
apOld[i] = 0;
7345373625
rc = sqlite3PagerWrite(pNew->pDbPage);
7345473626
nNew++;
73455
- if( sqlite3PagerPageRefcount(pNew->pDbPage)!=1+(i==(iParentIdx-nxDiv)) ){
73627
+ if( sqlite3PagerPageRefcount(pNew->pDbPage)!=1+(i==(iParentIdx-nxDiv))
73628
+ && rc==SQLITE_OK
73629
+ ){
7345673630
rc = SQLITE_CORRUPT_BKPT;
7345773631
}
7345873632
if( rc ) goto balance_cleanup;
7345973633
}else{
7346073634
assert( i>0 );
@@ -74248,11 +74422,12 @@
7424874422
}else if( loc==0 ){
7424974423
/* The cursor is *not* pointing to the cell to be overwritten, nor
7425074424
** to an adjacent cell. Move the cursor so that it is pointing either
7425174425
** to the cell to be overwritten or an adjacent cell.
7425274426
*/
74253
- rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, flags!=0, &loc);
74427
+ rc = sqlite3BtreeTableMoveto(pCur, pX->nKey,
74428
+ (flags & BTREE_APPEND)!=0, &loc);
7425474429
if( rc ) return rc;
7425574430
}
7425674431
}else{
7425774432
/* This is an index or a WITHOUT ROWID table */
7425874433
@@ -74271,17 +74446,15 @@
7427174446
UnpackedRecord r;
7427274447
r.pKeyInfo = pCur->pKeyInfo;
7427374448
r.aMem = pX->aMem;
7427474449
r.nField = pX->nMem;
7427574450
r.default_rc = 0;
74276
- r.errCode = 0;
74277
- r.r1 = 0;
74278
- r.r2 = 0;
7427974451
r.eqSeen = 0;
74280
- rc = sqlite3BtreeMovetoUnpacked(pCur, &r, 0, flags!=0, &loc);
74452
+ rc = sqlite3BtreeIndexMoveto(pCur, &r, &loc);
7428174453
}else{
74282
- rc = btreeMoveto(pCur, pX->pKey, pX->nKey, flags!=0, &loc);
74454
+ rc = btreeMoveto(pCur, pX->pKey, pX->nKey,
74455
+ (flags & BTREE_APPEND)!=0, &loc);
7428374456
}
7428474457
if( rc ) return rc;
7428574458
}
7428674459
7428774460
/* If the cursor is currently pointing to an entry to be overwritten
@@ -74911,11 +75084,11 @@
7491175084
*/
7491275085
static int clearDatabasePage(
7491375086
BtShared *pBt, /* The BTree that contains the table */
7491475087
Pgno pgno, /* Page number to clear */
7491575088
int freePageFlag, /* Deallocate page if true */
74916
- int *pnChange /* Add number of Cells freed to this counter */
75089
+ i64 *pnChange /* Add number of Cells freed to this counter */
7491775090
){
7491875091
MemPage *pPage;
7491975092
int rc;
7492075093
unsigned char *pCell;
7492175094
int i;
@@ -74944,10 +75117,11 @@
7494475117
if( rc ) goto cleardatabasepage_out;
7494575118
}
7494675119
if( !pPage->leaf ){
7494775120
rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
7494875121
if( rc ) goto cleardatabasepage_out;
75122
+ if( pPage->intKey ) pnChange = 0;
7494975123
}
7495075124
if( pnChange ){
7495175125
testcase( !pPage->intKey );
7495275126
*pnChange += pPage->nCell;
7495375127
}
@@ -74973,11 +75147,11 @@
7497375147
** root of the table.
7497475148
**
7497575149
** If pnChange is not NULL, then the integer value pointed to by pnChange
7497675150
** is incremented by the number of entries in the table.
7497775151
*/
74978
-SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){
75152
+SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, i64 *pnChange){
7497975153
int rc;
7498075154
BtShared *pBt = p->pBt;
7498175155
sqlite3BtreeEnter(p);
7498275156
assert( p->inTrans==TRANS_WRITE );
7498375157
@@ -82408,11 +82582,11 @@
8240882582
extern int sqlite3_search_count;
8240982583
#endif
8241082584
assert( p->deferredMoveto );
8241182585
assert( p->isTable );
8241282586
assert( p->eCurType==CURTYPE_BTREE );
82413
- rc = sqlite3BtreeMovetoUnpacked(p->uc.pCursor, 0, p->movetoTarget, 0, &res);
82587
+ rc = sqlite3BtreeTableMoveto(p->uc.pCursor, p->movetoTarget, 0, &res);
8241482588
if( rc ) return rc;
8241582589
if( res!=0 ) return SQLITE_CORRUPT_BKPT;
8241682590
#ifdef SQLITE_TEST
8241782591
sqlite3_search_count++;
8241882592
#endif
@@ -83192,11 +83366,11 @@
8319283366
/*
8319383367
** Do a comparison between a 64-bit signed integer and a 64-bit floating-point
8319483368
** number. Return negative, zero, or positive if the first (i64) is less than,
8319583369
** equal to, or greater than the second (double).
8319683370
*/
83197
-static int sqlite3IntFloatCompare(i64 i, double r){
83371
+SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){
8319883372
if( sizeof(LONGDOUBLE_TYPE)>8 ){
8319983373
LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i;
8320083374
testcase( x<r );
8320183375
testcase( x>r );
8320283376
testcase( x==r );
@@ -83916,11 +84090,11 @@
8391684090
8391784091
/*
8391884092
** This routine sets the value to be returned by subsequent calls to
8391984093
** sqlite3_changes() on the database handle 'db'.
8392084094
*/
83921
-SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *db, int nChange){
84095
+SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *db, i64 nChange){
8392284096
assert( sqlite3_mutex_held(db->mutex) );
8392384097
db->nChange = nChange;
8392484098
db->nTotalChange += nChange;
8392584099
}
8392684100
@@ -90284,10 +90458,12 @@
9028490458
assert( pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );
9028590459
assert( pOp->p4type==P4_KEYINFO );
9028690460
pCur = p->apCsr[pOp->p1];
9028790461
if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){
9028890462
assert( pCur->iDb==pOp->p3 ); /* Guaranteed by the code generator */
90463
+ assert( pCur->eCurType==CURTYPE_BTREE );
90464
+ sqlite3BtreeClearCursor(pCur->uc.pCursor);
9028990465
goto open_cursor_set_hints;
9029090466
}
9029190467
/* If the cursor is not currently open or is open on a different
9029290468
** index, then fall through into OP_OpenRead to force a reopen */
9029390469
case OP_OpenRead:
@@ -90771,45 +90947,47 @@
9077190947
pIn3->flags = flags3; /* But convert the type back to its original */
9077290948
9077390949
/* If the P3 value could not be converted into an integer without
9077490950
** loss of information, then special processing is required... */
9077590951
if( (newType & (MEM_Int|MEM_IntReal))==0 ){
90952
+ int c;
9077690953
if( (newType & MEM_Real)==0 ){
9077790954
if( (newType & MEM_Null) || oc>=OP_SeekGE ){
9077890955
VdbeBranchTaken(1,2);
9077990956
goto jump_to_p2;
9078090957
}else{
9078190958
rc = sqlite3BtreeLast(pC->uc.pCursor, &res);
9078290959
if( rc!=SQLITE_OK ) goto abort_due_to_error;
9078390960
goto seek_not_found;
9078490961
}
90785
- }else
90962
+ }
90963
+ c = sqlite3IntFloatCompare(iKey, pIn3->u.r);
9078690964
9078790965
/* If the approximation iKey is larger than the actual real search
9078890966
** term, substitute >= for > and < for <=. e.g. if the search term
9078990967
** is 4.9 and the integer approximation 5:
9079090968
**
9079190969
** (x > 4.9) -> (x >= 5)
9079290970
** (x <= 4.9) -> (x < 5)
9079390971
*/
90794
- if( pIn3->u.r<(double)iKey ){
90972
+ if( c>0 ){
9079590973
assert( OP_SeekGE==(OP_SeekGT-1) );
9079690974
assert( OP_SeekLT==(OP_SeekLE-1) );
9079790975
assert( (OP_SeekLE & 0x0001)==(OP_SeekGT & 0x0001) );
9079890976
if( (oc & 0x0001)==(OP_SeekGT & 0x0001) ) oc--;
9079990977
}
9080090978
9080190979
/* If the approximation iKey is smaller than the actual real search
9080290980
** term, substitute <= for < and > for >=. */
90803
- else if( pIn3->u.r>(double)iKey ){
90981
+ else if( c<0 ){
9080490982
assert( OP_SeekLE==(OP_SeekLT+1) );
9080590983
assert( OP_SeekGT==(OP_SeekGE+1) );
9080690984
assert( (OP_SeekLT & 0x0001)==(OP_SeekGE & 0x0001) );
9080790985
if( (oc & 0x0001)==(OP_SeekLT & 0x0001) ) oc++;
9080890986
}
9080990987
}
90810
- rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)iKey, 0, &res);
90988
+ rc = sqlite3BtreeTableMoveto(pC->uc.pCursor, (u64)iKey, 0, &res);
9081190989
pC->movetoTarget = iKey; /* Used by OP_Delete */
9081290990
if( rc!=SQLITE_OK ){
9081390991
goto abort_due_to_error;
9081490992
}
9081590993
}else{
@@ -90852,11 +91030,11 @@
9085291030
r.aMem = &aMem[pOp->p3];
9085391031
#ifdef SQLITE_DEBUG
9085491032
{ int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }
9085591033
#endif
9085691034
r.eqSeen = 0;
90857
- rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, &r, 0, 0, &res);
91035
+ rc = sqlite3BtreeIndexMoveto(pC->uc.pCursor, &r, &res);
9085891036
if( rc!=SQLITE_OK ){
9085991037
goto abort_due_to_error;
9086091038
}
9086191039
if( eqOnly && r.eqSeen==0 ){
9086291040
assert( res!=0 );
@@ -91271,11 +91449,11 @@
9127191449
takeJump = 1;
9127291450
break;
9127391451
}
9127491452
}
9127591453
}
91276
- rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, pIdxKey, 0, 0, &res);
91454
+ rc = sqlite3BtreeIndexMoveto(pC->uc.pCursor, pIdxKey, &res);
9127791455
if( pFree ) sqlite3DbFreeNN(db, pFree);
9127891456
if( rc!=SQLITE_OK ){
9127991457
goto abort_due_to_error;
9128091458
}
9128191459
pC->seekResult = res;
@@ -91380,11 +91558,11 @@
9138091558
assert( pC->isTable );
9138191559
assert( pC->eCurType==CURTYPE_BTREE );
9138291560
pCrsr = pC->uc.pCursor;
9138391561
assert( pCrsr!=0 );
9138491562
res = 0;
91385
- rc = sqlite3BtreeMovetoUnpacked(pCrsr, 0, iKey, 0, &res);
91563
+ rc = sqlite3BtreeTableMoveto(pCrsr, iKey, 0, &res);
9138691564
assert( rc==SQLITE_OK || res==0 );
9138791565
pC->movetoTarget = iKey; /* Used by OP_Delete */
9138891566
pC->nullRow = 0;
9138991567
pC->cacheStatus = CACHE_STALE;
9139091568
pC->deferredMoveto = 0;
@@ -91537,11 +91715,11 @@
9153791715
** an AUTOINCREMENT table. */
9153891716
cnt = 0;
9153991717
do{
9154091718
sqlite3_randomness(sizeof(v), &v);
9154191719
v &= (MAX_ROWID>>1); v++; /* Ensure that v is greater than zero */
91542
- }while( ((rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)v,
91720
+ }while( ((rc = sqlite3BtreeTableMoveto(pC->uc.pCursor, (u64)v,
9154391721
0, &res))==SQLITE_OK)
9154491722
&& (res==0)
9154591723
&& (++cnt<100));
9154691724
if( rc ) goto abort_due_to_error;
9154791725
if( res==0 ){
@@ -92435,11 +92613,11 @@
9243592613
assert( pCrsr!=0 );
9243692614
r.pKeyInfo = pC->pKeyInfo;
9243792615
r.nField = (u16)pOp->p3;
9243892616
r.default_rc = 0;
9243992617
r.aMem = &aMem[pOp->p2];
92440
- rc = sqlite3BtreeMovetoUnpacked(pCrsr, &r, 0, 0, &res);
92618
+ rc = sqlite3BtreeIndexMoveto(pCrsr, &r, &res);
9244192619
if( rc ) goto abort_due_to_error;
9244292620
if( res==0 ){
9244392621
rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
9244492622
if( rc ) goto abort_due_to_error;
9244592623
}else if( pOp->p5 ){
@@ -92748,11 +92926,11 @@
9274892926
** by the number of rows in the table being cleared.
9274992927
**
9275092928
** See also: Destroy
9275192929
*/
9275292930
case OP_Clear: {
92753
- int nChange;
92931
+ i64 nChange;
9275492932
9275592933
sqlite3VdbeIncrWriteCounter(p, 0);
9275692934
nChange = 0;
9275792935
assert( p->readOnly==0 );
9275892936
assert( DbMaskTest(p->btreeMask, pOp->p2) );
@@ -99511,11 +99689,11 @@
9951199689
if( pSrcList ){
9951299690
for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){
9951399691
u8 hCol;
9951499692
pTab = pItem->pTab;
9951599693
assert( pTab!=0 && pTab->zName!=0 );
99516
- assert( pTab->nCol>0 );
99694
+ assert( pTab->nCol>0 || pParse->nErr );
9951799695
if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){
9951899696
int hit = 0;
9951999697
pEList = pItem->pSelect->pEList;
9952099698
for(j=0; j<pEList->nExpr; j++){
9952199699
if( sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb) ){
@@ -99539,13 +99717,10 @@
9953999717
}
9954099718
if( IN_RENAME_OBJECT && pItem->zAlias ){
9954199719
sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab);
9954299720
}
9954399721
}
99544
- if( 0==(cntTab++) ){
99545
- pMatch = pItem;
99546
- }
9954799722
hCol = sqlite3StrIHash(zCol);
9954899723
for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){
9954999724
if( pCol->hName==hCol && sqlite3StrICmp(pCol->zName, zCol)==0 ){
9955099725
/* If there has been exactly one prior match and this match
9955199726
** is for the right-hand table of a NATURAL JOIN or is in a
@@ -99559,10 +99734,14 @@
9955999734
pMatch = pItem;
9956099735
/* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */
9956199736
pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;
9956299737
break;
9956399738
}
99739
+ }
99740
+ if( 0==cnt && VisibleRowid(pTab) ){
99741
+ cntTab++;
99742
+ pMatch = pItem;
9956499743
}
9956599744
}
9956699745
if( pMatch ){
9956799746
pExpr->iTable = pMatch->iCursor;
9956899747
pExpr->y.pTab = pMatch->pTab;
@@ -99682,11 +99861,11 @@
9968299861
if( cnt==0
9968399862
&& cntTab==1
9968499863
&& pMatch
9968599864
&& (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0
9968699865
&& sqlite3IsRowid(zCol)
99687
- && VisibleRowid(pMatch->pTab)
99866
+ && ALWAYS(VisibleRowid(pMatch->pTab))
9968899867
){
9968999868
cnt = 1;
9969099869
pExpr->iColumn = -1;
9969199870
pExpr->affExpr = SQLITE_AFF_INTEGER;
9969299871
}
@@ -100294,13 +100473,16 @@
100294100473
pNC2 = pNC2->pNext;
100295100474
}
100296100475
assert( pDef!=0 || IN_RENAME_OBJECT );
100297100476
if( pNC2 && pDef ){
100298100477
assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
100478
+ assert( SQLITE_FUNC_ANYORDER==NC_OrderAgg );
100299100479
testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
100300
- pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);
100301
-
100480
+ testcase( (pDef->funcFlags & SQLITE_FUNC_ANYORDER)!=0 );
100481
+ pNC2->ncFlags |= NC_HasAgg
100482
+ | ((pDef->funcFlags^SQLITE_FUNC_ANYORDER)
100483
+ & (SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER));
100302100484
}
100303100485
}
100304100486
pNC->ncFlags |= savedAllowFlags;
100305100487
}
100306100488
/* FIX ME: Compute pExpr->affinity based on the expected return
@@ -100839,11 +101021,11 @@
100839101021
assert( pSub->pPrior && pSub->pOrderBy==0 );
100840101022
pSub->pOrderBy = p->pOrderBy;
100841101023
p->pOrderBy = 0;
100842101024
}
100843101025
100844
- /* Recursively resolve names in all subqueries
101026
+ /* Recursively resolve names in all subqueries in the FROM clause
100845101027
*/
100846101028
for(i=0; i<p->pSrc->nSrc; i++){
100847101029
SrcItem *pItem = &p->pSrc->a[i];
100848101030
if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){
100849101031
int nRef = pOuterNC ? pOuterNC->nRef : 0;
@@ -100883,11 +101065,12 @@
100883101065
*/
100884101066
assert( (p->selFlags & SF_Aggregate)==0 );
100885101067
pGroupBy = p->pGroupBy;
100886101068
if( pGroupBy || (sNC.ncFlags & NC_HasAgg)!=0 ){
100887101069
assert( NC_MinMaxAgg==SF_MinMaxAgg );
100888
- p->selFlags |= SF_Aggregate | (sNC.ncFlags&NC_MinMaxAgg);
101070
+ assert( NC_OrderAgg==SF_OrderByReqd );
101071
+ p->selFlags |= SF_Aggregate | (sNC.ncFlags&(NC_MinMaxAgg|NC_OrderAgg));
100889101072
}else{
100890101073
sNC.ncFlags &= ~NC_AllowAgg;
100891101074
}
100892101075
100893101076
/* Add the output column list to the name-context before parsing the
@@ -101066,12 +101249,12 @@
101066101249
){
101067101250
int savedHasAgg;
101068101251
Walker w;
101069101252
101070101253
if( pExpr==0 ) return SQLITE_OK;
101071
- savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101072
- pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101254
+ savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
101255
+ pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
101073101256
w.pParse = pNC->pParse;
101074101257
w.xExprCallback = resolveExprStep;
101075101258
w.xSelectCallback = (pNC->ncFlags & NC_NoSelect) ? 0 : resolveSelectStep;
101076101259
w.xSelectCallback2 = 0;
101077101260
w.u.pNC = pNC;
@@ -101110,12 +101293,12 @@
101110101293
w.pParse = pNC->pParse;
101111101294
w.xExprCallback = resolveExprStep;
101112101295
w.xSelectCallback = resolveSelectStep;
101113101296
w.xSelectCallback2 = 0;
101114101297
w.u.pNC = pNC;
101115
- savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101116
- pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101298
+ savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
101299
+ pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
101117101300
for(i=0; i<pList->nExpr; i++){
101118101301
Expr *pExpr = pList->a[i].pExpr;
101119101302
if( pExpr==0 ) continue;
101120101303
#if SQLITE_MAX_EXPR_DEPTH>0
101121101304
w.pParse->nHeight += pExpr->nHeight;
@@ -101129,14 +101312,15 @@
101129101312
#endif
101130101313
assert( EP_Agg==NC_HasAgg );
101131101314
assert( EP_Win==NC_HasWin );
101132101315
testcase( pNC->ncFlags & NC_HasAgg );
101133101316
testcase( pNC->ncFlags & NC_HasWin );
101134
- if( pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin) ){
101317
+ if( pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg) ){
101135101318
ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) );
101136
- savedHasAgg |= pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101137
- pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101319
+ savedHasAgg |= pNC->ncFlags &
101320
+ (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
101321
+ pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
101138101322
}
101139101323
if( w.pParse->nErr>0 ) return WRC_Abort;
101140101324
}
101141101325
pNC->ncFlags |= savedHasAgg;
101142101326
return WRC_Continue;
@@ -101296,10 +101480,12 @@
101296101480
return sqlite3AffinityType(pExpr->u.zToken, 0);
101297101481
}
101298101482
#endif
101299101483
if( op==TK_SELECT_COLUMN ){
101300101484
assert( pExpr->pLeft->flags&EP_xIsSelect );
101485
+ assert( pExpr->iColumn < pExpr->iTable );
101486
+ assert( pExpr->iTable==pExpr->pLeft->x.pSelect->pEList->nExpr );
101301101487
return sqlite3ExprAffinity(
101302101488
pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
101303101489
);
101304101490
}
101305101491
if( op==TK_VECTOR ){
@@ -101706,11 +101892,12 @@
101706101892
** of the returned TK_SELECT_COLUMN Expr object.
101707101893
*/
101708101894
SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(
101709101895
Parse *pParse, /* Parsing context */
101710101896
Expr *pVector, /* The vector. List of expressions or a sub-SELECT */
101711
- int iField /* Which column of the vector to return */
101897
+ int iField, /* Which column of the vector to return */
101898
+ int nField /* Total number of columns in the vector */
101712101899
){
101713101900
Expr *pRet;
101714101901
if( pVector->op==TK_SELECT ){
101715101902
assert( pVector->flags & EP_xIsSelect );
101716101903
/* The TK_SELECT_COLUMN Expr node:
@@ -101729,14 +101916,14 @@
101729101916
** with the same pLeft pointer to the pVector, but only one of them
101730101917
** will own the pVector.
101731101918
*/
101732101919
pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0);
101733101920
if( pRet ){
101921
+ pRet->iTable = nField;
101734101922
pRet->iColumn = iField;
101735101923
pRet->pLeft = pVector;
101736101924
}
101737
- assert( pRet==0 || pRet->iTable==0 );
101738101925
}else{
101739101926
if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;
101740101927
pRet = sqlite3ExprDup(pParse->db, pVector, 0);
101741101928
sqlite3RenameTokenRemap(pParse, pRet, pVector);
101742101929
}
@@ -102167,10 +102354,60 @@
102167102354
assert( pParse->db->mallocFailed );
102168102355
sqlite3SelectDelete(pParse->db, pSelect);
102169102356
}
102170102357
}
102171102358
102359
+/*
102360
+** Expression list pEList is a list of vector values. This function
102361
+** converts the contents of pEList to a VALUES(...) Select statement
102362
+** returning 1 row for each element of the list. For example, the
102363
+** expression list:
102364
+**
102365
+** ( (1,2), (3,4) (5,6) )
102366
+**
102367
+** is translated to the equivalent of:
102368
+**
102369
+** VALUES(1,2), (3,4), (5,6)
102370
+**
102371
+** Each of the vector values in pEList must contain exactly nElem terms.
102372
+** If a list element that is not a vector or does not contain nElem terms,
102373
+** an error message is left in pParse.
102374
+**
102375
+** This is used as part of processing IN(...) expressions with a list
102376
+** of vectors on the RHS. e.g. "... IN ((1,2), (3,4), (5,6))".
102377
+*/
102378
+SQLITE_PRIVATE Select *sqlite3ExprListToValues(Parse *pParse, int nElem, ExprList *pEList){
102379
+ int ii;
102380
+ Select *pRet = 0;
102381
+ assert( nElem>1 );
102382
+ for(ii=0; ii<pEList->nExpr; ii++){
102383
+ Select *pSel;
102384
+ Expr *pExpr = pEList->a[ii].pExpr;
102385
+ int nExprElem = (pExpr->op==TK_VECTOR ? pExpr->x.pList->nExpr : 1);
102386
+ if( nExprElem!=nElem ){
102387
+ sqlite3ErrorMsg(pParse, "IN(...) element has %d term%s - expected %d",
102388
+ nExprElem, nExprElem>1?"s":"", nElem
102389
+ );
102390
+ break;
102391
+ }
102392
+ pSel = sqlite3SelectNew(pParse, pExpr->x.pList, 0, 0, 0, 0, 0, SF_Values,0);
102393
+ pExpr->x.pList = 0;
102394
+ if( pSel ){
102395
+ if( pRet ){
102396
+ pSel->op = TK_ALL;
102397
+ pSel->pPrior = pRet;
102398
+ }
102399
+ pRet = pSel;
102400
+ }
102401
+ }
102402
+
102403
+ if( pRet && pRet->pPrior ){
102404
+ pRet->selFlags |= SF_MultiValue;
102405
+ }
102406
+ sqlite3ExprListDelete(pParse->db, pEList);
102407
+ return pRet;
102408
+}
102172102409
102173102410
/*
102174102411
** Join two expressions using an AND operator. If either expression is
102175102412
** NULL, then just return the other expression.
102176102413
**
@@ -102211,11 +102448,14 @@
102211102448
pNew = sqlite3ExprAlloc(db, TK_FUNCTION, pToken, 1);
102212102449
if( pNew==0 ){
102213102450
sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */
102214102451
return 0;
102215102452
}
102216
- if( pList && pList->nExpr > pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
102453
+ if( pList
102454
+ && pList->nExpr > pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG]
102455
+ && !pParse->nested
102456
+ ){
102217102457
sqlite3ErrorMsg(pParse, "too many arguments on function %T", pToken);
102218102458
}
102219102459
pNew->x.pList = pList;
102220102460
ExprSetProperty(pNew, EP_HasFunc);
102221102461
assert( !ExprHasProperty(pNew, EP_xIsSelect) );
@@ -102619,11 +102859,10 @@
102619102859
}
102620102860
}else{
102621102861
if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
102622102862
if( pNew->op==TK_SELECT_COLUMN ){
102623102863
pNew->pLeft = p->pLeft;
102624
- assert( p->iColumn==0 || p->pRight==0 );
102625102864
assert( p->pRight==0 || p->pRight==p->pLeft
102626102865
|| ExprHasProperty(p->pLeft, EP_Subquery) );
102627102866
}else{
102628102867
pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
102629102868
}
@@ -102717,11 +102956,12 @@
102717102956
}
102718102957
SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags){
102719102958
ExprList *pNew;
102720102959
struct ExprList_item *pItem, *pOldItem;
102721102960
int i;
102722
- Expr *pPriorSelectCol = 0;
102961
+ Expr *pPriorSelectColOld = 0;
102962
+ Expr *pPriorSelectColNew = 0;
102723102963
assert( db!=0 );
102724102964
if( p==0 ) return 0;
102725102965
pNew = sqlite3DbMallocRawNN(db, sqlite3DbMallocSize(db, p));
102726102966
if( pNew==0 ) return 0;
102727102967
pNew->nExpr = p->nExpr;
@@ -102734,21 +102974,21 @@
102734102974
pItem->pExpr = sqlite3ExprDup(db, pOldExpr, flags);
102735102975
if( pOldExpr
102736102976
&& pOldExpr->op==TK_SELECT_COLUMN
102737102977
&& (pNewExpr = pItem->pExpr)!=0
102738102978
){
102739
- assert( pNewExpr->iColumn==0 || i>0 );
102740
- if( pNewExpr->iColumn==0 ){
102741
- assert( pOldExpr->pLeft==pOldExpr->pRight
102742
- || ExprHasProperty(pOldExpr->pLeft, EP_Subquery) );
102743
- pPriorSelectCol = pNewExpr->pLeft = pNewExpr->pRight;
102979
+ if( pNewExpr->pRight ){
102980
+ pPriorSelectColOld = pOldExpr->pRight;
102981
+ pPriorSelectColNew = pNewExpr->pRight;
102982
+ pNewExpr->pLeft = pNewExpr->pRight;
102744102983
}else{
102745
- assert( i>0 );
102746
- assert( pItem[-1].pExpr!=0 );
102747
- assert( pNewExpr->iColumn==pItem[-1].pExpr->iColumn+1 );
102748
- assert( pPriorSelectCol==pItem[-1].pExpr->pLeft );
102749
- pNewExpr->pLeft = pPriorSelectCol;
102984
+ if( pOldExpr->pLeft!=pPriorSelectColOld ){
102985
+ pPriorSelectColOld = pOldExpr->pLeft;
102986
+ pPriorSelectColNew = sqlite3ExprDup(db, pPriorSelectColOld, flags);
102987
+ pNewExpr->pRight = pPriorSelectColNew;
102988
+ }
102989
+ pNewExpr->pLeft = pPriorSelectColNew;
102750102990
}
102751102991
}
102752102992
pItem->zEName = sqlite3DbStrDup(db, pOldItem->zEName);
102753102993
pItem->sortFlags = pOldItem->sortFlags;
102754102994
pItem->eEName = pOldItem->eEName;
@@ -103003,15 +103243,13 @@
103003103243
pColumns->nId, n);
103004103244
goto vector_append_error;
103005103245
}
103006103246
103007103247
for(i=0; i<pColumns->nId; i++){
103008
- Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i);
103248
+ Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i, pColumns->nId);
103009103249
assert( pSubExpr!=0 || db->mallocFailed );
103010
- assert( pSubExpr==0 || pSubExpr->iTable==0 );
103011103250
if( pSubExpr==0 ) continue;
103012
- pSubExpr->iTable = pColumns->nId;
103013103251
pList = sqlite3ExprListAppend(pParse, pList, pSubExpr);
103014103252
if( pList ){
103015103253
assert( pList->nExpr==iFirst+i+1 );
103016103254
pList->a[pList->nExpr-1].zEName = pColumns->a[i].zName;
103017103255
pColumns->a[i].zName = 0;
@@ -105597,15 +105835,13 @@
105597105835
case TK_SELECT_COLUMN: {
105598105836
int n;
105599105837
if( pExpr->pLeft->iTable==0 ){
105600105838
pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft);
105601105839
}
105602
- assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT
105603
- || pExpr->pLeft->op==TK_ERROR );
105604
- if( pExpr->iTable!=0
105605
- && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft))
105606
- ){
105840
+ assert( pExpr->pLeft->op==TK_SELECT || pExpr->pLeft->op==TK_ERROR );
105841
+ n = sqlite3ExprVectorSize(pExpr->pLeft);
105842
+ if( pExpr->iTable!=n ){
105607105843
sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
105608105844
pExpr->iTable, n);
105609105845
}
105610105846
return pExpr->pLeft->iTable + pExpr->iColumn;
105611105847
}
@@ -107827,28 +108063,43 @@
107827108063
);
107828108064
sqlite3DbFree(db, zCol);
107829108065
db->mDbFlags = savedDbFlags;
107830108066
}
107831108067
107832
- /* Make sure the schema version is at least 3. But do not upgrade
107833
- ** from less than 3 to 4, as that will corrupt any preexisting DESC
107834
- ** index.
107835
- */
107836108068
v = sqlite3GetVdbe(pParse);
107837108069
if( v ){
108070
+ /* Make sure the schema version is at least 3. But do not upgrade
108071
+ ** from less than 3 to 4, as that will corrupt any preexisting DESC
108072
+ ** index.
108073
+ */
107838108074
r1 = sqlite3GetTempReg(pParse);
107839108075
sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);
107840108076
sqlite3VdbeUsesBtree(v, iDb);
107841108077
sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2);
107842108078
sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2);
107843108079
VdbeCoverage(v);
107844108080
sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3);
107845108081
sqlite3ReleaseTempReg(pParse, r1);
108082
+
108083
+ /* Reload the table definition */
108084
+ renameReloadSchema(pParse, iDb, INITFLAG_AlterRename);
108085
+
108086
+ /* Verify that constraints are still satisfied */
108087
+ if( pNew->pCheck!=0
108088
+ || (pCol->notNull && (pCol->colFlags & COLFLAG_GENERATED)!=0)
108089
+ ){
108090
+ sqlite3NestedParse(pParse,
108091
+ "SELECT CASE WHEN quick_check GLOB 'CHECK*'"
108092
+ " THEN raise(ABORT,'CHECK constraint failed')"
108093
+ " ELSE raise(ABORT,'NOT NULL constraint failed')"
108094
+ " END"
108095
+ " FROM pragma_quick_check(\"%w\",\"%w\")"
108096
+ " WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*'",
108097
+ zTab, zDb
108098
+ );
108099
+ }
107846108100
}
107847
-
107848
- /* Reload the table definition */
107849
- renameReloadSchema(pParse, iDb, INITFLAG_AlterRename);
107850108101
}
107851108102
107852108103
/*
107853108104
** This function is called by the parser after the table-name in
107854108105
** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
@@ -112865,10 +113116,11 @@
112865113116
Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
112866113117
if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
112867113118
pMod = sqlite3PragmaVtabRegister(db, zName);
112868113119
}
112869113120
if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
113121
+ testcase( pMod->pEpoTab==0 );
112870113122
return pMod->pEpoTab;
112871113123
}
112872113124
}
112873113125
#endif
112874113126
if( flags & LOCATE_NOERR ) return 0;
@@ -115592,10 +115844,11 @@
115592115844
SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db){
115593115845
#ifndef SQLITE_OMIT_VIRTUALTABLE
115594115846
if( (db->flags & SQLITE_Defensive)!=0
115595115847
&& db->pVtabCtx==0
115596115848
&& db->nVdbeExec==0
115849
+ && !sqlite3VtabInSync(db)
115597115850
){
115598115851
return 1;
115599115852
}
115600115853
#endif
115601115854
return 0;
@@ -119884,37 +120137,37 @@
119884120137
119885120138
/*
119886120139
** Implementation of the changes() SQL function.
119887120140
**
119888120141
** IMP: R-62073-11209 The changes() SQL function is a wrapper
119889
-** around the sqlite3_changes() C/C++ function and hence follows the same
120142
+** around the sqlite3_changes64() C/C++ function and hence follows the same
119890120143
** rules for counting changes.
119891120144
*/
119892120145
static void changes(
119893120146
sqlite3_context *context,
119894120147
int NotUsed,
119895120148
sqlite3_value **NotUsed2
119896120149
){
119897120150
sqlite3 *db = sqlite3_context_db_handle(context);
119898120151
UNUSED_PARAMETER2(NotUsed, NotUsed2);
119899
- sqlite3_result_int(context, sqlite3_changes(db));
120152
+ sqlite3_result_int64(context, sqlite3_changes64(db));
119900120153
}
119901120154
119902120155
/*
119903120156
** Implementation of the total_changes() SQL function. The return value is
119904
-** the same as the sqlite3_total_changes() API function.
120157
+** the same as the sqlite3_total_changes64() API function.
119905120158
*/
119906120159
static void total_changes(
119907120160
sqlite3_context *context,
119908120161
int NotUsed,
119909120162
sqlite3_value **NotUsed2
119910120163
){
119911120164
sqlite3 *db = sqlite3_context_db_handle(context);
119912120165
UNUSED_PARAMETER2(NotUsed, NotUsed2);
119913
- /* IMP: R-52756-41993 This function is a wrapper around the
120166
+ /* IMP: R-52756-41993 This function was a wrapper around the
119914120167
** sqlite3_total_changes() C/C++ interface. */
119915
- sqlite3_result_int(context, sqlite3_total_changes(db));
120168
+ sqlite3_result_int64(context, sqlite3_total_changes64(db));
119916120169
}
119917120170
119918120171
/*
119919120172
** A structure defining how to do GLOB-style comparisons.
119920120173
*/
@@ -121472,15 +121725,15 @@
121472121725
FUNCTION(trim, 1, 3, 0, trimFunc ),
121473121726
FUNCTION(trim, 2, 3, 0, trimFunc ),
121474121727
FUNCTION(min, -1, 0, 1, minmaxFunc ),
121475121728
FUNCTION(min, 0, 0, 1, 0 ),
121476121729
WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
121477
- SQLITE_FUNC_MINMAX ),
121730
+ SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
121478121731
FUNCTION(max, -1, 1, 1, minmaxFunc ),
121479121732
FUNCTION(max, 0, 1, 1, 0 ),
121480121733
WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
121481
- SQLITE_FUNC_MINMAX ),
121734
+ SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
121482121735
FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
121483121736
FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
121484121737
FUNCTION(instr, 2, 0, 0, instrFunc ),
121485121738
FUNCTION(printf, -1, 0, 0, printfFunc ),
121486121739
FUNCTION(unicode, 1, 0, 0, unicodeFunc ),
@@ -121512,13 +121765,14 @@
121512121765
FUNCTION(substring, 3, 0, 0, substrFunc ),
121513121766
WAGGREGATE(sum, 1,0,0, sumStep, sumFinalize, sumFinalize, sumInverse, 0),
121514121767
WAGGREGATE(total, 1,0,0, sumStep,totalFinalize,totalFinalize,sumInverse, 0),
121515121768
WAGGREGATE(avg, 1,0,0, sumStep, avgFinalize, avgFinalize, sumInverse, 0),
121516121769
WAGGREGATE(count, 0,0,0, countStep,
121517
- countFinalize, countFinalize, countInverse, SQLITE_FUNC_COUNT ),
121770
+ countFinalize, countFinalize, countInverse,
121771
+ SQLITE_FUNC_COUNT|SQLITE_FUNC_ANYORDER ),
121518121772
WAGGREGATE(count, 1,0,0, countStep,
121519
- countFinalize, countFinalize, countInverse, 0 ),
121773
+ countFinalize, countFinalize, countInverse, SQLITE_FUNC_ANYORDER ),
121520121774
WAGGREGATE(group_concat, 1, 0, 0, groupConcatStep,
121521121775
groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
121522121776
WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep,
121523121777
groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
121524121778
@@ -123169,11 +123423,11 @@
123169123423
123170123424
/*
123171123425
** Compute the affinity string for table pTab, if it has not already been
123172123426
** computed. As an optimization, omit trailing SQLITE_AFF_BLOB affinities.
123173123427
**
123174
-** If the affinity exists (if it is no entirely SQLITE_AFF_BLOB values) and
123428
+** If the affinity exists (if it is not entirely SQLITE_AFF_BLOB values) and
123175123429
** if iReg>0 then code an OP_Affinity opcode that will set the affinities
123176123430
** for register iReg and following. Or if affinities exists and iReg==0,
123177123431
** then just set the P4 operand of the previous opcode (which should be
123178123432
** an OP_MakeRecord) to the affinity string.
123179123433
**
@@ -126622,10 +126876,13 @@
126622126876
int,const char**);
126623126877
void (*free_filename)(char*);
126624126878
sqlite3_file *(*database_file_object)(const char*);
126625126879
/* Version 3.34.0 and later */
126626126880
int (*txn_state)(sqlite3*,const char*);
126881
+ /* Version 3.36.1 and later */
126882
+ sqlite3_int64 (*changes64)(sqlite3*);
126883
+ sqlite3_int64 (*total_changes64)(sqlite3*);
126627126884
};
126628126885
126629126886
/*
126630126887
** This is the function signature used for all extension entry points. It
126631126888
** is also defined in the file "loadext.c".
@@ -127412,10 +127669,13 @@
127412127669
sqlite3_create_filename,
127413127670
sqlite3_free_filename,
127414127671
sqlite3_database_file_object,
127415127672
/* Version 3.34.0 and later */
127416127673
sqlite3_txn_state,
127674
+ /* Version 3.36.1 and later */
127675
+ sqlite3_changes64,
127676
+ sqlite3_total_changes64,
127417127677
};
127418127678
127419127679
/* True if x is the directory separator character
127420127680
*/
127421127681
#if SQLITE_OS_WIN
@@ -128201,11 +128461,11 @@
128201128461
/* iArg: */ 1 },
128202128462
#endif
128203128463
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
128204128464
{/* zName: */ "integrity_check",
128205128465
/* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
128206
- /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1,
128466
+ /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1|PragFlg_SchemaOpt,
128207128467
/* ColNames: */ 0, 0,
128208128468
/* iArg: */ 0 },
128209128469
#endif
128210128470
#if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
128211128471
{/* zName: */ "journal_mode",
@@ -128309,11 +128569,11 @@
128309128569
/* iArg: */ SQLITE_QueryOnly },
128310128570
#endif
128311128571
#if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
128312128572
{/* zName: */ "quick_check",
128313128573
/* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
128314
- /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1,
128574
+ /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1|PragFlg_SchemaOpt,
128315128575
/* ColNames: */ 0, 0,
128316128576
/* iArg: */ 0 },
128317128577
#endif
128318128578
#if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
128319128579
{/* zName: */ "read_uncommitted",
@@ -129912,10 +130172,11 @@
129912130172
129913130173
/* Generate code to read the child key values into registers
129914130174
** regRow..regRow+n. If any of the child key values are NULL, this
129915130175
** row cannot cause an FK violation. Jump directly to addrOk in
129916130176
** this case. */
130177
+ if( regRow+pFK->nCol>pParse->nMem ) pParse->nMem = regRow+pFK->nCol;
129917130178
for(j=0; j<pFK->nCol; j++){
129918130179
int iCol = aiCols ? aiCols[j] : pFK->aCol[j].iFrom;
129919130180
sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, iCol, regRow+j);
129920130181
sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); VdbeCoverage(v);
129921130182
}
@@ -135823,14 +136084,14 @@
135823136084
/*
135824136085
** Assign new cursor numbers to each of the items in pSrc. For each
135825136086
** new cursor number assigned, set an entry in the aCsrMap[] array
135826136087
** to map the old cursor number to the new:
135827136088
**
135828
-** aCsrMap[iOld] = iNew;
136089
+** aCsrMap[iOld+1] = iNew;
135829136090
**
135830136091
** The array is guaranteed by the caller to be large enough for all
135831
-** existing cursor numbers in pSrc.
136092
+** existing cursor numbers in pSrc. aCsrMap[0] is the array size.
135832136093
**
135833136094
** If pSrc contains any sub-selects, call this routine recursively
135834136095
** on the FROM clause of each such sub-select, with iExcept set to -1.
135835136096
*/
135836136097
static void srclistRenumberCursors(
@@ -135842,33 +136103,44 @@
135842136103
int i;
135843136104
SrcItem *pItem;
135844136105
for(i=0, pItem=pSrc->a; i<pSrc->nSrc; i++, pItem++){
135845136106
if( i!=iExcept ){
135846136107
Select *p;
135847
- if( !pItem->fg.isRecursive || aCsrMap[pItem->iCursor]==0 ){
135848
- aCsrMap[pItem->iCursor] = pParse->nTab++;
136108
+ assert( pItem->iCursor < aCsrMap[0] );
136109
+ if( !pItem->fg.isRecursive || aCsrMap[pItem->iCursor+1]==0 ){
136110
+ aCsrMap[pItem->iCursor+1] = pParse->nTab++;
135849136111
}
135850
- pItem->iCursor = aCsrMap[pItem->iCursor];
136112
+ pItem->iCursor = aCsrMap[pItem->iCursor+1];
135851136113
for(p=pItem->pSelect; p; p=p->pPrior){
135852136114
srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1);
135853136115
}
135854136116
}
135855136117
}
135856136118
}
136119
+
136120
+/*
136121
+** *piCursor is a cursor number. Change it if it needs to be mapped.
136122
+*/
136123
+static void renumberCursorDoMapping(Walker *pWalker, int *piCursor){
136124
+ int *aCsrMap = pWalker->u.aiCol;
136125
+ int iCsr = *piCursor;
136126
+ if( iCsr < aCsrMap[0] && aCsrMap[iCsr+1]>0 ){
136127
+ *piCursor = aCsrMap[iCsr+1];
136128
+ }
136129
+}
135857136130
135858136131
/*
135859136132
** Expression walker callback used by renumberCursors() to update
135860136133
** Expr objects to match newly assigned cursor numbers.
135861136134
*/
135862136135
static int renumberCursorsCb(Walker *pWalker, Expr *pExpr){
135863
- int *aCsrMap = pWalker->u.aiCol;
135864136136
int op = pExpr->op;
135865
- if( (op==TK_COLUMN || op==TK_IF_NULL_ROW) && aCsrMap[pExpr->iTable] ){
135866
- pExpr->iTable = aCsrMap[pExpr->iTable];
136137
+ if( op==TK_COLUMN || op==TK_IF_NULL_ROW ){
136138
+ renumberCursorDoMapping(pWalker, &pExpr->iTable);
135867136139
}
135868
- if( ExprHasProperty(pExpr, EP_FromJoin) && aCsrMap[pExpr->iRightJoinTable] ){
135869
- pExpr->iRightJoinTable = aCsrMap[pExpr->iRightJoinTable];
136140
+ if( ExprHasProperty(pExpr, EP_FromJoin) ){
136141
+ renumberCursorDoMapping(pWalker, &pExpr->iRightJoinTable);
135870136142
}
135871136143
return WRC_Continue;
135872136144
}
135873136145
135874136146
/*
@@ -136208,11 +136480,12 @@
136208136480
/* Restriction (23) */
136209136481
if( (p->selFlags & SF_Recursive) ) return 0;
136210136482
136211136483
if( pSrc->nSrc>1 ){
136212136484
if( pParse->nSelect>500 ) return 0;
136213
- aCsrMap = sqlite3DbMallocZero(db, pParse->nTab*sizeof(int));
136485
+ aCsrMap = sqlite3DbMallocZero(db, (pParse->nTab+1)*sizeof(int));
136486
+ if( aCsrMap ) aCsrMap[0] = pParse->nTab;
136214136487
}
136215136488
}
136216136489
136217136490
/***** If we reach this point, flattening is permitted. *****/
136218136491
SELECTTRACE(1,pParse,p,("flatten %u.%p from term %d\n",
@@ -138088,12 +138361,20 @@
138088138361
** within the HAVING expression with a constant "1".
138089138362
*/
138090138363
static int havingToWhereExprCb(Walker *pWalker, Expr *pExpr){
138091138364
if( pExpr->op!=TK_AND ){
138092138365
Select *pS = pWalker->u.pSelect;
138366
+ /* This routine is called before the HAVING clause of the current
138367
+ ** SELECT is analyzed for aggregates. So if pExpr->pAggInfo is set
138368
+ ** here, it indicates that the expression is a correlated reference to a
138369
+ ** column from an outer aggregate query, or an aggregate function that
138370
+ ** belongs to an outer query. Do not move the expression to the WHERE
138371
+ ** clause in this obscure case, as doing so may corrupt the outer Select
138372
+ ** statements AggInfo structure. */
138093138373
if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, pS->pGroupBy)
138094138374
&& ExprAlwaysFalse(pExpr)==0
138375
+ && pExpr->pAggInfo==0
138095138376
){
138096138377
sqlite3 *db = pWalker->pParse->db;
138097138378
Expr *pNew = sqlite3Expr(db, TK_INTEGER, "1");
138098138379
if( pNew ){
138099138380
Expr *pWhere = pS->pWhere;
@@ -138355,15 +138636,20 @@
138355138636
SELECTTRACE(0x104,pParse,p, ("after name resolution:\n"));
138356138637
sqlite3TreeViewSelect(0, p, 0);
138357138638
}
138358138639
#endif
138359138640
138360
- /* If the SF_UpdateFrom flag is set, then this function is being called
138641
+ /* If the SF_UFSrcCheck flag is set, then this function is being called
138361138642
** as part of populating the temp table for an UPDATE...FROM statement.
138362138643
** In this case, it is an error if the target object (pSrc->a[0]) name
138363
- ** or alias is duplicated within FROM clause (pSrc->a[1..n]). */
138364
- if( p->selFlags & SF_UpdateFrom ){
138644
+ ** or alias is duplicated within FROM clause (pSrc->a[1..n]).
138645
+ **
138646
+ ** Postgres disallows this case too. The reason is that some other
138647
+ ** systems handle this case differently, and not all the same way,
138648
+ ** which is just confusing. To avoid this, we follow PG's lead and
138649
+ ** disallow it altogether. */
138650
+ if( p->selFlags & SF_UFSrcCheck ){
138365138651
SrcItem *p0 = &p->pSrc->a[0];
138366138652
for(i=1; i<p->pSrc->nSrc; i++){
138367138653
SrcItem *p1 = &p->pSrc->a[i];
138368138654
if( p0->pTab==p1->pTab && 0==sqlite3_stricmp(p0->zAlias, p1->zAlias) ){
138369138655
sqlite3ErrorMsg(pParse,
@@ -138371,10 +138657,16 @@
138371138657
p0->zAlias ? p0->zAlias : p0->pTab->zName
138372138658
);
138373138659
goto select_end;
138374138660
}
138375138661
}
138662
+
138663
+ /* Clear the SF_UFSrcCheck flag. The check has already been performed,
138664
+ ** and leaving this flag set can cause errors if a compound sub-query
138665
+ ** in p->pSrc is flattened into this query and this function called
138666
+ ** again as part of compound SELECT processing. */
138667
+ p->selFlags &= ~SF_UFSrcCheck;
138376138668
}
138377138669
138378138670
if( pDest->eDest==SRT_Output ){
138379138671
sqlite3GenerateColumnNames(pParse, p);
138380138672
}
@@ -138441,10 +138733,43 @@
138441138733
** will be implemented as a co-routine and there is no advantage to
138442138734
** flattening in that case.
138443138735
*/
138444138736
if( (pSub->selFlags & SF_Aggregate)!=0 ) continue;
138445138737
assert( pSub->pGroupBy==0 );
138738
+
138739
+ /* If a FROM-clause subquery has an ORDER BY clause that is not
138740
+ ** really doing anything, then delete it now so that it does not
138741
+ ** interfere with query flattening. See the discussion at
138742
+ ** https://sqlite.org/forum/forumpost/2d76f2bcf65d256a
138743
+ **
138744
+ ** Beware of these cases where the ORDER BY clause may not be safely
138745
+ ** omitted:
138746
+ **
138747
+ ** (1) There is also a LIMIT clause
138748
+ ** (2) The subquery was added to help with window-function
138749
+ ** processing
138750
+ ** (3) The subquery is in the FROM clause of an UPDATE
138751
+ ** (4) The outer query uses an aggregate function other than
138752
+ ** the built-in count(), min(), or max().
138753
+ ** (5) The ORDER BY isn't going to accomplish anything because
138754
+ ** one of:
138755
+ ** (a) The outer query has a different ORDER BY clause
138756
+ ** (b) The subquery is part of a join
138757
+ ** See forum post 062d576715d277c8
138758
+ */
138759
+ if( pSub->pOrderBy!=0
138760
+ && (p->pOrderBy!=0 || pTabList->nSrc>1) /* Condition (5) */
138761
+ && pSub->pLimit==0 /* Condition (1) */
138762
+ && (pSub->selFlags & SF_OrderByReqd)==0 /* Condition (2) */
138763
+ && (p->selFlags & SF_OrderByReqd)==0 /* Condition (3) and (4) */
138764
+ && OptimizationEnabled(db, SQLITE_OmitOrderBy)
138765
+ ){
138766
+ SELECTTRACE(0x100,pParse,p,
138767
+ ("omit superfluous ORDER BY on %r FROM-clause subquery\n",i+1));
138768
+ sqlite3ExprListDelete(db, pSub->pOrderBy);
138769
+ pSub->pOrderBy = 0;
138770
+ }
138446138771
138447138772
/* If the outer query contains a "complex" result set (that is,
138448138773
** if the result set of the outer query uses functions or subqueries)
138449138774
** and if the subquery contains an ORDER BY clause and if
138450138775
** it will be implemented as a co-routine, then do not flatten. This
@@ -140596,10 +140921,11 @@
140596140921
memset(&sFrom, 0, sizeof(sFrom));
140597140922
sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0);
140598140923
sSelect.pSrc = &sFrom;
140599140924
sFrom.nSrc = 1;
140600140925
sFrom.a[0].pTab = pTab;
140926
+ sFrom.a[0].iCursor = -1;
140601140927
sqlite3SelectPrep(pParse, &sSelect, 0);
140602140928
if( db->mallocFailed==0 && pParse->nErr==0 ){
140603140929
sqlite3GenerateColumnNames(pParse, &sSelect);
140604140930
}
140605140931
sqlite3ExprListDelete(db, sSelect.pEList);
@@ -141350,12 +141676,13 @@
141350141676
sqlite3ExprDup(db, pChanges->a[i].pExpr, 0)
141351141677
);
141352141678
}
141353141679
}
141354141680
pSelect = sqlite3SelectNew(pParse, pList,
141355
- pSrc, pWhere2, pGrp, 0, pOrderBy2, SF_UpdateFrom|SF_IncludeHidden, pLimit2
141681
+ pSrc, pWhere2, pGrp, 0, pOrderBy2, SF_UFSrcCheck|SF_IncludeHidden, pLimit2
141356141682
);
141683
+ if( pSelect ) pSelect->selFlags |= SF_OrderByReqd;
141357141684
sqlite3SelectDestInit(&dest, eDest, iEph);
141358141685
dest.iSDParm2 = (pPk ? pPk->nKeyCol : -1);
141359141686
sqlite3Select(pParse, pSelect, &dest);
141360141687
sqlite3SelectDelete(db, pSelect);
141361141688
}
@@ -142891,12 +143218,12 @@
142891143218
int rc = SQLITE_OK; /* Return code from service routines */
142892143219
Btree *pMain; /* The database being vacuumed */
142893143220
Btree *pTemp; /* The temporary database we vacuum into */
142894143221
u32 saved_mDbFlags; /* Saved value of db->mDbFlags */
142895143222
u64 saved_flags; /* Saved value of db->flags */
142896
- int saved_nChange; /* Saved value of db->nChange */
142897
- int saved_nTotalChange; /* Saved value of db->nTotalChange */
143223
+ i64 saved_nChange; /* Saved value of db->nChange */
143224
+ i64 saved_nTotalChange; /* Saved value of db->nTotalChange */
142898143225
u32 saved_openFlags; /* Saved value of db->openFlags */
142899143226
u8 saved_mTrace; /* Saved trace settings */
142900143227
Db *pDb = 0; /* Database to detach at end of vacuum */
142901143228
int isMemDb; /* True if vacuuming a :memory: database */
142902143229
int nRes; /* Bytes of reserved space at the end of each page */
@@ -144337,12 +144664,13 @@
144337144664
}
144338144665
144339144666
/*
144340144667
** Check to see if virtual table module pMod can be have an eponymous
144341144668
** virtual table instance. If it can, create one if one does not already
144342
-** exist. Return non-zero if the eponymous virtual table instance exists
144343
-** when this routine returns, and return zero if it does not exist.
144669
+** exist. Return non-zero if either the eponymous virtual table instance
144670
+** exists when this routine returns or if an attempt to create it failed
144671
+** and an error message was left in pParse.
144344144672
**
144345144673
** An eponymous virtual table instance is one that is named after its
144346144674
** module, and more importantly, does not require a CREATE VIRTUAL TABLE
144347144675
** statement in order to come into existance. Eponymous virtual table
144348144676
** instances always exist. They cannot be DROP-ed.
@@ -144377,11 +144705,10 @@
144377144705
rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr);
144378144706
if( rc ){
144379144707
sqlite3ErrorMsg(pParse, "%s", zErr);
144380144708
sqlite3DbFree(db, zErr);
144381144709
sqlite3VtabEponymousTableClear(db, pMod);
144382
- return 0;
144383144710
}
144384144711
return 1;
144385144712
}
144386144713
144387144714
/*
@@ -148940,12 +149267,12 @@
148940149267
){
148941149268
int i;
148942149269
for(i=0; i<nLeft; i++){
148943149270
int idxNew;
148944149271
Expr *pNew;
148945
- Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);
148946
- Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);
149272
+ Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i, nLeft);
149273
+ Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i, nLeft);
148947149274
148948149275
pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);
148949149276
transferJoinMarkings(pNew, pExpr);
148950149277
idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
148951149278
exprAnalyze(pSrc, pWC, idxNew);
@@ -154753,10 +155080,16 @@
154753155080
sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iTabCur);
154754155081
}
154755155082
if( (ws & WHERE_INDEXED)
154756155083
|| ((ws & WHERE_MULTI_OR) && pLevel->u.pCovidx)
154757155084
){
155085
+ if( ws & WHERE_MULTI_OR ){
155086
+ Index *pIx = pLevel->u.pCovidx;
155087
+ int iDb = sqlite3SchemaToIndex(db, pIx->pSchema);
155088
+ sqlite3VdbeAddOp3(v, OP_ReopenIdx, pLevel->iIdxCur, pIx->tnum, iDb);
155089
+ sqlite3VdbeSetP4KeyInfo(pParse, pIx);
155090
+ }
154758155091
sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);
154759155092
}
154760155093
if( pLevel->op==OP_Return ){
154761155094
sqlite3VdbeAddOp2(v, OP_Gosub, pLevel->p1, pLevel->addrFirst);
154762155095
}else{
@@ -155817,13 +156150,11 @@
155817156150
break;
155818156151
}
155819156152
if( bIntToNull ){
155820156153
int iDummy;
155821156154
Expr *pSub;
155822
- for(pSub=pDup; ExprHasProperty(pSub, EP_Skip); pSub=pSub->pLeft){
155823
- assert( pSub );
155824
- }
156155
+ pSub = sqlite3ExprSkipCollateAndLikely(pDup);
155825156156
if( sqlite3ExprIsInteger(pSub, &iDummy) ){
155826156157
pSub->op = TK_NULL;
155827156158
pSub->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse);
155828156159
pSub->u.zToken = 0;
155829156160
}
@@ -155981,11 +156312,11 @@
155981156312
p->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
155982156313
if( p->pSrc ){
155983156314
Table *pTab2;
155984156315
p->pSrc->a[0].pSelect = pSub;
155985156316
sqlite3SrcListAssignCursors(pParse, p->pSrc);
155986
- pSub->selFlags |= SF_Expanded;
156317
+ pSub->selFlags |= SF_Expanded|SF_OrderByReqd;
155987156318
pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE);
155988156319
pSub->selFlags |= (selFlags & SF_Aggregate);
155989156320
if( pTab2==0 ){
155990156321
/* Might actually be some other kind of error, but in that case
155991156322
** pParse->nErr will be set, so if SQLITE_NOMEM is set, we will get
@@ -162431,24 +162762,32 @@
162431162762
** simplify to constants 0 (false) and 1 (true), respectively,
162432162763
** regardless of the value of expr1.
162433162764
*/
162434162765
sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy404);
162435162766
yymsp[-4].minor.yy404 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy376 ? "1" : "0");
162436
- }else if( yymsp[-1].minor.yy70->nExpr==1 && sqlite3ExprIsConstant(yymsp[-1].minor.yy70->a[0].pExpr) ){
162767
+ }else{
162437162768
Expr *pRHS = yymsp[-1].minor.yy70->a[0].pExpr;
162438
- yymsp[-1].minor.yy70->a[0].pExpr = 0;
162439
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70);
162440
- pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
162441
- yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy404, pRHS);
162442
- if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
162443
- }else{
162444
- yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0);
162445
- if( yymsp[-4].minor.yy404 ){
162446
- yymsp[-4].minor.yy404->x.pList = yymsp[-1].minor.yy70;
162447
- sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy404);
162448
- }else{
162449
- sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70);
162769
+ if( yymsp[-1].minor.yy70->nExpr==1 && sqlite3ExprIsConstant(pRHS) && yymsp[-4].minor.yy404->op!=TK_VECTOR ){
162770
+ yymsp[-1].minor.yy70->a[0].pExpr = 0;
162771
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70);
162772
+ pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
162773
+ yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy404, pRHS);
162774
+ }else{
162775
+ yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0);
162776
+ if( yymsp[-4].minor.yy404==0 ){
162777
+ sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70);
162778
+ }else if( yymsp[-4].minor.yy404->pLeft->op==TK_VECTOR ){
162779
+ int nExpr = yymsp[-4].minor.yy404->pLeft->x.pList->nExpr;
162780
+ Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy70);
162781
+ if( pSelectRHS ){
162782
+ parserDoubleLinkSelect(pParse, pSelectRHS);
162783
+ sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy404, pSelectRHS);
162784
+ }
162785
+ }else{
162786
+ yymsp[-4].minor.yy404->x.pList = yymsp[-1].minor.yy70;
162787
+ sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy404);
162788
+ }
162450162789
}
162451162790
if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
162452162791
}
162453162792
}
162454162793
break;
@@ -166163,31 +166502,37 @@
166163166502
}
166164166503
166165166504
/*
166166166505
** Return the number of changes in the most recent call to sqlite3_exec().
166167166506
*/
166168
-SQLITE_API int sqlite3_changes(sqlite3 *db){
166507
+SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3 *db){
166169166508
#ifdef SQLITE_ENABLE_API_ARMOR
166170166509
if( !sqlite3SafetyCheckOk(db) ){
166171166510
(void)SQLITE_MISUSE_BKPT;
166172166511
return 0;
166173166512
}
166174166513
#endif
166175166514
return db->nChange;
166176166515
}
166516
+SQLITE_API int sqlite3_changes(sqlite3 *db){
166517
+ return (int)sqlite3_changes64(db);
166518
+}
166177166519
166178166520
/*
166179166521
** Return the number of changes since the database handle was opened.
166180166522
*/
166181
-SQLITE_API int sqlite3_total_changes(sqlite3 *db){
166523
+SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3 *db){
166182166524
#ifdef SQLITE_ENABLE_API_ARMOR
166183166525
if( !sqlite3SafetyCheckOk(db) ){
166184166526
(void)SQLITE_MISUSE_BKPT;
166185166527
return 0;
166186166528
}
166187166529
#endif
166188166530
return db->nTotalChange;
166531
+}
166532
+SQLITE_API int sqlite3_total_changes(sqlite3 *db){
166533
+ return (int)sqlite3_total_changes64(db);
166189166534
}
166190166535
166191166536
/*
166192166537
** Close all open savepoints. This function only manipulates fields of the
166193166538
** database handle object, it does not close any savepoints that may be open
@@ -166925,26 +167270,37 @@
166925167270
** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.
166926167271
**
166927167272
** If SQLITE_ANY is specified, add three versions of the function
166928167273
** to the hash table.
166929167274
*/
166930
- if( enc==SQLITE_UTF16 ){
166931
- enc = SQLITE_UTF16NATIVE;
166932
- }else if( enc==SQLITE_ANY ){
166933
- int rc;
166934
- rc = sqlite3CreateFunc(db, zFunctionName, nArg,
166935
- (SQLITE_UTF8|extraFlags)^SQLITE_FUNC_UNSAFE,
166936
- pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
166937
- if( rc==SQLITE_OK ){
166938
- rc = sqlite3CreateFunc(db, zFunctionName, nArg,
166939
- (SQLITE_UTF16LE|extraFlags)^SQLITE_FUNC_UNSAFE,
166940
- pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
166941
- }
166942
- if( rc!=SQLITE_OK ){
166943
- return rc;
166944
- }
166945
- enc = SQLITE_UTF16BE;
167275
+ switch( enc ){
167276
+ case SQLITE_UTF16:
167277
+ enc = SQLITE_UTF16NATIVE;
167278
+ break;
167279
+ case SQLITE_ANY: {
167280
+ int rc;
167281
+ rc = sqlite3CreateFunc(db, zFunctionName, nArg,
167282
+ (SQLITE_UTF8|extraFlags)^SQLITE_FUNC_UNSAFE,
167283
+ pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
167284
+ if( rc==SQLITE_OK ){
167285
+ rc = sqlite3CreateFunc(db, zFunctionName, nArg,
167286
+ (SQLITE_UTF16LE|extraFlags)^SQLITE_FUNC_UNSAFE,
167287
+ pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
167288
+ }
167289
+ if( rc!=SQLITE_OK ){
167290
+ return rc;
167291
+ }
167292
+ enc = SQLITE_UTF16BE;
167293
+ break;
167294
+ }
167295
+ case SQLITE_UTF8:
167296
+ case SQLITE_UTF16LE:
167297
+ case SQLITE_UTF16BE:
167298
+ break;
167299
+ default:
167300
+ enc = SQLITE_UTF8;
167301
+ break;
166946167302
}
166947167303
#else
166948167304
enc = SQLITE_UTF8;
166949167305
#endif
166950167306
@@ -167037,11 +167393,11 @@
167037167393
}
167038167394
rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p,
167039167395
xSFunc, xStep, xFinal, xValue, xInverse, pArg
167040167396
);
167041167397
if( pArg && pArg->nRef==0 ){
167042
- assert( rc!=SQLITE_OK );
167398
+ assert( rc!=SQLITE_OK || (xStep==0 && xFinal==0) );
167043167399
xDestroy(p);
167044167400
sqlite3_free(pArg);
167045167401
}
167046167402
167047167403
out:
@@ -168220,11 +168576,10 @@
168220168576
** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE,
168221168577
** SQLITE_OPEN_PRIVATECACHE, and some reserved bits. Silently mask
168222168578
** off all other flags.
168223168579
*/
168224168580
flags &= ~( SQLITE_OPEN_DELETEONCLOSE |
168225
- SQLITE_OPEN_EXCLUSIVE |
168226168581
SQLITE_OPEN_MAIN_DB |
168227168582
SQLITE_OPEN_TEMP_DB |
168228168583
SQLITE_OPEN_TRANSIENT_DB |
168229168584
SQLITE_OPEN_MAIN_JOURNAL |
168230168585
SQLITE_OPEN_TEMP_JOURNAL |
@@ -213440,10 +213795,13 @@
213440213795
/*
213441213796
** This interface is used by the fts5vocab module.
213442213797
*/
213443213798
static const char *sqlite3Fts5IterTerm(Fts5IndexIter*, int*);
213444213799
static int sqlite3Fts5IterNextScan(Fts5IndexIter*);
213800
+static void *sqlite3Fts5StructureRef(Fts5Index*);
213801
+static void sqlite3Fts5StructureRelease(void*);
213802
+static int sqlite3Fts5StructureTest(Fts5Index*, void*);
213445213803
213446213804
213447213805
/*
213448213806
** Insert or remove data to or from the index. Each time a document is
213449213807
** added to or removed from the index, this function is called one or more
@@ -216235,20 +216593,21 @@
216235216593
/* EOF */
216236216594
*piOff = -1;
216237216595
return 1;
216238216596
}else{
216239216597
i64 iOff = *piOff;
216240
- int iVal;
216598
+ u32 iVal;
216241216599
fts5FastGetVarint32(a, i, iVal);
216242216600
assert( iVal>=0 );
216243216601
if( iVal<=1 ){
216244216602
if( iVal==0 ){
216245216603
*pi = i;
216246216604
return 0;
216247216605
}
216248216606
fts5FastGetVarint32(a, i, iVal);
216249216607
iOff = ((i64)iVal) << 32;
216608
+ assert( iOff>=0 );
216250216609
fts5FastGetVarint32(a, i, iVal);
216251216610
if( iVal<2 ){
216252216611
/* This is a corrupt record. So stop parsing it here. */
216253216612
*piOff = -1;
216254216613
return 1;
@@ -216256,11 +216615,11 @@
216256216615
*piOff = iOff + ((iVal-2) & 0x7FFFFFFF);
216257216616
}else{
216258216617
*piOff = (iOff & (i64)0x7FFFFFFF<<32)+((iOff + (iVal-2)) & 0x7FFFFFFF);
216259216618
}
216260216619
*pi = i;
216261
- assert( *piOff>=iOff );
216620
+ assert_nc( *piOff>=iOff );
216262216621
return 0;
216263216622
}
216264216623
}
216265216624
216266216625
@@ -217565,10 +217924,11 @@
217565217924
217566217925
static void sqlite3Fts5ParseError(Fts5Parse *pParse, const char *zFmt, ...){
217567217926
va_list ap;
217568217927
va_start(ap, zFmt);
217569217928
if( pParse->rc==SQLITE_OK ){
217929
+ assert( pParse->zErr==0 );
217570217930
pParse->zErr = sqlite3_vmprintf(zFmt, ap);
217571217931
pParse->rc = SQLITE_ERROR;
217572217932
}
217573217933
va_end(ap);
217574217934
}
@@ -219574,13 +219934,12 @@
219574219934
Fts5ExprNode *pExpr,
219575219935
Fts5Colset *pColset
219576219936
){
219577219937
Fts5Colset *pFree = pColset;
219578219938
if( pParse->pConfig->eDetail==FTS5_DETAIL_NONE ){
219579
- pParse->rc = SQLITE_ERROR;
219580
- pParse->zErr = sqlite3_mprintf(
219581
- "fts5: column queries are not supported (detail=none)"
219939
+ sqlite3Fts5ParseError(pParse,
219940
+ "fts5: column queries are not supported (detail=none)"
219582219941
);
219583219942
}else{
219584219943
fts5ParseSetColset(pParse, pExpr, pColset, &pFree);
219585219944
}
219586219945
sqlite3_free(pFree);
@@ -219750,17 +220109,14 @@
219750220109
Fts5ExprPhrase *pPhrase = pNear->apPhrase[0];
219751220110
if( pNear->nPhrase!=1
219752220111
|| pPhrase->nTerm>1
219753220112
|| (pPhrase->nTerm>0 && pPhrase->aTerm[0].bFirst)
219754220113
){
219755
- assert( pParse->rc==SQLITE_OK );
219756
- pParse->rc = SQLITE_ERROR;
219757
- assert( pParse->zErr==0 );
219758
- pParse->zErr = sqlite3_mprintf(
220114
+ sqlite3Fts5ParseError(pParse,
219759220115
"fts5: %s queries are not supported (detail!=full)",
219760220116
pNear->nPhrase==1 ? "phrase": "NEAR"
219761
- );
220117
+ );
219762220118
sqlite3_free(pRet);
219763220119
pRet = 0;
219764220120
}
219765220121
}
219766220122
}else{
@@ -221873,10 +222229,26 @@
221873222229
}
221874222230
221875222231
static void fts5StructureRef(Fts5Structure *pStruct){
221876222232
pStruct->nRef++;
221877222233
}
222234
+
222235
+static void *sqlite3Fts5StructureRef(Fts5Index *p){
222236
+ fts5StructureRef(p->pStruct);
222237
+ return (void*)p->pStruct;
222238
+}
222239
+static void sqlite3Fts5StructureRelease(void *p){
222240
+ if( p ){
222241
+ fts5StructureRelease((Fts5Structure*)p);
222242
+ }
222243
+}
222244
+static int sqlite3Fts5StructureTest(Fts5Index *p, void *pStruct){
222245
+ if( p->pStruct!=(Fts5Structure*)pStruct ){
222246
+ return SQLITE_ABORT;
222247
+ }
222248
+ return SQLITE_OK;
222249
+}
221878222250
221879222251
/*
221880222252
** Deserialize and return the structure record currently stored in serialized
221881222253
** form within buffer pData/nData.
221882222254
**
@@ -230580,11 +230952,11 @@
230580230952
int nArg, /* Number of args */
230581230953
sqlite3_value **apUnused /* Function arguments */
230582230954
){
230583230955
assert( nArg==0 );
230584230956
UNUSED_PARAM2(nArg, apUnused);
230585
- sqlite3_result_text(pCtx, "fts5: 2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5", -1, SQLITE_TRANSIENT);
230957
+ sqlite3_result_text(pCtx, "fts5: 2021-07-20 14:57:49 1e35cc6d5c2f563c6bb163bb150d7bc6ede4c993efa828af1face3261bf65a2c", -1, SQLITE_TRANSIENT);
230586230958
}
230587230959
230588230960
/*
230589230961
** Return true if zName is the extension on one of the shadow tables used
230590230962
** by this module.
@@ -234476,10 +234848,11 @@
234476234848
sqlite3_stmt *pStmt; /* Statement holding lock on pIndex */
234477234849
Fts5Table *pFts5; /* Associated FTS5 table */
234478234850
234479234851
int bEof; /* True if this cursor is at EOF */
234480234852
Fts5IndexIter *pIter; /* Term/rowid iterator object */
234853
+ void *pStruct; /* From sqlite3Fts5StructureRef() */
234481234854
234482234855
int nLeTerm; /* Size of zLeTerm in bytes */
234483234856
char *zLeTerm; /* (term <= $zLeTerm) paramater, or NULL */
234484234857
234485234858
/* These are used by 'col' tables only */
@@ -234809,10 +235182,12 @@
234809235182
}
234810235183
234811235184
static void fts5VocabResetCursor(Fts5VocabCursor *pCsr){
234812235185
pCsr->rowid = 0;
234813235186
sqlite3Fts5IterClose(pCsr->pIter);
235187
+ sqlite3Fts5StructureRelease(pCsr->pStruct);
235188
+ pCsr->pStruct = 0;
234814235189
pCsr->pIter = 0;
234815235190
sqlite3_free(pCsr->zLeTerm);
234816235191
pCsr->nLeTerm = -1;
234817235192
pCsr->zLeTerm = 0;
234818235193
pCsr->bEof = 0;
@@ -234886,13 +235261,15 @@
234886235261
** Advance the cursor to the next row in the table.
234887235262
*/
234888235263
static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
234889235264
Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;
234890235265
Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab;
234891
- int rc = SQLITE_OK;
234892235266
int nCol = pCsr->pFts5->pConfig->nCol;
235267
+ int rc;
234893235268
235269
+ rc = sqlite3Fts5StructureTest(pCsr->pFts5->pIndex, pCsr->pStruct);
235270
+ if( rc!=SQLITE_OK ) return rc;
234894235271
pCsr->rowid++;
234895235272
234896235273
if( pTab->eType==FTS5_VOCAB_INSTANCE ){
234897235274
return fts5VocabInstanceNext(pCsr);
234898235275
}
@@ -235062,10 +235439,13 @@
235062235439
}
235063235440
235064235441
if( rc==SQLITE_OK ){
235065235442
Fts5Index *pIndex = pCsr->pFts5->pIndex;
235066235443
rc = sqlite3Fts5IndexQuery(pIndex, zTerm, nTerm, f, 0, &pCsr->pIter);
235444
+ if( rc==SQLITE_OK ){
235445
+ pCsr->pStruct = sqlite3Fts5StructureRef(pIndex);
235446
+ }
235067235447
}
235068235448
if( rc==SQLITE_OK && eType==FTS5_VOCAB_INSTANCE ){
235069235449
rc = fts5VocabInstanceNewTerm(pCsr);
235070235450
}
235071235451
if( rc==SQLITE_OK && !pCsr->bEof
@@ -235506,12 +235886,8 @@
235506235886
}
235507235887
#endif /* SQLITE_CORE */
235508235888
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
235509235889
235510235890
/************** End of stmt.c ************************************************/
235511
-#if __LINE__!=235511
235512
-#undef SQLITE_SOURCE_ID
235513
-#define SQLITE_SOURCE_ID "2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafaalt2"
235514
-#endif
235515235891
/* Return the source-id for this library */
235516235892
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
235517235893
/************************** End of sqlite3.c ******************************/
235518235894
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.36.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -20,797 +20,10 @@
20 #define SQLITE_CORE 1
21 #define SQLITE_AMALGAMATION 1
22 #ifndef SQLITE_PRIVATE
23 # define SQLITE_PRIVATE static
24 #endif
25 /************** Begin file ctime.c *******************************************/
26 /*
27 ** 2010 February 23
28 **
29 ** The author disclaims copyright to this source code. In place of
30 ** a legal notice, here is a blessing:
31 **
32 ** May you do good and not evil.
33 ** May you find forgiveness for yourself and forgive others.
34 ** May you share freely, never taking more than you give.
35 **
36 *************************************************************************
37 **
38 ** This file implements routines used to report what compile-time options
39 ** SQLite was built with.
40 */
41
42 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS /* IMP: R-16824-07538 */
43
44 /*
45 ** Include the configuration header output by 'configure' if we're using the
46 ** autoconf-based build
47 */
48 #if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
49 #include "config.h"
50 #define SQLITECONFIG_H 1
51 #endif
52
53 /* These macros are provided to "stringify" the value of the define
54 ** for those options in which the value is meaningful. */
55 #define CTIMEOPT_VAL_(opt) #opt
56 #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
57
58 /* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This
59 ** option requires a separate macro because legal values contain a single
60 ** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE="100,100") */
61 #define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
62 #define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)
63
64 /*
65 ** An array of names of all compile-time options. This array should
66 ** be sorted A-Z.
67 **
68 ** This array looks large, but in a typical installation actually uses
69 ** only a handful of compile-time options, so most times this array is usually
70 ** rather short and uses little memory space.
71 */
72 static const char * const sqlite3azCompileOpt[] = {
73
74 /*
75 ** BEGIN CODE GENERATED BY tool/mkctime.tcl
76 */
77 #if SQLITE_32BIT_ROWID
78 "32BIT_ROWID",
79 #endif
80 #if SQLITE_4_BYTE_ALIGNED_MALLOC
81 "4_BYTE_ALIGNED_MALLOC",
82 #endif
83 #if SQLITE_64BIT_STATS
84 "64BIT_STATS",
85 #endif
86 #ifdef SQLITE_ALLOW_COVERING_INDEX_SCAN
87 # if SQLITE_ALLOW_COVERING_INDEX_SCAN != 1
88 "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN),
89 # endif
90 #endif
91 #if SQLITE_ALLOW_URI_AUTHORITY
92 "ALLOW_URI_AUTHORITY",
93 #endif
94 #ifdef SQLITE_BITMASK_TYPE
95 "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),
96 #endif
97 #if SQLITE_BUG_COMPATIBLE_20160819
98 "BUG_COMPATIBLE_20160819",
99 #endif
100 #if SQLITE_CASE_SENSITIVE_LIKE
101 "CASE_SENSITIVE_LIKE",
102 #endif
103 #if SQLITE_CHECK_PAGES
104 "CHECK_PAGES",
105 #endif
106 #if defined(__clang__) && defined(__clang_major__)
107 "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
108 CTIMEOPT_VAL(__clang_minor__) "."
109 CTIMEOPT_VAL(__clang_patchlevel__),
110 #elif defined(_MSC_VER)
111 "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
112 #elif defined(__GNUC__) && defined(__VERSION__)
113 "COMPILER=gcc-" __VERSION__,
114 #endif
115 #if SQLITE_COVERAGE_TEST
116 "COVERAGE_TEST",
117 #endif
118 #if SQLITE_DEBUG
119 "DEBUG",
120 #endif
121 #if SQLITE_DEFAULT_AUTOMATIC_INDEX
122 "DEFAULT_AUTOMATIC_INDEX",
123 #endif
124 #if SQLITE_DEFAULT_AUTOVACUUM
125 "DEFAULT_AUTOVACUUM",
126 #endif
127 #ifdef SQLITE_DEFAULT_CACHE_SIZE
128 "DEFAULT_CACHE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE),
129 #endif
130 #if SQLITE_DEFAULT_CKPTFULLFSYNC
131 "DEFAULT_CKPTFULLFSYNC",
132 #endif
133 #ifdef SQLITE_DEFAULT_FILE_FORMAT
134 "DEFAULT_FILE_FORMAT=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT),
135 #endif
136 #ifdef SQLITE_DEFAULT_FILE_PERMISSIONS
137 "DEFAULT_FILE_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS),
138 #endif
139 #if SQLITE_DEFAULT_FOREIGN_KEYS
140 "DEFAULT_FOREIGN_KEYS",
141 #endif
142 #ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
143 "DEFAULT_JOURNAL_SIZE_LIMIT=" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT),
144 #endif
145 #ifdef SQLITE_DEFAULT_LOCKING_MODE
146 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
147 #endif
148 #ifdef SQLITE_DEFAULT_LOOKASIDE
149 "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE),
150 #endif
151 #ifdef SQLITE_DEFAULT_MEMSTATUS
152 # if SQLITE_DEFAULT_MEMSTATUS != 1
153 "DEFAULT_MEMSTATUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_MEMSTATUS),
154 # endif
155 #endif
156 #ifdef SQLITE_DEFAULT_MMAP_SIZE
157 "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
158 #endif
159 #ifdef SQLITE_DEFAULT_PAGE_SIZE
160 "DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE),
161 #endif
162 #ifdef SQLITE_DEFAULT_PCACHE_INITSZ
163 "DEFAULT_PCACHE_INITSZ=" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ),
164 #endif
165 #ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS
166 "DEFAULT_PROXYDIR_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS),
167 #endif
168 #if SQLITE_DEFAULT_RECURSIVE_TRIGGERS
169 "DEFAULT_RECURSIVE_TRIGGERS",
170 #endif
171 #ifdef SQLITE_DEFAULT_ROWEST
172 "DEFAULT_ROWEST=" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST),
173 #endif
174 #ifdef SQLITE_DEFAULT_SECTOR_SIZE
175 "DEFAULT_SECTOR_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE),
176 #endif
177 #ifdef SQLITE_DEFAULT_SYNCHRONOUS
178 "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),
179 #endif
180 #ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
181 "DEFAULT_WAL_AUTOCHECKPOINT=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT),
182 #endif
183 #ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS
184 "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),
185 #endif
186 #ifdef SQLITE_DEFAULT_WORKER_THREADS
187 "DEFAULT_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS),
188 #endif
189 #if SQLITE_DIRECT_OVERFLOW_READ
190 "DIRECT_OVERFLOW_READ",
191 #endif
192 #if SQLITE_DISABLE_DIRSYNC
193 "DISABLE_DIRSYNC",
194 #endif
195 #if SQLITE_DISABLE_FTS3_UNICODE
196 "DISABLE_FTS3_UNICODE",
197 #endif
198 #if SQLITE_DISABLE_FTS4_DEFERRED
199 "DISABLE_FTS4_DEFERRED",
200 #endif
201 #if SQLITE_DISABLE_INTRINSIC
202 "DISABLE_INTRINSIC",
203 #endif
204 #if SQLITE_DISABLE_LFS
205 "DISABLE_LFS",
206 #endif
207 #if SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
208 "DISABLE_PAGECACHE_OVERFLOW_STATS",
209 #endif
210 #if SQLITE_DISABLE_SKIPAHEAD_DISTINCT
211 "DISABLE_SKIPAHEAD_DISTINCT",
212 #endif
213 #ifdef SQLITE_ENABLE_8_3_NAMES
214 "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
215 #endif
216 #if SQLITE_ENABLE_API_ARMOR
217 "ENABLE_API_ARMOR",
218 #endif
219 #if SQLITE_ENABLE_ATOMIC_WRITE
220 "ENABLE_ATOMIC_WRITE",
221 #endif
222 #if SQLITE_ENABLE_BATCH_ATOMIC_WRITE
223 "ENABLE_BATCH_ATOMIC_WRITE",
224 #endif
225 #if SQLITE_ENABLE_BYTECODE_VTAB
226 "ENABLE_BYTECODE_VTAB",
227 #endif
228 #ifdef SQLITE_ENABLE_CEROD
229 "ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD),
230 #endif
231 #if SQLITE_ENABLE_COLUMN_METADATA
232 "ENABLE_COLUMN_METADATA",
233 #endif
234 #if SQLITE_ENABLE_COLUMN_USED_MASK
235 "ENABLE_COLUMN_USED_MASK",
236 #endif
237 #if SQLITE_ENABLE_COSTMULT
238 "ENABLE_COSTMULT",
239 #endif
240 #if SQLITE_ENABLE_CURSOR_HINTS
241 "ENABLE_CURSOR_HINTS",
242 #endif
243 #if SQLITE_ENABLE_DBPAGE_VTAB
244 "ENABLE_DBPAGE_VTAB",
245 #endif
246 #if SQLITE_ENABLE_DBSTAT_VTAB
247 "ENABLE_DBSTAT_VTAB",
248 #endif
249 #if SQLITE_ENABLE_EXPENSIVE_ASSERT
250 "ENABLE_EXPENSIVE_ASSERT",
251 #endif
252 #if SQLITE_ENABLE_EXPLAIN_COMMENTS
253 "ENABLE_EXPLAIN_COMMENTS",
254 #endif
255 #if SQLITE_ENABLE_FTS3
256 "ENABLE_FTS3",
257 #endif
258 #if SQLITE_ENABLE_FTS3_PARENTHESIS
259 "ENABLE_FTS3_PARENTHESIS",
260 #endif
261 #if SQLITE_ENABLE_FTS3_TOKENIZER
262 "ENABLE_FTS3_TOKENIZER",
263 #endif
264 #if SQLITE_ENABLE_FTS4
265 "ENABLE_FTS4",
266 #endif
267 #if SQLITE_ENABLE_FTS5
268 "ENABLE_FTS5",
269 #endif
270 #if SQLITE_ENABLE_GEOPOLY
271 "ENABLE_GEOPOLY",
272 #endif
273 #if SQLITE_ENABLE_HIDDEN_COLUMNS
274 "ENABLE_HIDDEN_COLUMNS",
275 #endif
276 #if SQLITE_ENABLE_ICU
277 "ENABLE_ICU",
278 #endif
279 #if SQLITE_ENABLE_IOTRACE
280 "ENABLE_IOTRACE",
281 #endif
282 #if SQLITE_ENABLE_JSON1
283 "ENABLE_JSON1",
284 #endif
285 #if SQLITE_ENABLE_LOAD_EXTENSION
286 "ENABLE_LOAD_EXTENSION",
287 #endif
288 #ifdef SQLITE_ENABLE_LOCKING_STYLE
289 "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
290 #endif
291 #if SQLITE_ENABLE_MATH_FUNCTIONS
292 "ENABLE_MATH_FUNCTIONS",
293 #endif
294 #if SQLITE_ENABLE_MEMORY_MANAGEMENT
295 "ENABLE_MEMORY_MANAGEMENT",
296 #endif
297 #if SQLITE_ENABLE_MEMSYS3
298 "ENABLE_MEMSYS3",
299 #endif
300 #if SQLITE_ENABLE_MEMSYS5
301 "ENABLE_MEMSYS5",
302 #endif
303 #if SQLITE_ENABLE_MULTIPLEX
304 "ENABLE_MULTIPLEX",
305 #endif
306 #if SQLITE_ENABLE_NORMALIZE
307 "ENABLE_NORMALIZE",
308 #endif
309 #if SQLITE_ENABLE_NULL_TRIM
310 "ENABLE_NULL_TRIM",
311 #endif
312 #if SQLITE_ENABLE_OFFSET_SQL_FUNC
313 "ENABLE_OFFSET_SQL_FUNC",
314 #endif
315 #if SQLITE_ENABLE_OVERSIZE_CELL_CHECK
316 "ENABLE_OVERSIZE_CELL_CHECK",
317 #endif
318 #if SQLITE_ENABLE_PREUPDATE_HOOK
319 "ENABLE_PREUPDATE_HOOK",
320 #endif
321 #if SQLITE_ENABLE_QPSG
322 "ENABLE_QPSG",
323 #endif
324 #if SQLITE_ENABLE_RBU
325 "ENABLE_RBU",
326 #endif
327 #if SQLITE_ENABLE_RTREE
328 "ENABLE_RTREE",
329 #endif
330 #if SQLITE_ENABLE_SELECTTRACE
331 "ENABLE_SELECTTRACE",
332 #endif
333 #if SQLITE_ENABLE_SESSION
334 "ENABLE_SESSION",
335 #endif
336 #if SQLITE_ENABLE_SNAPSHOT
337 "ENABLE_SNAPSHOT",
338 #endif
339 #if SQLITE_ENABLE_SORTER_REFERENCES
340 "ENABLE_SORTER_REFERENCES",
341 #endif
342 #if SQLITE_ENABLE_SQLLOG
343 "ENABLE_SQLLOG",
344 #endif
345 #if SQLITE_ENABLE_STAT4
346 "ENABLE_STAT4",
347 #endif
348 #if SQLITE_ENABLE_STMTVTAB
349 "ENABLE_STMTVTAB",
350 #endif
351 #if SQLITE_ENABLE_STMT_SCANSTATUS
352 "ENABLE_STMT_SCANSTATUS",
353 #endif
354 #if SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
355 "ENABLE_UNKNOWN_SQL_FUNCTION",
356 #endif
357 #if SQLITE_ENABLE_UNLOCK_NOTIFY
358 "ENABLE_UNLOCK_NOTIFY",
359 #endif
360 #if SQLITE_ENABLE_UPDATE_DELETE_LIMIT
361 "ENABLE_UPDATE_DELETE_LIMIT",
362 #endif
363 #if SQLITE_ENABLE_URI_00_ERROR
364 "ENABLE_URI_00_ERROR",
365 #endif
366 #if SQLITE_ENABLE_VFSTRACE
367 "ENABLE_VFSTRACE",
368 #endif
369 #if SQLITE_ENABLE_WHERETRACE
370 "ENABLE_WHERETRACE",
371 #endif
372 #if SQLITE_ENABLE_ZIPVFS
373 "ENABLE_ZIPVFS",
374 #endif
375 #if SQLITE_EXPLAIN_ESTIMATED_ROWS
376 "EXPLAIN_ESTIMATED_ROWS",
377 #endif
378 #if SQLITE_EXTRA_IFNULLROW
379 "EXTRA_IFNULLROW",
380 #endif
381 #ifdef SQLITE_EXTRA_INIT
382 "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT),
383 #endif
384 #ifdef SQLITE_EXTRA_SHUTDOWN
385 "EXTRA_SHUTDOWN=" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN),
386 #endif
387 #ifdef SQLITE_FTS3_MAX_EXPR_DEPTH
388 "FTS3_MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH),
389 #endif
390 #if SQLITE_FTS5_ENABLE_TEST_MI
391 "FTS5_ENABLE_TEST_MI",
392 #endif
393 #if SQLITE_FTS5_NO_WITHOUT_ROWID
394 "FTS5_NO_WITHOUT_ROWID",
395 #endif
396 #if HAVE_ISNAN || SQLITE_HAVE_ISNAN
397 "HAVE_ISNAN",
398 #endif
399 #ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
400 # if SQLITE_HOMEGROWN_RECURSIVE_MUTEX != 1
401 "HOMEGROWN_RECURSIVE_MUTEX=" CTIMEOPT_VAL(SQLITE_HOMEGROWN_RECURSIVE_MUTEX),
402 # endif
403 #endif
404 #if SQLITE_IGNORE_AFP_LOCK_ERRORS
405 "IGNORE_AFP_LOCK_ERRORS",
406 #endif
407 #if SQLITE_IGNORE_FLOCK_LOCK_ERRORS
408 "IGNORE_FLOCK_LOCK_ERRORS",
409 #endif
410 #if SQLITE_INLINE_MEMCPY
411 "INLINE_MEMCPY",
412 #endif
413 #if SQLITE_INT64_TYPE
414 "INT64_TYPE",
415 #endif
416 #ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX
417 "INTEGRITY_CHECK_ERROR_MAX=" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX),
418 #endif
419 #if SQLITE_LIKE_DOESNT_MATCH_BLOBS
420 "LIKE_DOESNT_MATCH_BLOBS",
421 #endif
422 #if SQLITE_LOCK_TRACE
423 "LOCK_TRACE",
424 #endif
425 #if SQLITE_LOG_CACHE_SPILL
426 "LOG_CACHE_SPILL",
427 #endif
428 #ifdef SQLITE_MALLOC_SOFT_LIMIT
429 "MALLOC_SOFT_LIMIT=" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT),
430 #endif
431 #ifdef SQLITE_MAX_ATTACHED
432 "MAX_ATTACHED=" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED),
433 #endif
434 #ifdef SQLITE_MAX_COLUMN
435 "MAX_COLUMN=" CTIMEOPT_VAL(SQLITE_MAX_COLUMN),
436 #endif
437 #ifdef SQLITE_MAX_COMPOUND_SELECT
438 "MAX_COMPOUND_SELECT=" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT),
439 #endif
440 #ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE
441 "MAX_DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE),
442 #endif
443 #ifdef SQLITE_MAX_EXPR_DEPTH
444 "MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH),
445 #endif
446 #ifdef SQLITE_MAX_FUNCTION_ARG
447 "MAX_FUNCTION_ARG=" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG),
448 #endif
449 #ifdef SQLITE_MAX_LENGTH
450 "MAX_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LENGTH),
451 #endif
452 #ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH
453 "MAX_LIKE_PATTERN_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH),
454 #endif
455 #ifdef SQLITE_MAX_MEMORY
456 "MAX_MEMORY=" CTIMEOPT_VAL(SQLITE_MAX_MEMORY),
457 #endif
458 #ifdef SQLITE_MAX_MMAP_SIZE
459 "MAX_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),
460 #endif
461 #ifdef SQLITE_MAX_MMAP_SIZE_
462 "MAX_MMAP_SIZE_=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_),
463 #endif
464 #ifdef SQLITE_MAX_PAGE_COUNT
465 "MAX_PAGE_COUNT=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT),
466 #endif
467 #ifdef SQLITE_MAX_PAGE_SIZE
468 "MAX_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE),
469 #endif
470 #ifdef SQLITE_MAX_SCHEMA_RETRY
471 "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
472 #endif
473 #ifdef SQLITE_MAX_SQL_LENGTH
474 "MAX_SQL_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH),
475 #endif
476 #ifdef SQLITE_MAX_TRIGGER_DEPTH
477 "MAX_TRIGGER_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH),
478 #endif
479 #ifdef SQLITE_MAX_VARIABLE_NUMBER
480 "MAX_VARIABLE_NUMBER=" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER),
481 #endif
482 #ifdef SQLITE_MAX_VDBE_OP
483 "MAX_VDBE_OP=" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP),
484 #endif
485 #ifdef SQLITE_MAX_WORKER_THREADS
486 "MAX_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS),
487 #endif
488 #if SQLITE_MEMDEBUG
489 "MEMDEBUG",
490 #endif
491 #if SQLITE_MIXED_ENDIAN_64BIT_FLOAT
492 "MIXED_ENDIAN_64BIT_FLOAT",
493 #endif
494 #if SQLITE_MMAP_READWRITE
495 "MMAP_READWRITE",
496 #endif
497 #if SQLITE_MUTEX_NOOP
498 "MUTEX_NOOP",
499 #endif
500 #if SQLITE_MUTEX_OMIT
501 "MUTEX_OMIT",
502 #endif
503 #if SQLITE_MUTEX_PTHREADS
504 "MUTEX_PTHREADS",
505 #endif
506 #if SQLITE_MUTEX_W32
507 "MUTEX_W32",
508 #endif
509 #if SQLITE_NEED_ERR_NAME
510 "NEED_ERR_NAME",
511 #endif
512 #if SQLITE_NOINLINE
513 "NOINLINE",
514 #endif
515 #if SQLITE_NO_SYNC
516 "NO_SYNC",
517 #endif
518 #if SQLITE_OMIT_ALTERTABLE
519 "OMIT_ALTERTABLE",
520 #endif
521 #if SQLITE_OMIT_ANALYZE
522 "OMIT_ANALYZE",
523 #endif
524 #if SQLITE_OMIT_ATTACH
525 "OMIT_ATTACH",
526 #endif
527 #if SQLITE_OMIT_AUTHORIZATION
528 "OMIT_AUTHORIZATION",
529 #endif
530 #if SQLITE_OMIT_AUTOINCREMENT
531 "OMIT_AUTOINCREMENT",
532 #endif
533 #if SQLITE_OMIT_AUTOINIT
534 "OMIT_AUTOINIT",
535 #endif
536 #if SQLITE_OMIT_AUTOMATIC_INDEX
537 "OMIT_AUTOMATIC_INDEX",
538 #endif
539 #if SQLITE_OMIT_AUTORESET
540 "OMIT_AUTORESET",
541 #endif
542 #if SQLITE_OMIT_AUTOVACUUM
543 "OMIT_AUTOVACUUM",
544 #endif
545 #if SQLITE_OMIT_BETWEEN_OPTIMIZATION
546 "OMIT_BETWEEN_OPTIMIZATION",
547 #endif
548 #if SQLITE_OMIT_BLOB_LITERAL
549 "OMIT_BLOB_LITERAL",
550 #endif
551 #if SQLITE_OMIT_CAST
552 "OMIT_CAST",
553 #endif
554 #if SQLITE_OMIT_CHECK
555 "OMIT_CHECK",
556 #endif
557 #if SQLITE_OMIT_COMPLETE
558 "OMIT_COMPLETE",
559 #endif
560 #if SQLITE_OMIT_COMPOUND_SELECT
561 "OMIT_COMPOUND_SELECT",
562 #endif
563 #if SQLITE_OMIT_CONFLICT_CLAUSE
564 "OMIT_CONFLICT_CLAUSE",
565 #endif
566 #if SQLITE_OMIT_CTE
567 "OMIT_CTE",
568 #endif
569 #if defined(SQLITE_OMIT_DATETIME_FUNCS) || defined(SQLITE_OMIT_FLOATING_POINT)
570 "OMIT_DATETIME_FUNCS",
571 #endif
572 #if SQLITE_OMIT_DECLTYPE
573 "OMIT_DECLTYPE",
574 #endif
575 #if SQLITE_OMIT_DEPRECATED
576 "OMIT_DEPRECATED",
577 #endif
578 #if SQLITE_OMIT_DESERIALIZE
579 "OMIT_DESERIALIZE",
580 #endif
581 #if SQLITE_OMIT_DISKIO
582 "OMIT_DISKIO",
583 #endif
584 #if SQLITE_OMIT_EXPLAIN
585 "OMIT_EXPLAIN",
586 #endif
587 #if SQLITE_OMIT_FLAG_PRAGMAS
588 "OMIT_FLAG_PRAGMAS",
589 #endif
590 #if SQLITE_OMIT_FLOATING_POINT
591 "OMIT_FLOATING_POINT",
592 #endif
593 #if SQLITE_OMIT_FOREIGN_KEY
594 "OMIT_FOREIGN_KEY",
595 #endif
596 #if SQLITE_OMIT_GET_TABLE
597 "OMIT_GET_TABLE",
598 #endif
599 #if SQLITE_OMIT_HEX_INTEGER
600 "OMIT_HEX_INTEGER",
601 #endif
602 #if SQLITE_OMIT_INCRBLOB
603 "OMIT_INCRBLOB",
604 #endif
605 #if SQLITE_OMIT_INTEGRITY_CHECK
606 "OMIT_INTEGRITY_CHECK",
607 #endif
608 #if SQLITE_OMIT_INTROSPECTION_PRAGMAS
609 "OMIT_INTROSPECTION_PRAGMAS",
610 #endif
611 #if SQLITE_OMIT_LIKE_OPTIMIZATION
612 "OMIT_LIKE_OPTIMIZATION",
613 #endif
614 #if SQLITE_OMIT_LOAD_EXTENSION
615 "OMIT_LOAD_EXTENSION",
616 #endif
617 #if SQLITE_OMIT_LOCALTIME
618 "OMIT_LOCALTIME",
619 #endif
620 #if SQLITE_OMIT_LOOKASIDE
621 "OMIT_LOOKASIDE",
622 #endif
623 #if SQLITE_OMIT_MEMORYDB
624 "OMIT_MEMORYDB",
625 #endif
626 #if SQLITE_OMIT_OR_OPTIMIZATION
627 "OMIT_OR_OPTIMIZATION",
628 #endif
629 #if SQLITE_OMIT_PAGER_PRAGMAS
630 "OMIT_PAGER_PRAGMAS",
631 #endif
632 #if SQLITE_OMIT_PARSER_TRACE
633 "OMIT_PARSER_TRACE",
634 #endif
635 #if SQLITE_OMIT_POPEN
636 "OMIT_POPEN",
637 #endif
638 #if SQLITE_OMIT_PRAGMA
639 "OMIT_PRAGMA",
640 #endif
641 #if SQLITE_OMIT_PROGRESS_CALLBACK
642 "OMIT_PROGRESS_CALLBACK",
643 #endif
644 #if SQLITE_OMIT_QUICKBALANCE
645 "OMIT_QUICKBALANCE",
646 #endif
647 #if SQLITE_OMIT_REINDEX
648 "OMIT_REINDEX",
649 #endif
650 #if SQLITE_OMIT_SCHEMA_PRAGMAS
651 "OMIT_SCHEMA_PRAGMAS",
652 #endif
653 #if SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
654 "OMIT_SCHEMA_VERSION_PRAGMAS",
655 #endif
656 #if SQLITE_OMIT_SHARED_CACHE
657 "OMIT_SHARED_CACHE",
658 #endif
659 #if SQLITE_OMIT_SHUTDOWN_DIRECTORIES
660 "OMIT_SHUTDOWN_DIRECTORIES",
661 #endif
662 #if SQLITE_OMIT_SUBQUERY
663 "OMIT_SUBQUERY",
664 #endif
665 #if SQLITE_OMIT_TCL_VARIABLE
666 "OMIT_TCL_VARIABLE",
667 #endif
668 #if SQLITE_OMIT_TEMPDB
669 "OMIT_TEMPDB",
670 #endif
671 #if SQLITE_OMIT_TEST_CONTROL
672 "OMIT_TEST_CONTROL",
673 #endif
674 #ifdef SQLITE_OMIT_TRACE
675 # if SQLITE_OMIT_TRACE != 1
676 "OMIT_TRACE=" CTIMEOPT_VAL(SQLITE_OMIT_TRACE),
677 # endif
678 #endif
679 #if SQLITE_OMIT_TRIGGER
680 "OMIT_TRIGGER",
681 #endif
682 #if SQLITE_OMIT_TRUNCATE_OPTIMIZATION
683 "OMIT_TRUNCATE_OPTIMIZATION",
684 #endif
685 #if SQLITE_OMIT_UTF16
686 "OMIT_UTF16",
687 #endif
688 #if SQLITE_OMIT_VACUUM
689 "OMIT_VACUUM",
690 #endif
691 #if SQLITE_OMIT_VIEW
692 "OMIT_VIEW",
693 #endif
694 #if SQLITE_OMIT_VIRTUALTABLE
695 "OMIT_VIRTUALTABLE",
696 #endif
697 #if SQLITE_OMIT_WAL
698 "OMIT_WAL",
699 #endif
700 #if SQLITE_OMIT_WSD
701 "OMIT_WSD",
702 #endif
703 #if SQLITE_OMIT_XFER_OPT
704 "OMIT_XFER_OPT",
705 #endif
706 #if SQLITE_PCACHE_SEPARATE_HEADER
707 "PCACHE_SEPARATE_HEADER",
708 #endif
709 #if SQLITE_PERFORMANCE_TRACE
710 "PERFORMANCE_TRACE",
711 #endif
712 #ifdef SQLITE_POWERSAFE_OVERWRITE
713 # if SQLITE_POWERSAFE_OVERWRITE != 1
714 "POWERSAFE_OVERWRITE=" CTIMEOPT_VAL(SQLITE_POWERSAFE_OVERWRITE),
715 # endif
716 #endif
717 #if SQLITE_PREFER_PROXY_LOCKING
718 "PREFER_PROXY_LOCKING",
719 #endif
720 #if SQLITE_PROXY_DEBUG
721 "PROXY_DEBUG",
722 #endif
723 #if SQLITE_REVERSE_UNORDERED_SELECTS
724 "REVERSE_UNORDERED_SELECTS",
725 #endif
726 #if SQLITE_RTREE_INT_ONLY
727 "RTREE_INT_ONLY",
728 #endif
729 #if SQLITE_SECURE_DELETE
730 "SECURE_DELETE",
731 #endif
732 #if SQLITE_SMALL_STACK
733 "SMALL_STACK",
734 #endif
735 #ifdef SQLITE_SORTER_PMASZ
736 "SORTER_PMASZ=" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ),
737 #endif
738 #if SQLITE_SOUNDEX
739 "SOUNDEX",
740 #endif
741 #ifdef SQLITE_STAT4_SAMPLES
742 "STAT4_SAMPLES=" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES),
743 #endif
744 #ifdef SQLITE_STMTJRNL_SPILL
745 "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),
746 #endif
747 #if SQLITE_SUBSTR_COMPATIBILITY
748 "SUBSTR_COMPATIBILITY",
749 #endif
750 #if (!defined(SQLITE_WIN32_MALLOC) \
751 && !defined(SQLITE_ZERO_MALLOC) \
752 && !defined(SQLITE_MEMDEBUG) \
753 ) || defined(SQLITE_SYSTEM_MALLOC)
754 "SYSTEM_MALLOC",
755 #endif
756 #if SQLITE_TCL
757 "TCL",
758 #endif
759 #ifdef SQLITE_TEMP_STORE
760 "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
761 #endif
762 #if SQLITE_TEST
763 "TEST",
764 #endif
765 #if defined(SQLITE_THREADSAFE)
766 "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
767 #elif defined(THREADSAFE)
768 "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE),
769 #else
770 "THREADSAFE=1",
771 #endif
772 #if SQLITE_UNLINK_AFTER_CLOSE
773 "UNLINK_AFTER_CLOSE",
774 #endif
775 #if SQLITE_UNTESTABLE
776 "UNTESTABLE",
777 #endif
778 #if SQLITE_USER_AUTHENTICATION
779 "USER_AUTHENTICATION",
780 #endif
781 #if SQLITE_USE_ALLOCA
782 "USE_ALLOCA",
783 #endif
784 #if SQLITE_USE_FCNTL_TRACE
785 "USE_FCNTL_TRACE",
786 #endif
787 #if SQLITE_USE_URI
788 "USE_URI",
789 #endif
790 #if SQLITE_VDBE_COVERAGE
791 "VDBE_COVERAGE",
792 #endif
793 #if SQLITE_WIN32_MALLOC
794 "WIN32_MALLOC",
795 #endif
796 #if SQLITE_ZERO_MALLOC
797 "ZERO_MALLOC",
798 #endif
799 /*
800 ** END CODE GENERATED BY tool/mkctime.tcl
801 */
802 };
803
804 SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){
805 *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);
806 return (const char**)sqlite3azCompileOpt;
807 }
808
809 #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
810
811 /************** End of ctime.c ***********************************************/
812 /************** Begin file sqliteInt.h ***************************************/
813 /*
814 ** 2001 September 15
815 **
816 ** The author disclaims copyright to this source code. In place of
@@ -1071,10 +284,21 @@
1071 defined(_WIN32) && !defined(_WIN64) && \
1072 defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION >= 4 && \
1073 defined(__MSVCRT__)
1074 # define _USE_32BIT_TIME_T
1075 #endif
 
 
 
 
 
 
 
 
 
 
 
1076
1077 /* The public SQLite interface. The _FILE_OFFSET_BITS macro must appear
1078 ** first in QNX. Also, the _USE_32BIT_TIME_T macro must appear first for
1079 ** MinGW.
1080 */
@@ -1123,11 +347,34 @@
1123 extern "C" {
1124 #endif
1125
1126
1127 /*
1128 ** Provide the ability to override linkage features of the interface.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1129 */
1130 #ifndef SQLITE_EXTERN
1131 # define SQLITE_EXTERN extern
1132 #endif
1133 #ifndef SQLITE_API
@@ -1203,13 +450,13 @@
1203 **
1204 ** See also: [sqlite3_libversion()],
1205 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1206 ** [sqlite_version()] and [sqlite_source_id()].
1207 */
1208 #define SQLITE_VERSION "3.36.0"
1209 #define SQLITE_VERSION_NUMBER 3036000
1210 #define SQLITE_SOURCE_ID "2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5"
1211
1212 /*
1213 ** CAPI3REF: Run-Time Library Version Numbers
1214 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1215 **
@@ -1596,10 +843,11 @@
1596 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
1597 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
1598 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
1599 #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
1600 #define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8))
 
1601 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
1602 #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
1603 #define SQLITE_CORRUPT_INDEX (SQLITE_CORRUPT | (3<<8))
1604 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
1605 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
@@ -3544,15 +2792,18 @@
3544
3545 /*
3546 ** CAPI3REF: Count The Number Of Rows Modified
3547 ** METHOD: sqlite3
3548 **
3549 ** ^This function returns the number of rows modified, inserted or
3550 ** deleted by the most recently completed INSERT, UPDATE or DELETE
3551 ** statement on the database connection specified by the only parameter.
3552 ** ^Executing any other type of SQL statement does not modify the value
3553 ** returned by this function.
 
 
 
3554 **
3555 ** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
3556 ** considered - auxiliary changes caused by [CREATE TRIGGER | triggers],
3557 ** [foreign key actions] or [REPLACE] constraint resolution are not counted.
3558 **
@@ -3597,20 +2848,25 @@
3597 ** <li> the [changes() SQL function]
3598 ** <li> the [data_version pragma]
3599 ** </ul>
3600 */
3601 SQLITE_API int sqlite3_changes(sqlite3*);
 
3602
3603 /*
3604 ** CAPI3REF: Total Number Of Rows Modified
3605 ** METHOD: sqlite3
3606 **
3607 ** ^This function returns the total number of rows inserted, modified or
3608 ** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
3609 ** since the database connection was opened, including those executed as
3610 ** part of trigger programs. ^Executing any other type of SQL statement
3611 ** does not affect the value returned by sqlite3_total_changes().
 
 
 
 
3612 **
3613 ** ^Changes made as part of [foreign key actions] are included in the
3614 ** count, but those made as part of REPLACE constraint resolution are
3615 ** not. ^Changes to a view that are intercepted by INSTEAD OF triggers
3616 ** are not counted.
@@ -3634,10 +2890,11 @@
3634 ** <li> the [data_version pragma]
3635 ** <li> the [SQLITE_FCNTL_DATA_VERSION] [file control]
3636 ** </ul>
3637 */
3638 SQLITE_API int sqlite3_total_changes(sqlite3*);
 
3639
3640 /*
3641 ** CAPI3REF: Interrupt A Long-Running Query
3642 ** METHOD: sqlite3
3643 **
@@ -4465,10 +3722,16 @@
4465 ** the default shared cache setting provided by
4466 ** [sqlite3_enable_shared_cache()].)^
4467 **
4468 ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt>
4469 ** <dd>The database filename is not allowed to be a symbolic link</dd>
 
 
 
 
 
 
4470 ** </dl>)^
4471 **
4472 ** If the 3rd parameter to sqlite3_open_v2() is not one of the
4473 ** required combinations shown above optionally combined with other
4474 ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]
@@ -5238,16 +4501,21 @@
5238 **
5239 ** ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P)
5240 ** are managed by SQLite and are automatically freed when the prepared
5241 ** statement is finalized.
5242 ** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
5243 ** is obtained from [sqlite3_malloc()] and must be free by the application
5244 ** by passing it to [sqlite3_free()].
 
 
 
5245 */
5246 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
5247 SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
 
5248 SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
 
5249
5250 /*
5251 ** CAPI3REF: Determine If An SQL Statement Writes The Database
5252 ** METHOD: sqlite3_stmt
5253 **
@@ -10090,12 +9358,13 @@
10090 ** that does not correspond to any valid SQLite error code, the results
10091 ** are undefined.
10092 **
10093 ** A single database handle may have at most a single write-ahead log callback
10094 ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any
10095 ** previously registered write-ahead log callback. ^Note that the
10096 ** [sqlite3_wal_autocheckpoint()] interface and the
 
10097 ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
10098 ** overwrite any prior [sqlite3_wal_hook()] settings.
10099 */
10100 SQLITE_API void *sqlite3_wal_hook(
10101 sqlite3*,
@@ -10957,10 +10226,14 @@
10957 ** if writes on the database cause it to grow larger than M bytes.
10958 **
10959 ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the
10960 ** database is currently in a read transaction or is involved in a backup
10961 ** operation.
 
 
 
 
10962 **
10963 ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
10964 ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
10965 ** [sqlite3_free()] is invoked on argument P prior to returning.
10966 **
@@ -13440,11 +12713,11 @@
13440 /*
13441 ** Include the configuration header output by 'configure' if we're using the
13442 ** autoconf-based build
13443 */
13444 #if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
13445 /* #include "config.h" */
13446 #define SQLITECONFIG_H 1
13447 #endif
13448
13449 /************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/
13450 /************** Begin file sqliteLimit.h *************************************/
@@ -13676,15 +12949,16 @@
13676 ** places. The following macros try to make this explicit.
13677 */
13678 #ifndef __has_extension
13679 # define __has_extension(x) 0 /* compatibility with non-clang compilers */
13680 #endif
13681 #if GCC_VERSION>=4007000 || \
13682 (__has_extension(c_atomic) && __has_extension(c_atomic_store_n))
13683 # define AtomicLoad(PTR) __atomic_load_n((PTR),__ATOMIC_RELAXED)
13684 # define AtomicStore(PTR,VAL) __atomic_store_n((PTR),(VAL),__ATOMIC_RELAXED)
13685 #else
 
13686 # define AtomicLoad(PTR) (*(PTR))
13687 # define AtomicStore(PTR,VAL) (*(PTR) = (VAL))
13688 #endif
13689
13690 /*
@@ -15349,11 +14623,11 @@
15349 */
15350 #define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */
15351 #define BTREE_BLOBKEY 2 /* Table has keys only - no data */
15352
15353 SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*);
15354 SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, int*);
15355 SQLITE_PRIVATE int sqlite3BtreeClearTableOfCursor(BtCursor*);
15356 SQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree*, int, int);
15357
15358 SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);
15359 SQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
@@ -15473,16 +14747,20 @@
15473 #ifdef SQLITE_ENABLE_CURSOR_HINTS
15474 SQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor*, int, ...);
15475 #endif
15476
15477 SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor*);
15478 SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(
15479 BtCursor*,
15480 UnpackedRecord *pUnKey,
15481 i64 intKey,
15482 int bias,
15483 int *pRes
 
 
 
 
 
15484 );
15485 SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*);
15486 SQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor*, int*);
15487 SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*, u8 flags);
15488
@@ -17110,12 +16388,12 @@
17110 u8 mTrace; /* zero or more SQLITE_TRACE flags */
17111 u8 noSharedCache; /* True if no shared-cache backends */
17112 u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
17113 int nextPagesize; /* Pagesize after VACUUM if >0 */
17114 u32 magic; /* Magic number for detect library misuse */
17115 int nChange; /* Value returned by sqlite3_changes() */
17116 int nTotalChange; /* Value returned by sqlite3_total_changes() */
17117 int aLimit[SQLITE_N_LIMIT]; /* Limits */
17118 int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */
17119 struct sqlite3InitInfo { /* Information used during initialization */
17120 Pgno newTnum; /* Rootpage of table being initialized */
17121 u8 iDb; /* Which db file is being initialized */
@@ -17320,10 +16598,12 @@
17320 #define SQLITE_SimplifyJoin 0x00002000 /* Convert LEFT JOIN to JOIN */
17321 #define SQLITE_SkipScan 0x00004000 /* Skip-scans */
17322 #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */
17323 #define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */
17324 #define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */
 
 
17325 #define SQLITE_AllOpts 0xffffffff /* All optimizations */
17326
17327 /*
17328 ** Macros for testing whether or not optimizations are enabled or disabled.
17329 */
@@ -17399,16 +16679,17 @@
17399 ** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG. And
17400 ** SQLITE_FUNC_CONSTANT must be the same as SQLITE_DETERMINISTIC. There
17401 ** are assert() statements in the code to verify this.
17402 **
17403 ** Value constraints (enforced via assert()):
17404 ** SQLITE_FUNC_MINMAX == NC_MinMaxAgg == SF_MinMaxAgg
17405 ** SQLITE_FUNC_LENGTH == OPFLAG_LENGTHARG
17406 ** SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG
17407 ** SQLITE_FUNC_CONSTANT == SQLITE_DETERMINISTIC from the API
17408 ** SQLITE_FUNC_DIRECT == SQLITE_DIRECTONLY from the API
17409 ** SQLITE_FUNC_UNSAFE == SQLITE_INNOCUOUS
 
17410 ** SQLITE_FUNC_ENCMASK depends on SQLITE_UTF* macros in the API
17411 */
17412 #define SQLITE_FUNC_ENCMASK 0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */
17413 #define SQLITE_FUNC_LIKE 0x0004 /* Candidate for the LIKE optimization */
17414 #define SQLITE_FUNC_CASE 0x0008 /* Case-sensitive LIKE-type function */
@@ -17429,10 +16710,11 @@
17429 #define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */
17430 #define SQLITE_FUNC_DIRECT 0x00080000 /* Not for use in TRIGGERs or VIEWs */
17431 #define SQLITE_FUNC_SUBTYPE 0x00100000 /* Result likely to have sub-type */
17432 #define SQLITE_FUNC_UNSAFE 0x00200000 /* Function has side effects */
17433 #define SQLITE_FUNC_INLINE 0x00400000 /* Functions implemented in-line */
 
17434
17435 /* Identifier numbers for each in-line function */
17436 #define INLINEFUNC_coalesce 0
17437 #define INLINEFUNC_implies_nonnull_row 1
17438 #define INLINEFUNC_expr_implies_expr 2
@@ -18664,35 +17946,37 @@
18664
18665 /*
18666 ** Allowed values for the NameContext, ncFlags field.
18667 **
18668 ** Value constraints (all checked via assert()):
18669 ** NC_HasAgg == SF_HasAgg == EP_Agg
18670 ** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX
 
18671 ** NC_HasWin == EP_Win
18672 **
18673 */
18674 #define NC_AllowAgg 0x00001 /* Aggregate functions are allowed here */
18675 #define NC_PartIdx 0x00002 /* True if resolving a partial index WHERE */
18676 #define NC_IsCheck 0x00004 /* True if resolving a CHECK constraint */
18677 #define NC_GenCol 0x00008 /* True for a GENERATED ALWAYS AS clause */
18678 #define NC_HasAgg 0x00010 /* One or more aggregate functions seen */
18679 #define NC_IdxExpr 0x00020 /* True if resolving columns of CREATE INDEX */
18680 #define NC_SelfRef 0x0002e /* Combo: PartIdx, isCheck, GenCol, and IdxExpr */
18681 #define NC_VarSelect 0x00040 /* A correlated subquery has been seen */
18682 #define NC_UEList 0x00080 /* True if uNC.pEList is used */
18683 #define NC_UAggInfo 0x00100 /* True if uNC.pAggInfo is used */
18684 #define NC_UUpsert 0x00200 /* True if uNC.pUpsert is used */
18685 #define NC_UBaseReg 0x00400 /* True if uNC.iBaseReg is used */
18686 #define NC_MinMaxAgg 0x01000 /* min/max aggregates seen. See note above */
18687 #define NC_Complex 0x02000 /* True if a function or subquery seen */
18688 #define NC_AllowWin 0x04000 /* Window functions are allowed here */
18689 #define NC_HasWin 0x08000 /* One or more window functions seen */
18690 #define NC_IsDDL 0x10000 /* Resolving names in a CREATE statement */
18691 #define NC_InAggFunc 0x20000 /* True if analyzing arguments to an agg func */
18692 #define NC_FromDDL 0x40000 /* SQL text comes from sqlite_schema */
18693 #define NC_NoSelect 0x80000 /* Do not descend into sub-selects */
 
18694
18695 /*
18696 ** An instance of the following object describes a single ON CONFLICT
18697 ** clause in an upsert.
18698 **
@@ -18771,13 +18055,14 @@
18771 /*
18772 ** Allowed values for Select.selFlags. The "SF" prefix stands for
18773 ** "Select Flag".
18774 **
18775 ** Value constraints (all checked via assert())
18776 ** SF_HasAgg == NC_HasAgg
18777 ** SF_MinMaxAgg == NC_MinMaxAgg == SQLITE_FUNC_MINMAX
18778 ** SF_FixedLimit == WHERE_USE_LIMIT
 
18779 */
18780 #define SF_Distinct 0x0000001 /* Output should be DISTINCT */
18781 #define SF_All 0x0000002 /* Includes the ALL keyword */
18782 #define SF_Resolved 0x0000004 /* Identifiers have been resolved */
18783 #define SF_Aggregate 0x0000008 /* Contains agg functions or a GROUP BY */
@@ -18798,14 +18083,15 @@
18798 #define SF_ComplexResult 0x0040000 /* Result contains subquery or function */
18799 #define SF_WhereBegin 0x0080000 /* Really a WhereBegin() call. Debug Only */
18800 #define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */
18801 #define SF_View 0x0200000 /* SELECT statement is a view */
18802 #define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */
18803 #define SF_UpdateFrom 0x0800000 /* Statement is an UPDATE...FROM */
18804 #define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */
18805 #define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */
18806 #define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */
 
18807
18808 /*
18809 ** The results of a SELECT can be distributed in several ways, as defined
18810 ** by one of the following macros. The "SRT" prefix means "SELECT Result
18811 ** Type".
@@ -19911,10 +19197,11 @@
19911 SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
19912 SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*);
19913 SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*);
19914 SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
19915 SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
 
19916 SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int,int);
19917 SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
19918 SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
19919 SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
19920 SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
@@ -20329,11 +19616,11 @@
20329 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
20330 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollateAndLikely(Expr*);
20331 SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
20332 SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3*);
20333 SQLITE_PRIVATE int sqlite3CheckObjectName(Parse*, const char*,const char*,const char*);
20334 SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, int);
20335 SQLITE_PRIVATE int sqlite3AddInt64(i64*,i64);
20336 SQLITE_PRIVATE int sqlite3SubInt64(i64*,i64);
20337 SQLITE_PRIVATE int sqlite3MulInt64(i64*,i64);
20338 SQLITE_PRIVATE int sqlite3AbsInt32(int);
20339 #ifdef SQLITE_ENABLE_8_3_NAMES
@@ -20779,20 +20066,807 @@
20779 #endif
20780
20781 SQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr);
20782 SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr);
20783 SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr*, int);
20784 SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int);
20785 SQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse*, Expr*);
20786
20787 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
20788 SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt);
20789 #endif
20790
20791 #endif /* SQLITEINT_H */
20792
20793 /************** End of sqliteInt.h *******************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20794 /************** Begin file global.c ******************************************/
20795 /*
20796 ** 2008 June 13
20797 **
20798 ** The author disclaims copyright to this source code. In place of
@@ -21342,12 +21416,12 @@
21342 int pc; /* Program Counter in parent (calling) frame */
21343 int nOp; /* Size of aOp array */
21344 int nMem; /* Number of entries in aMem */
21345 int nChildMem; /* Number of memory cells for child frame */
21346 int nChildCsr; /* Number of cursors for child frame */
21347 int nChange; /* Statement changes (Vdbe.nChange) */
21348 int nDbChange; /* Value of db->nChange */
21349 };
21350
21351 /* Magic number for sanity checking on VdbeFrame objects */
21352 #define SQLITE_FRAME_MAGIC 0x879fb71e
21353
@@ -21550,11 +21624,11 @@
21550 int nMem; /* Number of memory locations currently allocated */
21551 int nCursor; /* Number of slots in apCsr[] */
21552 u32 cacheCtr; /* VdbeCursor row cache generation counter */
21553 int pc; /* The program counter */
21554 int rc; /* Value to return */
21555 int nChange; /* Number of db changes made since last reset */
21556 int iStatement; /* Statement number (or 0 if has no opened stmt) */
21557 i64 iCurrentTime; /* Value of julianday('now') for this statement */
21558 i64 nFkConstraint; /* Number of imm. FK constraints this VM */
21559 i64 nStmtDefCons; /* Number of def. constraints when stmt started */
21560 i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
@@ -21695,10 +21769,11 @@
21695 SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*);
21696 #endif
21697 SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*);
21698 SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
21699 SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8);
 
21700 SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem*);
21701 SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*);
21702 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);
21703 SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull);
21704 SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*);
@@ -30077,10 +30152,12 @@
30077 sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx",
30078 pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed);
30079 }
30080 if( pItem->fg.jointype & JT_LEFT ){
30081 sqlite3_str_appendf(&x, " LEFT-JOIN");
 
 
30082 }
30083 if( pItem->fg.fromDDL ){
30084 sqlite3_str_appendf(&x, " DDL");
30085 }
30086 if( pItem->fg.isCte ){
@@ -30632,11 +30709,13 @@
30632 sqlite3TreeViewBareExprList(pView, pExpr->x.pList, z);
30633 sqlite3_free(z);
30634 break;
30635 }
30636 case TK_SELECT_COLUMN: {
30637 sqlite3TreeViewLine(pView, "SELECT-COLUMN %d", pExpr->iColumn);
 
 
30638 sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0);
30639 break;
30640 }
30641 case TK_IF_NULL_ROW: {
30642 sqlite3TreeViewLine(pView, "IF-NULL-ROW %d", pExpr->iTable);
@@ -30648,10 +30727,19 @@
30648 sqlite3TreeViewLine(pView, "ERROR");
30649 tmp = *pExpr;
30650 tmp.op = pExpr->op2;
30651 sqlite3TreeViewExpr(pView, &tmp, 0);
30652 break;
 
 
 
 
 
 
 
 
 
30653 }
30654 default: {
30655 sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
30656 break;
30657 }
@@ -40241,10 +40329,12 @@
40241 if( fd<0 ){
40242 if( isNewJrnl && errno==EACCES && osAccess(zName, F_OK) ){
40243 /* If unable to create a journal because the directory is not
40244 ** writable, change the error code to indicate that. */
40245 rc = SQLITE_READONLY_DIRECTORY;
 
 
40246 }else if( errno!=EISDIR && isReadWrite ){
40247 /* Failed to open the file for read/write access. Try read-only. */
40248 flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
40249 openFlags &= ~(O_RDWR|O_CREAT);
40250 flags |= SQLITE_OPEN_READONLY;
@@ -49327,11 +49417,12 @@
49327 #endif
49328
49329 sqlite3_mutex_enter(db->mutex);
49330 if( zSchema==0 ) zSchema = db->aDb[0].zDbSName;
49331 iDb = sqlite3FindDbName(db, zSchema);
49332 if( iDb<0 ){
 
49333 rc = SQLITE_ERROR;
49334 goto end_deserialize;
49335 }
49336 zSql = sqlite3_mprintf("ATTACH x AS %Q", zSchema);
49337 if( zSql==0 ){
@@ -66277,19 +66368,17 @@
66277 pIdxKey = sqlite3VdbeAllocUnpackedRecord(pKeyInfo);
66278 if( pIdxKey==0 ) return SQLITE_NOMEM_BKPT;
66279 sqlite3VdbeRecordUnpack(pKeyInfo, (int)nKey, pKey, pIdxKey);
66280 if( pIdxKey->nField==0 || pIdxKey->nField>pKeyInfo->nAllField ){
66281 rc = SQLITE_CORRUPT_BKPT;
66282 goto moveto_done;
 
66283 }
 
66284 }else{
66285 pIdxKey = 0;
66286 }
66287 rc = sqlite3BtreeMovetoUnpacked(pCur, pIdxKey, nKey, bias, pRes);
66288 moveto_done:
66289 if( pIdxKey ){
66290 sqlite3DbFree(pCur->pKeyInfo->db, pIdxKey);
66291 }
66292 return rc;
66293 }
66294
66295 /*
@@ -67134,11 +67223,11 @@
67134 u8 *pSpace = pageFindSlot(pPage, nByte, &rc);
67135 if( pSpace ){
67136 int g2;
67137 assert( pSpace+nByte<=data+pPage->pBt->usableSize );
67138 *pIdx = g2 = (int)(pSpace-data);
67139 if( NEVER(g2<=gap) ){
67140 return SQLITE_CORRUPT_PAGE(pPage);
67141 }else{
67142 return SQLITE_OK;
67143 }
67144 }else if( rc ){
@@ -70871,16 +70960,12 @@
70871 rc = SQLITE_OK;
70872 }
70873 return rc;
70874 }
70875
70876 /* Move the cursor so that it points to an entry near the key
70877 ** specified by pIdxKey or intKey. Return a success code.
70878 **
70879 ** For INTKEY tables, the intKey parameter is used. pIdxKey
70880 ** must be NULL. For index tables, pIdxKey is used and intKey
70881 ** is ignored.
70882 **
70883 ** If an exact match is not found, then the cursor is always
70884 ** left pointing at a leaf page which would hold the entry if it
70885 ** were present. The cursor might point to an entry that comes
70886 ** before or after the key.
@@ -70889,43 +70974,36 @@
70889 ** comparing the key with the entry to which the cursor is
70890 ** pointing. The meaning of the integer written into
70891 ** *pRes is as follows:
70892 **
70893 ** *pRes<0 The cursor is left pointing at an entry that
70894 ** is smaller than intKey/pIdxKey or if the table is empty
70895 ** and the cursor is therefore left point to nothing.
70896 **
70897 ** *pRes==0 The cursor is left pointing at an entry that
70898 ** exactly matches intKey/pIdxKey.
70899 **
70900 ** *pRes>0 The cursor is left pointing at an entry that
70901 ** is larger than intKey/pIdxKey.
70902 **
70903 ** For index tables, the pIdxKey->eqSeen field is set to 1 if there
70904 ** exists an entry in the table that exactly matches pIdxKey.
70905 */
70906 SQLITE_PRIVATE int sqlite3BtreeMovetoUnpacked(
70907 BtCursor *pCur, /* The cursor to be moved */
70908 UnpackedRecord *pIdxKey, /* Unpacked index key */
70909 i64 intKey, /* The table key */
70910 int biasRight, /* If true, bias the search to the high end */
70911 int *pRes /* Write search results here */
70912 ){
70913 int rc;
70914 RecordCompare xRecordCompare;
70915
70916 assert( cursorOwnsBtShared(pCur) );
70917 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
70918 assert( pRes );
70919 assert( (pIdxKey==0)==(pCur->pKeyInfo==0) );
70920 assert( pCur->eState!=CURSOR_VALID || (pIdxKey==0)==(pCur->curIntKey!=0) );
70921
70922 /* If the cursor is already positioned at the point we are trying
70923 ** to move to, then just return without doing any work */
70924 if( pIdxKey==0
70925 && pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0
70926 ){
70927 if( pCur->info.nKey==intKey ){
70928 *pRes = 0;
70929 return SQLITE_OK;
70930 }
70931 if( pCur->info.nKey<intKey ){
@@ -70956,20 +71034,153 @@
70956
70957 #ifdef SQLITE_DEBUG
70958 pCur->pBtree->nSeek++; /* Performance measurement during testing */
70959 #endif
70960
70961 if( pIdxKey ){
70962 xRecordCompare = sqlite3VdbeFindCompare(pIdxKey);
70963 pIdxKey->errCode = 0;
70964 assert( pIdxKey->default_rc==1
70965 || pIdxKey->default_rc==0
70966 || pIdxKey->default_rc==-1
70967 );
70968 }else{
70969 xRecordCompare = 0; /* All keys are integers */
70970 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70971
70972 rc = moveToRoot(pCur);
70973 if( rc ){
70974 if( rc==SQLITE_EMPTY ){
70975 assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );
@@ -70998,155 +71209,116 @@
70998 ** a moveToChild() or moveToRoot() call would have detected corruption. */
70999 assert( pPage->nCell>0 );
71000 assert( pPage->intKey==(pIdxKey==0) );
71001 lwr = 0;
71002 upr = pPage->nCell-1;
71003 assert( biasRight==0 || biasRight==1 );
71004 idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */
71005 pCur->ix = (u16)idx;
71006 if( xRecordCompare==0 ){
71007 for(;;){
71008 i64 nCellKey;
71009 pCell = findCellPastPtr(pPage, idx);
71010 if( pPage->intKeyLeaf ){
71011 while( 0x80 <= *(pCell++) ){
71012 if( pCell>=pPage->aDataEnd ){
71013 return SQLITE_CORRUPT_PAGE(pPage);
71014 }
71015 }
71016 }
71017 getVarint(pCell, (u64*)&nCellKey);
71018 if( nCellKey<intKey ){
71019 lwr = idx+1;
71020 if( lwr>upr ){ c = -1; break; }
71021 }else if( nCellKey>intKey ){
71022 upr = idx-1;
71023 if( lwr>upr ){ c = +1; break; }
71024 }else{
71025 assert( nCellKey==intKey );
71026 pCur->ix = (u16)idx;
71027 if( !pPage->leaf ){
71028 lwr = idx;
71029 goto moveto_next_layer;
71030 }else{
71031 pCur->curFlags |= BTCF_ValidNKey;
71032 pCur->info.nKey = nCellKey;
71033 pCur->info.nSize = 0;
71034 *pRes = 0;
71035 return SQLITE_OK;
71036 }
71037 }
71038 assert( lwr+upr>=0 );
71039 idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2; */
71040 }
71041 }else{
71042 for(;;){
71043 int nCell; /* Size of the pCell cell in bytes */
71044 pCell = findCellPastPtr(pPage, idx);
71045
71046 /* The maximum supported page-size is 65536 bytes. This means that
71047 ** the maximum number of record bytes stored on an index B-Tree
71048 ** page is less than 16384 bytes and may be stored as a 2-byte
71049 ** varint. This information is used to attempt to avoid parsing
71050 ** the entire cell by checking for the cases where the record is
71051 ** stored entirely within the b-tree page by inspecting the first
71052 ** 2 bytes of the cell.
71053 */
71054 nCell = pCell[0];
71055 if( nCell<=pPage->max1bytePayload ){
71056 /* This branch runs if the record-size field of the cell is a
71057 ** single byte varint and the record fits entirely on the main
71058 ** b-tree page. */
71059 testcase( pCell+nCell+1==pPage->aDataEnd );
71060 c = xRecordCompare(nCell, (void*)&pCell[1], pIdxKey);
71061 }else if( !(pCell[1] & 0x80)
71062 && (nCell = ((nCell&0x7f)<<7) + pCell[1])<=pPage->maxLocal
71063 ){
71064 /* The record-size field is a 2 byte varint and the record
71065 ** fits entirely on the main b-tree page. */
71066 testcase( pCell+nCell+2==pPage->aDataEnd );
71067 c = xRecordCompare(nCell, (void*)&pCell[2], pIdxKey);
71068 }else{
71069 /* The record flows over onto one or more overflow pages. In
71070 ** this case the whole cell needs to be parsed, a buffer allocated
71071 ** and accessPayload() used to retrieve the record into the
71072 ** buffer before VdbeRecordCompare() can be called.
71073 **
71074 ** If the record is corrupt, the xRecordCompare routine may read
71075 ** up to two varints past the end of the buffer. An extra 18
71076 ** bytes of padding is allocated at the end of the buffer in
71077 ** case this happens. */
71078 void *pCellKey;
71079 u8 * const pCellBody = pCell - pPage->childPtrSize;
71080 const int nOverrun = 18; /* Size of the overrun padding */
71081 pPage->xParseCell(pPage, pCellBody, &pCur->info);
71082 nCell = (int)pCur->info.nKey;
71083 testcase( nCell<0 ); /* True if key size is 2^32 or more */
71084 testcase( nCell==0 ); /* Invalid key size: 0x80 0x80 0x00 */
71085 testcase( nCell==1 ); /* Invalid key size: 0x80 0x80 0x01 */
71086 testcase( nCell==2 ); /* Minimum legal index key size */
71087 if( nCell<2 || nCell/pCur->pBt->usableSize>pCur->pBt->nPage ){
71088 rc = SQLITE_CORRUPT_PAGE(pPage);
71089 goto moveto_finish;
71090 }
71091 pCellKey = sqlite3Malloc( nCell+nOverrun );
71092 if( pCellKey==0 ){
71093 rc = SQLITE_NOMEM_BKPT;
71094 goto moveto_finish;
71095 }
71096 pCur->ix = (u16)idx;
71097 rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);
71098 memset(((u8*)pCellKey)+nCell,0,nOverrun); /* Fix uninit warnings */
71099 pCur->curFlags &= ~BTCF_ValidOvfl;
71100 if( rc ){
71101 sqlite3_free(pCellKey);
71102 goto moveto_finish;
71103 }
71104 c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey);
71105 sqlite3_free(pCellKey);
71106 }
71107 assert(
71108 (pIdxKey->errCode!=SQLITE_CORRUPT || c==0)
71109 && (pIdxKey->errCode!=SQLITE_NOMEM || pCur->pBtree->db->mallocFailed)
71110 );
71111 if( c<0 ){
71112 lwr = idx+1;
71113 }else if( c>0 ){
71114 upr = idx-1;
71115 }else{
71116 assert( c==0 );
71117 *pRes = 0;
71118 rc = SQLITE_OK;
71119 pCur->ix = (u16)idx;
71120 if( pIdxKey->errCode ) rc = SQLITE_CORRUPT_BKPT;
71121 goto moveto_finish;
71122 }
71123 if( lwr>upr ) break;
71124 assert( lwr+upr>=0 );
71125 idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2 */
71126 }
71127 }
71128 assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) );
71129 assert( pPage->isInit );
71130 if( pPage->leaf ){
71131 assert( pCur->ix<pCur->pPage->nCell );
71132 pCur->ix = (u16)idx;
71133 *pRes = c;
71134 rc = SQLITE_OK;
71135 goto moveto_finish;
71136 }
71137 moveto_next_layer:
71138 if( lwr>=pPage->nCell ){
71139 chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]);
71140 }else{
71141 chldPg = get4byte(findCell(pPage, lwr));
71142 }
71143 pCur->ix = (u16)lwr;
71144 rc = moveToChild(pCur, chldPg);
71145 if( rc ) break;
71146 }
71147 moveto_finish:
71148 pCur->info.nSize = 0;
71149 assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );
71150 return rc;
71151 }
71152
@@ -73126,10 +73298,11 @@
73126 if( rc ){
73127 memset(apOld, 0, (i)*sizeof(MemPage*));
73128 goto balance_cleanup;
73129 }
73130 }
 
73131 if( (i--)==0 ) break;
73132
73133 if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){
73134 apDiv[i] = pParent->apOvfl[0];
73135 pgno = get4byte(apDiv[i]);
@@ -73167,11 +73340,10 @@
73167 }
73168 }
73169
73170 /* Make nMaxCells a multiple of 4 in order to preserve 8-byte
73171 ** alignment */
73172 nMaxCells = nOld*(MX_CELL(pBt) + ArraySize(pParent->apOvfl));
73173 nMaxCells = (nMaxCells + 3)&~3;
73174
73175 /*
73176 ** Allocate space for memory structures
73177 */
@@ -73450,11 +73622,13 @@
73450 if( i<nOld ){
73451 pNew = apNew[i] = apOld[i];
73452 apOld[i] = 0;
73453 rc = sqlite3PagerWrite(pNew->pDbPage);
73454 nNew++;
73455 if( sqlite3PagerPageRefcount(pNew->pDbPage)!=1+(i==(iParentIdx-nxDiv)) ){
 
 
73456 rc = SQLITE_CORRUPT_BKPT;
73457 }
73458 if( rc ) goto balance_cleanup;
73459 }else{
73460 assert( i>0 );
@@ -74248,11 +74422,12 @@
74248 }else if( loc==0 ){
74249 /* The cursor is *not* pointing to the cell to be overwritten, nor
74250 ** to an adjacent cell. Move the cursor so that it is pointing either
74251 ** to the cell to be overwritten or an adjacent cell.
74252 */
74253 rc = sqlite3BtreeMovetoUnpacked(pCur, 0, pX->nKey, flags!=0, &loc);
 
74254 if( rc ) return rc;
74255 }
74256 }else{
74257 /* This is an index or a WITHOUT ROWID table */
74258
@@ -74271,17 +74446,15 @@
74271 UnpackedRecord r;
74272 r.pKeyInfo = pCur->pKeyInfo;
74273 r.aMem = pX->aMem;
74274 r.nField = pX->nMem;
74275 r.default_rc = 0;
74276 r.errCode = 0;
74277 r.r1 = 0;
74278 r.r2 = 0;
74279 r.eqSeen = 0;
74280 rc = sqlite3BtreeMovetoUnpacked(pCur, &r, 0, flags!=0, &loc);
74281 }else{
74282 rc = btreeMoveto(pCur, pX->pKey, pX->nKey, flags!=0, &loc);
 
74283 }
74284 if( rc ) return rc;
74285 }
74286
74287 /* If the cursor is currently pointing to an entry to be overwritten
@@ -74911,11 +75084,11 @@
74911 */
74912 static int clearDatabasePage(
74913 BtShared *pBt, /* The BTree that contains the table */
74914 Pgno pgno, /* Page number to clear */
74915 int freePageFlag, /* Deallocate page if true */
74916 int *pnChange /* Add number of Cells freed to this counter */
74917 ){
74918 MemPage *pPage;
74919 int rc;
74920 unsigned char *pCell;
74921 int i;
@@ -74944,10 +75117,11 @@
74944 if( rc ) goto cleardatabasepage_out;
74945 }
74946 if( !pPage->leaf ){
74947 rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
74948 if( rc ) goto cleardatabasepage_out;
 
74949 }
74950 if( pnChange ){
74951 testcase( !pPage->intKey );
74952 *pnChange += pPage->nCell;
74953 }
@@ -74973,11 +75147,11 @@
74973 ** root of the table.
74974 **
74975 ** If pnChange is not NULL, then the integer value pointed to by pnChange
74976 ** is incremented by the number of entries in the table.
74977 */
74978 SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, int *pnChange){
74979 int rc;
74980 BtShared *pBt = p->pBt;
74981 sqlite3BtreeEnter(p);
74982 assert( p->inTrans==TRANS_WRITE );
74983
@@ -82408,11 +82582,11 @@
82408 extern int sqlite3_search_count;
82409 #endif
82410 assert( p->deferredMoveto );
82411 assert( p->isTable );
82412 assert( p->eCurType==CURTYPE_BTREE );
82413 rc = sqlite3BtreeMovetoUnpacked(p->uc.pCursor, 0, p->movetoTarget, 0, &res);
82414 if( rc ) return rc;
82415 if( res!=0 ) return SQLITE_CORRUPT_BKPT;
82416 #ifdef SQLITE_TEST
82417 sqlite3_search_count++;
82418 #endif
@@ -83192,11 +83366,11 @@
83192 /*
83193 ** Do a comparison between a 64-bit signed integer and a 64-bit floating-point
83194 ** number. Return negative, zero, or positive if the first (i64) is less than,
83195 ** equal to, or greater than the second (double).
83196 */
83197 static int sqlite3IntFloatCompare(i64 i, double r){
83198 if( sizeof(LONGDOUBLE_TYPE)>8 ){
83199 LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i;
83200 testcase( x<r );
83201 testcase( x>r );
83202 testcase( x==r );
@@ -83916,11 +84090,11 @@
83916
83917 /*
83918 ** This routine sets the value to be returned by subsequent calls to
83919 ** sqlite3_changes() on the database handle 'db'.
83920 */
83921 SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *db, int nChange){
83922 assert( sqlite3_mutex_held(db->mutex) );
83923 db->nChange = nChange;
83924 db->nTotalChange += nChange;
83925 }
83926
@@ -90284,10 +90458,12 @@
90284 assert( pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );
90285 assert( pOp->p4type==P4_KEYINFO );
90286 pCur = p->apCsr[pOp->p1];
90287 if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){
90288 assert( pCur->iDb==pOp->p3 ); /* Guaranteed by the code generator */
 
 
90289 goto open_cursor_set_hints;
90290 }
90291 /* If the cursor is not currently open or is open on a different
90292 ** index, then fall through into OP_OpenRead to force a reopen */
90293 case OP_OpenRead:
@@ -90771,45 +90947,47 @@
90771 pIn3->flags = flags3; /* But convert the type back to its original */
90772
90773 /* If the P3 value could not be converted into an integer without
90774 ** loss of information, then special processing is required... */
90775 if( (newType & (MEM_Int|MEM_IntReal))==0 ){
 
90776 if( (newType & MEM_Real)==0 ){
90777 if( (newType & MEM_Null) || oc>=OP_SeekGE ){
90778 VdbeBranchTaken(1,2);
90779 goto jump_to_p2;
90780 }else{
90781 rc = sqlite3BtreeLast(pC->uc.pCursor, &res);
90782 if( rc!=SQLITE_OK ) goto abort_due_to_error;
90783 goto seek_not_found;
90784 }
90785 }else
 
90786
90787 /* If the approximation iKey is larger than the actual real search
90788 ** term, substitute >= for > and < for <=. e.g. if the search term
90789 ** is 4.9 and the integer approximation 5:
90790 **
90791 ** (x > 4.9) -> (x >= 5)
90792 ** (x <= 4.9) -> (x < 5)
90793 */
90794 if( pIn3->u.r<(double)iKey ){
90795 assert( OP_SeekGE==(OP_SeekGT-1) );
90796 assert( OP_SeekLT==(OP_SeekLE-1) );
90797 assert( (OP_SeekLE & 0x0001)==(OP_SeekGT & 0x0001) );
90798 if( (oc & 0x0001)==(OP_SeekGT & 0x0001) ) oc--;
90799 }
90800
90801 /* If the approximation iKey is smaller than the actual real search
90802 ** term, substitute <= for < and > for >=. */
90803 else if( pIn3->u.r>(double)iKey ){
90804 assert( OP_SeekLE==(OP_SeekLT+1) );
90805 assert( OP_SeekGT==(OP_SeekGE+1) );
90806 assert( (OP_SeekLT & 0x0001)==(OP_SeekGE & 0x0001) );
90807 if( (oc & 0x0001)==(OP_SeekLT & 0x0001) ) oc++;
90808 }
90809 }
90810 rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)iKey, 0, &res);
90811 pC->movetoTarget = iKey; /* Used by OP_Delete */
90812 if( rc!=SQLITE_OK ){
90813 goto abort_due_to_error;
90814 }
90815 }else{
@@ -90852,11 +91030,11 @@
90852 r.aMem = &aMem[pOp->p3];
90853 #ifdef SQLITE_DEBUG
90854 { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }
90855 #endif
90856 r.eqSeen = 0;
90857 rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, &r, 0, 0, &res);
90858 if( rc!=SQLITE_OK ){
90859 goto abort_due_to_error;
90860 }
90861 if( eqOnly && r.eqSeen==0 ){
90862 assert( res!=0 );
@@ -91271,11 +91449,11 @@
91271 takeJump = 1;
91272 break;
91273 }
91274 }
91275 }
91276 rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, pIdxKey, 0, 0, &res);
91277 if( pFree ) sqlite3DbFreeNN(db, pFree);
91278 if( rc!=SQLITE_OK ){
91279 goto abort_due_to_error;
91280 }
91281 pC->seekResult = res;
@@ -91380,11 +91558,11 @@
91380 assert( pC->isTable );
91381 assert( pC->eCurType==CURTYPE_BTREE );
91382 pCrsr = pC->uc.pCursor;
91383 assert( pCrsr!=0 );
91384 res = 0;
91385 rc = sqlite3BtreeMovetoUnpacked(pCrsr, 0, iKey, 0, &res);
91386 assert( rc==SQLITE_OK || res==0 );
91387 pC->movetoTarget = iKey; /* Used by OP_Delete */
91388 pC->nullRow = 0;
91389 pC->cacheStatus = CACHE_STALE;
91390 pC->deferredMoveto = 0;
@@ -91537,11 +91715,11 @@
91537 ** an AUTOINCREMENT table. */
91538 cnt = 0;
91539 do{
91540 sqlite3_randomness(sizeof(v), &v);
91541 v &= (MAX_ROWID>>1); v++; /* Ensure that v is greater than zero */
91542 }while( ((rc = sqlite3BtreeMovetoUnpacked(pC->uc.pCursor, 0, (u64)v,
91543 0, &res))==SQLITE_OK)
91544 && (res==0)
91545 && (++cnt<100));
91546 if( rc ) goto abort_due_to_error;
91547 if( res==0 ){
@@ -92435,11 +92613,11 @@
92435 assert( pCrsr!=0 );
92436 r.pKeyInfo = pC->pKeyInfo;
92437 r.nField = (u16)pOp->p3;
92438 r.default_rc = 0;
92439 r.aMem = &aMem[pOp->p2];
92440 rc = sqlite3BtreeMovetoUnpacked(pCrsr, &r, 0, 0, &res);
92441 if( rc ) goto abort_due_to_error;
92442 if( res==0 ){
92443 rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
92444 if( rc ) goto abort_due_to_error;
92445 }else if( pOp->p5 ){
@@ -92748,11 +92926,11 @@
92748 ** by the number of rows in the table being cleared.
92749 **
92750 ** See also: Destroy
92751 */
92752 case OP_Clear: {
92753 int nChange;
92754
92755 sqlite3VdbeIncrWriteCounter(p, 0);
92756 nChange = 0;
92757 assert( p->readOnly==0 );
92758 assert( DbMaskTest(p->btreeMask, pOp->p2) );
@@ -99511,11 +99689,11 @@
99511 if( pSrcList ){
99512 for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){
99513 u8 hCol;
99514 pTab = pItem->pTab;
99515 assert( pTab!=0 && pTab->zName!=0 );
99516 assert( pTab->nCol>0 );
99517 if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){
99518 int hit = 0;
99519 pEList = pItem->pSelect->pEList;
99520 for(j=0; j<pEList->nExpr; j++){
99521 if( sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb) ){
@@ -99539,13 +99717,10 @@
99539 }
99540 if( IN_RENAME_OBJECT && pItem->zAlias ){
99541 sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab);
99542 }
99543 }
99544 if( 0==(cntTab++) ){
99545 pMatch = pItem;
99546 }
99547 hCol = sqlite3StrIHash(zCol);
99548 for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){
99549 if( pCol->hName==hCol && sqlite3StrICmp(pCol->zName, zCol)==0 ){
99550 /* If there has been exactly one prior match and this match
99551 ** is for the right-hand table of a NATURAL JOIN or is in a
@@ -99559,10 +99734,14 @@
99559 pMatch = pItem;
99560 /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */
99561 pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;
99562 break;
99563 }
 
 
 
 
99564 }
99565 }
99566 if( pMatch ){
99567 pExpr->iTable = pMatch->iCursor;
99568 pExpr->y.pTab = pMatch->pTab;
@@ -99682,11 +99861,11 @@
99682 if( cnt==0
99683 && cntTab==1
99684 && pMatch
99685 && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0
99686 && sqlite3IsRowid(zCol)
99687 && VisibleRowid(pMatch->pTab)
99688 ){
99689 cnt = 1;
99690 pExpr->iColumn = -1;
99691 pExpr->affExpr = SQLITE_AFF_INTEGER;
99692 }
@@ -100294,13 +100473,16 @@
100294 pNC2 = pNC2->pNext;
100295 }
100296 assert( pDef!=0 || IN_RENAME_OBJECT );
100297 if( pNC2 && pDef ){
100298 assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
 
100299 testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
100300 pNC2->ncFlags |= NC_HasAgg | (pDef->funcFlags & SQLITE_FUNC_MINMAX);
100301
 
 
100302 }
100303 }
100304 pNC->ncFlags |= savedAllowFlags;
100305 }
100306 /* FIX ME: Compute pExpr->affinity based on the expected return
@@ -100839,11 +101021,11 @@
100839 assert( pSub->pPrior && pSub->pOrderBy==0 );
100840 pSub->pOrderBy = p->pOrderBy;
100841 p->pOrderBy = 0;
100842 }
100843
100844 /* Recursively resolve names in all subqueries
100845 */
100846 for(i=0; i<p->pSrc->nSrc; i++){
100847 SrcItem *pItem = &p->pSrc->a[i];
100848 if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){
100849 int nRef = pOuterNC ? pOuterNC->nRef : 0;
@@ -100883,11 +101065,12 @@
100883 */
100884 assert( (p->selFlags & SF_Aggregate)==0 );
100885 pGroupBy = p->pGroupBy;
100886 if( pGroupBy || (sNC.ncFlags & NC_HasAgg)!=0 ){
100887 assert( NC_MinMaxAgg==SF_MinMaxAgg );
100888 p->selFlags |= SF_Aggregate | (sNC.ncFlags&NC_MinMaxAgg);
 
100889 }else{
100890 sNC.ncFlags &= ~NC_AllowAgg;
100891 }
100892
100893 /* Add the output column list to the name-context before parsing the
@@ -101066,12 +101249,12 @@
101066 ){
101067 int savedHasAgg;
101068 Walker w;
101069
101070 if( pExpr==0 ) return SQLITE_OK;
101071 savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101072 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101073 w.pParse = pNC->pParse;
101074 w.xExprCallback = resolveExprStep;
101075 w.xSelectCallback = (pNC->ncFlags & NC_NoSelect) ? 0 : resolveSelectStep;
101076 w.xSelectCallback2 = 0;
101077 w.u.pNC = pNC;
@@ -101110,12 +101293,12 @@
101110 w.pParse = pNC->pParse;
101111 w.xExprCallback = resolveExprStep;
101112 w.xSelectCallback = resolveSelectStep;
101113 w.xSelectCallback2 = 0;
101114 w.u.pNC = pNC;
101115 savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101116 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101117 for(i=0; i<pList->nExpr; i++){
101118 Expr *pExpr = pList->a[i].pExpr;
101119 if( pExpr==0 ) continue;
101120 #if SQLITE_MAX_EXPR_DEPTH>0
101121 w.pParse->nHeight += pExpr->nHeight;
@@ -101129,14 +101312,15 @@
101129 #endif
101130 assert( EP_Agg==NC_HasAgg );
101131 assert( EP_Win==NC_HasWin );
101132 testcase( pNC->ncFlags & NC_HasAgg );
101133 testcase( pNC->ncFlags & NC_HasWin );
101134 if( pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin) ){
101135 ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) );
101136 savedHasAgg |= pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
101137 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin);
 
101138 }
101139 if( w.pParse->nErr>0 ) return WRC_Abort;
101140 }
101141 pNC->ncFlags |= savedHasAgg;
101142 return WRC_Continue;
@@ -101296,10 +101480,12 @@
101296 return sqlite3AffinityType(pExpr->u.zToken, 0);
101297 }
101298 #endif
101299 if( op==TK_SELECT_COLUMN ){
101300 assert( pExpr->pLeft->flags&EP_xIsSelect );
 
 
101301 return sqlite3ExprAffinity(
101302 pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
101303 );
101304 }
101305 if( op==TK_VECTOR ){
@@ -101706,11 +101892,12 @@
101706 ** of the returned TK_SELECT_COLUMN Expr object.
101707 */
101708 SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(
101709 Parse *pParse, /* Parsing context */
101710 Expr *pVector, /* The vector. List of expressions or a sub-SELECT */
101711 int iField /* Which column of the vector to return */
 
101712 ){
101713 Expr *pRet;
101714 if( pVector->op==TK_SELECT ){
101715 assert( pVector->flags & EP_xIsSelect );
101716 /* The TK_SELECT_COLUMN Expr node:
@@ -101729,14 +101916,14 @@
101729 ** with the same pLeft pointer to the pVector, but only one of them
101730 ** will own the pVector.
101731 */
101732 pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0);
101733 if( pRet ){
 
101734 pRet->iColumn = iField;
101735 pRet->pLeft = pVector;
101736 }
101737 assert( pRet==0 || pRet->iTable==0 );
101738 }else{
101739 if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;
101740 pRet = sqlite3ExprDup(pParse->db, pVector, 0);
101741 sqlite3RenameTokenRemap(pParse, pRet, pVector);
101742 }
@@ -102167,10 +102354,60 @@
102167 assert( pParse->db->mallocFailed );
102168 sqlite3SelectDelete(pParse->db, pSelect);
102169 }
102170 }
102171
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102172
102173 /*
102174 ** Join two expressions using an AND operator. If either expression is
102175 ** NULL, then just return the other expression.
102176 **
@@ -102211,11 +102448,14 @@
102211 pNew = sqlite3ExprAlloc(db, TK_FUNCTION, pToken, 1);
102212 if( pNew==0 ){
102213 sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */
102214 return 0;
102215 }
102216 if( pList && pList->nExpr > pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
 
 
 
102217 sqlite3ErrorMsg(pParse, "too many arguments on function %T", pToken);
102218 }
102219 pNew->x.pList = pList;
102220 ExprSetProperty(pNew, EP_HasFunc);
102221 assert( !ExprHasProperty(pNew, EP_xIsSelect) );
@@ -102619,11 +102859,10 @@
102619 }
102620 }else{
102621 if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
102622 if( pNew->op==TK_SELECT_COLUMN ){
102623 pNew->pLeft = p->pLeft;
102624 assert( p->iColumn==0 || p->pRight==0 );
102625 assert( p->pRight==0 || p->pRight==p->pLeft
102626 || ExprHasProperty(p->pLeft, EP_Subquery) );
102627 }else{
102628 pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
102629 }
@@ -102717,11 +102956,12 @@
102717 }
102718 SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags){
102719 ExprList *pNew;
102720 struct ExprList_item *pItem, *pOldItem;
102721 int i;
102722 Expr *pPriorSelectCol = 0;
 
102723 assert( db!=0 );
102724 if( p==0 ) return 0;
102725 pNew = sqlite3DbMallocRawNN(db, sqlite3DbMallocSize(db, p));
102726 if( pNew==0 ) return 0;
102727 pNew->nExpr = p->nExpr;
@@ -102734,21 +102974,21 @@
102734 pItem->pExpr = sqlite3ExprDup(db, pOldExpr, flags);
102735 if( pOldExpr
102736 && pOldExpr->op==TK_SELECT_COLUMN
102737 && (pNewExpr = pItem->pExpr)!=0
102738 ){
102739 assert( pNewExpr->iColumn==0 || i>0 );
102740 if( pNewExpr->iColumn==0 ){
102741 assert( pOldExpr->pLeft==pOldExpr->pRight
102742 || ExprHasProperty(pOldExpr->pLeft, EP_Subquery) );
102743 pPriorSelectCol = pNewExpr->pLeft = pNewExpr->pRight;
102744 }else{
102745 assert( i>0 );
102746 assert( pItem[-1].pExpr!=0 );
102747 assert( pNewExpr->iColumn==pItem[-1].pExpr->iColumn+1 );
102748 assert( pPriorSelectCol==pItem[-1].pExpr->pLeft );
102749 pNewExpr->pLeft = pPriorSelectCol;
 
102750 }
102751 }
102752 pItem->zEName = sqlite3DbStrDup(db, pOldItem->zEName);
102753 pItem->sortFlags = pOldItem->sortFlags;
102754 pItem->eEName = pOldItem->eEName;
@@ -103003,15 +103243,13 @@
103003 pColumns->nId, n);
103004 goto vector_append_error;
103005 }
103006
103007 for(i=0; i<pColumns->nId; i++){
103008 Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i);
103009 assert( pSubExpr!=0 || db->mallocFailed );
103010 assert( pSubExpr==0 || pSubExpr->iTable==0 );
103011 if( pSubExpr==0 ) continue;
103012 pSubExpr->iTable = pColumns->nId;
103013 pList = sqlite3ExprListAppend(pParse, pList, pSubExpr);
103014 if( pList ){
103015 assert( pList->nExpr==iFirst+i+1 );
103016 pList->a[pList->nExpr-1].zEName = pColumns->a[i].zName;
103017 pColumns->a[i].zName = 0;
@@ -105597,15 +105835,13 @@
105597 case TK_SELECT_COLUMN: {
105598 int n;
105599 if( pExpr->pLeft->iTable==0 ){
105600 pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft);
105601 }
105602 assert( pExpr->iTable==0 || pExpr->pLeft->op==TK_SELECT
105603 || pExpr->pLeft->op==TK_ERROR );
105604 if( pExpr->iTable!=0
105605 && pExpr->iTable!=(n = sqlite3ExprVectorSize(pExpr->pLeft))
105606 ){
105607 sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
105608 pExpr->iTable, n);
105609 }
105610 return pExpr->pLeft->iTable + pExpr->iColumn;
105611 }
@@ -107827,28 +108063,43 @@
107827 );
107828 sqlite3DbFree(db, zCol);
107829 db->mDbFlags = savedDbFlags;
107830 }
107831
107832 /* Make sure the schema version is at least 3. But do not upgrade
107833 ** from less than 3 to 4, as that will corrupt any preexisting DESC
107834 ** index.
107835 */
107836 v = sqlite3GetVdbe(pParse);
107837 if( v ){
 
 
 
 
107838 r1 = sqlite3GetTempReg(pParse);
107839 sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);
107840 sqlite3VdbeUsesBtree(v, iDb);
107841 sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2);
107842 sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2);
107843 VdbeCoverage(v);
107844 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3);
107845 sqlite3ReleaseTempReg(pParse, r1);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107846 }
107847
107848 /* Reload the table definition */
107849 renameReloadSchema(pParse, iDb, INITFLAG_AlterRename);
107850 }
107851
107852 /*
107853 ** This function is called by the parser after the table-name in
107854 ** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
@@ -112865,10 +113116,11 @@
112865 Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
112866 if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
112867 pMod = sqlite3PragmaVtabRegister(db, zName);
112868 }
112869 if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
 
112870 return pMod->pEpoTab;
112871 }
112872 }
112873 #endif
112874 if( flags & LOCATE_NOERR ) return 0;
@@ -115592,10 +115844,11 @@
115592 SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db){
115593 #ifndef SQLITE_OMIT_VIRTUALTABLE
115594 if( (db->flags & SQLITE_Defensive)!=0
115595 && db->pVtabCtx==0
115596 && db->nVdbeExec==0
 
115597 ){
115598 return 1;
115599 }
115600 #endif
115601 return 0;
@@ -119884,37 +120137,37 @@
119884
119885 /*
119886 ** Implementation of the changes() SQL function.
119887 **
119888 ** IMP: R-62073-11209 The changes() SQL function is a wrapper
119889 ** around the sqlite3_changes() C/C++ function and hence follows the same
119890 ** rules for counting changes.
119891 */
119892 static void changes(
119893 sqlite3_context *context,
119894 int NotUsed,
119895 sqlite3_value **NotUsed2
119896 ){
119897 sqlite3 *db = sqlite3_context_db_handle(context);
119898 UNUSED_PARAMETER2(NotUsed, NotUsed2);
119899 sqlite3_result_int(context, sqlite3_changes(db));
119900 }
119901
119902 /*
119903 ** Implementation of the total_changes() SQL function. The return value is
119904 ** the same as the sqlite3_total_changes() API function.
119905 */
119906 static void total_changes(
119907 sqlite3_context *context,
119908 int NotUsed,
119909 sqlite3_value **NotUsed2
119910 ){
119911 sqlite3 *db = sqlite3_context_db_handle(context);
119912 UNUSED_PARAMETER2(NotUsed, NotUsed2);
119913 /* IMP: R-52756-41993 This function is a wrapper around the
119914 ** sqlite3_total_changes() C/C++ interface. */
119915 sqlite3_result_int(context, sqlite3_total_changes(db));
119916 }
119917
119918 /*
119919 ** A structure defining how to do GLOB-style comparisons.
119920 */
@@ -121472,15 +121725,15 @@
121472 FUNCTION(trim, 1, 3, 0, trimFunc ),
121473 FUNCTION(trim, 2, 3, 0, trimFunc ),
121474 FUNCTION(min, -1, 0, 1, minmaxFunc ),
121475 FUNCTION(min, 0, 0, 1, 0 ),
121476 WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
121477 SQLITE_FUNC_MINMAX ),
121478 FUNCTION(max, -1, 1, 1, minmaxFunc ),
121479 FUNCTION(max, 0, 1, 1, 0 ),
121480 WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
121481 SQLITE_FUNC_MINMAX ),
121482 FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
121483 FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
121484 FUNCTION(instr, 2, 0, 0, instrFunc ),
121485 FUNCTION(printf, -1, 0, 0, printfFunc ),
121486 FUNCTION(unicode, 1, 0, 0, unicodeFunc ),
@@ -121512,13 +121765,14 @@
121512 FUNCTION(substring, 3, 0, 0, substrFunc ),
121513 WAGGREGATE(sum, 1,0,0, sumStep, sumFinalize, sumFinalize, sumInverse, 0),
121514 WAGGREGATE(total, 1,0,0, sumStep,totalFinalize,totalFinalize,sumInverse, 0),
121515 WAGGREGATE(avg, 1,0,0, sumStep, avgFinalize, avgFinalize, sumInverse, 0),
121516 WAGGREGATE(count, 0,0,0, countStep,
121517 countFinalize, countFinalize, countInverse, SQLITE_FUNC_COUNT ),
 
121518 WAGGREGATE(count, 1,0,0, countStep,
121519 countFinalize, countFinalize, countInverse, 0 ),
121520 WAGGREGATE(group_concat, 1, 0, 0, groupConcatStep,
121521 groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
121522 WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep,
121523 groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
121524
@@ -123169,11 +123423,11 @@
123169
123170 /*
123171 ** Compute the affinity string for table pTab, if it has not already been
123172 ** computed. As an optimization, omit trailing SQLITE_AFF_BLOB affinities.
123173 **
123174 ** If the affinity exists (if it is no entirely SQLITE_AFF_BLOB values) and
123175 ** if iReg>0 then code an OP_Affinity opcode that will set the affinities
123176 ** for register iReg and following. Or if affinities exists and iReg==0,
123177 ** then just set the P4 operand of the previous opcode (which should be
123178 ** an OP_MakeRecord) to the affinity string.
123179 **
@@ -126622,10 +126876,13 @@
126622 int,const char**);
126623 void (*free_filename)(char*);
126624 sqlite3_file *(*database_file_object)(const char*);
126625 /* Version 3.34.0 and later */
126626 int (*txn_state)(sqlite3*,const char*);
 
 
 
126627 };
126628
126629 /*
126630 ** This is the function signature used for all extension entry points. It
126631 ** is also defined in the file "loadext.c".
@@ -127412,10 +127669,13 @@
127412 sqlite3_create_filename,
127413 sqlite3_free_filename,
127414 sqlite3_database_file_object,
127415 /* Version 3.34.0 and later */
127416 sqlite3_txn_state,
 
 
 
127417 };
127418
127419 /* True if x is the directory separator character
127420 */
127421 #if SQLITE_OS_WIN
@@ -128201,11 +128461,11 @@
128201 /* iArg: */ 1 },
128202 #endif
128203 #if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
128204 {/* zName: */ "integrity_check",
128205 /* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
128206 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1,
128207 /* ColNames: */ 0, 0,
128208 /* iArg: */ 0 },
128209 #endif
128210 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
128211 {/* zName: */ "journal_mode",
@@ -128309,11 +128569,11 @@
128309 /* iArg: */ SQLITE_QueryOnly },
128310 #endif
128311 #if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
128312 {/* zName: */ "quick_check",
128313 /* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
128314 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1,
128315 /* ColNames: */ 0, 0,
128316 /* iArg: */ 0 },
128317 #endif
128318 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
128319 {/* zName: */ "read_uncommitted",
@@ -129912,10 +130172,11 @@
129912
129913 /* Generate code to read the child key values into registers
129914 ** regRow..regRow+n. If any of the child key values are NULL, this
129915 ** row cannot cause an FK violation. Jump directly to addrOk in
129916 ** this case. */
 
129917 for(j=0; j<pFK->nCol; j++){
129918 int iCol = aiCols ? aiCols[j] : pFK->aCol[j].iFrom;
129919 sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, iCol, regRow+j);
129920 sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); VdbeCoverage(v);
129921 }
@@ -135823,14 +136084,14 @@
135823 /*
135824 ** Assign new cursor numbers to each of the items in pSrc. For each
135825 ** new cursor number assigned, set an entry in the aCsrMap[] array
135826 ** to map the old cursor number to the new:
135827 **
135828 ** aCsrMap[iOld] = iNew;
135829 **
135830 ** The array is guaranteed by the caller to be large enough for all
135831 ** existing cursor numbers in pSrc.
135832 **
135833 ** If pSrc contains any sub-selects, call this routine recursively
135834 ** on the FROM clause of each such sub-select, with iExcept set to -1.
135835 */
135836 static void srclistRenumberCursors(
@@ -135842,33 +136103,44 @@
135842 int i;
135843 SrcItem *pItem;
135844 for(i=0, pItem=pSrc->a; i<pSrc->nSrc; i++, pItem++){
135845 if( i!=iExcept ){
135846 Select *p;
135847 if( !pItem->fg.isRecursive || aCsrMap[pItem->iCursor]==0 ){
135848 aCsrMap[pItem->iCursor] = pParse->nTab++;
 
135849 }
135850 pItem->iCursor = aCsrMap[pItem->iCursor];
135851 for(p=pItem->pSelect; p; p=p->pPrior){
135852 srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1);
135853 }
135854 }
135855 }
135856 }
 
 
 
 
 
 
 
 
 
 
 
135857
135858 /*
135859 ** Expression walker callback used by renumberCursors() to update
135860 ** Expr objects to match newly assigned cursor numbers.
135861 */
135862 static int renumberCursorsCb(Walker *pWalker, Expr *pExpr){
135863 int *aCsrMap = pWalker->u.aiCol;
135864 int op = pExpr->op;
135865 if( (op==TK_COLUMN || op==TK_IF_NULL_ROW) && aCsrMap[pExpr->iTable] ){
135866 pExpr->iTable = aCsrMap[pExpr->iTable];
135867 }
135868 if( ExprHasProperty(pExpr, EP_FromJoin) && aCsrMap[pExpr->iRightJoinTable] ){
135869 pExpr->iRightJoinTable = aCsrMap[pExpr->iRightJoinTable];
135870 }
135871 return WRC_Continue;
135872 }
135873
135874 /*
@@ -136208,11 +136480,12 @@
136208 /* Restriction (23) */
136209 if( (p->selFlags & SF_Recursive) ) return 0;
136210
136211 if( pSrc->nSrc>1 ){
136212 if( pParse->nSelect>500 ) return 0;
136213 aCsrMap = sqlite3DbMallocZero(db, pParse->nTab*sizeof(int));
 
136214 }
136215 }
136216
136217 /***** If we reach this point, flattening is permitted. *****/
136218 SELECTTRACE(1,pParse,p,("flatten %u.%p from term %d\n",
@@ -138088,12 +138361,20 @@
138088 ** within the HAVING expression with a constant "1".
138089 */
138090 static int havingToWhereExprCb(Walker *pWalker, Expr *pExpr){
138091 if( pExpr->op!=TK_AND ){
138092 Select *pS = pWalker->u.pSelect;
 
 
 
 
 
 
 
138093 if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, pS->pGroupBy)
138094 && ExprAlwaysFalse(pExpr)==0
 
138095 ){
138096 sqlite3 *db = pWalker->pParse->db;
138097 Expr *pNew = sqlite3Expr(db, TK_INTEGER, "1");
138098 if( pNew ){
138099 Expr *pWhere = pS->pWhere;
@@ -138355,15 +138636,20 @@
138355 SELECTTRACE(0x104,pParse,p, ("after name resolution:\n"));
138356 sqlite3TreeViewSelect(0, p, 0);
138357 }
138358 #endif
138359
138360 /* If the SF_UpdateFrom flag is set, then this function is being called
138361 ** as part of populating the temp table for an UPDATE...FROM statement.
138362 ** In this case, it is an error if the target object (pSrc->a[0]) name
138363 ** or alias is duplicated within FROM clause (pSrc->a[1..n]). */
138364 if( p->selFlags & SF_UpdateFrom ){
 
 
 
 
 
138365 SrcItem *p0 = &p->pSrc->a[0];
138366 for(i=1; i<p->pSrc->nSrc; i++){
138367 SrcItem *p1 = &p->pSrc->a[i];
138368 if( p0->pTab==p1->pTab && 0==sqlite3_stricmp(p0->zAlias, p1->zAlias) ){
138369 sqlite3ErrorMsg(pParse,
@@ -138371,10 +138657,16 @@
138371 p0->zAlias ? p0->zAlias : p0->pTab->zName
138372 );
138373 goto select_end;
138374 }
138375 }
 
 
 
 
 
 
138376 }
138377
138378 if( pDest->eDest==SRT_Output ){
138379 sqlite3GenerateColumnNames(pParse, p);
138380 }
@@ -138441,10 +138733,43 @@
138441 ** will be implemented as a co-routine and there is no advantage to
138442 ** flattening in that case.
138443 */
138444 if( (pSub->selFlags & SF_Aggregate)!=0 ) continue;
138445 assert( pSub->pGroupBy==0 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138446
138447 /* If the outer query contains a "complex" result set (that is,
138448 ** if the result set of the outer query uses functions or subqueries)
138449 ** and if the subquery contains an ORDER BY clause and if
138450 ** it will be implemented as a co-routine, then do not flatten. This
@@ -140596,10 +140921,11 @@
140596 memset(&sFrom, 0, sizeof(sFrom));
140597 sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0);
140598 sSelect.pSrc = &sFrom;
140599 sFrom.nSrc = 1;
140600 sFrom.a[0].pTab = pTab;
 
140601 sqlite3SelectPrep(pParse, &sSelect, 0);
140602 if( db->mallocFailed==0 && pParse->nErr==0 ){
140603 sqlite3GenerateColumnNames(pParse, &sSelect);
140604 }
140605 sqlite3ExprListDelete(db, sSelect.pEList);
@@ -141350,12 +141676,13 @@
141350 sqlite3ExprDup(db, pChanges->a[i].pExpr, 0)
141351 );
141352 }
141353 }
141354 pSelect = sqlite3SelectNew(pParse, pList,
141355 pSrc, pWhere2, pGrp, 0, pOrderBy2, SF_UpdateFrom|SF_IncludeHidden, pLimit2
141356 );
 
141357 sqlite3SelectDestInit(&dest, eDest, iEph);
141358 dest.iSDParm2 = (pPk ? pPk->nKeyCol : -1);
141359 sqlite3Select(pParse, pSelect, &dest);
141360 sqlite3SelectDelete(db, pSelect);
141361 }
@@ -142891,12 +143218,12 @@
142891 int rc = SQLITE_OK; /* Return code from service routines */
142892 Btree *pMain; /* The database being vacuumed */
142893 Btree *pTemp; /* The temporary database we vacuum into */
142894 u32 saved_mDbFlags; /* Saved value of db->mDbFlags */
142895 u64 saved_flags; /* Saved value of db->flags */
142896 int saved_nChange; /* Saved value of db->nChange */
142897 int saved_nTotalChange; /* Saved value of db->nTotalChange */
142898 u32 saved_openFlags; /* Saved value of db->openFlags */
142899 u8 saved_mTrace; /* Saved trace settings */
142900 Db *pDb = 0; /* Database to detach at end of vacuum */
142901 int isMemDb; /* True if vacuuming a :memory: database */
142902 int nRes; /* Bytes of reserved space at the end of each page */
@@ -144337,12 +144664,13 @@
144337 }
144338
144339 /*
144340 ** Check to see if virtual table module pMod can be have an eponymous
144341 ** virtual table instance. If it can, create one if one does not already
144342 ** exist. Return non-zero if the eponymous virtual table instance exists
144343 ** when this routine returns, and return zero if it does not exist.
 
144344 **
144345 ** An eponymous virtual table instance is one that is named after its
144346 ** module, and more importantly, does not require a CREATE VIRTUAL TABLE
144347 ** statement in order to come into existance. Eponymous virtual table
144348 ** instances always exist. They cannot be DROP-ed.
@@ -144377,11 +144705,10 @@
144377 rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr);
144378 if( rc ){
144379 sqlite3ErrorMsg(pParse, "%s", zErr);
144380 sqlite3DbFree(db, zErr);
144381 sqlite3VtabEponymousTableClear(db, pMod);
144382 return 0;
144383 }
144384 return 1;
144385 }
144386
144387 /*
@@ -148940,12 +149267,12 @@
148940 ){
148941 int i;
148942 for(i=0; i<nLeft; i++){
148943 int idxNew;
148944 Expr *pNew;
148945 Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i);
148946 Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i);
148947
148948 pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);
148949 transferJoinMarkings(pNew, pExpr);
148950 idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
148951 exprAnalyze(pSrc, pWC, idxNew);
@@ -154753,10 +155080,16 @@
154753 sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iTabCur);
154754 }
154755 if( (ws & WHERE_INDEXED)
154756 || ((ws & WHERE_MULTI_OR) && pLevel->u.pCovidx)
154757 ){
 
 
 
 
 
 
154758 sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);
154759 }
154760 if( pLevel->op==OP_Return ){
154761 sqlite3VdbeAddOp2(v, OP_Gosub, pLevel->p1, pLevel->addrFirst);
154762 }else{
@@ -155817,13 +156150,11 @@
155817 break;
155818 }
155819 if( bIntToNull ){
155820 int iDummy;
155821 Expr *pSub;
155822 for(pSub=pDup; ExprHasProperty(pSub, EP_Skip); pSub=pSub->pLeft){
155823 assert( pSub );
155824 }
155825 if( sqlite3ExprIsInteger(pSub, &iDummy) ){
155826 pSub->op = TK_NULL;
155827 pSub->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse);
155828 pSub->u.zToken = 0;
155829 }
@@ -155981,11 +156312,11 @@
155981 p->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
155982 if( p->pSrc ){
155983 Table *pTab2;
155984 p->pSrc->a[0].pSelect = pSub;
155985 sqlite3SrcListAssignCursors(pParse, p->pSrc);
155986 pSub->selFlags |= SF_Expanded;
155987 pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE);
155988 pSub->selFlags |= (selFlags & SF_Aggregate);
155989 if( pTab2==0 ){
155990 /* Might actually be some other kind of error, but in that case
155991 ** pParse->nErr will be set, so if SQLITE_NOMEM is set, we will get
@@ -162431,24 +162762,32 @@
162431 ** simplify to constants 0 (false) and 1 (true), respectively,
162432 ** regardless of the value of expr1.
162433 */
162434 sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy404);
162435 yymsp[-4].minor.yy404 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy376 ? "1" : "0");
162436 }else if( yymsp[-1].minor.yy70->nExpr==1 && sqlite3ExprIsConstant(yymsp[-1].minor.yy70->a[0].pExpr) ){
162437 Expr *pRHS = yymsp[-1].minor.yy70->a[0].pExpr;
162438 yymsp[-1].minor.yy70->a[0].pExpr = 0;
162439 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70);
162440 pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
162441 yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy404, pRHS);
162442 if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
162443 }else{
162444 yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0);
162445 if( yymsp[-4].minor.yy404 ){
162446 yymsp[-4].minor.yy404->x.pList = yymsp[-1].minor.yy70;
162447 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy404);
162448 }else{
162449 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70);
 
 
 
 
 
 
 
 
162450 }
162451 if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
162452 }
162453 }
162454 break;
@@ -166163,31 +166502,37 @@
166163 }
166164
166165 /*
166166 ** Return the number of changes in the most recent call to sqlite3_exec().
166167 */
166168 SQLITE_API int sqlite3_changes(sqlite3 *db){
166169 #ifdef SQLITE_ENABLE_API_ARMOR
166170 if( !sqlite3SafetyCheckOk(db) ){
166171 (void)SQLITE_MISUSE_BKPT;
166172 return 0;
166173 }
166174 #endif
166175 return db->nChange;
166176 }
 
 
 
166177
166178 /*
166179 ** Return the number of changes since the database handle was opened.
166180 */
166181 SQLITE_API int sqlite3_total_changes(sqlite3 *db){
166182 #ifdef SQLITE_ENABLE_API_ARMOR
166183 if( !sqlite3SafetyCheckOk(db) ){
166184 (void)SQLITE_MISUSE_BKPT;
166185 return 0;
166186 }
166187 #endif
166188 return db->nTotalChange;
 
 
 
166189 }
166190
166191 /*
166192 ** Close all open savepoints. This function only manipulates fields of the
166193 ** database handle object, it does not close any savepoints that may be open
@@ -166925,26 +167270,37 @@
166925 ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.
166926 **
166927 ** If SQLITE_ANY is specified, add three versions of the function
166928 ** to the hash table.
166929 */
166930 if( enc==SQLITE_UTF16 ){
166931 enc = SQLITE_UTF16NATIVE;
166932 }else if( enc==SQLITE_ANY ){
166933 int rc;
166934 rc = sqlite3CreateFunc(db, zFunctionName, nArg,
166935 (SQLITE_UTF8|extraFlags)^SQLITE_FUNC_UNSAFE,
166936 pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
166937 if( rc==SQLITE_OK ){
166938 rc = sqlite3CreateFunc(db, zFunctionName, nArg,
166939 (SQLITE_UTF16LE|extraFlags)^SQLITE_FUNC_UNSAFE,
166940 pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
166941 }
166942 if( rc!=SQLITE_OK ){
166943 return rc;
166944 }
166945 enc = SQLITE_UTF16BE;
 
 
 
 
 
 
 
 
 
 
 
166946 }
166947 #else
166948 enc = SQLITE_UTF8;
166949 #endif
166950
@@ -167037,11 +167393,11 @@
167037 }
167038 rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p,
167039 xSFunc, xStep, xFinal, xValue, xInverse, pArg
167040 );
167041 if( pArg && pArg->nRef==0 ){
167042 assert( rc!=SQLITE_OK );
167043 xDestroy(p);
167044 sqlite3_free(pArg);
167045 }
167046
167047 out:
@@ -168220,11 +168576,10 @@
168220 ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE,
168221 ** SQLITE_OPEN_PRIVATECACHE, and some reserved bits. Silently mask
168222 ** off all other flags.
168223 */
168224 flags &= ~( SQLITE_OPEN_DELETEONCLOSE |
168225 SQLITE_OPEN_EXCLUSIVE |
168226 SQLITE_OPEN_MAIN_DB |
168227 SQLITE_OPEN_TEMP_DB |
168228 SQLITE_OPEN_TRANSIENT_DB |
168229 SQLITE_OPEN_MAIN_JOURNAL |
168230 SQLITE_OPEN_TEMP_JOURNAL |
@@ -213440,10 +213795,13 @@
213440 /*
213441 ** This interface is used by the fts5vocab module.
213442 */
213443 static const char *sqlite3Fts5IterTerm(Fts5IndexIter*, int*);
213444 static int sqlite3Fts5IterNextScan(Fts5IndexIter*);
 
 
 
213445
213446
213447 /*
213448 ** Insert or remove data to or from the index. Each time a document is
213449 ** added to or removed from the index, this function is called one or more
@@ -216235,20 +216593,21 @@
216235 /* EOF */
216236 *piOff = -1;
216237 return 1;
216238 }else{
216239 i64 iOff = *piOff;
216240 int iVal;
216241 fts5FastGetVarint32(a, i, iVal);
216242 assert( iVal>=0 );
216243 if( iVal<=1 ){
216244 if( iVal==0 ){
216245 *pi = i;
216246 return 0;
216247 }
216248 fts5FastGetVarint32(a, i, iVal);
216249 iOff = ((i64)iVal) << 32;
 
216250 fts5FastGetVarint32(a, i, iVal);
216251 if( iVal<2 ){
216252 /* This is a corrupt record. So stop parsing it here. */
216253 *piOff = -1;
216254 return 1;
@@ -216256,11 +216615,11 @@
216256 *piOff = iOff + ((iVal-2) & 0x7FFFFFFF);
216257 }else{
216258 *piOff = (iOff & (i64)0x7FFFFFFF<<32)+((iOff + (iVal-2)) & 0x7FFFFFFF);
216259 }
216260 *pi = i;
216261 assert( *piOff>=iOff );
216262 return 0;
216263 }
216264 }
216265
216266
@@ -217565,10 +217924,11 @@
217565
217566 static void sqlite3Fts5ParseError(Fts5Parse *pParse, const char *zFmt, ...){
217567 va_list ap;
217568 va_start(ap, zFmt);
217569 if( pParse->rc==SQLITE_OK ){
 
217570 pParse->zErr = sqlite3_vmprintf(zFmt, ap);
217571 pParse->rc = SQLITE_ERROR;
217572 }
217573 va_end(ap);
217574 }
@@ -219574,13 +219934,12 @@
219574 Fts5ExprNode *pExpr,
219575 Fts5Colset *pColset
219576 ){
219577 Fts5Colset *pFree = pColset;
219578 if( pParse->pConfig->eDetail==FTS5_DETAIL_NONE ){
219579 pParse->rc = SQLITE_ERROR;
219580 pParse->zErr = sqlite3_mprintf(
219581 "fts5: column queries are not supported (detail=none)"
219582 );
219583 }else{
219584 fts5ParseSetColset(pParse, pExpr, pColset, &pFree);
219585 }
219586 sqlite3_free(pFree);
@@ -219750,17 +220109,14 @@
219750 Fts5ExprPhrase *pPhrase = pNear->apPhrase[0];
219751 if( pNear->nPhrase!=1
219752 || pPhrase->nTerm>1
219753 || (pPhrase->nTerm>0 && pPhrase->aTerm[0].bFirst)
219754 ){
219755 assert( pParse->rc==SQLITE_OK );
219756 pParse->rc = SQLITE_ERROR;
219757 assert( pParse->zErr==0 );
219758 pParse->zErr = sqlite3_mprintf(
219759 "fts5: %s queries are not supported (detail!=full)",
219760 pNear->nPhrase==1 ? "phrase": "NEAR"
219761 );
219762 sqlite3_free(pRet);
219763 pRet = 0;
219764 }
219765 }
219766 }else{
@@ -221873,10 +222229,26 @@
221873 }
221874
221875 static void fts5StructureRef(Fts5Structure *pStruct){
221876 pStruct->nRef++;
221877 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
221878
221879 /*
221880 ** Deserialize and return the structure record currently stored in serialized
221881 ** form within buffer pData/nData.
221882 **
@@ -230580,11 +230952,11 @@
230580 int nArg, /* Number of args */
230581 sqlite3_value **apUnused /* Function arguments */
230582 ){
230583 assert( nArg==0 );
230584 UNUSED_PARAM2(nArg, apUnused);
230585 sqlite3_result_text(pCtx, "fts5: 2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5", -1, SQLITE_TRANSIENT);
230586 }
230587
230588 /*
230589 ** Return true if zName is the extension on one of the shadow tables used
230590 ** by this module.
@@ -234476,10 +234848,11 @@
234476 sqlite3_stmt *pStmt; /* Statement holding lock on pIndex */
234477 Fts5Table *pFts5; /* Associated FTS5 table */
234478
234479 int bEof; /* True if this cursor is at EOF */
234480 Fts5IndexIter *pIter; /* Term/rowid iterator object */
 
234481
234482 int nLeTerm; /* Size of zLeTerm in bytes */
234483 char *zLeTerm; /* (term <= $zLeTerm) paramater, or NULL */
234484
234485 /* These are used by 'col' tables only */
@@ -234809,10 +235182,12 @@
234809 }
234810
234811 static void fts5VocabResetCursor(Fts5VocabCursor *pCsr){
234812 pCsr->rowid = 0;
234813 sqlite3Fts5IterClose(pCsr->pIter);
 
 
234814 pCsr->pIter = 0;
234815 sqlite3_free(pCsr->zLeTerm);
234816 pCsr->nLeTerm = -1;
234817 pCsr->zLeTerm = 0;
234818 pCsr->bEof = 0;
@@ -234886,13 +235261,15 @@
234886 ** Advance the cursor to the next row in the table.
234887 */
234888 static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
234889 Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;
234890 Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab;
234891 int rc = SQLITE_OK;
234892 int nCol = pCsr->pFts5->pConfig->nCol;
 
234893
 
 
234894 pCsr->rowid++;
234895
234896 if( pTab->eType==FTS5_VOCAB_INSTANCE ){
234897 return fts5VocabInstanceNext(pCsr);
234898 }
@@ -235062,10 +235439,13 @@
235062 }
235063
235064 if( rc==SQLITE_OK ){
235065 Fts5Index *pIndex = pCsr->pFts5->pIndex;
235066 rc = sqlite3Fts5IndexQuery(pIndex, zTerm, nTerm, f, 0, &pCsr->pIter);
 
 
 
235067 }
235068 if( rc==SQLITE_OK && eType==FTS5_VOCAB_INSTANCE ){
235069 rc = fts5VocabInstanceNewTerm(pCsr);
235070 }
235071 if( rc==SQLITE_OK && !pCsr->bEof
@@ -235506,12 +235886,8 @@
235506 }
235507 #endif /* SQLITE_CORE */
235508 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
235509
235510 /************** End of stmt.c ************************************************/
235511 #if __LINE__!=235511
235512 #undef SQLITE_SOURCE_ID
235513 #define SQLITE_SOURCE_ID "2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafaalt2"
235514 #endif
235515 /* Return the source-id for this library */
235516 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
235517 /************************** End of sqlite3.c ******************************/
235518
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.37.0. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -20,797 +20,10 @@
20 #define SQLITE_CORE 1
21 #define SQLITE_AMALGAMATION 1
22 #ifndef SQLITE_PRIVATE
23 # define SQLITE_PRIVATE static
24 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25 /************** Begin file sqliteInt.h ***************************************/
26 /*
27 ** 2001 September 15
28 **
29 ** The author disclaims copyright to this source code. In place of
@@ -1071,10 +284,21 @@
284 defined(_WIN32) && !defined(_WIN64) && \
285 defined(__MINGW_MAJOR_VERSION) && __MINGW_MAJOR_VERSION >= 4 && \
286 defined(__MSVCRT__)
287 # define _USE_32BIT_TIME_T
288 #endif
289
290 /* Optionally #include a user-defined header, whereby compilation options
291 ** may be set prior to where they take effect, but after platform setup.
292 ** If SQLITE_CUSTOM_INCLUDE=? is defined, its value names the #include
293 ** file.
294 */
295 #ifdef SQLITE_CUSTOM_INCLUDE
296 # define INC_STRINGIFY_(f) #f
297 # define INC_STRINGIFY(f) INC_STRINGIFY_(f)
298 # include INC_STRINGIFY(SQLITE_CUSTOM_INCLUDE)
299 #endif
300
301 /* The public SQLite interface. The _FILE_OFFSET_BITS macro must appear
302 ** first in QNX. Also, the _USE_32BIT_TIME_T macro must appear first for
303 ** MinGW.
304 */
@@ -1123,11 +347,34 @@
347 extern "C" {
348 #endif
349
350
351 /*
352 ** Facilitate override of interface linkage and calling conventions.
353 ** Be aware that these macros may not be used within this particular
354 ** translation of the amalgamation and its associated header file.
355 **
356 ** The SQLITE_EXTERN and SQLITE_API macros are used to instruct the
357 ** compiler that the target identifier should have external linkage.
358 **
359 ** The SQLITE_CDECL macro is used to set the calling convention for
360 ** public functions that accept a variable number of arguments.
361 **
362 ** The SQLITE_APICALL macro is used to set the calling convention for
363 ** public functions that accept a fixed number of arguments.
364 **
365 ** The SQLITE_STDCALL macro is no longer used and is now deprecated.
366 **
367 ** The SQLITE_CALLBACK macro is used to set the calling convention for
368 ** function pointers.
369 **
370 ** The SQLITE_SYSAPI macro is used to set the calling convention for
371 ** functions provided by the operating system.
372 **
373 ** Currently, the SQLITE_CDECL, SQLITE_APICALL, SQLITE_CALLBACK, and
374 ** SQLITE_SYSAPI macros are used only when building for environments
375 ** that require non-default calling conventions.
376 */
377 #ifndef SQLITE_EXTERN
378 # define SQLITE_EXTERN extern
379 #endif
380 #ifndef SQLITE_API
@@ -1203,13 +450,13 @@
450 **
451 ** See also: [sqlite3_libversion()],
452 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
453 ** [sqlite_version()] and [sqlite_source_id()].
454 */
455 #define SQLITE_VERSION "3.37.0"
456 #define SQLITE_VERSION_NUMBER 3037000
457 #define SQLITE_SOURCE_ID "2021-07-21 15:42:05 60695359dc5d3bcba68a68e1842c40f4a01650eb5af408e02fb856fd8245e16d"
458
459 /*
460 ** CAPI3REF: Run-Time Library Version Numbers
461 ** KEYWORDS: sqlite3_version sqlite3_sourceid
462 **
@@ -1596,10 +843,11 @@
843 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
844 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
845 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
846 #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
847 #define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8))
848 #define SQLITE_CANTOPEN_EXISTS (SQLITE_CANTOPEN | (7<<8))
849 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
850 #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
851 #define SQLITE_CORRUPT_INDEX (SQLITE_CORRUPT | (3<<8))
852 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
853 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
@@ -3544,15 +2792,18 @@
2792
2793 /*
2794 ** CAPI3REF: Count The Number Of Rows Modified
2795 ** METHOD: sqlite3
2796 **
2797 ** ^These functions return the number of rows modified, inserted or
2798 ** deleted by the most recently completed INSERT, UPDATE or DELETE
2799 ** statement on the database connection specified by the only parameter.
2800 ** The two functions are identical except for the type of the return value
2801 ** and that if the number of rows modified by the most recent INSERT, UPDATE
2802 ** or DELETE is greater than the maximum value supported by type "int", then
2803 ** the return value of sqlite3_changes() is undefined. ^Executing any other
2804 ** type of SQL statement does not modify the value returned by these functions.
2805 **
2806 ** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
2807 ** considered - auxiliary changes caused by [CREATE TRIGGER | triggers],
2808 ** [foreign key actions] or [REPLACE] constraint resolution are not counted.
2809 **
@@ -3597,20 +2848,25 @@
2848 ** <li> the [changes() SQL function]
2849 ** <li> the [data_version pragma]
2850 ** </ul>
2851 */
2852 SQLITE_API int sqlite3_changes(sqlite3*);
2853 SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3*);
2854
2855 /*
2856 ** CAPI3REF: Total Number Of Rows Modified
2857 ** METHOD: sqlite3
2858 **
2859 ** ^These functions return the total number of rows inserted, modified or
2860 ** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
2861 ** since the database connection was opened, including those executed as
2862 ** part of trigger programs. The two functions are identical except for the
2863 ** type of the return value and that if the number of rows modified by the
2864 ** connection exceeds the maximum value supported by type "int", then
2865 ** the return value of sqlite3_total_changes() is undefined. ^Executing
2866 ** any other type of SQL statement does not affect the value returned by
2867 ** sqlite3_total_changes().
2868 **
2869 ** ^Changes made as part of [foreign key actions] are included in the
2870 ** count, but those made as part of REPLACE constraint resolution are
2871 ** not. ^Changes to a view that are intercepted by INSTEAD OF triggers
2872 ** are not counted.
@@ -3634,10 +2890,11 @@
2890 ** <li> the [data_version pragma]
2891 ** <li> the [SQLITE_FCNTL_DATA_VERSION] [file control]
2892 ** </ul>
2893 */
2894 SQLITE_API int sqlite3_total_changes(sqlite3*);
2895 SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3*);
2896
2897 /*
2898 ** CAPI3REF: Interrupt A Long-Running Query
2899 ** METHOD: sqlite3
2900 **
@@ -4465,10 +3722,16 @@
3722 ** the default shared cache setting provided by
3723 ** [sqlite3_enable_shared_cache()].)^
3724 **
3725 ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt>
3726 ** <dd>The database filename is not allowed to be a symbolic link</dd>
3727 **
3728 ** [[OPEN_EXCLUSIVE]] ^(<dt>[SQLITE_OPEN_EXCLUSIVE]</dt>
3729 ** <dd>This flag causes the open to fail if the database file already
3730 ** exists. The open will only be success if this flag is used in combination
3731 ** with the SQLITE_OPEN_CREATE and SQLITE_OPEN_READWRITE flags and if
3732 ** the file does not previously exist.</dd>
3733 ** </dl>)^
3734 **
3735 ** If the 3rd parameter to sqlite3_open_v2() is not one of the
3736 ** required combinations shown above optionally combined with other
3737 ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]
@@ -5238,16 +4501,21 @@
4501 **
4502 ** ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P)
4503 ** are managed by SQLite and are automatically freed when the prepared
4504 ** statement is finalized.
4505 ** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
4506 ** is obtained from [sqlite3_malloc()] and must be freed by the application
4507 ** by passing it to [sqlite3_free()].
4508 **
4509 ** ^The sqlite3_normalized_sql() interface is only available if
4510 ** the [SQLITE_ENABLE_NORMALIZE] compile-time option is defined.
4511 */
4512 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
4513 SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
4514 #ifdef SQLITE_ENABLE_NORMALIZE
4515 SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
4516 #endif
4517
4518 /*
4519 ** CAPI3REF: Determine If An SQL Statement Writes The Database
4520 ** METHOD: sqlite3_stmt
4521 **
@@ -10090,12 +9358,13 @@
9358 ** that does not correspond to any valid SQLite error code, the results
9359 ** are undefined.
9360 **
9361 ** A single database handle may have at most a single write-ahead log callback
9362 ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any
9363 ** previously registered write-ahead log callback. ^The return value is
9364 ** a copy of the third parameter from the previous call, if any, or 0.
9365 ** ^Note that the [sqlite3_wal_autocheckpoint()] interface and the
9366 ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
9367 ** overwrite any prior [sqlite3_wal_hook()] settings.
9368 */
9369 SQLITE_API void *sqlite3_wal_hook(
9370 sqlite3*,
@@ -10957,10 +10226,14 @@
10226 ** if writes on the database cause it to grow larger than M bytes.
10227 **
10228 ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the
10229 ** database is currently in a read transaction or is involved in a backup
10230 ** operation.
10231 **
10232 ** It is not possible to deserialized into the TEMP database. If the
10233 ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the
10234 ** function returns SQLITE_ERROR.
10235 **
10236 ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
10237 ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
10238 ** [sqlite3_free()] is invoked on argument P prior to returning.
10239 **
@@ -13440,11 +12713,11 @@
12713 /*
12714 ** Include the configuration header output by 'configure' if we're using the
12715 ** autoconf-based build
12716 */
12717 #if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
12718 #include "config.h"
12719 #define SQLITECONFIG_H 1
12720 #endif
12721
12722 /************** Include sqliteLimit.h in the middle of sqliteInt.h ***********/
12723 /************** Begin file sqliteLimit.h *************************************/
@@ -13676,15 +12949,16 @@
12949 ** places. The following macros try to make this explicit.
12950 */
12951 #ifndef __has_extension
12952 # define __has_extension(x) 0 /* compatibility with non-clang compilers */
12953 #endif
12954 #if GCC_VERSION>=4007000 || __has_extension(c_atomic)
12955 # define SQLITE_ATOMIC_INTRINSICS 1
12956 # define AtomicLoad(PTR) __atomic_load_n((PTR),__ATOMIC_RELAXED)
12957 # define AtomicStore(PTR,VAL) __atomic_store_n((PTR),(VAL),__ATOMIC_RELAXED)
12958 #else
12959 # define SQLITE_ATOMIC_INTRINSICS 0
12960 # define AtomicLoad(PTR) (*(PTR))
12961 # define AtomicStore(PTR,VAL) (*(PTR) = (VAL))
12962 #endif
12963
12964 /*
@@ -15349,11 +14623,11 @@
14623 */
14624 #define BTREE_INTKEY 1 /* Table has only 64-bit signed integer keys */
14625 #define BTREE_BLOBKEY 2 /* Table has keys only - no data */
14626
14627 SQLITE_PRIVATE int sqlite3BtreeDropTable(Btree*, int, int*);
14628 SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree*, int, i64*);
14629 SQLITE_PRIVATE int sqlite3BtreeClearTableOfCursor(BtCursor*);
14630 SQLITE_PRIVATE int sqlite3BtreeTripAllCursors(Btree*, int, int);
14631
14632 SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);
14633 SQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
@@ -15473,16 +14747,20 @@
14747 #ifdef SQLITE_ENABLE_CURSOR_HINTS
14748 SQLITE_PRIVATE void sqlite3BtreeCursorHint(BtCursor*, int, ...);
14749 #endif
14750
14751 SQLITE_PRIVATE int sqlite3BtreeCloseCursor(BtCursor*);
14752 SQLITE_PRIVATE int sqlite3BtreeTableMoveto(
14753 BtCursor*,
 
14754 i64 intKey,
14755 int bias,
14756 int *pRes
14757 );
14758 SQLITE_PRIVATE int sqlite3BtreeIndexMoveto(
14759 BtCursor*,
14760 UnpackedRecord *pUnKey,
14761 int *pRes
14762 );
14763 SQLITE_PRIVATE int sqlite3BtreeCursorHasMoved(BtCursor*);
14764 SQLITE_PRIVATE int sqlite3BtreeCursorRestore(BtCursor*, int*);
14765 SQLITE_PRIVATE int sqlite3BtreeDelete(BtCursor*, u8 flags);
14766
@@ -17110,12 +16388,12 @@
16388 u8 mTrace; /* zero or more SQLITE_TRACE flags */
16389 u8 noSharedCache; /* True if no shared-cache backends */
16390 u8 nSqlExec; /* Number of pending OP_SqlExec opcodes */
16391 int nextPagesize; /* Pagesize after VACUUM if >0 */
16392 u32 magic; /* Magic number for detect library misuse */
16393 i64 nChange; /* Value returned by sqlite3_changes() */
16394 i64 nTotalChange; /* Value returned by sqlite3_total_changes() */
16395 int aLimit[SQLITE_N_LIMIT]; /* Limits */
16396 int nMaxSorterMmap; /* Maximum size of regions mapped by sorter */
16397 struct sqlite3InitInfo { /* Information used during initialization */
16398 Pgno newTnum; /* Rootpage of table being initialized */
16399 u8 iDb; /* Which db file is being initialized */
@@ -17320,10 +16598,12 @@
16598 #define SQLITE_SimplifyJoin 0x00002000 /* Convert LEFT JOIN to JOIN */
16599 #define SQLITE_SkipScan 0x00004000 /* Skip-scans */
16600 #define SQLITE_PropagateConst 0x00008000 /* The constant propagation opt */
16601 #define SQLITE_MinMaxOpt 0x00010000 /* The min/max optimization */
16602 #define SQLITE_SeekScan 0x00020000 /* The OP_SeekScan optimization */
16603 #define SQLITE_OmitOrderBy 0x00040000 /* Omit pointless ORDER BY */
16604 /* TH3 expects this value ^^^^^^^^^^ to be 0x40000. Coordinate any change */
16605 #define SQLITE_AllOpts 0xffffffff /* All optimizations */
16606
16607 /*
16608 ** Macros for testing whether or not optimizations are enabled or disabled.
16609 */
@@ -17399,16 +16679,17 @@
16679 ** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG. And
16680 ** SQLITE_FUNC_CONSTANT must be the same as SQLITE_DETERMINISTIC. There
16681 ** are assert() statements in the code to verify this.
16682 **
16683 ** Value constraints (enforced via assert()):
16684 ** SQLITE_FUNC_MINMAX == NC_MinMaxAgg == SF_MinMaxAgg
16685 ** SQLITE_FUNC_ANYORDER == NC_OrderAgg == SF_OrderByReqd
16686 ** SQLITE_FUNC_LENGTH == OPFLAG_LENGTHARG
16687 ** SQLITE_FUNC_TYPEOF == OPFLAG_TYPEOFARG
16688 ** SQLITE_FUNC_CONSTANT == SQLITE_DETERMINISTIC from the API
16689 ** SQLITE_FUNC_DIRECT == SQLITE_DIRECTONLY from the API
16690 ** SQLITE_FUNC_UNSAFE == SQLITE_INNOCUOUS
16691 ** SQLITE_FUNC_ENCMASK depends on SQLITE_UTF* macros in the API
16692 */
16693 #define SQLITE_FUNC_ENCMASK 0x0003 /* SQLITE_UTF8, SQLITE_UTF16BE or UTF16LE */
16694 #define SQLITE_FUNC_LIKE 0x0004 /* Candidate for the LIKE optimization */
16695 #define SQLITE_FUNC_CASE 0x0008 /* Case-sensitive LIKE-type function */
@@ -17429,10 +16710,11 @@
16710 #define SQLITE_FUNC_INTERNAL 0x00040000 /* For use by NestedParse() only */
16711 #define SQLITE_FUNC_DIRECT 0x00080000 /* Not for use in TRIGGERs or VIEWs */
16712 #define SQLITE_FUNC_SUBTYPE 0x00100000 /* Result likely to have sub-type */
16713 #define SQLITE_FUNC_UNSAFE 0x00200000 /* Function has side effects */
16714 #define SQLITE_FUNC_INLINE 0x00400000 /* Functions implemented in-line */
16715 #define SQLITE_FUNC_ANYORDER 0x08000000 /* count/min/max aggregate */
16716
16717 /* Identifier numbers for each in-line function */
16718 #define INLINEFUNC_coalesce 0
16719 #define INLINEFUNC_implies_nonnull_row 1
16720 #define INLINEFUNC_expr_implies_expr 2
@@ -18664,35 +17946,37 @@
17946
17947 /*
17948 ** Allowed values for the NameContext, ncFlags field.
17949 **
17950 ** Value constraints (all checked via assert()):
17951 ** NC_HasAgg == SF_HasAgg == EP_Agg
17952 ** NC_MinMaxAgg == SF_MinMaxAgg == SQLITE_FUNC_MINMAX
17953 ** NC_OrderAgg == SF_OrderByReqd == SQLITE_FUNC_ANYORDER
17954 ** NC_HasWin == EP_Win
17955 **
17956 */
17957 #define NC_AllowAgg 0x000001 /* Aggregate functions are allowed here */
17958 #define NC_PartIdx 0x000002 /* True if resolving a partial index WHERE */
17959 #define NC_IsCheck 0x000004 /* True if resolving a CHECK constraint */
17960 #define NC_GenCol 0x000008 /* True for a GENERATED ALWAYS AS clause */
17961 #define NC_HasAgg 0x000010 /* One or more aggregate functions seen */
17962 #define NC_IdxExpr 0x000020 /* True if resolving columns of CREATE INDEX */
17963 #define NC_SelfRef 0x00002e /* Combo: PartIdx, isCheck, GenCol, and IdxExpr */
17964 #define NC_VarSelect 0x000040 /* A correlated subquery has been seen */
17965 #define NC_UEList 0x000080 /* True if uNC.pEList is used */
17966 #define NC_UAggInfo 0x000100 /* True if uNC.pAggInfo is used */
17967 #define NC_UUpsert 0x000200 /* True if uNC.pUpsert is used */
17968 #define NC_UBaseReg 0x000400 /* True if uNC.iBaseReg is used */
17969 #define NC_MinMaxAgg 0x001000 /* min/max aggregates seen. See note above */
17970 #define NC_Complex 0x002000 /* True if a function or subquery seen */
17971 #define NC_AllowWin 0x004000 /* Window functions are allowed here */
17972 #define NC_HasWin 0x008000 /* One or more window functions seen */
17973 #define NC_IsDDL 0x010000 /* Resolving names in a CREATE statement */
17974 #define NC_InAggFunc 0x020000 /* True if analyzing arguments to an agg func */
17975 #define NC_FromDDL 0x040000 /* SQL text comes from sqlite_schema */
17976 #define NC_NoSelect 0x080000 /* Do not descend into sub-selects */
17977 #define NC_OrderAgg 0x8000000 /* Has an aggregate other than count/min/max */
17978
17979 /*
17980 ** An instance of the following object describes a single ON CONFLICT
17981 ** clause in an upsert.
17982 **
@@ -18771,13 +18055,14 @@
18055 /*
18056 ** Allowed values for Select.selFlags. The "SF" prefix stands for
18057 ** "Select Flag".
18058 **
18059 ** Value constraints (all checked via assert())
18060 ** SF_HasAgg == NC_HasAgg
18061 ** SF_MinMaxAgg == NC_MinMaxAgg == SQLITE_FUNC_MINMAX
18062 ** SF_OrderByReqd == NC_OrderAgg == SQLITE_FUNC_ANYORDER
18063 ** SF_FixedLimit == WHERE_USE_LIMIT
18064 */
18065 #define SF_Distinct 0x0000001 /* Output should be DISTINCT */
18066 #define SF_All 0x0000002 /* Includes the ALL keyword */
18067 #define SF_Resolved 0x0000004 /* Identifiers have been resolved */
18068 #define SF_Aggregate 0x0000008 /* Contains agg functions or a GROUP BY */
@@ -18798,14 +18083,15 @@
18083 #define SF_ComplexResult 0x0040000 /* Result contains subquery or function */
18084 #define SF_WhereBegin 0x0080000 /* Really a WhereBegin() call. Debug Only */
18085 #define SF_WinRewrite 0x0100000 /* Window function rewrite accomplished */
18086 #define SF_View 0x0200000 /* SELECT statement is a view */
18087 #define SF_NoopOrderBy 0x0400000 /* ORDER BY is ignored for this query */
18088 #define SF_UFSrcCheck 0x0800000 /* Check pSrc as required by UPDATE...FROM */
18089 #define SF_PushDown 0x1000000 /* SELECT has be modified by push-down opt */
18090 #define SF_MultiPart 0x2000000 /* Has multiple incompatible PARTITIONs */
18091 #define SF_CopyCte 0x4000000 /* SELECT statement is a copy of a CTE */
18092 #define SF_OrderByReqd 0x8000000 /* The ORDER BY clause may not be omitted */
18093
18094 /*
18095 ** The results of a SELECT can be distributed in several ways, as defined
18096 ** by one of the following macros. The "SRT" prefix means "SELECT Result
18097 ** Type".
@@ -19911,10 +19197,11 @@
19197 SQLITE_PRIVATE void sqlite3ExprDelete(sqlite3*, Expr*);
19198 SQLITE_PRIVATE void sqlite3ExprDeferredDelete(Parse*, Expr*);
19199 SQLITE_PRIVATE void sqlite3ExprUnmapAndDelete(Parse*, Expr*);
19200 SQLITE_PRIVATE ExprList *sqlite3ExprListAppend(Parse*,ExprList*,Expr*);
19201 SQLITE_PRIVATE ExprList *sqlite3ExprListAppendVector(Parse*,ExprList*,IdList*,Expr*);
19202 SQLITE_PRIVATE Select *sqlite3ExprListToValues(Parse*, int, ExprList*);
19203 SQLITE_PRIVATE void sqlite3ExprListSetSortOrder(ExprList*,int,int);
19204 SQLITE_PRIVATE void sqlite3ExprListSetName(Parse*,ExprList*,Token*,int);
19205 SQLITE_PRIVATE void sqlite3ExprListSetSpan(Parse*,ExprList*,const char*,const char*);
19206 SQLITE_PRIVATE void sqlite3ExprListDelete(sqlite3*, ExprList*);
19207 SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList*);
@@ -20329,11 +19616,11 @@
19616 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollate(Expr*);
19617 SQLITE_PRIVATE Expr *sqlite3ExprSkipCollateAndLikely(Expr*);
19618 SQLITE_PRIVATE int sqlite3CheckCollSeq(Parse *, CollSeq *);
19619 SQLITE_PRIVATE int sqlite3WritableSchema(sqlite3*);
19620 SQLITE_PRIVATE int sqlite3CheckObjectName(Parse*, const char*,const char*,const char*);
19621 SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *, i64);
19622 SQLITE_PRIVATE int sqlite3AddInt64(i64*,i64);
19623 SQLITE_PRIVATE int sqlite3SubInt64(i64*,i64);
19624 SQLITE_PRIVATE int sqlite3MulInt64(i64*,i64);
19625 SQLITE_PRIVATE int sqlite3AbsInt32(int);
19626 #ifdef SQLITE_ENABLE_8_3_NAMES
@@ -20779,20 +20066,807 @@
20066 #endif
20067
20068 SQLITE_PRIVATE int sqlite3ExprVectorSize(Expr *pExpr);
20069 SQLITE_PRIVATE int sqlite3ExprIsVector(Expr *pExpr);
20070 SQLITE_PRIVATE Expr *sqlite3VectorFieldSubexpr(Expr*, int);
20071 SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(Parse*,Expr*,int,int);
20072 SQLITE_PRIVATE void sqlite3VectorErrorMsg(Parse*, Expr*);
20073
20074 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
20075 SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt);
20076 #endif
20077
20078 #endif /* SQLITEINT_H */
20079
20080 /************** End of sqliteInt.h *******************************************/
20081 /************** Begin file ctime.c *******************************************/
20082 /*
20083 ** 2010 February 23
20084 **
20085 ** The author disclaims copyright to this source code. In place of
20086 ** a legal notice, here is a blessing:
20087 **
20088 ** May you do good and not evil.
20089 ** May you find forgiveness for yourself and forgive others.
20090 ** May you share freely, never taking more than you give.
20091 **
20092 *************************************************************************
20093 **
20094 ** This file implements routines used to report what compile-time options
20095 ** SQLite was built with.
20096 */
20097 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS /* IMP: R-16824-07538 */
20098
20099 /*
20100 ** Include the configuration header output by 'configure' if we're using the
20101 ** autoconf-based build
20102 */
20103 #if defined(_HAVE_SQLITE_CONFIG_H) && !defined(SQLITECONFIG_H)
20104 /* #include "config.h" */
20105 #define SQLITECONFIG_H 1
20106 #endif
20107
20108 /* These macros are provided to "stringify" the value of the define
20109 ** for those options in which the value is meaningful. */
20110 #define CTIMEOPT_VAL_(opt) #opt
20111 #define CTIMEOPT_VAL(opt) CTIMEOPT_VAL_(opt)
20112
20113 /* Like CTIMEOPT_VAL, but especially for SQLITE_DEFAULT_LOOKASIDE. This
20114 ** option requires a separate macro because legal values contain a single
20115 ** comma. e.g. (-DSQLITE_DEFAULT_LOOKASIDE="100,100") */
20116 #define CTIMEOPT_VAL2_(opt1,opt2) #opt1 "," #opt2
20117 #define CTIMEOPT_VAL2(opt) CTIMEOPT_VAL2_(opt)
20118 /* #include "sqliteInt.h" */
20119
20120 /*
20121 ** An array of names of all compile-time options. This array should
20122 ** be sorted A-Z.
20123 **
20124 ** This array looks large, but in a typical installation actually uses
20125 ** only a handful of compile-time options, so most times this array is usually
20126 ** rather short and uses little memory space.
20127 */
20128 static const char * const sqlite3azCompileOpt[] = {
20129
20130 /*
20131 ** BEGIN CODE GENERATED BY tool/mkctime.tcl
20132 */
20133 #ifdef SQLITE_32BIT_ROWID
20134 "32BIT_ROWID",
20135 #endif
20136 #ifdef SQLITE_4_BYTE_ALIGNED_MALLOC
20137 "4_BYTE_ALIGNED_MALLOC",
20138 #endif
20139 #ifdef SQLITE_64BIT_STATS
20140 "64BIT_STATS",
20141 #endif
20142 #ifdef SQLITE_ALLOW_COVERING_INDEX_SCAN
20143 # if SQLITE_ALLOW_COVERING_INDEX_SCAN != 1
20144 "ALLOW_COVERING_INDEX_SCAN=" CTIMEOPT_VAL(SQLITE_ALLOW_COVERING_INDEX_SCAN),
20145 # endif
20146 #endif
20147 #ifdef SQLITE_ALLOW_URI_AUTHORITY
20148 "ALLOW_URI_AUTHORITY",
20149 #endif
20150 #ifdef SQLITE_ATOMIC_INTRINSICS
20151 "ATOMIC_INTRINSICS=" CTIMEOPT_VAL(SQLITE_ATOMIC_INTRINSICS),
20152 #endif
20153 #ifdef SQLITE_BITMASK_TYPE
20154 "BITMASK_TYPE=" CTIMEOPT_VAL(SQLITE_BITMASK_TYPE),
20155 #endif
20156 #ifdef SQLITE_BUG_COMPATIBLE_20160819
20157 "BUG_COMPATIBLE_20160819",
20158 #endif
20159 #ifdef SQLITE_CASE_SENSITIVE_LIKE
20160 "CASE_SENSITIVE_LIKE",
20161 #endif
20162 #ifdef SQLITE_CHECK_PAGES
20163 "CHECK_PAGES",
20164 #endif
20165 #if defined(__clang__) && defined(__clang_major__)
20166 "COMPILER=clang-" CTIMEOPT_VAL(__clang_major__) "."
20167 CTIMEOPT_VAL(__clang_minor__) "."
20168 CTIMEOPT_VAL(__clang_patchlevel__),
20169 #elif defined(_MSC_VER)
20170 "COMPILER=msvc-" CTIMEOPT_VAL(_MSC_VER),
20171 #elif defined(__GNUC__) && defined(__VERSION__)
20172 "COMPILER=gcc-" __VERSION__,
20173 #endif
20174 #ifdef SQLITE_COVERAGE_TEST
20175 "COVERAGE_TEST",
20176 #endif
20177 #ifdef SQLITE_DEBUG
20178 "DEBUG",
20179 #endif
20180 #ifdef SQLITE_DEFAULT_AUTOMATIC_INDEX
20181 "DEFAULT_AUTOMATIC_INDEX",
20182 #endif
20183 #ifdef SQLITE_DEFAULT_AUTOVACUUM
20184 "DEFAULT_AUTOVACUUM",
20185 #endif
20186 #ifdef SQLITE_DEFAULT_CACHE_SIZE
20187 "DEFAULT_CACHE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_CACHE_SIZE),
20188 #endif
20189 #ifdef SQLITE_DEFAULT_CKPTFULLFSYNC
20190 "DEFAULT_CKPTFULLFSYNC",
20191 #endif
20192 #ifdef SQLITE_DEFAULT_FILE_FORMAT
20193 "DEFAULT_FILE_FORMAT=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_FORMAT),
20194 #endif
20195 #ifdef SQLITE_DEFAULT_FILE_PERMISSIONS
20196 "DEFAULT_FILE_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_FILE_PERMISSIONS),
20197 #endif
20198 #ifdef SQLITE_DEFAULT_FOREIGN_KEYS
20199 "DEFAULT_FOREIGN_KEYS",
20200 #endif
20201 #ifdef SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT
20202 "DEFAULT_JOURNAL_SIZE_LIMIT=" CTIMEOPT_VAL(SQLITE_DEFAULT_JOURNAL_SIZE_LIMIT),
20203 #endif
20204 #ifdef SQLITE_DEFAULT_LOCKING_MODE
20205 "DEFAULT_LOCKING_MODE=" CTIMEOPT_VAL(SQLITE_DEFAULT_LOCKING_MODE),
20206 #endif
20207 #ifdef SQLITE_DEFAULT_LOOKASIDE
20208 "DEFAULT_LOOKASIDE=" CTIMEOPT_VAL2(SQLITE_DEFAULT_LOOKASIDE),
20209 #endif
20210 #ifdef SQLITE_DEFAULT_MEMSTATUS
20211 # if SQLITE_DEFAULT_MEMSTATUS != 1
20212 "DEFAULT_MEMSTATUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_MEMSTATUS),
20213 # endif
20214 #endif
20215 #ifdef SQLITE_DEFAULT_MMAP_SIZE
20216 "DEFAULT_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_MMAP_SIZE),
20217 #endif
20218 #ifdef SQLITE_DEFAULT_PAGE_SIZE
20219 "DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_PAGE_SIZE),
20220 #endif
20221 #ifdef SQLITE_DEFAULT_PCACHE_INITSZ
20222 "DEFAULT_PCACHE_INITSZ=" CTIMEOPT_VAL(SQLITE_DEFAULT_PCACHE_INITSZ),
20223 #endif
20224 #ifdef SQLITE_DEFAULT_PROXYDIR_PERMISSIONS
20225 "DEFAULT_PROXYDIR_PERMISSIONS=" CTIMEOPT_VAL(SQLITE_DEFAULT_PROXYDIR_PERMISSIONS),
20226 #endif
20227 #ifdef SQLITE_DEFAULT_RECURSIVE_TRIGGERS
20228 "DEFAULT_RECURSIVE_TRIGGERS",
20229 #endif
20230 #ifdef SQLITE_DEFAULT_ROWEST
20231 "DEFAULT_ROWEST=" CTIMEOPT_VAL(SQLITE_DEFAULT_ROWEST),
20232 #endif
20233 #ifdef SQLITE_DEFAULT_SECTOR_SIZE
20234 "DEFAULT_SECTOR_SIZE=" CTIMEOPT_VAL(SQLITE_DEFAULT_SECTOR_SIZE),
20235 #endif
20236 #ifdef SQLITE_DEFAULT_SYNCHRONOUS
20237 "DEFAULT_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_SYNCHRONOUS),
20238 #endif
20239 #ifdef SQLITE_DEFAULT_WAL_AUTOCHECKPOINT
20240 "DEFAULT_WAL_AUTOCHECKPOINT=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_AUTOCHECKPOINT),
20241 #endif
20242 #ifdef SQLITE_DEFAULT_WAL_SYNCHRONOUS
20243 "DEFAULT_WAL_SYNCHRONOUS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WAL_SYNCHRONOUS),
20244 #endif
20245 #ifdef SQLITE_DEFAULT_WORKER_THREADS
20246 "DEFAULT_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_DEFAULT_WORKER_THREADS),
20247 #endif
20248 #ifdef SQLITE_DIRECT_OVERFLOW_READ
20249 "DIRECT_OVERFLOW_READ",
20250 #endif
20251 #ifdef SQLITE_DISABLE_DIRSYNC
20252 "DISABLE_DIRSYNC",
20253 #endif
20254 #ifdef SQLITE_DISABLE_FTS3_UNICODE
20255 "DISABLE_FTS3_UNICODE",
20256 #endif
20257 #ifdef SQLITE_DISABLE_FTS4_DEFERRED
20258 "DISABLE_FTS4_DEFERRED",
20259 #endif
20260 #ifdef SQLITE_DISABLE_INTRINSIC
20261 "DISABLE_INTRINSIC",
20262 #endif
20263 #ifdef SQLITE_DISABLE_LFS
20264 "DISABLE_LFS",
20265 #endif
20266 #ifdef SQLITE_DISABLE_PAGECACHE_OVERFLOW_STATS
20267 "DISABLE_PAGECACHE_OVERFLOW_STATS",
20268 #endif
20269 #ifdef SQLITE_DISABLE_SKIPAHEAD_DISTINCT
20270 "DISABLE_SKIPAHEAD_DISTINCT",
20271 #endif
20272 #ifdef SQLITE_ENABLE_8_3_NAMES
20273 "ENABLE_8_3_NAMES=" CTIMEOPT_VAL(SQLITE_ENABLE_8_3_NAMES),
20274 #endif
20275 #ifdef SQLITE_ENABLE_API_ARMOR
20276 "ENABLE_API_ARMOR",
20277 #endif
20278 #ifdef SQLITE_ENABLE_ATOMIC_WRITE
20279 "ENABLE_ATOMIC_WRITE",
20280 #endif
20281 #ifdef SQLITE_ENABLE_BATCH_ATOMIC_WRITE
20282 "ENABLE_BATCH_ATOMIC_WRITE",
20283 #endif
20284 #ifdef SQLITE_ENABLE_BYTECODE_VTAB
20285 "ENABLE_BYTECODE_VTAB",
20286 #endif
20287 #ifdef SQLITE_ENABLE_CEROD
20288 "ENABLE_CEROD=" CTIMEOPT_VAL(SQLITE_ENABLE_CEROD),
20289 #endif
20290 #ifdef SQLITE_ENABLE_COLUMN_METADATA
20291 "ENABLE_COLUMN_METADATA",
20292 #endif
20293 #ifdef SQLITE_ENABLE_COLUMN_USED_MASK
20294 "ENABLE_COLUMN_USED_MASK",
20295 #endif
20296 #ifdef SQLITE_ENABLE_COSTMULT
20297 "ENABLE_COSTMULT",
20298 #endif
20299 #ifdef SQLITE_ENABLE_CURSOR_HINTS
20300 "ENABLE_CURSOR_HINTS",
20301 #endif
20302 #ifdef SQLITE_ENABLE_DBPAGE_VTAB
20303 "ENABLE_DBPAGE_VTAB",
20304 #endif
20305 #ifdef SQLITE_ENABLE_DBSTAT_VTAB
20306 "ENABLE_DBSTAT_VTAB",
20307 #endif
20308 #ifdef SQLITE_ENABLE_EXPENSIVE_ASSERT
20309 "ENABLE_EXPENSIVE_ASSERT",
20310 #endif
20311 #ifdef SQLITE_ENABLE_EXPLAIN_COMMENTS
20312 "ENABLE_EXPLAIN_COMMENTS",
20313 #endif
20314 #ifdef SQLITE_ENABLE_FTS3
20315 "ENABLE_FTS3",
20316 #endif
20317 #ifdef SQLITE_ENABLE_FTS3_PARENTHESIS
20318 "ENABLE_FTS3_PARENTHESIS",
20319 #endif
20320 #ifdef SQLITE_ENABLE_FTS3_TOKENIZER
20321 "ENABLE_FTS3_TOKENIZER",
20322 #endif
20323 #ifdef SQLITE_ENABLE_FTS4
20324 "ENABLE_FTS4",
20325 #endif
20326 #ifdef SQLITE_ENABLE_FTS5
20327 "ENABLE_FTS5",
20328 #endif
20329 #ifdef SQLITE_ENABLE_GEOPOLY
20330 "ENABLE_GEOPOLY",
20331 #endif
20332 #ifdef SQLITE_ENABLE_HIDDEN_COLUMNS
20333 "ENABLE_HIDDEN_COLUMNS",
20334 #endif
20335 #ifdef SQLITE_ENABLE_ICU
20336 "ENABLE_ICU",
20337 #endif
20338 #ifdef SQLITE_ENABLE_IOTRACE
20339 "ENABLE_IOTRACE",
20340 #endif
20341 #ifdef SQLITE_ENABLE_JSON1
20342 "ENABLE_JSON1",
20343 #endif
20344 #ifdef SQLITE_ENABLE_LOAD_EXTENSION
20345 "ENABLE_LOAD_EXTENSION",
20346 #endif
20347 #ifdef SQLITE_ENABLE_LOCKING_STYLE
20348 "ENABLE_LOCKING_STYLE=" CTIMEOPT_VAL(SQLITE_ENABLE_LOCKING_STYLE),
20349 #endif
20350 #ifdef SQLITE_ENABLE_MATH_FUNCTIONS
20351 "ENABLE_MATH_FUNCTIONS",
20352 #endif
20353 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
20354 "ENABLE_MEMORY_MANAGEMENT",
20355 #endif
20356 #ifdef SQLITE_ENABLE_MEMSYS3
20357 "ENABLE_MEMSYS3",
20358 #endif
20359 #ifdef SQLITE_ENABLE_MEMSYS5
20360 "ENABLE_MEMSYS5",
20361 #endif
20362 #ifdef SQLITE_ENABLE_MULTIPLEX
20363 "ENABLE_MULTIPLEX",
20364 #endif
20365 #ifdef SQLITE_ENABLE_NORMALIZE
20366 "ENABLE_NORMALIZE",
20367 #endif
20368 #ifdef SQLITE_ENABLE_NULL_TRIM
20369 "ENABLE_NULL_TRIM",
20370 #endif
20371 #ifdef SQLITE_ENABLE_OFFSET_SQL_FUNC
20372 "ENABLE_OFFSET_SQL_FUNC",
20373 #endif
20374 #ifdef SQLITE_ENABLE_OVERSIZE_CELL_CHECK
20375 "ENABLE_OVERSIZE_CELL_CHECK",
20376 #endif
20377 #ifdef SQLITE_ENABLE_PREUPDATE_HOOK
20378 "ENABLE_PREUPDATE_HOOK",
20379 #endif
20380 #ifdef SQLITE_ENABLE_QPSG
20381 "ENABLE_QPSG",
20382 #endif
20383 #ifdef SQLITE_ENABLE_RBU
20384 "ENABLE_RBU",
20385 #endif
20386 #ifdef SQLITE_ENABLE_RTREE
20387 "ENABLE_RTREE",
20388 #endif
20389 #ifdef SQLITE_ENABLE_SELECTTRACE
20390 "ENABLE_SELECTTRACE",
20391 #endif
20392 #ifdef SQLITE_ENABLE_SESSION
20393 "ENABLE_SESSION",
20394 #endif
20395 #ifdef SQLITE_ENABLE_SNAPSHOT
20396 "ENABLE_SNAPSHOT",
20397 #endif
20398 #ifdef SQLITE_ENABLE_SORTER_REFERENCES
20399 "ENABLE_SORTER_REFERENCES",
20400 #endif
20401 #ifdef SQLITE_ENABLE_SQLLOG
20402 "ENABLE_SQLLOG",
20403 #endif
20404 #ifdef SQLITE_ENABLE_STAT4
20405 "ENABLE_STAT4",
20406 #endif
20407 #ifdef SQLITE_ENABLE_STMTVTAB
20408 "ENABLE_STMTVTAB",
20409 #endif
20410 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
20411 "ENABLE_STMT_SCANSTATUS",
20412 #endif
20413 #ifdef SQLITE_ENABLE_UNKNOWN_SQL_FUNCTION
20414 "ENABLE_UNKNOWN_SQL_FUNCTION",
20415 #endif
20416 #ifdef SQLITE_ENABLE_UNLOCK_NOTIFY
20417 "ENABLE_UNLOCK_NOTIFY",
20418 #endif
20419 #ifdef SQLITE_ENABLE_UPDATE_DELETE_LIMIT
20420 "ENABLE_UPDATE_DELETE_LIMIT",
20421 #endif
20422 #ifdef SQLITE_ENABLE_URI_00_ERROR
20423 "ENABLE_URI_00_ERROR",
20424 #endif
20425 #ifdef SQLITE_ENABLE_VFSTRACE
20426 "ENABLE_VFSTRACE",
20427 #endif
20428 #ifdef SQLITE_ENABLE_WHERETRACE
20429 "ENABLE_WHERETRACE",
20430 #endif
20431 #ifdef SQLITE_ENABLE_ZIPVFS
20432 "ENABLE_ZIPVFS",
20433 #endif
20434 #ifdef SQLITE_EXPLAIN_ESTIMATED_ROWS
20435 "EXPLAIN_ESTIMATED_ROWS",
20436 #endif
20437 #ifdef SQLITE_EXTRA_IFNULLROW
20438 "EXTRA_IFNULLROW",
20439 #endif
20440 #ifdef SQLITE_EXTRA_INIT
20441 "EXTRA_INIT=" CTIMEOPT_VAL(SQLITE_EXTRA_INIT),
20442 #endif
20443 #ifdef SQLITE_EXTRA_SHUTDOWN
20444 "EXTRA_SHUTDOWN=" CTIMEOPT_VAL(SQLITE_EXTRA_SHUTDOWN),
20445 #endif
20446 #ifdef SQLITE_FTS3_MAX_EXPR_DEPTH
20447 "FTS3_MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_FTS3_MAX_EXPR_DEPTH),
20448 #endif
20449 #ifdef SQLITE_FTS5_ENABLE_TEST_MI
20450 "FTS5_ENABLE_TEST_MI",
20451 #endif
20452 #ifdef SQLITE_FTS5_NO_WITHOUT_ROWID
20453 "FTS5_NO_WITHOUT_ROWID",
20454 #endif
20455 #if HAVE_ISNAN || SQLITE_HAVE_ISNAN
20456 "HAVE_ISNAN",
20457 #endif
20458 #ifdef SQLITE_HOMEGROWN_RECURSIVE_MUTEX
20459 # if SQLITE_HOMEGROWN_RECURSIVE_MUTEX != 1
20460 "HOMEGROWN_RECURSIVE_MUTEX=" CTIMEOPT_VAL(SQLITE_HOMEGROWN_RECURSIVE_MUTEX),
20461 # endif
20462 #endif
20463 #ifdef SQLITE_IGNORE_AFP_LOCK_ERRORS
20464 "IGNORE_AFP_LOCK_ERRORS",
20465 #endif
20466 #ifdef SQLITE_IGNORE_FLOCK_LOCK_ERRORS
20467 "IGNORE_FLOCK_LOCK_ERRORS",
20468 #endif
20469 #ifdef SQLITE_INLINE_MEMCPY
20470 "INLINE_MEMCPY",
20471 #endif
20472 #ifdef SQLITE_INT64_TYPE
20473 "INT64_TYPE",
20474 #endif
20475 #ifdef SQLITE_INTEGRITY_CHECK_ERROR_MAX
20476 "INTEGRITY_CHECK_ERROR_MAX=" CTIMEOPT_VAL(SQLITE_INTEGRITY_CHECK_ERROR_MAX),
20477 #endif
20478 #ifdef SQLITE_LIKE_DOESNT_MATCH_BLOBS
20479 "LIKE_DOESNT_MATCH_BLOBS",
20480 #endif
20481 #ifdef SQLITE_LOCK_TRACE
20482 "LOCK_TRACE",
20483 #endif
20484 #ifdef SQLITE_LOG_CACHE_SPILL
20485 "LOG_CACHE_SPILL",
20486 #endif
20487 #ifdef SQLITE_MALLOC_SOFT_LIMIT
20488 "MALLOC_SOFT_LIMIT=" CTIMEOPT_VAL(SQLITE_MALLOC_SOFT_LIMIT),
20489 #endif
20490 #ifdef SQLITE_MAX_ATTACHED
20491 "MAX_ATTACHED=" CTIMEOPT_VAL(SQLITE_MAX_ATTACHED),
20492 #endif
20493 #ifdef SQLITE_MAX_COLUMN
20494 "MAX_COLUMN=" CTIMEOPT_VAL(SQLITE_MAX_COLUMN),
20495 #endif
20496 #ifdef SQLITE_MAX_COMPOUND_SELECT
20497 "MAX_COMPOUND_SELECT=" CTIMEOPT_VAL(SQLITE_MAX_COMPOUND_SELECT),
20498 #endif
20499 #ifdef SQLITE_MAX_DEFAULT_PAGE_SIZE
20500 "MAX_DEFAULT_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_DEFAULT_PAGE_SIZE),
20501 #endif
20502 #ifdef SQLITE_MAX_EXPR_DEPTH
20503 "MAX_EXPR_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_EXPR_DEPTH),
20504 #endif
20505 #ifdef SQLITE_MAX_FUNCTION_ARG
20506 "MAX_FUNCTION_ARG=" CTIMEOPT_VAL(SQLITE_MAX_FUNCTION_ARG),
20507 #endif
20508 #ifdef SQLITE_MAX_LENGTH
20509 "MAX_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LENGTH),
20510 #endif
20511 #ifdef SQLITE_MAX_LIKE_PATTERN_LENGTH
20512 "MAX_LIKE_PATTERN_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_LIKE_PATTERN_LENGTH),
20513 #endif
20514 #ifdef SQLITE_MAX_MEMORY
20515 "MAX_MEMORY=" CTIMEOPT_VAL(SQLITE_MAX_MEMORY),
20516 #endif
20517 #ifdef SQLITE_MAX_MMAP_SIZE
20518 "MAX_MMAP_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE),
20519 #endif
20520 #ifdef SQLITE_MAX_MMAP_SIZE_
20521 "MAX_MMAP_SIZE_=" CTIMEOPT_VAL(SQLITE_MAX_MMAP_SIZE_),
20522 #endif
20523 #ifdef SQLITE_MAX_PAGE_COUNT
20524 "MAX_PAGE_COUNT=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_COUNT),
20525 #endif
20526 #ifdef SQLITE_MAX_PAGE_SIZE
20527 "MAX_PAGE_SIZE=" CTIMEOPT_VAL(SQLITE_MAX_PAGE_SIZE),
20528 #endif
20529 #ifdef SQLITE_MAX_SCHEMA_RETRY
20530 "MAX_SCHEMA_RETRY=" CTIMEOPT_VAL(SQLITE_MAX_SCHEMA_RETRY),
20531 #endif
20532 #ifdef SQLITE_MAX_SQL_LENGTH
20533 "MAX_SQL_LENGTH=" CTIMEOPT_VAL(SQLITE_MAX_SQL_LENGTH),
20534 #endif
20535 #ifdef SQLITE_MAX_TRIGGER_DEPTH
20536 "MAX_TRIGGER_DEPTH=" CTIMEOPT_VAL(SQLITE_MAX_TRIGGER_DEPTH),
20537 #endif
20538 #ifdef SQLITE_MAX_VARIABLE_NUMBER
20539 "MAX_VARIABLE_NUMBER=" CTIMEOPT_VAL(SQLITE_MAX_VARIABLE_NUMBER),
20540 #endif
20541 #ifdef SQLITE_MAX_VDBE_OP
20542 "MAX_VDBE_OP=" CTIMEOPT_VAL(SQLITE_MAX_VDBE_OP),
20543 #endif
20544 #ifdef SQLITE_MAX_WORKER_THREADS
20545 "MAX_WORKER_THREADS=" CTIMEOPT_VAL(SQLITE_MAX_WORKER_THREADS),
20546 #endif
20547 #ifdef SQLITE_MEMDEBUG
20548 "MEMDEBUG",
20549 #endif
20550 #ifdef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
20551 "MIXED_ENDIAN_64BIT_FLOAT",
20552 #endif
20553 #ifdef SQLITE_MMAP_READWRITE
20554 "MMAP_READWRITE",
20555 #endif
20556 #ifdef SQLITE_MUTEX_NOOP
20557 "MUTEX_NOOP",
20558 #endif
20559 #ifdef SQLITE_MUTEX_OMIT
20560 "MUTEX_OMIT",
20561 #endif
20562 #ifdef SQLITE_MUTEX_PTHREADS
20563 "MUTEX_PTHREADS",
20564 #endif
20565 #ifdef SQLITE_MUTEX_W32
20566 "MUTEX_W32",
20567 #endif
20568 #ifdef SQLITE_NEED_ERR_NAME
20569 "NEED_ERR_NAME",
20570 #endif
20571 #ifdef SQLITE_NO_SYNC
20572 "NO_SYNC",
20573 #endif
20574 #ifdef SQLITE_OMIT_ALTERTABLE
20575 "OMIT_ALTERTABLE",
20576 #endif
20577 #ifdef SQLITE_OMIT_ANALYZE
20578 "OMIT_ANALYZE",
20579 #endif
20580 #ifdef SQLITE_OMIT_ATTACH
20581 "OMIT_ATTACH",
20582 #endif
20583 #ifdef SQLITE_OMIT_AUTHORIZATION
20584 "OMIT_AUTHORIZATION",
20585 #endif
20586 #ifdef SQLITE_OMIT_AUTOINCREMENT
20587 "OMIT_AUTOINCREMENT",
20588 #endif
20589 #ifdef SQLITE_OMIT_AUTOINIT
20590 "OMIT_AUTOINIT",
20591 #endif
20592 #ifdef SQLITE_OMIT_AUTOMATIC_INDEX
20593 "OMIT_AUTOMATIC_INDEX",
20594 #endif
20595 #ifdef SQLITE_OMIT_AUTORESET
20596 "OMIT_AUTORESET",
20597 #endif
20598 #ifdef SQLITE_OMIT_AUTOVACUUM
20599 "OMIT_AUTOVACUUM",
20600 #endif
20601 #ifdef SQLITE_OMIT_BETWEEN_OPTIMIZATION
20602 "OMIT_BETWEEN_OPTIMIZATION",
20603 #endif
20604 #ifdef SQLITE_OMIT_BLOB_LITERAL
20605 "OMIT_BLOB_LITERAL",
20606 #endif
20607 #ifdef SQLITE_OMIT_CAST
20608 "OMIT_CAST",
20609 #endif
20610 #ifdef SQLITE_OMIT_CHECK
20611 "OMIT_CHECK",
20612 #endif
20613 #ifdef SQLITE_OMIT_COMPLETE
20614 "OMIT_COMPLETE",
20615 #endif
20616 #ifdef SQLITE_OMIT_COMPOUND_SELECT
20617 "OMIT_COMPOUND_SELECT",
20618 #endif
20619 #ifdef SQLITE_OMIT_CONFLICT_CLAUSE
20620 "OMIT_CONFLICT_CLAUSE",
20621 #endif
20622 #ifdef SQLITE_OMIT_CTE
20623 "OMIT_CTE",
20624 #endif
20625 #if defined(SQLITE_OMIT_DATETIME_FUNCS) || defined(SQLITE_OMIT_FLOATING_POINT)
20626 "OMIT_DATETIME_FUNCS",
20627 #endif
20628 #ifdef SQLITE_OMIT_DECLTYPE
20629 "OMIT_DECLTYPE",
20630 #endif
20631 #ifdef SQLITE_OMIT_DEPRECATED
20632 "OMIT_DEPRECATED",
20633 #endif
20634 #ifdef SQLITE_OMIT_DESERIALIZE
20635 "OMIT_DESERIALIZE",
20636 #endif
20637 #ifdef SQLITE_OMIT_DISKIO
20638 "OMIT_DISKIO",
20639 #endif
20640 #ifdef SQLITE_OMIT_EXPLAIN
20641 "OMIT_EXPLAIN",
20642 #endif
20643 #ifdef SQLITE_OMIT_FLAG_PRAGMAS
20644 "OMIT_FLAG_PRAGMAS",
20645 #endif
20646 #ifdef SQLITE_OMIT_FLOATING_POINT
20647 "OMIT_FLOATING_POINT",
20648 #endif
20649 #ifdef SQLITE_OMIT_FOREIGN_KEY
20650 "OMIT_FOREIGN_KEY",
20651 #endif
20652 #ifdef SQLITE_OMIT_GET_TABLE
20653 "OMIT_GET_TABLE",
20654 #endif
20655 #ifdef SQLITE_OMIT_HEX_INTEGER
20656 "OMIT_HEX_INTEGER",
20657 #endif
20658 #ifdef SQLITE_OMIT_INCRBLOB
20659 "OMIT_INCRBLOB",
20660 #endif
20661 #ifdef SQLITE_OMIT_INTEGRITY_CHECK
20662 "OMIT_INTEGRITY_CHECK",
20663 #endif
20664 #ifdef SQLITE_OMIT_INTROSPECTION_PRAGMAS
20665 "OMIT_INTROSPECTION_PRAGMAS",
20666 #endif
20667 #ifdef SQLITE_OMIT_LIKE_OPTIMIZATION
20668 "OMIT_LIKE_OPTIMIZATION",
20669 #endif
20670 #ifdef SQLITE_OMIT_LOAD_EXTENSION
20671 "OMIT_LOAD_EXTENSION",
20672 #endif
20673 #ifdef SQLITE_OMIT_LOCALTIME
20674 "OMIT_LOCALTIME",
20675 #endif
20676 #ifdef SQLITE_OMIT_LOOKASIDE
20677 "OMIT_LOOKASIDE",
20678 #endif
20679 #ifdef SQLITE_OMIT_MEMORYDB
20680 "OMIT_MEMORYDB",
20681 #endif
20682 #ifdef SQLITE_OMIT_OR_OPTIMIZATION
20683 "OMIT_OR_OPTIMIZATION",
20684 #endif
20685 #ifdef SQLITE_OMIT_PAGER_PRAGMAS
20686 "OMIT_PAGER_PRAGMAS",
20687 #endif
20688 #ifdef SQLITE_OMIT_PARSER_TRACE
20689 "OMIT_PARSER_TRACE",
20690 #endif
20691 #ifdef SQLITE_OMIT_POPEN
20692 "OMIT_POPEN",
20693 #endif
20694 #ifdef SQLITE_OMIT_PRAGMA
20695 "OMIT_PRAGMA",
20696 #endif
20697 #ifdef SQLITE_OMIT_PROGRESS_CALLBACK
20698 "OMIT_PROGRESS_CALLBACK",
20699 #endif
20700 #ifdef SQLITE_OMIT_QUICKBALANCE
20701 "OMIT_QUICKBALANCE",
20702 #endif
20703 #ifdef SQLITE_OMIT_REINDEX
20704 "OMIT_REINDEX",
20705 #endif
20706 #ifdef SQLITE_OMIT_SCHEMA_PRAGMAS
20707 "OMIT_SCHEMA_PRAGMAS",
20708 #endif
20709 #ifdef SQLITE_OMIT_SCHEMA_VERSION_PRAGMAS
20710 "OMIT_SCHEMA_VERSION_PRAGMAS",
20711 #endif
20712 #ifdef SQLITE_OMIT_SHARED_CACHE
20713 "OMIT_SHARED_CACHE",
20714 #endif
20715 #ifdef SQLITE_OMIT_SHUTDOWN_DIRECTORIES
20716 "OMIT_SHUTDOWN_DIRECTORIES",
20717 #endif
20718 #ifdef SQLITE_OMIT_SUBQUERY
20719 "OMIT_SUBQUERY",
20720 #endif
20721 #ifdef SQLITE_OMIT_TCL_VARIABLE
20722 "OMIT_TCL_VARIABLE",
20723 #endif
20724 #ifdef SQLITE_OMIT_TEMPDB
20725 "OMIT_TEMPDB",
20726 #endif
20727 #ifdef SQLITE_OMIT_TEST_CONTROL
20728 "OMIT_TEST_CONTROL",
20729 #endif
20730 #ifdef SQLITE_OMIT_TRACE
20731 # if SQLITE_OMIT_TRACE != 1
20732 "OMIT_TRACE=" CTIMEOPT_VAL(SQLITE_OMIT_TRACE),
20733 # endif
20734 #endif
20735 #ifdef SQLITE_OMIT_TRIGGER
20736 "OMIT_TRIGGER",
20737 #endif
20738 #ifdef SQLITE_OMIT_TRUNCATE_OPTIMIZATION
20739 "OMIT_TRUNCATE_OPTIMIZATION",
20740 #endif
20741 #ifdef SQLITE_OMIT_UTF16
20742 "OMIT_UTF16",
20743 #endif
20744 #ifdef SQLITE_OMIT_VACUUM
20745 "OMIT_VACUUM",
20746 #endif
20747 #ifdef SQLITE_OMIT_VIEW
20748 "OMIT_VIEW",
20749 #endif
20750 #ifdef SQLITE_OMIT_VIRTUALTABLE
20751 "OMIT_VIRTUALTABLE",
20752 #endif
20753 #ifdef SQLITE_OMIT_WAL
20754 "OMIT_WAL",
20755 #endif
20756 #ifdef SQLITE_OMIT_WSD
20757 "OMIT_WSD",
20758 #endif
20759 #ifdef SQLITE_OMIT_XFER_OPT
20760 "OMIT_XFER_OPT",
20761 #endif
20762 #ifdef SQLITE_PCACHE_SEPARATE_HEADER
20763 "PCACHE_SEPARATE_HEADER",
20764 #endif
20765 #ifdef SQLITE_PERFORMANCE_TRACE
20766 "PERFORMANCE_TRACE",
20767 #endif
20768 #ifdef SQLITE_POWERSAFE_OVERWRITE
20769 # if SQLITE_POWERSAFE_OVERWRITE != 1
20770 "POWERSAFE_OVERWRITE=" CTIMEOPT_VAL(SQLITE_POWERSAFE_OVERWRITE),
20771 # endif
20772 #endif
20773 #ifdef SQLITE_PREFER_PROXY_LOCKING
20774 "PREFER_PROXY_LOCKING",
20775 #endif
20776 #ifdef SQLITE_PROXY_DEBUG
20777 "PROXY_DEBUG",
20778 #endif
20779 #ifdef SQLITE_REVERSE_UNORDERED_SELECTS
20780 "REVERSE_UNORDERED_SELECTS",
20781 #endif
20782 #ifdef SQLITE_RTREE_INT_ONLY
20783 "RTREE_INT_ONLY",
20784 #endif
20785 #ifdef SQLITE_SECURE_DELETE
20786 "SECURE_DELETE",
20787 #endif
20788 #ifdef SQLITE_SMALL_STACK
20789 "SMALL_STACK",
20790 #endif
20791 #ifdef SQLITE_SORTER_PMASZ
20792 "SORTER_PMASZ=" CTIMEOPT_VAL(SQLITE_SORTER_PMASZ),
20793 #endif
20794 #ifdef SQLITE_SOUNDEX
20795 "SOUNDEX",
20796 #endif
20797 #ifdef SQLITE_STAT4_SAMPLES
20798 "STAT4_SAMPLES=" CTIMEOPT_VAL(SQLITE_STAT4_SAMPLES),
20799 #endif
20800 #ifdef SQLITE_STMTJRNL_SPILL
20801 "STMTJRNL_SPILL=" CTIMEOPT_VAL(SQLITE_STMTJRNL_SPILL),
20802 #endif
20803 #ifdef SQLITE_SUBSTR_COMPATIBILITY
20804 "SUBSTR_COMPATIBILITY",
20805 #endif
20806 #if (!defined(SQLITE_WIN32_MALLOC) \
20807 && !defined(SQLITE_ZERO_MALLOC) \
20808 && !defined(SQLITE_MEMDEBUG) \
20809 ) || defined(SQLITE_SYSTEM_MALLOC)
20810 "SYSTEM_MALLOC",
20811 #endif
20812 #ifdef SQLITE_TCL
20813 "TCL",
20814 #endif
20815 #ifdef SQLITE_TEMP_STORE
20816 "TEMP_STORE=" CTIMEOPT_VAL(SQLITE_TEMP_STORE),
20817 #endif
20818 #ifdef SQLITE_TEST
20819 "TEST",
20820 #endif
20821 #if defined(SQLITE_THREADSAFE)
20822 "THREADSAFE=" CTIMEOPT_VAL(SQLITE_THREADSAFE),
20823 #elif defined(THREADSAFE)
20824 "THREADSAFE=" CTIMEOPT_VAL(THREADSAFE),
20825 #else
20826 "THREADSAFE=1",
20827 #endif
20828 #ifdef SQLITE_UNLINK_AFTER_CLOSE
20829 "UNLINK_AFTER_CLOSE",
20830 #endif
20831 #ifdef SQLITE_UNTESTABLE
20832 "UNTESTABLE",
20833 #endif
20834 #ifdef SQLITE_USER_AUTHENTICATION
20835 "USER_AUTHENTICATION",
20836 #endif
20837 #ifdef SQLITE_USE_ALLOCA
20838 "USE_ALLOCA",
20839 #endif
20840 #ifdef SQLITE_USE_FCNTL_TRACE
20841 "USE_FCNTL_TRACE",
20842 #endif
20843 #ifdef SQLITE_USE_URI
20844 "USE_URI",
20845 #endif
20846 #ifdef SQLITE_VDBE_COVERAGE
20847 "VDBE_COVERAGE",
20848 #endif
20849 #ifdef SQLITE_WIN32_MALLOC
20850 "WIN32_MALLOC",
20851 #endif
20852 #ifdef SQLITE_ZERO_MALLOC
20853 "ZERO_MALLOC",
20854 #endif
20855 /*
20856 ** END CODE GENERATED BY tool/mkctime.tcl
20857 */
20858 };
20859
20860 SQLITE_PRIVATE const char **sqlite3CompileOptions(int *pnOpt){
20861 *pnOpt = sizeof(sqlite3azCompileOpt) / sizeof(sqlite3azCompileOpt[0]);
20862 return (const char**)sqlite3azCompileOpt;
20863 }
20864
20865 #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */
20866
20867 /************** End of ctime.c ***********************************************/
20868 /************** Begin file global.c ******************************************/
20869 /*
20870 ** 2008 June 13
20871 **
20872 ** The author disclaims copyright to this source code. In place of
@@ -21342,12 +21416,12 @@
21416 int pc; /* Program Counter in parent (calling) frame */
21417 int nOp; /* Size of aOp array */
21418 int nMem; /* Number of entries in aMem */
21419 int nChildMem; /* Number of memory cells for child frame */
21420 int nChildCsr; /* Number of cursors for child frame */
21421 i64 nChange; /* Statement changes (Vdbe.nChange) */
21422 i64 nDbChange; /* Value of db->nChange */
21423 };
21424
21425 /* Magic number for sanity checking on VdbeFrame objects */
21426 #define SQLITE_FRAME_MAGIC 0x879fb71e
21427
@@ -21550,11 +21624,11 @@
21624 int nMem; /* Number of memory locations currently allocated */
21625 int nCursor; /* Number of slots in apCsr[] */
21626 u32 cacheCtr; /* VdbeCursor row cache generation counter */
21627 int pc; /* The program counter */
21628 int rc; /* Value to return */
21629 i64 nChange; /* Number of db changes made since last reset */
21630 int iStatement; /* Statement number (or 0 if has no opened stmt) */
21631 i64 iCurrentTime; /* Value of julianday('now') for this statement */
21632 i64 nFkConstraint; /* Number of imm. FK constraints this VM */
21633 i64 nStmtDefCons; /* Number of def. constraints when stmt started */
21634 i64 nStmtDefImmCons; /* Number of def. imm constraints when stmt started */
@@ -21695,10 +21769,11 @@
21769 SQLITE_PRIVATE int sqlite3VdbeMemIsRowSet(const Mem*);
21770 #endif
21771 SQLITE_PRIVATE int sqlite3VdbeMemSetRowSet(Mem*);
21772 SQLITE_PRIVATE int sqlite3VdbeMemMakeWriteable(Mem*);
21773 SQLITE_PRIVATE int sqlite3VdbeMemStringify(Mem*, u8, u8);
21774 SQLITE_PRIVATE int sqlite3IntFloatCompare(i64,double);
21775 SQLITE_PRIVATE i64 sqlite3VdbeIntValue(Mem*);
21776 SQLITE_PRIVATE int sqlite3VdbeMemIntegerify(Mem*);
21777 SQLITE_PRIVATE double sqlite3VdbeRealValue(Mem*);
21778 SQLITE_PRIVATE int sqlite3VdbeBooleanValue(Mem*, int ifNull);
21779 SQLITE_PRIVATE void sqlite3VdbeIntegerAffinity(Mem*);
@@ -30077,10 +30152,12 @@
30152 sqlite3_str_appendf(&x, " tab=%Q nCol=%d ptr=%p used=%llx",
30153 pItem->pTab->zName, pItem->pTab->nCol, pItem->pTab, pItem->colUsed);
30154 }
30155 if( pItem->fg.jointype & JT_LEFT ){
30156 sqlite3_str_appendf(&x, " LEFT-JOIN");
30157 }else if( pItem->fg.jointype & JT_CROSS ){
30158 sqlite3_str_appendf(&x, " CROSS-JOIN");
30159 }
30160 if( pItem->fg.fromDDL ){
30161 sqlite3_str_appendf(&x, " DDL");
30162 }
30163 if( pItem->fg.isCte ){
@@ -30632,11 +30709,13 @@
30709 sqlite3TreeViewBareExprList(pView, pExpr->x.pList, z);
30710 sqlite3_free(z);
30711 break;
30712 }
30713 case TK_SELECT_COLUMN: {
30714 sqlite3TreeViewLine(pView, "SELECT-COLUMN %d of [0..%d]%s",
30715 pExpr->iColumn, pExpr->iTable-1,
30716 pExpr->pRight==pExpr->pLeft ? " (SELECT-owner)" : "");
30717 sqlite3TreeViewSelect(pView, pExpr->pLeft->x.pSelect, 0);
30718 break;
30719 }
30720 case TK_IF_NULL_ROW: {
30721 sqlite3TreeViewLine(pView, "IF-NULL-ROW %d", pExpr->iTable);
@@ -30648,10 +30727,19 @@
30727 sqlite3TreeViewLine(pView, "ERROR");
30728 tmp = *pExpr;
30729 tmp.op = pExpr->op2;
30730 sqlite3TreeViewExpr(pView, &tmp, 0);
30731 break;
30732 }
30733 case TK_ROW: {
30734 if( pExpr->iColumn<=0 ){
30735 sqlite3TreeViewLine(pView, "First FROM table rowid");
30736 }else{
30737 sqlite3TreeViewLine(pView, "First FROM table column %d",
30738 pExpr->iColumn-1);
30739 }
30740 break;
30741 }
30742 default: {
30743 sqlite3TreeViewLine(pView, "op=%d", pExpr->op);
30744 break;
30745 }
@@ -40241,10 +40329,12 @@
40329 if( fd<0 ){
40330 if( isNewJrnl && errno==EACCES && osAccess(zName, F_OK) ){
40331 /* If unable to create a journal because the directory is not
40332 ** writable, change the error code to indicate that. */
40333 rc = SQLITE_READONLY_DIRECTORY;
40334 }else if( errno==EEXIST ){
40335 rc = SQLITE_CANTOPEN_EXISTS;
40336 }else if( errno!=EISDIR && isReadWrite ){
40337 /* Failed to open the file for read/write access. Try read-only. */
40338 flags &= ~(SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE);
40339 openFlags &= ~(O_RDWR|O_CREAT);
40340 flags |= SQLITE_OPEN_READONLY;
@@ -49327,11 +49417,12 @@
49417 #endif
49418
49419 sqlite3_mutex_enter(db->mutex);
49420 if( zSchema==0 ) zSchema = db->aDb[0].zDbSName;
49421 iDb = sqlite3FindDbName(db, zSchema);
49422 testcase( iDb==1 );
49423 if( iDb<2 && iDb!=0 ){
49424 rc = SQLITE_ERROR;
49425 goto end_deserialize;
49426 }
49427 zSql = sqlite3_mprintf("ATTACH x AS %Q", zSchema);
49428 if( zSql==0 ){
@@ -66277,19 +66368,17 @@
66368 pIdxKey = sqlite3VdbeAllocUnpackedRecord(pKeyInfo);
66369 if( pIdxKey==0 ) return SQLITE_NOMEM_BKPT;
66370 sqlite3VdbeRecordUnpack(pKeyInfo, (int)nKey, pKey, pIdxKey);
66371 if( pIdxKey->nField==0 || pIdxKey->nField>pKeyInfo->nAllField ){
66372 rc = SQLITE_CORRUPT_BKPT;
66373 }else{
66374 rc = sqlite3BtreeIndexMoveto(pCur, pIdxKey, pRes);
66375 }
66376 sqlite3DbFree(pCur->pKeyInfo->db, pIdxKey);
66377 }else{
66378 pIdxKey = 0;
66379 rc = sqlite3BtreeTableMoveto(pCur, nKey, bias, pRes);
 
 
 
 
66380 }
66381 return rc;
66382 }
66383
66384 /*
@@ -67134,11 +67223,11 @@
67223 u8 *pSpace = pageFindSlot(pPage, nByte, &rc);
67224 if( pSpace ){
67225 int g2;
67226 assert( pSpace+nByte<=data+pPage->pBt->usableSize );
67227 *pIdx = g2 = (int)(pSpace-data);
67228 if( g2<=gap ){
67229 return SQLITE_CORRUPT_PAGE(pPage);
67230 }else{
67231 return SQLITE_OK;
67232 }
67233 }else if( rc ){
@@ -70871,16 +70960,12 @@
70960 rc = SQLITE_OK;
70961 }
70962 return rc;
70963 }
70964
70965 /* Move the cursor so that it points to an entry in a table (a.k.a INTKEY)
70966 ** table near the key intKey. Return a success code.
 
 
 
 
70967 **
70968 ** If an exact match is not found, then the cursor is always
70969 ** left pointing at a leaf page which would hold the entry if it
70970 ** were present. The cursor might point to an entry that comes
70971 ** before or after the key.
@@ -70889,43 +70974,36 @@
70974 ** comparing the key with the entry to which the cursor is
70975 ** pointing. The meaning of the integer written into
70976 ** *pRes is as follows:
70977 **
70978 ** *pRes<0 The cursor is left pointing at an entry that
70979 ** is smaller than intKey or if the table is empty
70980 ** and the cursor is therefore left point to nothing.
70981 **
70982 ** *pRes==0 The cursor is left pointing at an entry that
70983 ** exactly matches intKey.
70984 **
70985 ** *pRes>0 The cursor is left pointing at an entry that
70986 ** is larger than intKey.
 
 
 
70987 */
70988 SQLITE_PRIVATE int sqlite3BtreeTableMoveto(
70989 BtCursor *pCur, /* The cursor to be moved */
 
70990 i64 intKey, /* The table key */
70991 int biasRight, /* If true, bias the search to the high end */
70992 int *pRes /* Write search results here */
70993 ){
70994 int rc;
 
70995
70996 assert( cursorOwnsBtShared(pCur) );
70997 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
70998 assert( pRes );
70999 assert( pCur->pKeyInfo==0 );
71000 assert( pCur->eState!=CURSOR_VALID || pCur->curIntKey!=0 );
71001
71002 /* If the cursor is already positioned at the point we are trying
71003 ** to move to, then just return without doing any work */
71004 if( pCur->eState==CURSOR_VALID && (pCur->curFlags & BTCF_ValidNKey)!=0 ){
 
 
71005 if( pCur->info.nKey==intKey ){
71006 *pRes = 0;
71007 return SQLITE_OK;
71008 }
71009 if( pCur->info.nKey<intKey ){
@@ -70956,20 +71034,153 @@
71034
71035 #ifdef SQLITE_DEBUG
71036 pCur->pBtree->nSeek++; /* Performance measurement during testing */
71037 #endif
71038
71039 rc = moveToRoot(pCur);
71040 if( rc ){
71041 if( rc==SQLITE_EMPTY ){
71042 assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );
71043 *pRes = -1;
71044 return SQLITE_OK;
71045 }
71046 return rc;
71047 }
71048 assert( pCur->pPage );
71049 assert( pCur->pPage->isInit );
71050 assert( pCur->eState==CURSOR_VALID );
71051 assert( pCur->pPage->nCell > 0 );
71052 assert( pCur->iPage==0 || pCur->apPage[0]->intKey==pCur->curIntKey );
71053 assert( pCur->curIntKey );
71054
71055 for(;;){
71056 int lwr, upr, idx, c;
71057 Pgno chldPg;
71058 MemPage *pPage = pCur->pPage;
71059 u8 *pCell; /* Pointer to current cell in pPage */
71060
71061 /* pPage->nCell must be greater than zero. If this is the root-page
71062 ** the cursor would have been INVALID above and this for(;;) loop
71063 ** not run. If this is not the root-page, then the moveToChild() routine
71064 ** would have already detected db corruption. Similarly, pPage must
71065 ** be the right kind (index or table) of b-tree page. Otherwise
71066 ** a moveToChild() or moveToRoot() call would have detected corruption. */
71067 assert( pPage->nCell>0 );
71068 assert( pPage->intKey );
71069 lwr = 0;
71070 upr = pPage->nCell-1;
71071 assert( biasRight==0 || biasRight==1 );
71072 idx = upr>>(1-biasRight); /* idx = biasRight ? upr : (lwr+upr)/2; */
71073 pCur->ix = (u16)idx;
71074 for(;;){
71075 i64 nCellKey;
71076 pCell = findCellPastPtr(pPage, idx);
71077 if( pPage->intKeyLeaf ){
71078 while( 0x80 <= *(pCell++) ){
71079 if( pCell>=pPage->aDataEnd ){
71080 return SQLITE_CORRUPT_PAGE(pPage);
71081 }
71082 }
71083 }
71084 getVarint(pCell, (u64*)&nCellKey);
71085 if( nCellKey<intKey ){
71086 lwr = idx+1;
71087 if( lwr>upr ){ c = -1; break; }
71088 }else if( nCellKey>intKey ){
71089 upr = idx-1;
71090 if( lwr>upr ){ c = +1; break; }
71091 }else{
71092 assert( nCellKey==intKey );
71093 pCur->ix = (u16)idx;
71094 if( !pPage->leaf ){
71095 lwr = idx;
71096 goto moveto_table_next_layer;
71097 }else{
71098 pCur->curFlags |= BTCF_ValidNKey;
71099 pCur->info.nKey = nCellKey;
71100 pCur->info.nSize = 0;
71101 *pRes = 0;
71102 return SQLITE_OK;
71103 }
71104 }
71105 assert( lwr+upr>=0 );
71106 idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2; */
71107 }
71108 assert( lwr==upr+1 || !pPage->leaf );
71109 assert( pPage->isInit );
71110 if( pPage->leaf ){
71111 assert( pCur->ix<pCur->pPage->nCell );
71112 pCur->ix = (u16)idx;
71113 *pRes = c;
71114 rc = SQLITE_OK;
71115 goto moveto_table_finish;
71116 }
71117 moveto_table_next_layer:
71118 if( lwr>=pPage->nCell ){
71119 chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]);
71120 }else{
71121 chldPg = get4byte(findCell(pPage, lwr));
71122 }
71123 pCur->ix = (u16)lwr;
71124 rc = moveToChild(pCur, chldPg);
71125 if( rc ) break;
71126 }
71127 moveto_table_finish:
71128 pCur->info.nSize = 0;
71129 assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );
71130 return rc;
71131 }
71132
71133 /* Move the cursor so that it points to an entry in an index table
71134 ** near the key pIdxKey. Return a success code.
71135 **
71136 ** If an exact match is not found, then the cursor is always
71137 ** left pointing at a leaf page which would hold the entry if it
71138 ** were present. The cursor might point to an entry that comes
71139 ** before or after the key.
71140 **
71141 ** An integer is written into *pRes which is the result of
71142 ** comparing the key with the entry to which the cursor is
71143 ** pointing. The meaning of the integer written into
71144 ** *pRes is as follows:
71145 **
71146 ** *pRes<0 The cursor is left pointing at an entry that
71147 ** is smaller than pIdxKey or if the table is empty
71148 ** and the cursor is therefore left point to nothing.
71149 **
71150 ** *pRes==0 The cursor is left pointing at an entry that
71151 ** exactly matches pIdxKey.
71152 **
71153 ** *pRes>0 The cursor is left pointing at an entry that
71154 ** is larger than pIdxKey.
71155 **
71156 ** The pIdxKey->eqSeen field is set to 1 if there
71157 ** exists an entry in the table that exactly matches pIdxKey.
71158 */
71159 SQLITE_PRIVATE int sqlite3BtreeIndexMoveto(
71160 BtCursor *pCur, /* The cursor to be moved */
71161 UnpackedRecord *pIdxKey, /* Unpacked index key */
71162 int *pRes /* Write search results here */
71163 ){
71164 int rc;
71165 RecordCompare xRecordCompare;
71166
71167 assert( cursorOwnsBtShared(pCur) );
71168 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
71169 assert( pRes );
71170 assert( pCur->pKeyInfo!=0 );
71171
71172 #ifdef SQLITE_DEBUG
71173 pCur->pBtree->nSeek++; /* Performance measurement during testing */
71174 #endif
71175
71176 xRecordCompare = sqlite3VdbeFindCompare(pIdxKey);
71177 pIdxKey->errCode = 0;
71178 assert( pIdxKey->default_rc==1
71179 || pIdxKey->default_rc==0
71180 || pIdxKey->default_rc==-1
71181 );
71182
71183 rc = moveToRoot(pCur);
71184 if( rc ){
71185 if( rc==SQLITE_EMPTY ){
71186 assert( pCur->pgnoRoot==0 || pCur->pPage->nCell==0 );
@@ -70998,155 +71209,116 @@
71209 ** a moveToChild() or moveToRoot() call would have detected corruption. */
71210 assert( pPage->nCell>0 );
71211 assert( pPage->intKey==(pIdxKey==0) );
71212 lwr = 0;
71213 upr = pPage->nCell-1;
71214 idx = upr>>1; /* idx = (lwr+upr)/2; */
71215 pCur->ix = (u16)idx;
71216 for(;;){
71217 int nCell; /* Size of the pCell cell in bytes */
71218 pCell = findCellPastPtr(pPage, idx);
71219
71220 /* The maximum supported page-size is 65536 bytes. This means that
71221 ** the maximum number of record bytes stored on an index B-Tree
71222 ** page is less than 16384 bytes and may be stored as a 2-byte
71223 ** varint. This information is used to attempt to avoid parsing
71224 ** the entire cell by checking for the cases where the record is
71225 ** stored entirely within the b-tree page by inspecting the first
71226 ** 2 bytes of the cell.
71227 */
71228 nCell = pCell[0];
71229 if( nCell<=pPage->max1bytePayload ){
71230 /* This branch runs if the record-size field of the cell is a
71231 ** single byte varint and the record fits entirely on the main
71232 ** b-tree page. */
71233 testcase( pCell+nCell+1==pPage->aDataEnd );
71234 c = xRecordCompare(nCell, (void*)&pCell[1], pIdxKey);
71235 }else if( !(pCell[1] & 0x80)
71236 && (nCell = ((nCell&0x7f)<<7) + pCell[1])<=pPage->maxLocal
71237 ){
71238 /* The record-size field is a 2 byte varint and the record
71239 ** fits entirely on the main b-tree page. */
71240 testcase( pCell+nCell+2==pPage->aDataEnd );
71241 c = xRecordCompare(nCell, (void*)&pCell[2], pIdxKey);
71242 }else{
71243 /* The record flows over onto one or more overflow pages. In
71244 ** this case the whole cell needs to be parsed, a buffer allocated
71245 ** and accessPayload() used to retrieve the record into the
71246 ** buffer before VdbeRecordCompare() can be called.
71247 **
71248 ** If the record is corrupt, the xRecordCompare routine may read
71249 ** up to two varints past the end of the buffer. An extra 18
71250 ** bytes of padding is allocated at the end of the buffer in
71251 ** case this happens. */
71252 void *pCellKey;
71253 u8 * const pCellBody = pCell - pPage->childPtrSize;
71254 const int nOverrun = 18; /* Size of the overrun padding */
71255 pPage->xParseCell(pPage, pCellBody, &pCur->info);
71256 nCell = (int)pCur->info.nKey;
71257 testcase( nCell<0 ); /* True if key size is 2^32 or more */
71258 testcase( nCell==0 ); /* Invalid key size: 0x80 0x80 0x00 */
71259 testcase( nCell==1 ); /* Invalid key size: 0x80 0x80 0x01 */
71260 testcase( nCell==2 ); /* Minimum legal index key size */
71261 if( nCell<2 || nCell/pCur->pBt->usableSize>pCur->pBt->nPage ){
71262 rc = SQLITE_CORRUPT_PAGE(pPage);
71263 goto moveto_index_finish;
71264 }
71265 pCellKey = sqlite3Malloc( nCell+nOverrun );
71266 if( pCellKey==0 ){
71267 rc = SQLITE_NOMEM_BKPT;
71268 goto moveto_index_finish;
71269 }
71270 pCur->ix = (u16)idx;
71271 rc = accessPayload(pCur, 0, nCell, (unsigned char*)pCellKey, 0);
71272 memset(((u8*)pCellKey)+nCell,0,nOverrun); /* Fix uninit warnings */
71273 pCur->curFlags &= ~BTCF_ValidOvfl;
71274 if( rc ){
71275 sqlite3_free(pCellKey);
71276 goto moveto_index_finish;
71277 }
71278 c = sqlite3VdbeRecordCompare(nCell, pCellKey, pIdxKey);
71279 sqlite3_free(pCellKey);
71280 }
71281 assert(
71282 (pIdxKey->errCode!=SQLITE_CORRUPT || c==0)
71283 && (pIdxKey->errCode!=SQLITE_NOMEM || pCur->pBtree->db->mallocFailed)
71284 );
71285 if( c<0 ){
71286 lwr = idx+1;
71287 }else if( c>0 ){
71288 upr = idx-1;
71289 }else{
71290 assert( c==0 );
71291 *pRes = 0;
71292 rc = SQLITE_OK;
71293 pCur->ix = (u16)idx;
71294 if( pIdxKey->errCode ) rc = SQLITE_CORRUPT_BKPT;
71295 goto moveto_index_finish;
71296 }
71297 if( lwr>upr ) break;
71298 assert( lwr+upr>=0 );
71299 idx = (lwr+upr)>>1; /* idx = (lwr+upr)/2 */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71300 }
71301 assert( lwr==upr+1 || (pPage->intKey && !pPage->leaf) );
71302 assert( pPage->isInit );
71303 if( pPage->leaf ){
71304 assert( pCur->ix<pCur->pPage->nCell );
71305 pCur->ix = (u16)idx;
71306 *pRes = c;
71307 rc = SQLITE_OK;
71308 goto moveto_index_finish;
71309 }
 
71310 if( lwr>=pPage->nCell ){
71311 chldPg = get4byte(&pPage->aData[pPage->hdrOffset+8]);
71312 }else{
71313 chldPg = get4byte(findCell(pPage, lwr));
71314 }
71315 pCur->ix = (u16)lwr;
71316 rc = moveToChild(pCur, chldPg);
71317 if( rc ) break;
71318 }
71319 moveto_index_finish:
71320 pCur->info.nSize = 0;
71321 assert( (pCur->curFlags & BTCF_ValidOvfl)==0 );
71322 return rc;
71323 }
71324
@@ -73126,10 +73298,11 @@
73298 if( rc ){
73299 memset(apOld, 0, (i)*sizeof(MemPage*));
73300 goto balance_cleanup;
73301 }
73302 }
73303 nMaxCells += apOld[i]->nCell + ArraySize(pParent->apOvfl);
73304 if( (i--)==0 ) break;
73305
73306 if( pParent->nOverflow && i+nxDiv==pParent->aiOvfl[0] ){
73307 apDiv[i] = pParent->apOvfl[0];
73308 pgno = get4byte(apDiv[i]);
@@ -73167,11 +73340,10 @@
73340 }
73341 }
73342
73343 /* Make nMaxCells a multiple of 4 in order to preserve 8-byte
73344 ** alignment */
 
73345 nMaxCells = (nMaxCells + 3)&~3;
73346
73347 /*
73348 ** Allocate space for memory structures
73349 */
@@ -73450,11 +73622,13 @@
73622 if( i<nOld ){
73623 pNew = apNew[i] = apOld[i];
73624 apOld[i] = 0;
73625 rc = sqlite3PagerWrite(pNew->pDbPage);
73626 nNew++;
73627 if( sqlite3PagerPageRefcount(pNew->pDbPage)!=1+(i==(iParentIdx-nxDiv))
73628 && rc==SQLITE_OK
73629 ){
73630 rc = SQLITE_CORRUPT_BKPT;
73631 }
73632 if( rc ) goto balance_cleanup;
73633 }else{
73634 assert( i>0 );
@@ -74248,11 +74422,12 @@
74422 }else if( loc==0 ){
74423 /* The cursor is *not* pointing to the cell to be overwritten, nor
74424 ** to an adjacent cell. Move the cursor so that it is pointing either
74425 ** to the cell to be overwritten or an adjacent cell.
74426 */
74427 rc = sqlite3BtreeTableMoveto(pCur, pX->nKey,
74428 (flags & BTREE_APPEND)!=0, &loc);
74429 if( rc ) return rc;
74430 }
74431 }else{
74432 /* This is an index or a WITHOUT ROWID table */
74433
@@ -74271,17 +74446,15 @@
74446 UnpackedRecord r;
74447 r.pKeyInfo = pCur->pKeyInfo;
74448 r.aMem = pX->aMem;
74449 r.nField = pX->nMem;
74450 r.default_rc = 0;
 
 
 
74451 r.eqSeen = 0;
74452 rc = sqlite3BtreeIndexMoveto(pCur, &r, &loc);
74453 }else{
74454 rc = btreeMoveto(pCur, pX->pKey, pX->nKey,
74455 (flags & BTREE_APPEND)!=0, &loc);
74456 }
74457 if( rc ) return rc;
74458 }
74459
74460 /* If the cursor is currently pointing to an entry to be overwritten
@@ -74911,11 +75084,11 @@
75084 */
75085 static int clearDatabasePage(
75086 BtShared *pBt, /* The BTree that contains the table */
75087 Pgno pgno, /* Page number to clear */
75088 int freePageFlag, /* Deallocate page if true */
75089 i64 *pnChange /* Add number of Cells freed to this counter */
75090 ){
75091 MemPage *pPage;
75092 int rc;
75093 unsigned char *pCell;
75094 int i;
@@ -74944,10 +75117,11 @@
75117 if( rc ) goto cleardatabasepage_out;
75118 }
75119 if( !pPage->leaf ){
75120 rc = clearDatabasePage(pBt, get4byte(&pPage->aData[hdr+8]), 1, pnChange);
75121 if( rc ) goto cleardatabasepage_out;
75122 if( pPage->intKey ) pnChange = 0;
75123 }
75124 if( pnChange ){
75125 testcase( !pPage->intKey );
75126 *pnChange += pPage->nCell;
75127 }
@@ -74973,11 +75147,11 @@
75147 ** root of the table.
75148 **
75149 ** If pnChange is not NULL, then the integer value pointed to by pnChange
75150 ** is incremented by the number of entries in the table.
75151 */
75152 SQLITE_PRIVATE int sqlite3BtreeClearTable(Btree *p, int iTable, i64 *pnChange){
75153 int rc;
75154 BtShared *pBt = p->pBt;
75155 sqlite3BtreeEnter(p);
75156 assert( p->inTrans==TRANS_WRITE );
75157
@@ -82408,11 +82582,11 @@
82582 extern int sqlite3_search_count;
82583 #endif
82584 assert( p->deferredMoveto );
82585 assert( p->isTable );
82586 assert( p->eCurType==CURTYPE_BTREE );
82587 rc = sqlite3BtreeTableMoveto(p->uc.pCursor, p->movetoTarget, 0, &res);
82588 if( rc ) return rc;
82589 if( res!=0 ) return SQLITE_CORRUPT_BKPT;
82590 #ifdef SQLITE_TEST
82591 sqlite3_search_count++;
82592 #endif
@@ -83192,11 +83366,11 @@
83366 /*
83367 ** Do a comparison between a 64-bit signed integer and a 64-bit floating-point
83368 ** number. Return negative, zero, or positive if the first (i64) is less than,
83369 ** equal to, or greater than the second (double).
83370 */
83371 SQLITE_PRIVATE int sqlite3IntFloatCompare(i64 i, double r){
83372 if( sizeof(LONGDOUBLE_TYPE)>8 ){
83373 LONGDOUBLE_TYPE x = (LONGDOUBLE_TYPE)i;
83374 testcase( x<r );
83375 testcase( x>r );
83376 testcase( x==r );
@@ -83916,11 +84090,11 @@
84090
84091 /*
84092 ** This routine sets the value to be returned by subsequent calls to
84093 ** sqlite3_changes() on the database handle 'db'.
84094 */
84095 SQLITE_PRIVATE void sqlite3VdbeSetChanges(sqlite3 *db, i64 nChange){
84096 assert( sqlite3_mutex_held(db->mutex) );
84097 db->nChange = nChange;
84098 db->nTotalChange += nChange;
84099 }
84100
@@ -90284,10 +90458,12 @@
90458 assert( pOp->p5==0 || pOp->p5==OPFLAG_SEEKEQ );
90459 assert( pOp->p4type==P4_KEYINFO );
90460 pCur = p->apCsr[pOp->p1];
90461 if( pCur && pCur->pgnoRoot==(u32)pOp->p2 ){
90462 assert( pCur->iDb==pOp->p3 ); /* Guaranteed by the code generator */
90463 assert( pCur->eCurType==CURTYPE_BTREE );
90464 sqlite3BtreeClearCursor(pCur->uc.pCursor);
90465 goto open_cursor_set_hints;
90466 }
90467 /* If the cursor is not currently open or is open on a different
90468 ** index, then fall through into OP_OpenRead to force a reopen */
90469 case OP_OpenRead:
@@ -90771,45 +90947,47 @@
90947 pIn3->flags = flags3; /* But convert the type back to its original */
90948
90949 /* If the P3 value could not be converted into an integer without
90950 ** loss of information, then special processing is required... */
90951 if( (newType & (MEM_Int|MEM_IntReal))==0 ){
90952 int c;
90953 if( (newType & MEM_Real)==0 ){
90954 if( (newType & MEM_Null) || oc>=OP_SeekGE ){
90955 VdbeBranchTaken(1,2);
90956 goto jump_to_p2;
90957 }else{
90958 rc = sqlite3BtreeLast(pC->uc.pCursor, &res);
90959 if( rc!=SQLITE_OK ) goto abort_due_to_error;
90960 goto seek_not_found;
90961 }
90962 }
90963 c = sqlite3IntFloatCompare(iKey, pIn3->u.r);
90964
90965 /* If the approximation iKey is larger than the actual real search
90966 ** term, substitute >= for > and < for <=. e.g. if the search term
90967 ** is 4.9 and the integer approximation 5:
90968 **
90969 ** (x > 4.9) -> (x >= 5)
90970 ** (x <= 4.9) -> (x < 5)
90971 */
90972 if( c>0 ){
90973 assert( OP_SeekGE==(OP_SeekGT-1) );
90974 assert( OP_SeekLT==(OP_SeekLE-1) );
90975 assert( (OP_SeekLE & 0x0001)==(OP_SeekGT & 0x0001) );
90976 if( (oc & 0x0001)==(OP_SeekGT & 0x0001) ) oc--;
90977 }
90978
90979 /* If the approximation iKey is smaller than the actual real search
90980 ** term, substitute <= for < and > for >=. */
90981 else if( c<0 ){
90982 assert( OP_SeekLE==(OP_SeekLT+1) );
90983 assert( OP_SeekGT==(OP_SeekGE+1) );
90984 assert( (OP_SeekLT & 0x0001)==(OP_SeekGE & 0x0001) );
90985 if( (oc & 0x0001)==(OP_SeekLT & 0x0001) ) oc++;
90986 }
90987 }
90988 rc = sqlite3BtreeTableMoveto(pC->uc.pCursor, (u64)iKey, 0, &res);
90989 pC->movetoTarget = iKey; /* Used by OP_Delete */
90990 if( rc!=SQLITE_OK ){
90991 goto abort_due_to_error;
90992 }
90993 }else{
@@ -90852,11 +91030,11 @@
91030 r.aMem = &aMem[pOp->p3];
91031 #ifdef SQLITE_DEBUG
91032 { int i; for(i=0; i<r.nField; i++) assert( memIsValid(&r.aMem[i]) ); }
91033 #endif
91034 r.eqSeen = 0;
91035 rc = sqlite3BtreeIndexMoveto(pC->uc.pCursor, &r, &res);
91036 if( rc!=SQLITE_OK ){
91037 goto abort_due_to_error;
91038 }
91039 if( eqOnly && r.eqSeen==0 ){
91040 assert( res!=0 );
@@ -91271,11 +91449,11 @@
91449 takeJump = 1;
91450 break;
91451 }
91452 }
91453 }
91454 rc = sqlite3BtreeIndexMoveto(pC->uc.pCursor, pIdxKey, &res);
91455 if( pFree ) sqlite3DbFreeNN(db, pFree);
91456 if( rc!=SQLITE_OK ){
91457 goto abort_due_to_error;
91458 }
91459 pC->seekResult = res;
@@ -91380,11 +91558,11 @@
91558 assert( pC->isTable );
91559 assert( pC->eCurType==CURTYPE_BTREE );
91560 pCrsr = pC->uc.pCursor;
91561 assert( pCrsr!=0 );
91562 res = 0;
91563 rc = sqlite3BtreeTableMoveto(pCrsr, iKey, 0, &res);
91564 assert( rc==SQLITE_OK || res==0 );
91565 pC->movetoTarget = iKey; /* Used by OP_Delete */
91566 pC->nullRow = 0;
91567 pC->cacheStatus = CACHE_STALE;
91568 pC->deferredMoveto = 0;
@@ -91537,11 +91715,11 @@
91715 ** an AUTOINCREMENT table. */
91716 cnt = 0;
91717 do{
91718 sqlite3_randomness(sizeof(v), &v);
91719 v &= (MAX_ROWID>>1); v++; /* Ensure that v is greater than zero */
91720 }while( ((rc = sqlite3BtreeTableMoveto(pC->uc.pCursor, (u64)v,
91721 0, &res))==SQLITE_OK)
91722 && (res==0)
91723 && (++cnt<100));
91724 if( rc ) goto abort_due_to_error;
91725 if( res==0 ){
@@ -92435,11 +92613,11 @@
92613 assert( pCrsr!=0 );
92614 r.pKeyInfo = pC->pKeyInfo;
92615 r.nField = (u16)pOp->p3;
92616 r.default_rc = 0;
92617 r.aMem = &aMem[pOp->p2];
92618 rc = sqlite3BtreeIndexMoveto(pCrsr, &r, &res);
92619 if( rc ) goto abort_due_to_error;
92620 if( res==0 ){
92621 rc = sqlite3BtreeDelete(pCrsr, BTREE_AUXDELETE);
92622 if( rc ) goto abort_due_to_error;
92623 }else if( pOp->p5 ){
@@ -92748,11 +92926,11 @@
92926 ** by the number of rows in the table being cleared.
92927 **
92928 ** See also: Destroy
92929 */
92930 case OP_Clear: {
92931 i64 nChange;
92932
92933 sqlite3VdbeIncrWriteCounter(p, 0);
92934 nChange = 0;
92935 assert( p->readOnly==0 );
92936 assert( DbMaskTest(p->btreeMask, pOp->p2) );
@@ -99511,11 +99689,11 @@
99689 if( pSrcList ){
99690 for(i=0, pItem=pSrcList->a; i<pSrcList->nSrc; i++, pItem++){
99691 u8 hCol;
99692 pTab = pItem->pTab;
99693 assert( pTab!=0 && pTab->zName!=0 );
99694 assert( pTab->nCol>0 || pParse->nErr );
99695 if( pItem->pSelect && (pItem->pSelect->selFlags & SF_NestedFrom)!=0 ){
99696 int hit = 0;
99697 pEList = pItem->pSelect->pEList;
99698 for(j=0; j<pEList->nExpr; j++){
99699 if( sqlite3MatchEName(&pEList->a[j], zCol, zTab, zDb) ){
@@ -99539,13 +99717,10 @@
99717 }
99718 if( IN_RENAME_OBJECT && pItem->zAlias ){
99719 sqlite3RenameTokenRemap(pParse, 0, (void*)&pExpr->y.pTab);
99720 }
99721 }
 
 
 
99722 hCol = sqlite3StrIHash(zCol);
99723 for(j=0, pCol=pTab->aCol; j<pTab->nCol; j++, pCol++){
99724 if( pCol->hName==hCol && sqlite3StrICmp(pCol->zName, zCol)==0 ){
99725 /* If there has been exactly one prior match and this match
99726 ** is for the right-hand table of a NATURAL JOIN or is in a
@@ -99559,10 +99734,14 @@
99734 pMatch = pItem;
99735 /* Substitute the rowid (column -1) for the INTEGER PRIMARY KEY */
99736 pExpr->iColumn = j==pTab->iPKey ? -1 : (i16)j;
99737 break;
99738 }
99739 }
99740 if( 0==cnt && VisibleRowid(pTab) ){
99741 cntTab++;
99742 pMatch = pItem;
99743 }
99744 }
99745 if( pMatch ){
99746 pExpr->iTable = pMatch->iCursor;
99747 pExpr->y.pTab = pMatch->pTab;
@@ -99682,11 +99861,11 @@
99861 if( cnt==0
99862 && cntTab==1
99863 && pMatch
99864 && (pNC->ncFlags & (NC_IdxExpr|NC_GenCol))==0
99865 && sqlite3IsRowid(zCol)
99866 && ALWAYS(VisibleRowid(pMatch->pTab))
99867 ){
99868 cnt = 1;
99869 pExpr->iColumn = -1;
99870 pExpr->affExpr = SQLITE_AFF_INTEGER;
99871 }
@@ -100294,13 +100473,16 @@
100473 pNC2 = pNC2->pNext;
100474 }
100475 assert( pDef!=0 || IN_RENAME_OBJECT );
100476 if( pNC2 && pDef ){
100477 assert( SQLITE_FUNC_MINMAX==NC_MinMaxAgg );
100478 assert( SQLITE_FUNC_ANYORDER==NC_OrderAgg );
100479 testcase( (pDef->funcFlags & SQLITE_FUNC_MINMAX)!=0 );
100480 testcase( (pDef->funcFlags & SQLITE_FUNC_ANYORDER)!=0 );
100481 pNC2->ncFlags |= NC_HasAgg
100482 | ((pDef->funcFlags^SQLITE_FUNC_ANYORDER)
100483 & (SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER));
100484 }
100485 }
100486 pNC->ncFlags |= savedAllowFlags;
100487 }
100488 /* FIX ME: Compute pExpr->affinity based on the expected return
@@ -100839,11 +101021,11 @@
101021 assert( pSub->pPrior && pSub->pOrderBy==0 );
101022 pSub->pOrderBy = p->pOrderBy;
101023 p->pOrderBy = 0;
101024 }
101025
101026 /* Recursively resolve names in all subqueries in the FROM clause
101027 */
101028 for(i=0; i<p->pSrc->nSrc; i++){
101029 SrcItem *pItem = &p->pSrc->a[i];
101030 if( pItem->pSelect && (pItem->pSelect->selFlags & SF_Resolved)==0 ){
101031 int nRef = pOuterNC ? pOuterNC->nRef : 0;
@@ -100883,11 +101065,12 @@
101065 */
101066 assert( (p->selFlags & SF_Aggregate)==0 );
101067 pGroupBy = p->pGroupBy;
101068 if( pGroupBy || (sNC.ncFlags & NC_HasAgg)!=0 ){
101069 assert( NC_MinMaxAgg==SF_MinMaxAgg );
101070 assert( NC_OrderAgg==SF_OrderByReqd );
101071 p->selFlags |= SF_Aggregate | (sNC.ncFlags&(NC_MinMaxAgg|NC_OrderAgg));
101072 }else{
101073 sNC.ncFlags &= ~NC_AllowAgg;
101074 }
101075
101076 /* Add the output column list to the name-context before parsing the
@@ -101066,12 +101249,12 @@
101249 ){
101250 int savedHasAgg;
101251 Walker w;
101252
101253 if( pExpr==0 ) return SQLITE_OK;
101254 savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
101255 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
101256 w.pParse = pNC->pParse;
101257 w.xExprCallback = resolveExprStep;
101258 w.xSelectCallback = (pNC->ncFlags & NC_NoSelect) ? 0 : resolveSelectStep;
101259 w.xSelectCallback2 = 0;
101260 w.u.pNC = pNC;
@@ -101110,12 +101293,12 @@
101293 w.pParse = pNC->pParse;
101294 w.xExprCallback = resolveExprStep;
101295 w.xSelectCallback = resolveSelectStep;
101296 w.xSelectCallback2 = 0;
101297 w.u.pNC = pNC;
101298 savedHasAgg = pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
101299 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
101300 for(i=0; i<pList->nExpr; i++){
101301 Expr *pExpr = pList->a[i].pExpr;
101302 if( pExpr==0 ) continue;
101303 #if SQLITE_MAX_EXPR_DEPTH>0
101304 w.pParse->nHeight += pExpr->nHeight;
@@ -101129,14 +101312,15 @@
101312 #endif
101313 assert( EP_Agg==NC_HasAgg );
101314 assert( EP_Win==NC_HasWin );
101315 testcase( pNC->ncFlags & NC_HasAgg );
101316 testcase( pNC->ncFlags & NC_HasWin );
101317 if( pNC->ncFlags & (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg) ){
101318 ExprSetProperty(pExpr, pNC->ncFlags & (NC_HasAgg|NC_HasWin) );
101319 savedHasAgg |= pNC->ncFlags &
101320 (NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
101321 pNC->ncFlags &= ~(NC_HasAgg|NC_MinMaxAgg|NC_HasWin|NC_OrderAgg);
101322 }
101323 if( w.pParse->nErr>0 ) return WRC_Abort;
101324 }
101325 pNC->ncFlags |= savedHasAgg;
101326 return WRC_Continue;
@@ -101296,10 +101480,12 @@
101480 return sqlite3AffinityType(pExpr->u.zToken, 0);
101481 }
101482 #endif
101483 if( op==TK_SELECT_COLUMN ){
101484 assert( pExpr->pLeft->flags&EP_xIsSelect );
101485 assert( pExpr->iColumn < pExpr->iTable );
101486 assert( pExpr->iTable==pExpr->pLeft->x.pSelect->pEList->nExpr );
101487 return sqlite3ExprAffinity(
101488 pExpr->pLeft->x.pSelect->pEList->a[pExpr->iColumn].pExpr
101489 );
101490 }
101491 if( op==TK_VECTOR ){
@@ -101706,11 +101892,12 @@
101892 ** of the returned TK_SELECT_COLUMN Expr object.
101893 */
101894 SQLITE_PRIVATE Expr *sqlite3ExprForVectorField(
101895 Parse *pParse, /* Parsing context */
101896 Expr *pVector, /* The vector. List of expressions or a sub-SELECT */
101897 int iField, /* Which column of the vector to return */
101898 int nField /* Total number of columns in the vector */
101899 ){
101900 Expr *pRet;
101901 if( pVector->op==TK_SELECT ){
101902 assert( pVector->flags & EP_xIsSelect );
101903 /* The TK_SELECT_COLUMN Expr node:
@@ -101729,14 +101916,14 @@
101916 ** with the same pLeft pointer to the pVector, but only one of them
101917 ** will own the pVector.
101918 */
101919 pRet = sqlite3PExpr(pParse, TK_SELECT_COLUMN, 0, 0);
101920 if( pRet ){
101921 pRet->iTable = nField;
101922 pRet->iColumn = iField;
101923 pRet->pLeft = pVector;
101924 }
 
101925 }else{
101926 if( pVector->op==TK_VECTOR ) pVector = pVector->x.pList->a[iField].pExpr;
101927 pRet = sqlite3ExprDup(pParse->db, pVector, 0);
101928 sqlite3RenameTokenRemap(pParse, pRet, pVector);
101929 }
@@ -102167,10 +102354,60 @@
102354 assert( pParse->db->mallocFailed );
102355 sqlite3SelectDelete(pParse->db, pSelect);
102356 }
102357 }
102358
102359 /*
102360 ** Expression list pEList is a list of vector values. This function
102361 ** converts the contents of pEList to a VALUES(...) Select statement
102362 ** returning 1 row for each element of the list. For example, the
102363 ** expression list:
102364 **
102365 ** ( (1,2), (3,4) (5,6) )
102366 **
102367 ** is translated to the equivalent of:
102368 **
102369 ** VALUES(1,2), (3,4), (5,6)
102370 **
102371 ** Each of the vector values in pEList must contain exactly nElem terms.
102372 ** If a list element that is not a vector or does not contain nElem terms,
102373 ** an error message is left in pParse.
102374 **
102375 ** This is used as part of processing IN(...) expressions with a list
102376 ** of vectors on the RHS. e.g. "... IN ((1,2), (3,4), (5,6))".
102377 */
102378 SQLITE_PRIVATE Select *sqlite3ExprListToValues(Parse *pParse, int nElem, ExprList *pEList){
102379 int ii;
102380 Select *pRet = 0;
102381 assert( nElem>1 );
102382 for(ii=0; ii<pEList->nExpr; ii++){
102383 Select *pSel;
102384 Expr *pExpr = pEList->a[ii].pExpr;
102385 int nExprElem = (pExpr->op==TK_VECTOR ? pExpr->x.pList->nExpr : 1);
102386 if( nExprElem!=nElem ){
102387 sqlite3ErrorMsg(pParse, "IN(...) element has %d term%s - expected %d",
102388 nExprElem, nExprElem>1?"s":"", nElem
102389 );
102390 break;
102391 }
102392 pSel = sqlite3SelectNew(pParse, pExpr->x.pList, 0, 0, 0, 0, 0, SF_Values,0);
102393 pExpr->x.pList = 0;
102394 if( pSel ){
102395 if( pRet ){
102396 pSel->op = TK_ALL;
102397 pSel->pPrior = pRet;
102398 }
102399 pRet = pSel;
102400 }
102401 }
102402
102403 if( pRet && pRet->pPrior ){
102404 pRet->selFlags |= SF_MultiValue;
102405 }
102406 sqlite3ExprListDelete(pParse->db, pEList);
102407 return pRet;
102408 }
102409
102410 /*
102411 ** Join two expressions using an AND operator. If either expression is
102412 ** NULL, then just return the other expression.
102413 **
@@ -102211,11 +102448,14 @@
102448 pNew = sqlite3ExprAlloc(db, TK_FUNCTION, pToken, 1);
102449 if( pNew==0 ){
102450 sqlite3ExprListDelete(db, pList); /* Avoid memory leak when malloc fails */
102451 return 0;
102452 }
102453 if( pList
102454 && pList->nExpr > pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG]
102455 && !pParse->nested
102456 ){
102457 sqlite3ErrorMsg(pParse, "too many arguments on function %T", pToken);
102458 }
102459 pNew->x.pList = pList;
102460 ExprSetProperty(pNew, EP_HasFunc);
102461 assert( !ExprHasProperty(pNew, EP_xIsSelect) );
@@ -102619,11 +102859,10 @@
102859 }
102860 }else{
102861 if( !ExprHasProperty(p, EP_TokenOnly|EP_Leaf) ){
102862 if( pNew->op==TK_SELECT_COLUMN ){
102863 pNew->pLeft = p->pLeft;
 
102864 assert( p->pRight==0 || p->pRight==p->pLeft
102865 || ExprHasProperty(p->pLeft, EP_Subquery) );
102866 }else{
102867 pNew->pLeft = sqlite3ExprDup(db, p->pLeft, 0);
102868 }
@@ -102717,11 +102956,12 @@
102956 }
102957 SQLITE_PRIVATE ExprList *sqlite3ExprListDup(sqlite3 *db, ExprList *p, int flags){
102958 ExprList *pNew;
102959 struct ExprList_item *pItem, *pOldItem;
102960 int i;
102961 Expr *pPriorSelectColOld = 0;
102962 Expr *pPriorSelectColNew = 0;
102963 assert( db!=0 );
102964 if( p==0 ) return 0;
102965 pNew = sqlite3DbMallocRawNN(db, sqlite3DbMallocSize(db, p));
102966 if( pNew==0 ) return 0;
102967 pNew->nExpr = p->nExpr;
@@ -102734,21 +102974,21 @@
102974 pItem->pExpr = sqlite3ExprDup(db, pOldExpr, flags);
102975 if( pOldExpr
102976 && pOldExpr->op==TK_SELECT_COLUMN
102977 && (pNewExpr = pItem->pExpr)!=0
102978 ){
102979 if( pNewExpr->pRight ){
102980 pPriorSelectColOld = pOldExpr->pRight;
102981 pPriorSelectColNew = pNewExpr->pRight;
102982 pNewExpr->pLeft = pNewExpr->pRight;
 
102983 }else{
102984 if( pOldExpr->pLeft!=pPriorSelectColOld ){
102985 pPriorSelectColOld = pOldExpr->pLeft;
102986 pPriorSelectColNew = sqlite3ExprDup(db, pPriorSelectColOld, flags);
102987 pNewExpr->pRight = pPriorSelectColNew;
102988 }
102989 pNewExpr->pLeft = pPriorSelectColNew;
102990 }
102991 }
102992 pItem->zEName = sqlite3DbStrDup(db, pOldItem->zEName);
102993 pItem->sortFlags = pOldItem->sortFlags;
102994 pItem->eEName = pOldItem->eEName;
@@ -103003,15 +103243,13 @@
103243 pColumns->nId, n);
103244 goto vector_append_error;
103245 }
103246
103247 for(i=0; i<pColumns->nId; i++){
103248 Expr *pSubExpr = sqlite3ExprForVectorField(pParse, pExpr, i, pColumns->nId);
103249 assert( pSubExpr!=0 || db->mallocFailed );
 
103250 if( pSubExpr==0 ) continue;
 
103251 pList = sqlite3ExprListAppend(pParse, pList, pSubExpr);
103252 if( pList ){
103253 assert( pList->nExpr==iFirst+i+1 );
103254 pList->a[pList->nExpr-1].zEName = pColumns->a[i].zName;
103255 pColumns->a[i].zName = 0;
@@ -105597,15 +105835,13 @@
105835 case TK_SELECT_COLUMN: {
105836 int n;
105837 if( pExpr->pLeft->iTable==0 ){
105838 pExpr->pLeft->iTable = sqlite3CodeSubselect(pParse, pExpr->pLeft);
105839 }
105840 assert( pExpr->pLeft->op==TK_SELECT || pExpr->pLeft->op==TK_ERROR );
105841 n = sqlite3ExprVectorSize(pExpr->pLeft);
105842 if( pExpr->iTable!=n ){
 
 
105843 sqlite3ErrorMsg(pParse, "%d columns assigned %d values",
105844 pExpr->iTable, n);
105845 }
105846 return pExpr->pLeft->iTable + pExpr->iColumn;
105847 }
@@ -107827,28 +108063,43 @@
108063 );
108064 sqlite3DbFree(db, zCol);
108065 db->mDbFlags = savedDbFlags;
108066 }
108067
 
 
 
 
108068 v = sqlite3GetVdbe(pParse);
108069 if( v ){
108070 /* Make sure the schema version is at least 3. But do not upgrade
108071 ** from less than 3 to 4, as that will corrupt any preexisting DESC
108072 ** index.
108073 */
108074 r1 = sqlite3GetTempReg(pParse);
108075 sqlite3VdbeAddOp3(v, OP_ReadCookie, iDb, r1, BTREE_FILE_FORMAT);
108076 sqlite3VdbeUsesBtree(v, iDb);
108077 sqlite3VdbeAddOp2(v, OP_AddImm, r1, -2);
108078 sqlite3VdbeAddOp2(v, OP_IfPos, r1, sqlite3VdbeCurrentAddr(v)+2);
108079 VdbeCoverage(v);
108080 sqlite3VdbeAddOp3(v, OP_SetCookie, iDb, BTREE_FILE_FORMAT, 3);
108081 sqlite3ReleaseTempReg(pParse, r1);
108082
108083 /* Reload the table definition */
108084 renameReloadSchema(pParse, iDb, INITFLAG_AlterRename);
108085
108086 /* Verify that constraints are still satisfied */
108087 if( pNew->pCheck!=0
108088 || (pCol->notNull && (pCol->colFlags & COLFLAG_GENERATED)!=0)
108089 ){
108090 sqlite3NestedParse(pParse,
108091 "SELECT CASE WHEN quick_check GLOB 'CHECK*'"
108092 " THEN raise(ABORT,'CHECK constraint failed')"
108093 " ELSE raise(ABORT,'NOT NULL constraint failed')"
108094 " END"
108095 " FROM pragma_quick_check(\"%w\",\"%w\")"
108096 " WHERE quick_check GLOB 'CHECK*' OR quick_check GLOB 'NULL*'",
108097 zTab, zDb
108098 );
108099 }
108100 }
 
 
 
108101 }
108102
108103 /*
108104 ** This function is called by the parser after the table-name in
108105 ** an "ALTER TABLE <table-name> ADD" statement is parsed. Argument
@@ -112865,10 +113116,11 @@
113116 Module *pMod = (Module*)sqlite3HashFind(&db->aModule, zName);
113117 if( pMod==0 && sqlite3_strnicmp(zName, "pragma_", 7)==0 ){
113118 pMod = sqlite3PragmaVtabRegister(db, zName);
113119 }
113120 if( pMod && sqlite3VtabEponymousTableInit(pParse, pMod) ){
113121 testcase( pMod->pEpoTab==0 );
113122 return pMod->pEpoTab;
113123 }
113124 }
113125 #endif
113126 if( flags & LOCATE_NOERR ) return 0;
@@ -115592,10 +115844,11 @@
115844 SQLITE_PRIVATE int sqlite3ReadOnlyShadowTables(sqlite3 *db){
115845 #ifndef SQLITE_OMIT_VIRTUALTABLE
115846 if( (db->flags & SQLITE_Defensive)!=0
115847 && db->pVtabCtx==0
115848 && db->nVdbeExec==0
115849 && !sqlite3VtabInSync(db)
115850 ){
115851 return 1;
115852 }
115853 #endif
115854 return 0;
@@ -119884,37 +120137,37 @@
120137
120138 /*
120139 ** Implementation of the changes() SQL function.
120140 **
120141 ** IMP: R-62073-11209 The changes() SQL function is a wrapper
120142 ** around the sqlite3_changes64() C/C++ function and hence follows the same
120143 ** rules for counting changes.
120144 */
120145 static void changes(
120146 sqlite3_context *context,
120147 int NotUsed,
120148 sqlite3_value **NotUsed2
120149 ){
120150 sqlite3 *db = sqlite3_context_db_handle(context);
120151 UNUSED_PARAMETER2(NotUsed, NotUsed2);
120152 sqlite3_result_int64(context, sqlite3_changes64(db));
120153 }
120154
120155 /*
120156 ** Implementation of the total_changes() SQL function. The return value is
120157 ** the same as the sqlite3_total_changes64() API function.
120158 */
120159 static void total_changes(
120160 sqlite3_context *context,
120161 int NotUsed,
120162 sqlite3_value **NotUsed2
120163 ){
120164 sqlite3 *db = sqlite3_context_db_handle(context);
120165 UNUSED_PARAMETER2(NotUsed, NotUsed2);
120166 /* IMP: R-52756-41993 This function was a wrapper around the
120167 ** sqlite3_total_changes() C/C++ interface. */
120168 sqlite3_result_int64(context, sqlite3_total_changes64(db));
120169 }
120170
120171 /*
120172 ** A structure defining how to do GLOB-style comparisons.
120173 */
@@ -121472,15 +121725,15 @@
121725 FUNCTION(trim, 1, 3, 0, trimFunc ),
121726 FUNCTION(trim, 2, 3, 0, trimFunc ),
121727 FUNCTION(min, -1, 0, 1, minmaxFunc ),
121728 FUNCTION(min, 0, 0, 1, 0 ),
121729 WAGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
121730 SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
121731 FUNCTION(max, -1, 1, 1, minmaxFunc ),
121732 FUNCTION(max, 0, 1, 1, 0 ),
121733 WAGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize, minMaxValue, 0,
121734 SQLITE_FUNC_MINMAX|SQLITE_FUNC_ANYORDER ),
121735 FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
121736 FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
121737 FUNCTION(instr, 2, 0, 0, instrFunc ),
121738 FUNCTION(printf, -1, 0, 0, printfFunc ),
121739 FUNCTION(unicode, 1, 0, 0, unicodeFunc ),
@@ -121512,13 +121765,14 @@
121765 FUNCTION(substring, 3, 0, 0, substrFunc ),
121766 WAGGREGATE(sum, 1,0,0, sumStep, sumFinalize, sumFinalize, sumInverse, 0),
121767 WAGGREGATE(total, 1,0,0, sumStep,totalFinalize,totalFinalize,sumInverse, 0),
121768 WAGGREGATE(avg, 1,0,0, sumStep, avgFinalize, avgFinalize, sumInverse, 0),
121769 WAGGREGATE(count, 0,0,0, countStep,
121770 countFinalize, countFinalize, countInverse,
121771 SQLITE_FUNC_COUNT|SQLITE_FUNC_ANYORDER ),
121772 WAGGREGATE(count, 1,0,0, countStep,
121773 countFinalize, countFinalize, countInverse, SQLITE_FUNC_ANYORDER ),
121774 WAGGREGATE(group_concat, 1, 0, 0, groupConcatStep,
121775 groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
121776 WAGGREGATE(group_concat, 2, 0, 0, groupConcatStep,
121777 groupConcatFinalize, groupConcatValue, groupConcatInverse, 0),
121778
@@ -123169,11 +123423,11 @@
123423
123424 /*
123425 ** Compute the affinity string for table pTab, if it has not already been
123426 ** computed. As an optimization, omit trailing SQLITE_AFF_BLOB affinities.
123427 **
123428 ** If the affinity exists (if it is not entirely SQLITE_AFF_BLOB values) and
123429 ** if iReg>0 then code an OP_Affinity opcode that will set the affinities
123430 ** for register iReg and following. Or if affinities exists and iReg==0,
123431 ** then just set the P4 operand of the previous opcode (which should be
123432 ** an OP_MakeRecord) to the affinity string.
123433 **
@@ -126622,10 +126876,13 @@
126876 int,const char**);
126877 void (*free_filename)(char*);
126878 sqlite3_file *(*database_file_object)(const char*);
126879 /* Version 3.34.0 and later */
126880 int (*txn_state)(sqlite3*,const char*);
126881 /* Version 3.36.1 and later */
126882 sqlite3_int64 (*changes64)(sqlite3*);
126883 sqlite3_int64 (*total_changes64)(sqlite3*);
126884 };
126885
126886 /*
126887 ** This is the function signature used for all extension entry points. It
126888 ** is also defined in the file "loadext.c".
@@ -127412,10 +127669,13 @@
127669 sqlite3_create_filename,
127670 sqlite3_free_filename,
127671 sqlite3_database_file_object,
127672 /* Version 3.34.0 and later */
127673 sqlite3_txn_state,
127674 /* Version 3.36.1 and later */
127675 sqlite3_changes64,
127676 sqlite3_total_changes64,
127677 };
127678
127679 /* True if x is the directory separator character
127680 */
127681 #if SQLITE_OS_WIN
@@ -128201,11 +128461,11 @@
128461 /* iArg: */ 1 },
128462 #endif
128463 #if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
128464 {/* zName: */ "integrity_check",
128465 /* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
128466 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1|PragFlg_SchemaOpt,
128467 /* ColNames: */ 0, 0,
128468 /* iArg: */ 0 },
128469 #endif
128470 #if !defined(SQLITE_OMIT_PAGER_PRAGMAS)
128471 {/* zName: */ "journal_mode",
@@ -128309,11 +128569,11 @@
128569 /* iArg: */ SQLITE_QueryOnly },
128570 #endif
128571 #if !defined(SQLITE_OMIT_INTEGRITY_CHECK)
128572 {/* zName: */ "quick_check",
128573 /* ePragTyp: */ PragTyp_INTEGRITY_CHECK,
128574 /* ePragFlg: */ PragFlg_NeedSchema|PragFlg_Result0|PragFlg_Result1|PragFlg_SchemaOpt,
128575 /* ColNames: */ 0, 0,
128576 /* iArg: */ 0 },
128577 #endif
128578 #if !defined(SQLITE_OMIT_FLAG_PRAGMAS)
128579 {/* zName: */ "read_uncommitted",
@@ -129912,10 +130172,11 @@
130172
130173 /* Generate code to read the child key values into registers
130174 ** regRow..regRow+n. If any of the child key values are NULL, this
130175 ** row cannot cause an FK violation. Jump directly to addrOk in
130176 ** this case. */
130177 if( regRow+pFK->nCol>pParse->nMem ) pParse->nMem = regRow+pFK->nCol;
130178 for(j=0; j<pFK->nCol; j++){
130179 int iCol = aiCols ? aiCols[j] : pFK->aCol[j].iFrom;
130180 sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, iCol, regRow+j);
130181 sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); VdbeCoverage(v);
130182 }
@@ -135823,14 +136084,14 @@
136084 /*
136085 ** Assign new cursor numbers to each of the items in pSrc. For each
136086 ** new cursor number assigned, set an entry in the aCsrMap[] array
136087 ** to map the old cursor number to the new:
136088 **
136089 ** aCsrMap[iOld+1] = iNew;
136090 **
136091 ** The array is guaranteed by the caller to be large enough for all
136092 ** existing cursor numbers in pSrc. aCsrMap[0] is the array size.
136093 **
136094 ** If pSrc contains any sub-selects, call this routine recursively
136095 ** on the FROM clause of each such sub-select, with iExcept set to -1.
136096 */
136097 static void srclistRenumberCursors(
@@ -135842,33 +136103,44 @@
136103 int i;
136104 SrcItem *pItem;
136105 for(i=0, pItem=pSrc->a; i<pSrc->nSrc; i++, pItem++){
136106 if( i!=iExcept ){
136107 Select *p;
136108 assert( pItem->iCursor < aCsrMap[0] );
136109 if( !pItem->fg.isRecursive || aCsrMap[pItem->iCursor+1]==0 ){
136110 aCsrMap[pItem->iCursor+1] = pParse->nTab++;
136111 }
136112 pItem->iCursor = aCsrMap[pItem->iCursor+1];
136113 for(p=pItem->pSelect; p; p=p->pPrior){
136114 srclistRenumberCursors(pParse, aCsrMap, p->pSrc, -1);
136115 }
136116 }
136117 }
136118 }
136119
136120 /*
136121 ** *piCursor is a cursor number. Change it if it needs to be mapped.
136122 */
136123 static void renumberCursorDoMapping(Walker *pWalker, int *piCursor){
136124 int *aCsrMap = pWalker->u.aiCol;
136125 int iCsr = *piCursor;
136126 if( iCsr < aCsrMap[0] && aCsrMap[iCsr+1]>0 ){
136127 *piCursor = aCsrMap[iCsr+1];
136128 }
136129 }
136130
136131 /*
136132 ** Expression walker callback used by renumberCursors() to update
136133 ** Expr objects to match newly assigned cursor numbers.
136134 */
136135 static int renumberCursorsCb(Walker *pWalker, Expr *pExpr){
 
136136 int op = pExpr->op;
136137 if( op==TK_COLUMN || op==TK_IF_NULL_ROW ){
136138 renumberCursorDoMapping(pWalker, &pExpr->iTable);
136139 }
136140 if( ExprHasProperty(pExpr, EP_FromJoin) ){
136141 renumberCursorDoMapping(pWalker, &pExpr->iRightJoinTable);
136142 }
136143 return WRC_Continue;
136144 }
136145
136146 /*
@@ -136208,11 +136480,12 @@
136480 /* Restriction (23) */
136481 if( (p->selFlags & SF_Recursive) ) return 0;
136482
136483 if( pSrc->nSrc>1 ){
136484 if( pParse->nSelect>500 ) return 0;
136485 aCsrMap = sqlite3DbMallocZero(db, (pParse->nTab+1)*sizeof(int));
136486 if( aCsrMap ) aCsrMap[0] = pParse->nTab;
136487 }
136488 }
136489
136490 /***** If we reach this point, flattening is permitted. *****/
136491 SELECTTRACE(1,pParse,p,("flatten %u.%p from term %d\n",
@@ -138088,12 +138361,20 @@
138361 ** within the HAVING expression with a constant "1".
138362 */
138363 static int havingToWhereExprCb(Walker *pWalker, Expr *pExpr){
138364 if( pExpr->op!=TK_AND ){
138365 Select *pS = pWalker->u.pSelect;
138366 /* This routine is called before the HAVING clause of the current
138367 ** SELECT is analyzed for aggregates. So if pExpr->pAggInfo is set
138368 ** here, it indicates that the expression is a correlated reference to a
138369 ** column from an outer aggregate query, or an aggregate function that
138370 ** belongs to an outer query. Do not move the expression to the WHERE
138371 ** clause in this obscure case, as doing so may corrupt the outer Select
138372 ** statements AggInfo structure. */
138373 if( sqlite3ExprIsConstantOrGroupBy(pWalker->pParse, pExpr, pS->pGroupBy)
138374 && ExprAlwaysFalse(pExpr)==0
138375 && pExpr->pAggInfo==0
138376 ){
138377 sqlite3 *db = pWalker->pParse->db;
138378 Expr *pNew = sqlite3Expr(db, TK_INTEGER, "1");
138379 if( pNew ){
138380 Expr *pWhere = pS->pWhere;
@@ -138355,15 +138636,20 @@
138636 SELECTTRACE(0x104,pParse,p, ("after name resolution:\n"));
138637 sqlite3TreeViewSelect(0, p, 0);
138638 }
138639 #endif
138640
138641 /* If the SF_UFSrcCheck flag is set, then this function is being called
138642 ** as part of populating the temp table for an UPDATE...FROM statement.
138643 ** In this case, it is an error if the target object (pSrc->a[0]) name
138644 ** or alias is duplicated within FROM clause (pSrc->a[1..n]).
138645 **
138646 ** Postgres disallows this case too. The reason is that some other
138647 ** systems handle this case differently, and not all the same way,
138648 ** which is just confusing. To avoid this, we follow PG's lead and
138649 ** disallow it altogether. */
138650 if( p->selFlags & SF_UFSrcCheck ){
138651 SrcItem *p0 = &p->pSrc->a[0];
138652 for(i=1; i<p->pSrc->nSrc; i++){
138653 SrcItem *p1 = &p->pSrc->a[i];
138654 if( p0->pTab==p1->pTab && 0==sqlite3_stricmp(p0->zAlias, p1->zAlias) ){
138655 sqlite3ErrorMsg(pParse,
@@ -138371,10 +138657,16 @@
138657 p0->zAlias ? p0->zAlias : p0->pTab->zName
138658 );
138659 goto select_end;
138660 }
138661 }
138662
138663 /* Clear the SF_UFSrcCheck flag. The check has already been performed,
138664 ** and leaving this flag set can cause errors if a compound sub-query
138665 ** in p->pSrc is flattened into this query and this function called
138666 ** again as part of compound SELECT processing. */
138667 p->selFlags &= ~SF_UFSrcCheck;
138668 }
138669
138670 if( pDest->eDest==SRT_Output ){
138671 sqlite3GenerateColumnNames(pParse, p);
138672 }
@@ -138441,10 +138733,43 @@
138733 ** will be implemented as a co-routine and there is no advantage to
138734 ** flattening in that case.
138735 */
138736 if( (pSub->selFlags & SF_Aggregate)!=0 ) continue;
138737 assert( pSub->pGroupBy==0 );
138738
138739 /* If a FROM-clause subquery has an ORDER BY clause that is not
138740 ** really doing anything, then delete it now so that it does not
138741 ** interfere with query flattening. See the discussion at
138742 ** https://sqlite.org/forum/forumpost/2d76f2bcf65d256a
138743 **
138744 ** Beware of these cases where the ORDER BY clause may not be safely
138745 ** omitted:
138746 **
138747 ** (1) There is also a LIMIT clause
138748 ** (2) The subquery was added to help with window-function
138749 ** processing
138750 ** (3) The subquery is in the FROM clause of an UPDATE
138751 ** (4) The outer query uses an aggregate function other than
138752 ** the built-in count(), min(), or max().
138753 ** (5) The ORDER BY isn't going to accomplish anything because
138754 ** one of:
138755 ** (a) The outer query has a different ORDER BY clause
138756 ** (b) The subquery is part of a join
138757 ** See forum post 062d576715d277c8
138758 */
138759 if( pSub->pOrderBy!=0
138760 && (p->pOrderBy!=0 || pTabList->nSrc>1) /* Condition (5) */
138761 && pSub->pLimit==0 /* Condition (1) */
138762 && (pSub->selFlags & SF_OrderByReqd)==0 /* Condition (2) */
138763 && (p->selFlags & SF_OrderByReqd)==0 /* Condition (3) and (4) */
138764 && OptimizationEnabled(db, SQLITE_OmitOrderBy)
138765 ){
138766 SELECTTRACE(0x100,pParse,p,
138767 ("omit superfluous ORDER BY on %r FROM-clause subquery\n",i+1));
138768 sqlite3ExprListDelete(db, pSub->pOrderBy);
138769 pSub->pOrderBy = 0;
138770 }
138771
138772 /* If the outer query contains a "complex" result set (that is,
138773 ** if the result set of the outer query uses functions or subqueries)
138774 ** and if the subquery contains an ORDER BY clause and if
138775 ** it will be implemented as a co-routine, then do not flatten. This
@@ -140596,10 +140921,11 @@
140921 memset(&sFrom, 0, sizeof(sFrom));
140922 sSelect.pEList = sqlite3ExprListDup(db, pReturning->pReturnEL, 0);
140923 sSelect.pSrc = &sFrom;
140924 sFrom.nSrc = 1;
140925 sFrom.a[0].pTab = pTab;
140926 sFrom.a[0].iCursor = -1;
140927 sqlite3SelectPrep(pParse, &sSelect, 0);
140928 if( db->mallocFailed==0 && pParse->nErr==0 ){
140929 sqlite3GenerateColumnNames(pParse, &sSelect);
140930 }
140931 sqlite3ExprListDelete(db, sSelect.pEList);
@@ -141350,12 +141676,13 @@
141676 sqlite3ExprDup(db, pChanges->a[i].pExpr, 0)
141677 );
141678 }
141679 }
141680 pSelect = sqlite3SelectNew(pParse, pList,
141681 pSrc, pWhere2, pGrp, 0, pOrderBy2, SF_UFSrcCheck|SF_IncludeHidden, pLimit2
141682 );
141683 if( pSelect ) pSelect->selFlags |= SF_OrderByReqd;
141684 sqlite3SelectDestInit(&dest, eDest, iEph);
141685 dest.iSDParm2 = (pPk ? pPk->nKeyCol : -1);
141686 sqlite3Select(pParse, pSelect, &dest);
141687 sqlite3SelectDelete(db, pSelect);
141688 }
@@ -142891,12 +143218,12 @@
143218 int rc = SQLITE_OK; /* Return code from service routines */
143219 Btree *pMain; /* The database being vacuumed */
143220 Btree *pTemp; /* The temporary database we vacuum into */
143221 u32 saved_mDbFlags; /* Saved value of db->mDbFlags */
143222 u64 saved_flags; /* Saved value of db->flags */
143223 i64 saved_nChange; /* Saved value of db->nChange */
143224 i64 saved_nTotalChange; /* Saved value of db->nTotalChange */
143225 u32 saved_openFlags; /* Saved value of db->openFlags */
143226 u8 saved_mTrace; /* Saved trace settings */
143227 Db *pDb = 0; /* Database to detach at end of vacuum */
143228 int isMemDb; /* True if vacuuming a :memory: database */
143229 int nRes; /* Bytes of reserved space at the end of each page */
@@ -144337,12 +144664,13 @@
144664 }
144665
144666 /*
144667 ** Check to see if virtual table module pMod can be have an eponymous
144668 ** virtual table instance. If it can, create one if one does not already
144669 ** exist. Return non-zero if either the eponymous virtual table instance
144670 ** exists when this routine returns or if an attempt to create it failed
144671 ** and an error message was left in pParse.
144672 **
144673 ** An eponymous virtual table instance is one that is named after its
144674 ** module, and more importantly, does not require a CREATE VIRTUAL TABLE
144675 ** statement in order to come into existance. Eponymous virtual table
144676 ** instances always exist. They cannot be DROP-ed.
@@ -144377,11 +144705,10 @@
144705 rc = vtabCallConstructor(db, pTab, pMod, pModule->xConnect, &zErr);
144706 if( rc ){
144707 sqlite3ErrorMsg(pParse, "%s", zErr);
144708 sqlite3DbFree(db, zErr);
144709 sqlite3VtabEponymousTableClear(db, pMod);
 
144710 }
144711 return 1;
144712 }
144713
144714 /*
@@ -148940,12 +149267,12 @@
149267 ){
149268 int i;
149269 for(i=0; i<nLeft; i++){
149270 int idxNew;
149271 Expr *pNew;
149272 Expr *pLeft = sqlite3ExprForVectorField(pParse, pExpr->pLeft, i, nLeft);
149273 Expr *pRight = sqlite3ExprForVectorField(pParse, pExpr->pRight, i, nLeft);
149274
149275 pNew = sqlite3PExpr(pParse, pExpr->op, pLeft, pRight);
149276 transferJoinMarkings(pNew, pExpr);
149277 idxNew = whereClauseInsert(pWC, pNew, TERM_DYNAMIC);
149278 exprAnalyze(pSrc, pWC, idxNew);
@@ -154753,10 +155080,16 @@
155080 sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iTabCur);
155081 }
155082 if( (ws & WHERE_INDEXED)
155083 || ((ws & WHERE_MULTI_OR) && pLevel->u.pCovidx)
155084 ){
155085 if( ws & WHERE_MULTI_OR ){
155086 Index *pIx = pLevel->u.pCovidx;
155087 int iDb = sqlite3SchemaToIndex(db, pIx->pSchema);
155088 sqlite3VdbeAddOp3(v, OP_ReopenIdx, pLevel->iIdxCur, pIx->tnum, iDb);
155089 sqlite3VdbeSetP4KeyInfo(pParse, pIx);
155090 }
155091 sqlite3VdbeAddOp1(v, OP_NullRow, pLevel->iIdxCur);
155092 }
155093 if( pLevel->op==OP_Return ){
155094 sqlite3VdbeAddOp2(v, OP_Gosub, pLevel->p1, pLevel->addrFirst);
155095 }else{
@@ -155817,13 +156150,11 @@
156150 break;
156151 }
156152 if( bIntToNull ){
156153 int iDummy;
156154 Expr *pSub;
156155 pSub = sqlite3ExprSkipCollateAndLikely(pDup);
 
 
156156 if( sqlite3ExprIsInteger(pSub, &iDummy) ){
156157 pSub->op = TK_NULL;
156158 pSub->flags &= ~(EP_IntValue|EP_IsTrue|EP_IsFalse);
156159 pSub->u.zToken = 0;
156160 }
@@ -155981,11 +156312,11 @@
156312 p->pSrc = sqlite3SrcListAppend(pParse, 0, 0, 0);
156313 if( p->pSrc ){
156314 Table *pTab2;
156315 p->pSrc->a[0].pSelect = pSub;
156316 sqlite3SrcListAssignCursors(pParse, p->pSrc);
156317 pSub->selFlags |= SF_Expanded|SF_OrderByReqd;
156318 pTab2 = sqlite3ResultSetOfSelect(pParse, pSub, SQLITE_AFF_NONE);
156319 pSub->selFlags |= (selFlags & SF_Aggregate);
156320 if( pTab2==0 ){
156321 /* Might actually be some other kind of error, but in that case
156322 ** pParse->nErr will be set, so if SQLITE_NOMEM is set, we will get
@@ -162431,24 +162762,32 @@
162762 ** simplify to constants 0 (false) and 1 (true), respectively,
162763 ** regardless of the value of expr1.
162764 */
162765 sqlite3ExprUnmapAndDelete(pParse, yymsp[-4].minor.yy404);
162766 yymsp[-4].minor.yy404 = sqlite3Expr(pParse->db, TK_INTEGER, yymsp[-3].minor.yy376 ? "1" : "0");
162767 }else{
162768 Expr *pRHS = yymsp[-1].minor.yy70->a[0].pExpr;
162769 if( yymsp[-1].minor.yy70->nExpr==1 && sqlite3ExprIsConstant(pRHS) && yymsp[-4].minor.yy404->op!=TK_VECTOR ){
162770 yymsp[-1].minor.yy70->a[0].pExpr = 0;
162771 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70);
162772 pRHS = sqlite3PExpr(pParse, TK_UPLUS, pRHS, 0);
162773 yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_EQ, yymsp[-4].minor.yy404, pRHS);
162774 }else{
162775 yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy404, 0);
162776 if( yymsp[-4].minor.yy404==0 ){
162777 sqlite3ExprListDelete(pParse->db, yymsp[-1].minor.yy70);
162778 }else if( yymsp[-4].minor.yy404->pLeft->op==TK_VECTOR ){
162779 int nExpr = yymsp[-4].minor.yy404->pLeft->x.pList->nExpr;
162780 Select *pSelectRHS = sqlite3ExprListToValues(pParse, nExpr, yymsp[-1].minor.yy70);
162781 if( pSelectRHS ){
162782 parserDoubleLinkSelect(pParse, pSelectRHS);
162783 sqlite3PExprAddSelect(pParse, yymsp[-4].minor.yy404, pSelectRHS);
162784 }
162785 }else{
162786 yymsp[-4].minor.yy404->x.pList = yymsp[-1].minor.yy70;
162787 sqlite3ExprSetHeightAndFlags(pParse, yymsp[-4].minor.yy404);
162788 }
162789 }
162790 if( yymsp[-3].minor.yy376 ) yymsp[-4].minor.yy404 = sqlite3PExpr(pParse, TK_NOT, yymsp[-4].minor.yy404, 0);
162791 }
162792 }
162793 break;
@@ -166163,31 +166502,37 @@
166502 }
166503
166504 /*
166505 ** Return the number of changes in the most recent call to sqlite3_exec().
166506 */
166507 SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3 *db){
166508 #ifdef SQLITE_ENABLE_API_ARMOR
166509 if( !sqlite3SafetyCheckOk(db) ){
166510 (void)SQLITE_MISUSE_BKPT;
166511 return 0;
166512 }
166513 #endif
166514 return db->nChange;
166515 }
166516 SQLITE_API int sqlite3_changes(sqlite3 *db){
166517 return (int)sqlite3_changes64(db);
166518 }
166519
166520 /*
166521 ** Return the number of changes since the database handle was opened.
166522 */
166523 SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3 *db){
166524 #ifdef SQLITE_ENABLE_API_ARMOR
166525 if( !sqlite3SafetyCheckOk(db) ){
166526 (void)SQLITE_MISUSE_BKPT;
166527 return 0;
166528 }
166529 #endif
166530 return db->nTotalChange;
166531 }
166532 SQLITE_API int sqlite3_total_changes(sqlite3 *db){
166533 return (int)sqlite3_total_changes64(db);
166534 }
166535
166536 /*
166537 ** Close all open savepoints. This function only manipulates fields of the
166538 ** database handle object, it does not close any savepoints that may be open
@@ -166925,26 +167270,37 @@
167270 ** SQLITE_UTF16NATIVE macro. SQLITE_UTF16 is not used internally.
167271 **
167272 ** If SQLITE_ANY is specified, add three versions of the function
167273 ** to the hash table.
167274 */
167275 switch( enc ){
167276 case SQLITE_UTF16:
167277 enc = SQLITE_UTF16NATIVE;
167278 break;
167279 case SQLITE_ANY: {
167280 int rc;
167281 rc = sqlite3CreateFunc(db, zFunctionName, nArg,
167282 (SQLITE_UTF8|extraFlags)^SQLITE_FUNC_UNSAFE,
167283 pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
167284 if( rc==SQLITE_OK ){
167285 rc = sqlite3CreateFunc(db, zFunctionName, nArg,
167286 (SQLITE_UTF16LE|extraFlags)^SQLITE_FUNC_UNSAFE,
167287 pUserData, xSFunc, xStep, xFinal, xValue, xInverse, pDestructor);
167288 }
167289 if( rc!=SQLITE_OK ){
167290 return rc;
167291 }
167292 enc = SQLITE_UTF16BE;
167293 break;
167294 }
167295 case SQLITE_UTF8:
167296 case SQLITE_UTF16LE:
167297 case SQLITE_UTF16BE:
167298 break;
167299 default:
167300 enc = SQLITE_UTF8;
167301 break;
167302 }
167303 #else
167304 enc = SQLITE_UTF8;
167305 #endif
167306
@@ -167037,11 +167393,11 @@
167393 }
167394 rc = sqlite3CreateFunc(db, zFunc, nArg, enc, p,
167395 xSFunc, xStep, xFinal, xValue, xInverse, pArg
167396 );
167397 if( pArg && pArg->nRef==0 ){
167398 assert( rc!=SQLITE_OK || (xStep==0 && xFinal==0) );
167399 xDestroy(p);
167400 sqlite3_free(pArg);
167401 }
167402
167403 out:
@@ -168220,11 +168576,10 @@
168576 ** SQLITE_OPEN_READWRITE, SQLITE_OPEN_CREATE, SQLITE_OPEN_SHAREDCACHE,
168577 ** SQLITE_OPEN_PRIVATECACHE, and some reserved bits. Silently mask
168578 ** off all other flags.
168579 */
168580 flags &= ~( SQLITE_OPEN_DELETEONCLOSE |
 
168581 SQLITE_OPEN_MAIN_DB |
168582 SQLITE_OPEN_TEMP_DB |
168583 SQLITE_OPEN_TRANSIENT_DB |
168584 SQLITE_OPEN_MAIN_JOURNAL |
168585 SQLITE_OPEN_TEMP_JOURNAL |
@@ -213440,10 +213795,13 @@
213795 /*
213796 ** This interface is used by the fts5vocab module.
213797 */
213798 static const char *sqlite3Fts5IterTerm(Fts5IndexIter*, int*);
213799 static int sqlite3Fts5IterNextScan(Fts5IndexIter*);
213800 static void *sqlite3Fts5StructureRef(Fts5Index*);
213801 static void sqlite3Fts5StructureRelease(void*);
213802 static int sqlite3Fts5StructureTest(Fts5Index*, void*);
213803
213804
213805 /*
213806 ** Insert or remove data to or from the index. Each time a document is
213807 ** added to or removed from the index, this function is called one or more
@@ -216235,20 +216593,21 @@
216593 /* EOF */
216594 *piOff = -1;
216595 return 1;
216596 }else{
216597 i64 iOff = *piOff;
216598 u32 iVal;
216599 fts5FastGetVarint32(a, i, iVal);
216600 assert( iVal>=0 );
216601 if( iVal<=1 ){
216602 if( iVal==0 ){
216603 *pi = i;
216604 return 0;
216605 }
216606 fts5FastGetVarint32(a, i, iVal);
216607 iOff = ((i64)iVal) << 32;
216608 assert( iOff>=0 );
216609 fts5FastGetVarint32(a, i, iVal);
216610 if( iVal<2 ){
216611 /* This is a corrupt record. So stop parsing it here. */
216612 *piOff = -1;
216613 return 1;
@@ -216256,11 +216615,11 @@
216615 *piOff = iOff + ((iVal-2) & 0x7FFFFFFF);
216616 }else{
216617 *piOff = (iOff & (i64)0x7FFFFFFF<<32)+((iOff + (iVal-2)) & 0x7FFFFFFF);
216618 }
216619 *pi = i;
216620 assert_nc( *piOff>=iOff );
216621 return 0;
216622 }
216623 }
216624
216625
@@ -217565,10 +217924,11 @@
217924
217925 static void sqlite3Fts5ParseError(Fts5Parse *pParse, const char *zFmt, ...){
217926 va_list ap;
217927 va_start(ap, zFmt);
217928 if( pParse->rc==SQLITE_OK ){
217929 assert( pParse->zErr==0 );
217930 pParse->zErr = sqlite3_vmprintf(zFmt, ap);
217931 pParse->rc = SQLITE_ERROR;
217932 }
217933 va_end(ap);
217934 }
@@ -219574,13 +219934,12 @@
219934 Fts5ExprNode *pExpr,
219935 Fts5Colset *pColset
219936 ){
219937 Fts5Colset *pFree = pColset;
219938 if( pParse->pConfig->eDetail==FTS5_DETAIL_NONE ){
219939 sqlite3Fts5ParseError(pParse,
219940 "fts5: column queries are not supported (detail=none)"
 
219941 );
219942 }else{
219943 fts5ParseSetColset(pParse, pExpr, pColset, &pFree);
219944 }
219945 sqlite3_free(pFree);
@@ -219750,17 +220109,14 @@
220109 Fts5ExprPhrase *pPhrase = pNear->apPhrase[0];
220110 if( pNear->nPhrase!=1
220111 || pPhrase->nTerm>1
220112 || (pPhrase->nTerm>0 && pPhrase->aTerm[0].bFirst)
220113 ){
220114 sqlite3Fts5ParseError(pParse,
 
 
 
220115 "fts5: %s queries are not supported (detail!=full)",
220116 pNear->nPhrase==1 ? "phrase": "NEAR"
220117 );
220118 sqlite3_free(pRet);
220119 pRet = 0;
220120 }
220121 }
220122 }else{
@@ -221873,10 +222229,26 @@
222229 }
222230
222231 static void fts5StructureRef(Fts5Structure *pStruct){
222232 pStruct->nRef++;
222233 }
222234
222235 static void *sqlite3Fts5StructureRef(Fts5Index *p){
222236 fts5StructureRef(p->pStruct);
222237 return (void*)p->pStruct;
222238 }
222239 static void sqlite3Fts5StructureRelease(void *p){
222240 if( p ){
222241 fts5StructureRelease((Fts5Structure*)p);
222242 }
222243 }
222244 static int sqlite3Fts5StructureTest(Fts5Index *p, void *pStruct){
222245 if( p->pStruct!=(Fts5Structure*)pStruct ){
222246 return SQLITE_ABORT;
222247 }
222248 return SQLITE_OK;
222249 }
222250
222251 /*
222252 ** Deserialize and return the structure record currently stored in serialized
222253 ** form within buffer pData/nData.
222254 **
@@ -230580,11 +230952,11 @@
230952 int nArg, /* Number of args */
230953 sqlite3_value **apUnused /* Function arguments */
230954 ){
230955 assert( nArg==0 );
230956 UNUSED_PARAM2(nArg, apUnused);
230957 sqlite3_result_text(pCtx, "fts5: 2021-07-20 14:57:49 1e35cc6d5c2f563c6bb163bb150d7bc6ede4c993efa828af1face3261bf65a2c", -1, SQLITE_TRANSIENT);
230958 }
230959
230960 /*
230961 ** Return true if zName is the extension on one of the shadow tables used
230962 ** by this module.
@@ -234476,10 +234848,11 @@
234848 sqlite3_stmt *pStmt; /* Statement holding lock on pIndex */
234849 Fts5Table *pFts5; /* Associated FTS5 table */
234850
234851 int bEof; /* True if this cursor is at EOF */
234852 Fts5IndexIter *pIter; /* Term/rowid iterator object */
234853 void *pStruct; /* From sqlite3Fts5StructureRef() */
234854
234855 int nLeTerm; /* Size of zLeTerm in bytes */
234856 char *zLeTerm; /* (term <= $zLeTerm) paramater, or NULL */
234857
234858 /* These are used by 'col' tables only */
@@ -234809,10 +235182,12 @@
235182 }
235183
235184 static void fts5VocabResetCursor(Fts5VocabCursor *pCsr){
235185 pCsr->rowid = 0;
235186 sqlite3Fts5IterClose(pCsr->pIter);
235187 sqlite3Fts5StructureRelease(pCsr->pStruct);
235188 pCsr->pStruct = 0;
235189 pCsr->pIter = 0;
235190 sqlite3_free(pCsr->zLeTerm);
235191 pCsr->nLeTerm = -1;
235192 pCsr->zLeTerm = 0;
235193 pCsr->bEof = 0;
@@ -234886,13 +235261,15 @@
235261 ** Advance the cursor to the next row in the table.
235262 */
235263 static int fts5VocabNextMethod(sqlite3_vtab_cursor *pCursor){
235264 Fts5VocabCursor *pCsr = (Fts5VocabCursor*)pCursor;
235265 Fts5VocabTable *pTab = (Fts5VocabTable*)pCursor->pVtab;
 
235266 int nCol = pCsr->pFts5->pConfig->nCol;
235267 int rc;
235268
235269 rc = sqlite3Fts5StructureTest(pCsr->pFts5->pIndex, pCsr->pStruct);
235270 if( rc!=SQLITE_OK ) return rc;
235271 pCsr->rowid++;
235272
235273 if( pTab->eType==FTS5_VOCAB_INSTANCE ){
235274 return fts5VocabInstanceNext(pCsr);
235275 }
@@ -235062,10 +235439,13 @@
235439 }
235440
235441 if( rc==SQLITE_OK ){
235442 Fts5Index *pIndex = pCsr->pFts5->pIndex;
235443 rc = sqlite3Fts5IndexQuery(pIndex, zTerm, nTerm, f, 0, &pCsr->pIter);
235444 if( rc==SQLITE_OK ){
235445 pCsr->pStruct = sqlite3Fts5StructureRef(pIndex);
235446 }
235447 }
235448 if( rc==SQLITE_OK && eType==FTS5_VOCAB_INSTANCE ){
235449 rc = fts5VocabInstanceNewTerm(pCsr);
235450 }
235451 if( rc==SQLITE_OK && !pCsr->bEof
@@ -235506,12 +235886,8 @@
235886 }
235887 #endif /* SQLITE_CORE */
235888 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
235889
235890 /************** End of stmt.c ************************************************/
 
 
 
 
235891 /* Return the source-id for this library */
235892 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
235893 /************************** End of sqlite3.c ******************************/
235894
+62 -13
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -41,11 +41,34 @@
4141
extern "C" {
4242
#endif
4343
4444
4545
/*
46
-** Provide the ability to override linkage features of the interface.
46
+** Facilitate override of interface linkage and calling conventions.
47
+** Be aware that these macros may not be used within this particular
48
+** translation of the amalgamation and its associated header file.
49
+**
50
+** The SQLITE_EXTERN and SQLITE_API macros are used to instruct the
51
+** compiler that the target identifier should have external linkage.
52
+**
53
+** The SQLITE_CDECL macro is used to set the calling convention for
54
+** public functions that accept a variable number of arguments.
55
+**
56
+** The SQLITE_APICALL macro is used to set the calling convention for
57
+** public functions that accept a fixed number of arguments.
58
+**
59
+** The SQLITE_STDCALL macro is no longer used and is now deprecated.
60
+**
61
+** The SQLITE_CALLBACK macro is used to set the calling convention for
62
+** function pointers.
63
+**
64
+** The SQLITE_SYSAPI macro is used to set the calling convention for
65
+** functions provided by the operating system.
66
+**
67
+** Currently, the SQLITE_CDECL, SQLITE_APICALL, SQLITE_CALLBACK, and
68
+** SQLITE_SYSAPI macros are used only when building for environments
69
+** that require non-default calling conventions.
4770
*/
4871
#ifndef SQLITE_EXTERN
4972
# define SQLITE_EXTERN extern
5073
#endif
5174
#ifndef SQLITE_API
@@ -121,13 +144,13 @@
121144
**
122145
** See also: [sqlite3_libversion()],
123146
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124147
** [sqlite_version()] and [sqlite_source_id()].
125148
*/
126
-#define SQLITE_VERSION "3.36.0"
127
-#define SQLITE_VERSION_NUMBER 3036000
128
-#define SQLITE_SOURCE_ID "2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5"
149
+#define SQLITE_VERSION "3.37.0"
150
+#define SQLITE_VERSION_NUMBER 3037000
151
+#define SQLITE_SOURCE_ID "2021-07-21 15:42:05 60695359dc5d3bcba68a68e1842c40f4a01650eb5af408e02fb856fd8245e16d"
129152
130153
/*
131154
** CAPI3REF: Run-Time Library Version Numbers
132155
** KEYWORDS: sqlite3_version sqlite3_sourceid
133156
**
@@ -514,10 +537,11 @@
514537
#define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
515538
#define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
516539
#define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
517540
#define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
518541
#define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8))
542
+#define SQLITE_CANTOPEN_EXISTS (SQLITE_CANTOPEN | (7<<8))
519543
#define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
520544
#define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
521545
#define SQLITE_CORRUPT_INDEX (SQLITE_CORRUPT | (3<<8))
522546
#define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
523547
#define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
@@ -2462,15 +2486,18 @@
24622486
24632487
/*
24642488
** CAPI3REF: Count The Number Of Rows Modified
24652489
** METHOD: sqlite3
24662490
**
2467
-** ^This function returns the number of rows modified, inserted or
2491
+** ^These functions return the number of rows modified, inserted or
24682492
** deleted by the most recently completed INSERT, UPDATE or DELETE
24692493
** statement on the database connection specified by the only parameter.
2470
-** ^Executing any other type of SQL statement does not modify the value
2471
-** returned by this function.
2494
+** The two functions are identical except for the type of the return value
2495
+** and that if the number of rows modified by the most recent INSERT, UPDATE
2496
+** or DELETE is greater than the maximum value supported by type "int", then
2497
+** the return value of sqlite3_changes() is undefined. ^Executing any other
2498
+** type of SQL statement does not modify the value returned by these functions.
24722499
**
24732500
** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
24742501
** considered - auxiliary changes caused by [CREATE TRIGGER | triggers],
24752502
** [foreign key actions] or [REPLACE] constraint resolution are not counted.
24762503
**
@@ -2515,20 +2542,25 @@
25152542
** <li> the [changes() SQL function]
25162543
** <li> the [data_version pragma]
25172544
** </ul>
25182545
*/
25192546
SQLITE_API int sqlite3_changes(sqlite3*);
2547
+SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3*);
25202548
25212549
/*
25222550
** CAPI3REF: Total Number Of Rows Modified
25232551
** METHOD: sqlite3
25242552
**
2525
-** ^This function returns the total number of rows inserted, modified or
2553
+** ^These functions return the total number of rows inserted, modified or
25262554
** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
25272555
** since the database connection was opened, including those executed as
2528
-** part of trigger programs. ^Executing any other type of SQL statement
2529
-** does not affect the value returned by sqlite3_total_changes().
2556
+** part of trigger programs. The two functions are identical except for the
2557
+** type of the return value and that if the number of rows modified by the
2558
+** connection exceeds the maximum value supported by type "int", then
2559
+** the return value of sqlite3_total_changes() is undefined. ^Executing
2560
+** any other type of SQL statement does not affect the value returned by
2561
+** sqlite3_total_changes().
25302562
**
25312563
** ^Changes made as part of [foreign key actions] are included in the
25322564
** count, but those made as part of REPLACE constraint resolution are
25332565
** not. ^Changes to a view that are intercepted by INSTEAD OF triggers
25342566
** are not counted.
@@ -2552,10 +2584,11 @@
25522584
** <li> the [data_version pragma]
25532585
** <li> the [SQLITE_FCNTL_DATA_VERSION] [file control]
25542586
** </ul>
25552587
*/
25562588
SQLITE_API int sqlite3_total_changes(sqlite3*);
2589
+SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3*);
25572590
25582591
/*
25592592
** CAPI3REF: Interrupt A Long-Running Query
25602593
** METHOD: sqlite3
25612594
**
@@ -3383,10 +3416,16 @@
33833416
** the default shared cache setting provided by
33843417
** [sqlite3_enable_shared_cache()].)^
33853418
**
33863419
** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt>
33873420
** <dd>The database filename is not allowed to be a symbolic link</dd>
3421
+**
3422
+** [[OPEN_EXCLUSIVE]] ^(<dt>[SQLITE_OPEN_EXCLUSIVE]</dt>
3423
+** <dd>This flag causes the open to fail if the database file already
3424
+** exists. The open will only be success if this flag is used in combination
3425
+** with the SQLITE_OPEN_CREATE and SQLITE_OPEN_READWRITE flags and if
3426
+** the file does not previously exist.</dd>
33883427
** </dl>)^
33893428
**
33903429
** If the 3rd parameter to sqlite3_open_v2() is not one of the
33913430
** required combinations shown above optionally combined with other
33923431
** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]
@@ -4156,16 +4195,21 @@
41564195
**
41574196
** ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P)
41584197
** are managed by SQLite and are automatically freed when the prepared
41594198
** statement is finalized.
41604199
** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
4161
-** is obtained from [sqlite3_malloc()] and must be free by the application
4200
+** is obtained from [sqlite3_malloc()] and must be freed by the application
41624201
** by passing it to [sqlite3_free()].
4202
+**
4203
+** ^The sqlite3_normalized_sql() interface is only available if
4204
+** the [SQLITE_ENABLE_NORMALIZE] compile-time option is defined.
41634205
*/
41644206
SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
41654207
SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
4208
+#ifdef SQLITE_ENABLE_NORMALIZE
41664209
SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
4210
+#endif
41674211
41684212
/*
41694213
** CAPI3REF: Determine If An SQL Statement Writes The Database
41704214
** METHOD: sqlite3_stmt
41714215
**
@@ -9008,12 +9052,13 @@
90089052
** that does not correspond to any valid SQLite error code, the results
90099053
** are undefined.
90109054
**
90119055
** A single database handle may have at most a single write-ahead log callback
90129056
** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any
9013
-** previously registered write-ahead log callback. ^Note that the
9014
-** [sqlite3_wal_autocheckpoint()] interface and the
9057
+** previously registered write-ahead log callback. ^The return value is
9058
+** a copy of the third parameter from the previous call, if any, or 0.
9059
+** ^Note that the [sqlite3_wal_autocheckpoint()] interface and the
90159060
** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
90169061
** overwrite any prior [sqlite3_wal_hook()] settings.
90179062
*/
90189063
SQLITE_API void *sqlite3_wal_hook(
90199064
sqlite3*,
@@ -9875,10 +9920,14 @@
98759920
** if writes on the database cause it to grow larger than M bytes.
98769921
**
98779922
** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the
98789923
** database is currently in a read transaction or is involved in a backup
98799924
** operation.
9925
+**
9926
+** It is not possible to deserialized into the TEMP database. If the
9927
+** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the
9928
+** function returns SQLITE_ERROR.
98809929
**
98819930
** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
98829931
** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
98839932
** [sqlite3_free()] is invoked on argument P prior to returning.
98849933
**
98859934
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -41,11 +41,34 @@
41 extern "C" {
42 #endif
43
44
45 /*
46 ** Provide the ability to override linkage features of the interface.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47 */
48 #ifndef SQLITE_EXTERN
49 # define SQLITE_EXTERN extern
50 #endif
51 #ifndef SQLITE_API
@@ -121,13 +144,13 @@
121 **
122 ** See also: [sqlite3_libversion()],
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.36.0"
127 #define SQLITE_VERSION_NUMBER 3036000
128 #define SQLITE_SOURCE_ID "2021-06-18 18:36:39 5c9a6c06871cb9fe42814af9c039eb6da5427a6ec28f187af7ebfb62eafa66e5"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
@@ -514,10 +537,11 @@
514 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
515 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
516 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
517 #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
518 #define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8))
 
519 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
520 #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
521 #define SQLITE_CORRUPT_INDEX (SQLITE_CORRUPT | (3<<8))
522 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
523 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
@@ -2462,15 +2486,18 @@
2462
2463 /*
2464 ** CAPI3REF: Count The Number Of Rows Modified
2465 ** METHOD: sqlite3
2466 **
2467 ** ^This function returns the number of rows modified, inserted or
2468 ** deleted by the most recently completed INSERT, UPDATE or DELETE
2469 ** statement on the database connection specified by the only parameter.
2470 ** ^Executing any other type of SQL statement does not modify the value
2471 ** returned by this function.
 
 
 
2472 **
2473 ** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
2474 ** considered - auxiliary changes caused by [CREATE TRIGGER | triggers],
2475 ** [foreign key actions] or [REPLACE] constraint resolution are not counted.
2476 **
@@ -2515,20 +2542,25 @@
2515 ** <li> the [changes() SQL function]
2516 ** <li> the [data_version pragma]
2517 ** </ul>
2518 */
2519 SQLITE_API int sqlite3_changes(sqlite3*);
 
2520
2521 /*
2522 ** CAPI3REF: Total Number Of Rows Modified
2523 ** METHOD: sqlite3
2524 **
2525 ** ^This function returns the total number of rows inserted, modified or
2526 ** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
2527 ** since the database connection was opened, including those executed as
2528 ** part of trigger programs. ^Executing any other type of SQL statement
2529 ** does not affect the value returned by sqlite3_total_changes().
 
 
 
 
2530 **
2531 ** ^Changes made as part of [foreign key actions] are included in the
2532 ** count, but those made as part of REPLACE constraint resolution are
2533 ** not. ^Changes to a view that are intercepted by INSTEAD OF triggers
2534 ** are not counted.
@@ -2552,10 +2584,11 @@
2552 ** <li> the [data_version pragma]
2553 ** <li> the [SQLITE_FCNTL_DATA_VERSION] [file control]
2554 ** </ul>
2555 */
2556 SQLITE_API int sqlite3_total_changes(sqlite3*);
 
2557
2558 /*
2559 ** CAPI3REF: Interrupt A Long-Running Query
2560 ** METHOD: sqlite3
2561 **
@@ -3383,10 +3416,16 @@
3383 ** the default shared cache setting provided by
3384 ** [sqlite3_enable_shared_cache()].)^
3385 **
3386 ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt>
3387 ** <dd>The database filename is not allowed to be a symbolic link</dd>
 
 
 
 
 
 
3388 ** </dl>)^
3389 **
3390 ** If the 3rd parameter to sqlite3_open_v2() is not one of the
3391 ** required combinations shown above optionally combined with other
3392 ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]
@@ -4156,16 +4195,21 @@
4156 **
4157 ** ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P)
4158 ** are managed by SQLite and are automatically freed when the prepared
4159 ** statement is finalized.
4160 ** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
4161 ** is obtained from [sqlite3_malloc()] and must be free by the application
4162 ** by passing it to [sqlite3_free()].
 
 
 
4163 */
4164 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
4165 SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
 
4166 SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
 
4167
4168 /*
4169 ** CAPI3REF: Determine If An SQL Statement Writes The Database
4170 ** METHOD: sqlite3_stmt
4171 **
@@ -9008,12 +9052,13 @@
9008 ** that does not correspond to any valid SQLite error code, the results
9009 ** are undefined.
9010 **
9011 ** A single database handle may have at most a single write-ahead log callback
9012 ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any
9013 ** previously registered write-ahead log callback. ^Note that the
9014 ** [sqlite3_wal_autocheckpoint()] interface and the
 
9015 ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
9016 ** overwrite any prior [sqlite3_wal_hook()] settings.
9017 */
9018 SQLITE_API void *sqlite3_wal_hook(
9019 sqlite3*,
@@ -9875,10 +9920,14 @@
9875 ** if writes on the database cause it to grow larger than M bytes.
9876 **
9877 ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the
9878 ** database is currently in a read transaction or is involved in a backup
9879 ** operation.
 
 
 
 
9880 **
9881 ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
9882 ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
9883 ** [sqlite3_free()] is invoked on argument P prior to returning.
9884 **
9885
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -41,11 +41,34 @@
41 extern "C" {
42 #endif
43
44
45 /*
46 ** Facilitate override of interface linkage and calling conventions.
47 ** Be aware that these macros may not be used within this particular
48 ** translation of the amalgamation and its associated header file.
49 **
50 ** The SQLITE_EXTERN and SQLITE_API macros are used to instruct the
51 ** compiler that the target identifier should have external linkage.
52 **
53 ** The SQLITE_CDECL macro is used to set the calling convention for
54 ** public functions that accept a variable number of arguments.
55 **
56 ** The SQLITE_APICALL macro is used to set the calling convention for
57 ** public functions that accept a fixed number of arguments.
58 **
59 ** The SQLITE_STDCALL macro is no longer used and is now deprecated.
60 **
61 ** The SQLITE_CALLBACK macro is used to set the calling convention for
62 ** function pointers.
63 **
64 ** The SQLITE_SYSAPI macro is used to set the calling convention for
65 ** functions provided by the operating system.
66 **
67 ** Currently, the SQLITE_CDECL, SQLITE_APICALL, SQLITE_CALLBACK, and
68 ** SQLITE_SYSAPI macros are used only when building for environments
69 ** that require non-default calling conventions.
70 */
71 #ifndef SQLITE_EXTERN
72 # define SQLITE_EXTERN extern
73 #endif
74 #ifndef SQLITE_API
@@ -121,13 +144,13 @@
144 **
145 ** See also: [sqlite3_libversion()],
146 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
147 ** [sqlite_version()] and [sqlite_source_id()].
148 */
149 #define SQLITE_VERSION "3.37.0"
150 #define SQLITE_VERSION_NUMBER 3037000
151 #define SQLITE_SOURCE_ID "2021-07-21 15:42:05 60695359dc5d3bcba68a68e1842c40f4a01650eb5af408e02fb856fd8245e16d"
152
153 /*
154 ** CAPI3REF: Run-Time Library Version Numbers
155 ** KEYWORDS: sqlite3_version sqlite3_sourceid
156 **
@@ -514,10 +537,11 @@
537 #define SQLITE_CANTOPEN_ISDIR (SQLITE_CANTOPEN | (2<<8))
538 #define SQLITE_CANTOPEN_FULLPATH (SQLITE_CANTOPEN | (3<<8))
539 #define SQLITE_CANTOPEN_CONVPATH (SQLITE_CANTOPEN | (4<<8))
540 #define SQLITE_CANTOPEN_DIRTYWAL (SQLITE_CANTOPEN | (5<<8)) /* Not Used */
541 #define SQLITE_CANTOPEN_SYMLINK (SQLITE_CANTOPEN | (6<<8))
542 #define SQLITE_CANTOPEN_EXISTS (SQLITE_CANTOPEN | (7<<8))
543 #define SQLITE_CORRUPT_VTAB (SQLITE_CORRUPT | (1<<8))
544 #define SQLITE_CORRUPT_SEQUENCE (SQLITE_CORRUPT | (2<<8))
545 #define SQLITE_CORRUPT_INDEX (SQLITE_CORRUPT | (3<<8))
546 #define SQLITE_READONLY_RECOVERY (SQLITE_READONLY | (1<<8))
547 #define SQLITE_READONLY_CANTLOCK (SQLITE_READONLY | (2<<8))
@@ -2462,15 +2486,18 @@
2486
2487 /*
2488 ** CAPI3REF: Count The Number Of Rows Modified
2489 ** METHOD: sqlite3
2490 **
2491 ** ^These functions return the number of rows modified, inserted or
2492 ** deleted by the most recently completed INSERT, UPDATE or DELETE
2493 ** statement on the database connection specified by the only parameter.
2494 ** The two functions are identical except for the type of the return value
2495 ** and that if the number of rows modified by the most recent INSERT, UPDATE
2496 ** or DELETE is greater than the maximum value supported by type "int", then
2497 ** the return value of sqlite3_changes() is undefined. ^Executing any other
2498 ** type of SQL statement does not modify the value returned by these functions.
2499 **
2500 ** ^Only changes made directly by the INSERT, UPDATE or DELETE statement are
2501 ** considered - auxiliary changes caused by [CREATE TRIGGER | triggers],
2502 ** [foreign key actions] or [REPLACE] constraint resolution are not counted.
2503 **
@@ -2515,20 +2542,25 @@
2542 ** <li> the [changes() SQL function]
2543 ** <li> the [data_version pragma]
2544 ** </ul>
2545 */
2546 SQLITE_API int sqlite3_changes(sqlite3*);
2547 SQLITE_API sqlite3_int64 sqlite3_changes64(sqlite3*);
2548
2549 /*
2550 ** CAPI3REF: Total Number Of Rows Modified
2551 ** METHOD: sqlite3
2552 **
2553 ** ^These functions return the total number of rows inserted, modified or
2554 ** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
2555 ** since the database connection was opened, including those executed as
2556 ** part of trigger programs. The two functions are identical except for the
2557 ** type of the return value and that if the number of rows modified by the
2558 ** connection exceeds the maximum value supported by type "int", then
2559 ** the return value of sqlite3_total_changes() is undefined. ^Executing
2560 ** any other type of SQL statement does not affect the value returned by
2561 ** sqlite3_total_changes().
2562 **
2563 ** ^Changes made as part of [foreign key actions] are included in the
2564 ** count, but those made as part of REPLACE constraint resolution are
2565 ** not. ^Changes to a view that are intercepted by INSTEAD OF triggers
2566 ** are not counted.
@@ -2552,10 +2584,11 @@
2584 ** <li> the [data_version pragma]
2585 ** <li> the [SQLITE_FCNTL_DATA_VERSION] [file control]
2586 ** </ul>
2587 */
2588 SQLITE_API int sqlite3_total_changes(sqlite3*);
2589 SQLITE_API sqlite3_int64 sqlite3_total_changes64(sqlite3*);
2590
2591 /*
2592 ** CAPI3REF: Interrupt A Long-Running Query
2593 ** METHOD: sqlite3
2594 **
@@ -3383,10 +3416,16 @@
3416 ** the default shared cache setting provided by
3417 ** [sqlite3_enable_shared_cache()].)^
3418 **
3419 ** [[OPEN_NOFOLLOW]] ^(<dt>[SQLITE_OPEN_NOFOLLOW]</dt>
3420 ** <dd>The database filename is not allowed to be a symbolic link</dd>
3421 **
3422 ** [[OPEN_EXCLUSIVE]] ^(<dt>[SQLITE_OPEN_EXCLUSIVE]</dt>
3423 ** <dd>This flag causes the open to fail if the database file already
3424 ** exists. The open will only be success if this flag is used in combination
3425 ** with the SQLITE_OPEN_CREATE and SQLITE_OPEN_READWRITE flags and if
3426 ** the file does not previously exist.</dd>
3427 ** </dl>)^
3428 **
3429 ** If the 3rd parameter to sqlite3_open_v2() is not one of the
3430 ** required combinations shown above optionally combined with other
3431 ** [SQLITE_OPEN_READONLY | SQLITE_OPEN_* bits]
@@ -4156,16 +4195,21 @@
4195 **
4196 ** ^The strings returned by sqlite3_sql(P) and sqlite3_normalized_sql(P)
4197 ** are managed by SQLite and are automatically freed when the prepared
4198 ** statement is finalized.
4199 ** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
4200 ** is obtained from [sqlite3_malloc()] and must be freed by the application
4201 ** by passing it to [sqlite3_free()].
4202 **
4203 ** ^The sqlite3_normalized_sql() interface is only available if
4204 ** the [SQLITE_ENABLE_NORMALIZE] compile-time option is defined.
4205 */
4206 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
4207 SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt);
4208 #ifdef SQLITE_ENABLE_NORMALIZE
4209 SQLITE_API const char *sqlite3_normalized_sql(sqlite3_stmt *pStmt);
4210 #endif
4211
4212 /*
4213 ** CAPI3REF: Determine If An SQL Statement Writes The Database
4214 ** METHOD: sqlite3_stmt
4215 **
@@ -9008,12 +9052,13 @@
9052 ** that does not correspond to any valid SQLite error code, the results
9053 ** are undefined.
9054 **
9055 ** A single database handle may have at most a single write-ahead log callback
9056 ** registered at one time. ^Calling [sqlite3_wal_hook()] replaces any
9057 ** previously registered write-ahead log callback. ^The return value is
9058 ** a copy of the third parameter from the previous call, if any, or 0.
9059 ** ^Note that the [sqlite3_wal_autocheckpoint()] interface and the
9060 ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
9061 ** overwrite any prior [sqlite3_wal_hook()] settings.
9062 */
9063 SQLITE_API void *sqlite3_wal_hook(
9064 sqlite3*,
@@ -9875,10 +9920,14 @@
9920 ** if writes on the database cause it to grow larger than M bytes.
9921 **
9922 ** The sqlite3_deserialize() interface will fail with SQLITE_BUSY if the
9923 ** database is currently in a read transaction or is involved in a backup
9924 ** operation.
9925 **
9926 ** It is not possible to deserialized into the TEMP database. If the
9927 ** S argument to sqlite3_deserialize(D,S,P,N,M,F) is "temp" then the
9928 ** function returns SQLITE_ERROR.
9929 **
9930 ** If sqlite3_deserialize(D,S,P,N,M,F) fails for any reason and if the
9931 ** SQLITE_DESERIALIZE_FREEONCLOSE bit is set in argument F, then
9932 ** [sqlite3_free()] is invoked on argument P prior to returning.
9933 **
9934

Keyboard Shortcuts

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