From 69f3d04810dd4793ce5bc4517158e7d4df6fba11 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 11 Mar 2013 01:23:37 +0000 Subject: [PATCH 01/42] Add experimental tointeger() and todouble() SQL functions. FossilOrigin-Name: 465fd853d3e3544cb06b15ffa32ce25774d816c7 --- manifest | 18 +-- manifest.uuid | 2 +- src/func.c | 110 +++++++++++++++++ test/func4.test | 318 ++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 440 insertions(+), 8 deletions(-) create mode 100644 test/func4.test diff --git a/manifest b/manifest index 035401514a..2f958e4c82 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\stest\scase\sfor\sthe\sproblem\sfixed\sby\sthe\sprevious\scommit. -D 2013-03-09T14:49:07.597 +C Add\sexperimental\stointeger()\sand\stodouble()\sSQL\sfunctions. +D 2013-03-11T01:23:37.658 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -133,7 +133,7 @@ F src/delete.c aeabdabeeeaa0584127f291baa9617153d334778 F src/expr.c a23b4aac2a455b2e76b55bef5dcfbe62b665375c F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e16942bd5c8a868ac53287886464a5ed0e72b179 -F src/func.c 48987c025d69399f59a1c2a553cea5da41bf105d +F src/func.c 82dfd6b6744bd583cb52157ee1496af351ec9d49 F src/global.c e59ecd2c553ad0d4bfbc84ca71231336f8993a7a F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -511,6 +511,7 @@ F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test b058483c17952eff7797b837bbb61e27e6b05606 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a +F test/func4.test f87bfeee439933de8170e96d2a89db7eaf3b42a5 F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 F test/fuzz.test 77fd50afc12847af50fcf1941679d90adebadde6 F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167 @@ -1037,7 +1038,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P ddee56c9b2b591b9386b1072c3b3a699f7c1f853 -R 0685395d6c72f7d3eee9637a399e2144 -U dan -Z 77cf7ba50ad60c04d236fa95e2bf9a03 +P e899b058a703158012c054974bd9a909d75144d8 +R b5370fb9874f2982950e0680a1d54689 +T *branch * toTypeFuncs +T *sym-toTypeFuncs * +T -sym-trunk * +U mistachkin +Z ce323d9c5c5aa4b2dbf9898a0e2eb8db diff --git a/manifest.uuid b/manifest.uuid index 947aa65ad8..cf25290033 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e899b058a703158012c054974bd9a909d75144d8 \ No newline at end of file +465fd853d3e3544cb06b15ffa32ce25774d816c7 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 0fce95904f..c642e022fb 100644 --- a/src/func.c +++ b/src/func.c @@ -962,6 +962,112 @@ static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ } } +/* +** EXPERIMENTAL - This is not an official function. The interface may +** change. This function may disappear. Do not write code that depends +** on this function. +** +** Implementation of the TOINTEGER() function. This function takes a +** single argument. If the argument is an integer or is a double that +** can be losslessly converted to an integer, the return value is the +** same as the argument. If the argument is a double that cannot be +** losslessly represented as an integer, the return value is undefined. +** If the argument is NULL, the return value is NULL. Otherwise, an +** attempt is made to convert the argument to an integer. If the +** conversion is successful, the integer value is returned; otherwise, +** NULL is returned. +*/ +static void tointegerFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + assert( argc==1 ); + UNUSED_PARAMETER(argc); + switch( sqlite3_value_type(argv[0]) ){ + case SQLITE_FLOAT: + case SQLITE_INTEGER: { + sqlite3_result_int64(context, sqlite3_value_int64(argv[0])); + break; + } + case SQLITE_BLOB: + case SQLITE_TEXT: { + const unsigned char *zStr = sqlite3_value_text(argv[0]); + if( zStr ){ + int nStr = sqlite3_value_bytes(argv[0]); + if( nStr ){ + i64 iVal; + if( !sqlite3Atoi64(zStr, &iVal, nStr, SQLITE_UTF8) ){ + sqlite3_result_int64(context, iVal); + return; + } + } + } + sqlite3_result_null(context); + break; + } + default: { + assert( sqlite3_value_type(argv[0])==SQLITE_NULL ); + sqlite3_result_null(context); + break; + } + } +} + +/* +** EXPERIMENTAL - This is not an official function. The interface may +** change. This function may disappear. Do not write code that depends +** on this function. +** +** Implementation of the TODOUBLE() function. This function takes a +** single argument. If the argument is a double or is an integer that +** can be losslessly converted to a double, the return value is the +** same as the argument. If the argument is an integer that cannot be +** losslessly represented as a double, the return value is undefined. +** If the argument is NULL, the return value is NULL. Otherwise, an +** attempt is made to convert the argument to a double. If the +** conversion is successful, the double value is returned; otherwise, +** NULL is returned. +*/ +#ifndef SQLITE_OMIT_FLOATING_POINT +static void todoubleFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + assert( argc==1 ); + UNUSED_PARAMETER(argc); + switch( sqlite3_value_type(argv[0]) ){ + case SQLITE_FLOAT: + case SQLITE_INTEGER: { + sqlite3_result_double(context, sqlite3_value_double(argv[0])); + break; + } + case SQLITE_BLOB: + case SQLITE_TEXT: { + const unsigned char *zStr = sqlite3_value_text(argv[0]); + if( zStr ){ + int nStr = sqlite3_value_bytes(argv[0]); + if( nStr ){ + double rVal; + if( sqlite3AtoF(zStr, &rVal, nStr, SQLITE_UTF8) ){ + sqlite3_result_double(context, rVal); + return; + } + } + } + sqlite3_result_null(context); + break; + } + default: { + assert( sqlite3_value_type(argv[0])==SQLITE_NULL ); + sqlite3_result_null(context); + break; + } + } +} +#endif + /* ** The unicode() function. Return the integer unicode code-point value ** for the first character of the input string. @@ -1670,6 +1776,10 @@ void sqlite3RegisterGlobalFunctions(void){ FUNCTION(sqlite_compileoption_get, 1, 0, 0, compileoptiongetFunc ), #endif /* SQLITE_OMIT_COMPILEOPTION_DIAGS */ FUNCTION(quote, 1, 0, 0, quoteFunc ), + FUNCTION(tointeger, 1, 0, 0, tointegerFunc ), +#ifndef SQLITE_OMIT_FLOATING_POINT + FUNCTION(todouble, 1, 0, 0, todoubleFunc ), +#endif FUNCTION(last_insert_rowid, 0, 0, 0, last_insert_rowid), FUNCTION(changes, 0, 0, 0, changes ), FUNCTION(total_changes, 0, 0, 0, total_changes ), diff --git a/test/func4.test b/test/func4.test new file mode 100644 index 0000000000..6956fa27c6 --- /dev/null +++ b/test/func4.test @@ -0,0 +1,318 @@ +# 2013 March 10 +# +# The author disclaims copyright to this source code. In place of +# a legal notice, here is a blessing: +# +# May you do good and not evil. +# May you find forgiveness for yourself and forgive others. +# May you share freely, never taking more than you give. +# +#*********************************************************************** +# This file implements regression tests for SQLite library. The +# focus of this file is testing the TOINTEGER() and TODOUBLE() +# functions. +# +set testdir [file dirname $argv0] +source $testdir/tester.tcl + +set i 0 +do_execsql_test func4-1.[incr i] { + SELECT tointeger(NULL); +} {{}} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(''); +} {{}} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(' '); +} {{}} +do_execsql_test func4-1.[incr i] { + SELECT tointeger('1234'); +} {1234} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(' 1234'); +} {1234} +do_execsql_test func4-1.[incr i] { + SELECT tointeger('bad'); +} {{}} +do_execsql_test func4-1.[incr i] { + SELECT tointeger('0xBAD'); +} {{}} +do_execsql_test func4-1.[incr i] { + SELECT tointeger('123BAD'); +} {{}} +do_execsql_test func4-1.[incr i] { + SELECT tointeger('0x123BAD'); +} {{}} +do_execsql_test func4-1.[incr i] { + SELECT tointeger('123NO'); +} {{}} +do_execsql_test func4-1.[incr i] { + SELECT tointeger('0x123NO'); +} {{}} +do_execsql_test func4-1.[incr i] { + SELECT tointeger('-0x1'); +} {{}} +do_execsql_test func4-1.[incr i] { + SELECT tointeger('-0x0'); +} {{}} +do_execsql_test func4-1.[incr i] { + SELECT tointeger('0x0'); +} {{}} +do_execsql_test func4-1.[incr i] { + SELECT tointeger('0x1'); +} {{}} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(-1); +} {-1} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(-0); +} {0} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(0); +} {0} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(1); +} {1} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(-1.79769313486232e308 - 1); +} {-9223372036854775808} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(-1.79769313486232e308); +} {-9223372036854775808} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(-1.79769313486232e308 + 1); +} {-9223372036854775808} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(-9223372036854775808 - 1); +} {-9223372036854775808} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(-9223372036854775808); +} {-9223372036854775808} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(-9223372036854775808 + 1); +} {-9223372036854775807} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(-2147483648 - 1); +} {-2147483649} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(-2147483648); +} {-2147483648} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(-2147483648 + 1); +} {-2147483647} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(2147483647 - 1); +} {2147483646} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(2147483647); +} {2147483647} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(2147483647 + 1); +} {2147483648} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(9223372036854775807 - 1); +} {9223372036854775806} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(9223372036854775807); +} {9223372036854775807} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(9223372036854775807 + 1); +} {-9223372036854775808} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(1.79769313486232e308 - 1); +} {-9223372036854775808} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(1.79769313486232e308); +} {-9223372036854775808} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(1.79769313486232e308 + 1); +} {-9223372036854775808} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(4503599627370496 - 1); +} {4503599627370495} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(4503599627370496); +} {4503599627370496} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(4503599627370496 + 1); +} {4503599627370497} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(9007199254740992 - 1); +} {9007199254740991} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(9007199254740992); +} {9007199254740992} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(9007199254740992 + 1); +} {9007199254740993} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(9223372036854775808 - 1); +} {-9223372036854775808} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(9223372036854775808); +} {-9223372036854775808} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(9223372036854775808 + 1); +} {-9223372036854775808} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(18446744073709551616 - 1); +} {-9223372036854775808} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(18446744073709551616); +} {-9223372036854775808} +do_execsql_test func4-1.[incr i] { + SELECT tointeger(18446744073709551616 + 1); +} {-9223372036854775808} + +ifcapable floatingpoint { + set i 0 + do_execsql_test func4-2.[incr i] { + SELECT todouble(NULL); + } {{}} + do_execsql_test func4-2.[incr i] { + SELECT todouble(''); + } {{}} + do_execsql_test func4-2.[incr i] { + SELECT todouble(' '); + } {{}} + do_execsql_test func4-2.[incr i] { + SELECT todouble('1234'); + } {1234.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(' 1234'); + } {1234.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble('bad'); + } {{}} + do_execsql_test func4-2.[incr i] { + SELECT todouble('0xBAD'); + } {{}} + do_execsql_test func4-2.[incr i] { + SELECT todouble('123BAD'); + } {{}} + do_execsql_test func4-2.[incr i] { + SELECT todouble('0x123BAD'); + } {{}} + do_execsql_test func4-2.[incr i] { + SELECT todouble('123NO'); + } {{}} + do_execsql_test func4-2.[incr i] { + SELECT todouble('0x123NO'); + } {{}} + do_execsql_test func4-2.[incr i] { + SELECT todouble('-0x1'); + } {{}} + do_execsql_test func4-2.[incr i] { + SELECT todouble('-0x0'); + } {{}} + do_execsql_test func4-2.[incr i] { + SELECT todouble('0x0'); + } {{}} + do_execsql_test func4-2.[incr i] { + SELECT todouble('0x1'); + } {{}} + do_execsql_test func4-2.[incr i] { + SELECT todouble(-1); + } {-1.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(-0); + } {0.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(0); + } {0.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(1); + } {1.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(-1.79769313486232e308 - 1); + } {-Inf} + do_execsql_test func4-2.[incr i] { + SELECT todouble(-1.79769313486232e308); + } {-Inf} + do_execsql_test func4-2.[incr i] { + SELECT todouble(-1.79769313486232e308 + 1); + } {-Inf} + do_execsql_test func4-2.[incr i] { + SELECT todouble(-9223372036854775808 - 1); + } {-9.22337203685478e+18} + do_execsql_test func4-2.[incr i] { + SELECT todouble(-9223372036854775808); + } {-9.22337203685478e+18} + do_execsql_test func4-2.[incr i] { + SELECT todouble(-9223372036854775808 + 1); + } {-9.22337203685478e+18} + do_execsql_test func4-2.[incr i] { + SELECT todouble(-2147483648 - 1); + } {-2147483649.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(-2147483648); + } {-2147483648.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(-2147483648 + 1); + } {-2147483647.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(2147483647 - 1); + } {2147483646.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(2147483647); + } {2147483647.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(2147483647 + 1); + } {2147483648.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(9223372036854775807 - 1); + } {9.22337203685478e+18} + do_execsql_test func4-2.[incr i] { + SELECT todouble(9223372036854775807); + } {9.22337203685478e+18} + do_execsql_test func4-2.[incr i] { + SELECT todouble(9223372036854775807 + 1); + } {9.22337203685478e+18} + do_execsql_test func4-2.[incr i] { + SELECT todouble(1.79769313486232e308 - 1); + } {Inf} + do_execsql_test func4-2.[incr i] { + SELECT todouble(1.79769313486232e308); + } {Inf} + do_execsql_test func4-2.[incr i] { + SELECT todouble(1.79769313486232e308 + 1); + } {Inf} + do_execsql_test func4-2.[incr i] { + SELECT todouble(4503599627370496 - 1); + } {4503599627370500.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(4503599627370496); + } {4503599627370500.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(4503599627370496 + 1); + } {4503599627370500.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(9007199254740992 - 1); + } {9007199254740990.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(9007199254740992); + } {9007199254740990.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(9007199254740992 + 1); + } {9007199254740990.0} + do_execsql_test func4-2.[incr i] { + SELECT todouble(9223372036854775808 - 1); + } {9.22337203685478e+18} + do_execsql_test func4-2.[incr i] { + SELECT todouble(9223372036854775808); + } {9.22337203685478e+18} + do_execsql_test func4-2.[incr i] { + SELECT todouble(9223372036854775808 + 1); + } {9.22337203685478e+18} + do_execsql_test func4-2.[incr i] { + SELECT todouble(18446744073709551616 - 1); + } {1.84467440737096e+19} + do_execsql_test func4-2.[incr i] { + SELECT todouble(18446744073709551616); + } {1.84467440737096e+19} + do_execsql_test func4-2.[incr i] { + SELECT todouble(18446744073709551616 + 1); + } {1.84467440737096e+19} +} + +finish_test From 32be00a55be775db820bd91de7d85b99386b5aea Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 11 Mar 2013 06:24:46 +0000 Subject: [PATCH 02/42] Add more tests. FossilOrigin-Name: f9468e334d6086b8a80c6a4204ec4e03fe59cf96 --- manifest | 15 ++++------ manifest.uuid | 2 +- test/func4.test | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 84 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 2f958e4c82..06b814fc57 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sexperimental\stointeger()\sand\stodouble()\sSQL\sfunctions. -D 2013-03-11T01:23:37.658 +C Add\smore\stests. +D 2013-03-11T06:24:46.255 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -511,7 +511,7 @@ F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test b058483c17952eff7797b837bbb61e27e6b05606 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a -F test/func4.test f87bfeee439933de8170e96d2a89db7eaf3b42a5 +F test/func4.test 86f48cf1982a47001447a1924f5573d3c1e17ccf F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 F test/fuzz.test 77fd50afc12847af50fcf1941679d90adebadde6 F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167 @@ -1038,10 +1038,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P e899b058a703158012c054974bd9a909d75144d8 -R b5370fb9874f2982950e0680a1d54689 -T *branch * toTypeFuncs -T *sym-toTypeFuncs * -T -sym-trunk * +P 465fd853d3e3544cb06b15ffa32ce25774d816c7 +R de601f18e2d7c1d69cbd21be32cf69bf U mistachkin -Z ce323d9c5c5aa4b2dbf9898a0e2eb8db +Z 349394d9a983439850a7e1f0ab403301 diff --git a/manifest.uuid b/manifest.uuid index cf25290033..f4a06310b7 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -465fd853d3e3544cb06b15ffa32ce25774d816c7 \ No newline at end of file +f9468e334d6086b8a80c6a4204ec4e03fe59cf96 \ No newline at end of file diff --git a/test/func4.test b/test/func4.test index 6956fa27c6..274b94520d 100644 --- a/test/func4.test +++ b/test/func4.test @@ -315,4 +315,81 @@ ifcapable floatingpoint { } {1.84467440737096e+19} } +ifcapable check { + set i 0 + do_execsql_test func4-3.[incr i] { + CREATE TABLE t1( + x INTEGER CHECK(tointeger(x) IS NOT NULL AND x = CAST(x AS INTEGER)) + ); + } {} + do_test func4-3.[incr i] { + catchsql { + INSERT INTO t1 (x) VALUES (NULL); + } + } {1 {constraint failed}} + do_test func4-3.[incr i] { + catchsql { + INSERT INTO t1 (x) VALUES (NULL); + } + } {1 {constraint failed}} + do_test func4-3.[incr i] { + catchsql { + INSERT INTO t1 (x) VALUES (''); + } + } {1 {constraint failed}} + do_test func4-3.[incr i] { + catchsql { + INSERT INTO t1 (x) VALUES ('bad'); + } + } {1 {constraint failed}} + do_test func4-3.[incr i] { + catchsql { + INSERT INTO t1 (x) VALUES ('1234bad'); + } + } {1 {constraint failed}} + do_test func4-3.[incr i] { + catchsql { + INSERT INTO t1 (x) VALUES (1234); + } + } {0 {}} + do_test func4-3.[incr i] { + catchsql { + INSERT INTO t1 (x) VALUES (1234.56); + } + } {1 {constraint failed}} + do_test func4-3.[incr i] { + catchsql { + INSERT INTO t1 (x) VALUES ('1234'); + } + } {0 {}} + do_test func4-3.[incr i] { + catchsql { + INSERT INTO t1 (x) VALUES ('1234.56'); + } + } {1 {constraint failed}} + do_test func4-3.[incr i] { + catchsql { + INSERT INTO t1 (x) VALUES (ZEROBLOB(4)); + } + } {1 {constraint failed}} + do_test func4-3.[incr i] { + catchsql { + INSERT INTO t1 (x) VALUES (X''); + } + } {1 {constraint failed}} + do_test func4-3.[incr i] { + catchsql { + INSERT INTO t1 (x) VALUES (X'1234'); + } + } {1 {constraint failed}} + do_test func4-3.[incr i] { + catchsql { + INSERT INTO t1 (x) VALUES (X'12345678'); + } + } {1 {constraint failed}} + do_execsql_test func4-3.[incr i] { + SELECT x FROM t1 ORDER BY x; + } {1234 1234} +} + finish_test From ee1c64ed25e9f4823327f18bb7e36d4d796606d5 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 12 Mar 2013 09:07:25 +0000 Subject: [PATCH 03/42] Increase strictness of the new experimental functions and add more tests. FossilOrigin-Name: 05c4463ec5f36dde50f6eb116624dc40142f2c8c --- manifest | 16 ++++---- manifest.uuid | 2 +- src/func.c | 29 ++++++++++++- src/sqliteInt.h | 2 + test/func4.test | 105 +++++++++++++++++++++++++++++++++++++++++++----- 5 files changed, 134 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index 06b814fc57..645afb8d7e 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\smore\stests. -D 2013-03-11T06:24:46.255 +C Increase\sstrictness\sof\sthe\snew\sexperimental\sfunctions\sand\sadd\smore\stests. +D 2013-03-12T09:07:25.371 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -133,7 +133,7 @@ F src/delete.c aeabdabeeeaa0584127f291baa9617153d334778 F src/expr.c a23b4aac2a455b2e76b55bef5dcfbe62b665375c F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e16942bd5c8a868ac53287886464a5ed0e72b179 -F src/func.c 82dfd6b6744bd583cb52157ee1496af351ec9d49 +F src/func.c cdf7b604909be1feca6e928ceb4c511b79c085f3 F src/global.c e59ecd2c553ad0d4bfbc84ca71231336f8993a7a F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -179,7 +179,7 @@ F src/shell.c 7c41bfcd9e5bf9d96b9215f79b03a5b2b44a3bca F src/sqlite.h.in 31045976254225e6bf046a96e87b40fa4c1d55e4 F src/sqlite3.rc fea433eb0a59f4c9393c8e6d76a6e2596b1fe0c0 F src/sqlite3ext.h 7183ab832e23db0f934494f16928da127a571d75 -F src/sqliteInt.h 601c887f6d9c92e75551873c0a34711fff745bed +F src/sqliteInt.h 4d3c88acd03a6c480c52ad1324aecb8b4059a909 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c bedc37ec1a6bb9399944024d63f4c769971955a9 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -511,7 +511,7 @@ F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test b058483c17952eff7797b837bbb61e27e6b05606 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a -F test/func4.test 86f48cf1982a47001447a1924f5573d3c1e17ccf +F test/func4.test 161f051a028d8347cdf044ba84b3cb353980b01f F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 F test/fuzz.test 77fd50afc12847af50fcf1941679d90adebadde6 F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167 @@ -1038,7 +1038,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 465fd853d3e3544cb06b15ffa32ce25774d816c7 -R de601f18e2d7c1d69cbd21be32cf69bf +P f9468e334d6086b8a80c6a4204ec4e03fe59cf96 +R 4e552e5f44d1389ed4af9199ab9f91b5 U mistachkin -Z 349394d9a983439850a7e1f0ab403301 +Z 362f229b782fa4883f52597e4e59d3e0 diff --git a/manifest.uuid b/manifest.uuid index f4a06310b7..93772b155e 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f9468e334d6086b8a80c6a4204ec4e03fe59cf96 \ No newline at end of file +05c4463ec5f36dde50f6eb116624dc40142f2c8c \ No newline at end of file diff --git a/src/func.c b/src/func.c index c642e022fb..82eba542cf 100644 --- a/src/func.c +++ b/src/func.c @@ -19,6 +19,9 @@ #include "sqliteInt.h" #include #include +#ifndef SQLITE_OMIT_FLOATING_POINT +# include +#endif #include "vdbeInt.h" /* @@ -986,6 +989,19 @@ static void tointegerFunc( UNUSED_PARAMETER(argc); switch( sqlite3_value_type(argv[0]) ){ case SQLITE_FLOAT: +#ifndef SQLITE_OMIT_FLOATING_POINT + { + double rVal = sqlite3_value_double(argv[0]); + double rIntVal = 0.0; + if( !sqlite3IsNaN(rVal) && modf(rVal, &rIntVal)==0.0 && + rIntVal>=SMALLEST_INT64 && rIntVal<=LARGEST_INT64 ){ + sqlite3_result_int64(context, (i64)rIntVal); + return; + } + sqlite3_result_null(context); + break; + } +#endif case SQLITE_INTEGER: { sqlite3_result_int64(context, sqlite3_value_int64(argv[0])); break; @@ -1038,11 +1054,20 @@ static void todoubleFunc( assert( argc==1 ); UNUSED_PARAMETER(argc); switch( sqlite3_value_type(argv[0]) ){ - case SQLITE_FLOAT: - case SQLITE_INTEGER: { + case SQLITE_FLOAT: { sqlite3_result_double(context, sqlite3_value_double(argv[0])); break; } + case SQLITE_INTEGER: { + i64 iVal = sqlite3_value_int64(argv[0]); + double rVal = (double)iVal; + if( iVal==rVal ){ + sqlite3_result_double(context, rVal); + return; + } + sqlite3_result_null(context); + break; + } case SQLITE_BLOB: case SQLITE_TEXT: { const unsigned char *zStr = sqlite3_value_text(argv[0]); diff --git a/src/sqliteInt.h b/src/sqliteInt.h index a7c1f0e018..c5ac2f6acd 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -347,6 +347,8 @@ # define SQLITE_OMIT_TRACE 1 # undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT # undef SQLITE_HAVE_ISNAN +#else +# include #endif #ifndef SQLITE_BIG_DBL # define SQLITE_BIG_DBL (1e99) diff --git a/test/func4.test b/test/func4.test index 274b94520d..1ee67cd607 100644 --- a/test/func4.test +++ b/test/func4.test @@ -75,13 +75,13 @@ do_execsql_test func4-1.[incr i] { } {1} do_execsql_test func4-1.[incr i] { SELECT tointeger(-1.79769313486232e308 - 1); -} {-9223372036854775808} +} {{}} do_execsql_test func4-1.[incr i] { SELECT tointeger(-1.79769313486232e308); -} {-9223372036854775808} +} {{}} do_execsql_test func4-1.[incr i] { SELECT tointeger(-1.79769313486232e308 + 1); -} {-9223372036854775808} +} {{}} do_execsql_test func4-1.[incr i] { SELECT tointeger(-9223372036854775808 - 1); } {-9223372036854775808} @@ -120,13 +120,13 @@ do_execsql_test func4-1.[incr i] { } {-9223372036854775808} do_execsql_test func4-1.[incr i] { SELECT tointeger(1.79769313486232e308 - 1); -} {-9223372036854775808} +} {{}} do_execsql_test func4-1.[incr i] { SELECT tointeger(1.79769313486232e308); -} {-9223372036854775808} +} {{}} do_execsql_test func4-1.[incr i] { SELECT tointeger(1.79769313486232e308 + 1); -} {-9223372036854775808} +} {{}} do_execsql_test func4-1.[incr i] { SELECT tointeger(4503599627370496 - 1); } {4503599627370495} @@ -156,13 +156,13 @@ do_execsql_test func4-1.[incr i] { } {-9223372036854775808} do_execsql_test func4-1.[incr i] { SELECT tointeger(18446744073709551616 - 1); -} {-9223372036854775808} +} {{}} do_execsql_test func4-1.[incr i] { SELECT tointeger(18446744073709551616); -} {-9223372036854775808} +} {{}} do_execsql_test func4-1.[incr i] { SELECT tointeger(18446744073709551616 + 1); -} {-9223372036854775808} +} {{}} ifcapable floatingpoint { set i 0 @@ -347,6 +347,11 @@ ifcapable check { INSERT INTO t1 (x) VALUES ('1234bad'); } } {1 {constraint failed}} + do_test func4-3.[incr i] { + catchsql { + INSERT INTO t1 (x) VALUES ('1234.56bad'); + } + } {1 {constraint failed}} do_test func4-3.[incr i] { catchsql { INSERT INTO t1 (x) VALUES (1234); @@ -390,6 +395,88 @@ ifcapable check { do_execsql_test func4-3.[incr i] { SELECT x FROM t1 ORDER BY x; } {1234 1234} + + ifcapable floatingpoint { + set i 0 + do_execsql_test func4-4.[incr i] { + CREATE TABLE t2( + x REAL CHECK(todouble(x) IS NOT NULL) + ); + } {} + do_test func4-4.[incr i] { + catchsql { + INSERT INTO t2 (x) VALUES (NULL); + } + } {1 {constraint failed}} + do_test func4-4.[incr i] { + catchsql { + INSERT INTO t2 (x) VALUES (NULL); + } + } {1 {constraint failed}} + do_test func4-4.[incr i] { + catchsql { + INSERT INTO t2 (x) VALUES (''); + } + } {1 {constraint failed}} + do_test func4-4.[incr i] { + catchsql { + INSERT INTO t2 (x) VALUES ('bad'); + } + } {1 {constraint failed}} + do_test func4-4.[incr i] { + catchsql { + INSERT INTO t2 (x) VALUES ('1234bad'); + } + } {1 {constraint failed}} + do_test func4-4.[incr i] { + catchsql { + INSERT INTO t2 (x) VALUES ('1234.56bad'); + } + } {1 {constraint failed}} + do_test func4-4.[incr i] { + catchsql { + INSERT INTO t2 (x) VALUES (1234); + } + } {0 {}} + do_test func4-4.[incr i] { + catchsql { + INSERT INTO t2 (x) VALUES (1234.56); + } + } {0 {}} + do_test func4-4.[incr i] { + catchsql { + INSERT INTO t2 (x) VALUES ('1234'); + } + } {0 {}} + do_test func4-4.[incr i] { + catchsql { + INSERT INTO t2 (x) VALUES ('1234.56'); + } + } {0 {}} + do_test func4-4.[incr i] { + catchsql { + INSERT INTO t2 (x) VALUES (ZEROBLOB(4)); + } + } {1 {constraint failed}} + do_test func4-4.[incr i] { + catchsql { + INSERT INTO t2 (x) VALUES (X''); + } + } {1 {constraint failed}} + do_test func4-4.[incr i] { + catchsql { + INSERT INTO t2 (x) VALUES (X'1234'); + } + } {1 {constraint failed}} + do_test func4-4.[incr i] { + catchsql { + INSERT INTO t2 (x) VALUES (X'12345678'); + } + } {1 {constraint failed}} + do_execsql_test func4-4.[incr i] { + SELECT x FROM t2 ORDER BY x; + } {1234.0 1234.0 1234.56 1234.56} + } } finish_test From bc3ec28b885654d28add23a8552dfbc3ed28b467 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 13 Mar 2013 06:48:05 +0000 Subject: [PATCH 04/42] Rename the experimental todouble() function to toreal(), update comments. FossilOrigin-Name: 12c318ef1b674d1ef347458ce149398885f5ba10 --- manifest | 14 +++---- manifest.uuid | 2 +- src/func.c | 12 +++--- test/func4.test | 102 ++++++++++++++++++++++++------------------------ 4 files changed, 65 insertions(+), 65 deletions(-) diff --git a/manifest b/manifest index 645afb8d7e..088b73e209 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Increase\sstrictness\sof\sthe\snew\sexperimental\sfunctions\sand\sadd\smore\stests. -D 2013-03-12T09:07:25.371 +C Rename\sthe\sexperimental\stodouble()\sfunction\sto\storeal(),\supdate\scomments. +D 2013-03-13T06:48:05.170 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 9a804abbd3cae82d196e4d33aba13239e32522a5 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -133,7 +133,7 @@ F src/delete.c aeabdabeeeaa0584127f291baa9617153d334778 F src/expr.c a23b4aac2a455b2e76b55bef5dcfbe62b665375c F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c e16942bd5c8a868ac53287886464a5ed0e72b179 -F src/func.c cdf7b604909be1feca6e928ceb4c511b79c085f3 +F src/func.c d83c67a1d247389af7ad8a4c05b3665027658a17 F src/global.c e59ecd2c553ad0d4bfbc84ca71231336f8993a7a F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 2894c932d84d9f892d4b4023a75e501f83050970 @@ -511,7 +511,7 @@ F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test b058483c17952eff7797b837bbb61e27e6b05606 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a -F test/func4.test 161f051a028d8347cdf044ba84b3cb353980b01f +F test/func4.test cf09a622b456d3e2f33a3fb1a2be8eec7a8e35e2 F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 F test/fuzz.test 77fd50afc12847af50fcf1941679d90adebadde6 F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167 @@ -1038,7 +1038,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P f9468e334d6086b8a80c6a4204ec4e03fe59cf96 -R 4e552e5f44d1389ed4af9199ab9f91b5 +P 05c4463ec5f36dde50f6eb116624dc40142f2c8c +R 64196e5fa6ca1fac5ad547b6cea78dab U mistachkin -Z 362f229b782fa4883f52597e4e59d3e0 +Z b2ce5eefc524290638881e73eb677e9a diff --git a/manifest.uuid b/manifest.uuid index 93772b155e..e5f1e9fbe5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -05c4463ec5f36dde50f6eb116624dc40142f2c8c \ No newline at end of file +12c318ef1b674d1ef347458ce149398885f5ba10 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 82eba542cf..4f0760b371 100644 --- a/src/func.c +++ b/src/func.c @@ -970,11 +970,11 @@ static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ ** change. This function may disappear. Do not write code that depends ** on this function. ** -** Implementation of the TOINTEGER() function. This function takes a +** Implementation of the tointeger() function. This function takes a ** single argument. If the argument is an integer or is a double that ** can be losslessly converted to an integer, the return value is the ** same as the argument. If the argument is a double that cannot be -** losslessly represented as an integer, the return value is undefined. +** losslessly represented as an integer, the return value is NULL. ** If the argument is NULL, the return value is NULL. Otherwise, an ** attempt is made to convert the argument to an integer. If the ** conversion is successful, the integer value is returned; otherwise, @@ -1035,18 +1035,18 @@ static void tointegerFunc( ** change. This function may disappear. Do not write code that depends ** on this function. ** -** Implementation of the TODOUBLE() function. This function takes a +** Implementation of the toreal() function. This function takes a ** single argument. If the argument is a double or is an integer that ** can be losslessly converted to a double, the return value is the ** same as the argument. If the argument is an integer that cannot be -** losslessly represented as a double, the return value is undefined. +** losslessly represented as a double, the return value is NULL. ** If the argument is NULL, the return value is NULL. Otherwise, an ** attempt is made to convert the argument to a double. If the ** conversion is successful, the double value is returned; otherwise, ** NULL is returned. */ #ifndef SQLITE_OMIT_FLOATING_POINT -static void todoubleFunc( +static void torealFunc( sqlite3_context *context, int argc, sqlite3_value **argv @@ -1803,7 +1803,7 @@ void sqlite3RegisterGlobalFunctions(void){ FUNCTION(quote, 1, 0, 0, quoteFunc ), FUNCTION(tointeger, 1, 0, 0, tointegerFunc ), #ifndef SQLITE_OMIT_FLOATING_POINT - FUNCTION(todouble, 1, 0, 0, todoubleFunc ), + FUNCTION(toreal, 1, 0, 0, torealFunc ), #endif FUNCTION(last_insert_rowid, 0, 0, 0, last_insert_rowid), FUNCTION(changes, 0, 0, 0, changes ), diff --git a/test/func4.test b/test/func4.test index 1ee67cd607..44a275a486 100644 --- a/test/func4.test +++ b/test/func4.test @@ -9,7 +9,7 @@ # #*********************************************************************** # This file implements regression tests for SQLite library. The -# focus of this file is testing the TOINTEGER() and TODOUBLE() +# focus of this file is testing the tointeger() and toreal() # functions. # set testdir [file dirname $argv0] @@ -167,151 +167,151 @@ do_execsql_test func4-1.[incr i] { ifcapable floatingpoint { set i 0 do_execsql_test func4-2.[incr i] { - SELECT todouble(NULL); + SELECT toreal(NULL); } {{}} do_execsql_test func4-2.[incr i] { - SELECT todouble(''); + SELECT toreal(''); } {{}} do_execsql_test func4-2.[incr i] { - SELECT todouble(' '); + SELECT toreal(' '); } {{}} do_execsql_test func4-2.[incr i] { - SELECT todouble('1234'); + SELECT toreal('1234'); } {1234.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(' 1234'); + SELECT toreal(' 1234'); } {1234.0} do_execsql_test func4-2.[incr i] { - SELECT todouble('bad'); + SELECT toreal('bad'); } {{}} do_execsql_test func4-2.[incr i] { - SELECT todouble('0xBAD'); + SELECT toreal('0xBAD'); } {{}} do_execsql_test func4-2.[incr i] { - SELECT todouble('123BAD'); + SELECT toreal('123BAD'); } {{}} do_execsql_test func4-2.[incr i] { - SELECT todouble('0x123BAD'); + SELECT toreal('0x123BAD'); } {{}} do_execsql_test func4-2.[incr i] { - SELECT todouble('123NO'); + SELECT toreal('123NO'); } {{}} do_execsql_test func4-2.[incr i] { - SELECT todouble('0x123NO'); + SELECT toreal('0x123NO'); } {{}} do_execsql_test func4-2.[incr i] { - SELECT todouble('-0x1'); + SELECT toreal('-0x1'); } {{}} do_execsql_test func4-2.[incr i] { - SELECT todouble('-0x0'); + SELECT toreal('-0x0'); } {{}} do_execsql_test func4-2.[incr i] { - SELECT todouble('0x0'); + SELECT toreal('0x0'); } {{}} do_execsql_test func4-2.[incr i] { - SELECT todouble('0x1'); + SELECT toreal('0x1'); } {{}} do_execsql_test func4-2.[incr i] { - SELECT todouble(-1); + SELECT toreal(-1); } {-1.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(-0); + SELECT toreal(-0); } {0.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(0); + SELECT toreal(0); } {0.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(1); + SELECT toreal(1); } {1.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(-1.79769313486232e308 - 1); + SELECT toreal(-1.79769313486232e308 - 1); } {-Inf} do_execsql_test func4-2.[incr i] { - SELECT todouble(-1.79769313486232e308); + SELECT toreal(-1.79769313486232e308); } {-Inf} do_execsql_test func4-2.[incr i] { - SELECT todouble(-1.79769313486232e308 + 1); + SELECT toreal(-1.79769313486232e308 + 1); } {-Inf} do_execsql_test func4-2.[incr i] { - SELECT todouble(-9223372036854775808 - 1); + SELECT toreal(-9223372036854775808 - 1); } {-9.22337203685478e+18} do_execsql_test func4-2.[incr i] { - SELECT todouble(-9223372036854775808); + SELECT toreal(-9223372036854775808); } {-9.22337203685478e+18} do_execsql_test func4-2.[incr i] { - SELECT todouble(-9223372036854775808 + 1); + SELECT toreal(-9223372036854775808 + 1); } {-9.22337203685478e+18} do_execsql_test func4-2.[incr i] { - SELECT todouble(-2147483648 - 1); + SELECT toreal(-2147483648 - 1); } {-2147483649.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(-2147483648); + SELECT toreal(-2147483648); } {-2147483648.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(-2147483648 + 1); + SELECT toreal(-2147483648 + 1); } {-2147483647.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(2147483647 - 1); + SELECT toreal(2147483647 - 1); } {2147483646.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(2147483647); + SELECT toreal(2147483647); } {2147483647.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(2147483647 + 1); + SELECT toreal(2147483647 + 1); } {2147483648.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(9223372036854775807 - 1); + SELECT toreal(9223372036854775807 - 1); } {9.22337203685478e+18} do_execsql_test func4-2.[incr i] { - SELECT todouble(9223372036854775807); + SELECT toreal(9223372036854775807); } {9.22337203685478e+18} do_execsql_test func4-2.[incr i] { - SELECT todouble(9223372036854775807 + 1); + SELECT toreal(9223372036854775807 + 1); } {9.22337203685478e+18} do_execsql_test func4-2.[incr i] { - SELECT todouble(1.79769313486232e308 - 1); + SELECT toreal(1.79769313486232e308 - 1); } {Inf} do_execsql_test func4-2.[incr i] { - SELECT todouble(1.79769313486232e308); + SELECT toreal(1.79769313486232e308); } {Inf} do_execsql_test func4-2.[incr i] { - SELECT todouble(1.79769313486232e308 + 1); + SELECT toreal(1.79769313486232e308 + 1); } {Inf} do_execsql_test func4-2.[incr i] { - SELECT todouble(4503599627370496 - 1); + SELECT toreal(4503599627370496 - 1); } {4503599627370500.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(4503599627370496); + SELECT toreal(4503599627370496); } {4503599627370500.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(4503599627370496 + 1); + SELECT toreal(4503599627370496 + 1); } {4503599627370500.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(9007199254740992 - 1); + SELECT toreal(9007199254740992 - 1); } {9007199254740990.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(9007199254740992); + SELECT toreal(9007199254740992); } {9007199254740990.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(9007199254740992 + 1); + SELECT toreal(9007199254740992 + 1); } {9007199254740990.0} do_execsql_test func4-2.[incr i] { - SELECT todouble(9223372036854775808 - 1); + SELECT toreal(9223372036854775808 - 1); } {9.22337203685478e+18} do_execsql_test func4-2.[incr i] { - SELECT todouble(9223372036854775808); + SELECT toreal(9223372036854775808); } {9.22337203685478e+18} do_execsql_test func4-2.[incr i] { - SELECT todouble(9223372036854775808 + 1); + SELECT toreal(9223372036854775808 + 1); } {9.22337203685478e+18} do_execsql_test func4-2.[incr i] { - SELECT todouble(18446744073709551616 - 1); + SELECT toreal(18446744073709551616 - 1); } {1.84467440737096e+19} do_execsql_test func4-2.[incr i] { - SELECT todouble(18446744073709551616); + SELECT toreal(18446744073709551616); } {1.84467440737096e+19} do_execsql_test func4-2.[incr i] { - SELECT todouble(18446744073709551616 + 1); + SELECT toreal(18446744073709551616 + 1); } {1.84467440737096e+19} } @@ -400,7 +400,7 @@ ifcapable check { set i 0 do_execsql_test func4-4.[incr i] { CREATE TABLE t2( - x REAL CHECK(todouble(x) IS NOT NULL) + x REAL CHECK(toreal(x) IS NOT NULL) ); } {} do_test func4-4.[incr i] { From f13394c0ad5b02e9ff7c93c2e4a1f4b95b01800a Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 11 Apr 2013 00:13:46 +0000 Subject: [PATCH 05/42] Experimental changes to support a Win32 VSIX package flavor. FossilOrigin-Name: abedd7cb454aab99b62b63ed4fdd70c31ef87b0b --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- tool/mkvsix.tcl | 12 +++++++++++- tool/win/sqlite.vsix | Bin 32816 -> 32815 bytes 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 6d3e751585..58b0335339 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Enhance\smulti-process\stester\sintegration\swith\sthe\sWin32\sAPI. -D 2013-04-11T00:09:44.820 +C Experimental\schanges\sto\ssupport\sa\sWin32\sVSIX\spackage\sflavor. +D 2013-04-11T00:13:46.757 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 3dd3fcb87b70c78d99b2c8a03e44ec86d6ca9ce2 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1024,7 +1024,7 @@ F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02 F tool/mksqlite3c.tcl a570a0b0847f5659482087f70e409ac45ce93b91 F tool/mksqlite3h.tcl ba24038056f51fde07c0079c41885ab85e2cff12 F tool/mksqlite3internalh.tcl 3dca7bb5374cee003379b8cbac73714f610ef795 -F tool/mkvsix.tcl 0be7f7a591f1e83f9199cb82911b66668ca484c9 +F tool/mkvsix.tcl 7d6b5c45521f1422bca980f13c08fc0226ecd8aa F tool/offsets.c fe4262fdfa378e8f5499a42136d17bf3b98f6091 F tool/omittest.tcl 4665982e95a6e5c1bd806cf7bc3dea95be422d77 F tool/opcodeDoc.awk b3a2a3d5d3075b8bd90b7afe24283efdd586659c @@ -1049,8 +1049,11 @@ F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 -F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P be7d2c5482c41baf000d7fb5dccc31b974e91064 -R 255ee63faf4906e3f01e118bd1c7af53 +F tool/win/sqlite.vsix 1cf37bf79e04fc4030f7a5acf1de64d6162e9a23 +P 0fdc743583c67a3a017b9ad812c62a5104b9aee7 +R f5ec6eca1c57a0969247b9c441fad8c1 +T *branch * vsixWin32 +T *sym-vsixWin32 * +T -sym-trunk * U mistachkin -Z 56dc3349791505b3e20ff09949e0bcd7 +Z 6f9112a4a88191e1094322a991d7d8e6 diff --git a/manifest.uuid b/manifest.uuid index 557333d3d0..79c87cb330 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -0fdc743583c67a3a017b9ad812c62a5104b9aee7 \ No newline at end of file +abedd7cb454aab99b62b63ed4fdd70c31ef87b0b \ No newline at end of file diff --git a/tool/mkvsix.tcl b/tool/mkvsix.tcl index e9f1f818da..48602a308e 100644 --- a/tool/mkvsix.tcl +++ b/tool/mkvsix.tcl @@ -255,6 +255,7 @@ if {[string equal -nocase $packageFlavor WinRT]} then { set shortName SQLite.WinRT set displayName "SQLite for Windows Runtime" set targetPlatformIdentifier Windows + set targetPlatformVersion v8.0 set extraSdkPath "" set extraFileListAttributes [appendArgs \ "\r\n " {AppliesTo="WindowsAppContainer"} \ @@ -263,10 +264,19 @@ if {[string equal -nocase $packageFlavor WinRT]} then { set shortName SQLite.WP80 set displayName "SQLite for Windows Phone" set targetPlatformIdentifier "Windows Phone" + set targetPlatformVersion v8.0 set extraSdkPath "\\..\\$targetPlatformIdentifier" set extraFileListAttributes "" +} elseif {[string equal -nocase $packageFlavor Win32]} then { + set shortName SQLite.Win32 + set displayName "SQLite for Windows" + set targetPlatformIdentifier Windows + set targetPlatformVersion v8.0 + set extraSdkPath "" + set extraFileListAttributes [appendArgs \ + "\r\n " {AppliesTo="VisualC"}] } else { - fail "unsupported package flavor, must be \"WinRT\" or \"WP80\"" + fail "unsupported package flavor, must be \"WinRT\", \"WP80\", or \"Win32\"" } if {$argc >= 4} then { diff --git a/tool/win/sqlite.vsix b/tool/win/sqlite.vsix index 93eefac2dbbd9da8a901fc215cc94629002b5723..9eeb80719897363a2375e7c90217cd891ee882eb 100644 GIT binary patch delta 668 zcmV;N0%QHKfC8_80FB)v6Pg_+u>up78VOvq+61DBniKSnkM;~!@ae0~KpFaU)V zoFnB559Ra~-Xf7Q^^~L|EN>U8#C$iO)oPXcKbnh9t*b?83!gUB>P);3+IRc|H8SSC zCG;l}x#*&8EgpYcW#G|wY=pytuh|6o6gOaxn8 zWO1~~0o{0#T5qQb*IGaDz?m!L7MQ@aupMvgt+sQiBN5(&%%rQ4wj>zu`Sf*7+#p-0 zH{TM7E)({ztZO50DupiagHG69--aD=iat0paKN;D4jlN8jZys}A;s=Gj=PDfYwwZb zZS@k&HXWXBaU!W1CVcFlpp>7S1H?XICf+<%tosMECI!BD4YaO_LYu9ZYDEG70KSv) zeK!X)2*O>bHO`YSememrlWTri0b-NIep~@4lOlgy0sE7Ge_#Owli+_!1`2!t0001^ C7&|)v delta 669 zcmV;O0%HBIfC8|90#v6FSp#TI`*Qsk#>iup5EG(jy(atuGnI%)JUxk@k6iv%`}(r%d4 z%uxoJc}D^jKT2nW944gCA7%+mmkT9bO?H^fzTHVCxQQh+ zJ~7M*n*>CMb|YP@a2o(dXD`J;ddDvTiLRQ9_^D$2MD3tHCh5C7Z&XnxJCxq zw2A`i&V^KYo*T_5H5CIdTi=8t=LYbHtO>SKR!e`2A^QN>qIQ@E0Tp;K2)DFAM?kvr zIZ|KYp`5P5TVj^FnlW0Y;&v$u8tvz^UawR4Tlu0>V=GaZ+@&=)Dii+)^&NjFMIQ6s zFu4RV2cjkU83lct?Us&!;aN_6>UL z?B;6%(PirWOJkeJn^KYu{NNL|*SBFkr&c+i0;6ZebJ+KPnYUBFOFpr0{kZa|x^|8@ z-b^RKeB09LcBaVnF!9Ikxk>%=a)9U)X5!7WDU%_8Tmk%(et%#A1(V-@N(Kvj00000 D&x1Xt From 749ced9923571c73f3b965b4143bd924375e280a Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 19 Aug 2013 22:22:41 +0000 Subject: [PATCH 06/42] Additional performance improvements in sqlite3BtreeNext() and sqlite3BtreePrevious(). FossilOrigin-Name: 6f99b54aedeb91e46d52f65504d02a9cc61c0062 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/btree.c | 36 +++++++++++++++++++++++------------- src/btreeInt.h | 16 +++++++++++----- 4 files changed, 43 insertions(+), 27 deletions(-) diff --git a/manifest b/manifest index 3a55a00463..58a5caee72 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stointeger()\sand\storeal()\sSQL\sfunctions. -D 2013-08-19T21:15:34.654 +C Additional\sperformance\simprovements\sin\ssqlite3BtreeNext()\sand\nsqlite3BtreePrevious(). +D 2013-08-19T22:22:41.690 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -163,9 +163,9 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 43b348822db3e4cef48b2ae5a445fbeb6c73a165 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c 78287b3012fe65fd5e38927d40c01e01a783e016 +F src/btree.c d8cb52cddfe575d91b90d056d91607259f78706b F src/btree.h bfe0e8c5759b4ec77b0d18390064a6ef3cdffaaf -F src/btreeInt.h eecc84f02375b2bb7a44abbcbbe3747dde73edb2 +F src/btreeInt.h 51cf220a9b9223354770883e93a859dc377aa27f F src/build.c f99a715ff9290996b579d5e1ec8e94239dc9ae5e F src/callback.c d7e46f40c3cf53c43550b7da7a1d0479910b62cc F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac @@ -1106,7 +1106,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P dc65ad8c4c67b21e3b042b8df6580d02b634a90b dd4b77c82af07bdcc92ed743f050e70887e5956e -R e3fb50f27097137963de60af3dbc18b8 -U mistachkin -Z 2bb7e5e3c9622cb177c0d8f0e5a92db1 +P af49707211ff7c7c4d30f4f457631ea8a9fa39eb +R d86e9a19461f588d02ed145ef81cfebb +U drh +Z 1181ebcd03ded8a6c716b64a93881e5c diff --git a/manifest.uuid b/manifest.uuid index 7dd17e4566..10a6d51396 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -af49707211ff7c7c4d30f4f457631ea8a9fa39eb \ No newline at end of file +6f99b54aedeb91e46d52f65504d02a9cc61c0062 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index bf679cd1f7..d3db676526 100644 --- a/src/btree.c +++ b/src/btree.c @@ -724,6 +724,9 @@ static int btreeRestoreCursorPosition(BtCursor *pCur){ sqlite3_free(pCur->pKey); pCur->pKey = 0; assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID ); + if( pCur->skipNext && pCur->eState==CURSOR_VALID ){ + pCur->eState = CURSOR_SKIPNEXT; + } } return rc; } @@ -749,7 +752,7 @@ int sqlite3BtreeCursorHasMoved(BtCursor *pCur, int *pHasMoved){ *pHasMoved = 1; return rc; } - if( pCur->eState!=CURSOR_VALID || pCur->skipNext!=0 ){ + if( pCur->eState!=CURSOR_VALID || NEVER(pCur->skipNext!=0) ){ *pHasMoved = 1; }else{ *pHasMoved = 0; @@ -4797,6 +4800,7 @@ int sqlite3BtreeNext(BtCursor *pCur, int *pRes){ assert( cursorHoldsMutex(pCur) ); assert( pRes!=0 ); + assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID ); if( pCur->eState!=CURSOR_VALID ){ rc = restoreCursorPosition(pCur); if( rc!=SQLITE_OK ){ @@ -4806,14 +4810,16 @@ int sqlite3BtreeNext(BtCursor *pCur, int *pRes){ *pRes = 1; return SQLITE_OK; } - } - if( pCur->skipNext ){ - if( pCur->skipNext>0 ){ + if( pCur->skipNext ){ + assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT ); + pCur->eState = CURSOR_VALID; + if( pCur->skipNext>0 ){ + pCur->skipNext = 0; + *pRes = 0; + return SQLITE_OK; + } pCur->skipNext = 0; - *pRes = 0; - return SQLITE_OK; } - pCur->skipNext = 0; } pPage = pCur->apPage[pCur->iPage]; @@ -4874,6 +4880,8 @@ int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){ MemPage *pPage; assert( cursorHoldsMutex(pCur) ); + assert( pRes!=0 ); + assert( pCur->skipNext==0 || pCur->eState!=CURSOR_VALID ); pCur->atLast = 0; if( pCur->eState!=CURSOR_VALID ){ if( ALWAYS(pCur->eState>=CURSOR_REQUIRESEEK) ){ @@ -4884,14 +4892,16 @@ int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){ *pRes = 1; return SQLITE_OK; } - } - if( pCur->skipNext ){ - if( pCur->skipNext<0 ){ + if( pCur->skipNext ){ + assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_SKIPNEXT ); + pCur->eState = CURSOR_VALID; + if( pCur->skipNext<0 ){ + pCur->skipNext = 0; + *pRes = 0; + return SQLITE_OK; + } pCur->skipNext = 0; - *pRes = 0; - return SQLITE_OK; } - pCur->skipNext = 0; } pPage = pCur->apPage[pCur->iPage]; diff --git a/src/btreeInt.h b/src/btreeInt.h index ce3c5493f8..60da24d90c 100644 --- a/src/btreeInt.h +++ b/src/btreeInt.h @@ -520,14 +520,19 @@ struct BtCursor { /* ** Potential values for BtCursor.eState. ** -** CURSOR_VALID: -** Cursor points to a valid entry. getPayload() etc. may be called. -** ** CURSOR_INVALID: ** Cursor does not point to a valid entry. This can happen (for example) ** because the table is empty or because BtreeCursorFirst() has not been ** called. ** +** CURSOR_VALID: +** Cursor points to a valid entry. getPayload() etc. may be called. +** +** CURSOR_SKIPNEXT: +** Cursor is valid except that the Cursor.skipNext field is non-zero +** indicating that the next sqlite3BtreeNext() or sqlite3BtreePrevious() +** operation should be a no-op. +** ** CURSOR_REQUIRESEEK: ** The table that this cursor was opened on still exists, but has been ** modified since the cursor was last used. The cursor position is saved @@ -544,8 +549,9 @@ struct BtCursor { */ #define CURSOR_INVALID 0 #define CURSOR_VALID 1 -#define CURSOR_REQUIRESEEK 2 -#define CURSOR_FAULT 3 +#define CURSOR_SKIPNEXT 2 +#define CURSOR_REQUIRESEEK 3 +#define CURSOR_FAULT 4 /* ** The database page the PENDING_BYTE occupies. This page is never used. From 5805eedb879ca4c245eb5a70fb33d2251d7b3a48 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 19 Aug 2013 23:18:12 +0000 Subject: [PATCH 07/42] Performance improvement to SQL function calls in the VDBE. FossilOrigin-Name: d2efea1682a7e708000c1f5d36370aaf1199b3be --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/vdbe.c | 16 +++++++--------- src/vdbeInt.h | 7 ++++--- src/vdbeapi.c | 9 +++++++++ 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/manifest b/manifest index 58a5caee72..13d108d3d2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\sperformance\simprovements\sin\ssqlite3BtreeNext()\sand\nsqlite3BtreePrevious(). -D 2013-08-19T22:22:41.690 +C Performance\simprovement\sto\sSQL\sfunction\scalls\sin\sthe\sVDBE. +D 2013-08-19T23:18:12.597 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -277,10 +277,10 @@ F src/update.c 7f3fe64d8f3b44c44a1eac293f0f85f87c355b7a F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f F src/util.c f566b5138099a2df8533b190d0dcc74b7dfbe0c9 F src/vacuum.c d9c5759f4c5a438bb43c2086f72c5d2edabc36c8 -F src/vdbe.c 0fbe7a904a1187dc6c8a2dbe2f594f0ce8d01401 +F src/vdbe.c 54d28e7fbea2215998f8e12fcb0ddb15fadc5b14 F src/vdbe.h 4f554b5627f26710c4c36d919110a3fc611ca5c4 -F src/vdbeInt.h e9b7c6b165a31a4715c5aa97223d20d265515231 -F src/vdbeapi.c 4d13580bd058b39623e8fcfc233b7df4b8191e8b +F src/vdbeInt.h 6931139cefc2f01f8612b771a31d96d06b1a6860 +F src/vdbeapi.c a183f0daa22374427bd4cf3f18a6261aac141f5a F src/vdbeaux.c a6ea36a9dc714e1128a0173249a0532ddcab0489 F src/vdbeblob.c 5dc79627775bd9a9b494dd956e26297946417d69 F src/vdbemem.c 833005f1cbbf447289f1973dba2a0c2228c7b8ab @@ -1106,7 +1106,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P af49707211ff7c7c4d30f4f457631ea8a9fa39eb -R d86e9a19461f588d02ed145ef81cfebb +P 6f99b54aedeb91e46d52f65504d02a9cc61c0062 +R a4ebd23f8bd1f91badaa0be999a387b9 U drh -Z 1181ebcd03ded8a6c716b64a93881e5c +Z 07c571cc9e32147d1ee20914dbc33fe8 diff --git a/manifest.uuid b/manifest.uuid index 10a6d51396..cd5dd5dbfe 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -6f99b54aedeb91e46d52f65504d02a9cc61c0062 \ No newline at end of file +d2efea1682a7e708000c1f5d36370aaf1199b3be \ No newline at end of file diff --git a/src/vdbe.c b/src/vdbe.c index 4bd26b377c..716c7127fd 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -1449,7 +1449,7 @@ case OP_Function: { sqlite3VdbeMemMove(&ctx.s, pOut); MemSetTypeFlag(&ctx.s, MEM_Null); - ctx.isError = 0; + ctx.fErrorOrAux = 0; if( ctx.pFunc->flags & SQLITE_FUNC_NEEDCOLL ){ assert( pOp>aOp ); assert( pOp[-1].p4type==P4_COLLSEQ ); @@ -1460,11 +1460,6 @@ case OP_Function: { (*ctx.pFunc->xFunc)(&ctx, n, apVal); /* IMP: R-24505-23230 */ lastRowid = db->lastRowid; - /* If any auxiliary data functions have been called by this user function, - ** immediately call the destructor for any non-static values. - */ - sqlite3VdbeDeleteAuxData(p, pc, pOp->p1); - if( db->mallocFailed ){ /* Even though a malloc() has failed, the implementation of the ** user function may have called an sqlite3_result_XXX() function @@ -1476,9 +1471,12 @@ case OP_Function: { } /* If the function returned an error, throw an exception */ - if( ctx.isError ){ - sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&ctx.s)); - rc = ctx.isError; + if( ctx.fErrorOrAux ){ + if( ctx.isError ){ + sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&ctx.s)); + rc = ctx.isError; + } + sqlite3VdbeDeleteAuxData(p, pc, pOp->p1); } /* Copy the result of the function into register P3 */ diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 9ee82b4ea0..1003d8465c 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -266,10 +266,11 @@ struct sqlite3_context { Mem s; /* The return value is stored here */ Mem *pMem; /* Memory cell used to store aggregate context */ CollSeq *pColl; /* Collating sequence */ - int isError; /* Error code returned by the function. */ - int skipFlag; /* Skip skip accumulator loading if true */ - int iOp; /* Instruction number of OP_Function */ Vdbe *pVdbe; /* The VM that owns this context */ + int iOp; /* Instruction number of OP_Function */ + int isError; /* Error code returned by the function. */ + u8 skipFlag; /* Skip skip accumulator loading if true */ + u8 fErrorOrAux; /* isError!=0 or pVdbe->pAuxData modified */ }; /* diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 7c9db9beec..178129d34e 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -211,12 +211,14 @@ void sqlite3_result_double(sqlite3_context *pCtx, double rVal){ void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){ assert( sqlite3_mutex_held(pCtx->s.db->mutex) ); pCtx->isError = SQLITE_ERROR; + pCtx->fErrorOrAux = 1; sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF8, SQLITE_TRANSIENT); } #ifndef SQLITE_OMIT_UTF16 void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){ assert( sqlite3_mutex_held(pCtx->s.db->mutex) ); pCtx->isError = SQLITE_ERROR; + pCtx->fErrorOrAux = 1; sqlite3VdbeMemSetStr(&pCtx->s, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT); } #endif @@ -280,6 +282,7 @@ void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){ } void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ pCtx->isError = errCode; + pCtx->fErrorOrAux = 1; if( pCtx->s.flags & MEM_Null ){ sqlite3VdbeMemSetStr(&pCtx->s, sqlite3ErrStr(errCode), -1, SQLITE_UTF8, SQLITE_STATIC); @@ -290,6 +293,7 @@ void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){ void sqlite3_result_error_toobig(sqlite3_context *pCtx){ assert( sqlite3_mutex_held(pCtx->s.db->mutex) ); pCtx->isError = SQLITE_TOOBIG; + pCtx->fErrorOrAux = 1; sqlite3VdbeMemSetStr(&pCtx->s, "string or blob too big", -1, SQLITE_UTF8, SQLITE_STATIC); } @@ -299,6 +303,7 @@ void sqlite3_result_error_nomem(sqlite3_context *pCtx){ assert( sqlite3_mutex_held(pCtx->s.db->mutex) ); sqlite3VdbeMemSetNull(&pCtx->s); pCtx->isError = SQLITE_NOMEM; + pCtx->fErrorOrAux = 1; pCtx->s.db->mallocFailed = 1; } @@ -621,6 +626,10 @@ void sqlite3_set_auxdata( pAuxData->iArg = iArg; pAuxData->pNext = pVdbe->pAuxData; pVdbe->pAuxData = pAuxData; + if( pCtx->fErrorOrAux==0 ){ + pCtx->isError = 0; + pCtx->fErrorOrAux = 1; + } }else if( pAuxData->xDelete ){ pAuxData->xDelete(pAuxData->pAux); } From 36df58e45ff90c997e6901c8bf18ddd83882d66c Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 20 Aug 2013 00:42:11 +0000 Subject: [PATCH 08/42] Performance optimizations in the VDBE and especially to the OP_Next and related opcodes. FossilOrigin-Name: d78c5d89de4b840351b026c9db1952fc24e689d0 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/btree.c | 12 ++++++++++-- src/vdbe.c | 18 +++++++++--------- src/vdbeInt.h | 2 +- src/vdbeapi.c | 6 +++--- 6 files changed, 33 insertions(+), 25 deletions(-) diff --git a/manifest b/manifest index 13d108d3d2..eb143f76a4 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\simprovement\sto\sSQL\sfunction\scalls\sin\sthe\sVDBE. -D 2013-08-19T23:18:12.597 +C Performance\soptimizations\sin\sthe\sVDBE\sand\sespecially\sto\sthe\sOP_Next\sand\nrelated\sopcodes. +D 2013-08-20T00:42:11.120 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -163,7 +163,7 @@ F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 43b348822db3e4cef48b2ae5a445fbeb6c73a165 F src/bitvec.c 19a4ba637bd85f8f63fc8c9bae5ade9fb05ec1cb F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 -F src/btree.c d8cb52cddfe575d91b90d056d91607259f78706b +F src/btree.c adea13e65d6c7b969bcd74cea6ae79b2d3c393fa F src/btree.h bfe0e8c5759b4ec77b0d18390064a6ef3cdffaaf F src/btreeInt.h 51cf220a9b9223354770883e93a859dc377aa27f F src/build.c f99a715ff9290996b579d5e1ec8e94239dc9ae5e @@ -277,10 +277,10 @@ F src/update.c 7f3fe64d8f3b44c44a1eac293f0f85f87c355b7a F src/utf.c 8d819e2e5104a430fc2005f018db14347c95a38f F src/util.c f566b5138099a2df8533b190d0dcc74b7dfbe0c9 F src/vacuum.c d9c5759f4c5a438bb43c2086f72c5d2edabc36c8 -F src/vdbe.c 54d28e7fbea2215998f8e12fcb0ddb15fadc5b14 +F src/vdbe.c 938feb53407dee2234849aad0f103ae9b941595e F src/vdbe.h 4f554b5627f26710c4c36d919110a3fc611ca5c4 -F src/vdbeInt.h 6931139cefc2f01f8612b771a31d96d06b1a6860 -F src/vdbeapi.c a183f0daa22374427bd4cf3f18a6261aac141f5a +F src/vdbeInt.h cbe71b8b36d8b3bba5709cc3f436c7e3b47b7b08 +F src/vdbeapi.c 96b24b946cf21894f63d9393e821baa2f0a80979 F src/vdbeaux.c a6ea36a9dc714e1128a0173249a0532ddcab0489 F src/vdbeblob.c 5dc79627775bd9a9b494dd956e26297946417d69 F src/vdbemem.c 833005f1cbbf447289f1973dba2a0c2228c7b8ab @@ -1106,7 +1106,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 6f99b54aedeb91e46d52f65504d02a9cc61c0062 -R a4ebd23f8bd1f91badaa0be999a387b9 +P d2efea1682a7e708000c1f5d36370aaf1199b3be +R 08cd0ad5f78761d7e8cb97606228a179 U drh -Z 07c571cc9e32147d1ee20914dbc33fe8 +Z 1caed0652391fde507351b876419455b diff --git a/manifest.uuid b/manifest.uuid index cd5dd5dbfe..fd7914b709 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d2efea1682a7e708000c1f5d36370aaf1199b3be \ No newline at end of file +d78c5d89de4b840351b026c9db1952fc24e689d0 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index d3db676526..27f9f412fb 100644 --- a/src/btree.c +++ b/src/btree.c @@ -4804,6 +4804,7 @@ int sqlite3BtreeNext(BtCursor *pCur, int *pRes){ if( pCur->eState!=CURSOR_VALID ){ rc = restoreCursorPosition(pCur); if( rc!=SQLITE_OK ){ + *pRes = 0; return rc; } if( CURSOR_INVALID==pCur->eState ){ @@ -4838,7 +4839,10 @@ int sqlite3BtreeNext(BtCursor *pCur, int *pRes){ if( idx>=pPage->nCell ){ if( !pPage->leaf ){ rc = moveToChild(pCur, get4byte(&pPage->aData[pPage->hdrOffset+8])); - if( rc ) return rc; + if( rc ){ + *pRes = 0; + return rc; + } rc = moveToLeftmost(pCur); *pRes = 0; return rc; @@ -4886,7 +4890,10 @@ int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){ if( pCur->eState!=CURSOR_VALID ){ if( ALWAYS(pCur->eState>=CURSOR_REQUIRESEEK) ){ rc = btreeRestoreCursorPosition(pCur); - if( rc!=SQLITE_OK ) return rc; + if( rc!=SQLITE_OK ){ + *pRes = 0; + return rc; + } } if( CURSOR_INVALID==pCur->eState ){ *pRes = 1; @@ -4910,6 +4917,7 @@ int sqlite3BtreePrevious(BtCursor *pCur, int *pRes){ int idx = pCur->aiIdx[pCur->iPage]; rc = moveToChild(pCur, get4byte(findCell(pPage, idx))); if( rc ){ + *pRes = 0; return rc; } rc = moveToRightmost(pCur); diff --git a/src/vdbe.c b/src/vdbe.c index 716c7127fd..516e8ae9b4 100644 --- a/src/vdbe.c +++ b/src/vdbe.c @@ -588,7 +588,7 @@ int sqlite3VdbeExec( #ifndef SQLITE_OMIT_PROGRESS_CALLBACK if( db->xProgress ){ assert( 0 < db->nProgressOps ); - nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1]; + nProgressLimit = (unsigned)p->aCounter[SQLITE_STMTSTATUS_VM_STEP]; if( nProgressLimit==0 ){ nProgressLimit = db->nProgressOps; }else{ @@ -1848,12 +1848,12 @@ case OP_Ge: { /* same as TK_GE, jump, in1, in3 */ ** then the result is always NULL. ** The jump is taken if the SQLITE_JUMPIFNULL bit is set. */ - if( pOp->p5 & SQLITE_STOREP2 ){ + if( pOp->p5 & SQLITE_JUMPIFNULL ){ + pc = pOp->p2-1; + }else if( pOp->p5 & SQLITE_STOREP2 ){ pOut = &aMem[pOp->p2]; MemSetTypeFlag(pOut, MEM_Null); REGISTER_TRACE(pOp->p2, pOut); - }else if( pOp->p5 & SQLITE_JUMPIFNULL ){ - pc = pOp->p2-1; } break; } @@ -4438,7 +4438,7 @@ case OP_Sort: { /* jump */ sqlite3_sort_count++; sqlite3_search_count--; #endif - p->aCounter[SQLITE_STMTSTATUS_SORT-1]++; + p->aCounter[SQLITE_STMTSTATUS_SORT]++; /* Fall through into OP_Rewind */ } /* Opcode: Rewind P1 P2 * * * @@ -4517,7 +4517,7 @@ case OP_Next: { /* jump */ int res; assert( pOp->p1>=0 && pOp->p1nCursor ); - assert( pOp->p5<=ArraySize(p->aCounter) ); + assert( pOp->p5aCounter) ); pC = p->apCsr[pOp->p1]; if( pC==0 ){ break; /* See ticket #2273 */ @@ -4527,7 +4527,7 @@ case OP_Next: { /* jump */ assert( pOp->opcode==OP_SorterNext ); rc = sqlite3VdbeSorterNext(db, pC, &res); }else{ - res = 1; + /* res = 1; // Always initialized by the xAdvance() call */ assert( pC->deferredMoveto==0 ); assert( pC->pCursor ); assert( pOp->opcode!=OP_Next || pOp->p4.xAdvance==sqlite3BtreeNext ); @@ -4538,7 +4538,7 @@ case OP_Next: { /* jump */ pC->cacheStatus = CACHE_STALE; if( res==0 ){ pc = pOp->p2 - 1; - if( pOp->p5 ) p->aCounter[pOp->p5-1]++; + p->aCounter[pOp->p5]++; #ifdef SQLITE_TEST sqlite3_search_count++; #endif @@ -6241,7 +6241,7 @@ vdbe_error_halt: vdbe_return: db->lastRowid = lastRowid; testcase( nVmStep>0 ); - p->aCounter[SQLITE_STMTSTATUS_VM_STEP-1] += (int)nVmStep; + p->aCounter[SQLITE_STMTSTATUS_VM_STEP] += (int)nVmStep; sqlite3VdbeLeave(p); return rc; diff --git a/src/vdbeInt.h b/src/vdbeInt.h index 1003d8465c..a699c414b0 100644 --- a/src/vdbeInt.h +++ b/src/vdbeInt.h @@ -346,7 +346,7 @@ struct Vdbe { yDbMask btreeMask; /* Bitmask of db->aDb[] entries referenced */ yDbMask lockMask; /* Subset of btreeMask that requires a lock */ int iStatement; /* Statement number (or 0 if has not opened stmt) */ - int aCounter[4]; /* Counters used by sqlite3_stmt_status() */ + u32 aCounter[5]; /* Counters used by sqlite3_stmt_status() */ #ifndef SQLITE_OMIT_TRACE i64 startTime; /* Time when query started - used for profiling */ #endif diff --git a/src/vdbeapi.c b/src/vdbeapi.c index 178129d34e..52c6b2a797 100644 --- a/src/vdbeapi.c +++ b/src/vdbeapi.c @@ -1298,7 +1298,7 @@ sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){ */ int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){ Vdbe *pVdbe = (Vdbe*)pStmt; - int v = pVdbe->aCounter[op-1]; - if( resetFlag ) pVdbe->aCounter[op-1] = 0; - return v; + u32 v = pVdbe->aCounter[op]; + if( resetFlag ) pVdbe->aCounter[op] = 0; + return (int)v; } From db1c12b79fee0335ee72f81e3da972b8f5fc942a Mon Sep 17 00:00:00 2001 From: drh Date: Tue, 20 Aug 2013 02:07:50 +0000 Subject: [PATCH 09/42] Fix compiler warnings and boundary cases for the tointeger() and toreal() functions. FossilOrigin-Name: 4438b9865826446721b7aa09295fe335bf2fafb7 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/func.c | 16 ++++++---------- 3 files changed, 13 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index eb143f76a4..4d99f3c10c 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Performance\soptimizations\sin\sthe\sVDBE\sand\sespecially\sto\sthe\sOP_Next\sand\nrelated\sopcodes. -D 2013-08-20T00:42:11.120 +C Fix\scompiler\swarnings\sand\sboundary\scases\sfor\sthe\stointeger()\sand\storeal()\nfunctions. +D 2013-08-20T02:07:50.845 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/delete.c 2317c814866d9aa71fea16b3faf4fdd4d6a49b94 F src/expr.c 42d8235af422661ab80be097bebca485b33e2e14 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 914a6bbd987d857c41ac9d244efa6641f36faadb -F src/func.c 835168be942c8c18a6c6b3b78462bc378d25c7b4 +F src/func.c 03a79c7a2ae5535c36157d7f5823883c5d0179b1 F src/global.c 5caf4deab621abb45b4c607aad1bd21c20aac759 F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 @@ -1106,7 +1106,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P d2efea1682a7e708000c1f5d36370aaf1199b3be -R 08cd0ad5f78761d7e8cb97606228a179 +P d78c5d89de4b840351b026c9db1952fc24e689d0 +R f40049688c2f823d8e8fd7e09d988578 U drh -Z 1caed0652391fde507351b876419455b +Z 180da4560f629509c84cc64c4a342242 diff --git a/manifest.uuid b/manifest.uuid index fd7914b709..b43e0cae13 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -d78c5d89de4b840351b026c9db1952fc24e689d0 \ No newline at end of file +4438b9865826446721b7aa09295fe335bf2fafb7 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 995f104260..81f75851f7 100644 --- a/src/func.c +++ b/src/func.c @@ -981,7 +981,7 @@ static void tointegerFunc( case SQLITE_FLOAT: { double rVal = sqlite3_value_double(argv[0]); i64 iVal = (i64)rVal; - if( !sqlite3IsNaN(rVal) && rVal==(double)iVal ){ + if( rVal==(double)iVal ){ sqlite3_result_int64(context, iVal); } break; @@ -995,9 +995,9 @@ static void tointegerFunc( const unsigned char *zStr = sqlite3_value_text(argv[0]); if( zStr ){ int nStr = sqlite3_value_bytes(argv[0]); - if( nStr ){ + if( nStr && !sqlite3Isspace(zStr[0]) ){ i64 iVal; - if( !sqlite3Atoi64(zStr, &iVal, nStr, SQLITE_UTF8) ){ + if( !sqlite3Atoi64((const char*)zStr, &iVal, nStr, SQLITE_UTF8) ){ sqlite3_result_int64(context, iVal); } } @@ -1028,11 +1028,7 @@ static void torealFunc( break; } case SQLITE_INTEGER: { - i64 iVal = sqlite3_value_int64(argv[0]); - double rVal = (double)iVal; - if( iVal==rVal ){ - sqlite3_result_double(context, rVal); - } + sqlite3_result_double(context, (double)sqlite3_value_int64(argv[0])); break; } case SQLITE_BLOB: @@ -1040,9 +1036,9 @@ static void torealFunc( const unsigned char *zStr = sqlite3_value_text(argv[0]); if( zStr ){ int nStr = sqlite3_value_bytes(argv[0]); - if( nStr ){ + if( nStr && !sqlite3Isspace(zStr[0]) && !sqlite3Isspace(zStr[nStr-1]) ){ double rVal; - if( sqlite3AtoF(zStr, &rVal, nStr, SQLITE_UTF8) ){ + if( sqlite3AtoF((const char*)zStr, &rVal, nStr, SQLITE_UTF8) ){ sqlite3_result_double(context, rVal); return; } From 98ab33a82f131056bd428fe547fbec74999fb34a Mon Sep 17 00:00:00 2001 From: mistachkin Date: Tue, 20 Aug 2013 09:26:38 +0000 Subject: [PATCH 10/42] Add test cases for tointeger() and toreal() functions. Fixes for several tests. FossilOrigin-Name: 5e1e9fd5e4f189836442baa42244be00de13ff0f --- manifest | 16 +-- manifest.uuid | 2 +- src/func.c | 6 +- test/func4.test | 298 +++++++++++++++++++++++++++++++++++------------- 4 files changed, 235 insertions(+), 87 deletions(-) diff --git a/manifest b/manifest index 4d99f3c10c..4dcfa0f08d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompiler\swarnings\sand\sboundary\scases\sfor\sthe\stointeger()\sand\storeal()\nfunctions. -D 2013-08-20T02:07:50.845 +C Add\stest\scases\sfor\stointeger()\sand\storeal()\sfunctions.\s\sFixes\sfor\sseveral\stests. +D 2013-08-20T09:26:38.953 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/delete.c 2317c814866d9aa71fea16b3faf4fdd4d6a49b94 F src/expr.c 42d8235af422661ab80be097bebca485b33e2e14 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 914a6bbd987d857c41ac9d244efa6641f36faadb -F src/func.c 03a79c7a2ae5535c36157d7f5823883c5d0179b1 +F src/func.c c47ebaaf71b862edee4beaa041fd77e369d27d6d F src/global.c 5caf4deab621abb45b4c607aad1bd21c20aac759 F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 @@ -560,7 +560,7 @@ F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test cd25cf605c5a345d038dc7b84232204c6a901c84 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a -F test/func4.test 0e2d0e295bc9093676c6e34ff6e33e2541417985 +F test/func4.test 91a0ff89a98304d23dc795c4dbb65865a484633b F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 F test/fuzz.test 77fd50afc12847af50fcf1941679d90adebadde6 F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167 @@ -1106,7 +1106,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P d78c5d89de4b840351b026c9db1952fc24e689d0 -R f40049688c2f823d8e8fd7e09d988578 -U drh -Z 180da4560f629509c84cc64c4a342242 +P 4438b9865826446721b7aa09295fe335bf2fafb7 +R 87152ed0f9f1782b5b4a8475fb92076d +U mistachkin +Z 1ef8a0ac47017357f676bd9db534f67b diff --git a/manifest.uuid b/manifest.uuid index b43e0cae13..054e2b1e73 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4438b9865826446721b7aa09295fe335bf2fafb7 \ No newline at end of file +5e1e9fd5e4f189836442baa42244be00de13ff0f \ No newline at end of file diff --git a/src/func.c b/src/func.c index 81f75851f7..db81760469 100644 --- a/src/func.c +++ b/src/func.c @@ -1028,7 +1028,11 @@ static void torealFunc( break; } case SQLITE_INTEGER: { - sqlite3_result_double(context, (double)sqlite3_value_int64(argv[0])); + i64 iVal = sqlite3_value_int64(argv[0]); + double rVal = (double)iVal; + if( iVal==rVal ){ + sqlite3_result_double(context, rVal); + } break; } case SQLITE_BLOB: diff --git a/test/func4.test b/test/func4.test index b40cca448e..3e26fea614 100644 --- a/test/func4.test +++ b/test/func4.test @@ -14,6 +14,8 @@ # set testdir [file dirname $argv0] source $testdir/tester.tcl +set saved_tcl_precision $tcl_precision +set tcl_precision 0 do_execsql_test func4-1.1 { SELECT tointeger(NULL); @@ -29,7 +31,7 @@ do_execsql_test func4-1.4 { } {1234} do_execsql_test func4-1.5 { SELECT tointeger(' 1234'); -} {1234} +} {{}} do_execsql_test func4-1.6 { SELECT tointeger('bad'); } {{}} @@ -91,80 +93,97 @@ do_execsql_test func4-1.25 { SELECT tointeger(-9223372036854775808 + 1); } {-9223372036854775807} do_execsql_test func4-1.26 { + SELECT tointeger(-9223372036854775807 - 1); +} {-9223372036854775808} +do_execsql_test func4-1.27 { + SELECT tointeger(-9223372036854775807); +} {-9223372036854775807} +do_execsql_test func4-1.28 { + SELECT tointeger(-9223372036854775807 + 1); +} {-9223372036854775806} +do_execsql_test func4-1.29 { SELECT tointeger(-2147483648 - 1); } {-2147483649} -do_execsql_test func4-1.27 { +do_execsql_test func4-1.30 { SELECT tointeger(-2147483648); } {-2147483648} -do_execsql_test func4-1.28 { +do_execsql_test func4-1.31 { SELECT tointeger(-2147483648 + 1); } {-2147483647} -do_execsql_test func4-1.29 { +do_execsql_test func4-1.32 { SELECT tointeger(2147483647 - 1); } {2147483646} -do_execsql_test func4-1.30 { +do_execsql_test func4-1.33 { SELECT tointeger(2147483647); } {2147483647} -do_execsql_test func4-1.31 { +do_execsql_test func4-1.34 { SELECT tointeger(2147483647 + 1); } {2147483648} -do_execsql_test func4-1.32 { +do_execsql_test func4-1.35 { SELECT tointeger(9223372036854775807 - 1); } {9223372036854775806} -do_execsql_test func4-1.33 { +do_execsql_test func4-1.36 { SELECT tointeger(9223372036854775807); } {9223372036854775807} -do_execsql_test func4-1.34 { +do_execsql_test func4-1.37 { SELECT tointeger(9223372036854775807 + 1); } {{}} -do_execsql_test func4-1.35 { +do_execsql_test func4-1.38 { SELECT tointeger(1.79769313486232e308 - 1); } {{}} -do_execsql_test func4-1.36 { +do_execsql_test func4-1.39 { SELECT tointeger(1.79769313486232e308); } {{}} -do_execsql_test func4-1.37 { +do_execsql_test func4-1.40 { SELECT tointeger(1.79769313486232e308 + 1); } {{}} -do_execsql_test func4-1.38 { +do_execsql_test func4-1.41 { SELECT tointeger(4503599627370496 - 1); } {4503599627370495} -do_execsql_test func4-1.39 { +do_execsql_test func4-1.42 { SELECT tointeger(4503599627370496); } {4503599627370496} -do_execsql_test func4-1.40 { +do_execsql_test func4-1.43 { SELECT tointeger(4503599627370496 + 1); } {4503599627370497} -do_execsql_test func4-1.41 { +do_execsql_test func4-1.44 { SELECT tointeger(9007199254740992 - 1); } {9007199254740991} -do_execsql_test func4-1.42 { +do_execsql_test func4-1.45 { SELECT tointeger(9007199254740992); } {9007199254740992} -do_execsql_test func4-1.43 { +do_execsql_test func4-1.46 { SELECT tointeger(9007199254740992 + 1); } {9007199254740993} -do_execsql_test func4-1.44 { +do_execsql_test func4-1.47 { + SELECT tointeger(9223372036854775807 - 1); +} {9223372036854775806} +do_execsql_test func4-1.48 { + SELECT tointeger(9223372036854775807); +} {9223372036854775807} +do_execsql_test func4-1.49 { + SELECT tointeger(9223372036854775807 + 1); +} {{}} +do_execsql_test func4-1.50 { SELECT tointeger(9223372036854775808 - 1); } {{}} -do_execsql_test func4-1.45 { +do_execsql_test func4-1.51 { SELECT tointeger(9223372036854775808); } {{}} -do_execsql_test func4-1.46 { +do_execsql_test func4-1.52 { SELECT tointeger(9223372036854775808 + 1); } {{}} -do_execsql_test func4-1.47 { +do_execsql_test func4-1.53 { SELECT tointeger(18446744073709551616 - 1); } {{}} -do_execsql_test func4-1.48 { +do_execsql_test func4-1.54 { SELECT tointeger(18446744073709551616); } {{}} -do_execsql_test func4-1.49 { +do_execsql_test func4-1.55 { SELECT tointeger(18446744073709551616 + 1); } {{}} ifcapable floatingpoint { - set i 0 do_execsql_test func4-2.1 { SELECT toreal(NULL); } {{}} @@ -179,7 +198,7 @@ ifcapable floatingpoint { } {1234.0} do_execsql_test func4-2.5 { SELECT toreal(' 1234'); - } {1234.0} + } {{}} do_execsql_test func4-2.6 { SELECT toreal('bad'); } {{}} @@ -233,92 +252,103 @@ ifcapable floatingpoint { } {-Inf} do_execsql_test func4-2.23 { SELECT toreal(-9223372036854775808 - 1); - } {-9.22337203685478e+18} + } {-9.223372036854776e+18} do_execsql_test func4-2.24 { SELECT toreal(-9223372036854775808); - } {-9.22337203685478e+18} + } {-9.223372036854776e+18} do_execsql_test func4-2.25 { SELECT toreal(-9223372036854775808 + 1); - } {-9.22337203685478e+18} + } {{}} do_execsql_test func4-2.26 { + SELECT toreal(-9223372036854775807 - 1); + } {-9.223372036854776e+18} + do_execsql_test func4-2.27 { + SELECT toreal(-9223372036854775807); + } {{}} + do_execsql_test func4-2.28 { + SELECT toreal(-9223372036854775807 + 1); + } {{}} + do_execsql_test func4-2.29 { SELECT toreal(-2147483648 - 1); } {-2147483649.0} - do_execsql_test func4-2.27 { + do_execsql_test func4-2.30 { SELECT toreal(-2147483648); } {-2147483648.0} - do_execsql_test func4-2.28 { + do_execsql_test func4-2.31 { SELECT toreal(-2147483648 + 1); } {-2147483647.0} - do_execsql_test func4-2.29 { + do_execsql_test func4-2.32 { SELECT toreal(2147483647 - 1); } {2147483646.0} - do_execsql_test func4-2.30 { + do_execsql_test func4-2.33 { SELECT toreal(2147483647); } {2147483647.0} - do_execsql_test func4-2.31 { + do_execsql_test func4-2.34 { SELECT toreal(2147483647 + 1); } {2147483648.0} - do_execsql_test func4-2.32 { - SELECT toreal(9223372036854775807 - 1); - } {9.22337203685478e+18} - do_execsql_test func4-2.33 { - SELECT toreal(9223372036854775807); - } {9.22337203685478e+18} - do_execsql_test func4-2.34 { - SELECT toreal(9223372036854775807 + 1); - } {9.22337203685478e+18} do_execsql_test func4-2.35 { + SELECT toreal(9223372036854775807 - 1); + } {{}} + do_execsql_test func4-2.36 { + SELECT toreal(9223372036854775807); + } {{}} + do_execsql_test func4-2.37 { + SELECT toreal(9223372036854775807 + 1); + } {9.223372036854776e+18} + do_execsql_test func4-2.38 { SELECT toreal(1.79769313486232e308 - 1); } {Inf} - do_execsql_test func4-2.36 { + do_execsql_test func4-2.39 { SELECT toreal(1.79769313486232e308); } {Inf} - do_execsql_test func4-2.37 { + do_execsql_test func4-2.40 { SELECT toreal(1.79769313486232e308 + 1); } {Inf} - do_execsql_test func4-2.38 { - SELECT toreal(4503599627370496 - 1); - } {4503599627370500.0} - do_execsql_test func4-2.39 { - SELECT toreal(4503599627370496); - } {4503599627370500.0} - do_execsql_test func4-2.40 { - SELECT toreal(4503599627370496 + 1); - } {4503599627370500.0} do_execsql_test func4-2.41 { - SELECT toreal(9007199254740992 - 1); - } {9007199254740990.0} + SELECT toreal(4503599627370496 - 1); + } {4503599627370495.0} do_execsql_test func4-2.42 { - SELECT toreal(9007199254740992); - } {9007199254740990.0} + SELECT toreal(4503599627370496); + } {4503599627370496.0} do_execsql_test func4-2.43 { - SELECT toreal(9007199254740992 + 1); - } {9007199254740990.0} + SELECT toreal(4503599627370496 + 1); + } {4503599627370497.0} do_execsql_test func4-2.44 { - SELECT toreal(9223372036854775808 - 1); - } {9.22337203685478e+18} + SELECT toreal(9007199254740992 - 1); + } {9007199254740991.0} do_execsql_test func4-2.45 { - SELECT toreal(9223372036854775808); - } {9.22337203685478e+18} + SELECT toreal(9007199254740992); + } {9007199254740992.0} do_execsql_test func4-2.46 { - SELECT toreal(9223372036854775808 + 1); - } {9.22337203685478e+18} + SELECT toreal(9007199254740992 + 1); + } {{}} do_execsql_test func4-2.47 { - SELECT toreal(18446744073709551616 - 1); - } {1.84467440737096e+19} + SELECT toreal(9007199254740992 + 2); + } {9007199254740994.0} do_execsql_test func4-2.48 { - SELECT toreal(18446744073709551616); - } {1.84467440737096e+19} + SELECT toreal(tointeger(9223372036854775808) - 1); + } {{}} do_execsql_test func4-2.49 { - SELECT toreal(18446744073709551616 + 1); - } {1.84467440737096e+19} + SELECT toreal(tointeger(9223372036854775808)); + } {{}} + do_execsql_test func4-2.50 { + SELECT toreal(tointeger(9223372036854775808) + 1); + } {{}} + do_execsql_test func4-2.51 { + SELECT toreal(tointeger(18446744073709551616) - 1); + } {{}} + do_execsql_test func4-2.52 { + SELECT toreal(tointeger(18446744073709551616)); + } {{}} + do_execsql_test func4-2.53 { + SELECT toreal(tointeger(18446744073709551616) + 1); + } {{}} } ifcapable check { - set i 0 do_execsql_test func4-3.1 { CREATE TABLE t1( - x INTEGER CHECK(tointeger(x) IS NOT NULL AND x = CAST(x AS INTEGER)) + x INTEGER CHECK(tointeger(x) IS NOT NULL) ); } {} do_test func4-3.2 { @@ -391,12 +421,31 @@ ifcapable check { INSERT INTO t1 (x) VALUES (X'12345678'); } } {1 {constraint failed}} - do_execsql_test func4-3.16 { + do_test func4-3.16 { + catchsql { + INSERT INTO t1 (x) VALUES ('1234.00'); + } + } {1 {constraint failed}} + do_test func4-3.17 { + catchsql { + INSERT INTO t1 (x) VALUES (1234.00); + } + } {0 {}} + do_test func4-3.18 { + catchsql { + INSERT INTO t1 (x) VALUES ('-9223372036854775809'); + } + } {1 {constraint failed}} + do_test func4-3.19 { + catchsql { + INSERT INTO t1 (x) VALUES (9223372036854775808); + } + } {1 {constraint failed}} + do_execsql_test func4-3.20 { SELECT x FROM t1 ORDER BY x; - } {1234 1234} + } {1234 1234 1234} ifcapable floatingpoint { - set i 0 do_execsql_test func4-4.1 { CREATE TABLE t2( x REAL CHECK(toreal(x) IS NOT NULL) @@ -478,4 +527,99 @@ ifcapable check { } } +ifcapable floatingpoint { + do_execsql_test func4-5.1 { + SELECT tointeger(toreal('1234')); + } {1234} + do_execsql_test func4-5.2 { + SELECT tointeger(toreal(-1)); + } {-1} + do_execsql_test func4-5.3 { + SELECT tointeger(toreal(-0)); + } {0} + do_execsql_test func4-5.4 { + SELECT tointeger(toreal(0)); + } {0} + do_execsql_test func4-5.5 { + SELECT tointeger(toreal(1)); + } {1} + do_execsql_test func4-5.6 { + SELECT tointeger(toreal(-9223372036854775808 - 1)); + } {-9223372036854775808} + do_execsql_test func4-5.7 { + SELECT tointeger(toreal(-9223372036854775808)); + } {-9223372036854775808} + do_execsql_test func4-5.8 { + SELECT tointeger(toreal(-9223372036854775808 + 1)); + } {{}} + do_execsql_test func4-5.9 { + SELECT tointeger(toreal(-2147483648 - 1)); + } {-2147483649} + do_execsql_test func4-5.10 { + SELECT tointeger(toreal(-2147483648)); + } {-2147483648} + do_execsql_test func4-5.11 { + SELECT tointeger(toreal(-2147483648 + 1)); + } {-2147483647} + do_execsql_test func4-5.12 { + SELECT tointeger(toreal(2147483647 - 1)); + } {2147483646} + do_execsql_test func4-5.13 { + SELECT tointeger(toreal(2147483647)); + } {2147483647} + do_execsql_test func4-5.14 { + SELECT tointeger(toreal(2147483647 + 1)); + } {2147483648} + do_execsql_test func4-5.15 { + SELECT tointeger(toreal(9223372036854775807 - 1)); + } {{}} + do_execsql_test func4-5.16 { + SELECT tointeger(toreal(9223372036854775807)); + } {{}} + do_execsql_test func4-5.17 { + SELECT tointeger(toreal(9223372036854775807 + 1)); + } {{}} + do_execsql_test func4-5.18 { + SELECT tointeger(toreal(4503599627370496 - 1)); + } {4503599627370495} + do_execsql_test func4-5.19 { + SELECT tointeger(toreal(4503599627370496)); + } {4503599627370496} + do_execsql_test func4-5.20 { + SELECT tointeger(toreal(4503599627370496 + 1)); + } {4503599627370497} + do_execsql_test func4-5.21 { + SELECT tointeger(toreal(9007199254740992 - 1)); + } {9007199254740991} + do_execsql_test func4-5.22 { + SELECT tointeger(toreal(9007199254740992)); + } {9007199254740992} + do_execsql_test func4-5.23 { + SELECT tointeger(toreal(9007199254740992 + 1)); + } {{}} + do_execsql_test func4-5.24 { + SELECT tointeger(toreal(9007199254740992 + 2)); + } {9007199254740994} + do_execsql_test func4-5.25 { + SELECT tointeger(toreal(9223372036854775808 - 1)); + } {{}} + do_execsql_test func4-5.26 { + SELECT tointeger(toreal(9223372036854775808)); + } {{}} + do_execsql_test func4-5.27 { + SELECT tointeger(toreal(9223372036854775808 + 1)); + } {{}} + do_execsql_test func4-5.28 { + SELECT tointeger(toreal(18446744073709551616 - 1)); + } {{}} + do_execsql_test func4-5.29 { + SELECT tointeger(toreal(18446744073709551616)); + } {{}} + do_execsql_test func4-5.30 { + SELECT tointeger(toreal(18446744073709551616 + 1)); + } {{}} +} + +set tcl_precision $saved_tcl_precision +unset saved_tcl_precision finish_test From 60883e540122dd38939d9a288c251f204722800e Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 29 Aug 2013 01:01:11 +0000 Subject: [PATCH 11/42] Fix boundary case for the toreal() SQL function. FossilOrigin-Name: abe82c634ccda7d62687df5917d18a9d6e411142 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/func.c | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/manifest b/manifest index e4961822f3..05b0b77188 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\supdates\sfrom\strunk. -D 2013-08-28T18:56:04.093 +C Fix\sboundary\scase\sfor\sthe\storeal()\sSQL\sfunction. +D 2013-08-29T01:01:11.268 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/delete.c 2317c814866d9aa71fea16b3faf4fdd4d6a49b94 F src/expr.c 4d89bd03a04fcdb5ff71d86b4e0cc7d3230797b8 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 914a6bbd987d857c41ac9d244efa6641f36faadb -F src/func.c f3ab79a3f46f5c744a14a649d8f4acec30a07cd4 +F src/func.c 6099094d90f401c9fe7ed565d16b6ab07926960e F src/global.c 5caf4deab621abb45b4c607aad1bd21c20aac759 F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 @@ -1109,7 +1109,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 5e1e9fd5e4f189836442baa42244be00de13ff0f 12d0a8859de0a9d823997cfeccc77bd572cb6d13 -R 81e42b2f9c462fbb356fb6a9b3d50e1d +P ffc6e682836cdf275189427109f8af2aeb423bcd +R 5b28ae921fcc930fbdb4ed7973c09a22 U mistachkin -Z a257c970f64b4c0a5f36c110c9d698d7 +Z eee04e7f47bd53db98c6ff93d7e968bb diff --git a/manifest.uuid b/manifest.uuid index 013ba63477..a6f7367f72 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -ffc6e682836cdf275189427109f8af2aeb423bcd \ No newline at end of file +abe82c634ccda7d62687df5917d18a9d6e411142 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 658559ba4b..36b0e5f378 100644 --- a/src/func.c +++ b/src/func.c @@ -1030,7 +1030,7 @@ static void torealFunc( case SQLITE_INTEGER: { i64 iVal = sqlite3_value_int64(argv[0]); double rVal = (double)iVal; - if( iVal==rVal ){ + if( iVal==(i64)rVal ){ sqlite3_result_double(context, rVal); } break; From 09dee52885441dd2b5d666be5aa90738c9f30731 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 29 Aug 2013 01:17:24 +0000 Subject: [PATCH 12/42] Prevent the implementation of the toreal() SQL function from being 'optimized' by MSVC. FossilOrigin-Name: 047bd1c24553b00ccf12d7745bb4c46820b91f5e --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/func.c | 6 ++++++ 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/manifest b/manifest index 6b536697bd..dc0eaaf043 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\supdates\sfrom\strunk. -D 2013-08-29T01:11:45.298 +C Prevent\sthe\simplementation\sof\sthe\storeal()\sSQL\sfunction\sfrom\sbeing\s'optimized'\sby\sMSVC. +D 2013-08-29T01:17:24.949 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/delete.c 2317c814866d9aa71fea16b3faf4fdd4d6a49b94 F src/expr.c 4d89bd03a04fcdb5ff71d86b4e0cc7d3230797b8 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 914a6bbd987d857c41ac9d244efa6641f36faadb -F src/func.c 6099094d90f401c9fe7ed565d16b6ab07926960e +F src/func.c 5c85fed36b47a484e8b85c6528348f83ec5f8855 F src/global.c 5caf4deab621abb45b4c607aad1bd21c20aac759 F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 @@ -1109,7 +1109,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P abe82c634ccda7d62687df5917d18a9d6e411142 9229aeb361f9805894321327d05aba855b8799f3 -R 37bb2eb70562f6e2f1a6470983432e85 +P 375dfe288fd0c4eb3c343a3cb23a7e3851903805 +R 7c55303025c97a6a9c8303db7e5df83c U mistachkin -Z 8236c13d7d380aaddad2f7d32e5c8a7f +Z 349da4d5082e6d065b9211864249410e diff --git a/manifest.uuid b/manifest.uuid index fe6fc5eb26..761fcfda92 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -375dfe288fd0c4eb3c343a3cb23a7e3851903805 \ No newline at end of file +047bd1c24553b00ccf12d7745bb4c46820b91f5e \ No newline at end of file diff --git a/src/func.c b/src/func.c index 36b0e5f378..fb999c9f98 100644 --- a/src/func.c +++ b/src/func.c @@ -1015,6 +1015,9 @@ static void tointegerFunc( ** toreal(X): If X can be losslessly converted into a real number, then ** do so and return that real number. Otherwise return NULL. */ +#if defined(_MSC_VER) +#pragma optimize("", off) +#endif static void torealFunc( sqlite3_context *context, int argc, @@ -1056,6 +1059,9 @@ static void torealFunc( } } } +#if defined(_MSC_VER) +#pragma optimize("", on) +#endif /* ** The unicode() function. Return the integer unicode code-point value From a17713ff8d7e1dc39f530ff2cee21f5243b0fe4d Mon Sep 17 00:00:00 2001 From: mistachkin Date: Thu, 29 Aug 2013 02:27:39 +0000 Subject: [PATCH 13/42] Disable several toreal() tests that require high floating point precision when it is unavailable. FossilOrigin-Name: b724219b008d9851de18bd4158375100d781c5a3 --- manifest | 12 ++++----- manifest.uuid | 2 +- test/func4.test | 72 ++++++++++++++++++++++++++++++------------------- 3 files changed, 52 insertions(+), 34 deletions(-) diff --git a/manifest b/manifest index dc0eaaf043..09f33e19c2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Prevent\sthe\simplementation\sof\sthe\storeal()\sSQL\sfunction\sfrom\sbeing\s'optimized'\sby\sMSVC. -D 2013-08-29T01:17:24.949 +C Disable\sseveral\storeal()\stests\sthat\srequire\shigh\sfloating\spoint\sprecision\swhen\sit\sis\sunavailable. +D 2013-08-29T02:27:39.369 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -562,7 +562,7 @@ F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test cd25cf605c5a345d038dc7b84232204c6a901c84 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a -F test/func4.test 91a0ff89a98304d23dc795c4dbb65865a484633b +F test/func4.test 4eaa19eed2fd37a39b4bb274c4bf84b142a9a40a F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 F test/fuzz.test 77fd50afc12847af50fcf1941679d90adebadde6 F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167 @@ -1109,7 +1109,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 375dfe288fd0c4eb3c343a3cb23a7e3851903805 -R 7c55303025c97a6a9c8303db7e5df83c +P 047bd1c24553b00ccf12d7745bb4c46820b91f5e +R 23d92ec42ac516cd6bc59a2369e868fb U mistachkin -Z 349da4d5082e6d065b9211864249410e +Z 305c9d921855a6e7bed35ab5c2575022 diff --git a/manifest.uuid b/manifest.uuid index 761fcfda92..abd3892813 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -047bd1c24553b00ccf12d7745bb4c46820b91f5e \ No newline at end of file +b724219b008d9851de18bd4158375100d781c5a3 \ No newline at end of file diff --git a/test/func4.test b/test/func4.test index 3e26fea614..6b1f228b57 100644 --- a/test/func4.test +++ b/test/func4.test @@ -8,9 +8,12 @@ # May you share freely, never taking more than you give. # #*********************************************************************** -# This file implements regression tests for SQLite library. The -# focus of this file is testing the tointeger() and toreal() -# functions. +# This file implements regression tests for SQLite library. The focus of +# this file is testing the tointeger() and toreal() functions. +# +# Several of the toreal() tests are disabled on platforms where floating +# point precision is not high enough to represent their constant integer +# expression arguments as double precision floating point values. # set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -184,6 +187,9 @@ do_execsql_test func4-1.55 { } {{}} ifcapable floatingpoint { + set highPrecision [expr \ + {[memdbsql {SELECT toreal(-9223372036854775808 + 1);}] eq {{}}}] + do_execsql_test func4-2.1 { SELECT toreal(NULL); } {{}} @@ -256,18 +262,22 @@ ifcapable floatingpoint { do_execsql_test func4-2.24 { SELECT toreal(-9223372036854775808); } {-9.223372036854776e+18} - do_execsql_test func4-2.25 { - SELECT toreal(-9223372036854775808 + 1); - } {{}} + if {$highPrecision} { + do_execsql_test func4-2.25 { + SELECT toreal(-9223372036854775808 + 1); + } {{}} + } do_execsql_test func4-2.26 { SELECT toreal(-9223372036854775807 - 1); } {-9.223372036854776e+18} - do_execsql_test func4-2.27 { - SELECT toreal(-9223372036854775807); - } {{}} - do_execsql_test func4-2.28 { - SELECT toreal(-9223372036854775807 + 1); - } {{}} + if {$highPrecision} { + do_execsql_test func4-2.27 { + SELECT toreal(-9223372036854775807); + } {{}} + do_execsql_test func4-2.28 { + SELECT toreal(-9223372036854775807 + 1); + } {{}} + } do_execsql_test func4-2.29 { SELECT toreal(-2147483648 - 1); } {-2147483649.0} @@ -286,12 +296,14 @@ ifcapable floatingpoint { do_execsql_test func4-2.34 { SELECT toreal(2147483647 + 1); } {2147483648.0} - do_execsql_test func4-2.35 { - SELECT toreal(9223372036854775807 - 1); - } {{}} - do_execsql_test func4-2.36 { - SELECT toreal(9223372036854775807); - } {{}} + if {$highPrecision} { + do_execsql_test func4-2.35 { + SELECT toreal(9223372036854775807 - 1); + } {{}} + do_execsql_test func4-2.36 { + SELECT toreal(9223372036854775807); + } {{}} + } do_execsql_test func4-2.37 { SELECT toreal(9223372036854775807 + 1); } {9.223372036854776e+18} @@ -319,9 +331,11 @@ ifcapable floatingpoint { do_execsql_test func4-2.45 { SELECT toreal(9007199254740992); } {9007199254740992.0} - do_execsql_test func4-2.46 { - SELECT toreal(9007199254740992 + 1); - } {{}} + if {$highPrecision} { + do_execsql_test func4-2.46 { + SELECT toreal(9007199254740992 + 1); + } {{}} + } do_execsql_test func4-2.47 { SELECT toreal(9007199254740992 + 2); } {9007199254740994.0} @@ -549,9 +563,11 @@ ifcapable floatingpoint { do_execsql_test func4-5.7 { SELECT tointeger(toreal(-9223372036854775808)); } {-9223372036854775808} - do_execsql_test func4-5.8 { - SELECT tointeger(toreal(-9223372036854775808 + 1)); - } {{}} + if {$highPrecision} { + do_execsql_test func4-5.8 { + SELECT tointeger(toreal(-9223372036854775808 + 1)); + } {{}} + } do_execsql_test func4-5.9 { SELECT tointeger(toreal(-2147483648 - 1)); } {-2147483649} @@ -594,9 +610,11 @@ ifcapable floatingpoint { do_execsql_test func4-5.22 { SELECT tointeger(toreal(9007199254740992)); } {9007199254740992} - do_execsql_test func4-5.23 { - SELECT tointeger(toreal(9007199254740992 + 1)); - } {{}} + if {$highPrecision} { + do_execsql_test func4-5.23 { + SELECT tointeger(toreal(9007199254740992 + 1)); + } {{}} + } do_execsql_test func4-5.24 { SELECT tointeger(toreal(9007199254740992 + 2)); } {9007199254740994} From 05b1ba1e3fe57eba290419729d6e4eaa4fa6ac32 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 31 Aug 2013 21:41:09 +0000 Subject: [PATCH 14/42] Handle BLOBs specially, treating them as binary, in the tointeger() and toreal() SQL functions. FossilOrigin-Name: c4c53acb985a248c89db2d75025d941e3a4899bc --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/func.c | 26 ++++++++++++++++++++++++-- 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 09f33e19c2..e7f15964da 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Disable\sseveral\storeal()\stests\sthat\srequire\shigh\sfloating\spoint\sprecision\swhen\sit\sis\sunavailable. -D 2013-08-29T02:27:39.369 +C Handle\sBLOBs\sspecially,\streating\sthem\sas\sbinary,\sin\sthe\stointeger()\sand\storeal()\sSQL\sfunctions. +D 2013-08-31T21:41:09.620 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/delete.c 2317c814866d9aa71fea16b3faf4fdd4d6a49b94 F src/expr.c 4d89bd03a04fcdb5ff71d86b4e0cc7d3230797b8 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 914a6bbd987d857c41ac9d244efa6641f36faadb -F src/func.c 5c85fed36b47a484e8b85c6528348f83ec5f8855 +F src/func.c ed294cd9437881cb7e2fbece2ea3389fc80c9fc7 F src/global.c 5caf4deab621abb45b4c607aad1bd21c20aac759 F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 @@ -1109,7 +1109,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 047bd1c24553b00ccf12d7745bb4c46820b91f5e -R 23d92ec42ac516cd6bc59a2369e868fb +P b724219b008d9851de18bd4158375100d781c5a3 +R eb3d216eeef911fedebe51f6e14ce498 U mistachkin -Z 305c9d921855a6e7bed35ab5c2575022 +Z 1633034cbe064c087ca5481033ebadfd diff --git a/manifest.uuid b/manifest.uuid index abd3892813..4503ca3dd4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -b724219b008d9851de18bd4158375100d781c5a3 \ No newline at end of file +c4c53acb985a248c89db2d75025d941e3a4899bc \ No newline at end of file diff --git a/src/func.c b/src/func.c index fb999c9f98..31b96d4a9c 100644 --- a/src/func.c +++ b/src/func.c @@ -990,7 +990,18 @@ static void tointegerFunc( sqlite3_result_int64(context, sqlite3_value_int64(argv[0])); break; } - case SQLITE_BLOB: + case SQLITE_BLOB: { + const unsigned char *zBlob = sqlite3_value_blob(argv[0]); + if( zBlob ){ + int nBlob = sqlite3_value_bytes(argv[0]); + if( nBlob==sizeof(i64) ){ + i64 iVal; + memcpy(&iVal, zBlob, sizeof(i64)); + sqlite3_result_int64(context, iVal); + } + } + break; + } case SQLITE_TEXT: { const unsigned char *zStr = sqlite3_value_text(argv[0]); if( zStr ){ @@ -1038,7 +1049,18 @@ static void torealFunc( } break; } - case SQLITE_BLOB: + case SQLITE_BLOB: { + const unsigned char *zBlob = sqlite3_value_blob(argv[0]); + if( zBlob ){ + int nBlob = sqlite3_value_bytes(argv[0]); + if( nBlob==sizeof(double) ){ + double rVal; + memcpy(&rVal, zBlob, sizeof(double)); + sqlite3_result_double(context, rVal); + } + } + break; + } case SQLITE_TEXT: { const unsigned char *zStr = sqlite3_value_text(argv[0]); if( zStr ){ From aeddf19e60ae9cbeaf272646b17e03c9344b9e68 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Wed, 4 Sep 2013 00:58:00 +0000 Subject: [PATCH 15/42] Additional test cases for the tointeger() and toreal() SQL functions when converting from a BLOB. FossilOrigin-Name: e1814452faa698946ef77f06a42665277ee59cc1 --- manifest | 12 +-- manifest.uuid | 2 +- test/func4.test | 242 ++++++++++++++++++++++++++++++++++++++---------- 3 files changed, 198 insertions(+), 58 deletions(-) diff --git a/manifest b/manifest index ff7380ec5a..39884a7204 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Merge\supdates\sfrom\strunk. -D 2013-09-01T23:36:44.564 +C Additional\stest\scases\sfor\sthe\stointeger()\sand\storeal()\sSQL\sfunctions\swhen\sconverting\sfrom\sa\sBLOB. +D 2013-09-04T00:58:00.238 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -562,7 +562,7 @@ F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test cd25cf605c5a345d038dc7b84232204c6a901c84 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a -F test/func4.test 4eaa19eed2fd37a39b4bb274c4bf84b142a9a40a +F test/func4.test 488c8deabf6a282e47aa5fcde782c6657e7625bc F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 F test/fuzz.test 77fd50afc12847af50fcf1941679d90adebadde6 F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167 @@ -1110,7 +1110,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P c4c53acb985a248c89db2d75025d941e3a4899bc c94933f13208f3f7d6d1b117ce6d2821100655a4 -R 78e6edd05b7acf1ce753e27ea742b6df +P 2982725e12715fba425a46ae024f317f031b6a54 +R c95b9007057313a186c90146fdfe015a U mistachkin -Z e29db6a65ca4b79187ca51ff7b874db3 +Z e95b03ef226de372c05086e066827ed5 diff --git a/manifest.uuid b/manifest.uuid index 66df56a57e..c24c8842e5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -2982725e12715fba425a46ae024f317f031b6a54 \ No newline at end of file +e1814452faa698946ef77f06a42665277ee59cc1 \ No newline at end of file diff --git a/test/func4.test b/test/func4.test index 6b1f228b57..c14a5e9af9 100644 --- a/test/func4.test +++ b/test/func4.test @@ -20,6 +20,9 @@ source $testdir/tester.tcl set saved_tcl_precision $tcl_precision set tcl_precision 0 +set highPrecision(1) [expr \ + {[memdbsql {SELECT tointeger(9223372036854775807 + 1);}] eq {{}}}] + do_execsql_test func4-1.1 { SELECT tointeger(NULL); } {{}} @@ -128,9 +131,11 @@ do_execsql_test func4-1.35 { do_execsql_test func4-1.36 { SELECT tointeger(9223372036854775807); } {9223372036854775807} -do_execsql_test func4-1.37 { - SELECT tointeger(9223372036854775807 + 1); -} {{}} +if {$highPrecision(1)} { + do_execsql_test func4-1.37 { + SELECT tointeger(9223372036854775807 + 1); + } {{}} +} do_execsql_test func4-1.38 { SELECT tointeger(1.79769313486232e308 - 1); } {{}} @@ -164,18 +169,20 @@ do_execsql_test func4-1.47 { do_execsql_test func4-1.48 { SELECT tointeger(9223372036854775807); } {9223372036854775807} -do_execsql_test func4-1.49 { - SELECT tointeger(9223372036854775807 + 1); -} {{}} -do_execsql_test func4-1.50 { - SELECT tointeger(9223372036854775808 - 1); -} {{}} -do_execsql_test func4-1.51 { - SELECT tointeger(9223372036854775808); -} {{}} -do_execsql_test func4-1.52 { - SELECT tointeger(9223372036854775808 + 1); -} {{}} +if {$highPrecision(1)} { + do_execsql_test func4-1.49 { + SELECT tointeger(9223372036854775807 + 1); + } {{}} + do_execsql_test func4-1.50 { + SELECT tointeger(9223372036854775808 - 1); + } {{}} + do_execsql_test func4-1.51 { + SELECT tointeger(9223372036854775808); + } {{}} + do_execsql_test func4-1.52 { + SELECT tointeger(9223372036854775808 + 1); + } {{}} +} do_execsql_test func4-1.53 { SELECT tointeger(18446744073709551616 - 1); } {{}} @@ -187,7 +194,7 @@ do_execsql_test func4-1.55 { } {{}} ifcapable floatingpoint { - set highPrecision [expr \ + set highPrecision(2) [expr \ {[memdbsql {SELECT toreal(-9223372036854775808 + 1);}] eq {{}}}] do_execsql_test func4-2.1 { @@ -262,7 +269,7 @@ ifcapable floatingpoint { do_execsql_test func4-2.24 { SELECT toreal(-9223372036854775808); } {-9.223372036854776e+18} - if {$highPrecision} { + if {$highPrecision(2)} { do_execsql_test func4-2.25 { SELECT toreal(-9223372036854775808 + 1); } {{}} @@ -270,7 +277,7 @@ ifcapable floatingpoint { do_execsql_test func4-2.26 { SELECT toreal(-9223372036854775807 - 1); } {-9.223372036854776e+18} - if {$highPrecision} { + if {$highPrecision(2)} { do_execsql_test func4-2.27 { SELECT toreal(-9223372036854775807); } {{}} @@ -296,13 +303,15 @@ ifcapable floatingpoint { do_execsql_test func4-2.34 { SELECT toreal(2147483647 + 1); } {2147483648.0} - if {$highPrecision} { + if {$highPrecision(2)} { do_execsql_test func4-2.35 { SELECT toreal(9223372036854775807 - 1); } {{}} - do_execsql_test func4-2.36 { - SELECT toreal(9223372036854775807); - } {{}} + if {$highPrecision(1)} { + do_execsql_test func4-2.36 { + SELECT toreal(9223372036854775807); + } {{}} + } } do_execsql_test func4-2.37 { SELECT toreal(9223372036854775807 + 1); @@ -331,7 +340,7 @@ ifcapable floatingpoint { do_execsql_test func4-2.45 { SELECT toreal(9007199254740992); } {9007199254740992.0} - if {$highPrecision} { + if {$highPrecision(2)} { do_execsql_test func4-2.46 { SELECT toreal(9007199254740992 + 1); } {{}} @@ -342,12 +351,14 @@ ifcapable floatingpoint { do_execsql_test func4-2.48 { SELECT toreal(tointeger(9223372036854775808) - 1); } {{}} - do_execsql_test func4-2.49 { - SELECT toreal(tointeger(9223372036854775808)); - } {{}} - do_execsql_test func4-2.50 { - SELECT toreal(tointeger(9223372036854775808) + 1); - } {{}} + if {$highPrecision(1)} { + do_execsql_test func4-2.49 { + SELECT toreal(tointeger(9223372036854775808)); + } {{}} + do_execsql_test func4-2.50 { + SELECT toreal(tointeger(9223372036854775808) + 1); + } {{}} + } do_execsql_test func4-2.51 { SELECT toreal(tointeger(18446744073709551616) - 1); } {{}} @@ -450,11 +461,13 @@ ifcapable check { INSERT INTO t1 (x) VALUES ('-9223372036854775809'); } } {1 {constraint failed}} - do_test func4-3.19 { - catchsql { - INSERT INTO t1 (x) VALUES (9223372036854775808); - } - } {1 {constraint failed}} + if {$highPrecision(1)} { + do_test func4-3.19 { + catchsql { + INSERT INTO t1 (x) VALUES (9223372036854775808); + } + } {1 {constraint failed}} + } do_execsql_test func4-3.20 { SELECT x FROM t1 ORDER BY x; } {1234 1234 1234} @@ -563,7 +576,7 @@ ifcapable floatingpoint { do_execsql_test func4-5.7 { SELECT tointeger(toreal(-9223372036854775808)); } {-9223372036854775808} - if {$highPrecision} { + if {$highPrecision(2)} { do_execsql_test func4-5.8 { SELECT tointeger(toreal(-9223372036854775808 + 1)); } {{}} @@ -589,12 +602,14 @@ ifcapable floatingpoint { do_execsql_test func4-5.15 { SELECT tointeger(toreal(9223372036854775807 - 1)); } {{}} - do_execsql_test func4-5.16 { - SELECT tointeger(toreal(9223372036854775807)); - } {{}} - do_execsql_test func4-5.17 { - SELECT tointeger(toreal(9223372036854775807 + 1)); - } {{}} + if {$highPrecision(1)} { + do_execsql_test func4-5.16 { + SELECT tointeger(toreal(9223372036854775807)); + } {{}} + do_execsql_test func4-5.17 { + SELECT tointeger(toreal(9223372036854775807 + 1)); + } {{}} + } do_execsql_test func4-5.18 { SELECT tointeger(toreal(4503599627370496 - 1)); } {4503599627370495} @@ -610,7 +625,7 @@ ifcapable floatingpoint { do_execsql_test func4-5.22 { SELECT tointeger(toreal(9007199254740992)); } {9007199254740992} - if {$highPrecision} { + if {$highPrecision(2)} { do_execsql_test func4-5.23 { SELECT tointeger(toreal(9007199254740992 + 1)); } {{}} @@ -618,15 +633,17 @@ ifcapable floatingpoint { do_execsql_test func4-5.24 { SELECT tointeger(toreal(9007199254740992 + 2)); } {9007199254740994} - do_execsql_test func4-5.25 { - SELECT tointeger(toreal(9223372036854775808 - 1)); - } {{}} - do_execsql_test func4-5.26 { - SELECT tointeger(toreal(9223372036854775808)); - } {{}} - do_execsql_test func4-5.27 { - SELECT tointeger(toreal(9223372036854775808 + 1)); - } {{}} + if {$highPrecision(1)} { + do_execsql_test func4-5.25 { + SELECT tointeger(toreal(9223372036854775808 - 1)); + } {{}} + do_execsql_test func4-5.26 { + SELECT tointeger(toreal(9223372036854775808)); + } {{}} + do_execsql_test func4-5.27 { + SELECT tointeger(toreal(9223372036854775808 + 1)); + } {{}} + } do_execsql_test func4-5.28 { SELECT tointeger(toreal(18446744073709551616 - 1)); } {{}} @@ -638,6 +655,129 @@ ifcapable floatingpoint { } {{}} } +for {set i 0} {$i < 10} {incr i} { + if {$i == 8} continue + do_execsql_test func4-6.1.$i.1 [subst { + SELECT tointeger(x'[string repeat 01 $i]'); + }] {{}} + ifcapable floatingpoint { + do_execsql_test func4-6.1.$i.2 [subst { + SELECT toreal(x'[string repeat 01 $i]'); + }] {{}} + } +} + +proc swapHexBytes { value } { + if {[string length $value] % 2 != 0} { + error "value \"$value\" must have an even number of characters" + } + if {![string is xdigit -strict $value]} then { + error "value \"$value\" must contain only hexadecimal digits" + } + join [lreverse [regexp -all -inline {.{2}} $value]] "" +} + +proc swapIntegerHexBytes { value } { + if {![info exists ::tcl_platform(byteOrder)] || \ + $::tcl_platform(byteOrder) eq "littleEndian"} { + return $value + } + return [swapHexBytes $value] +} + +proc swapDoubleHexBytes { value } { + if {![info exists ::tcl_platform(byteOrder)] || \ + $::tcl_platform(byteOrder) ne "littleEndian"} { + return $value + } + return [swapHexBytes $value] +} + +do_execsql_test func4-6.2.1 [subst { + SELECT tointeger(x'[swapIntegerHexBytes 0102030405060708]'); +}] {578437695752307201} +do_execsql_test func4-6.2.2 [subst { + SELECT tointeger(x'[swapIntegerHexBytes 0807060504030201]'); +}] {72623859790382856} + +ifcapable floatingpoint { + do_execsql_test func4-6.3.1 [subst { + SELECT toreal(x'[swapDoubleHexBytes ffefffffffffffff]'); + }] {-1.7976931348623157e+308} + do_execsql_test func4-6.3.2 [subst { + SELECT toreal(x'[swapDoubleHexBytes 8010000000000000]'); + }] {-2.2250738585072014e-308} + do_execsql_test func4-6.3.3 [subst { + SELECT toreal(x'[swapDoubleHexBytes c000000000000000]'); + }] {-2.0} + do_execsql_test func4-6.3.4 [subst { + SELECT toreal(x'[swapDoubleHexBytes bff0000000000000]'); + }] {-1.0} + do_execsql_test func4-6.3.5 [subst { + SELECT toreal(x'[swapDoubleHexBytes 8000000000000000]'); + }] {-0.0} + do_execsql_test func4-6.3.6 [subst { + SELECT toreal(x'[swapDoubleHexBytes 0000000000000000]'); + }] {0.0} + do_execsql_test func4-6.3.7 [subst { + SELECT toreal(x'[swapDoubleHexBytes 3ff0000000000000]'); + }] {1.0} + do_execsql_test func4-6.3.8 [subst { + SELECT toreal(x'[swapDoubleHexBytes 4000000000000000]'); + }] {2.0} + do_execsql_test func4-6.3.9 [subst { + SELECT toreal(x'[swapDoubleHexBytes 0010000000000000]'); + }] {2.2250738585072014e-308} + do_execsql_test func4-6.3.10 [subst { + SELECT toreal(x'[swapDoubleHexBytes 7fefffffffffffff]'); + }] {1.7976931348623157e+308} + do_execsql_test func4-6.3.11 [subst { + SELECT toreal(x'[swapDoubleHexBytes 8000000000000001]'); + }] {-5e-324} + do_execsql_test func4-6.3.12 [subst { + SELECT toreal(x'[swapDoubleHexBytes 800fffffffffffff]'); + }] {-2.225073858507201e-308} + do_execsql_test func4-6.3.13 [subst { + SELECT toreal(x'[swapDoubleHexBytes 0000000000000001]'); + }] {5e-324} + do_execsql_test func4-6.3.14 [subst { + SELECT toreal(x'[swapDoubleHexBytes 000fffffffffffff]'); + }] {2.225073858507201e-308} + do_execsql_test func4-6.3.15 [subst { + SELECT toreal(x'[swapDoubleHexBytes fff0000000000000]'); + }] {-Inf} + do_execsql_test func4-6.3.16 [subst { + SELECT toreal(x'[swapDoubleHexBytes 7ff0000000000000]'); + }] {Inf} + do_execsql_test func4-6.3.17 [subst { + SELECT toreal(x'[swapDoubleHexBytes fff8000000000000]'); + }] {{}} + do_execsql_test func4-6.3.18 [subst { + SELECT toreal(x'[swapDoubleHexBytes fff0000000000001]'); + }] {{}} + do_execsql_test func4-6.3.19 [subst { + SELECT toreal(x'[swapDoubleHexBytes fff7ffffffffffff]'); + }] {{}} + do_execsql_test func4-6.3.20 [subst { + SELECT toreal(x'[swapDoubleHexBytes 7ff0000000000001]'); + }] {{}} + do_execsql_test func4-6.3.21 [subst { + SELECT toreal(x'[swapDoubleHexBytes 7ff7ffffffffffff]'); + }] {{}} + do_execsql_test func4-6.3.22 [subst { + SELECT toreal(x'[swapDoubleHexBytes fff8000000000001]'); + }] {{}} + do_execsql_test func4-6.3.23 [subst { + SELECT toreal(x'[swapDoubleHexBytes ffffffffffffffff]'); + }] {{}} + do_execsql_test func4-6.3.24 [subst { + SELECT toreal(x'[swapDoubleHexBytes 7ff8000000000000]'); + }] {{}} + do_execsql_test func4-6.3.25 [subst { + SELECT toreal(x'[swapDoubleHexBytes 7fffffffffffffff]'); + }] {{}} +} + set tcl_precision $saved_tcl_precision unset saved_tcl_precision finish_test From 9a5b271908e1f934e2cd3db2e62ad2a0eddbc624 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 6 Sep 2013 20:30:53 +0000 Subject: [PATCH 16/42] When converting from a BLOB value in the tointeger() and toreal() SQL functions, make sure that endianness of the machine does not matter. FossilOrigin-Name: 94c4cdc50d2753c859e494d53cebd09edd2e5663 --- manifest | 14 ++-- manifest.uuid | 2 +- src/func.c | 31 ++++++-- test/func4.test | 188 +++++++++++++++++++++--------------------------- 4 files changed, 114 insertions(+), 121 deletions(-) diff --git a/manifest b/manifest index 39884a7204..6da51c9843 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\stest\scases\sfor\sthe\stointeger()\sand\storeal()\sSQL\sfunctions\swhen\sconverting\sfrom\sa\sBLOB. -D 2013-09-04T00:58:00.238 +C When\sconverting\sfrom\sa\sBLOB\svalue\sin\sthe\stointeger()\sand\storeal()\sSQL\sfunctions,\smake\ssure\sthat\sendianness\sof\sthe\smachine\sdoes\snot\smatter. +D 2013-09-06T20:30:53.365 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/delete.c 2317c814866d9aa71fea16b3faf4fdd4d6a49b94 F src/expr.c 4d89bd03a04fcdb5ff71d86b4e0cc7d3230797b8 F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb F src/fkey.c 914a6bbd987d857c41ac9d244efa6641f36faadb -F src/func.c ed294cd9437881cb7e2fbece2ea3389fc80c9fc7 +F src/func.c 1f24db7b0f19e28170ffa5d5887b842e4d9a48d9 F src/global.c 5caf4deab621abb45b4c607aad1bd21c20aac759 F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 F src/hash.h 8890a25af81fb85a9ad7790d32eedab4b994da22 @@ -562,7 +562,7 @@ F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test cd25cf605c5a345d038dc7b84232204c6a901c84 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a -F test/func4.test 488c8deabf6a282e47aa5fcde782c6657e7625bc +F test/func4.test 142490571f2e7ee6c3c5a65f24cad3f8342c02a2 F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 F test/fuzz.test 77fd50afc12847af50fcf1941679d90adebadde6 F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167 @@ -1110,7 +1110,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P 2982725e12715fba425a46ae024f317f031b6a54 -R c95b9007057313a186c90146fdfe015a +P e1814452faa698946ef77f06a42665277ee59cc1 +R 134c8f8ed3149356b5cf5475063a56e8 U mistachkin -Z e95b03ef226de372c05086e066827ed5 +Z b7db7274557533e42de3d2876d1a3f58 diff --git a/manifest.uuid b/manifest.uuid index c24c8842e5..95adfb0cad 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -e1814452faa698946ef77f06a42665277ee59cc1 \ No newline at end of file +94c4cdc50d2753c859e494d53cebd09edd2e5663 \ No newline at end of file diff --git a/src/func.c b/src/func.c index 31b96d4a9c..7c6c6b26b0 100644 --- a/src/func.c +++ b/src/func.c @@ -966,8 +966,8 @@ static void quoteFunc(sqlite3_context *context, int argc, sqlite3_value **argv){ } /* -** tointeger(X): If X is any value (integer, double, or string) that can -** be losslessly converted into an integer, then make the conversion and +** tointeger(X): If X is any value (integer, double, blob, or string) that +** can be losslessly converted into an integer, then make the conversion and ** return the result. Otherwise, return NULL. */ static void tointegerFunc( @@ -996,7 +996,16 @@ static void tointegerFunc( int nBlob = sqlite3_value_bytes(argv[0]); if( nBlob==sizeof(i64) ){ i64 iVal; - memcpy(&iVal, zBlob, sizeof(i64)); + if( SQLITE_BIGENDIAN ){ + int i; + unsigned char *zBlobRev = contextMalloc(context, nBlob); + if( !zBlobRev ) break; + for(i=0; i Date: Fri, 6 Sep 2013 21:41:11 +0000 Subject: [PATCH 17/42] Add the ability to generate assembly listing files using the MSVC makefile. FossilOrigin-Name: 6caa2cd10421a85db6740fb2ae8a42b573959562 --- Makefile.msc | 23 ++++++++++++++++++++++- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 6e32eb5124..761de56d67 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -25,6 +25,13 @@ USE_ICU = 0 USE_CRT_DLL = 0 !ENDIF +# Set this non-0 to generate assembly code listings for the source code +# files. +# +!IFNDEF USE_LISTINGS +USE_LISTINGS = 0 +!ENDIF + # Set this non-0 to attempt setting the native compiler automatically # for cross-compiling the command line tools needed during the compilation # process. @@ -181,6 +188,13 @@ NSDKLIBPATH = $(NSDKLIBPATH:\\=\) # BCC = $(NCC) -W3 +# Check if assembly code listings should be generated for the source +# code files to be compiled. +# +!IF $(USE_LISTINGS)!=0 +BCC = $(BCC) -FAcs +!ENDIF + # Check if the native library paths should be used when compiling # the command line tools used during the compilation process. If # so, set the necessary macro now. @@ -196,6 +210,13 @@ NLTLIBPATHS = "/LIBPATH:$(NCRTLIBPATH)" "/LIBPATH:$(NSDKLIBPATH)" TCC = $(CC) -W3 -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src -fp:precise RCC = $(RC) -DSQLITE_OS_WIN=1 -I$(TOP) -I$(TOP)\src +# Check if assembly code listings should be generated for the source +# code files to be compiled. +# +!IF $(USE_LISTINGS)!=0 +TCC = $(TCC) -FAcs +!ENDIF + # When compiling the library for use in the WinRT environment, # the following compile-time options must be used as well to # disable use of Win32 APIs that are not available and to enable @@ -1285,7 +1306,7 @@ sqlite3_analyzer.exe: sqlite3_analyzer.c $(LIBRESOBJS) clean: del /Q *.lo *.ilk *.lib *.obj *.pdb sqlite3.exe libsqlite3.lib - del /Q *.da *.bb *.bbg gmon.out + del /Q *.cod *.da *.bb *.bbg gmon.out del /Q sqlite3.h opcodes.c opcodes.h del /Q lemon.exe lempar.c parse.* del /Q mkkeywordhash.exe keywordhash.h diff --git a/manifest b/manifest index 6da51c9843..ea4e76fd56 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C When\sconverting\sfrom\sa\sBLOB\svalue\sin\sthe\stointeger()\sand\storeal()\sSQL\sfunctions,\smake\ssure\sthat\sendianness\sof\sthe\smachine\sdoes\snot\smatter. -D 2013-09-06T20:30:53.365 +C Add\sthe\sability\sto\sgenerate\sassembly\slisting\sfiles\susing\sthe\sMSVC\smakefile. +D 2013-09-06T21:41:11.484 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc a97163524522cd829cb91bcf900d07608e025502 +F Makefile.msc bf73c5d1f39a132901cc0a9aea88e724cd0340ad F Makefile.vxworks db21ed42a01d5740e656b16f92cb5d8d5e5dd315 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION a8d1f6839521130dc73c5408cdd24bcfd791df34 @@ -1110,7 +1110,7 @@ F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/wherecosttest.c f407dc4c79786982a475261866a161cd007947ae F tool/win/sqlite.vsix 97894c2790eda7b5bce3cc79cb2a8ec2fde9b3ac -P e1814452faa698946ef77f06a42665277ee59cc1 -R 134c8f8ed3149356b5cf5475063a56e8 +P 94c4cdc50d2753c859e494d53cebd09edd2e5663 +R 6b551c6dae3914b271288c70374acb57 U mistachkin -Z b7db7274557533e42de3d2876d1a3f58 +Z c5c612cbd00cecdaa9ef5d871289b004 diff --git a/manifest.uuid b/manifest.uuid index 95adfb0cad..aec120a35d 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -94c4cdc50d2753c859e494d53cebd09edd2e5663 \ No newline at end of file +6caa2cd10421a85db6740fb2ae8a42b573959562 \ No newline at end of file From e71e0603c57f0d73ead94fdde6042454f4c5729a Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 11 Oct 2013 05:51:15 +0000 Subject: [PATCH 18/42] Fix compilation issue for WinRT. FossilOrigin-Name: 7a2006ca94c458c7b1eae7b2b6df51da67546462 --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/os_win.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 81b99da581..e4f18467ea 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\srule\sto\sthe\smain.mk\smakefile\sfor\sbuilding\sshowdb. -D 2013-10-10T17:33:52.465 +C Fix\scompilation\sissue\sfor\sWinRT. +D 2013-10-11T05:51:15.854 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -204,7 +204,7 @@ F src/os.c b4ad71336fd96f97776f75587cd9e8218288f5be F src/os.h 4a46270a64e9193af4a0aaa3bc2c66dc07c29b3f F src/os_common.h 92815ed65f805560b66166e3583470ff94478f04 F src/os_unix.c 243fb37f47dc072fc59839ea241ff0a17c8d76e6 -F src/os_win.c b8f54f42d9c232c48cb694b7dbe94e601c816b5c +F src/os_win.c 0fea05bc7b75eccb01d8a8a10aaeaf4147b8e0cd F src/pager.c 2aa4444ffe86e9282d03bc349a4a5e49bd77c0e8 F src/pager.h f094af9f6ececfaa8a1e93876905a4f34233fb0c F src/parse.y a97566d6da75075589a7c716d1bda14b586cf8da @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P af7abebeb1f70466833bc766d294d721eaef746f -R 72ea412e1f005785e4d9ffe166caaf06 -U drh -Z 5e82c322ecc9e035c3abfaf4bdd53129 +P fc5552da0d3c41aea58292d267c247f9ca8ed474 +R 84fe925337bfa03eb6ac40832327358d +U mistachkin +Z bbc636d652c3d5a123c35b456ae25f1e diff --git a/manifest.uuid b/manifest.uuid index 9d26a0616b..d2c8ee24bd 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fc5552da0d3c41aea58292d267c247f9ca8ed474 \ No newline at end of file +7a2006ca94c458c7b1eae7b2b6df51da67546462 \ No newline at end of file diff --git a/src/os_win.c b/src/os_win.c index 1e9ee02380..e1ed22c333 100644 --- a/src/os_win.c +++ b/src/os_win.c @@ -682,7 +682,7 @@ static struct win_syscall { #define osGetVersionExA ((BOOL(WINAPI*)( \ LPOSVERSIONINFOA))aSyscall[34].pCurrent) -#if defined(SQLITE_WIN32_HAS_WIDE) +#if !SQLITE_OS_WINRT && defined(SQLITE_WIN32_HAS_WIDE) { "GetVersionExW", (SYSCALL)GetVersionExW, 0 }, #else { "GetVersionExW", (SYSCALL)0, 0 }, From 80e0b72e8def34ee3b807e4b2e89519a3e590519 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 11 Oct 2013 13:27:26 +0000 Subject: [PATCH 19/42] Make sure the sqlite3.h file occurs at the very top of the sqlite3.c amalgamation. FossilOrigin-Name: 03593817ab5abdd4bbaa5e47e2e4745eef025af9 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/sqliteInt.h | 2 +- tool/mksqlite3c.tcl | 2 ++ 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index e4f18467ea..5280e87603 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompilation\sissue\sfor\sWinRT. -D 2013-10-11T05:51:15.854 +C Make\ssure\sthe\ssqlite3.h\sfile\soccurs\sat\sthe\svery\stop\sof\sthe\ssqlite3.c\namalgamation. +D 2013-10-11T13:27:26.997 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -222,7 +222,7 @@ F src/shell.c 5ee50ca3e35453bbd6ccdf1bdd0f6bbe9738e9fb F src/sqlite.h.in ec40aa958a270416fb04b4f72210357bf163d2c5 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc -F src/sqliteInt.h 5dbfc960fb39dbb55ba16697f453b03cd759b04a +F src/sqliteInt.h eeebd2522bbd5ac7e3024be64113e8366caa66c8 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -1093,7 +1093,7 @@ F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e F tool/mkpragmatab.tcl ceaaeebcd882864caefe4176592ca6fa4648fab1 F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02 -F tool/mksqlite3c.tcl d344cc3144a0271cd853c5e3df36e9f31d78d619 +F tool/mksqlite3c.tcl d8dc444d403019167260e5578f5c362741f03696 F tool/mksqlite3h.tcl ba24038056f51fde07c0079c41885ab85e2cff12 F tool/mksqlite3internalh.tcl 3dca7bb5374cee003379b8cbac73714f610ef795 F tool/mkvsix.tcl f3312df26fd9938a27fa0a845ec96bea84b0c16b @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P fc5552da0d3c41aea58292d267c247f9ca8ed474 -R 84fe925337bfa03eb6ac40832327358d -U mistachkin -Z bbc636d652c3d5a123c35b456ae25f1e +P 7a2006ca94c458c7b1eae7b2b6df51da67546462 +R 38f19be9ac5880c5287ba4258503ff24 +U drh +Z d014af66fac4fdf12353ef13980d354d diff --git a/manifest.uuid b/manifest.uuid index d2c8ee24bd..724041ad6b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7a2006ca94c458c7b1eae7b2b6df51da67546462 \ No newline at end of file +03593817ab5abdd4bbaa5e47e2e4745eef025af9 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index b02fb12b26..17e9348af1 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -12,6 +12,7 @@ ** Internal interface definitions for SQLite. ** */ +#include "sqlite3.h" #ifndef _SQLITEINT_H_ #define _SQLITEINT_H_ @@ -305,7 +306,6 @@ #define likely(X) (X) #define unlikely(X) (X) -#include "sqlite3.h" #include "hash.h" #include "parse.h" #include diff --git a/tool/mksqlite3c.tcl b/tool/mksqlite3c.tcl index 343f606cfe..3f42da549d 100644 --- a/tool/mksqlite3c.tcl +++ b/tool/mksqlite3c.tcl @@ -120,6 +120,7 @@ foreach hdr { set available_hdr($hdr) 1 } set available_hdr(sqliteInt.h) 0 +set available_hdr(sqlite3.h) 0 # 78 stars used for comment formatting. set s78 \ @@ -227,6 +228,7 @@ proc copy_file {filename} { # inlining opportunities. # foreach file { + sqlite3.h sqliteInt.h global.c From 4f991890510bbc30a83f1ef1f70c080a09b45b1a Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 11 Oct 2013 15:05:05 +0000 Subject: [PATCH 20/42] Fix various harmless compiler warnings. Change the "warnings.sh" script to work with STAT4 instead of STAT3. FossilOrigin-Name: 7df06684ab36bfdad9e9aca6940b7a665c2a0cb5 --- ext/fts3/fts3.c | 2 +- ext/misc/vfslog.c | 5 +++++ manifest | 24 ++++++++++++------------ manifest.uuid | 2 +- src/analyze.c | 14 +++++++++++++- src/build.c | 2 +- src/vdbemem.c | 5 ++++- src/where.c | 17 ++++++++++------- tool/warnings.sh | 4 ++-- 9 files changed, 49 insertions(+), 26 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 192e329659..6f2ba13363 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -4327,7 +4327,7 @@ static int fts3EvalIncrPhraseNext( while( bEof==0 ){ int bMaxSet = 0; - sqlite3_int64 iMax; /* Largest docid for all iterators */ + sqlite3_int64 iMax = 0; /* Largest docid for all iterators */ int i; /* Used to iterate through tokens */ /* Advance the iterator for each token in the phrase once. */ diff --git a/ext/misc/vfslog.c b/ext/misc/vfslog.c index 2f7c492f80..7cc1083303 100644 --- a/ext/misc/vfslog.c +++ b/ext/misc/vfslog.c @@ -30,6 +30,9 @@ #include #include #include +#if SQLITE_OS_UNIX +# include +#endif /* ** Forward declaration of objects used by this utility @@ -284,11 +287,13 @@ static VLogLog *vlogLogOpen(const char *zFilename){ if( pTemp ){ sqlite3_free(pTemp); }else{ +#if SQLITE_OS_UNIX char zHost[200]; zHost[0] = 0; gethostname(zHost, sizeof(zHost)-1); zHost[sizeof(zHost)-1] = 0; vlogLogPrint(pLog, tNow, 0, "IDENT", getpid(), -1, zHost, 0); +#endif } if( pLog && isJournal ) pLog++; pLog->nRef++; diff --git a/manifest b/manifest index 5280e87603..11c834a877 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssure\sthe\ssqlite3.h\sfile\soccurs\sat\sthe\svery\stop\sof\sthe\ssqlite3.c\namalgamation. -D 2013-10-11T13:27:26.997 +C Fix\svarious\sharmless\scompiler\swarnings.\s\sChange\sthe\s"warnings.sh"\sscript\sto\nwork\swith\sSTAT4\sinstead\sof\sSTAT3. +D 2013-10-11T15:05:05.066 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -78,7 +78,7 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 543cbd7322822ea5dbbe6c17fdecf830c51dcb1c +F ext/fts3/fts3.c 1864684d2fafa3988f144e421340246e064c8f71 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 8689f7cf85020e7f88d1e761eeac480c3b0ea7ad F ext/fts3/fts3_aux.c b02632f6dd0e375ce97870206d914ea6d8df5ccd @@ -115,7 +115,7 @@ F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a F ext/misc/spellfix.c 5e1d547e9a2aed13897fa91bac924333f62fd2d9 -F ext/misc/vfslog.c e8a9e57c9e9bb2c4f730d04ada96722dffcc85ee +F ext/misc/vfslog.c 1abb192d8d4bd323adbddec0c024580496b51b7a F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 F ext/rtree/README 6315c0d73ebf0ec40dedb5aa0e942bc8b54e3761 @@ -158,7 +158,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c 2af0330bb1b601af7a7789bf7229675fd772a083 -F src/analyze.c 4383cd3ceeb1c93de4b142b11761e85294ce2c41 +F src/analyze.c f9e4eec962f2d81d775d8d5c2efb27b84acb0be0 F src/attach.c 0a17c9364895316ca4f52d06a97a72c0af1ae8b3 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 2f1987981139bd2f6d8c728d64bf09fb387443c3 @@ -167,7 +167,7 @@ F src/btmutex.c 976f45a12e37293e32cae0281b15a21d48a8aaa7 F src/btree.c d5720cbb21ae56e7e5b07847e05e5b203818acac F src/btree.h bfe0e8c5759b4ec77b0d18390064a6ef3cdffaaf F src/btreeInt.h f038e818bfadf75afbd09819ed93c26a333d39e0 -F src/build.c 3da02c07b0f198a11ce3766cd34eac311656f1e8 +F src/build.c 8ae900bf021a66ac110f5eb2dcf994d24d1c2061 F src/callback.c f99a8957ba2adf369645fac0db09ad8adcf1caa2 F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c ea4b7f3623a0fcb1146e7f245d7410033e86859c @@ -284,14 +284,14 @@ F src/vdbeInt.h ff57f67aee1ba26a3a47e786533dab155ab6dad6 F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed F src/vdbeaux.c 55f4858fe6abd84bd7311acbf30a75a28903ec25 F src/vdbeblob.c 5dc79627775bd9a9b494dd956e26297946417d69 -F src/vdbemem.c 817ce21ab4ca57f902619bb8fef3f8a51bbd0ed8 +F src/vdbemem.c 28730af78c730cf230b64d62757a009668e76444 F src/vdbesort.c 3937e06b2a0e354500e17dc206ef4c35770a5017 F src/vdbetrace.c e7ec40e1999ff3c6414424365d5941178966dcbc F src/vtab.c 5a423b042eb1402ef77697d03d6a67378d97bc8d F src/wal.c 7dc3966ef98b74422267e7e6e46e07ff6c6eb1b4 F src/wal.h df01efe09c5cb8c8e391ff1715cca294f89668a4 F src/walker.c e9e593d5bb798c3e67fc3893dfe7055c9e7d8d74 -F src/where.c 8dd4cb208b9b70beeb9da7dbcd9b8b8b08261ed7 +F src/where.c dd2d0d69280d6653d8ef8cf3b6b4b848b9058197 F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/aggnested.test 45c0201e28045ad38a530b5a144b73cd4aa2cfd6 @@ -1121,9 +1121,9 @@ F tool/symbols.sh fec58532668296d7c7dc48be9c87f75ccdb5814f F tool/tostr.awk e75472c2f98dd76e06b8c9c1367f4ab07e122d06 F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 -F tool/warnings.sh fbc018d67fd7395f440c28f33ef0f94420226381 +F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 7a2006ca94c458c7b1eae7b2b6df51da67546462 -R 38f19be9ac5880c5287ba4258503ff24 +P 03593817ab5abdd4bbaa5e47e2e4745eef025af9 +R 69bfe11e608e913aa8e62a6f442097f3 U drh -Z d014af66fac4fdf12353ef13980d354d +Z 351cca8cdf907d3e0b7192caaf766811 diff --git a/manifest.uuid b/manifest.uuid index 724041ad6b..106229245a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -03593817ab5abdd4bbaa5e47e2e4745eef025af9 \ No newline at end of file +7df06684ab36bfdad9e9aca6940b7a665c2a0cb5 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index c83133a4df..98687f5ac3 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -589,6 +589,11 @@ static void samplePushPrevious(Stat4Accum *p, int iChng){ } } #endif + +#ifndef SQLITE_ENABLE_STAT3_OR_STAT4 + UNUSED_PARAMETER( p ); + UNUSED_PARAMETER( iChng ); +#endif } /* @@ -614,6 +619,8 @@ static void statPush( Stat4Accum *p = (Stat4Accum*)sqlite3_value_blob(argv[0]); int iChng = sqlite3_value_int(argv[1]); + UNUSED_PARAMETER( argc ); + UNUSED_PARAMETER( context ); assert( p->nCol>1 ); /* Includes rowid field */ assert( iChngnCol ); @@ -799,6 +806,9 @@ static void statGet( } } #endif /* SQLITE_ENABLE_STAT3_OR_STAT4 */ +#ifndef SQLITE_DEBUG + UNUSED_PARAMETER( argc ); +#endif } static const FuncDef statGetFuncdef = { 1+IsStat34, /* nArg */ @@ -817,8 +827,10 @@ static void callStatGet(Vdbe *v, int regStat4, int iParam, int regOut){ assert( regOut!=regStat4 && regOut!=regStat4+1 ); #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 sqlite3VdbeAddOp2(v, OP_Integer, iParam, regStat4+1); -#else +#elif SQLITE_DEBUG assert( iParam==STAT_GET_STAT1 ); +#else + UNUSED_PARAMETER( iParam ); #endif sqlite3VdbeAddOp3(v, OP_Function, 0, regStat4, regOut); sqlite3VdbeChangeP4(v, -1, (char*)&statGetFuncdef, P4_FUNCDEF); diff --git a/src/build.c b/src/build.c index e14988ae1f..6868e60e0f 100644 --- a/src/build.c +++ b/src/build.c @@ -1113,7 +1113,7 @@ char sqlite3AffinityType(const char *zIn, u8 *pszEst){ if( zChar ){ while( zChar[0] ){ if( sqlite3Isdigit(zChar[0]) ){ - int v; + int v = 0; sqlite3GetInt32(zChar, &v); v = v/4 + 1; if( v>255 ) v = 255; diff --git a/src/vdbemem.c b/src/vdbemem.c index 95a8798712..91193bf2cf 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1059,7 +1059,9 @@ static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){ pRec->nField = p->iVal+1; return &pRec->aMem[p->iVal]; } -#endif +#else + UNUSED_PARAMETER(p); +#endif /* defined(SQLITE_ENABLE_STAT3_OR_STAT4) */ return sqlite3ValueNew(db); } @@ -1230,6 +1232,7 @@ static void recordFunc( sqlite3 *db; u8 *aRet; + UNUSED_PARAMETER( argc ); iSerial = sqlite3VdbeSerialType(argv[0], file_format); nSerial = sqlite3VarintLen(iSerial); nVal = sqlite3VdbeSerialTypeLen(iSerial); diff --git a/src/where.c b/src/where.c index 545dee2d29..d89ce65137 100644 --- a/src/where.c +++ b/src/where.c @@ -2337,6 +2337,9 @@ static void whereKeyStats( int iTest; /* Next sample to test */ int res; /* Result of comparison operation */ +#ifndef SQLITE_DEBUG + UNUSED_PARAMETER( pParse ); +#endif assert( pRec!=0 || pParse->db->mallocFailed ); if( pRec==0 ) return; iCol = pRec->nField - 1; @@ -2454,11 +2457,11 @@ static int whereRangeScanEst( ){ int rc = SQLITE_OK; int nOut = pLoop->nOut; - int nEq = pLoop->u.btree.nEq; LogEst nNew; #ifdef SQLITE_ENABLE_STAT3_OR_STAT4 Index *p = pLoop->u.btree.pIndex; + int nEq = pLoop->u.btree.nEq; if( p->nSample>0 && nEq==pBuilder->nRecValid @@ -4182,7 +4185,7 @@ whereLoopInsert_noop: ** the number of output rows by a factor of 10 and each additional term ** reduces the number of output rows by sqrt(2). */ -static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop, int iCur){ +static void whereLoopOutputAdjust(WhereClause *pWC, WhereLoop *pLoop){ WhereTerm *pTerm, *pX; Bitmask notAllowed = ~(pLoop->prereq|pLoop->maskSelf); int i, j; @@ -4357,8 +4360,8 @@ static int whereLoopAddBtreeIndex( } assert( nOut==0 || rc==SQLITE_OK ); if( nOut ){ - nOut = sqlite3LogEst(nOut); - pNew->nOut = MIN(nOut, saved_nOut); + pNew->nOut = sqlite3LogEst(nOut); + if( pNew->nOut>saved_nOut ) pNew->nOut = saved_nOut; } } #endif @@ -4369,7 +4372,7 @@ static int whereLoopAddBtreeIndex( } /* Step cost for each output row */ pNew->rRun = sqlite3LogEstAdd(pNew->rRun, pNew->nOut); - whereLoopOutputAdjust(pBuilder->pWC, pNew, pSrc->iCursor); + whereLoopOutputAdjust(pBuilder->pWC, pNew); rc = whereLoopInsert(pBuilder, pNew); if( (pNew->wsFlags & WHERE_TOP_LIMIT)==0 && pNew->u.btree.nEq<(pProbe->nColumn + (pProbe->zName!=0)) @@ -4573,7 +4576,7 @@ static int whereLoopAddBtree( ** + The extra 3 factor is to encourage the use of indexed lookups ** over full scans. FIXME */ pNew->rRun = sqlite3LogEstAdd(rSize,rLogSize) + 16; - whereLoopOutputAdjust(pWC, pNew, pSrc->iCursor); + whereLoopOutputAdjust(pWC, pNew); rc = whereLoopInsert(pBuilder, pNew); pNew->nOut = rSize; if( rc ) break; @@ -4606,7 +4609,7 @@ static int whereLoopAddBtree( ** which we will simplify to just N*log2(N) */ pNew->rRun = rSize + rLogSize; } - whereLoopOutputAdjust(pWC, pNew, pSrc->iCursor); + whereLoopOutputAdjust(pWC, pNew); rc = whereLoopInsert(pBuilder, pNew); pNew->nOut = rSize; if( rc ) break; diff --git a/tool/warnings.sh b/tool/warnings.sh index 78cfb55d3a..246bccbe23 100644 --- a/tool/warnings.sh +++ b/tool/warnings.sh @@ -9,9 +9,9 @@ echo '********** No optimizations. Includes FTS4 and RTREE *********' gcc -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ -ansi -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \ sqlite3.c -echo '********** No optimizations. ENABLE_STAT3. THREADSAFE=0 *******' +echo '********** No optimizations. ENABLE_STAT4. THREADSAFE=0 *******' gcc -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ - -ansi -DSQLITE_ENABLE_STAT3 -DSQLITE_THREADSAFE=0 \ + -ansi -DSQLITE_ENABLE_STAT4 -DSQLITE_THREADSAFE=0 \ sqlite3.c echo '********** Optimized -O3. Includes FTS4 and RTREE ************' gcc -O3 -c -Wshadow -Wall -Wextra -pedantic-errors -Wno-long-long -std=c89 \ From 3432daa8b2ec4cde8291a35f13a2cd887e6b8c67 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 11 Oct 2013 16:35:49 +0000 Subject: [PATCH 21/42] Additional test cases and requirements marks for the unlikely(), likelihood() and instr() functions. FossilOrigin-Name: 5f01cd36ee8678a07b79f9e01855daffb6bb8c43 --- manifest | 20 ++++++------ manifest.uuid | 2 +- src/resolve.c | 4 +++ src/shell.c | 2 +- test/func.test | 8 +++++ test/func3.test | 83 +++++++++++++++++++++++++++++++++++++++++++++++++ test/instr.test | 45 +++++++++++++++++++++++++-- 7 files changed, 150 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index 11c834a877..e7be7f74a7 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\svarious\sharmless\scompiler\swarnings.\s\sChange\sthe\s"warnings.sh"\sscript\sto\nwork\swith\sSTAT4\sinstead\sof\sSTAT3. -D 2013-10-11T15:05:05.066 +C Additional\stest\scases\sand\srequirements\smarks\sfor\sthe\sunlikely(),\nlikelihood()\sand\sinstr()\sfunctions. +D 2013-10-11T16:35:49.710 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -215,10 +215,10 @@ F src/pragma.c f4ff6e29c316d06bf7dffca0c8cee7c229cae42e F src/prepare.c fa6988589f39af8504a61731614cd4f6ae71554f F src/printf.c da9119eb31a187a4b99f60aa4a225141c0ebb74b F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68 -F src/resolve.c 7459801d02997b07e8b8da85ef255392ba1d022b +F src/resolve.c 5f15b00644c36a1610b87857abf42db38c07519c F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c 15127b54cc11defb2cddef6914e1f384501a61c4 -F src/shell.c 5ee50ca3e35453bbd6ccdf1bdd0f6bbe9738e9fb +F src/shell.c 6f11f0e9ded63d48e306f2c6858c521e568a47bb F src/sqlite.h.in ec40aa958a270416fb04b4f72210357bf163d2c5 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc @@ -566,9 +566,9 @@ F test/fts4merge4.test c19c85ca1faa7b6d536832b49c12e1867235f584 F test/fts4noti.test aed33ba44808852dcb24bf70fa132e7bf530f057 F test/fts4unicode.test ebd937061e1ce096240d2352feb424587f2187b9 F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d -F test/func.test cd25cf605c5a345d038dc7b84232204c6a901c84 +F test/func.test c7e80a44eebac8604397eb2ad83d0d5d9d541237 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f -F test/func3.test 001021e5b88bd02a3b365a5c5fd8f6f49d39744a +F test/func3.test dbccee9133cfef1473c59ec07b5f0262b9d72f9a F test/fuzz-oss1.test 4912e528ec9cf2f42134456933659d371c9e0d74 F test/fuzz.test 77fd50afc12847af50fcf1941679d90adebadde6 F test/fuzz2.test 207d0f9d06db3eaf47a6b7bfc835b8e2fc397167 @@ -609,7 +609,7 @@ F test/insert2.test 4f3a04d168c728ed5ec2c88842e772606c7ce435 F test/insert3.test 1b7db95a03ad9c5013fdf7d6722b6cd66ee55e30 F test/insert4.test 87f6798f31d60c4e177622fcc3663367e6ecbd90 F test/insert5.test 394f96728d1258f406fe5f5aeb0aaf29487c39a6 -F test/instr.test a34e1d46a9eefb098a7167ef0e730a4a3d82fba0 +F test/instr.test 737bbf80685232033f3abedc6ae92f75860b5dd2 F test/intarray.test 066b7d7ac38d25bf96f87f1b017bfc687551cdd4 F test/interrupt.test dfe9a67a94b0b2d8f70545ba1a6cca10780d71cc F test/intpkey.test a9674fc6195e0952e4e6105a9981ce1e48e7f215 @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 03593817ab5abdd4bbaa5e47e2e4745eef025af9 -R 69bfe11e608e913aa8e62a6f442097f3 +P 7df06684ab36bfdad9e9aca6940b7a665c2a0cb5 +R 4f6661cda267d0bd057e23bc72d2b257 U drh -Z 351cca8cdf907d3e0b7192caaf766811 +Z 03f2ce5f38a3f7315fba8a787fd51abf diff --git a/manifest.uuid b/manifest.uuid index 106229245a..6b65ca082a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7df06684ab36bfdad9e9aca6940b7a665c2a0cb5 \ No newline at end of file +5f01cd36ee8678a07b79f9e01855daffb6bb8c43 \ No newline at end of file diff --git a/src/resolve.c b/src/resolve.c index eacffc5406..dfe4b84c47 100644 --- a/src/resolve.c +++ b/src/resolve.c @@ -707,6 +707,10 @@ static int resolveExprStep(Walker *pWalker, Expr *pExpr){ pNC->nErr++; } }else{ + /* EVIDENCE-OF: R-61304-29449 The unlikely(X) function is equivalent to + ** likelihood(X, 0.0625). + ** EVIDENCE-OF: R-35738-39582 The unlikely(X) fucntion is short-hand for + ** likelihood(X,0.0625). */ pExpr->iTable = 62; /* TUNING: Default 2nd arg to unlikely() is 0.0625 */ } } diff --git a/src/shell.c b/src/shell.c index 9f0e3530bc..41ea56492e 100644 --- a/src/shell.c +++ b/src/shell.c @@ -1204,7 +1204,7 @@ static int shell_exec( /* extract the data and data types */ for(i=0; imode==MODE_Insert ){ + if( x==SQLITE_BLOB && pArg && pArg->mode==MODE_Insert ){ azVals[i] = ""; }else{ azVals[i] = (char*)sqlite3_column_text(pStmt, i); diff --git a/test/func.test b/test/func.test index d8303f8bf3..7c7d55e1b7 100644 --- a/test/func.test +++ b/test/func.test @@ -1319,6 +1319,14 @@ do_test func-29.6 { set x } {1} +# EVIDENCE-OF: R-29701-50711 The unicode(X) function returns the numeric +# unicode code point corresponding to the first character of the string +# X. +# +# EVIDENCE-OF: R-55469-62130 The char(X1,X2,...,XN) function returns a +# string composed of characters having the unicode code point values of +# integers X1 through XN, respectively. +# do_execsql_test func-30.1 {SELECT unicode('$');} 36 do_execsql_test func-30.2 [subst {SELECT unicode('\u00A2');}] 162 do_execsql_test func-30.3 [subst {SELECT unicode('\u20AC');}] 8364 diff --git a/test/func3.test b/test/func3.test index d5a462fe33..2a2b7be4f4 100644 --- a/test/func3.test +++ b/test/func3.test @@ -70,4 +70,87 @@ do_test func3-4.1 { } {1 SQLITE_MISUSE} do_test func3-4.2 { set destroyed } 1 +# EVIDENCE-OF: R-41921-05214 The likelihood(X,Y) function returns +# argument X unchanged. +# +do_execsql_test func3-5.1 { + SELECT likelihood(9223372036854775807, 0.5); +} {9223372036854775807} +do_execsql_test func3-5.2 { + SELECT likelihood(-9223372036854775808, 0.5); +} {-9223372036854775808} +do_execsql_test func3-5.3 { + SELECT likelihood(14.125, 0.5); +} {14.125} +do_execsql_test func3-5.4 { + SELECT likelihood(NULL, 0.5); +} {{}} +do_execsql_test func3-5.5 { + SELECT likelihood('test-string', 0.5); +} {test-string} +do_execsql_test func3-5.6 { + SELECT quote(likelihood(x'010203000405', 0.5)); +} {X'010203000405'} + +# EVIDENCE-OF: R-44133-61651 The value Y in likelihood(X,Y) must be a +# floating point constant between 0.0 and 1.0, inclusive. +# +do_execsql_test func3-5.7 { + SELECT likelihood(123, 1.0), likelihood(456, 0.0); +} {123 456} +do_test func3-5.8 { + catchsql { + SELECT likelihood(123, 1.000001); + } +} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}} +do_test func3-5.9 { + catchsql { + SELECT likelihood(123, -0.000001); + } +} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}} +do_test func3-5.10 { + catchsql { + SELECT likelihood(123, 0.5+0.3); + } +} {1 {second argument to likelihood() must be a constant between 0.0 and 1.0}} + +# EVIDENCE-OF: R-28535-44631 The likelihood(X) function is a no-op that +# the code generator optimizes away so that it consumes no CPU cycles +# during run-time (that is, during calls to sqlite3_step()). +# +do_test func3-5.20 { + db eval {EXPLAIN SELECT likelihood(min(1.0+'2.0',4*11), 0.5)} +} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}] + + +# EVIDENCE-OF: R-11152-23456 The unlikely(X) function returns the +# argument X unchanged. +# +do_execsql_test func3-5.30 { + SELECT unlikely(9223372036854775807); +} {9223372036854775807} +do_execsql_test func3-5.31 { + SELECT unlikely(-9223372036854775808); +} {-9223372036854775808} +do_execsql_test func3-5.32 { + SELECT unlikely(14.125); +} {14.125} +do_execsql_test func3-5.33 { + SELECT unlikely(NULL); +} {{}} +do_execsql_test func3-5.34 { + SELECT unlikely('test-string'); +} {test-string} +do_execsql_test func3-5.35 { + SELECT quote(unlikely(x'010203000405')); +} {X'010203000405'} + +# EVIDENCE-OF: R-22887-63324 The unlikely(X) function is a no-op that +# the code generator optimizes away so that it consumes no CPU cycles at +# run-time (that is, during calls to sqlite3_step()). +# +do_test func3-5.40 { + db eval {EXPLAIN SELECT unlikely(min(1.0+'2.0',4*11))} +} [db eval {EXPLAIN SELECT min(1.0+'2.0',4*11)}] + finish_test diff --git a/test/instr.test b/test/instr.test index b328cd1d2d..c8be4862b9 100644 --- a/test/instr.test +++ b/test/instr.test @@ -11,6 +11,11 @@ # This file implements regression tests for SQLite library. The # focus of this file is testing the built-in INSTR() functions. # +# EVIDENCE-OF: R-27549-59611 The instr(X,Y) function finds the first +# occurrence of string Y within string X and returns the number of prior +# characters plus 1, or 0 if Y is nowhere found within X. +# + set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -199,12 +204,48 @@ do_test instr-1.54 { do_test instr-1.55 { db eval {SELECT instr(x'78c3a4e282ac79','y');} } {4} -do_test instr-1.56 { + +# EVIDENCE-OF: R-46421-32541 Or, if X and Y are both BLOBs, then +# instr(X,Y) returns one more than the number bytes prior to the first +# occurrence of Y, or 0 if Y does not occur anywhere within X. +# +do_test instr-1.56.1 { db eval {SELECT instr(x'78c3a4e282ac79',x'79');} } {7} -do_test instr-1.57 { +do_test instr-1.56.2 { + db eval {SELECT instr(x'78c3a4e282ac79',x'7a');} +} {0} +do_test instr-1.56.3 { + db eval {SELECT instr(x'78c3a4e282ac79',x'78');} +} {1} +do_test instr-1.56.3 { + db eval {SELECT instr(x'78c3a4e282ac79',x'a4');} +} {3} + +# EVIDENCE-OF: R-17329-35644 If both arguments X and Y to instr(X,Y) are +# non-NULL and are not BLOBs then both are interpreted as strings. +# +do_test instr-1.57.1 { db eval {SELECT instr('xä€y',x'79');} } {4} +do_test instr-1.57.2 { + db eval {SELECT instr('xä€y',x'a4');} +} {0} +do_test instr-1.57.3 { + db eval {SELECT instr(x'78c3a4e282ac79','y');} +} {4} +# EVIDENCE-OF: R-14708-27487 If either X or Y are NULL in instr(X,Y) +# then the result is NULL. +# +do_execsql_test instr-1.60 { + SELECT coalesce(instr(NULL,'abc'), 999); +} {999} +do_execsql_test instr-1.61 { + SELECT coalesce(instr('abc',NULL), 999); +} {999} +do_execsql_test instr-1.62 { + SELECT coalesce(instr(NULL,NULL), 999); +} {999} finish_test From e4bf4f08c01c5d0cc2fe92db134abf5c74e9d568 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 11 Oct 2013 20:14:37 +0000 Subject: [PATCH 22/42] Add requirements marks. No code changes. FossilOrigin-Name: 5e0d43ab55de006b20c58cb18b938d1c7b658e51 --- manifest | 20 ++++++++++---------- manifest.uuid | 2 +- src/date.c | 9 +++++++++ test/date.test | 4 ++++ test/fkey5.test | 19 +++++++++++++++++++ test/fkey6.test | 11 +++++++++++ test/pragma2.test | 10 ++++++++++ 7 files changed, 64 insertions(+), 11 deletions(-) diff --git a/manifest b/manifest index e7be7f74a7..5250a5d48f 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Additional\stest\scases\sand\srequirements\smarks\sfor\sthe\sunlikely(),\nlikelihood()\sand\sinstr()\sfunctions. -D 2013-10-11T16:35:49.710 +C Add\srequirements\smarks.\s\sNo\scode\schanges. +D 2013-10-11T20:14:37.415 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -171,7 +171,7 @@ F src/build.c 8ae900bf021a66ac110f5eb2dcf994d24d1c2061 F src/callback.c f99a8957ba2adf369645fac0db09ad8adcf1caa2 F src/complete.c dc1d136c0feee03c2f7550bafc0d29075e36deac F src/ctime.c ea4b7f3623a0fcb1146e7f245d7410033e86859c -F src/date.c 65196e95e69f36993659bd7781abe7c2f1994739 +F src/date.c 593c744b2623971e45affd0bde347631bdfa4625 F src/delete.c 45788c5e48734f2af4acd75a876466e5b9838e34 F src/expr.c e7338ccffdc391c53ba2d51c5eb6a2f5299e040e F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb @@ -415,7 +415,7 @@ F test/crashtest1.c 09c1c7d728ccf4feb9e481671e29dda5669bbcc2 F test/createtab.test b5de160630b209c4b8925bdcbbaf48cc90b67fe8 F test/cse.test 277350a26264495e86b1785f34d2d0c8600e021c F test/ctime.test 7bd009071e242aac4f18521581536b652b789a47 -F test/date.test 502ddcbaaac9ce103bcd76d8e9d9bc8aa04e61b0 +F test/date.test 42973251b9429f2c41b77eb98a7b0b0ba2d3b2c0 F test/dbstatus.test aee30c3f337e6c217ff06df59fb8fe6e6448dce2 F test/dbstatus2.test 10418e62b3db5dca070f0c3eef3ea13946f339c2 F test/default.test 6faf23ccb300114924353007795aa9a8ec0aa9dc @@ -462,8 +462,8 @@ F test/fkey1.test e1d1fa84cde579185ea01358436839703e415a5b F test/fkey2.test 06e0b4cc9e1b3271ae2ae6feeb19755468432111 F test/fkey3.test 5ec899d12b13bcf1e9ef40eff7fb692fdb91392e F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d -F test/fkey5.test 0bf64f2d19ad80433ca0b24edbf604a18b353d5f -F test/fkey6.test c555f7fc45d842cc84b0d3ff93951ce2b8c25fc8 +F test/fkey5.test 2b8c761ad23bb6a95b9cf8366c9a982a80a439c2 +F test/fkey6.test c1d7cb176648e0e1e9f971f5f9bde4dd5bcd046d F test/fkey7.test e31d0e71a41c1d29349a16448d6c420e2c53a8fc F test/fkey_malloc.test bb74c9cb8f8fceed03b58f8a7ef2df98520bbd51 F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb @@ -726,7 +726,7 @@ F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 F test/percentile.test b98fc868d71eb5619d42a1702e9ab91718cbed54 F test/permutations.test e154f5ed66d4d4913a99a110e870c9407f75b055 F test/pragma.test 5c6e8ae9eaa9a505cc1035b51f7f0da9805092c7 -F test/pragma2.test 224f0381f9411a78ae685cac24c13656a62021b7 +F test/pragma2.test aea7b3d82c76034a2df2b38a13745172ddc0bc13 F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552 F test/progress.test a282973d1d17f08071bc58a77d6b80f2a81c354d F test/ptrchng.test ef1aa72d6cf35a2bbd0869a649b744e9d84977fc @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 7df06684ab36bfdad9e9aca6940b7a665c2a0cb5 -R 4f6661cda267d0bd057e23bc72d2b257 +P 5f01cd36ee8678a07b79f9e01855daffb6bb8c43 +R 9bc31ca11c970b0b1f57ebe7aef5f122 U drh -Z 03f2ce5f38a3f7315fba8a787fd51abf +Z e5a31fb8b2987670c6226df61ef5e152 diff --git a/manifest.uuid b/manifest.uuid index 6b65ca082a..48aa688296 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5f01cd36ee8678a07b79f9e01855daffb6bb8c43 \ No newline at end of file +5e0d43ab55de006b20c58cb18b938d1c7b658e51 \ No newline at end of file diff --git a/src/date.c b/src/date.c index 5fe3f67867..f8f4ee0a6b 100644 --- a/src/date.c +++ b/src/date.c @@ -426,6 +426,10 @@ static void clearYMD_HMS_TZ(DateTime *p){ ** ** If the sqlite3GlobalConfig.bLocaltimeFault variable is true then this ** routine will always fail. +** +** EVIDENCE-OF: R-62172-00036 In this implementation, the standard C +** library function localtime_r() is used to assist in the calculation of +** local time. */ static int osLocaltime(time_t *t, struct tm *pTm){ int rc; @@ -482,6 +486,11 @@ static sqlite3_int64 localtimeOffset( x = *p; computeYMD_HMS(&x); if( x.Y<1971 || x.Y>=2038 ){ + /* EVIDENCE-OF: R-55269-29598 The localtime_r() C function normally only + ** works for years between 1970 and 2037. For dates outside this range, + ** SQLite attempts to map the year into an equivalent year within this + ** range, do the calculation, then map the year back. + */ x.Y = 2000; x.M = 1; x.D = 1; diff --git a/test/date.test b/test/date.test index 895b415436..b1d1c677c1 100644 --- a/test/date.test +++ b/test/date.test @@ -532,6 +532,10 @@ if {0==[sqlite3 -has-codec]} { # Verify that multiple calls to date functions with 'now' return the # same answer. # +# EVIDENCE-OF: R-34818-13664 The 'now' argument to date and time +# functions always returns exactly the same value for multiple +# invocations within the same sqlite3_step() call. +# proc sleeper {} {after 100} do_test date-15.1 { db func sleeper sleeper diff --git a/test/fkey5.test b/test/fkey5.test index 40a1a5e961..16efc26685 100644 --- a/test/fkey5.test +++ b/test/fkey5.test @@ -12,6 +12,8 @@ # # This file tests the PRAGMA foreign_key_check command. # +# EVIDENCE-OF: R-05426-18119 PRAGMA foreign_key_check; PRAGMA +# foreign_key_check(table-name); set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -82,6 +84,20 @@ do_test fkey5-1.4 { } } {} +# EVIDENCE-OF: R-45728-08709 There are four columns in each result row. +# +# EVIDENCE-OF: R-55672-01620 The first column is the name of the table +# that contains the REFERENCES clause. +# +# EVIDENCE-OF: R-25219-25618 The second column is the rowid of the row +# that contains the invalid REFERENCES clause. +# +# EVIDENCE-OF: R-40482-20265 The third column is the name of the table +# that is referred to. +# +# EVIDENCE-OF: R-62839-07969 The fourth column is the index of the +# specific foreign key constraint that failed. +# do_test fkey5-2.0 { db eval { INSERT INTO c5 SELECT x FROM c1; @@ -99,6 +115,9 @@ do_test fkey5-2.2 { PRAGMA foreign_key_check(c1); } } {} +do_execsql_test fkey5-2.3 { + PRAGMA foreign_key_list(c5); +} {0 0 p1 x {} {NO ACTION} {NO ACTION} NONE} do_test fkey5-3.0 { db eval { diff --git a/test/fkey6.test b/test/fkey6.test index 10a093f032..1c77c3d051 100644 --- a/test/fkey6.test +++ b/test/fkey6.test @@ -13,6 +13,13 @@ # This file tests the PRAGMA defer_foreign_keys and # SQLITE_DBSTATUS_DEFERRED_FKS # +# EVIDENCE-OF: R-18981-16292 When the defer_foreign_keys PRAGMA is on, +# enforcement of all foreign key constraints is delayed until the +# outermost transaction is committed. +# +# EVIDENCE-OF: R-28911-57501 The defer_foreign_keys pragma defaults to +# OFF so that foreign key constraints are only deferred if they are +# created as "DEFERRABLE INITIALLY DEFERRED". set testdir [file dirname $argv0] source $testdir/tester.tcl @@ -22,6 +29,10 @@ ifcapable {!foreignkey} { return } +do_execsql_test fkey6-1.0 { + PRAGMA defer_foreign_keys; +} {0} + do_execsql_test fkey6-1.1 { PRAGMA foreign_keys=ON; CREATE TABLE t1(x INTEGER PRIMARY KEY); diff --git a/test/pragma2.test b/test/pragma2.test index 85ea962e03..0dbc9777d2 100644 --- a/test/pragma2.test +++ b/test/pragma2.test @@ -119,6 +119,11 @@ ifcapable attach { # Default setting of PRAGMA cache_spill is always ON # +# EVIDENCE-OF: R-51036-62828 PRAGMA cache_spill; PRAGMA +# cache_spill=boolean; +# +# EVIDENCE-OF: R-23955-02765 Cache_spill is enabled by default +# db close delete_file test.db test.db-journal delete_file test2.db test2.db-journal @@ -155,6 +160,11 @@ do_execsql_test pragma2-4.3 { PRAGMA cache_spill=ON; } {} sqlite3_release_memory +# +# EVIDENCE-OF: R-07634-40532 The cache_spill pragma enables or disables +# the ability of the pager to spill dirty cache pages to the database +# file in the middle of a transaction. +# do_test pragma2-4.4 { db eval { BEGIN; From cbc53fec75965f89b8720ae6efc16aa4f2df78f1 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 11 Oct 2013 22:17:39 +0000 Subject: [PATCH 23/42] Fix test numbering. FossilOrigin-Name: cef39f6933dcfec4b4a087a05dbb4e7766003fb7 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/fts4unicode.test | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 5250a5d48f..e0eaf91fdc 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\srequirements\smarks.\s\sNo\scode\schanges. -D 2013-10-11T20:14:37.415 +C Fix\stest\snumbering. +D 2013-10-11T22:17:39.287 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -564,7 +564,7 @@ F test/fts4merge2.test 5faa558d1b672f82b847d2a337465fa745e46891 F test/fts4merge3.test aab02a09f50fe6baaddc2e159c3eabc116d45fc7 F test/fts4merge4.test c19c85ca1faa7b6d536832b49c12e1867235f584 F test/fts4noti.test aed33ba44808852dcb24bf70fa132e7bf530f057 -F test/fts4unicode.test ebd937061e1ce096240d2352feb424587f2187b9 +F test/fts4unicode.test 20195bca1e3a4301924c2c8b46257d64127f17df F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test c7e80a44eebac8604397eb2ad83d0d5d9d541237 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 5f01cd36ee8678a07b79f9e01855daffb6bb8c43 -R 9bc31ca11c970b0b1f57ebe7aef5f122 -U drh -Z e5a31fb8b2987670c6226df61ef5e152 +P 5e0d43ab55de006b20c58cb18b938d1c7b658e51 +R 1b1171afe4edda3c5b3cb5d754aa44ea +U mistachkin +Z 4ee7f0b668ae06fb4348c4967185c786 diff --git a/manifest.uuid b/manifest.uuid index 48aa688296..8f8d83af40 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -5e0d43ab55de006b20c58cb18b938d1c7b658e51 \ No newline at end of file +cef39f6933dcfec4b4a087a05dbb4e7766003fb7 \ No newline at end of file diff --git a/test/fts4unicode.test b/test/fts4unicode.test index f49a9fd2a0..b8b98a327a 100644 --- a/test/fts4unicode.test +++ b/test/fts4unicode.test @@ -378,10 +378,10 @@ foreach T $tokenizers { do_isspace_test 6.$T.18 $T 12288 do_isspace_test 6.$T.19 $T {32 160 5760 6158} - do_isspace_test 6.$T.19 $T {8192 8193 8194 8195} - do_isspace_test 6.$T.19 $T {8196 8197 8198 8199} - do_isspace_test 6.$T.19 $T {8200 8201 8202 8239} - do_isspace_test 6.$T.19 $T {8287 12288} + do_isspace_test 6.$T.20 $T {8192 8193 8194 8195} + do_isspace_test 6.$T.21 $T {8196 8197 8198 8199} + do_isspace_test 6.$T.22 $T {8200 8201 8202 8239} + do_isspace_test 6.$T.23 $T {8287 12288} } #------------------------------------------------------------------------- From 691d4c993650a6ef8616471fc6886403c364088f Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 11 Oct 2013 22:19:55 +0000 Subject: [PATCH 24/42] Add -no-undefined option when linking the shared libraries. FossilOrigin-Name: 977d2b12e5efc70c26129b08c1f6d65c9d6d211e --- Makefile.in | 4 ++-- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Makefile.in b/Makefile.in index a82f4d2e15..91cac6ed37 100644 --- a/Makefile.in +++ b/Makefile.in @@ -500,11 +500,11 @@ sqlite3.pc: $(TOP)/sqlite3.pc.in ./config.status libsqlite3.la: $(LIBOBJ) - $(LTLINK) -o $@ $(LIBOBJ) $(TLIBS) \ + $(LTLINK) -no-undefined -o $@ $(LIBOBJ) $(TLIBS) \ ${ALLOWRELEASE} -rpath "$(libdir)" -version-info "8:6:8" libtclsqlite3.la: tclsqlite.lo libsqlite3.la - $(LTLINK) -o $@ tclsqlite.lo \ + $(LTLINK) -no-undefined -o $@ tclsqlite.lo \ libsqlite3.la @TCL_STUB_LIB_SPEC@ $(TLIBS) \ -rpath "$(TCLLIBDIR)" \ -version-info "8:6:8" \ diff --git a/manifest b/manifest index e0eaf91fdc..390ad71553 100644 --- a/manifest +++ b/manifest @@ -1,7 +1,7 @@ -C Fix\stest\snumbering. -D 2013-10-11T22:17:39.287 +C Add\s-no-undefined\soption\swhen\slinking\sthe\sshared\slibraries. +D 2013-10-11T22:19:55.056 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f -F Makefile.in 5e41da95d92656a5004b03d3576e8b226858a28e +F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 F Makefile.msc 9af063716f726a73b5d5c98c69ea97eca6a9369b F Makefile.vxworks db21ed42a01d5740e656b16f92cb5d8d5e5dd315 @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 5e0d43ab55de006b20c58cb18b938d1c7b658e51 -R 1b1171afe4edda3c5b3cb5d754aa44ea +P cef39f6933dcfec4b4a087a05dbb4e7766003fb7 +R 4b63c8e744f6fb27473896450f836426 U mistachkin -Z 4ee7f0b668ae06fb4348c4967185c786 +Z 3fce88c09247715d1b76fae81385d1b5 diff --git a/manifest.uuid b/manifest.uuid index 8f8d83af40..392ea2dae3 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -cef39f6933dcfec4b4a087a05dbb4e7766003fb7 \ No newline at end of file +977d2b12e5efc70c26129b08c1f6d65c9d6d211e \ No newline at end of file From 2b51f2153b0af25966184de4a9a56091d40f60e6 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 11 Oct 2013 23:01:02 +0000 Subject: [PATCH 25/42] Fix a harmless compiler warning in lemon.c. FossilOrigin-Name: 62959c0ce3a2c486ebd82e6511efad0412b944a0 --- manifest | 14 +++++++------- manifest.uuid | 2 +- tool/lemon.c | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/manifest b/manifest index 390ad71553..97e6aa2b5a 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\s-no-undefined\soption\swhen\slinking\sthe\sshared\slibraries. -D 2013-10-11T22:19:55.056 +C Fix\sa\sharmless\scompiler\swarning\sin\slemon.c. +D 2013-10-11T23:01:02.703 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -1084,7 +1084,7 @@ F tool/fragck.tcl 5265a95126abcf6ab357f7efa544787e5963f439 F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4 F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5 F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce -F tool/lemon.c 323e54ac86fb2393f9950219224e304620d2fb12 +F tool/lemon.c 796930d5fc2036c7636f3f1ee12f9ae03719a2eb F tool/lempar.c 01ca97f87610d1dac6d8cd96ab109ab1130e76dc F tool/logest.c 7ad625cac3d54012b27d468b7af6612f78b9ba75 F tool/mkautoconfamal.sh f8d8dbf7d62f409ebed5134998bf5b51d7266383 @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P cef39f6933dcfec4b4a087a05dbb4e7766003fb7 -R 4b63c8e744f6fb27473896450f836426 -U mistachkin -Z 3fce88c09247715d1b76fae81385d1b5 +P 977d2b12e5efc70c26129b08c1f6d65c9d6d211e +R bcbb126665574af7901e0480e4bce971 +U drh +Z bd333009a6747ce18c3ec43add5f57d2 diff --git a/manifest.uuid b/manifest.uuid index 392ea2dae3..3ac1dcb019 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -977d2b12e5efc70c26129b08c1f6d65c9d6d211e \ No newline at end of file +62959c0ce3a2c486ebd82e6511efad0412b944a0 \ No newline at end of file diff --git a/tool/lemon.c b/tool/lemon.c index ac08250220..58f13880f0 100644 --- a/tool/lemon.c +++ b/tool/lemon.c @@ -3458,7 +3458,7 @@ void print_stack_union( break; } hash++; - if( hash>=arraysize ) hash = 0; + if( hash>=(unsigned)arraysize ) hash = 0; } if( types[hash]==0 ){ sp->dtnum = hash + 1; From 7651091de52c30634fd25f0213821ce4fd8222a4 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 11 Oct 2013 23:01:18 +0000 Subject: [PATCH 26/42] Enhance debugging support for the split amalgamation files when compiling with MSVC. FossilOrigin-Name: 8ff17c553d8c159fa81c961441e16dbba8da62ba --- Makefile.msc | 28 ++++++++++++++++++++++------ main.mk | 2 +- manifest | 16 ++++++++-------- manifest.uuid | 2 +- 4 files changed, 32 insertions(+), 16 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 959ce87de5..0dffd89240 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -13,6 +13,13 @@ TOP = . USE_AMALGAMATION = 1 !ENDIF +# Set this non-0 to split the SQLite amalgamation file into chunks to +# be used for debugging with Visual Studio. +# +!IFNDEF SPLIT_AMALGAMATION +SPLIT_AMALGAMATION = 1 +!ENDIF + # Set this non-0 to use the International Components for Unicode (ICU). # !IFNDEF USE_ICU @@ -892,10 +899,19 @@ sqlite3.c: .target_source $(TOP)\tool\mksqlite3c.tcl sqlite3-all.c: sqlite3.c $(TOP)\tool\split-sqlite3c.tcl $(TCLSH_CMD) $(TOP)\tool\split-sqlite3c.tcl +# Set the source code file to be used by executables and libraries when +# they need the amalgamation. +# +!IF $(SPLIT_AMALGAMATION)!=0 +SQLITE3C = sqlite3-all.c +!ELSE +SQLITE3C = sqlite3.c +!ENDIF + # Rule to build the amalgamation # -sqlite3.lo: sqlite3.c - $(LTCOMPILE) -c sqlite3.c +sqlite3.lo: $(SQLITE3C) + $(LTCOMPILE) -c $(SQLITE3C) # Rules to build the LEMON compiler generator # @@ -1255,7 +1271,7 @@ TESTFIXTURE_FLAGS = -DTCLSH=1 -DSQLITE_TEST=1 -DSQLITE_CRASH_TEST=1 TESTFIXTURE_FLAGS = $(TESTFIXTURE_FLAGS) -DSQLITE_SERVER=1 -DSQLITE_PRIVATE="" -DSQLITE_CORE TESTFIXTURE_SRC0 = $(TESTEXT) $(TESTSRC2) libsqlite3.lib -TESTFIXTURE_SRC1 = $(TESTEXT) sqlite3.c +TESTFIXTURE_SRC1 = $(TESTEXT) $(SQLITE3C) !IF $(USE_AMALGAMATION)==0 TESTFIXTURE_SRC = $(TESTSRC) $(TOP)\src\tclsqlite.c $(TESTFIXTURE_SRC0) !ELSE @@ -1283,8 +1299,8 @@ queryplantest: testfixture.exe sqlite3.exe test: testfixture.exe sqlite3.exe .\testfixture.exe $(TOP)\test\veryquick.test -sqlite3_analyzer.c: sqlite3.c $(TOP)\src\test_stat.c $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl - copy sqlite3.c + $(TOP)\src\test_stat.c + $(TOP)\src\tclsqlite.c $@ +sqlite3_analyzer.c: $(SQLITE3C) $(TOP)\src\test_stat.c $(TOP)\src\tclsqlite.c $(TOP)\tool\spaceanal.tcl + copy $(SQLITE3C) + $(TOP)\src\test_stat.c + $(TOP)\src\tclsqlite.c $@ echo static const char *tclsh_main_loop(void){ >> $@ echo static const char *zMainloop = >> $@ $(NAWK) -f $(TOP)\tool\tostr.awk $(TOP)\tool\spaceanal.tcl >> $@ @@ -1310,7 +1326,7 @@ clean: del /Q tclsqlite3.exe tclsqlite3.exp del /Q testfixture.exe testfixture.exp test.db del /Q sqlite3.dll sqlite3.lib sqlite3.exp sqlite3.def - del /Q sqlite3.c + del /Q sqlite3.c sqlite3-*.c del /Q sqlite3rc.h del /Q shell.c sqlite3ext.h del /Q sqlite3_analyzer.exe sqlite3_analyzer.exp sqlite3_analyzer.c diff --git a/main.mk b/main.mk index ee5dd7f7e0..fd30019833 100644 --- a/main.mk +++ b/main.mk @@ -656,7 +656,7 @@ clean: rm -f fts3-testfixture fts3-testfixture.exe rm -f testfixture testfixture.exe rm -f threadtest3 threadtest3.exe - rm -f sqlite3.c fts?amal.c tclsqlite3.c + rm -f sqlite3.c sqlite3-*.c fts?amal.c tclsqlite3.c rm -f sqlite3rc.h rm -f shell.c sqlite3ext.h rm -f sqlite3_analyzer sqlite3_analyzer.exe sqlite3_analyzer.c diff --git a/manifest b/manifest index 97e6aa2b5a..0d91a23543 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Fix\sa\sharmless\scompiler\swarning\sin\slemon.c. -D 2013-10-11T23:01:02.703 +C Enhance\sdebugging\ssupport\sfor\sthe\ssplit\samalgamation\sfiles\swhen\scompiling\swith\sMSVC. +D 2013-10-11T23:01:18.933 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc 9af063716f726a73b5d5c98c69ea97eca6a9369b +F Makefile.msc fa3af28a0df2ecab7292feaa672e0550d213806a F Makefile.vxworks db21ed42a01d5740e656b16f92cb5d8d5e5dd315 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION a8d1f6839521130dc73c5408cdd24bcfd791df34 @@ -140,7 +140,7 @@ F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 F magic.txt f2b23a6bde8f1c6e86b957e4d94eab0add520b0d -F main.mk 0c63aec9b9ecf66aaa8c09a02fcd74cf76e89ac8 +F main.mk 2e01504061f618db804812143a9e9ec45a66ae70 F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f F mkextw.sh d2a981497b404d6498f5ff3e3b1f3816bdfcb338 @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 977d2b12e5efc70c26129b08c1f6d65c9d6d211e -R bcbb126665574af7901e0480e4bce971 -U drh -Z bd333009a6747ce18c3ec43add5f57d2 +P 62959c0ce3a2c486ebd82e6511efad0412b944a0 +R c5b525d775079bac122c214ef10fb100 +U mistachkin +Z a753a3f398abd9b81fb8f5b8241736c7 diff --git a/manifest.uuid b/manifest.uuid index 3ac1dcb019..ae32dfe106 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -62959c0ce3a2c486ebd82e6511efad0412b944a0 \ No newline at end of file +8ff17c553d8c159fa81c961441e16dbba8da62ba \ No newline at end of file From 0aedc6be45b62415874faac150af9006a1cb66c2 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Fri, 11 Oct 2013 23:02:13 +0000 Subject: [PATCH 27/42] The split amalgamation option should be disabled by default. FossilOrigin-Name: 7c24d22ffa1e12f3d24cad06b5ff7cc34219b2bb --- Makefile.msc | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile.msc b/Makefile.msc index 0dffd89240..af7f0e3eab 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -17,7 +17,7 @@ USE_AMALGAMATION = 1 # be used for debugging with Visual Studio. # !IFNDEF SPLIT_AMALGAMATION -SPLIT_AMALGAMATION = 1 +SPLIT_AMALGAMATION = 0 !ENDIF # Set this non-0 to use the International Components for Unicode (ICU). diff --git a/manifest b/manifest index 0d91a23543..a9002040b9 100644 --- a/manifest +++ b/manifest @@ -1,9 +1,9 @@ -C Enhance\sdebugging\ssupport\sfor\sthe\ssplit\samalgamation\sfiles\swhen\scompiling\swith\sMSVC. -D 2013-10-11T23:01:18.933 +C The\ssplit\samalgamation\soption\sshould\sbe\sdisabled\sby\sdefault. +D 2013-10-11T23:02:13.717 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 -F Makefile.msc fa3af28a0df2ecab7292feaa672e0550d213806a +F Makefile.msc a08b5f4ed4f760bae4eae4e723371487c5378983 F Makefile.vxworks db21ed42a01d5740e656b16f92cb5d8d5e5dd315 F README cd04a36fbc7ea56932a4052d7d0b7f09f27c33d6 F VERSION a8d1f6839521130dc73c5408cdd24bcfd791df34 @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 62959c0ce3a2c486ebd82e6511efad0412b944a0 -R c5b525d775079bac122c214ef10fb100 +P 8ff17c553d8c159fa81c961441e16dbba8da62ba +R a87e0d5d722c6daa90ba9ca2073832b4 U mistachkin -Z a753a3f398abd9b81fb8f5b8241736c7 +Z e20245d1470af628d2df5bb3da30e84f diff --git a/manifest.uuid b/manifest.uuid index ae32dfe106..f51646052b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -8ff17c553d8c159fa81c961441e16dbba8da62ba \ No newline at end of file +7c24d22ffa1e12f3d24cad06b5ff7cc34219b2bb \ No newline at end of file From cf9fca4629cf0f6f0aac7e489c8737b7313354b5 Mon Sep 17 00:00:00 2001 From: drh Date: Fri, 11 Oct 2013 23:37:57 +0000 Subject: [PATCH 28/42] Identify requirements text in the SQLITE_CONFIG_ documentation. Fix a typo (a duplicated word) in part of that documentation. Add some requirements marks for DETACH to the test scripts. No code changes. FossilOrigin-Name: 1be0a3adaba2914c65c46fbebc4906ae4e70f899 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/sqlite.h.in | 26 +++++++++++++------------- test/attach2.test | 3 +++ test/shared7.test | 3 +++ 5 files changed, 29 insertions(+), 23 deletions(-) diff --git a/manifest b/manifest index a9002040b9..1579b56e79 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C The\ssplit\samalgamation\soption\sshould\sbe\sdisabled\sby\sdefault. -D 2013-10-11T23:02:13.717 +C Identify\srequirements\stext\sin\sthe\sSQLITE_CONFIG_\sdocumentation.\s\sFix\sa\stypo\n(a\sduplicated\sword)\sin\spart\sof\sthat\sdocumentation.\s\sAdd\ssome\srequirements\nmarks\sfor\sDETACH\sto\sthe\stest\sscripts.\s\sNo\scode\schanges. +D 2013-10-11T23:37:57.890 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -219,7 +219,7 @@ F src/resolve.c 5f15b00644c36a1610b87857abf42db38c07519c F src/rowset.c 64655f1a627c9c212d9ab497899e7424a34222e0 F src/select.c 15127b54cc11defb2cddef6914e1f384501a61c4 F src/shell.c 6f11f0e9ded63d48e306f2c6858c521e568a47bb -F src/sqlite.h.in ec40aa958a270416fb04b4f72210357bf163d2c5 +F src/sqlite.h.in 4c6eb96fded1d56a27cec04b6b6803789eb28f54 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc F src/sqliteInt.h eeebd2522bbd5ac7e3024be64113e8366caa66c8 @@ -320,7 +320,7 @@ F test/async4.test 1787e3952128aa10238bf39945126de7ca23685a F test/async5.test 383ab533fdb9f7ad228cc99ee66e1acb34cc0dc0 F test/atof1.test 9bf1d25180a2e05fc12ce3940cc8003033642f68 F test/attach.test 0d112b7713611fdf0340260192749737135fda5f -F test/attach2.test e54436ed956d3d88bdee61221da59bf3935a0966 +F test/attach2.test 0ec5defa340363de6cd50fd595046465e9aaba2d F test/attach3.test d89ccfe4fe6e2b5e368d480fcdfe4b496c54cf4e F test/attach4.test 53bf502f17647c6d6c5add46dda6bac8b6f4665c F test/attachmalloc.test 3a4bfca9545bfe906a8d2e622de10fbac5b711b0 @@ -782,7 +782,7 @@ F test/shared2.test 03eb4a8d372e290107d34b6ce1809919a698e879 F test/shared3.test fcd65cb11d189eff5f5c85cc4fad246fb0933108 F test/shared4.test 72d90821e8d2fc918a08f16d32880868d8ee8e9d F test/shared6.test 866bb4982c45ce216c61ded5e8fde4e7e2f3ffa9 -F test/shared7.test 960760bc8d03e1419e70dea69cf41db62853616e +F test/shared7.test a81e99f83e6c51b02ac99c96fb3a2a7b5978c956 F test/shared8.test 00a07bf5e1337ecf72e94542bdefdc330d7a2538 F test/shared9.test 5f2a8f79b4d6c7d107a01ffa1ed05ae7e6333e21 F test/sharedA.test 0cdf1a76dfa00e6beee66af5b534b1e8df2720f5 @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 8ff17c553d8c159fa81c961441e16dbba8da62ba -R a87e0d5d722c6daa90ba9ca2073832b4 -U mistachkin -Z e20245d1470af628d2df5bb3da30e84f +P 7c24d22ffa1e12f3d24cad06b5ff7cc34219b2bb +R d7d2fd1a5883ae409ba0ba13e9010231 +U drh +Z a2b10bb03f0ef138962d7a6660a6c09c diff --git a/manifest.uuid b/manifest.uuid index f51646052b..8c5019e9e4 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -7c24d22ffa1e12f3d24cad06b5ff7cc34219b2bb \ No newline at end of file +1be0a3adaba2914c65c46fbebc4906ae4e70f899 \ No newline at end of file diff --git a/src/sqlite.h.in b/src/sqlite.h.in index 1e5a3f22a4..2206704f4e 100644 --- a/src/sqlite.h.in +++ b/src/sqlite.h.in @@ -1612,27 +1612,27 @@ struct sqlite3_mem_methods { ** function must be threadsafe. ** ** [[SQLITE_CONFIG_URI]]
SQLITE_CONFIG_URI -**
This option takes a single argument of type int. If non-zero, then +**
^(This option takes a single argument of type int. If non-zero, then ** URI handling is globally enabled. If the parameter is zero, then URI handling -** is globally disabled. If URI handling is globally enabled, all filenames +** is globally disabled.)^ ^If URI handling is globally enabled, all filenames ** passed to [sqlite3_open()], [sqlite3_open_v2()], [sqlite3_open16()] or ** specified as part of [ATTACH] commands are interpreted as URIs, regardless ** of whether or not the [SQLITE_OPEN_URI] flag is set when the database -** connection is opened. If it is globally disabled, filenames are +** connection is opened. ^If it is globally disabled, filenames are ** only interpreted as URIs if the SQLITE_OPEN_URI flag is set when the -** database connection is opened. By default, URI handling is globally +** database connection is opened. ^(By default, URI handling is globally ** disabled. The default value may be changed by compiling with the -** [SQLITE_USE_URI] symbol defined. +** [SQLITE_USE_URI] symbol defined.)^ ** ** [[SQLITE_CONFIG_COVERING_INDEX_SCAN]]
SQLITE_CONFIG_COVERING_INDEX_SCAN -**
This option takes a single integer argument which is interpreted as +**
^This option takes a single integer argument which is interpreted as ** a boolean in order to enable or disable the use of covering indices for -** full table scans in the query optimizer. The default setting is determined +** full table scans in the query optimizer. ^The default setting is determined ** by the [SQLITE_ALLOW_COVERING_INDEX_SCAN] compile-time option, or is "on" ** if that compile-time option is omitted. ** The ability to disable the use of covering indices for full table scans ** is because some incorrectly coded legacy applications might malfunction -** malfunction when the optimization is enabled. Providing the ability to +** when the optimization is enabled. Providing the ability to ** disable the optimization allows the older, buggy application code to work ** without change even with newer versions of SQLite. ** @@ -1661,16 +1661,16 @@ struct sqlite3_mem_methods { ** ** [[SQLITE_CONFIG_MMAP_SIZE]] **
SQLITE_CONFIG_MMAP_SIZE -**
SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values +**
^SQLITE_CONFIG_MMAP_SIZE takes two 64-bit integer (sqlite3_int64) values ** that are the default mmap size limit (the default setting for ** [PRAGMA mmap_size]) and the maximum allowed mmap size limit. -** The default setting can be overridden by each database connection using +** ^The default setting can be overridden by each database connection using ** either the [PRAGMA mmap_size] command, or by using the -** [SQLITE_FCNTL_MMAP_SIZE] file control. The maximum allowed mmap size +** [SQLITE_FCNTL_MMAP_SIZE] file control. ^(The maximum allowed mmap size ** cannot be changed at run-time. Nor may the maximum allowed mmap size ** exceed the compile-time maximum mmap size set by the -** [SQLITE_MAX_MMAP_SIZE] compile-time option. -** If either argument to this option is negative, then that argument is +** [SQLITE_MAX_MMAP_SIZE] compile-time option.)^ +** ^If either argument to this option is negative, then that argument is ** changed to its compile-time default. ** */ diff --git a/test/attach2.test b/test/attach2.test index db230723ab..f870568541 100644 --- a/test/attach2.test +++ b/test/attach2.test @@ -377,6 +377,9 @@ do_test attach2-6.2 { } } {1 {cannot ATTACH database within transaction}} +# EVIDENCE-OF: R-59740-55581 This statement will fail if SQLite is in +# the middle of a transaction. +# do_test attach2-6.3 { catchsql { DETACH aux; diff --git a/test/shared7.test b/test/shared7.test index 5c4a1da24c..9f4880f56e 100644 --- a/test/shared7.test +++ b/test/shared7.test @@ -23,6 +23,9 @@ do_test shared7-1.1 { sqlite3_enable_shared_cache } {1} +# EVIDENCE-OF: R-05098-06501 In shared cache mode, attempting to attach +# the same database file more than once results in an error. +# do_test shared7-1.2 { db close sqlite3 db test.db From 549bc3db1fc56b7b6751f86fc70017029091ae99 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 12 Oct 2013 00:56:21 +0000 Subject: [PATCH 29/42] Fix Unicode character encoding issues on Windows. FossilOrigin-Name: c9310c9a2bad11f1d033a57b33ea7aed43a8238d --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/fts4unicode.test | 27 ++++++++++++++++----------- 3 files changed, 24 insertions(+), 19 deletions(-) diff --git a/manifest b/manifest index 1579b56e79..888c047bd8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Identify\srequirements\stext\sin\sthe\sSQLITE_CONFIG_\sdocumentation.\s\sFix\sa\stypo\n(a\sduplicated\sword)\sin\spart\sof\sthat\sdocumentation.\s\sAdd\ssome\srequirements\nmarks\sfor\sDETACH\sto\sthe\stest\sscripts.\s\sNo\scode\schanges. -D 2013-10-11T23:37:57.890 +C Fix\sUnicode\scharacter\sencoding\sissues\son\sWindows. +D 2013-10-12T00:56:21.621 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -564,7 +564,7 @@ F test/fts4merge2.test 5faa558d1b672f82b847d2a337465fa745e46891 F test/fts4merge3.test aab02a09f50fe6baaddc2e159c3eabc116d45fc7 F test/fts4merge4.test c19c85ca1faa7b6d536832b49c12e1867235f584 F test/fts4noti.test aed33ba44808852dcb24bf70fa132e7bf530f057 -F test/fts4unicode.test 20195bca1e3a4301924c2c8b46257d64127f17df +F test/fts4unicode.test e28ba1a14181e709dcdf47455f207adf14c7cfe0 F test/full.test 6b3c8fb43c6beab6b95438c1675374b95fab245d F test/func.test c7e80a44eebac8604397eb2ad83d0d5d9d541237 F test/func2.test 772d66227e4e6684b86053302e2d74a2500e1e0f @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 7c24d22ffa1e12f3d24cad06b5ff7cc34219b2bb -R d7d2fd1a5883ae409ba0ba13e9010231 -U drh -Z a2b10bb03f0ef138962d7a6660a6c09c +P 1be0a3adaba2914c65c46fbebc4906ae4e70f899 +R ca24bf11e504ff21d9315944c9b4b854 +U mistachkin +Z ae94ccc0d8018ab65fe4f23e4fae4aa0 diff --git a/manifest.uuid b/manifest.uuid index 8c5019e9e4..d6f3901595 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1be0a3adaba2914c65c46fbebc4906ae4e70f899 \ No newline at end of file +c9310c9a2bad11f1d033a57b33ea7aed43a8238d \ No newline at end of file diff --git a/test/fts4unicode.test b/test/fts4unicode.test index b8b98a327a..8edc2877da 100644 --- a/test/fts4unicode.test +++ b/test/fts4unicode.test @@ -44,31 +44,36 @@ proc do_unicode_token_test3 {tn args} { } do_unicode_token_test 1.0 {a B c D} {0 a a 1 b B 2 c c 3 d D} -do_unicode_token_test 1.1 {Ä Ö Ü} {0 ä Ä 1 ö Ö 2 ü Ü} -do_unicode_token_test 1.2 {xÄx xÖx xÜx} {0 xäx xÄx 1 xöx xÖx 2 xüx xÜx} + +do_unicode_token_test 1.1 "\uC4 \uD6 \uDC" \ + "0 \uE4 \uC4 1 \uF6 \uD6 2 \uFC \uDC" + +do_unicode_token_test 1.2 "x\uC4x x\uD6x x\uDCx" \ + "0 x\uE4x x\uC4x 1 x\uF6x x\uD6x 2 x\uFCx x\uDCx" # 0x00DF is a small "sharp s". 0x1E9E is a capital sharp s. do_unicode_token_test 1.3 "\uDF" "0 \uDF \uDF" -do_unicode_token_test 1.4 "\u1E9E" "0 ß \u1E9E" -do_unicode_token_test 1.5 "\u1E9E" "0 \uDF \u1E9E" +do_unicode_token_test 1.4 "\u1E9E" "0 \uDF \u1E9E" -do_unicode_token_test 1.6 "The quick brown fox" { +do_unicode_token_test 1.5 "The quick brown fox" { 0 the The 1 quick quick 2 brown brown 3 fox fox } -do_unicode_token_test 1.7 "The\u00bfquick\u224ebrown\u2263fox" { +do_unicode_token_test 1.6 "The\u00bfquick\u224ebrown\u2263fox" { 0 the The 1 quick quick 2 brown brown 3 fox fox } -do_unicode_token_test2 1.8 {a B c D} {0 a a 1 b B 2 c c 3 d D} -do_unicode_token_test2 1.9 {Ä Ö Ü} {0 a Ä 1 o Ö 2 u Ü} -do_unicode_token_test2 1.10 {xÄx xÖx xÜx} {0 xax xÄx 1 xox xÖx 2 xux xÜx} +do_unicode_token_test2 1.7 {a B c D} {0 a a 1 b B 2 c c 3 d D} +do_unicode_token_test2 1.8 "\uC4 \uD6 \uDC" "0 a \uC4 1 o \uD6 2 u \uDC" + +do_unicode_token_test2 1.9 "x\uC4x x\uD6x x\uDCx" \ + "0 xax x\uC4x 1 xox x\uD6x 2 xux x\uDCx" # Check that diacritics are removed if remove_diacritics=1 is specified. # And that they do not break tokens. -do_unicode_token_test2 1.11 "xx\u0301xx" "0 xxxx xx\u301xx" +do_unicode_token_test2 1.10 "xx\u0301xx" "0 xxxx xx\u301xx" # Title-case mappings work -do_unicode_token_test 1.12 "\u01c5" "0 \u01c6 \u01c5" +do_unicode_token_test 1.11 "\u01c5" "0 \u01c6 \u01c5" #------------------------------------------------------------------------- # From b0845822996f923651aace8c86b2d05beea17d6e Mon Sep 17 00:00:00 2001 From: mistachkin Date: Sat, 12 Oct 2013 02:33:22 +0000 Subject: [PATCH 30/42] Fix harmless compiler warning. FossilOrigin-Name: 4b130f88fba216e088f61252bbcdde57ec7ee6a9 --- ext/fts3/fts3.c | 2 +- manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index 6f2ba13363..a3dfae22fe 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -4370,7 +4370,7 @@ static int fts3EvalIncrPhraseNext( int nDist = p->nToken-1-i; int res = fts3PoslistPhraseMerge(&pOut, nDist, 0, 1, &pL, &pR); if( res==0 ) break; - nList = (pOut - aDoclist); + nList = (int)(pOut - aDoclist); } } if( i==(p->nToken-1) ){ diff --git a/manifest b/manifest index 00e6569186..af48feadda 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Permit\sthe\screation\sof\sVSIX\spackages\sfor\sWin32. -D 2013-10-12T02:31:34.870 +C Fix\sharmless\scompiler\swarning. +D 2013-10-12T02:33:22.853 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -78,7 +78,7 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c 1864684d2fafa3988f144e421340246e064c8f71 +F ext/fts3/fts3.c dcb90d12ff4a0ccfceaefb3bae2199b6536e0dfc F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 8689f7cf85020e7f88d1e761eeac480c3b0ea7ad F ext/fts3/fts3_aux.c b02632f6dd0e375ce97870206d914ea6d8df5ccd @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P c9310c9a2bad11f1d033a57b33ea7aed43a8238d abedd7cb454aab99b62b63ed4fdd70c31ef87b0b -R 070d15876134de221199198e15ca3595 +P 035d03e94252f31025b39da49d8401933352fb77 +R 674aebabd5ad2749788043a817e7f011 U mistachkin -Z 2c05f3c55946fe5fa8d9a3ccbc09acf7 +Z fc9cb3270f125330055c4b37111cf872 diff --git a/manifest.uuid b/manifest.uuid index ad8ea59cef..de1b48360a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -035d03e94252f31025b39da49d8401933352fb77 \ No newline at end of file +4b130f88fba216e088f61252bbcdde57ec7ee6a9 \ No newline at end of file From 5dbb7cc24ff9ecad2761f2229ce45a12c18b3d29 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 12 Oct 2013 13:16:15 +0000 Subject: [PATCH 31/42] Add tests that demonstrate that PRAGMA defer_foreign_keys will reset to off at the conclusion of the next transaction. FossilOrigin-Name: 67e28a11de97e97889f0c0f41c05605721c605c1 --- manifest | 14 +++++++------- manifest.uuid | 2 +- test/fkey6.test | 23 +++++++++++++++++------ 3 files changed, 25 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index af48feadda..6be0e9f5fb 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarning. -D 2013-10-12T02:33:22.853 +C Add\stests\sthat\sdemonstrate\sthat\sPRAGMA\sdefer_foreign_keys\swill\sreset\sto\soff\nat\sthe\sconclusion\sof\sthe\snext\stransaction. +D 2013-10-12T13:16:15.885 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -463,7 +463,7 @@ F test/fkey2.test 06e0b4cc9e1b3271ae2ae6feeb19755468432111 F test/fkey3.test 5ec899d12b13bcf1e9ef40eff7fb692fdb91392e F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d F test/fkey5.test 2b8c761ad23bb6a95b9cf8366c9a982a80a439c2 -F test/fkey6.test c1d7cb176648e0e1e9f971f5f9bde4dd5bcd046d +F test/fkey6.test aaf64e18e68fd9967e6accec65e2598ccefcb1e4 F test/fkey7.test e31d0e71a41c1d29349a16448d6c420e2c53a8fc F test/fkey_malloc.test bb74c9cb8f8fceed03b58f8a7ef2df98520bbd51 F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 035d03e94252f31025b39da49d8401933352fb77 -R 674aebabd5ad2749788043a817e7f011 -U mistachkin -Z fc9cb3270f125330055c4b37111cf872 +P 4b130f88fba216e088f61252bbcdde57ec7ee6a9 +R 99a9e83f60fa4dd81ccd94c036548c85 +U drh +Z 4e218592d1ebb0a4d1a6f06c784de251 diff --git a/manifest.uuid b/manifest.uuid index de1b48360a..e1694f337c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -4b130f88fba216e088f61252bbcdde57ec7ee6a9 \ No newline at end of file +67e28a11de97e97889f0c0f41c05605721c605c1 \ No newline at end of file diff --git a/test/fkey6.test b/test/fkey6.test index 1c77c3d051..2ca364e4e3 100644 --- a/test/fkey6.test +++ b/test/fkey6.test @@ -81,12 +81,23 @@ do_test fkey6-1.8 { do_test fkey6-1.9 { sqlite3_db_status db DBSTATUS_DEFERRED_FKS 0 } {0 1 0} -do_test fkey6-1.10 { - execsql { - ROLLBACK; - PRAGMA defer_foreign_keys=OFF; - BEGIN; - } + +# EVIDENCE-OF: R-21752-26913 The defer_foreign_keys pragma is +# automatically switched off at each COMMIT or ROLLBACK. Hence, the +# defer_foreign_keys pragma must be separately enabled for each +# transaction. +do_execsql_test fkey6-1.10.1 { + PRAGMA defer_foreign_keys; + ROLLBACK; + PRAGMA defer_foreign_keys; + BEGIN; + PRAGMA defer_foreign_keys=ON; + PRAGMA defer_foreign_keys; + COMMIT; + PRAGMA defer_foreign_keys; + BEGIN; +} {1 0 1 0} +do_test fkey6-1.10.2 { catchsql {DELETE FROM t1 WHERE x=3} } {1 {foreign key constraint failed}} db eval {ROLLBACK} From a8dbadacee3097940388a5fdcb093d2563c048c2 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 12 Oct 2013 15:12:43 +0000 Subject: [PATCH 32/42] Fix handling of "DROP TABLE" commands when "PRAGMA defer_foreign_keys=1" is set. FossilOrigin-Name: 27001356ed8201529b3f31d4313f2010f1b4e1b1 --- manifest | 16 ++++++++-------- manifest.uuid | 2 +- src/fkey.c | 19 ++++++++++++------ test/fkey6.test | 51 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 73 insertions(+), 15 deletions(-) diff --git a/manifest b/manifest index 6be0e9f5fb..10577d4ef5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\stests\sthat\sdemonstrate\sthat\sPRAGMA\sdefer_foreign_keys\swill\sreset\sto\soff\nat\sthe\sconclusion\sof\sthe\snext\stransaction. -D 2013-10-12T13:16:15.885 +C Fix\shandling\sof\s"DROP\sTABLE"\scommands\swhen\s"PRAGMA\sdefer_foreign_keys=1"\sis\sset. +D 2013-10-12T15:12:43.761 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -175,7 +175,7 @@ F src/date.c 593c744b2623971e45affd0bde347631bdfa4625 F src/delete.c 45788c5e48734f2af4acd75a876466e5b9838e34 F src/expr.c e7338ccffdc391c53ba2d51c5eb6a2f5299e040e F src/fault.c 160a0c015b6c2629d3899ed2daf63d75754a32bb -F src/fkey.c be866cd8c4fa6cae98ba33109578fd1a3311ee5b +F src/fkey.c 5dc10cbaa355753903cd2a64da040f948997ebf8 F src/func.c 2c47b65e6e00e3e9374942f28254faf8adafe398 F src/global.c 5caf4deab621abb45b4c607aad1bd21c20aac759 F src/hash.c ac3470bbf1ca4ae4e306a8ecb0fdf1731810ffe4 @@ -463,7 +463,7 @@ F test/fkey2.test 06e0b4cc9e1b3271ae2ae6feeb19755468432111 F test/fkey3.test 5ec899d12b13bcf1e9ef40eff7fb692fdb91392e F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d F test/fkey5.test 2b8c761ad23bb6a95b9cf8366c9a982a80a439c2 -F test/fkey6.test aaf64e18e68fd9967e6accec65e2598ccefcb1e4 +F test/fkey6.test 18e8c024d39f68f8d4bb1177c992bcffdc273464 F test/fkey7.test e31d0e71a41c1d29349a16448d6c420e2c53a8fc F test/fkey_malloc.test bb74c9cb8f8fceed03b58f8a7ef2df98520bbd51 F test/format4.test 1f0cac8ff3895e9359ed87e41aaabee982a812eb @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 4b130f88fba216e088f61252bbcdde57ec7ee6a9 -R 99a9e83f60fa4dd81ccd94c036548c85 -U drh -Z 4e218592d1ebb0a4d1a6f06c784de251 +P 67e28a11de97e97889f0c0f41c05605721c605c1 +R dc1f4dd0df343cdf7a68b757db650d93 +U dan +Z abee286031badbf2a2b4e2d1bb40e0a3 diff --git a/manifest.uuid b/manifest.uuid index e1694f337c..2f25de0eb8 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -67e28a11de97e97889f0c0f41c05605721c605c1 \ No newline at end of file +27001356ed8201529b3f31d4313f2010f1b4e1b1 \ No newline at end of file diff --git a/src/fkey.c b/src/fkey.c index 1947c2ee20..5c49ded876 100644 --- a/src/fkey.c +++ b/src/fkey.c @@ -656,7 +656,7 @@ void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){ ** when this statement is run. */ FKey *p; for(p=pTab->pFKey; p; p=p->pNextFrom){ - if( p->isDeferred ) break; + if( p->isDeferred || (db->flags & SQLITE_DeferFKs) ) break; } if( !p ) return; iSkip = sqlite3VdbeMakeLabel(v); @@ -670,11 +670,18 @@ void sqlite3FkDropTable(Parse *pParse, SrcList *pName, Table *pTab){ /* If the DELETE has generated immediate foreign key constraint ** violations, halt the VDBE and return an error at this point, before ** any modifications to the schema are made. This is because statement - ** transactions are not able to rollback schema changes. */ - sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2); - sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY, - OE_Abort, "foreign key constraint failed", P4_STATIC - ); + ** transactions are not able to rollback schema changes. + ** + ** If the SQLITE_DeferFKs flag is set, then this is not required, as + ** the statement transaction will not be rolled back even if FK + ** constraints are violated. + */ + if( (db->flags & SQLITE_DeferFKs)==0 ){ + sqlite3VdbeAddOp2(v, OP_FkIfZero, 0, sqlite3VdbeCurrentAddr(v)+2); + sqlite3HaltConstraint(pParse, SQLITE_CONSTRAINT_FOREIGNKEY, + OE_Abort, "foreign key constraint failed", P4_STATIC + ); + } if( iSkip ){ sqlite3VdbeResolveLabel(v, iSkip); diff --git a/test/fkey6.test b/test/fkey6.test index 2ca364e4e3..8f90116487 100644 --- a/test/fkey6.test +++ b/test/fkey6.test @@ -121,5 +121,56 @@ do_test fkey6-1.22 { } } {} +do_execsql_test fkey6-2.1 { + CREATE TABLE p1(a PRIMARY KEY); + INSERT INTO p1 VALUES('one'), ('two'); + CREATE TABLE c1(x REFERENCES p1); + INSERT INTO c1 VALUES('two'), ('one'); +} + +do_execsql_test fkey6-2.2 { + BEGIN; + PRAGMA defer_foreign_keys = 1; + DELETE FROM p1; + ROLLBACK; + PRAGMA defer_foreign_keys; +} {0} + +do_execsql_test fkey6-2.3 { + BEGIN; + PRAGMA defer_foreign_keys = 1; + DROP TABLE p1; + PRAGMA vdbe_trace = 0; + ROLLBACK; + PRAGMA defer_foreign_keys; +} {0} + +do_execsql_test fkey6-2.4 { + BEGIN; + PRAGMA defer_foreign_keys = 1; + DELETE FROM p1; + DROP TABLE c1; + COMMIT; + PRAGMA defer_foreign_keys; +} {0} + +do_execsql_test fkey6-2.5 { + DROP TABLE p1; + CREATE TABLE p1(a PRIMARY KEY); + INSERT INTO p1 VALUES('one'), ('two'); + CREATE TABLE c1(x REFERENCES p1); + INSERT INTO c1 VALUES('two'), ('one'); +} + +do_execsql_test fkey6-2.6 { + BEGIN; + PRAGMA defer_foreign_keys = 1; + INSERT INTO c1 VALUES('three'); + DROP TABLE c1; + COMMIT; + PRAGMA defer_foreign_keys; +} {0} + finish_test + From 5e87830fa370a3a9309339ebe339cc6103b7b630 Mon Sep 17 00:00:00 2001 From: dan Date: Sat, 12 Oct 2013 19:06:48 +0000 Subject: [PATCH 33/42] In "PRAGMA foreign_key_check", treat missing parent tables as empty (instead of as errors). FossilOrigin-Name: 8c13a7fd738e5441af370537649b0bfa97679cda --- manifest | 17 ++++++++++------- manifest.uuid | 2 +- src/pragma.c | 28 ++++++++++++++++------------ test/fkey5.test | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+), 20 deletions(-) diff --git a/manifest b/manifest index 10577d4ef5..c7e0df6844 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\shandling\sof\s"DROP\sTABLE"\scommands\swhen\s"PRAGMA\sdefer_foreign_keys=1"\sis\sset. -D 2013-10-12T15:12:43.761 +C In\s"PRAGMA\sforeign_key_check",\streat\smissing\sparent\stables\sas\sempty\s(instead\sof\sas\serrors). +D 2013-10-12T19:06:48.154 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -211,7 +211,7 @@ F src/parse.y a97566d6da75075589a7c716d1bda14b586cf8da F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222 F src/pcache1.c a467393909a4ed7ca9de066d85ba5c5b04a5be63 -F src/pragma.c f4ff6e29c316d06bf7dffca0c8cee7c229cae42e +F src/pragma.c 24fb88e294ff7cd5bd1859f88503349ce92aa187 F src/prepare.c fa6988589f39af8504a61731614cd4f6ae71554f F src/printf.c da9119eb31a187a4b99f60aa4a225141c0ebb74b F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68 @@ -462,7 +462,7 @@ F test/fkey1.test e1d1fa84cde579185ea01358436839703e415a5b F test/fkey2.test 06e0b4cc9e1b3271ae2ae6feeb19755468432111 F test/fkey3.test 5ec899d12b13bcf1e9ef40eff7fb692fdb91392e F test/fkey4.test 86446017011273aad8f9a99c1a65019e7bd9ca9d -F test/fkey5.test 2b8c761ad23bb6a95b9cf8366c9a982a80a439c2 +F test/fkey5.test 8a1fde4e7721ae00b05b3178888833726ca2df8d F test/fkey6.test 18e8c024d39f68f8d4bb1177c992bcffdc273464 F test/fkey7.test e31d0e71a41c1d29349a16448d6c420e2c53a8fc F test/fkey_malloc.test bb74c9cb8f8fceed03b58f8a7ef2df98520bbd51 @@ -1123,7 +1123,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 67e28a11de97e97889f0c0f41c05605721c605c1 -R dc1f4dd0df343cdf7a68b757db650d93 +P 27001356ed8201529b3f31d4313f2010f1b4e1b1 +R d979b0883c0e5512213e1d7af1d7ac15 +T *branch * fkc-missing-parent-tables +T *sym-fkc-missing-parent-tables * +T -sym-trunk * U dan -Z abee286031badbf2a2b4e2d1bb40e0a3 +Z 1f7e86e642b676f584ebb1b861caf588 diff --git a/manifest.uuid b/manifest.uuid index 2f25de0eb8..bf1535ba3c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -27001356ed8201529b3f31d4313f2010f1b4e1b1 \ No newline at end of file +8c13a7fd738e5441af370537649b0bfa97679cda \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 969af6af34..60f9d8d924 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -1610,8 +1610,8 @@ void sqlite3Pragma( sqlite3VdbeAddOp4(v, OP_String8, 0, regResult, 0, pTab->zName, P4_TRANSIENT); for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){ - pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb); - if( pParent==0 ) break; + pParent = sqlite3FindTable(db, pFK->zTo, zDb); + if( pParent==0 ) continue; pIdx = 0; sqlite3TableLock(pParse, iDb, pParent->tnum, 0, pParent->zName); x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, 0); @@ -1628,18 +1628,20 @@ void sqlite3Pragma( break; } } + assert( pParse->nErr>0 || pFK==0 ); if( pFK ) break; if( pParse->nTabnTab = i; addrTop = sqlite3VdbeAddOp1(v, OP_Rewind, 0); for(i=1, pFK=pTab->pFKey; pFK; i++, pFK=pFK->pNextFrom){ - pParent = sqlite3LocateTable(pParse, 0, pFK->zTo, zDb); - assert( pParent!=0 ); + pParent = sqlite3FindTable(db, pFK->zTo, zDb); pIdx = 0; aiCols = 0; - x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols); - assert( x==0 ); + if( pParent ){ + x = sqlite3FkLocateIndex(pParse, pParent, pFK, &pIdx, &aiCols); + assert( x==0 ); + } addrOk = sqlite3VdbeMakeLabel(v); - if( pIdx==0 ){ + if( pParent && pIdx==0 ){ int iKey = pFK->aCol[0].iFrom; assert( iKey>=0 && iKeynCol ); if( iKey!=pTab->iPKey ){ @@ -1657,13 +1659,15 @@ void sqlite3Pragma( }else{ for(j=0; jnCol; j++){ sqlite3ExprCodeGetColumnOfTable(v, pTab, 0, - aiCols ? aiCols[j] : pFK->aCol[0].iFrom, regRow+j); + aiCols ? aiCols[j] : pFK->aCol[j].iFrom, regRow+j); sqlite3VdbeAddOp2(v, OP_IsNull, regRow+j, addrOk); } - sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey); - sqlite3VdbeChangeP4(v, -1, - sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT); - sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0); + if( pParent ){ + sqlite3VdbeAddOp3(v, OP_MakeRecord, regRow, pFK->nCol, regKey); + sqlite3VdbeChangeP4(v, -1, + sqlite3IndexAffinityStr(v,pIdx), P4_TRANSIENT); + sqlite3VdbeAddOp4Int(v, OP_Found, i, addrOk, regKey, 0); + } } sqlite3VdbeAddOp2(v, OP_Rowid, 0, regResult+1); sqlite3VdbeAddOp4(v, OP_String8, 0, regResult+2, 0, diff --git a/test/fkey5.test b/test/fkey5.test index 16efc26685..5aa8b1d4b7 100644 --- a/test/fkey5.test +++ b/test/fkey5.test @@ -17,6 +17,7 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +set testprefix fkey5 ifcapable {!foreignkey} { finish_test @@ -325,5 +326,38 @@ do_test fkey5-8.7 { } {} +#------------------------------------------------------------------------- +# Tests 9.* verify that missing parent tables are handled correctly. +# +do_execsql_test 9.1.1 { + CREATE TABLE k1(x REFERENCES s1); + PRAGMA foreign_key_check(k1); +} {} +do_execsql_test 9.1.2 { + INSERT INTO k1 VALUES(NULL); + PRAGMA foreign_key_check(k1); +} {} +do_execsql_test 9.1.3 { + INSERT INTO k1 VALUES(1); + PRAGMA foreign_key_check(k1); +} {k1 2 s1 0} + +do_execsql_test 9.2.1 { + CREATE TABLE k2(x, y, FOREIGN KEY(x, y) REFERENCES s1(a, b)); + PRAGMA foreign_key_check(k2); +} {} +do_execsql_test 9.2 { + INSERT INTO k2 VALUES(NULL, 'five'); + PRAGMA foreign_key_check(k2); +} {} +do_execsql_test 9.3 { + INSERT INTO k2 VALUES('one', NULL); + PRAGMA foreign_key_check(k2); +} {} +do_execsql_test 9.4 { + INSERT INTO k2 VALUES('six', 'seven'); + PRAGMA foreign_key_check(k2); +} {k2 3 s1 0} + finish_test From 3ef261567abf1b70a8de037e1058916618b9f248 Mon Sep 17 00:00:00 2001 From: drh Date: Sat, 12 Oct 2013 20:22:00 +0000 Subject: [PATCH 34/42] Restore the index_list pragma back to its former operation. Create a new PRAGMA stats used to access the table and index widths and heights. FossilOrigin-Name: f0cf8c85dcbcc7778aed2816792c368d777f79cb --- manifest | 18 +++++----- manifest.uuid | 2 +- src/pragma.c | 80 ++++++++++++++++++++++++++++++-------------- test/pragma.test | 6 ++-- tool/mkpragmatab.tcl | 4 +++ 5 files changed, 71 insertions(+), 39 deletions(-) diff --git a/manifest b/manifest index 10577d4ef5..dc0e75d8d8 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\shandling\sof\s"DROP\sTABLE"\scommands\swhen\s"PRAGMA\sdefer_foreign_keys=1"\sis\sset. -D 2013-10-12T15:12:43.761 +C Restore\sthe\sindex_list\spragma\sback\sto\sits\sformer\soperation.\s\sCreate\sa\snew\nPRAGMA\sstats\sused\sto\saccess\sthe\stable\sand\sindex\swidths\sand\sheights. +D 2013-10-12T20:22:00.025 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -211,7 +211,7 @@ F src/parse.y a97566d6da75075589a7c716d1bda14b586cf8da F src/pcache.c f8043b433a57aba85384a531e3937a804432a346 F src/pcache.h a5e4f5d9f5d592051d91212c5949517971ae6222 F src/pcache1.c a467393909a4ed7ca9de066d85ba5c5b04a5be63 -F src/pragma.c f4ff6e29c316d06bf7dffca0c8cee7c229cae42e +F src/pragma.c 1c00ed0dea8bc119d248e26e648d438e16e92010 F src/prepare.c fa6988589f39af8504a61731614cd4f6ae71554f F src/printf.c da9119eb31a187a4b99f60aa4a225141c0ebb74b F src/random.c 0b2dbc37fdfbfa6bd455b091dfcef5bdb32dba68 @@ -725,7 +725,7 @@ F test/pcache.test b09104b03160aca0d968d99e8cd2c5b1921a993d F test/pcache2.test a83efe2dec0d392f814bfc998def1d1833942025 F test/percentile.test b98fc868d71eb5619d42a1702e9ab91718cbed54 F test/permutations.test e154f5ed66d4d4913a99a110e870c9407f75b055 -F test/pragma.test 5c6e8ae9eaa9a505cc1035b51f7f0da9805092c7 +F test/pragma.test 5e7de6c32a5d764f09437d2025f07e4917b9e178 F test/pragma2.test aea7b3d82c76034a2df2b38a13745172ddc0bc13 F test/printf.test ec9870c4dce8686a37818e0bf1aba6e6a1863552 F test/progress.test a282973d1d17f08071bc58a77d6b80f2a81c354d @@ -1090,7 +1090,7 @@ F tool/logest.c 7ad625cac3d54012b27d468b7af6612f78b9ba75 F tool/mkautoconfamal.sh f8d8dbf7d62f409ebed5134998bf5b51d7266383 F tool/mkkeywordhash.c bb52064aa614e1426445e4b2b9b00eeecd23cc79 F tool/mkopts.tcl 66ac10d240cc6e86abd37dc908d50382f84ff46e -F tool/mkpragmatab.tcl ceaaeebcd882864caefe4176592ca6fa4648fab1 +F tool/mkpragmatab.tcl 3fc52e00a234750675e8a569d2919ff48558e9eb F tool/mkspeedsql.tcl a1a334d288f7adfe6e996f2e712becf076745c97 F tool/mksqlite3c-noext.tcl 8bce31074e4cbe631bb7676526a048335f4c9f02 F tool/mksqlite3c.tcl d8dc444d403019167260e5578f5c362741f03696 @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 67e28a11de97e97889f0c0f41c05605721c605c1 -R dc1f4dd0df343cdf7a68b757db650d93 -U dan -Z abee286031badbf2a2b4e2d1bb40e0a3 +P 27001356ed8201529b3f31d4313f2010f1b4e1b1 +R f3adfc8132b3f36843e2e67728415fbc +U drh +Z d16ae1a1de8f3334074e16125e33c2b1 diff --git a/manifest.uuid b/manifest.uuid index 2f25de0eb8..6559ca61a5 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -27001356ed8201529b3f31d4313f2010f1b4e1b1 \ No newline at end of file +f0cf8c85dcbcc7778aed2816792c368d777f79cb \ No newline at end of file diff --git a/src/pragma.c b/src/pragma.c index 969af6af34..735dafc39f 100644 --- a/src/pragma.c +++ b/src/pragma.c @@ -56,18 +56,19 @@ #define PragTyp_SECURE_DELETE 25 #define PragTyp_SHRINK_MEMORY 26 #define PragTyp_SOFT_HEAP_LIMIT 27 -#define PragTyp_SYNCHRONOUS 28 -#define PragTyp_TABLE_INFO 29 -#define PragTyp_TEMP_STORE 30 -#define PragTyp_TEMP_STORE_DIRECTORY 31 -#define PragTyp_WAL_AUTOCHECKPOINT 32 -#define PragTyp_WAL_CHECKPOINT 33 -#define PragTyp_ACTIVATE_EXTENSIONS 34 -#define PragTyp_HEXKEY 35 -#define PragTyp_KEY 36 -#define PragTyp_REKEY 37 -#define PragTyp_LOCK_STATUS 38 -#define PragTyp_PARSER_TRACE 39 +#define PragTyp_STATS 28 +#define PragTyp_SYNCHRONOUS 29 +#define PragTyp_TABLE_INFO 30 +#define PragTyp_TEMP_STORE 31 +#define PragTyp_TEMP_STORE_DIRECTORY 32 +#define PragTyp_WAL_AUTOCHECKPOINT 33 +#define PragTyp_WAL_CHECKPOINT 34 +#define PragTyp_ACTIVATE_EXTENSIONS 35 +#define PragTyp_HEXKEY 36 +#define PragTyp_KEY 37 +#define PragTyp_REKEY 38 +#define PragTyp_LOCK_STATUS 39 +#define PragTyp_PARSER_TRACE 40 #define PragFlag_NeedSchema 0x01 static const struct sPragmaNames { const char *const zName; /* Name of pragma */ @@ -359,6 +360,12 @@ static const struct sPragmaNames { /* ePragFlag: */ 0, /* iArg: */ SQLITE_SqlTrace }, #endif +#if !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) + { /* zName: */ "stats", + /* ePragTyp: */ PragTyp_STATS, + /* ePragFlag: */ PragFlag_NeedSchema, + /* iArg: */ 0 }, +#endif #if !defined(SQLITE_OMIT_PAGER_PRAGMAS) { /* zName: */ "synchronous", /* ePragTyp: */ PragTyp_SYNCHRONOUS, @@ -420,7 +427,7 @@ static const struct sPragmaNames { /* ePragFlag: */ 0, /* iArg: */ SQLITE_WriteSchema|SQLITE_RecoveryMode }, }; -/* Number of pragmas: 55 on by default, 67 total. */ +/* Number of pragmas: 56 on by default, 68 total. */ /* End of the automatically generated pragma table. ***************************************************************************/ @@ -1425,6 +1432,36 @@ void sqlite3Pragma( } break; + case PragTyp_STATS: { + Index *pIdx; + HashElem *i; + v = sqlite3GetVdbe(pParse); + sqlite3VdbeSetNumCols(v, 4); + pParse->nMem = 4; + sqlite3CodeVerifySchema(pParse, iDb); + sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "table", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "index", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "width", SQLITE_STATIC); + sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "height", SQLITE_STATIC); + for(i=sqliteHashFirst(&pDb->pSchema->tblHash); i; i=sqliteHashNext(i)){ + Table *pTab = sqliteHashData(i); + sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, pTab->zName, 0); + sqlite3VdbeAddOp2(v, OP_Null, 0, 2); + sqlite3VdbeAddOp2(v, OP_Integer, + (int)sqlite3LogEstToInt(pTab->szTabRow), 3); + sqlite3VdbeAddOp2(v, OP_Integer, (int)pTab->nRowEst, 4); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4); + for(pIdx=pTab->pIndex; pIdx; pIdx=pIdx->pNext){ + sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0); + sqlite3VdbeAddOp2(v, OP_Integer, + (int)sqlite3LogEstToInt(pIdx->szIdxRow), 3); + sqlite3VdbeAddOp2(v, OP_Integer, (int)pIdx->aiRowEst[0], 4); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4); + } + } + } + break; + case PragTyp_INDEX_INFO: if( zRight ){ Index *pIdx; Table *pTab; @@ -1457,26 +1494,17 @@ void sqlite3Pragma( pTab = sqlite3FindTable(db, zRight, zDb); if( pTab ){ v = sqlite3GetVdbe(pParse); - sqlite3VdbeSetNumCols(v, 4); - pParse->nMem = 4; + sqlite3VdbeSetNumCols(v, 3); + pParse->nMem = 3; sqlite3CodeVerifySchema(pParse, iDb); sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "seq", SQLITE_STATIC); sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "name", SQLITE_STATIC); sqlite3VdbeSetColName(v, 2, COLNAME_NAME, "unique", SQLITE_STATIC); - sqlite3VdbeSetColName(v, 3, COLNAME_NAME, "avgrowsize", SQLITE_STATIC); - sqlite3VdbeAddOp2(v, OP_Integer, 0, 1); - sqlite3VdbeAddOp2(v, OP_Null, 0, 2); - sqlite3VdbeAddOp2(v, OP_Integer, 1, 3); - sqlite3VdbeAddOp2(v, OP_Integer, - (int)sqlite3LogEstToInt(pTab->szTabRow), 4); - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4); - for(pIdx=pTab->pIndex, i=1; pIdx; pIdx=pIdx->pNext, i++){ + for(pIdx=pTab->pIndex, i=0; pIdx; pIdx=pIdx->pNext, i++){ sqlite3VdbeAddOp2(v, OP_Integer, i, 1); sqlite3VdbeAddOp4(v, OP_String8, 0, 2, 0, pIdx->zName, 0); sqlite3VdbeAddOp2(v, OP_Integer, pIdx->onError!=OE_None, 3); - sqlite3VdbeAddOp2(v, OP_Integer, - (int)sqlite3LogEstToInt(pIdx->szIdxRow), 4); - sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 4); + sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 3); } } } diff --git a/test/pragma.test b/test/pragma.test index 808aeb04d9..a6d198eb69 100644 --- a/test/pragma.test +++ b/test/pragma.test @@ -574,7 +574,7 @@ ifcapable {foreignkey} { execsql { pragma index_list(t3); } - } {/0 {} 1 \d+ 1 sqlite_autoindex_t3_1 1 \d+/} + } {0 sqlite_autoindex_t3_1 1} } ifcapable {!foreignkey} { execsql {CREATE TABLE t3(a,b UNIQUE)} @@ -647,7 +647,7 @@ do_test pragma-7.1.1 { execsql { pragma index_list(t3); } -} {/0 {} 1 \d+ 1 t3i1 0 \d+ 2 sqlite_autoindex_t3_1 1 \d+/} +} {0 t3i1 0 1 sqlite_autoindex_t3_1 1} do_test pragma-7.1.2 { execsql { pragma index_list(t3_bogus); @@ -1661,7 +1661,7 @@ do_test 23.3 { CREATE INDEX i3 ON t1(d,b,c); } db2 eval {PRAGMA index_list(t1)} -} {/0 {} 1 \d+ 1 i3 0 \d+ 2 i2 0 \d+ 3 i1 0 \d+/} +} {0 i3 0 1 i2 0 2 i1 0} do_test 23.4 { db eval { ALTER TABLE t1 ADD COLUMN e; diff --git a/tool/mkpragmatab.tcl b/tool/mkpragmatab.tcl index a5d9f5ab6d..1ba0bd6be9 100644 --- a/tool/mkpragmatab.tcl +++ b/tool/mkpragmatab.tcl @@ -172,6 +172,10 @@ set pragma_def { FLAG: NeedSchema IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) + NAME: stats + FLAG: NeedSchema + IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) + NAME: index_info FLAG: NeedSchema IF: !defined(SQLITE_OMIT_SCHEMA_PRAGMAS) From c0f1d0c697825529319c42561fb2f0f016e84502 Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 14 Oct 2013 10:46:05 +0000 Subject: [PATCH 35/42] Add a new application_id for GeoPackage version 1.0. FossilOrigin-Name: 98ddfe45713775657e586f5a2499cf3c036f13dd --- magic.txt | 1 + manifest | 12 ++++++------ manifest.uuid | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/magic.txt b/magic.txt index 3351466680..c6340d9b18 100644 --- a/magic.txt +++ b/magic.txt @@ -26,4 +26,5 @@ >68 belong =0x42654c6e Bentley Systems Localization File - >60 belong =0x5f4d544e Monotone source repository - >68 belong =0x47504b47 OGC GeoPackage file - +>68 belong =0x47503130 OGC GeoPackage version 1.0 file - >0 string =SQLite SQLite3 database diff --git a/manifest b/manifest index dc0e75d8d8..93d93d8c84 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Restore\sthe\sindex_list\spragma\sback\sto\sits\sformer\soperation.\s\sCreate\sa\snew\nPRAGMA\sstats\sused\sto\saccess\sthe\stable\sand\sindex\swidths\sand\sheights. -D 2013-10-12T20:22:00.025 +C Add\sa\snew\sapplication_id\sfor\sGeoPackage\sversion\s1.0. +D 2013-10-14T10:46:05.794 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -139,7 +139,7 @@ F ext/rtree/tkt3363.test 142ab96eded44a3615ec79fba98c7bde7d0f96de F ext/rtree/viewrtree.tcl eea6224b3553599ae665b239bd827e182b466024 F install-sh 9d4de14ab9fb0facae2f48780b874848cbf2f895 x F ltmain.sh 3ff0879076df340d2e23ae905484d8c15d5fdea8 -F magic.txt f2b23a6bde8f1c6e86b957e4d94eab0add520b0d +F magic.txt 814d3de5ec227817ff2ad26cbc73159c968a2a58 F main.mk 2e01504061f618db804812143a9e9ec45a66ae70 F mkdll.sh 7d09b23c05d56532e9d44a50868eb4b12ff4f74a F mkextu.sh 416f9b7089d80e5590a29692c9d9280a10dbad9f @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 27001356ed8201529b3f31d4313f2010f1b4e1b1 -R f3adfc8132b3f36843e2e67728415fbc +P f0cf8c85dcbcc7778aed2816792c368d777f79cb +R 4f36494c4571dae8d7d76b44817e2e09 U drh -Z d16ae1a1de8f3334074e16125e33c2b1 +Z 654d268a6340b2587df2d3f244d3f538 diff --git a/manifest.uuid b/manifest.uuid index 6559ca61a5..988bedcc6f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -f0cf8c85dcbcc7778aed2816792c368d777f79cb \ No newline at end of file +98ddfe45713775657e586f5a2499cf3c036f13dd \ No newline at end of file From a7f4bf3f888bd3e581aa13a400e1594e0512b84f Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 14 Oct 2013 13:21:00 +0000 Subject: [PATCH 36/42] Make subroutines sampleCopy() and valueFromExpr() have file scope. FossilOrigin-Name: 1660efbe46439734c7dc1674994ceb86a9b41d1a --- manifest | 14 +++++++------- manifest.uuid | 2 +- src/analyze.c | 2 +- src/vdbemem.c | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/manifest b/manifest index 93d93d8c84..f602a8f225 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\sa\snew\sapplication_id\sfor\sGeoPackage\sversion\s1.0. -D 2013-10-14T10:46:05.794 +C Make\ssubroutines\ssampleCopy()\sand\svalueFromExpr()\shave\sfile\sscope. +D 2013-10-14T13:21:00.014 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -158,7 +158,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c 2af0330bb1b601af7a7789bf7229675fd772a083 -F src/analyze.c f9e4eec962f2d81d775d8d5c2efb27b84acb0be0 +F src/analyze.c c6259f93c9e9029df8e23e1093e0c650974ca7e5 F src/attach.c 0a17c9364895316ca4f52d06a97a72c0af1ae8b3 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 2f1987981139bd2f6d8c728d64bf09fb387443c3 @@ -284,7 +284,7 @@ F src/vdbeInt.h ff57f67aee1ba26a3a47e786533dab155ab6dad6 F src/vdbeapi.c 93a22a9ba2abe292d5c2cf304d7eb2e894dde0ed F src/vdbeaux.c 55f4858fe6abd84bd7311acbf30a75a28903ec25 F src/vdbeblob.c 5dc79627775bd9a9b494dd956e26297946417d69 -F src/vdbemem.c 28730af78c730cf230b64d62757a009668e76444 +F src/vdbemem.c 649933bad3e922465b726eaf85c72a75acba2ab7 F src/vdbesort.c 3937e06b2a0e354500e17dc206ef4c35770a5017 F src/vdbetrace.c e7ec40e1999ff3c6414424365d5941178966dcbc F src/vtab.c 5a423b042eb1402ef77697d03d6a67378d97bc8d @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P f0cf8c85dcbcc7778aed2816792c368d777f79cb -R 4f36494c4571dae8d7d76b44817e2e09 +P 98ddfe45713775657e586f5a2499cf3c036f13dd +R 967432a4e7657b2df96a7af6fdae0344 U drh -Z 654d268a6340b2587df2d3f244d3f538 +Z 96efb7a8ef8355039cf707d085dc7cb4 diff --git a/manifest.uuid b/manifest.uuid index 988bedcc6f..13ff7e5a8a 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -98ddfe45713775657e586f5a2499cf3c036f13dd \ No newline at end of file +1660efbe46439734c7dc1674994ceb86a9b41d1a \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index 98687f5ac3..de2f84e325 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -444,7 +444,7 @@ static int sampleIsBetter( /* ** Copy the contents of object (*pFrom) into (*pTo). */ -void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){ +static void sampleCopy(Stat4Accum *p, Stat4Sample *pTo, Stat4Sample *pFrom){ pTo->iRowid = pFrom->iRowid; pTo->isPSample = pFrom->isPSample; pTo->iCol = pFrom->iCol; diff --git a/src/vdbemem.c b/src/vdbemem.c index 91193bf2cf..b549c4a31a 100644 --- a/src/vdbemem.c +++ b/src/vdbemem.c @@ -1075,7 +1075,7 @@ static sqlite3_value *valueNew(sqlite3 *db, struct ValueNewStat4Ctx *p){ ** NULL, it is assumed that the caller will free any allocated object ** in all cases. */ -int valueFromExpr( +static int valueFromExpr( sqlite3 *db, /* The database connection */ Expr *pExpr, /* The expression to evaluate */ u8 enc, /* Encoding to use */ From 0ae4f14e458006e51456eed1631ad72d5328e77c Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 14 Oct 2013 14:21:59 +0000 Subject: [PATCH 37/42] Corrects to comments on the STAT4 implementation. FossilOrigin-Name: e06f74d32d44f281dd21908d401184f35f9455a4 --- manifest | 12 ++++++------ manifest.uuid | 2 +- src/analyze.c | 14 +++++++------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/manifest b/manifest index f602a8f225..660a6e9b4d 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Make\ssubroutines\ssampleCopy()\sand\svalueFromExpr()\shave\sfile\sscope. -D 2013-10-14T13:21:00.014 +C Corrects\sto\scomments\son\sthe\sSTAT4\simplementation. +D 2013-10-14T14:21:59.159 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -158,7 +158,7 @@ F sqlite.pc.in 42b7bf0d02e08b9e77734a47798d1a55a9e0716b F sqlite3.1 6be1ad09113570e1fc8dcaff84c9b0b337db5ffc F sqlite3.pc.in 48fed132e7cb71ab676105d2a4dc77127d8c1f3a F src/alter.c 2af0330bb1b601af7a7789bf7229675fd772a083 -F src/analyze.c c6259f93c9e9029df8e23e1093e0c650974ca7e5 +F src/analyze.c f1c5ed1fe128c3f106dcd95e97ee9ef94db7a3fa F src/attach.c 0a17c9364895316ca4f52d06a97a72c0af1ae8b3 F src/auth.c 523da7fb4979469955d822ff9298352d6b31de34 F src/backup.c 2f1987981139bd2f6d8c728d64bf09fb387443c3 @@ -1123,7 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 98ddfe45713775657e586f5a2499cf3c036f13dd -R 967432a4e7657b2df96a7af6fdae0344 +P 1660efbe46439734c7dc1674994ceb86a9b41d1a +R f477aeb6857af43b8fdd44c053eea21e U drh -Z 96efb7a8ef8355039cf707d085dc7cb4 +Z 5a50d5097c4b6be57e9ef1781ac233fc diff --git a/manifest.uuid b/manifest.uuid index 13ff7e5a8a..2cfee1187b 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1660efbe46439734c7dc1674994ceb86a9b41d1a \ No newline at end of file +e06f74d32d44f281dd21908d401184f35f9455a4 \ No newline at end of file diff --git a/src/analyze.c b/src/analyze.c index de2f84e325..30ea0f6065 100644 --- a/src/analyze.c +++ b/src/analyze.c @@ -31,7 +31,7 @@ ** SQLITE_ENABLE_STAT3 defined. The functionality of sqlite_stat3 ** is a superset of sqlite_stat2. The sqlite_stat4 is an enhanced ** version of sqlite_stat3 and is only available when compiled with -** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.0 and later. It is +** SQLITE_ENABLE_STAT4 and in SQLite versions 3.8.1 and later. It is ** not possible to enable both STAT3 and STAT4 at the same time. If they ** are both enabled, then STAT4 takes precedence. ** @@ -107,12 +107,12 @@ ** The idx column names the index and the tbl column is the table of the ** index. If the idx and tbl columns are the same, then the sample is ** of the INTEGER PRIMARY KEY. The sample column is a blob which is the -** binary encoding of a key from the index, with the trailing rowid -** omitted. The nEq column is a list of integers. The first integer -** is the approximate number of entries in the index whose left-most -** column exactly matches the left-most column of the sample. The second -** integer in nEq is the approximate number of entries in the index where -** the first two columns match the first two columns of the sample. +** binary encoding of a key from the index. The nEq column is a +** list of integers. The first integer is the approximate number +** of entries in the index whose left-most column exactly matches +** the left-most column of the sample. The second integer in nEq +** is the approximate number of entries in the index where the +** first two columns match the first two columns of the sample. ** And so forth. nLt is another list of integers that show the approximate ** number of entries that are strictly less than the sample. The first ** integer in nLt contains the number of entries in the index where the From 67896cef89c84695b3fe5af960f9fdce2d0cd63a Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 14 Oct 2013 15:41:39 +0000 Subject: [PATCH 38/42] Fix for building with SQLITE_OMIT_FOREIGN_KEY. FossilOrigin-Name: b8b5f6c8f646989bc62bb59416de9bca003a5896 --- manifest | 15 +++++++-------- manifest.uuid | 2 +- src/sqliteInt.h | 6 +++--- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/manifest b/manifest index 20cf3d6b53..477ef62207 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Update\sthe\sforeign_key_check\spragma\sso\sthat\swhen\sa\sparent\stable\sis\sundefined\nit\sis\streated\sas\san\sempty\stable. -D 2013-10-14T14:30:02.391 +C Fix\sfor\sbuilding\swith\sSQLITE_OMIT_FOREIGN_KEY. +D 2013-10-14T15:41:39.130 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -222,7 +222,7 @@ F src/shell.c 6f11f0e9ded63d48e306f2c6858c521e568a47bb F src/sqlite.h.in 4c6eb96fded1d56a27cec04b6b6803789eb28f54 F src/sqlite3.rc 11094cc6a157a028b301a9f06b3d03089ea37c3e F src/sqlite3ext.h 886f5a34de171002ad46fae8c36a7d8051c190fc -F src/sqliteInt.h eeebd2522bbd5ac7e3024be64113e8366caa66c8 +F src/sqliteInt.h 4dd81a25a919509ce94b1f8f120bbef14458d4b9 F src/sqliteLimit.h 164b0e6749d31e0daa1a4589a169d31c0dec7b3d F src/status.c 7ac05a5c7017d0b9f0b4bcd701228b784f987158 F src/table.c 2cd62736f845d82200acfa1287e33feb3c15d62e @@ -1123,8 +1123,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P e06f74d32d44f281dd21908d401184f35f9455a4 8c13a7fd738e5441af370537649b0bfa97679cda -R 569f3fd7fb4e81f584789e4d94c2c097 -T +closed 8c13a7fd738e5441af370537649b0bfa97679cda -U drh -Z 337ac35bfd11421ae22a03d4fa2d5ecb +P 208b259ad73b51e7df163fee3d7ed2bd79767597 +R d404755b57382c433b54a7ffeebb1595 +U dan +Z 9d63388bf55fa4140187d4341a01752c diff --git a/manifest.uuid b/manifest.uuid index cc50cbfe0f..b36e197eb9 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -208b259ad73b51e7df163fee3d7ed2bd79767597 \ No newline at end of file +b8b5f6c8f646989bc62bb59416de9bca003a5896 \ No newline at end of file diff --git a/src/sqliteInt.h b/src/sqliteInt.h index 17e9348af1..4974b2d0f3 100644 --- a/src/sqliteInt.h +++ b/src/sqliteInt.h @@ -3248,10 +3248,10 @@ const char *sqlite3JournalModename(int); FKey *sqlite3FkReferences(Table *); #else #define sqlite3FkActions(a,b,c,d,e,f) - #define sqlite3FkCheck(a,b,c,d) + #define sqlite3FkCheck(a,b,c,d,e,f) #define sqlite3FkDropTable(a,b,c) - #define sqlite3FkOldmask(a,b) 0 - #define sqlite3FkRequired(a,b,c,d,e,f) 0 + #define sqlite3FkOldmask(a,b) 0 + #define sqlite3FkRequired(a,b,c,d) 0 #endif #ifndef SQLITE_OMIT_FOREIGN_KEY void sqlite3FkDelete(sqlite3 *, Table*); From 362d21614e22ed56cbffd4f786965aac8ddabdcd Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 14 Oct 2013 20:30:51 +0000 Subject: [PATCH 39/42] Fix a crash in FTS incremental phrase processing that can occur if the second or subsequent token is much more common in the dataset than the first. FossilOrigin-Name: 0bf438fc30582a08fddfc3cec49366ee17ae2abe --- ext/fts3/fts3.c | 2 +- manifest | 17 ++++++++--------- manifest.uuid | 2 +- test/fts4incr.test | 22 ++++++++++++++++++++++ 4 files changed, 32 insertions(+), 11 deletions(-) diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index a3dfae22fe..dd6d38a59d 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -4331,7 +4331,7 @@ static int fts3EvalIncrPhraseNext( int i; /* Used to iterate through tokens */ /* Advance the iterator for each token in the phrase once. */ - for(i=0; rc==SQLITE_OK && inToken; i++){ + for(i=0; rc==SQLITE_OK && inToken && bEof==0; i++){ rc = incrPhraseTokenNext(pTab, p, i, &a[i], &bEof); if( a[i].bIgnore==0 && (bMaxSet==0 || DOCID_CMP(iMax, a[i].iDocid)<0) ){ iMax = a[i].iDocid; diff --git a/manifest b/manifest index 64348ab890..811db3a0b0 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Add\simplementations\sfor\sthe\stoInteger()\sand\stoReal()\sSQL\sfunctions. -D 2013-10-14T19:35:33.432 +C Fix\sa\scrash\sin\sFTS\sincremental\sphrase\sprocessing\sthat\scan\soccur\sif\sthe\ssecond\sor\ssubsequent\stoken\sis\smuch\smore\scommon\sin\sthe\sdataset\sthan\sthe\sfirst. +D 2013-10-14T20:30:51.215 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in e2d28ec95bd17ab4f3b6ee40b7102e9d7a0857b9 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -78,7 +78,7 @@ F ext/fts3/README.content fdc666a70d5257a64fee209f97cf89e0e6e32b51 F ext/fts3/README.syntax a19711dc5458c20734b8e485e75fb1981ec2427a F ext/fts3/README.tokenizers e0a8b81383ea60d0334d274fadf305ea14a8c314 F ext/fts3/README.txt 8c18f41574404623b76917b9da66fcb0ab38328d -F ext/fts3/fts3.c dcb90d12ff4a0ccfceaefb3bae2199b6536e0dfc +F ext/fts3/fts3.c f25ae5729d40cc4e661c0a552685038f27e72bc9 F ext/fts3/fts3.h 3a10a0af180d502cecc50df77b1b22df142817fe F ext/fts3/fts3Int.h 8689f7cf85020e7f88d1e761eeac480c3b0ea7ad F ext/fts3/fts3_aux.c b02632f6dd0e375ce97870206d914ea6d8df5ccd @@ -557,7 +557,7 @@ F test/fts4aa.test 0c3152322c7f0b548cc942ad763eaba0da87ccca F test/fts4check.test 66fa274cab2b615f2fb338b257713aba8fad88a8 F test/fts4content.test 2e7252557d6d24afa101d9ba1de710d6140e6d06 F test/fts4docid.test e33c383cfbdff0284685604d256f347a18fdbf01 -F test/fts4incr.test 2fae04582c2329a038b2b1f985e702478fb94888 +F test/fts4incr.test 361960ed3550e781f3f313e17e2182ef9cefc0e9 F test/fts4langid.test 24a6e41063b416bbdf371ff6b4476fa41c194aa7 F test/fts4merge.test c424309743fdd203f8e56a1f1cd7872cd66cc0ee F test/fts4merge2.test 5faa558d1b672f82b847d2a337465fa745e46891 @@ -1124,8 +1124,7 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P b8b5f6c8f646989bc62bb59416de9bca003a5896 a88b5be01e68b26267ff6eb05e931ef2e7fc9f99 -R fc9823e555e748e8dd749e50020ff907 -T +closed a88b5be01e68b26267ff6eb05e931ef2e7fc9f99 -U drh -Z f917a0a33a0846e0a4d8398bd8607f59 +P a0f7cbc068416cf55b86056f2ce7ee505c6cc3ea +R 5f9ee33bea159851b0bd3b4df54def2b +U dan +Z 1fee4cc09a93b480a53b5d3c883e606f diff --git a/manifest.uuid b/manifest.uuid index 91226e5773..f84250b290 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -a0f7cbc068416cf55b86056f2ce7ee505c6cc3ea \ No newline at end of file +0bf438fc30582a08fddfc3cec49366ee17ae2abe \ No newline at end of file diff --git a/test/fts4incr.test b/test/fts4incr.test index a9799b351d..17212efce7 100644 --- a/test/fts4incr.test +++ b/test/fts4incr.test @@ -50,4 +50,26 @@ foreach {tn q res} { puts "with optimization: $t(0) without: $t(1)" } +do_test 2.1 { + execsql { + CREATE VIRTUAL TABLE t2 USING fts4(order=DESC); + } + set num [list one two three four five six seven eight nine ten] + execsql BEGIN + for {set i 0} {$i < 10000} {incr i} { + set x "[lindex $num [expr $i%10]] zero" + execsql { INSERT INTO t2(docid, content) VALUES($i, $x) } + } + execsql COMMIT + execsql { INSERT INTO t2(t2) VALUES('optimize') } +} {} + +do_execsql_test 2.2 { + SELECT count(*) FROM t2 WHERE t2 MATCH '"never zero"' +} {0} + +do_execsql_test 2.3 { + SELECT count(*) FROM t2 WHERE t2 MATCH '"two zero"' +} {1000} + finish_test From 5f8cdac620fbf61fbdebd173f18b06b7f6f1906f Mon Sep 17 00:00:00 2001 From: drh Date: Mon, 14 Oct 2013 21:14:42 +0000 Subject: [PATCH 40/42] Move the tointeger() and toreal() functions out of core and make them into a run-time loadable extension. FossilOrigin-Name: 9f66dd7e3790c04f0ab724419f5381bd21f9ebad --- Makefile.in | 1 + Makefile.msc | 1 + ext/misc/totype.c | 503 ++++++++++++++++++++++++++++++++++++++++++++++ main.mk | 1 + manifest | 25 +-- manifest.uuid | 2 +- src/func.c | 141 ------------- src/test1.c | 2 + test/func4.test | 5 +- 9 files changed, 525 insertions(+), 156 deletions(-) create mode 100644 ext/misc/totype.c diff --git a/Makefile.in b/Makefile.in index 91cac6ed37..f01cae05e7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -396,6 +396,7 @@ TESTSRC += \ $(TOP)/ext/misc/percentile.c \ $(TOP)/ext/misc/regexp.c \ $(TOP)/ext/misc/spellfix.c \ + $(TOP)/ext/misc/totype.c \ $(TOP)/ext/misc/wholenumber.c # Source code to the library files needed by the test fixture diff --git a/Makefile.msc b/Makefile.msc index f50b31b418..b9aeea334b 100644 --- a/Makefile.msc +++ b/Makefile.msc @@ -782,6 +782,7 @@ TESTEXT = \ $(TOP)\ext\misc\percentile.c \ $(TOP)\ext\misc\regexp.c \ $(TOP)\ext\misc\spellfix.c \ + $(TOP)\ext\misc\totype.c \ $(TOP)\ext\misc\wholenumber.c diff --git a/ext/misc/totype.c b/ext/misc/totype.c new file mode 100644 index 0000000000..e7288d56ba --- /dev/null +++ b/ext/misc/totype.c @@ -0,0 +1,503 @@ +/* +** 2013-10-14 +** +** The author disclaims copyright to this source code. In place of +** a legal notice, here is a blessing: +** +** May you do good and not evil. +** May you find forgiveness for yourself and forgive others. +** May you share freely, never taking more than you give. +** +****************************************************************************** +** +** This SQLite extension implements functions tointeger(X) and toreal(X). +** +** If X is an integer, real, or string value that can be +** losslessly represented as an integer, then tointeger(X) +** returns the corresponding integer value. +** If X is an 8-byte BLOB then that blob is interpreted as +** a signed two-compliment little-endian encoding of an integer +** and tointeger(X) returns the corresponding integer value. +** Otherwise tointeger(X) return NULL. +** +** If X is an integer, real, or string value that can be +** convert into a real number, preserving at least 15 digits +** of precision, then toreal(X) returns the corresponding real value. +** If X is an 8-byte BLOB then that blob is interpreted as +** a 64-bit IEEE754 big-endian floating point value +** and toreal(X) returns the corresponding real value. +** Otherwise toreal(X) return NULL. +** +** Note that tointeger(X) of an 8-byte BLOB assumes a little-endian +** encoding whereas toreal(X) of an 8-byte BLOB assumes a big-endian +** encoding. +*/ +#include "sqlite3ext.h" +SQLITE_EXTENSION_INIT1 +#include +#include + +/* +** Determine if this is running on a big-endian or little-endian +** processor +*/ +#if defined(i386) || defined(__i386__) || defined(_M_IX86)\ + || defined(__x86_64) || defined(__x86_64__) +# define SQLITE_BIGENDIAN 0 +# define SQLITE_LITTLEENDIAN 1 +#else + const int totype_one = 1; +# define SQLITE_BIGENDIAN (*(char *)(&totype_one)==0) +# define SQLITE_LITTLEENDIAN (*(char *)(&totype_one)==1) +#endif + +/* +** Constants for the largest and smallest possible 64-bit signed integers. +** These macros are designed to work correctly on both 32-bit and 64-bit +** compilers. +*/ +#define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32)) +#define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64) + +/* +** Return TRUE if character c is a whitespace character +*/ +static int totypeIsspace(unsigned char c){ + return c==' ' || c=='\t' || c=='\n' || c=='\r'; +} + +/* +** Return TRUE if character c is a digit +*/ +static int totypeIsdigit(unsigned char c){ + return c>='0' && c<='9'; +} + +/* +** Compare the 19-character string zNum against the text representation +** value 2^63: 9223372036854775808. Return negative, zero, or positive +** if zNum is less than, equal to, or greater than the string. +** Note that zNum must contain exactly 19 characters. +** +** Unlike memcmp() this routine is guaranteed to return the difference +** in the values of the last digit if the only difference is in the +** last digit. So, for example, +** +** totypeCompare2pow63("9223372036854775800", 1) +** +** will return -8. +*/ +static int totypeCompare2pow63(const char *zNum){ + int c = 0; + int i; + /* 012345678901234567 */ + const char *pow63 = "922337203685477580"; + for(i=0; c==0 && i<18; i++){ + c = (zNum[i]-pow63[i])*10; + } + if( c==0 ){ + c = zNum[18] - '8'; + } + return c; +} + +/* +** Convert zNum to a 64-bit signed integer. +** +** If the zNum value is representable as a 64-bit twos-complement +** integer, then write that value into *pNum and return 0. +** +** If zNum is exactly 9223372036854665808, return 2. This special +** case is broken out because while 9223372036854665808 cannot be a +** signed 64-bit integer, its negative -9223372036854665808 can be. +** +** If zNum is too big for a 64-bit integer and is not +** 9223372036854665808 or if zNum contains any non-numeric text, +** then return 1. +*/ +static int totypeAtoi64(const char *zNum, sqlite3_int64 *pNum, int length){ + sqlite3_uint64 u = 0; + int neg = 0; /* assume positive */ + int i; + int c = 0; + int nonNum = 0; + const char *zStart; + const char *zEnd = zNum + length; + + while( zNum='0' && c<='9'; i++){ + u = u*10 + c - '0'; + } + if( u>LARGEST_INT64 ){ + *pNum = SMALLEST_INT64; + }else if( neg ){ + *pNum = -(sqlite3_int64)u; + }else{ + *pNum = (sqlite3_int64)u; + } + if( (c!=0 && &zNum[i]19 || nonNum ){ + /* zNum is empty or contains non-numeric text or is longer + ** than 19 digits (thus guaranteeing that it is too large) */ + return 1; + }else if( i<19 ){ + /* Less than 19 digits, so we know that it fits in 64 bits */ + assert( u<=LARGEST_INT64 ); + return 0; + }else{ + /* zNum is a 19-digit numbers. Compare it against 9223372036854775808. */ + c = totypeCompare2pow63(zNum); + if( c<0 ){ + /* zNum is less than 9223372036854775808 so it fits */ + assert( u<=LARGEST_INT64 ); + return 0; + }else if( c>0 ){ + /* zNum is greater than 9223372036854775808 so it overflows */ + return 1; + }else{ + /* zNum is exactly 9223372036854775808. Fits if negative. The + ** special case 2 overflow if positive */ + assert( u-1==LARGEST_INT64 ); + assert( (*pNum)==SMALLEST_INT64 ); + return neg ? 0 : 2; + } + } +} +/* +** The string z[] is an text representation of a real number. +** Convert this string to a double and write it into *pResult. +** +** The string z[] is length bytes in length (bytes, not characters) and +** uses the encoding enc. The string is not necessarily zero-terminated. +** +** Return TRUE if the result is a valid real number (or integer) and FALSE +** if the string is empty or contains extraneous text. Valid numbers +** are in one of these formats: +** +** [+-]digits[E[+-]digits] +** [+-]digits.[digits][E[+-]digits] +** [+-].digits[E[+-]digits] +** +** Leading and trailing whitespace is ignored for the purpose of determining +** validity. +** +** If some prefix of the input string is a valid number, this routine +** returns FALSE but it still converts the prefix and writes the result +** into *pResult. +*/ +static int totypeAtoF(const char *z, double *pResult, int length){ + const char *zEnd = z + length; + /* sign * significand * (10 ^ (esign * exponent)) */ + int sign = 1; /* sign of significand */ + sqlite3_int64 s = 0; /* significand */ + int d = 0; /* adjust exponent for shifting decimal point */ + int esign = 1; /* sign of exponent */ + int e = 0; /* exponent */ + int eValid = 1; /* True exponent is either not used or is well-formed */ + double result; + int nDigits = 0; + int nonNum = 0; + + *pResult = 0.0; /* Default return value, in case of an error */ + + /* skip leading spaces */ + while( z=zEnd ) return 0; + + /* get sign of significand */ + if( *z=='-' ){ + sign = -1; + z++; + }else if( *z=='+' ){ + z++; + } + + /* skip leading zeroes */ + while( z=zEnd ) goto totype_atof_calc; + + /* if decimal point is present */ + if( *z=='.' ){ + z++; + /* copy digits from after decimal to significand + ** (decrease exponent by d to shift decimal right) */ + while( z=zEnd ) goto totype_atof_calc; + + /* if exponent is present */ + if( *z=='e' || *z=='E' ){ + z++; + eValid = 0; + if( z>=zEnd ) goto totype_atof_calc; + /* get sign of exponent */ + if( *z=='-' ){ + esign = -1; + z++; + }else if( *z=='+' ){ + z++; + } + /* copy digits to exponent */ + while( z0 ){ + while( s<(LARGEST_INT64/10) && e>0 ) e--,s*=10; + }else{ + while( !(s%10) && e>0 ) e--,s/=10; + } + + /* adjust the sign of significand */ + s = sign<0 ? -s : s; + + /* if exponent, scale significand as appropriate + ** and store in result. */ + if( e ){ + double scale = 1.0; + /* attempt to handle extremely small/large numbers better */ + if( e>307 && e<342 ){ + while( e%308 ) { scale *= 1.0e+1; e -= 1; } + if( esign<0 ){ + result = s / scale; + result /= 1.0e+308; + }else{ + result = s * scale; + result *= 1.0e+308; + } + }else if( e>=342 ){ + if( esign<0 ){ + result = 0.0*s; + }else{ + result = 1e308*1e308*s; /* Infinity */ + } + }else{ + /* 1.0e+22 is the largest power of 10 than can be + ** represented exactly. */ + while( e%22 ) { scale *= 1.0e+1; e -= 1; } + while( e>0 ) { scale *= 1.0e+22; e -= 22; } + if( esign<0 ){ + result = s / scale; + }else{ + result = s * scale; + } + } + } else { + result = (double)s; + } + } + + /* store the result */ + *pResult = result; + + /* return true if number and no extra non-whitespace chracters after */ + return z>=zEnd && nDigits>0 && eValid && nonNum==0; +} + +/* +** tointeger(X): If X is any value (integer, double, blob, or string) that +** can be losslessly converted into an integer, then make the conversion and +** return the result. Otherwise, return NULL. +*/ +static void tointegerFunc( + sqlite3_context *context, + int argc, + sqlite3_value **argv +){ + assert( argc==1 ); + (void)argc; + switch( sqlite3_value_type(argv[0]) ){ + case SQLITE_FLOAT: { + double rVal = sqlite3_value_double(argv[0]); + sqlite3_int64 iVal = (sqlite3_int64)rVal; + if( rVal==(double)iVal ){ + sqlite3_result_int64(context, iVal); + } + break; + } + case SQLITE_INTEGER: { + sqlite3_result_int64(context, sqlite3_value_int64(argv[0])); + break; + } + case SQLITE_BLOB: { + const unsigned char *zBlob = sqlite3_value_blob(argv[0]); + if( zBlob ){ + int nBlob = sqlite3_value_bytes(argv[0]); + if( nBlob==sizeof(sqlite3_int64) ){ + sqlite3_int64 iVal; + if( SQLITE_BIGENDIAN ){ + int i; + unsigned char zBlobRev[sizeof(sqlite3_int64)]; + for(i=0; i Date: Mon, 14 Oct 2013 22:35:40 +0000 Subject: [PATCH 41/42] Fix harmless compiler warning in the totype extension. Include all standard whitespace characters in totypeIsspace. Minor adjustments to style and comments. FossilOrigin-Name: 73238f655a58c810876f46cc04eab1ac2d5b8ef7 --- ext/misc/totype.c | 34 +++++++++++++++++++--------------- manifest | 14 +++++++------- manifest.uuid | 2 +- 3 files changed, 27 insertions(+), 23 deletions(-) diff --git a/ext/misc/totype.c b/ext/misc/totype.c index e7288d56ba..bb4acb267d 100644 --- a/ext/misc/totype.c +++ b/ext/misc/totype.c @@ -43,12 +43,12 @@ SQLITE_EXTENSION_INIT1 */ #if defined(i386) || defined(__i386__) || defined(_M_IX86)\ || defined(__x86_64) || defined(__x86_64__) -# define SQLITE_BIGENDIAN 0 -# define SQLITE_LITTLEENDIAN 1 +# define TOTYPE_BIGENDIAN 0 +# define TOTYPE_LITTLEENDIAN 1 #else const int totype_one = 1; -# define SQLITE_BIGENDIAN (*(char *)(&totype_one)==0) -# define SQLITE_LITTLEENDIAN (*(char *)(&totype_one)==1) +# define TOTYPE_BIGENDIAN (*(char *)(&totype_one)==0) +# define TOTYPE_LITTLEENDIAN (*(char *)(&totype_one)==1) #endif /* @@ -63,7 +63,7 @@ SQLITE_EXTENSION_INIT1 ** Return TRUE if character c is a whitespace character */ static int totypeIsspace(unsigned char c){ - return c==' ' || c=='\t' || c=='\n' || c=='\r'; + return c==' ' || c=='\t' || c=='\n' || c=='\v' || c=='\f' || c=='\r'; } /* @@ -83,7 +83,7 @@ static int totypeIsdigit(unsigned char c){ ** in the values of the last digit if the only difference is in the ** last digit. So, for example, ** -** totypeCompare2pow63("9223372036854775800", 1) +** totypeCompare2pow63("9223372036854775800") ** ** will return -8. */ @@ -104,16 +104,18 @@ static int totypeCompare2pow63(const char *zNum){ /* ** Convert zNum to a 64-bit signed integer. ** -** If the zNum value is representable as a 64-bit twos-complement +** If the zNum value is representable as a 64-bit twos-complement ** integer, then write that value into *pNum and return 0. ** ** If zNum is exactly 9223372036854665808, return 2. This special -** case is broken out because while 9223372036854665808 cannot be a +** case is broken out because while 9223372036854665808 cannot be a ** signed 64-bit integer, its negative -9223372036854665808 can be. ** ** If zNum is too big for a 64-bit integer and is not ** 9223372036854665808 or if zNum contains any non-numeric text, ** then return 1. +** +** The string is not necessarily zero-terminated. */ static int totypeAtoi64(const char *zNum, sqlite3_int64 *pNum, int length){ sqlite3_uint64 u = 0; @@ -172,12 +174,12 @@ static int totypeAtoi64(const char *zNum, sqlite3_int64 *pNum, int length){ } } } + /* ** The string z[] is an text representation of a real number. ** Convert this string to a double and write it into *pResult. ** -** The string z[] is length bytes in length (bytes, not characters) and -** uses the encoding enc. The string is not necessarily zero-terminated. +** The string is not necessarily zero-terminated. ** ** Return TRUE if the result is a valid real number (or integer) and FALSE ** if the string is empty or contains extraneous text. Valid numbers @@ -321,7 +323,7 @@ totype_atof_calc: result = 1e308*1e308*s; /* Infinity */ } }else{ - /* 1.0e+22 is the largest power of 10 than can be + /* 1.0e+22 is the largest power of 10 than can be ** represented exactly. */ while( e%22 ) { scale *= 1.0e+1; e -= 1; } while( e>0 ) { scale *= 1.0e+22; e -= 22; } @@ -374,7 +376,7 @@ static void tointegerFunc( int nBlob = sqlite3_value_bytes(argv[0]); if( nBlob==sizeof(sqlite3_int64) ){ sqlite3_int64 iVal; - if( SQLITE_BIGENDIAN ){ + if( TOTYPE_BIGENDIAN ){ int i; unsigned char zBlobRev[sizeof(sqlite3_int64)]; for(i=0; i Date: Tue, 15 Oct 2013 10:43:04 +0000 Subject: [PATCH 42/42] Fix harmless macro redefinition warnings in the totype extension. FossilOrigin-Name: a38adeb7ffd77474754b66877d60717cdb3cb865 --- ext/misc/totype.c | 9 +++++++-- manifest | 15 +++++++++------ manifest.uuid | 2 +- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ext/misc/totype.c b/ext/misc/totype.c index bb4acb267d..5dc99f3d7d 100644 --- a/ext/misc/totype.c +++ b/ext/misc/totype.c @@ -56,8 +56,13 @@ SQLITE_EXTENSION_INIT1 ** These macros are designed to work correctly on both 32-bit and 64-bit ** compilers. */ -#define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32)) -#define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64) +#ifndef LARGEST_INT64 +# define LARGEST_INT64 (0xffffffff|(((sqlite3_int64)0x7fffffff)<<32)) +#endif + +#ifndef SMALLEST_INT64 +# define SMALLEST_INT64 (((sqlite3_int64)-1) - LARGEST_INT64) +#endif /* ** Return TRUE if character c is a whitespace character diff --git a/manifest b/manifest index 787b522208..f74bebdfc2 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\sharmless\scompiler\swarning\sin\sthe\stotype\sextension.\s\sInclude\sall\sstandard\swhitespace\scharacters\sin\stotypeIsspace.\s\sMinor\sadjustments\sto\sstyle\sand\scomments. -D 2013-10-14T22:35:40.075 +C Fix\sharmless\smacro\sredefinition\swarnings\sin\sthe\stotype\sextension. +D 2013-10-15T10:43:04.884 F Makefile.arm-wince-mingw32ce-gcc d6df77f1f48d690bd73162294bbba7f59507c72f F Makefile.in 0522b53cdc1fcfc18f3a98e0246add129136c654 F Makefile.linux-gcc 91d710bdc4998cb015f39edf3cb314ec4f4d7e23 @@ -115,7 +115,7 @@ F ext/misc/percentile.c bcbee3c061b884eccb80e21651daaae8e1e43c63 F ext/misc/regexp.c af92cdaa5058fcec1451e49becc7ba44dba023dc F ext/misc/rot13.c 1ac6f95f99b575907b9b09c81a349114cf9be45a F ext/misc/spellfix.c 5e1d547e9a2aed13897fa91bac924333f62fd2d9 -F ext/misc/totype.c 86eeb8efb5c0e1a09d713e4183ff1eda95c8f342 +F ext/misc/totype.c 4a167594e791abeed95e0a8db028822b5e8fe512 F ext/misc/vfslog.c 1abb192d8d4bd323adbddec0c024580496b51b7a F ext/misc/vtshim.c babb0dc2bf116029e3e7c9a618b8a1377045303e F ext/misc/wholenumber.c 784b12543d60702ebdd47da936e278aa03076212 @@ -1125,7 +1125,10 @@ F tool/vdbe-compress.tcl f12c884766bd14277f4fcedcae07078011717381 F tool/warnings-clang.sh f6aa929dc20ef1f856af04a730772f59283631d4 F tool/warnings.sh d1a6de74685f360ab718efda6265994b99bbea01 F tool/win/sqlite.vsix 030f3eeaf2cb811a3692ab9c14d021a75ce41fff -P 9f66dd7e3790c04f0ab724419f5381bd21f9ebad -R f21c7b96aefc2201770b50ac2899ad7e +P 73238f655a58c810876f46cc04eab1ac2d5b8ef7 +R 0fe1cba58471de6f4ef89edb477677c8 +T *branch * noWarnings +T *sym-noWarnings * +T -sym-trunk * U mistachkin -Z 42e92dc11d48272f024e4ddd08e08231 +Z 63a2ac2e5d8e33918534e02f647beddb diff --git a/manifest.uuid b/manifest.uuid index d796a6ec13..43452c755f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -73238f655a58c810876f46cc04eab1ac2d5b8ef7 \ No newline at end of file +a38adeb7ffd77474754b66877d60717cdb3cb865 \ No newline at end of file