Fossil SCM

Update the built-in SQLite to the latest 3.29.0 alpha.

drh 2019-06-05 19:45 trunk
Commit 9c128d2e896fd59b88edb869acaf0042734c0e974e8d9d0f0bc2a01814333264
3 files changed +124 +129 -103 +1 -1
+124
--- src/shell.c
+++ src/shell.c
@@ -12053,10 +12053,12 @@
1205312053
".exit ?CODE? Exit this program with return-code CODE",
1205412054
".expert EXPERIMENTAL. Suggest indexes for specified queries",
1205512055
/* Because explain mode comes on automatically now, the ".explain" mode
1205612056
** is removed from the help screen. It is still supported for legacy, however */
1205712057
/*".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic",*/
12058
+ ".filectrl CMD ... Run various sqlite3_file_control() operations",
12059
+ " Run \".filectrl\" with no arguments for details",
1205812060
".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
1205912061
".headers on|off Turn display of headers on or off",
1206012062
".help ?-all? ?PATTERN? Show help text for PATTERN",
1206112063
".import FILE TABLE Import data from FILE into TABLE",
1206212064
#ifndef SQLITE_OMIT_TEST_CONTROL
@@ -12170,10 +12172,12 @@
1217012172
#ifndef SQLITE_NOHAVE_SYSTEM
1217112173
".system CMD ARGS... Run CMD ARGS... in a system shell",
1217212174
#endif
1217312175
".tables ?TABLE? List names of tables matching LIKE pattern TABLE",
1217412176
".testcase NAME Begin redirecting output to 'testcase-out.txt'",
12177
+ ".testctrl CMD ... Run various sqlite3_test_control() operations",
12178
+ " Run \".testctrl\" with no arguments for details",
1217512179
".timeout MS Try opening locked tables for MS milliseconds",
1217612180
".timer on|off Turn SQL timer on or off",
1217712181
#ifndef SQLITE_OMIT_TRACE
1217812182
".trace ?OPTIONS? Output each SQL statement as it is run",
1217912183
" FILE Send output to FILE",
@@ -13392,10 +13396,11 @@
1339213396
utf8_printf(stderr, "Failed: [%s]\n", zCmd);
1339313397
}
1339413398
sqlite3_free(zCmd);
1339513399
outputModePop(p);
1339613400
p->doXdgOpen = 0;
13401
+ sqlite3_sleep(100);
1339713402
}
1339813403
#endif /* !defined(SQLITE_NOHAVE_SYSTEM) */
1339913404
}
1340013405
p->outfile[0] = 0;
1340113406
p->out = stdout;
@@ -15818,10 +15823,129 @@
1581815823
if( c=='e' && strncmp(azArg[0], "expert", n)==0 ){
1581915824
open_db(p, 0);
1582015825
expertDotCommand(p, azArg, nArg);
1582115826
}else
1582215827
#endif
15828
+
15829
+ if( c=='f' && strncmp(azArg[0], "filectrl", n)==0 ){
15830
+ static const struct {
15831
+ const char *zCtrlName; /* Name of a test-control option */
15832
+ int ctrlCode; /* Integer code for that option */
15833
+ const char *zUsage; /* Usage notes */
15834
+ } aCtrl[] = {
15835
+ { "size_limit", SQLITE_FCNTL_SIZE_LIMIT, "[LIMIT]" },
15836
+ { "chunk_size", SQLITE_FCNTL_CHUNK_SIZE, "SIZE" },
15837
+ /* { "win32_av_retry", SQLITE_FCNTL_WIN32_AV_RETRY, "COUNT DELAY" },*/
15838
+ { "persist_wal", SQLITE_FCNTL_PERSIST_WAL, "[BOOLEAN]" },
15839
+ { "psow", SQLITE_FCNTL_POWERSAFE_OVERWRITE, "[BOOLEAN]" },
15840
+ /* { "pragma", SQLITE_FCNTL_PRAGMA, "NAME ARG" },*/
15841
+ { "tempfilename", SQLITE_FCNTL_TEMPFILENAME, "" },
15842
+ { "has_moved", SQLITE_FCNTL_HAS_MOVED, "" },
15843
+ { "lock_timeout", SQLITE_FCNTL_LOCK_TIMEOUT, "MILLISEC" },
15844
+ };
15845
+ int filectrl = -1;
15846
+ int iCtrl = -1;
15847
+ sqlite3_int64 iRes; /* Integer result to display if rc2==1 */
15848
+ int isOk = 0; /* 0: usage 1: %lld 2: no-result */
15849
+ int n2, i;
15850
+ const char *zCmd = 0;
15851
+
15852
+ open_db(p, 0);
15853
+ zCmd = nArg>=2 ? azArg[1] : "help";
15854
+
15855
+ /* The argument can optionally begin with "-" or "--" */
15856
+ if( zCmd[0]=='-' && zCmd[1] ){
15857
+ zCmd++;
15858
+ if( zCmd[0]=='-' && zCmd[1] ) zCmd++;
15859
+ }
15860
+
15861
+ /* --help lists all file-controls */
15862
+ if( strcmp(zCmd,"help")==0 ){
15863
+ utf8_printf(p->out, "Available file-controls:\n");
15864
+ for(i=0; i<ArraySize(aCtrl); i++){
15865
+ utf8_printf(p->out, " .filectrl %s %s\n",
15866
+ aCtrl[i].zCtrlName, aCtrl[i].zUsage);
15867
+ }
15868
+ rc = 1;
15869
+ goto meta_command_exit;
15870
+ }
15871
+
15872
+ /* convert filectrl text option to value. allow any unique prefix
15873
+ ** of the option name, or a numerical value. */
15874
+ n2 = strlen30(zCmd);
15875
+ for(i=0; i<ArraySize(aCtrl); i++){
15876
+ if( strncmp(zCmd, aCtrl[i].zCtrlName, n2)==0 ){
15877
+ if( filectrl<0 ){
15878
+ filectrl = aCtrl[i].ctrlCode;
15879
+ iCtrl = i;
15880
+ }else{
15881
+ utf8_printf(stderr, "Error: ambiguous file-control: \"%s\"\n"
15882
+ "Use \".filectrl --help\" for help\n", zCmd);
15883
+ rc = 1;
15884
+ goto meta_command_exit;
15885
+ }
15886
+ }
15887
+ }
15888
+ if( filectrl<0 ){
15889
+ utf8_printf(stderr,"Error: unknown file-control: %s\n"
15890
+ "Use \".filectrl --help\" for help\n", zCmd);
15891
+ }else{
15892
+ switch(filectrl){
15893
+ case SQLITE_FCNTL_SIZE_LIMIT: {
15894
+ if( nArg!=2 && nArg!=3 ) break;
15895
+ iRes = nArg==3 ? integerValue(azArg[2]) : -1;
15896
+ sqlite3_file_control(p->db, 0, SQLITE_FCNTL_SIZE_LIMIT, &iRes);
15897
+ isOk = 1;
15898
+ break;
15899
+ }
15900
+ case SQLITE_FCNTL_LOCK_TIMEOUT:
15901
+ case SQLITE_FCNTL_CHUNK_SIZE: {
15902
+ int x;
15903
+ if( nArg!=3 ) break;
15904
+ x = (int)integerValue(azArg[2]);
15905
+ sqlite3_file_control(p->db, 0, filectrl, &x);
15906
+ isOk = 2;
15907
+ break;
15908
+ }
15909
+ case SQLITE_FCNTL_PERSIST_WAL:
15910
+ case SQLITE_FCNTL_POWERSAFE_OVERWRITE: {
15911
+ int x;
15912
+ if( nArg!=2 && nArg!=3 ) break;
15913
+ x = nArg==3 ? booleanValue(azArg[2]) : -1;
15914
+ sqlite3_file_control(p->db, 0, filectrl, &x);
15915
+ iRes = x;
15916
+ isOk = 1;
15917
+ break;
15918
+ }
15919
+ case SQLITE_FCNTL_HAS_MOVED: {
15920
+ int x;
15921
+ if( nArg!=2 ) break;
15922
+ sqlite3_file_control(p->db, 0, filectrl, &x);
15923
+ iRes = x;
15924
+ isOk = 1;
15925
+ break;
15926
+ }
15927
+ case SQLITE_FCNTL_TEMPFILENAME: {
15928
+ char *z = 0;
15929
+ if( nArg!=2 ) break;
15930
+ sqlite3_file_control(p->db, 0, filectrl, &z);
15931
+ if( z ){
15932
+ utf8_printf(p->out, "%s\n", z);
15933
+ sqlite3_free(z);
15934
+ }
15935
+ isOk = 2;
15936
+ break;
15937
+ }
15938
+ }
15939
+ }
15940
+ if( isOk==0 && iCtrl>=0 ){
15941
+ utf8_printf(p->out, "Usage: .filectrl %s %s\n", zCmd,aCtrl[iCtrl].zUsage);
15942
+ rc = 1;
15943
+ }else if( isOk==1 ){
15944
+ raw_printf(p->out, "%lld\n", iRes);
15945
+ }
15946
+ }else
1582315947
1582415948
if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){
1582515949
ShellState data;
1582615950
char *zErrMsg = 0;
1582715951
int doStats = 0;
1582815952
--- src/shell.c
+++ src/shell.c
@@ -12053,10 +12053,12 @@
12053 ".exit ?CODE? Exit this program with return-code CODE",
12054 ".expert EXPERIMENTAL. Suggest indexes for specified queries",
12055 /* Because explain mode comes on automatically now, the ".explain" mode
12056 ** is removed from the help screen. It is still supported for legacy, however */
12057 /*".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic",*/
 
 
12058 ".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
12059 ".headers on|off Turn display of headers on or off",
12060 ".help ?-all? ?PATTERN? Show help text for PATTERN",
12061 ".import FILE TABLE Import data from FILE into TABLE",
12062 #ifndef SQLITE_OMIT_TEST_CONTROL
@@ -12170,10 +12172,12 @@
12170 #ifndef SQLITE_NOHAVE_SYSTEM
12171 ".system CMD ARGS... Run CMD ARGS... in a system shell",
12172 #endif
12173 ".tables ?TABLE? List names of tables matching LIKE pattern TABLE",
12174 ".testcase NAME Begin redirecting output to 'testcase-out.txt'",
 
 
12175 ".timeout MS Try opening locked tables for MS milliseconds",
12176 ".timer on|off Turn SQL timer on or off",
12177 #ifndef SQLITE_OMIT_TRACE
12178 ".trace ?OPTIONS? Output each SQL statement as it is run",
12179 " FILE Send output to FILE",
@@ -13392,10 +13396,11 @@
13392 utf8_printf(stderr, "Failed: [%s]\n", zCmd);
13393 }
13394 sqlite3_free(zCmd);
13395 outputModePop(p);
13396 p->doXdgOpen = 0;
 
