From 69f3d04810dd4793ce5bc4517158e7d4df6fba11 Mon Sep 17 00:00:00 2001 From: mistachkin Date: Mon, 11 Mar 2013 01:23:37 +0000 Subject: [PATCH 1/4] 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 2/4] 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 3/4] 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 4/4] 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] {