Increase strictness of the new experimental functions and add more tests.

FossilOrigin-Name: 05c4463ec5f36dde50f6eb116624dc40142f2c8c
This commit is contained in:
mistachkin 2013-03-12 09:07:25 +00:00
parent 32be00a55b
commit ee1c64ed25
5 changed files with 134 additions and 20 deletions

View File

@ -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

View File

@ -1 +1 @@
f9468e334d6086b8a80c6a4204ec4e03fe59cf96
05c4463ec5f36dde50f6eb116624dc40142f2c8c

View File

@ -19,6 +19,9 @@
#include "sqliteInt.h"
#include <stdlib.h>
#include <assert.h>
#ifndef SQLITE_OMIT_FLOATING_POINT
# include <math.h>
#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]);

View File

@ -347,6 +347,8 @@
# define SQLITE_OMIT_TRACE 1
# undef SQLITE_MIXED_ENDIAN_64BIT_FLOAT
# undef SQLITE_HAVE_ISNAN
#else
# include <math.h>
#endif
#ifndef SQLITE_BIG_DBL
# define SQLITE_BIG_DBL (1e99)

View File

@ -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