13397 }
13398 #endif /* !defined(SQLITE_NOHAVE_SYSTEM) */
13399 }
13400 p->outfile[0] = 0;
13401 p->out = stdout;
@@ -15818,10 +15823,129 @@
15818 if( c=='e' && strncmp(azArg[0], "expert", n)==0 ){
15819 open_db(p, 0);
15820 expertDotCommand(p, azArg, nArg);
15821 }else
15822 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15823
15824 if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){
15825 ShellState data;
15826 char *zErrMsg = 0;
15827 int doStats = 0;
15828
--- src/shell.c
+++ src/shell.c
@@ -12053,10 +12053,12 @@
12053 ".exit ?CODE? Exit this program with return-code CODE",
12054 ".expert EXPERIMENTAL. Suggest indexes for specified queries",
12055 /* Because explain mode comes on automatically now, the ".explain" mode
12056 ** is removed from the help screen. It is still supported for legacy, however */
12057 /*".explain ?on|off|auto? Turn EXPLAIN output mode on or off or to automatic",*/
12058 ".filectrl CMD ... Run various sqlite3_file_control() operations",
12059 " Run \".filectrl\" with no arguments for details",
12060 ".fullschema ?--indent? Show schema and the content of sqlite_stat tables",
12061 ".headers on|off Turn display of headers on or off",
12062 ".help ?-all? ?PATTERN? Show help text for PATTERN",
12063 ".import FILE TABLE Import data from FILE into TABLE",
12064 #ifndef SQLITE_OMIT_TEST_CONTROL
@@ -12170,10 +12172,12 @@
12172 #ifndef SQLITE_NOHAVE_SYSTEM
12173 ".system CMD ARGS... Run CMD ARGS... in a system shell",
12174 #endif
12175 ".tables ?TABLE? List names of tables matching LIKE pattern TABLE",
12176 ".testcase NAME Begin redirecting output to 'testcase-out.txt'",
12177 ".testctrl CMD ... Run various sqlite3_test_control() operations",
12178 " Run \".testctrl\" with no arguments for details",
12179 ".timeout MS Try opening locked tables for MS milliseconds",
12180 ".timer on|off Turn SQL timer on or off",
12181 #ifndef SQLITE_OMIT_TRACE
12182 ".trace ?OPTIONS? Output each SQL statement as it is run",
12183 " FILE Send output to FILE",
@@ -13392,10 +13396,11 @@
13396 utf8_printf(stderr, "Failed: [%s]\n", zCmd);
13397 }
13398 sqlite3_free(zCmd);
13399 outputModePop(p);
13400 p->doXdgOpen = 0;
13401 sqlite3_sleep(100);
13402 }
13403 #endif /* !defined(SQLITE_NOHAVE_SYSTEM) */
13404 }
13405 p->outfile[0] = 0;
13406 p->out = stdout;
@@ -15818,10 +15823,129 @@
15823 if( c=='e' && strncmp(azArg[0], "expert", n)==0 ){
15824 open_db(p, 0);
15825 expertDotCommand(p, azArg, nArg);
15826 }else
15827 #endif
15828
15829 if( c=='f' && strncmp(azArg[0], "filectrl", n)==0 ){
15830 static const struct {
15831 const char *zCtrlName; /* Name of a test-control option */
15832 int ctrlCode; /* Integer code for that option */
15833 const char *zUsage; /* Usage notes */
15834 } aCtrl[] = {
15835 { "size_limit", SQLITE_FCNTL_SIZE_LIMIT, "[LIMIT]" },
15836 { "chunk_size", SQLITE_FCNTL_CHUNK_SIZE, "SIZE" },
15837 /* { "win32_av_retry", SQLITE_FCNTL_WIN32_AV_RETRY, "COUNT DELAY" },*/
15838 { "persist_wal", SQLITE_FCNTL_PERSIST_WAL, "[BOOLEAN]" },
15839 { "psow", SQLITE_FCNTL_POWERSAFE_OVERWRITE, "[BOOLEAN]" },
15840 /* { "pragma", SQLITE_FCNTL_PRAGMA, "NAME ARG" },*/
15841 { "tempfilename", SQLITE_FCNTL_TEMPFILENAME, "" },
15842 { "has_moved", SQLITE_FCNTL_HAS_MOVED, "" },
15843 { "lock_timeout", SQLITE_FCNTL_LOCK_TIMEOUT, "MILLISEC" },
15844 };
15845 int filectrl = -1;
15846 int iCtrl = -1;
15847 sqlite3_int64 iRes; /* Integer result to display if rc2==1 */
15848 int isOk = 0; /* 0: usage 1: %lld 2: no-result */
15849 int n2, i;
15850 const char *zCmd = 0;
15851
15852 open_db(p, 0);
15853 zCmd = nArg>=2 ? azArg[1] : "help";
15854
15855 /* The argument can optionally begin with "-" or "--" */
15856 if( zCmd[0]=='-' && zCmd[1] ){
15857 zCmd++;
15858 if( zCmd[0]=='-' && zCmd[1] ) zCmd++;
15859 }
15860
15861 /* --help lists all file-controls */
15862 if( strcmp(zCmd,"help")==0 ){
15863 utf8_printf(p->out, "Available file-controls:\n");
15864 for(i=0; i<ArraySize(aCtrl); i++){
15865 utf8_printf(p->out, " .filectrl %s %s\n",
15866 aCtrl[i].zCtrlName, aCtrl[i].zUsage);
15867 }
15868 rc = 1;
15869 goto meta_command_exit;
15870 }
15871
15872 /* convert filectrl text option to value. allow any unique prefix
15873 ** of the option name, or a numerical value. */
15874 n2 = strlen30(zCmd);
15875 for(i=0; i<ArraySize(aCtrl); i++){
15876 if( strncmp(zCmd, aCtrl[i].zCtrlName, n2)==0 ){
15877 if( filectrl<0 ){
15878 filectrl = aCtrl[i].ctrlCode;
15879 iCtrl = i;
15880 }else{
15881 utf8_printf(stderr, "Error: ambiguous file-control: \"%s\"\n"
15882 "Use \".filectrl --help\" for help\n", zCmd);
15883 rc = 1;
15884 goto meta_command_exit;
15885 }
15886 }
15887 }
15888 if( filectrl<0 ){
15889 utf8_printf(stderr,"Error: unknown file-control: %s\n"
15890 "Use \".filectrl --help\" for help\n", zCmd);
15891 }else{
15892 switch(filectrl){
15893 case SQLITE_FCNTL_SIZE_LIMIT: {
15894 if( nArg!=2 && nArg!=3 ) break;
15895 iRes = nArg==3 ? integerValue(azArg[2]) : -1;
15896 sqlite3_file_control(p->db, 0, SQLITE_FCNTL_SIZE_LIMIT, &iRes);
15897 isOk = 1;
15898 break;
15899 }
15900 case SQLITE_FCNTL_LOCK_TIMEOUT:
15901 case SQLITE_FCNTL_CHUNK_SIZE: {
15902 int x;
15903 if( nArg!=3 ) break;
15904 x = (int)integerValue(azArg[2]);
15905 sqlite3_file_control(p->db, 0, filectrl, &x);
15906 isOk = 2;
15907 break;
15908 }
15909 case SQLITE_FCNTL_PERSIST_WAL:
15910 case SQLITE_FCNTL_POWERSAFE_OVERWRITE: {
15911 int x;
15912 if( nArg!=2 && nArg!=3 ) break;
15913 x = nArg==3 ? booleanValue(azArg[2]) : -1;
15914 sqlite3_file_control(p->db, 0, filectrl, &x);
15915 iRes = x;
15916 isOk = 1;
15917 break;
15918 }
15919 case SQLITE_FCNTL_HAS_MOVED: {
15920 int x;
15921 if( nArg!=2 ) break;
15922 sqlite3_file_control(p->db, 0, filectrl, &x);
15923 iRes = x;
15924 isOk = 1;
15925 break;
15926 }
15927 case SQLITE_FCNTL_TEMPFILENAME: {
15928 char *z = 0;
15929 if( nArg!=2 ) break;
15930 sqlite3_file_control(p->db, 0, filectrl, &z);
15931 if( z ){
15932 utf8_printf(p->out, "%s\n", z);
15933 sqlite3_free(z);
15934 }
15935 isOk = 2;
15936 break;
15937 }
15938 }
15939 }
15940 if( isOk==0 && iCtrl>=0 ){
15941 utf8_printf(p->out, "Usage: .filectrl %s %s\n", zCmd,aCtrl[iCtrl].zUsage);
15942 rc = 1;
15943 }else if( isOk==1 ){
15944 raw_printf(p->out, "%lld\n", iRes);
15945 }
15946 }else
15947
15948 if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){
15949 ShellState data;
15950 char *zErrMsg = 0;
15951 int doStats = 0;
15952
+129 -103
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1167,11 +1167,11 @@
11671167
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
11681168
** [sqlite_version()] and [sqlite_source_id()].
11691169
*/
11701170
#define SQLITE_VERSION "3.29.0"
11711171
#define SQLITE_VERSION_NUMBER 3029000
1172
-#define SQLITE_SOURCE_ID "2019-05-23 16:38:12 d2fe370cafa9b11f6c3eb4e1c3be48d9d2610b9d2f9d9ebf9e50267f9079dfc0"
1172
+#define SQLITE_SOURCE_ID "2019-06-05 14:29:53 7b3a99fce8b4a757f2b2ef2f0b02d68566f2528d9ae1e30628522717f872466c"
11731173
11741174
/*
11751175
** CAPI3REF: Run-Time Library Version Numbers
11761176
** KEYWORDS: sqlite3_version sqlite3_sourceid
11771177
**
@@ -18730,12 +18730,16 @@
1873018730
#else
1873118731
# define sqlite3MutexWarnOnContention(x)
1873218732
#endif
1873318733
1873418734
#ifndef SQLITE_OMIT_FLOATING_POINT
18735
+# define EXP754 (((u64)0x7ff)<<52)
18736
+# define MAN754 ((((u64)1)<<52)-1)
18737
+# define IsNaN(X) (((X)&EXP754)==EXP754 && ((X)&MAN754)!=0)
1873518738
SQLITE_PRIVATE int sqlite3IsNaN(double);
1873618739
#else
18740
+# define IsNaN(X) 0
1873718741
# define sqlite3IsNaN(X) 0
1873818742
#endif
1873918743
1874018744
/*
1874118745
** An instance of the following structure holds information about SQL
@@ -19103,10 +19107,11 @@
1910319107
SQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*);
1910419108
SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*);
1910519109
SQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*);
1910619110
SQLITE_PRIVATE int sqlite3FixExprList(DbFixer*, ExprList*);
1910719111
SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
19112
+SQLITE_PRIVATE int sqlite3RealSameAsInt(double,sqlite3_int64);
1910819113
SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*, int, u8);
1910919114
SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
1911019115
SQLITE_PRIVATE int sqlite3Atoi(const char*);
1911119116
#ifndef SQLITE_OMIT_UTF16
1911219117
SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar);
@@ -27348,10 +27353,16 @@
2734827353
{ 'T', 0, 0, etTOKEN, 0, 0 },
2734927354
{ 'S', 0, 0, etSRCLIST, 0, 0 },
2735027355
{ 'r', 10, 1, etORDINAL, 0, 0 },
2735127356
};
2735227357
27358
+/* Floating point constants used for rounding */
27359
+static const double arRound[] = {
27360
+ 5.0e-01, 5.0e-02, 5.0e-03, 5.0e-04, 5.0e-05,
27361
+ 5.0e-06, 5.0e-07, 5.0e-08, 5.0e-09, 5.0e-10,
27362
+};
27363
+
2735327364
/*
2735427365
** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point
2735527366
** conversions will work.
2735627367
*/
2735727368
#ifndef SQLITE_OMIT_FLOATING_POINT
@@ -27766,12 +27777,22 @@
2776627777
}else{
2776727778
prefix = flag_prefix;
2776827779
}
2776927780
if( xtype==etGENERIC && precision>0 ) precision--;
2777027781
testcase( precision>0xfff );
27771
- for(idx=precision&0xfff, rounder=0.5; idx>0; idx--, rounder*=0.1){}
27772
- if( xtype==etFLOAT ) realvalue += rounder;
27782
+ idx = precision & 0xfff;
27783
+ rounder = arRound[idx%10];
27784
+ while( idx>=10 ){ rounder *= 1.0e-10; idx -= 10; }
27785
+ if( xtype==etFLOAT ){
27786
+ double rx = (double)realvalue;
27787
+ sqlite3_uint64 u;
27788
+ int ex;
27789
+ memcpy(&u, &rx, sizeof(u));
27790
+ ex = -1023 + (int)((u>>52)&0x7ff);
27791
+ if( precision+(ex/3) < 15 ) rounder += realvalue*3e-16;
27792
+ realvalue += rounder;
27793
+ }
2777327794
/* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
2777427795
exp = 0;
2777527796
if( sqlite3IsNaN((double)realvalue) ){
2777627797
bufpt = "NaN";
2777727798
length = 3;
@@ -30270,51 +30291,15 @@
3027030291
#endif
3027130292
3027230293
#ifndef SQLITE_OMIT_FLOATING_POINT
3027330294
/*
3027430295
** Return true if the floating point value is Not a Number (NaN).
30275
-**
30276
-** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN.
30277
-** Otherwise, we have our own implementation that works on most systems.
3027830296
*/
3027930297
SQLITE_PRIVATE int sqlite3IsNaN(double x){
30280
- int rc; /* The value return */
30281
-#if !SQLITE_HAVE_ISNAN && !HAVE_ISNAN
30282
- /*
30283
- ** Systems that support the isnan() library function should probably
30284
- ** make use of it by compiling with -DSQLITE_HAVE_ISNAN. But we have
30285
- ** found that many systems do not have a working isnan() function so
30286
- ** this implementation is provided as an alternative.
30287
- **
30288
- ** This NaN test sometimes fails if compiled on GCC with -ffast-math.
30289
- ** On the other hand, the use of -ffast-math comes with the following
30290
- ** warning:
30291
- **
30292
- ** This option [-ffast-math] should never be turned on by any
30293
- ** -O option since it can result in incorrect output for programs
30294
- ** which depend on an exact implementation of IEEE or ISO
30295
- ** rules/specifications for math functions.
30296
- **
30297
- ** Under MSVC, this NaN test may fail if compiled with a floating-
30298
- ** point precision mode other than /fp:precise. From the MSDN
30299
- ** documentation:
30300
- **
30301
- ** The compiler [with /fp:precise] will properly handle comparisons
30302
- ** involving NaN. For example, x != x evaluates to true if x is NaN
30303
- ** ...
30304
- */
30305
-#ifdef __FAST_MATH__
30306
-# error SQLite will not work correctly with the -ffast-math option of GCC.
30307
-#endif
30308
- volatile double y = x;
30309
- volatile double z = y;
30310
- rc = (y!=z);
30311
-#else /* if HAVE_ISNAN */
30312
- rc = isnan(x);
30313
-#endif /* HAVE_ISNAN */
30314
- testcase( rc );
30315
- return rc;
30298
+ u64 y;
30299
+ memcpy(&y,&x,sizeof(y));
30300
+ return IsNaN(y);
3031630301
}
3031730302
#endif /* SQLITE_OMIT_FLOATING_POINT */
3031830303
3031930304
/*
3032030305
** Compute a string length that is limited to what can be stored in
@@ -30571,19 +30556,19 @@
3057130556
** This routine only works for values of E between 1 and 341.
3057230557
*/
3057330558
static LONGDOUBLE_TYPE sqlite3Pow10(int E){
3057430559
#if defined(_MSC_VER)
3057530560
static const LONGDOUBLE_TYPE x[] = {
30576
- 1.0e+001,
30577
- 1.0e+002,
30578
- 1.0e+004,
30579
- 1.0e+008,
30580
- 1.0e+016,
30581
- 1.0e+032,
30582
- 1.0e+064,
30583
- 1.0e+128,
30584
- 1.0e+256
30561
+ 1.0e+001L,
30562
+ 1.0e+002L,
30563
+ 1.0e+004L,
30564
+ 1.0e+008L,
30565
+ 1.0e+016L,
30566
+ 1.0e+032L,
30567
+ 1.0e+064L,
30568
+ 1.0e+128L,
30569
+ 1.0e+256L
3058530570
};
3058630571
LONGDOUBLE_TYPE r = 1.0;
3058730572
int i;
3058830573
assert( E>=0 && E<=307 );
3058930574
for(i=0; E!=0; i++, E >>=1){
@@ -30609,12 +30594,17 @@
3060930594
**
3061030595
** The string z[] is length bytes in length (bytes, not characters) and
3061130596
** uses the encoding enc. The string is not necessarily zero-terminated.
3061230597
**
3061330598
** Return TRUE if the result is a valid real number (or integer) and FALSE
30614
-** if the string is empty or contains extraneous text. Valid numbers
30615
-** are in one of these formats:
30599
+** if the string is empty or contains extraneous text. More specifically
30600
+** return
30601
+** 1 => The input string is a pure integer
30602
+** 2 or more => The input has a decimal point or eNNN clause
30603
+** 0 => The input string is not a valid number
30604
+**
30605
+** Valid numbers are in one of these formats:
3061630606
**
3061730607
** [+-]digits[E[+-]digits]
3061830608
** [+-]digits.[digits][E[+-]digits]
3061930609
** [+-].digits[E[+-]digits]
3062030610
**
@@ -30635,12 +30625,12 @@
3063530625
int d = 0; /* adjust exponent for shifting decimal point */
3063630626
int esign = 1; /* sign of exponent */
3063730627
int e = 0; /* exponent */
3063830628
int eValid = 1; /* True exponent is either not used or is well-formed */
3063930629
double result;
30640
- int nDigits = 0;
30641
- int nonNum = 0; /* True if input contains UTF16 with high byte non-zero */
30630
+ int nDigit = 0; /* Number of digits processed */
30631
+ int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */
3064230632
3064330633
assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
3064430634
*pResult = 0.0; /* Default return value, in case of an error */
3064530635
3064630636
if( enc==SQLITE_UTF8 ){
@@ -30647,12 +30637,14 @@
3064730637
incr = 1;
3064830638
}else{
3064930639
int i;
3065030640
incr = 2;
3065130641
assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
30642
+ testcase( enc==SQLITE_UTF16LE );
30643
+ testcase( enc==SQLITE_UTF16BE );
3065230644
for(i=3-enc; i<length && z[i]==0; i+=2){}
30653
- nonNum = i<length;
30645
+ if( i<length ) eType = -100;
3065430646
zEnd = &z[i^1];
3065530647
z += (enc&1);
3065630648
}
3065730649
3065830650
/* skip leading spaces */
@@ -30666,39 +30658,43 @@
3066630658
}else if( *z=='+' ){
3066730659
z+=incr;
3066830660
}
3066930661
3067030662
/* copy max significant digits to significand */
30671
- while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){
30663
+ while( z<zEnd && sqlite3Isdigit(*z) ){
3067230664
s = s*10 + (*z - '0');
30673
- z+=incr; nDigits++;
30665
+ z+=incr; nDigit++;
30666
+ if( s>=((LARGEST_INT64-9)/10) ){
30667
+ /* skip non-significant significand digits
30668
+ ** (increase exponent by d to shift decimal left) */
30669
+ while( z<zEnd && sqlite3Isdigit(*z) ){ z+=incr; d++; }
30670
+ }
3067430671
}
30675
-
30676
- /* skip non-significant significand digits
30677
- ** (increase exponent by d to shift decimal left) */
30678
- while( z<zEnd && sqlite3Isdigit(*z) ){ z+=incr; nDigits++; d++; }
3067930672
if( z>=zEnd ) goto do_atof_calc;
3068030673
3068130674
/* if decimal point is present */
3068230675
if( *z=='.' ){
3068330676
z+=incr;
30677
+ eType++;
3068430678
/* copy digits from after decimal to significand
3068530679
** (decrease exponent by d to shift decimal right) */
3068630680
while( z<zEnd && sqlite3Isdigit(*z) ){
3068730681
if( s<((LARGEST_INT64-9)/10) ){
3068830682
s = s*10 + (*z - '0');
3068930683
d--;
30684
+ nDigit++;
3069030685
}
30691
- z+=incr; nDigits++;
30686
+ z+=incr;
3069230687
}
3069330688
}
3069430689
if( z>=zEnd ) goto do_atof_calc;
3069530690
3069630691
/* if exponent is present */
3069730692
if( *z=='e' || *z=='E' ){
3069830693
z+=incr;
3069930694
eValid = 0;
30695
+ eType++;
3070030696
3070130697
/* This branch is needed to avoid a (harmless) buffer overread. The
3070230698
** special comment alerts the mutation tester that the correct answer
3070330699
** is obtained even if the branch is omitted */
3070430700
if( z>=zEnd ) goto do_atof_calc; /*PREVENTS-HARMLESS-OVERREAD*/
@@ -30793,11 +30789,11 @@
3079330789
3079430790
/* store the result */
3079530791
*pResult = result;
3079630792
3079730793
/* return true if number and no extra non-whitespace chracters after */
30798
- return z==zEnd && nDigits>0 && eValid && nonNum==0;
30794
+ return z==zEnd && nDigit>0 && eValid && eType>0 ? eType : 0;
3079930795
#else
3080030796
return !sqlite3Atoi64(z, pResult, length, enc);
3080130797
#endif /* SQLITE_OMIT_FLOATING_POINT */
3080230798
}
3080330799
@@ -75146,11 +75142,11 @@
7514675142
**
7514775143
** For some versions of GCC on 32-bit machines, if you do the more obvious
7514875144
** comparison of "r1==(double)i" you sometimes get an answer of false even
7514975145
** though the r1 and (double)i values are bit-for-bit the same.
7515075146
*/
75151
-static int sqlite3RealSameAsInt(double r1, sqlite3_int64 i){
75147
+SQLITE_PRIVATE int sqlite3RealSameAsInt(double r1, sqlite3_int64 i){
7515275148
double r2 = (double)i;
7515375149
return memcmp(&r1, &r2, sizeof(r1))==0;
7515475150
}
7515575151
7515675152
/*
@@ -80035,11 +80031,11 @@
8003580031
** This function is implemented as two separate routines for performance.
8003680032
** The few cases that require local variables are broken out into a separate
8003780033
** routine so that in most cases the overhead of moving the stack pointer
8003880034
** is avoided.
8003980035
*/
80040
-static u32 SQLITE_NOINLINE serialGet(
80036
+static u32 serialGet(
8004180037
const unsigned char *buf, /* Buffer to deserialize from */
8004280038
u32 serial_type, /* Serial type to deserialize */
8004380039
Mem *pMem /* Memory cell to write value into */
8004480040
){
8004580041
u64 x = FOUR_BYTE_UINT(buf);
@@ -80067,11 +80063,11 @@
8006780063
assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );
8006880064
#endif
8006980065
assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 );
8007080066
swapMixedEndianFloat(x);
8007180067
memcpy(&pMem->u.r, &x, sizeof(x));
80072
- pMem->flags = sqlite3IsNaN(pMem->u.r) ? MEM_Null : MEM_Real;
80068
+ pMem->flags = IsNaN(x) ? MEM_Null : MEM_Real;
8007380069
}
8007480070
return 8;
8007580071
}
8007680072
SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
8007780073
const unsigned char *buf, /* Buffer to deserialize from */
@@ -83930,10 +83926,34 @@
8393083926
sqlite3BtreeCursorZero(pCx->uc.pCursor);
8393183927
}
8393283928
}
8393383929
return pCx;
8393483930
}
83931
+
83932
+/*
83933
+** The string in pRec is known to look like an integer and to have a
83934
+** floating point value of rValue. Return true and set *piValue to the
83935
+** integer value if the string is in range to be an integer. Otherwise,
83936
+** return false.
83937
+*/
83938
+static int alsoAnInt(Mem *pRec, double rValue, i64 *piValue){
83939
+ i64 iValue = (double)rValue;
83940
+ if( sqlite3RealSameAsInt(rValue,iValue) ){
83941
+ testcase( iValue<-2251799813685248 );
83942
+ testcase( iValue==-2251799813685248 );
83943
+ testcase( iValue==-2251799813685247 );
83944
+ testcase( iValue>-2251799813685247 && iValue<+2251799813685247 );
83945
+ testcase( iValue==+2251799813685247 );
83946
+ testcase( iValue==+2251799813685248 );
83947
+ testcase( iValue>+2251799813685248 );
83948
+ if( iValue > -2251799813685248 && iValue < 2251799813685248 ){
83949
+ *piValue = iValue;
83950
+ return 1;
83951
+ }
83952
+ }
83953
+ return 0==sqlite3Atoi64(pRec->z, piValue, pRec->n, pRec->enc);
83954
+}
8393583955
8393683956
/*
8393783957
** Try to convert a value into a numeric representation if we can
8393883958
** do so without loss of information. In other words, if the string
8393983959
** looks like a number, convert it into a number. If it does not
@@ -83948,16 +83968,16 @@
8394883968
** point or exponential notation, the result is only MEM_Real, even
8394983969
** if there is an exact integer representation of the quantity.
8395083970
*/
8395183971
static void applyNumericAffinity(Mem *pRec, int bTryForInt){
8395283972
double rValue;
83953
- i64 iValue;
8395483973
u8 enc = pRec->enc;
83974
+ int rc;
8395583975
assert( (pRec->flags & (MEM_Str|MEM_Int|MEM_Real|MEM_IntReal))==MEM_Str );
83956
- if( sqlite3AtoF(pRec->z, &rValue, pRec->n, enc)==0 ) return;
83957
- if( 0==sqlite3Atoi64(pRec->z, &iValue, pRec->n, enc) ){
83958
- pRec->u.i = iValue;
83976
+ rc = sqlite3AtoF(pRec->z, &rValue, pRec->n, enc);
83977
+ if( rc==0 ) return;
83978
+ if( rc==1 && alsoAnInt(pRec, rValue, &pRec->u.i) ){
8395983979
pRec->flags |= MEM_Int;
8396083980
}else{
8396183981
pRec->u.r = rValue;
8396283982
pRec->flags |= MEM_Real;
8396383983
if( bTryForInt ) sqlite3VdbeIntegerAffinity(pRec);
@@ -113767,14 +113787,14 @@
113767113787
r = sqlite3_value_double(argv[0]);
113768113788
/* If Y==0 and X will fit in a 64-bit int,
113769113789
** handle the rounding directly,
113770113790
** otherwise use printf.
113771113791
*/
113772
- if( n==0 && r>=0 && r<LARGEST_INT64-1 ){
113773
- r = (double)((sqlite_int64)(r+0.5));
113774
- }else if( n==0 && r<0 && (-r)<LARGEST_INT64-1 ){
113775
- r = -(double)((sqlite_int64)((-r)+0.5));
113792
+ if( r<-4503599627370496.0 || r>+4503599627370496.0 ){
113793
+ /* The value has no fractional part so there is nothing to round */
113794
+ }else if( n==0 ){
113795
+ r = (double)((sqlite_int64)(r+(r<0?-0.5:+0.5)));
113776113796
}else{
113777113797
zBuf = sqlite3_mprintf("%.*f",n,r);
113778113798
if( zBuf==0 ){
113779113799
sqlite3_result_error_nomem(context);
113780113800
return;
@@ -127556,10 +127576,11 @@
127556127576
/* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only
127557127577
** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.
127558127578
*/
127559127579
assert( p && p->pPrior ); /* Calling function guarantees this much */
127560127580
assert( (p->selFlags & SF_Recursive)==0 || p->op==TK_ALL || p->op==TK_UNION );
127581
+ assert( p->selFlags & SF_Compound );
127561127582
db = pParse->db;
127562127583
pPrior = p->pPrior;
127563127584
dest = *pDest;
127564127585
if( pPrior->pOrderBy || pPrior->pLimit ){
127565127586
sqlite3ErrorMsg(pParse,"%s clause should come after %s not before",
@@ -129061,14 +129082,14 @@
129061129082
x.isLeftJoin = isLeftJoin;
129062129083
x.pEList = pSub->pEList;
129063129084
substSelect(&x, pParent, 0);
129064129085
}
129065129086
129066
- /* The flattened query is distinct if either the inner or the
129067
- ** outer query is distinct.
129068
- */
129069
- pParent->selFlags |= pSub->selFlags & SF_Distinct;
129087
+ /* The flattened query is a compound if either the inner or the
129088
+ ** outer query is a compound. */
129089
+ pParent->selFlags |= pSub->selFlags & SF_Compound;
129090
+ assert( (pSub->selFlags & SF_Distinct)==0 ); /* restriction (17b) */
129070129091
129071129092
/*
129072129093
** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y;
129073129094
**
129074129095
** One is tempted to try to add a and b to combine the limits. But this
@@ -174772,11 +174793,11 @@
174772174793
int nSuffix; /* Size of term suffix in bytes */
174773174794
174774174795
/* Node must have already been started. There must be a doclist for a
174775174796
** leaf node, and there must not be a doclist for an internal node. */
174776174797
assert( pNode->n>0 );
174777
- assert( (pNode->a[0]=='\0')==(aDoclist!=0) );
174798
+ assert_fts3_nc( (pNode->a[0]=='\0')==(aDoclist!=0) );
174778174799
174779174800
blobGrowBuffer(pPrev, nTerm, &rc);
174780174801
if( rc!=SQLITE_OK ) return rc;
174781174802
174782174803
nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);
@@ -174988,11 +175009,11 @@
174988175009
const char *zRhs, int nRhs /* RHS of comparison */
174989175010
){
174990175011
int nCmp = MIN(nLhs, nRhs);
174991175012
int res;
174992175013
174993
- res = memcmp(zLhs, zRhs, nCmp);
175014
+ res = (nCmp ? memcmp(zLhs, zRhs, nCmp) : 0);
174994175015
if( res==0 ) res = nLhs - nRhs;
174995175016
174996175017
return res;
174997175018
}
174998175019
@@ -175131,27 +175152,29 @@
175131175152
for(i=nHeight; i>=0 && rc==SQLITE_OK; i--){
175132175153
NodeReader reader;
175133175154
pNode = &pWriter->aNodeWriter[i];
175134175155
175135175156
rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n);
175136
- while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader);
175137
- blobGrowBuffer(&pNode->key, reader.term.n, &rc);
175138
- if( rc==SQLITE_OK ){
175139
- memcpy(pNode->key.a, reader.term.a, reader.term.n);
175140
- pNode->key.n = reader.term.n;
175141
- if( i>0 ){
175142
- char *aBlock = 0;
175143
- int nBlock = 0;
175144
- pNode = &pWriter->aNodeWriter[i-1];
175145
- pNode->iBlock = reader.iChild;
175146
- rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0);
175147
- blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc);
175148
- if( rc==SQLITE_OK ){
175149
- memcpy(pNode->block.a, aBlock, nBlock);
175150
- pNode->block.n = nBlock;
175151
- }
175152
- sqlite3_free(aBlock);
175157
+ if( reader.aNode ){
175158
+ while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader);
175159
+ blobGrowBuffer(&pNode->key, reader.term.n, &rc);
175160
+ if( rc==SQLITE_OK ){
175161
+ memcpy(pNode->key.a, reader.term.a, reader.term.n);
175162
+ pNode->key.n = reader.term.n;
175163
+ if( i>0 ){
175164
+ char *aBlock = 0;
175165
+ int nBlock = 0;
175166
+ pNode = &pWriter->aNodeWriter[i-1];
175167
+ pNode->iBlock = reader.iChild;
175168
+ rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0);
175169
+ blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc);
175170
+ if( rc==SQLITE_OK ){
175171
+ memcpy(pNode->block.a, aBlock, nBlock);
175172
+ pNode->block.n = nBlock;
175173
+ }
175174
+ sqlite3_free(aBlock);
175175
+ }
175153175176
}
175154175177
}
175155175178
nodeReaderRelease(&reader);
175156175179
}
175157175180
}
@@ -175390,11 +175413,14 @@
175390175413
sqlite3_int64 *piBlock /* OUT: Block number in next layer down */
175391175414
){
175392175415
NodeReader reader; /* Reader object */
175393175416
Blob prev = {0, 0, 0}; /* Previous term written to new node */
175394175417
int rc = SQLITE_OK; /* Return code */
175395
- int bLeaf = aNode[0]=='\0'; /* True for a leaf node */
175418
+ int bLeaf; /* True for a leaf node */
175419
+
175420
+ if( nNode<1 ) return FTS_CORRUPT_VTAB;
175421
+ bLeaf = aNode[0]=='\0';
175396175422
175397175423
/* Allocate required output space */
175398175424
blobGrowBuffer(pNew, nNode, &rc);
175399175425
if( rc!=SQLITE_OK ) return rc;
175400175426
pNew->n = 0;
@@ -210593,11 +210619,11 @@
210593210619
pData = fts5DataRead(p, FTS5_STRUCTURE_ROWID);
210594210620
if( p->rc==SQLITE_OK ){
210595210621
/* TODO: Do we need this if the leaf-index is appended? Probably... */
210596210622
memset(&pData->p[pData->nn], 0, FTS5_DATA_PADDING);
210597210623
p->rc = fts5StructureDecode(pData->p, pData->nn, &iCookie, &pRet);
210598
- if( p->rc==SQLITE_OK && pConfig->iCookie!=iCookie ){
210624
+ if( p->rc==SQLITE_OK && (pConfig->pgsz==0 || pConfig->iCookie!=iCookie) ){
210599210625
p->rc = sqlite3Fts5ConfigLoad(pConfig, iCookie);
210600210626
}
210601210627
fts5DataRelease(pData);
210602210628
if( p->rc!=SQLITE_OK ){
210603210629
fts5StructureRelease(pRet);
@@ -218831,11 +218857,11 @@
218831218857
int nArg, /* Number of args */
218832218858
sqlite3_value **apUnused /* Function arguments */
218833218859
){
218834218860
assert( nArg==0 );
218835218861
UNUSED_PARAM2(nArg, apUnused);
218836
- sqlite3_result_text(pCtx, "fts5: 2019-05-23 16:38:12 d2fe370cafa9b11f6c3eb4e1c3be48d9d2610b9d2f9d9ebf9e50267f9079dfc0", -1, SQLITE_TRANSIENT);
218862
+ sqlite3_result_text(pCtx, "fts5: 2019-06-04 18:21:59 4979f138e8c8bef7dd6b5921fb9ca9fea86bbf7ec1419934bb2d1a0d74e77183", -1, SQLITE_TRANSIENT);
218837218863
}
218838218864
218839218865
/*
218840218866
** Return true if zName is the extension on one of the shadow tables used
218841218867
** by this module.
@@ -223597,12 +223623,12 @@
223597223623
}
223598223624
#endif /* SQLITE_CORE */
223599223625
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
223600223626
223601223627
/************** End of stmt.c ************************************************/
223602
-#if __LINE__!=223602
223628
+#if __LINE__!=223628
223603223629
#undef SQLITE_SOURCE_ID
223604
-#define SQLITE_SOURCE_ID "2019-05-23 16:38:12 d2fe370cafa9b11f6c3eb4e1c3be48d9d2610b9d2f9d9ebf9e50267f9079alt2"
223630
+#define SQLITE_SOURCE_ID "2019-06-05 14:29:53 7b3a99fce8b4a757f2b2ef2f0b02d68566f2528d9ae1e30628522717f872alt2"
223605223631
#endif
223606223632
/* Return the source-id for this library */
223607223633
SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
223608223634
/************************** End of sqlite3.c ******************************/
223609223635
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1167,11 +1167,11 @@
1167 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1168 ** [sqlite_version()] and [sqlite_source_id()].
1169 */
1170 #define SQLITE_VERSION "3.29.0"
1171 #define SQLITE_VERSION_NUMBER 3029000
1172 #define SQLITE_SOURCE_ID "2019-05-23 16:38:12 d2fe370cafa9b11f6c3eb4e1c3be48d9d2610b9d2f9d9ebf9e50267f9079dfc0"
1173
1174 /*
1175 ** CAPI3REF: Run-Time Library Version Numbers
1176 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1177 **
@@ -18730,12 +18730,16 @@
18730 #else
18731 # define sqlite3MutexWarnOnContention(x)
18732 #endif
18733
18734 #ifndef SQLITE_OMIT_FLOATING_POINT
 
 
 
18735 SQLITE_PRIVATE int sqlite3IsNaN(double);
18736 #else
 
18737 # define sqlite3IsNaN(X) 0
18738 #endif
18739
18740 /*
18741 ** An instance of the following structure holds information about SQL
@@ -19103,10 +19107,11 @@
19103 SQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*);
19104 SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*);
19105 SQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*);
19106 SQLITE_PRIVATE int sqlite3FixExprList(DbFixer*, ExprList*);
19107 SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
 
19108 SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*, int, u8);
19109 SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
19110 SQLITE_PRIVATE int sqlite3Atoi(const char*);
19111 #ifndef SQLITE_OMIT_UTF16
19112 SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar);
@@ -27348,10 +27353,16 @@
27348 { 'T', 0, 0, etTOKEN, 0, 0 },
27349 { 'S', 0, 0, etSRCLIST, 0, 0 },
27350 { 'r', 10, 1, etORDINAL, 0, 0 },
27351 };
27352
 
 
 
 
 
 
27353 /*
27354 ** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point
27355 ** conversions will work.
27356 */
27357 #ifndef SQLITE_OMIT_FLOATING_POINT
@@ -27766,12 +27777,22 @@
27766 }else{
27767 prefix = flag_prefix;
27768 }
27769 if( xtype==etGENERIC && precision>0 ) precision--;
27770 testcase( precision>0xfff );
27771 for(idx=precision&0xfff, rounder=0.5; idx>0; idx--, rounder*=0.1){}
27772 if( xtype==etFLOAT ) realvalue += rounder;
 
 
 
 
 
 
 
 
 
 
27773 /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
27774 exp = 0;
27775 if( sqlite3IsNaN((double)realvalue) ){
27776 bufpt = "NaN";
27777 length = 3;
@@ -30270,51 +30291,15 @@
30270 #endif
30271
30272 #ifndef SQLITE_OMIT_FLOATING_POINT
30273 /*
30274 ** Return true if the floating point value is Not a Number (NaN).
30275 **
30276 ** Use the math library isnan() function if compiled with SQLITE_HAVE_ISNAN.
30277 ** Otherwise, we have our own implementation that works on most systems.
30278 */
30279 SQLITE_PRIVATE int sqlite3IsNaN(double x){
30280 int rc; /* The value return */
30281 #if !SQLITE_HAVE_ISNAN && !HAVE_ISNAN
30282 /*
30283 ** Systems that support the isnan() library function should probably
30284 ** make use of it by compiling with -DSQLITE_HAVE_ISNAN. But we have
30285 ** found that many systems do not have a working isnan() function so
30286 ** this implementation is provided as an alternative.
30287 **
30288 ** This NaN test sometimes fails if compiled on GCC with -ffast-math.
30289 ** On the other hand, the use of -ffast-math comes with the following
30290 ** warning:
30291 **
30292 ** This option [-ffast-math] should never be turned on by any
30293 ** -O option since it can result in incorrect output for programs
30294 ** which depend on an exact implementation of IEEE or ISO
30295 ** rules/specifications for math functions.
30296 **
30297 ** Under MSVC, this NaN test may fail if compiled with a floating-
30298 ** point precision mode other than /fp:precise. From the MSDN
30299 ** documentation:
30300 **
30301 ** The compiler [with /fp:precise] will properly handle comparisons
30302 ** involving NaN. For example, x != x evaluates to true if x is NaN
30303 ** ...
30304 */
30305 #ifdef __FAST_MATH__
30306 # error SQLite will not work correctly with the -ffast-math option of GCC.
30307 #endif
30308 volatile double y = x;
30309 volatile double z = y;
30310 rc = (y!=z);
30311 #else /* if HAVE_ISNAN */
30312 rc = isnan(x);
30313 #endif /* HAVE_ISNAN */
30314 testcase( rc );
30315 return rc;
30316 }
30317 #endif /* SQLITE_OMIT_FLOATING_POINT */
30318
30319 /*
30320 ** Compute a string length that is limited to what can be stored in
@@ -30571,19 +30556,19 @@
30571 ** This routine only works for values of E between 1 and 341.
30572 */
30573 static LONGDOUBLE_TYPE sqlite3Pow10(int E){
30574 #if defined(_MSC_VER)
30575 static const LONGDOUBLE_TYPE x[] = {
30576 1.0e+001,
30577 1.0e+002,
30578 1.0e+004,
30579 1.0e+008,
30580 1.0e+016,
30581 1.0e+032,
30582 1.0e+064,
30583 1.0e+128,
30584 1.0e+256
30585 };
30586 LONGDOUBLE_TYPE r = 1.0;
30587 int i;
30588 assert( E>=0 && E<=307 );
30589 for(i=0; E!=0; i++, E >>=1){
@@ -30609,12 +30594,17 @@
30609 **
30610 ** The string z[] is length bytes in length (bytes, not characters) and
30611 ** uses the encoding enc. The string is not necessarily zero-terminated.
30612 **
30613 ** Return TRUE if the result is a valid real number (or integer) and FALSE
30614 ** if the string is empty or contains extraneous text. Valid numbers
30615 ** are in one of these formats:
 
 
 
 
 
30616 **
30617 ** [+-]digits[E[+-]digits]
30618 ** [+-]digits.[digits][E[+-]digits]
30619 ** [+-].digits[E[+-]digits]
30620 **
@@ -30635,12 +30625,12 @@
30635 int d = 0; /* adjust exponent for shifting decimal point */
30636 int esign = 1; /* sign of exponent */
30637 int e = 0; /* exponent */
30638 int eValid = 1; /* True exponent is either not used or is well-formed */
30639 double result;
30640 int nDigits = 0;
30641 int nonNum = 0; /* True if input contains UTF16 with high byte non-zero */
30642
30643 assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
30644 *pResult = 0.0; /* Default return value, in case of an error */
30645
30646 if( enc==SQLITE_UTF8 ){
@@ -30647,12 +30637,14 @@
30647 incr = 1;
30648 }else{
30649 int i;
30650 incr = 2;
30651 assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
 
 
30652 for(i=3-enc; i<length && z[i]==0; i+=2){}
30653 nonNum = i<length;
30654 zEnd = &z[i^1];
30655 z += (enc&1);
30656 }
30657
30658 /* skip leading spaces */
@@ -30666,39 +30658,43 @@
30666 }else if( *z=='+' ){
30667 z+=incr;
30668 }
30669
30670 /* copy max significant digits to significand */
30671 while( z<zEnd && sqlite3Isdigit(*z) && s<((LARGEST_INT64-9)/10) ){
30672 s = s*10 + (*z - '0');
30673 z+=incr; nDigits++;
 
 
 
 
 
30674 }
30675
30676 /* skip non-significant significand digits
30677 ** (increase exponent by d to shift decimal left) */
30678 while( z<zEnd && sqlite3Isdigit(*z) ){ z+=incr; nDigits++; d++; }
30679 if( z>=zEnd ) goto do_atof_calc;
30680
30681 /* if decimal point is present */
30682 if( *z=='.' ){
30683 z+=incr;
 
30684 /* copy digits from after decimal to significand
30685 ** (decrease exponent by d to shift decimal right) */
30686 while( z<zEnd && sqlite3Isdigit(*z) ){
30687 if( s<((LARGEST_INT64-9)/10) ){
30688 s = s*10 + (*z - '0');
30689 d--;
 
30690 }
30691 z+=incr; nDigits++;
30692 }
30693 }
30694 if( z>=zEnd ) goto do_atof_calc;
30695
30696 /* if exponent is present */
30697 if( *z=='e' || *z=='E' ){
30698 z+=incr;
30699 eValid = 0;
 
30700
30701 /* This branch is needed to avoid a (harmless) buffer overread. The
30702 ** special comment alerts the mutation tester that the correct answer
30703 ** is obtained even if the branch is omitted */
30704 if( z>=zEnd ) goto do_atof_calc; /*PREVENTS-HARMLESS-OVERREAD*/
@@ -30793,11 +30789,11 @@
30793
30794 /* store the result */
30795 *pResult = result;
30796
30797 /* return true if number and no extra non-whitespace chracters after */
30798 return z==zEnd && nDigits>0 && eValid && nonNum==0;
30799 #else
30800 return !sqlite3Atoi64(z, pResult, length, enc);
30801 #endif /* SQLITE_OMIT_FLOATING_POINT */
30802 }
30803
@@ -75146,11 +75142,11 @@
75146 **
75147 ** For some versions of GCC on 32-bit machines, if you do the more obvious
75148 ** comparison of "r1==(double)i" you sometimes get an answer of false even
75149 ** though the r1 and (double)i values are bit-for-bit the same.
75150 */
75151 static int sqlite3RealSameAsInt(double r1, sqlite3_int64 i){
75152 double r2 = (double)i;
75153 return memcmp(&r1, &r2, sizeof(r1))==0;
75154 }
75155
75156 /*
@@ -80035,11 +80031,11 @@
80035 ** This function is implemented as two separate routines for performance.
80036 ** The few cases that require local variables are broken out into a separate
80037 ** routine so that in most cases the overhead of moving the stack pointer
80038 ** is avoided.
80039 */
80040 static u32 SQLITE_NOINLINE serialGet(
80041 const unsigned char *buf, /* Buffer to deserialize from */
80042 u32 serial_type, /* Serial type to deserialize */
80043 Mem *pMem /* Memory cell to write value into */
80044 ){
80045 u64 x = FOUR_BYTE_UINT(buf);
@@ -80067,11 +80063,11 @@
80067 assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );
80068 #endif
80069 assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 );
80070 swapMixedEndianFloat(x);
80071 memcpy(&pMem->u.r, &x, sizeof(x));
80072 pMem->flags = sqlite3IsNaN(pMem->u.r) ? MEM_Null : MEM_Real;
80073 }
80074 return 8;
80075 }
80076 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
80077 const unsigned char *buf, /* Buffer to deserialize from */
@@ -83930,10 +83926,34 @@
83930 sqlite3BtreeCursorZero(pCx->uc.pCursor);
83931 }
83932 }
83933 return pCx;
83934 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
83935
83936 /*
83937 ** Try to convert a value into a numeric representation if we can
83938 ** do so without loss of information. In other words, if the string
83939 ** looks like a number, convert it into a number. If it does not
@@ -83948,16 +83968,16 @@
83948 ** point or exponential notation, the result is only MEM_Real, even
83949 ** if there is an exact integer representation of the quantity.
83950 */
83951 static void applyNumericAffinity(Mem *pRec, int bTryForInt){
83952 double rValue;
83953 i64 iValue;
83954 u8 enc = pRec->enc;
 
83955 assert( (pRec->flags & (MEM_Str|MEM_Int|MEM_Real|MEM_IntReal))==MEM_Str );
83956 if( sqlite3AtoF(pRec->z, &rValue, pRec->n, enc)==0 ) return;
83957 if( 0==sqlite3Atoi64(pRec->z, &iValue, pRec->n, enc) ){
83958 pRec->u.i = iValue;
83959 pRec->flags |= MEM_Int;
83960 }else{
83961 pRec->u.r = rValue;
83962 pRec->flags |= MEM_Real;
83963 if( bTryForInt ) sqlite3VdbeIntegerAffinity(pRec);
@@ -113767,14 +113787,14 @@
113767 r = sqlite3_value_double(argv[0]);
113768 /* If Y==0 and X will fit in a 64-bit int,
113769 ** handle the rounding directly,
113770 ** otherwise use printf.
113771 */
113772 if( n==0 && r>=0 && r<LARGEST_INT64-1 ){
113773 r = (double)((sqlite_int64)(r+0.5));
113774 }else if( n==0 && r<0 && (-r)<LARGEST_INT64-1 ){
113775 r = -(double)((sqlite_int64)((-r)+0.5));
113776 }else{
113777 zBuf = sqlite3_mprintf("%.*f",n,r);
113778 if( zBuf==0 ){
113779 sqlite3_result_error_nomem(context);
113780 return;
@@ -127556,10 +127576,11 @@
127556 /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only
127557 ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.
127558 */
127559 assert( p && p->pPrior ); /* Calling function guarantees this much */
127560 assert( (p->selFlags & SF_Recursive)==0 || p->op==TK_ALL || p->op==TK_UNION );
 
127561 db = pParse->db;
127562 pPrior = p->pPrior;
127563 dest = *pDest;
127564 if( pPrior->pOrderBy || pPrior->pLimit ){
127565 sqlite3ErrorMsg(pParse,"%s clause should come after %s not before",
@@ -129061,14 +129082,14 @@
129061 x.isLeftJoin = isLeftJoin;
129062 x.pEList = pSub->pEList;
129063 substSelect(&x, pParent, 0);
129064 }
129065
129066 /* The flattened query is distinct if either the inner or the
129067 ** outer query is distinct.
129068 */
129069 pParent->selFlags |= pSub->selFlags & SF_Distinct;
129070
129071 /*
129072 ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y;
129073 **
129074 ** One is tempted to try to add a and b to combine the limits. But this
@@ -174772,11 +174793,11 @@
174772 int nSuffix; /* Size of term suffix in bytes */
174773
174774 /* Node must have already been started. There must be a doclist for a
174775 ** leaf node, and there must not be a doclist for an internal node. */
174776 assert( pNode->n>0 );
174777 assert( (pNode->a[0]=='\0')==(aDoclist!=0) );
174778
174779 blobGrowBuffer(pPrev, nTerm, &rc);
174780 if( rc!=SQLITE_OK ) return rc;
174781
174782 nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);
@@ -174988,11 +175009,11 @@
174988 const char *zRhs, int nRhs /* RHS of comparison */
174989 ){
174990 int nCmp = MIN(nLhs, nRhs);
174991 int res;
174992
174993 res = memcmp(zLhs, zRhs, nCmp);
174994 if( res==0 ) res = nLhs - nRhs;
174995
174996 return res;
174997 }
174998
@@ -175131,27 +175152,29 @@
175131 for(i=nHeight; i>=0 && rc==SQLITE_OK; i--){
175132 NodeReader reader;
175133 pNode = &pWriter->aNodeWriter[i];
175134
175135 rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n);
175136 while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader);
175137 blobGrowBuffer(&pNode->key, reader.term.n, &rc);
175138 if( rc==SQLITE_OK ){
175139 memcpy(pNode->key.a, reader.term.a, reader.term.n);
175140 pNode->key.n = reader.term.n;
175141 if( i>0 ){
175142 char *aBlock = 0;
175143 int nBlock = 0;
175144 pNode = &pWriter->aNodeWriter[i-1];
175145 pNode->iBlock = reader.iChild;
175146 rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0);
175147 blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc);
175148 if( rc==SQLITE_OK ){
175149 memcpy(pNode->block.a, aBlock, nBlock);
175150 pNode->block.n = nBlock;
175151 }
175152 sqlite3_free(aBlock);
 
 
175153 }
175154 }
175155 nodeReaderRelease(&reader);
175156 }
175157 }
@@ -175390,11 +175413,14 @@
175390 sqlite3_int64 *piBlock /* OUT: Block number in next layer down */
175391 ){
175392 NodeReader reader; /* Reader object */
175393 Blob prev = {0, 0, 0}; /* Previous term written to new node */
175394 int rc = SQLITE_OK; /* Return code */
175395 int bLeaf = aNode[0]=='\0'; /* True for a leaf node */
 
 
 
175396
175397 /* Allocate required output space */
175398 blobGrowBuffer(pNew, nNode, &rc);
175399 if( rc!=SQLITE_OK ) return rc;
175400 pNew->n = 0;
@@ -210593,11 +210619,11 @@
210593 pData = fts5DataRead(p, FTS5_STRUCTURE_ROWID);
210594 if( p->rc==SQLITE_OK ){
210595 /* TODO: Do we need this if the leaf-index is appended? Probably... */
210596 memset(&pData->p[pData->nn], 0, FTS5_DATA_PADDING);
210597 p->rc = fts5StructureDecode(pData->p, pData->nn, &iCookie, &pRet);
210598 if( p->rc==SQLITE_OK && pConfig->iCookie!=iCookie ){
210599 p->rc = sqlite3Fts5ConfigLoad(pConfig, iCookie);
210600 }
210601 fts5DataRelease(pData);
210602 if( p->rc!=SQLITE_OK ){
210603 fts5StructureRelease(pRet);
@@ -218831,11 +218857,11 @@
218831 int nArg, /* Number of args */
218832 sqlite3_value **apUnused /* Function arguments */
218833 ){
218834 assert( nArg==0 );
218835 UNUSED_PARAM2(nArg, apUnused);
218836 sqlite3_result_text(pCtx, "fts5: 2019-05-23 16:38:12 d2fe370cafa9b11f6c3eb4e1c3be48d9d2610b9d2f9d9ebf9e50267f9079dfc0", -1, SQLITE_TRANSIENT);
218837 }
218838
218839 /*
218840 ** Return true if zName is the extension on one of the shadow tables used
218841 ** by this module.
@@ -223597,12 +223623,12 @@
223597 }
223598 #endif /* SQLITE_CORE */
223599 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
223600
223601 /************** End of stmt.c ************************************************/
223602 #if __LINE__!=223602
223603 #undef SQLITE_SOURCE_ID
223604 #define SQLITE_SOURCE_ID "2019-05-23 16:38:12 d2fe370cafa9b11f6c3eb4e1c3be48d9d2610b9d2f9d9ebf9e50267f9079alt2"
223605 #endif
223606 /* Return the source-id for this library */
223607 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
223608 /************************** End of sqlite3.c ******************************/
223609
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1167,11 +1167,11 @@
1167 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
1168 ** [sqlite_version()] and [sqlite_source_id()].
1169 */
1170 #define SQLITE_VERSION "3.29.0"
1171 #define SQLITE_VERSION_NUMBER 3029000
1172 #define SQLITE_SOURCE_ID "2019-06-05 14:29:53 7b3a99fce8b4a757f2b2ef2f0b02d68566f2528d9ae1e30628522717f872466c"
1173
1174 /*
1175 ** CAPI3REF: Run-Time Library Version Numbers
1176 ** KEYWORDS: sqlite3_version sqlite3_sourceid
1177 **
@@ -18730,12 +18730,16 @@
18730 #else
18731 # define sqlite3MutexWarnOnContention(x)
18732 #endif
18733
18734 #ifndef SQLITE_OMIT_FLOATING_POINT
18735 # define EXP754 (((u64)0x7ff)<<52)
18736 # define MAN754 ((((u64)1)<<52)-1)
18737 # define IsNaN(X) (((X)&EXP754)==EXP754 && ((X)&MAN754)!=0)
18738 SQLITE_PRIVATE int sqlite3IsNaN(double);
18739 #else
18740 # define IsNaN(X) 0
18741 # define sqlite3IsNaN(X) 0
18742 #endif
18743
18744 /*
18745 ** An instance of the following structure holds information about SQL
@@ -19103,10 +19107,11 @@
19107 SQLITE_PRIVATE int sqlite3FixSrcList(DbFixer*, SrcList*);
19108 SQLITE_PRIVATE int sqlite3FixSelect(DbFixer*, Select*);
19109 SQLITE_PRIVATE int sqlite3FixExpr(DbFixer*, Expr*);
19110 SQLITE_PRIVATE int sqlite3FixExprList(DbFixer*, ExprList*);
19111 SQLITE_PRIVATE int sqlite3FixTriggerStep(DbFixer*, TriggerStep*);
19112 SQLITE_PRIVATE int sqlite3RealSameAsInt(double,sqlite3_int64);
19113 SQLITE_PRIVATE int sqlite3AtoF(const char *z, double*, int, u8);
19114 SQLITE_PRIVATE int sqlite3GetInt32(const char *, int*);
19115 SQLITE_PRIVATE int sqlite3Atoi(const char*);
19116 #ifndef SQLITE_OMIT_UTF16
19117 SQLITE_PRIVATE int sqlite3Utf16ByteLen(const void *pData, int nChar);
@@ -27348,10 +27353,16 @@
27353 { 'T', 0, 0, etTOKEN, 0, 0 },
27354 { 'S', 0, 0, etSRCLIST, 0, 0 },
27355 { 'r', 10, 1, etORDINAL, 0, 0 },
27356 };
27357
27358 /* Floating point constants used for rounding */
27359 static const double arRound[] = {
27360 5.0e-01, 5.0e-02, 5.0e-03, 5.0e-04, 5.0e-05,
27361 5.0e-06, 5.0e-07, 5.0e-08, 5.0e-09, 5.0e-10,
27362 };
27363
27364 /*
27365 ** If SQLITE_OMIT_FLOATING_POINT is defined, then none of the floating point
27366 ** conversions will work.
27367 */
27368 #ifndef SQLITE_OMIT_FLOATING_POINT
@@ -27766,12 +27777,22 @@
27777 }else{
27778 prefix = flag_prefix;
27779 }
27780 if( xtype==etGENERIC && precision>0 ) precision--;
27781 testcase( precision>0xfff );
27782 idx = precision & 0xfff;
27783 rounder = arRound[idx%10];
27784 while( idx>=10 ){ rounder *= 1.0e-10; idx -= 10; }
27785 if( xtype==etFLOAT ){
27786 double rx = (double)realvalue;
27787 sqlite3_uint64 u;
27788 int ex;
27789 memcpy(&u, &rx, sizeof(u));
27790 ex = -1023 + (int)((u>>52)&0x7ff);
27791 if( precision+(ex/3) < 15 ) rounder += realvalue*3e-16;
27792 realvalue += rounder;
27793 }
27794 /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
27795 exp = 0;
27796 if( sqlite3IsNaN((double)realvalue) ){
27797 bufpt = "NaN";
27798 length = 3;
@@ -30270,51 +30291,15 @@
30291 #endif
30292
30293 #ifndef SQLITE_OMIT_FLOATING_POINT
30294 /*
30295 ** Return true if the floating point value is Not a Number (NaN).
 
 
 
30296 */
30297 SQLITE_PRIVATE int sqlite3IsNaN(double x){
30298 u64 y;
30299 memcpy(&y,&x,sizeof(y));
30300 return IsNaN(y);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30301 }
30302 #endif /* SQLITE_OMIT_FLOATING_POINT */
30303
30304 /*
30305 ** Compute a string length that is limited to what can be stored in
@@ -30571,19 +30556,19 @@
30556 ** This routine only works for values of E between 1 and 341.
30557 */
30558 static LONGDOUBLE_TYPE sqlite3Pow10(int E){
30559 #if defined(_MSC_VER)
30560 static const LONGDOUBLE_TYPE x[] = {
30561 1.0e+001L,
30562 1.0e+002L,
30563 1.0e+004L,
30564 1.0e+008L,
30565 1.0e+016L,
30566 1.0e+032L,
30567 1.0e+064L,
30568 1.0e+128L,
30569 1.0e+256L
30570 };
30571 LONGDOUBLE_TYPE r = 1.0;
30572 int i;
30573 assert( E>=0 && E<=307 );
30574 for(i=0; E!=0; i++, E >>=1){
@@ -30609,12 +30594,17 @@
30594 **
30595 ** The string z[] is length bytes in length (bytes, not characters) and
30596 ** uses the encoding enc. The string is not necessarily zero-terminated.
30597 **
30598 ** Return TRUE if the result is a valid real number (or integer) and FALSE
30599 ** if the string is empty or contains extraneous text. More specifically
30600 ** return
30601 ** 1 => The input string is a pure integer
30602 ** 2 or more => The input has a decimal point or eNNN clause
30603 ** 0 => The input string is not a valid number
30604 **
30605 ** Valid numbers are in one of these formats:
30606 **
30607 ** [+-]digits[E[+-]digits]
30608 ** [+-]digits.[digits][E[+-]digits]
30609 ** [+-].digits[E[+-]digits]
30610 **
@@ -30635,12 +30625,12 @@
30625 int d = 0; /* adjust exponent for shifting decimal point */
30626 int esign = 1; /* sign of exponent */
30627 int e = 0; /* exponent */
30628 int eValid = 1; /* True exponent is either not used or is well-formed */
30629 double result;
30630 int nDigit = 0; /* Number of digits processed */
30631 int eType = 1; /* 1: pure integer, 2+: fractional -1 or less: bad UTF16 */
30632
30633 assert( enc==SQLITE_UTF8 || enc==SQLITE_UTF16LE || enc==SQLITE_UTF16BE );
30634 *pResult = 0.0; /* Default return value, in case of an error */
30635
30636 if( enc==SQLITE_UTF8 ){
@@ -30647,12 +30637,14 @@
30637 incr = 1;
30638 }else{
30639 int i;
30640 incr = 2;
30641 assert( SQLITE_UTF16LE==2 && SQLITE_UTF16BE==3 );
30642 testcase( enc==SQLITE_UTF16LE );
30643 testcase( enc==SQLITE_UTF16BE );
30644 for(i=3-enc; i<length && z[i]==0; i+=2){}
30645 if( i<length ) eType = -100;
30646 zEnd = &z[i^1];
30647 z += (enc&1);
30648 }
30649
30650 /* skip leading spaces */
@@ -30666,39 +30658,43 @@
30658 }else if( *z=='+' ){
30659 z+=incr;
30660 }
30661
30662 /* copy max significant digits to significand */
30663 while( z<zEnd && sqlite3Isdigit(*z) ){
30664 s = s*10 + (*z - '0');
30665 z+=incr; nDigit++;
30666 if( s>=((LARGEST_INT64-9)/10) ){
30667 /* skip non-significant significand digits
30668 ** (increase exponent by d to shift decimal left) */
30669 while( z<zEnd && sqlite3Isdigit(*z) ){ z+=incr; d++; }
30670 }
30671 }
 
 
 
 
30672 if( z>=zEnd ) goto do_atof_calc;
30673
30674 /* if decimal point is present */
30675 if( *z=='.' ){
30676 z+=incr;
30677 eType++;
30678 /* copy digits from after decimal to significand
30679 ** (decrease exponent by d to shift decimal right) */
30680 while( z<zEnd && sqlite3Isdigit(*z) ){
30681 if( s<((LARGEST_INT64-9)/10) ){
30682 s = s*10 + (*z - '0');
30683 d--;
30684 nDigit++;
30685 }
30686 z+=incr;
30687 }
30688 }
30689 if( z>=zEnd ) goto do_atof_calc;
30690
30691 /* if exponent is present */
30692 if( *z=='e' || *z=='E' ){
30693 z+=incr;
30694 eValid = 0;
30695 eType++;
30696
30697 /* This branch is needed to avoid a (harmless) buffer overread. The
30698 ** special comment alerts the mutation tester that the correct answer
30699 ** is obtained even if the branch is omitted */
30700 if( z>=zEnd ) goto do_atof_calc; /*PREVENTS-HARMLESS-OVERREAD*/
@@ -30793,11 +30789,11 @@
30789
30790 /* store the result */
30791 *pResult = result;
30792
30793 /* return true if number and no extra non-whitespace chracters after */
30794 return z==zEnd && nDigit>0 && eValid && eType>0 ? eType : 0;
30795 #else
30796 return !sqlite3Atoi64(z, pResult, length, enc);
30797 #endif /* SQLITE_OMIT_FLOATING_POINT */
30798 }
30799
@@ -75146,11 +75142,11 @@
75142 **
75143 ** For some versions of GCC on 32-bit machines, if you do the more obvious
75144 ** comparison of "r1==(double)i" you sometimes get an answer of false even
75145 ** though the r1 and (double)i values are bit-for-bit the same.
75146 */
75147 SQLITE_PRIVATE int sqlite3RealSameAsInt(double r1, sqlite3_int64 i){
75148 double r2 = (double)i;
75149 return memcmp(&r1, &r2, sizeof(r1))==0;
75150 }
75151
75152 /*
@@ -80035,11 +80031,11 @@
80031 ** This function is implemented as two separate routines for performance.
80032 ** The few cases that require local variables are broken out into a separate
80033 ** routine so that in most cases the overhead of moving the stack pointer
80034 ** is avoided.
80035 */
80036 static u32 serialGet(
80037 const unsigned char *buf, /* Buffer to deserialize from */
80038 u32 serial_type, /* Serial type to deserialize */
80039 Mem *pMem /* Memory cell to write value into */
80040 ){
80041 u64 x = FOUR_BYTE_UINT(buf);
@@ -80067,11 +80063,11 @@
80063 assert( sizeof(r1)==sizeof(t2) && memcmp(&r1, &t2, sizeof(r1))==0 );
80064 #endif
80065 assert( sizeof(x)==8 && sizeof(pMem->u.r)==8 );
80066 swapMixedEndianFloat(x);
80067 memcpy(&pMem->u.r, &x, sizeof(x));
80068 pMem->flags = IsNaN(x) ? MEM_Null : MEM_Real;
80069 }
80070 return 8;
80071 }
80072 SQLITE_PRIVATE u32 sqlite3VdbeSerialGet(
80073 const unsigned char *buf, /* Buffer to deserialize from */
@@ -83930,10 +83926,34 @@
83926 sqlite3BtreeCursorZero(pCx->uc.pCursor);
83927 }
83928 }
83929 return pCx;
83930 }
83931
83932 /*
83933 ** The string in pRec is known to look like an integer and to have a
83934 ** floating point value of rValue. Return true and set *piValue to the
83935 ** integer value if the string is in range to be an integer. Otherwise,
83936 ** return false.
83937 */
83938 static int alsoAnInt(Mem *pRec, double rValue, i64 *piValue){
83939 i64 iValue = (double)rValue;
83940 if( sqlite3RealSameAsInt(rValue,iValue) ){
83941 testcase( iValue<-2251799813685248 );
83942 testcase( iValue==-2251799813685248 );
83943 testcase( iValue==-2251799813685247 );
83944 testcase( iValue>-2251799813685247 && iValue<+2251799813685247 );
83945 testcase( iValue==+2251799813685247 );
83946 testcase( iValue==+2251799813685248 );
83947 testcase( iValue>+2251799813685248 );
83948 if( iValue > -2251799813685248 && iValue < 2251799813685248 ){
83949 *piValue = iValue;
83950 return 1;
83951 }
83952 }
83953 return 0==sqlite3Atoi64(pRec->z, piValue, pRec->n, pRec->enc);
83954 }
83955
83956 /*
83957 ** Try to convert a value into a numeric representation if we can
83958 ** do so without loss of information. In other words, if the string
83959 ** looks like a number, convert it into a number. If it does not
@@ -83948,16 +83968,16 @@
83968 ** point or exponential notation, the result is only MEM_Real, even
83969 ** if there is an exact integer representation of the quantity.
83970 */
83971 static void applyNumericAffinity(Mem *pRec, int bTryForInt){
83972 double rValue;
 
83973 u8 enc = pRec->enc;
83974 int rc;
83975 assert( (pRec->flags & (MEM_Str|MEM_Int|MEM_Real|MEM_IntReal))==MEM_Str );
83976 rc = sqlite3AtoF(pRec->z, &rValue, pRec->n, enc);
83977 if( rc==0 ) return;
83978 if( rc==1 && alsoAnInt(pRec, rValue, &pRec->u.i) ){
83979 pRec->flags |= MEM_Int;
83980 }else{
83981 pRec->u.r = rValue;
83982 pRec->flags |= MEM_Real;
83983 if( bTryForInt ) sqlite3VdbeIntegerAffinity(pRec);
@@ -113767,14 +113787,14 @@
113787 r = sqlite3_value_double(argv[0]);
113788 /* If Y==0 and X will fit in a 64-bit int,
113789 ** handle the rounding directly,
113790 ** otherwise use printf.
113791 */
113792 if( r<-4503599627370496.0 || r>+4503599627370496.0 ){
113793 /* The value has no fractional part so there is nothing to round */
113794 }else if( n==0 ){
113795 r = (double)((sqlite_int64)(r+(r<0?-0.5:+0.5)));
113796 }else{
113797 zBuf = sqlite3_mprintf("%.*f",n,r);
113798 if( zBuf==0 ){
113799 sqlite3_result_error_nomem(context);
113800 return;
@@ -127556,10 +127576,11 @@
127576 /* Make sure there is no ORDER BY or LIMIT clause on prior SELECTs. Only
127577 ** the last (right-most) SELECT in the series may have an ORDER BY or LIMIT.
127578 */
127579 assert( p && p->pPrior ); /* Calling function guarantees this much */
127580 assert( (p->selFlags & SF_Recursive)==0 || p->op==TK_ALL || p->op==TK_UNION );
127581 assert( p->selFlags & SF_Compound );
127582 db = pParse->db;
127583 pPrior = p->pPrior;
127584 dest = *pDest;
127585 if( pPrior->pOrderBy || pPrior->pLimit ){
127586 sqlite3ErrorMsg(pParse,"%s clause should come after %s not before",
@@ -129061,14 +129082,14 @@
129082 x.isLeftJoin = isLeftJoin;
129083 x.pEList = pSub->pEList;
129084 substSelect(&x, pParent, 0);
129085 }
129086
129087 /* The flattened query is a compound if either the inner or the
129088 ** outer query is a compound. */
129089 pParent->selFlags |= pSub->selFlags & SF_Compound;
129090 assert( (pSub->selFlags & SF_Distinct)==0 ); /* restriction (17b) */
129091
129092 /*
129093 ** SELECT ... FROM (SELECT ... LIMIT a OFFSET b) LIMIT x OFFSET y;
129094 **
129095 ** One is tempted to try to add a and b to combine the limits. But this
@@ -174772,11 +174793,11 @@
174793 int nSuffix; /* Size of term suffix in bytes */
174794
174795 /* Node must have already been started. There must be a doclist for a
174796 ** leaf node, and there must not be a doclist for an internal node. */
174797 assert( pNode->n>0 );
174798 assert_fts3_nc( (pNode->a[0]=='\0')==(aDoclist!=0) );
174799
174800 blobGrowBuffer(pPrev, nTerm, &rc);
174801 if( rc!=SQLITE_OK ) return rc;
174802
174803 nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);
@@ -174988,11 +175009,11 @@
175009 const char *zRhs, int nRhs /* RHS of comparison */
175010 ){
175011 int nCmp = MIN(nLhs, nRhs);
175012 int res;
175013
175014 res = (nCmp ? memcmp(zLhs, zRhs, nCmp) : 0);
175015 if( res==0 ) res = nLhs - nRhs;
175016
175017 return res;
175018 }
175019
@@ -175131,27 +175152,29 @@
175152 for(i=nHeight; i>=0 && rc==SQLITE_OK; i--){
175153 NodeReader reader;
175154 pNode = &pWriter->aNodeWriter[i];
175155
175156 rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n);
175157 if( reader.aNode ){
175158 while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader);
175159 blobGrowBuffer(&pNode->key, reader.term.n, &rc);
175160 if( rc==SQLITE_OK ){
175161 memcpy(pNode->key.a, reader.term.a, reader.term.n);
175162 pNode->key.n = reader.term.n;
175163 if( i>0 ){
175164 char *aBlock = 0;
175165 int nBlock = 0;
175166 pNode = &pWriter->aNodeWriter[i-1];
175167 pNode->iBlock = reader.iChild;
175168 rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0);
175169 blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc);
175170 if( rc==SQLITE_OK ){
175171 memcpy(pNode->block.a, aBlock, nBlock);
175172 pNode->block.n = nBlock;
175173 }
175174 sqlite3_free(aBlock);
175175 }
175176 }
175177 }
175178 nodeReaderRelease(&reader);
175179 }
175180 }
@@ -175390,11 +175413,14 @@
175413 sqlite3_int64 *piBlock /* OUT: Block number in next layer down */
175414 ){
175415 NodeReader reader; /* Reader object */
175416 Blob prev = {0, 0, 0}; /* Previous term written to new node */
175417 int rc = SQLITE_OK; /* Return code */
175418 int bLeaf; /* True for a leaf node */
175419
175420 if( nNode<1 ) return FTS_CORRUPT_VTAB;
175421 bLeaf = aNode[0]=='\0';
175422
175423 /* Allocate required output space */
175424 blobGrowBuffer(pNew, nNode, &rc);
175425 if( rc!=SQLITE_OK ) return rc;
175426 pNew->n = 0;
@@ -210593,11 +210619,11 @@
210619 pData = fts5DataRead(p, FTS5_STRUCTURE_ROWID);
210620 if( p->rc==SQLITE_OK ){
210621 /* TODO: Do we need this if the leaf-index is appended? Probably... */
210622 memset(&pData->p[pData->nn], 0, FTS5_DATA_PADDING);
210623 p->rc = fts5StructureDecode(pData->p, pData->nn, &iCookie, &pRet);
210624 if( p->rc==SQLITE_OK && (pConfig->pgsz==0 || pConfig->iCookie!=iCookie) ){
210625 p->rc = sqlite3Fts5ConfigLoad(pConfig, iCookie);
210626 }
210627 fts5DataRelease(pData);
210628 if( p->rc!=SQLITE_OK ){
210629 fts5StructureRelease(pRet);
@@ -218831,11 +218857,11 @@
218857 int nArg, /* Number of args */
218858 sqlite3_value **apUnused /* Function arguments */
218859 ){
218860 assert( nArg==0 );
218861 UNUSED_PARAM2(nArg, apUnused);
218862 sqlite3_result_text(pCtx, "fts5: 2019-06-04 18:21:59 4979f138e8c8bef7dd6b5921fb9ca9fea86bbf7ec1419934bb2d1a0d74e77183", -1, SQLITE_TRANSIENT);
218863 }
218864
218865 /*
218866 ** Return true if zName is the extension on one of the shadow tables used
218867 ** by this module.
@@ -223597,12 +223623,12 @@
223623 }
223624 #endif /* SQLITE_CORE */
223625 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_STMTVTAB) */
223626
223627 /************** End of stmt.c ************************************************/
223628 #if __LINE__!=223628
223629 #undef SQLITE_SOURCE_ID
223630 #define SQLITE_SOURCE_ID "2019-06-05 14:29:53 7b3a99fce8b4a757f2b2ef2f0b02d68566f2528d9ae1e30628522717f872alt2"
223631 #endif
223632 /* Return the source-id for this library */
223633 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
223634 /************************** End of sqlite3.c ******************************/
223635
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123123
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124124
** [sqlite_version()] and [sqlite_source_id()].
125125
*/
126126
#define SQLITE_VERSION "3.29.0"
127127
#define SQLITE_VERSION_NUMBER 3029000
128
-#define SQLITE_SOURCE_ID "2019-05-23 16:38:12 d2fe370cafa9b11f6c3eb4e1c3be48d9d2610b9d2f9d9ebf9e50267f9079dfc0"
128
+#define SQLITE_SOURCE_ID "2019-06-05 14:29:53 7b3a99fce8b4a757f2b2ef2f0b02d68566f2528d9ae1e30628522717f872466c"
129129
130130
/*
131131
** CAPI3REF: Run-Time Library Version Numbers
132132
** KEYWORDS: sqlite3_version sqlite3_sourceid
133133
**
134134
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.29.0"
127 #define SQLITE_VERSION_NUMBER 3029000
128 #define SQLITE_SOURCE_ID "2019-05-23 16:38:12 d2fe370cafa9b11f6c3eb4e1c3be48d9d2610b9d2f9d9ebf9e50267f9079dfc0"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
134
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -123,11 +123,11 @@
123 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
124 ** [sqlite_version()] and [sqlite_source_id()].
125 */
126 #define SQLITE_VERSION "3.29.0"
127 #define SQLITE_VERSION_NUMBER 3029000
128 #define SQLITE_SOURCE_ID "2019-06-05 14:29:53 7b3a99fce8b4a757f2b2ef2f0b02d68566f2528d9ae1e30628522717f872466c"
129
130 /*
131 ** CAPI3REF: Run-Time Library Version Numbers
132 ** KEYWORDS: sqlite3_version sqlite3_sourceid
133 **
134

Keyboard Shortcuts

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