mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-30 19:03:16 +03:00
Changes to completely remove all floating point ops if SQLITE_OMIT_FLOATING_POINT defined. Note that w/o fp, date/time, round, nan, etc. are all gone or limited in functionality. Updated some of the test scripts to support missing fp and 64-bit functionality. Ticket #3029. (CVS 6250)
FossilOrigin-Name: 5cef400023205b55152b91441acc78f9cd8d58a9
This commit is contained in:
34
manifest
34
manifest
@ -1,5 +1,5 @@
|
|||||||
C Remove\scompiler\swarnings\sunder\sMSVC.\s(CVS\s6249)
|
C Changes\sto\scompletely\sremove\sall\sfloating\spoint\sops\sif\sSQLITE_OMIT_FLOATING_POINT\sdefined.\s\sNote\sthat\sw/o\sfp,\sdate/time,\sround,\snan,\setc.\sare\sall\sgone\sor\slimited\sin\sfunctionality.\s\s\sUpdated\ssome\sof\sthe\stest\sscripts\sto\ssupport\smissing\sfp\sand\s64-bit\sfunctionality.\s\s\sTicket\s#3029.\s(CVS\s6250)
|
||||||
D 2009-02-04T01:49:30
|
D 2009-02-04T03:59:25
|
||||||
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0
|
||||||
F Makefile.in c7a5a30fb6852bd7839b1024e1661da8549878ee
|
F Makefile.in c7a5a30fb6852bd7839b1024e1661da8549878ee
|
||||||
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654
|
||||||
@ -110,11 +110,11 @@ F src/btreeInt.h 0a4884e6152d7cae9c741e91b830064c19fd2c05
|
|||||||
F src/build.c 6f3d5f74e262d561d77f0210c6063b7122f16c98
|
F src/build.c 6f3d5f74e262d561d77f0210c6063b7122f16c98
|
||||||
F src/callback.c 5f10bca853e59a2c272bbfd5b720303f8b69e520
|
F src/callback.c 5f10bca853e59a2c272bbfd5b720303f8b69e520
|
||||||
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
|
F src/complete.c cb14e06dbe79dee031031f0d9e686ff306afe07c
|
||||||
F src/date.c 870770dde3fb56772ab247dfb6a6eda44d16cfbc
|
F src/date.c 0d804df3bbda46329946a01ff5c75c3f4f135218
|
||||||
F src/delete.c 6249005bdd8f85db6ec5f31ddb5c07de023693cc
|
F src/delete.c 6249005bdd8f85db6ec5f31ddb5c07de023693cc
|
||||||
F src/expr.c 76dc3dc83b56ab8db50a772714fac49def8bbf12
|
F src/expr.c e60f69f624a03a8f493900b071b3affbfa699585
|
||||||
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
|
F src/fault.c dc88c821842157460750d2d61a8a8b4197d047ff
|
||||||
F src/func.c ec95417daf260fe574d8a6500946db30e88242ed
|
F src/func.c 35d6f4a98c5fd5d504fd92a9197bae3220bbac39
|
||||||
F src/global.c ab003581ea4ff193cfe17a00e1303bc51db619a5
|
F src/global.c ab003581ea4ff193cfe17a00e1303bc51db619a5
|
||||||
F src/hash.c 5824e6ff7ba78cd34c8d6cd724367713583e5b55
|
F src/hash.c 5824e6ff7ba78cd34c8d6cd724367713583e5b55
|
||||||
F src/hash.h 28f38ebb1006a5beedcb013bcdfe31befe7437ae
|
F src/hash.h 28f38ebb1006a5beedcb013bcdfe31befe7437ae
|
||||||
@ -123,7 +123,7 @@ F src/insert.c f6db1e6f43aae337e64a755208abb6ff124edc19
|
|||||||
F src/journal.c e00df0c0da8413ab6e1bb7d7cab5665d4a9000d0
|
F src/journal.c e00df0c0da8413ab6e1bb7d7cab5665d4a9000d0
|
||||||
F src/legacy.c 8b3b95d48d202614946d7ce7256e7ba898905c3b
|
F src/legacy.c 8b3b95d48d202614946d7ce7256e7ba898905c3b
|
||||||
F src/loadext.c 3f96631089fc4f3871a67f02f2e4fc7ea4d51edc
|
F src/loadext.c 3f96631089fc4f3871a67f02f2e4fc7ea4d51edc
|
||||||
F src/main.c da51988dd4d75de4ccc66d2c99dd1b5b3b266e6c
|
F src/main.c abc8351627679bcf95ddc0539360ee93c00ac8cc
|
||||||
F src/malloc.c bc408056b126db37b6fba00e170d578cc67be6b3
|
F src/malloc.c bc408056b126db37b6fba00e170d578cc67be6b3
|
||||||
F src/mem0.c f2f84062d1f35814d6535c9f9e33de3bfb3b132c
|
F src/mem0.c f2f84062d1f35814d6535c9f9e33de3bfb3b132c
|
||||||
F src/mem1.c 3bfb39e4f60b0179713a7c087b2d4f0dc205735f
|
F src/mem1.c 3bfb39e4f60b0179713a7c087b2d4f0dc205735f
|
||||||
@ -142,7 +142,7 @@ F src/os.h f996ab57d2035a20e63173419055608548a834c6
|
|||||||
F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
|
F src/os_common.h 24525d8b7bce66c374dfc1810a6c9043f3359b60
|
||||||
F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5
|
F src/os_os2.c bed77dc26e3a95ce4a204936b9a1ca6fe612fcc5
|
||||||
F src/os_unix.c f0fce3042011d462b8ae633564a5668260bd3636
|
F src/os_unix.c f0fce3042011d462b8ae633564a5668260bd3636
|
||||||
F src/os_win.c ec133f2a3c0da786995ea09ba67056af8f18cc2e
|
F src/os_win.c b83b57c24ec5bca07cb0eca6f620e796209e952f
|
||||||
F src/pager.c 1181eac160b1bc58108deb013624437ed695d15f
|
F src/pager.c 1181eac160b1bc58108deb013624437ed695d15f
|
||||||
F src/pager.h 0c9f3520c00d8a3b8e792ca56c9a11b6b02b4b0f
|
F src/pager.h 0c9f3520c00d8a3b8e792ca56c9a11b6b02b4b0f
|
||||||
F src/parse.y 4f4d16aee0d11f69fec2adb77dac88878043ed8d
|
F src/parse.y 4f4d16aee0d11f69fec2adb77dac88878043ed8d
|
||||||
@ -198,18 +198,18 @@ F src/tokenize.c 6987fb7f0d6a87ac53499aee568cabb05eb4bea8
|
|||||||
F src/trigger.c ca6d78f7c1314053800386ca64361e487774fda3
|
F src/trigger.c ca6d78f7c1314053800386ca64361e487774fda3
|
||||||
F src/update.c 8c4925f9ca664effc8a1faaad67449d2074567b1
|
F src/update.c 8c4925f9ca664effc8a1faaad67449d2074567b1
|
||||||
F src/utf.c 1da9c832dba0fa8f865b5b902d93f420a1ee4245
|
F src/utf.c 1da9c832dba0fa8f865b5b902d93f420a1ee4245
|
||||||
F src/util.c f1ac1bcd3ec5e3300982031504659b6f9435de33
|
F src/util.c 1363f64351f3b544790f3c523439354c02f8c4e9
|
||||||
F src/vacuum.c 4929a585ef0fb1dfaf46302f8a9c4aa30c2d9cf5
|
F src/vacuum.c 4929a585ef0fb1dfaf46302f8a9c4aa30c2d9cf5
|
||||||
F src/vdbe.c 81120d5a5ba2d93eb7d7f66e814bbc811305daa2
|
F src/vdbe.c c719017876405d32c9f342e39dc5b10dceff5811
|
||||||
F src/vdbe.h 03516f28bf5aca00a53c4dccd6c313f96adb94f6
|
F src/vdbe.h 03516f28bf5aca00a53c4dccd6c313f96adb94f6
|
||||||
F src/vdbeInt.h 13cb4868ea579b5a8f6b6b5098caa99cd5a14078
|
F src/vdbeInt.h 13cb4868ea579b5a8f6b6b5098caa99cd5a14078
|
||||||
F src/vdbeapi.c 85c33cfbfa56249cbe627831610afafba754477d
|
F src/vdbeapi.c b23c4b1686f150a0ddc36459c8e3876be62638e1
|
||||||
F src/vdbeaux.c 75c3ac2a3c37747ae66ea0935f8f48bb1879234a
|
F src/vdbeaux.c 75c3ac2a3c37747ae66ea0935f8f48bb1879234a
|
||||||
F src/vdbeblob.c b0dcebfafedcf9c0addc7901ad98f6f986c08935
|
F src/vdbeblob.c b0dcebfafedcf9c0addc7901ad98f6f986c08935
|
||||||
F src/vdbemem.c c6127c335f802ba159c6fec4e3284ba82a070602
|
F src/vdbemem.c 543a79d722734d2f8b7ad70f08218c30bcc5bbf5
|
||||||
F src/vtab.c e39e011d7443a8d574b1b9cde207a35522e6df43
|
F src/vtab.c e39e011d7443a8d574b1b9cde207a35522e6df43
|
||||||
F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d
|
F src/walker.c 488c2660e13224ff70c0c82761118efb547f8f0d
|
||||||
F src/where.c fb89dfb2d9f99ed75c8bff6148fdae07791d7a91
|
F src/where.c 63bb752784b352d8e226dc6b1ec02f0d19fed916
|
||||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||||
F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911
|
F test/alias.test 597662c5d777a122f9a3df0047ea5c5bd383a911
|
||||||
F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45
|
F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45
|
||||||
@ -314,7 +314,7 @@ F test/eval.test bc269c365ba877554948441e91ad5373f9f91be3
|
|||||||
F test/exclusive.test cb991e44aa7cf744976143afce18586920f6696a
|
F test/exclusive.test cb991e44aa7cf744976143afce18586920f6696a
|
||||||
F test/exclusive2.test 6bdf254770a843c2933b54bee9ed239934f0a183
|
F test/exclusive2.test 6bdf254770a843c2933b54bee9ed239934f0a183
|
||||||
F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7
|
F test/exec.test e949714dc127eaa5ecc7d723efec1ec27118fdd7
|
||||||
F test/expr.test bc1e6997c27238f6de539f1079ff93e5078ea7c3
|
F test/expr.test 80f3cf99f786ffbac19d2b0083673e7fc797030f
|
||||||
F test/filectrl.test 8923a6dc7630f31c8a9dd3d3d740aa0922df7bf8
|
F test/filectrl.test 8923a6dc7630f31c8a9dd3d3d740aa0922df7bf8
|
||||||
F test/filefmt.test 053b622009fbbb74dd37921ffad374d852c13cd8
|
F test/filefmt.test 053b622009fbbb74dd37921ffad374d852c13cd8
|
||||||
F test/fkey1.test 78506fa55800d553d8fe1f3e7f73ce996fd2cef9
|
F test/fkey1.test 78506fa55800d553d8fe1f3e7f73ce996fd2cef9
|
||||||
@ -377,7 +377,7 @@ F test/fts3e.test 1f6c6ac9cc8b772ca256e6b22aaeed50c9350851
|
|||||||
F test/fts3expr.test 000f05df771e203187ceac49ad21c303c720b783
|
F test/fts3expr.test 000f05df771e203187ceac49ad21c303c720b783
|
||||||
F test/fts3expr2.test 8501de895a4c0631e7226c9bac055cd49c9f6646
|
F test/fts3expr2.test 8501de895a4c0631e7226c9bac055cd49c9f6646
|
||||||
F test/fts3near.test dc196dd17b4606f440c580d45b3d23aa975fd077
|
F test/fts3near.test dc196dd17b4606f440c580d45b3d23aa975fd077
|
||||||
F test/func.test e40978f08973f5956cfd32a7f87ef427e39cf9d3
|
F test/func.test 70ea3d5b10d40cbc87a19b0819d2842dbcdb31f2
|
||||||
F test/fuzz.test 8bad3b9b09bad47c50f3433f9598707a70247ce1
|
F test/fuzz.test 8bad3b9b09bad47c50f3433f9598707a70247ce1
|
||||||
F test/fuzz2.test ea38692ce2da99ad79fe0be5eb1a452c1c4d37bb
|
F test/fuzz2.test ea38692ce2da99ad79fe0be5eb1a452c1c4d37bb
|
||||||
F test/fuzz3.test aec64345184d1662bd30e6a17851ff659d596dc5
|
F test/fuzz3.test aec64345184d1662bd30e6a17851ff659d596dc5
|
||||||
@ -700,7 +700,7 @@ F tool/speedtest16.c c8a9c793df96db7e4933f0852abb7a03d48f2e81
|
|||||||
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff
|
||||||
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224
|
||||||
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e
|
||||||
P 7f827ba9d7af2dfe44aed386b4407716c85daf5e
|
P 6301f08a2b32289a49c4af994f2770318c444b49
|
||||||
R 64bfcfe14f6ed5f9fc8ac6244bf9afce
|
R 1e107d374c57a504206ef2bd99db8710
|
||||||
U shane
|
U shane
|
||||||
Z 3dacbef726dfade40da5a8d7ccd5cff0
|
Z a11c50747a0f4d959a770fa2e57dbba2
|
||||||
|
@ -1 +1 @@
|
|||||||
6301f08a2b32289a49c4af994f2770318c444b49
|
5cef400023205b55152b91441acc78f9cd8d58a9
|
12
src/date.c
12
src/date.c
@ -16,7 +16,7 @@
|
|||||||
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
|
** sqlite3RegisterDateTimeFunctions() found at the bottom of the file.
|
||||||
** All other code has file scope.
|
** All other code has file scope.
|
||||||
**
|
**
|
||||||
** $Id: date.c,v 1.102 2009/01/30 17:27:44 drh Exp $
|
** $Id: date.c,v 1.103 2009/02/04 03:59:25 shane Exp $
|
||||||
**
|
**
|
||||||
** SQLite processes all times and dates as Julian Day numbers. The
|
** SQLite processes all times and dates as Julian Day numbers. The
|
||||||
** dates and times are stored as the number of days since noon
|
** dates and times are stored as the number of days since noon
|
||||||
@ -1042,9 +1042,19 @@ static void currentTimeFunc(
|
|||||||
double rT;
|
double rT;
|
||||||
char zBuf[20];
|
char zBuf[20];
|
||||||
|
|
||||||
|
UNUSED_PARAMETER(argc);
|
||||||
|
UNUSED_PARAMETER(argv);
|
||||||
|
|
||||||
db = sqlite3_context_db_handle(context);
|
db = sqlite3_context_db_handle(context);
|
||||||
sqlite3OsCurrentTime(db->pVfs, &rT);
|
sqlite3OsCurrentTime(db->pVfs, &rT);
|
||||||
|
#ifndef SQLITE_OMIT_FLOATING_POINT
|
||||||
t = 86400.0*(rT - 2440587.5) + 0.5;
|
t = 86400.0*(rT - 2440587.5) + 0.5;
|
||||||
|
#else
|
||||||
|
/* without floating point support, rT will have
|
||||||
|
** already lost fractional day precision.
|
||||||
|
*/
|
||||||
|
t = 86400 * (rT - 2440587) - 43200;
|
||||||
|
#endif
|
||||||
#ifdef HAVE_GMTIME_R
|
#ifdef HAVE_GMTIME_R
|
||||||
{
|
{
|
||||||
struct tm sNow;
|
struct tm sNow;
|
||||||
|
12
src/expr.c
12
src/expr.c
@ -12,7 +12,7 @@
|
|||||||
** This file contains routines used for analyzing expressions and
|
** This file contains routines used for analyzing expressions and
|
||||||
** for generating VDBE code that evaluates expressions in SQLite.
|
** for generating VDBE code that evaluates expressions in SQLite.
|
||||||
**
|
**
|
||||||
** $Id: expr.c,v 1.410 2009/01/20 16:53:40 danielk1977 Exp $
|
** $Id: expr.c,v 1.411 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@ -1932,12 +1932,10 @@ int sqlite3ExprCodeTarget(Parse *pParse, Expr *pExpr, int target){
|
|||||||
case TK_UMINUS: {
|
case TK_UMINUS: {
|
||||||
Expr *pLeft = pExpr->pLeft;
|
Expr *pLeft = pExpr->pLeft;
|
||||||
assert( pLeft );
|
assert( pLeft );
|
||||||
if( pLeft->op==TK_FLOAT || pLeft->op==TK_INTEGER ){
|
if( pLeft->op==TK_FLOAT ){
|
||||||
if( pLeft->op==TK_FLOAT ){
|
codeReal(v, (char*)pLeft->token.z, pLeft->token.n, 1, target);
|
||||||
codeReal(v, (char*)pLeft->token.z, pLeft->token.n, 1, target);
|
}else if( pLeft->op==TK_INTEGER ){
|
||||||
}else{
|
codeInteger(v, pLeft, 1, target);
|
||||||
codeInteger(v, pLeft, 1, target);
|
|
||||||
}
|
|
||||||
}else{
|
}else{
|
||||||
regFree1 = r1 = sqlite3GetTempReg(pParse);
|
regFree1 = r1 = sqlite3GetTempReg(pParse);
|
||||||
sqlite3VdbeAddOp2(v, OP_Integer, 0, r1);
|
sqlite3VdbeAddOp2(v, OP_Integer, 0, r1);
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
|
** sqliteRegisterBuildinFunctions() found at the bottom of the file.
|
||||||
** All other code has file scope.
|
** All other code has file scope.
|
||||||
**
|
**
|
||||||
** $Id: func.c,v 1.221 2009/02/03 15:50:34 drh Exp $
|
** $Id: func.c,v 1.222 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -243,6 +243,7 @@ static void substrFunc(
|
|||||||
/*
|
/*
|
||||||
** Implementation of the round() function
|
** Implementation of the round() function
|
||||||
*/
|
*/
|
||||||
|
#ifndef SQLITE_OMIT_FLOATING_POINT
|
||||||
static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
||||||
int n = 0;
|
int n = 0;
|
||||||
double r;
|
double r;
|
||||||
@ -260,6 +261,7 @@ static void roundFunc(sqlite3_context *context, int argc, sqlite3_value **argv){
|
|||||||
sqlite3AtoF(zBuf, &r);
|
sqlite3AtoF(zBuf, &r);
|
||||||
sqlite3_result_double(context, r);
|
sqlite3_result_double(context, r);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Allocate nByte bytes of space using sqlite3_malloc(). If the
|
** Allocate nByte bytes of space using sqlite3_malloc(). If the
|
||||||
@ -1131,7 +1133,8 @@ static void avgFinalize(sqlite3_context *context){
|
|||||||
static void totalFinalize(sqlite3_context *context){
|
static void totalFinalize(sqlite3_context *context){
|
||||||
SumCtx *p;
|
SumCtx *p;
|
||||||
p = sqlite3_aggregate_context(context, 0);
|
p = sqlite3_aggregate_context(context, 0);
|
||||||
sqlite3_result_double(context, p ? p->rSum : 0.0);
|
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
sqlite3_result_double(context, p ? p->rSum : (double)0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1378,8 +1381,10 @@ void sqlite3RegisterGlobalFunctions(void){
|
|||||||
FUNCTION(substr, 2, 0, 0, substrFunc ),
|
FUNCTION(substr, 2, 0, 0, substrFunc ),
|
||||||
FUNCTION(substr, 3, 0, 0, substrFunc ),
|
FUNCTION(substr, 3, 0, 0, substrFunc ),
|
||||||
FUNCTION(abs, 1, 0, 0, absFunc ),
|
FUNCTION(abs, 1, 0, 0, absFunc ),
|
||||||
|
#ifndef SQLITE_OMIT_FLOATING_POINT
|
||||||
FUNCTION(round, 1, 0, 0, roundFunc ),
|
FUNCTION(round, 1, 0, 0, roundFunc ),
|
||||||
FUNCTION(round, 2, 0, 0, roundFunc ),
|
FUNCTION(round, 2, 0, 0, roundFunc ),
|
||||||
|
#endif
|
||||||
FUNCTION(upper, 1, 0, 0, upperFunc ),
|
FUNCTION(upper, 1, 0, 0, upperFunc ),
|
||||||
FUNCTION(lower, 1, 0, 0, lowerFunc ),
|
FUNCTION(lower, 1, 0, 0, lowerFunc ),
|
||||||
FUNCTION(coalesce, 1, 0, 0, 0 ),
|
FUNCTION(coalesce, 1, 0, 0, 0 ),
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
** other files are for internal use by SQLite and should not be
|
** other files are for internal use by SQLite and should not be
|
||||||
** accessed by users of the library.
|
** accessed by users of the library.
|
||||||
**
|
**
|
||||||
** $Id: main.c,v 1.525 2009/02/03 16:51:25 danielk1977 Exp $
|
** $Id: main.c,v 1.526 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@ -191,6 +191,7 @@ int sqlite3_initialize(void){
|
|||||||
** reason. So we run it once during initialization.
|
** reason. So we run it once during initialization.
|
||||||
*/
|
*/
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
|
#ifndef SQLITE_OMIT_FLOATING_POINT
|
||||||
/* This section of code's only "output" is via assert() statements. */
|
/* This section of code's only "output" is via assert() statements. */
|
||||||
if ( rc==SQLITE_OK ){
|
if ( rc==SQLITE_OK ){
|
||||||
u64 x = (((u64)1)<<63)-1;
|
u64 x = (((u64)1)<<63)-1;
|
||||||
@ -200,6 +201,7 @@ int sqlite3_initialize(void){
|
|||||||
memcpy(&y, &x, 8);
|
memcpy(&y, &x, 8);
|
||||||
assert( sqlite3IsNaN(y) );
|
assert( sqlite3IsNaN(y) );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
29
src/os_win.c
29
src/os_win.c
@ -12,7 +12,7 @@
|
|||||||
**
|
**
|
||||||
** This file contains code that is specific to windows.
|
** This file contains code that is specific to windows.
|
||||||
**
|
**
|
||||||
** $Id: os_win.c,v 1.146 2009/01/30 05:59:11 shane Exp $
|
** $Id: os_win.c,v 1.147 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#if SQLITE_OS_WIN /* This file is used for windows only */
|
#if SQLITE_OS_WIN /* This file is used for windows only */
|
||||||
@ -755,10 +755,10 @@ int sqlite3_fullsync_count = 0;
|
|||||||
static int winSync(sqlite3_file *id, int flags){
|
static int winSync(sqlite3_file *id, int flags){
|
||||||
#ifndef SQLITE_NO_SYNC
|
#ifndef SQLITE_NO_SYNC
|
||||||
winFile *pFile = (winFile*)id;
|
winFile *pFile = (winFile*)id;
|
||||||
|
OSTRACE3("SYNC %d lock=%d\n", pFile->h, pFile->locktype);
|
||||||
#else
|
#else
|
||||||
UNUSED_PARAMETER(id);
|
UNUSED_PARAMETER(id);
|
||||||
#endif
|
#endif
|
||||||
OSTRACE3("SYNC %d lock=%d\n", pFile->h, pFile->locktype);
|
|
||||||
#ifndef SQLITE_TEST
|
#ifndef SQLITE_TEST
|
||||||
UNUSED_PARAMETER(flags);
|
UNUSED_PARAMETER(flags);
|
||||||
#else
|
#else
|
||||||
@ -1672,7 +1672,7 @@ int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){
|
|||||||
/* FILETIME structure is a 64-bit value representing the number of
|
/* FILETIME structure is a 64-bit value representing the number of
|
||||||
100-nanosecond intervals since January 1, 1601 (= JD 2305813.5).
|
100-nanosecond intervals since January 1, 1601 (= JD 2305813.5).
|
||||||
*/
|
*/
|
||||||
double now;
|
sqlite3_int64 timeW, timeF;
|
||||||
#if SQLITE_OS_WINCE
|
#if SQLITE_OS_WINCE
|
||||||
SYSTEMTIME time;
|
SYSTEMTIME time;
|
||||||
GetSystemTime(&time);
|
GetSystemTime(&time);
|
||||||
@ -1684,11 +1684,28 @@ int winCurrentTime(sqlite3_vfs *pVfs, double *prNow){
|
|||||||
GetSystemTimeAsFileTime( &ft );
|
GetSystemTimeAsFileTime( &ft );
|
||||||
#endif
|
#endif
|
||||||
UNUSED_PARAMETER(pVfs);
|
UNUSED_PARAMETER(pVfs);
|
||||||
now = ((double)ft.dwHighDateTime) * 4294967296.0;
|
#if defined(_MSC_VER)
|
||||||
*prNow = (now + ft.dwLowDateTime)/864000000000.0 + 2305813.5;
|
timeW = (((sqlite3_int64)ft.dwHighDateTime)*4294967296) + ft.dwLowDateTime;
|
||||||
|
timeF = timeW % 864000000000; /* fractional days (100-nanoseconds) */
|
||||||
|
timeW = timeW / 864000000000; /* whole days */
|
||||||
|
timeW = timeW + 2305813; /* add whole days (from 2305813.5) */
|
||||||
|
timeF = timeF + 432000000000; /* add half a day (from 2305813.5) */
|
||||||
|
timeW = timeW + (timeF / 864000000000); /* add whole day if half day made one */
|
||||||
|
timeF = timeF % 864000000000; /* compute new fractional days */
|
||||||
|
*prNow = (double)timeW + ((double)timeF / (double)864000000000);
|
||||||
|
#else
|
||||||
|
timeW = (((sqlite3_int64)ft.dwHighDateTime)*4294967296LL) + ft.dwLowDateTime;
|
||||||
|
timeF = timeW % 864000000000LL; /* fractional days (100-nanoseconds) */
|
||||||
|
timeW = timeW / 864000000000LL; /* whole days */
|
||||||
|
timeW = timeW + 2305813; /* add whole days (from 2305813.5) */
|
||||||
|
timeF = timeF + 432000000000LL; /* add half a day (from 2305813.5) */
|
||||||
|
timeW = timeW + (timeF / 864000000000LL); /* add whole day if half day made one */
|
||||||
|
timeF = timeF % 864000000000LL; /* compute new fractional days */
|
||||||
|
*prNow = (double)timeW + ((double)timeF / (double)864000000000LL);
|
||||||
|
#endif
|
||||||
#ifdef SQLITE_TEST
|
#ifdef SQLITE_TEST
|
||||||
if( sqlite3_current_time ){
|
if( sqlite3_current_time ){
|
||||||
*prNow = sqlite3_current_time/86400.0 + 2440587.5;
|
*prNow = ((double)sqlite3_current_time + (double)43200) / (double)86400 + (double)2440587;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -14,12 +14,11 @@
|
|||||||
** This file contains functions for allocating memory, comparing
|
** This file contains functions for allocating memory, comparing
|
||||||
** strings, and stuff like that.
|
** strings, and stuff like that.
|
||||||
**
|
**
|
||||||
** $Id: util.c,v 1.247 2009/01/20 16:53:41 danielk1977 Exp $
|
** $Id: util.c,v 1.248 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
** Routine needed to support the testcase() macro.
|
** Routine needed to support the testcase() macro.
|
||||||
*/
|
*/
|
||||||
|
@ -43,7 +43,7 @@
|
|||||||
** in this file for details. If in doubt, do not deviate from existing
|
** in this file for details. If in doubt, do not deviate from existing
|
||||||
** commenting and indentation practices when changing or adding code.
|
** commenting and indentation practices when changing or adding code.
|
||||||
**
|
**
|
||||||
** $Id: vdbe.c,v 1.813 2009/02/01 00:29:57 drh Exp $
|
** $Id: vdbe.c,v 1.814 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "vdbeInt.h"
|
#include "vdbeInt.h"
|
||||||
@ -1228,7 +1228,8 @@ case OP_Remainder: { /* same as TK_REM, in1, in2, out3 */
|
|||||||
case OP_Subtract: b -= a; break;
|
case OP_Subtract: b -= a; break;
|
||||||
case OP_Multiply: b *= a; break;
|
case OP_Multiply: b *= a; break;
|
||||||
case OP_Divide: {
|
case OP_Divide: {
|
||||||
if( a==0.0 ) goto arithmetic_result_is_null;
|
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
if( a==(double)0 ) goto arithmetic_result_is_null;
|
||||||
b /= a;
|
b /= a;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1873,7 +1874,7 @@ case OP_IfNot: { /* jump, in1 */
|
|||||||
c = pOp->p3;
|
c = pOp->p3;
|
||||||
}else{
|
}else{
|
||||||
#ifdef SQLITE_OMIT_FLOATING_POINT
|
#ifdef SQLITE_OMIT_FLOATING_POINT
|
||||||
c = sqlite3VdbeIntValue(pIn1);
|
c = sqlite3VdbeIntValue(pIn1)!=0;
|
||||||
#else
|
#else
|
||||||
c = sqlite3VdbeRealValue(pIn1)!=0.0;
|
c = sqlite3VdbeRealValue(pIn1)!=0.0;
|
||||||
#endif
|
#endif
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
** This file contains code use to implement APIs that are part of the
|
** This file contains code use to implement APIs that are part of the
|
||||||
** VDBE.
|
** VDBE.
|
||||||
**
|
**
|
||||||
** $Id: vdbeapi.c,v 1.150 2008/12/10 18:03:47 drh Exp $
|
** $Id: vdbeapi.c,v 1.151 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "vdbeInt.h"
|
#include "vdbeInt.h"
|
||||||
@ -752,7 +752,8 @@ static Mem *columnMem(sqlite3_stmt *pStmt, int i){
|
|||||||
vals = sqlite3_data_count(pStmt);
|
vals = sqlite3_data_count(pStmt);
|
||||||
pOut = &pVm->pResultSet[i];
|
pOut = &pVm->pResultSet[i];
|
||||||
}else{
|
}else{
|
||||||
static const Mem nullMem = {{0}, 0.0, 0, "", 0, MEM_Null, SQLITE_NULL, 0, 0, 0 };
|
/* ((double)0) In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
static const Mem nullMem = {{0}, (double)0, 0, "", 0, MEM_Null, SQLITE_NULL, 0, 0, 0 };
|
||||||
if( pVm->db ){
|
if( pVm->db ){
|
||||||
sqlite3_mutex_enter(pVm->db->mutex);
|
sqlite3_mutex_enter(pVm->db->mutex);
|
||||||
sqlite3Error(pVm->db, SQLITE_RANGE, 0);
|
sqlite3Error(pVm->db, SQLITE_RANGE, 0);
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
** only within the VDBE. Interface routines refer to a Mem using the
|
** only within the VDBE. Interface routines refer to a Mem using the
|
||||||
** name sqlite_value
|
** name sqlite_value
|
||||||
**
|
**
|
||||||
** $Id: vdbemem.c,v 1.136 2009/02/03 15:39:01 drh Exp $
|
** $Id: vdbemem.c,v 1.137 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
#include "vdbeInt.h"
|
#include "vdbeInt.h"
|
||||||
@ -373,17 +373,20 @@ double sqlite3VdbeRealValue(Mem *pMem){
|
|||||||
}else if( pMem->flags & MEM_Int ){
|
}else if( pMem->flags & MEM_Int ){
|
||||||
return (double)pMem->u.i;
|
return (double)pMem->u.i;
|
||||||
}else if( pMem->flags & (MEM_Str|MEM_Blob) ){
|
}else if( pMem->flags & (MEM_Str|MEM_Blob) ){
|
||||||
double val = 0.0;
|
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
double val = (double)0;
|
||||||
pMem->flags |= MEM_Str;
|
pMem->flags |= MEM_Str;
|
||||||
if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8)
|
if( sqlite3VdbeChangeEncoding(pMem, SQLITE_UTF8)
|
||||||
|| sqlite3VdbeMemNulTerminate(pMem) ){
|
|| sqlite3VdbeMemNulTerminate(pMem) ){
|
||||||
return 0.0;
|
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
return (double)0;
|
||||||
}
|
}
|
||||||
assert( pMem->z );
|
assert( pMem->z );
|
||||||
sqlite3AtoF(pMem->z, &val);
|
sqlite3AtoF(pMem->z, &val);
|
||||||
return val;
|
return val;
|
||||||
}else{
|
}else{
|
||||||
return 0.0;
|
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
return (double)0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -969,7 +972,8 @@ int sqlite3ValueFromExpr(
|
|||||||
}else if( op==TK_UMINUS ) {
|
}else if( op==TK_UMINUS ) {
|
||||||
if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) ){
|
if( SQLITE_OK==sqlite3ValueFromExpr(db,pExpr->pLeft,enc,affinity,&pVal) ){
|
||||||
pVal->u.i = -1 * pVal->u.i;
|
pVal->u.i = -1 * pVal->u.i;
|
||||||
pVal->r = -1.0 * pVal->r;
|
/* (double)-1 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
pVal->r = (double)-1 * pVal->r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifndef SQLITE_OMIT_BLOB_LITERAL
|
#ifndef SQLITE_OMIT_BLOB_LITERAL
|
||||||
|
17
src/where.c
17
src/where.c
@ -16,7 +16,7 @@
|
|||||||
** so is applicable. Because this module is responsible for selecting
|
** so is applicable. Because this module is responsible for selecting
|
||||||
** indices, you might also think of this module as the "query optimizer".
|
** indices, you might also think of this module as the "query optimizer".
|
||||||
**
|
**
|
||||||
** $Id: where.c,v 1.367 2009/02/04 01:49:30 shane Exp $
|
** $Id: where.c,v 1.368 2009/02/04 03:59:25 shane Exp $
|
||||||
*/
|
*/
|
||||||
#include "sqliteInt.h"
|
#include "sqliteInt.h"
|
||||||
|
|
||||||
@ -1547,7 +1547,8 @@ static double bestVirtualIndex(
|
|||||||
+ sizeof(*pIdxOrderBy)*nOrderBy );
|
+ sizeof(*pIdxOrderBy)*nOrderBy );
|
||||||
if( pIdxInfo==0 ){
|
if( pIdxInfo==0 ){
|
||||||
sqlite3ErrorMsg(pParse, "out of memory");
|
sqlite3ErrorMsg(pParse, "out of memory");
|
||||||
return 0.0;
|
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
return (double)0;
|
||||||
}
|
}
|
||||||
*ppIdxInfo = pIdxInfo;
|
*ppIdxInfo = pIdxInfo;
|
||||||
|
|
||||||
@ -1650,7 +1651,8 @@ static double bestVirtualIndex(
|
|||||||
pIdxInfo->idxNum = 0;
|
pIdxInfo->idxNum = 0;
|
||||||
pIdxInfo->needToFreeIdxStr = 0;
|
pIdxInfo->needToFreeIdxStr = 0;
|
||||||
pIdxInfo->orderByConsumed = 0;
|
pIdxInfo->orderByConsumed = 0;
|
||||||
pIdxInfo->estimatedCost = SQLITE_BIG_DBL / 2.0;
|
/* ((double)2) In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
pIdxInfo->estimatedCost = SQLITE_BIG_DBL / ((double)2);
|
||||||
nOrderBy = pIdxInfo->nOrderBy;
|
nOrderBy = pIdxInfo->nOrderBy;
|
||||||
if( pIdxInfo->nOrderBy && !orderByUsable ){
|
if( pIdxInfo->nOrderBy && !orderByUsable ){
|
||||||
*(int*)&pIdxInfo->nOrderBy = 0;
|
*(int*)&pIdxInfo->nOrderBy = 0;
|
||||||
@ -1679,7 +1681,8 @@ static double bestVirtualIndex(
|
|||||||
if( !pIdxInfo->aConstraint[i].usable && pUsage[i].argvIndex>0 ){
|
if( !pIdxInfo->aConstraint[i].usable && pUsage[i].argvIndex>0 ){
|
||||||
sqlite3ErrorMsg(pParse,
|
sqlite3ErrorMsg(pParse,
|
||||||
"table %s: xBestIndex returned an invalid plan", pTab->zName);
|
"table %s: xBestIndex returned an invalid plan", pTab->zName);
|
||||||
return 0.0;
|
/* (double)0 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
return (double)0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3092,12 +3095,14 @@ WhereInfo *sqlite3WhereBegin(
|
|||||||
sCost.plan.wsFlags = WHERE_VIRTUALTABLE | WHERE_ORDERBY;
|
sCost.plan.wsFlags = WHERE_VIRTUALTABLE | WHERE_ORDERBY;
|
||||||
}
|
}
|
||||||
sCost.plan.nEq = 0;
|
sCost.plan.nEq = 0;
|
||||||
if( (SQLITE_BIG_DBL/2.0)<sCost.rCost ){
|
/* (double)2 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
if( (SQLITE_BIG_DBL/((double)2))<sCost.rCost ){
|
||||||
/* The cost is not allowed to be larger than SQLITE_BIG_DBL (the
|
/* The cost is not allowed to be larger than SQLITE_BIG_DBL (the
|
||||||
** inital value of lowestCost in this loop. If it is, then
|
** inital value of lowestCost in this loop. If it is, then
|
||||||
** the (cost<lowestCost) test below will never be true.
|
** the (cost<lowestCost) test below will never be true.
|
||||||
*/
|
*/
|
||||||
sCost.rCost = (SQLITE_BIG_DBL/2.0);
|
/* (double)2 In case of SQLITE_OMIT_FLOATING_POINT... */
|
||||||
|
sCost.rCost = (SQLITE_BIG_DBL/((double)2));
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
#endif
|
#endif
|
||||||
|
241
test/expr.test
241
test/expr.test
@ -11,15 +11,22 @@
|
|||||||
# This file implements regression tests for SQLite library. The
|
# This file implements regression tests for SQLite library. The
|
||||||
# focus of this file is testing expressions.
|
# focus of this file is testing expressions.
|
||||||
#
|
#
|
||||||
# $Id: expr.test,v 1.66 2008/12/30 17:55:00 drh Exp $
|
# $Id: expr.test,v 1.67 2009/02/04 03:59:25 shane Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
|
|
||||||
# Create a table to work with.
|
# Create a table to work with.
|
||||||
#
|
#
|
||||||
execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}
|
ifcapable floatingpoint {
|
||||||
execsql {INSERT INTO test1 VALUES(1,2,1.1,2.2,'hello','world')}
|
execsql {CREATE TABLE test1(i1 int, i2 int, r1 real, r2 real, t1 text, t2 text)}
|
||||||
|
execsql {INSERT INTO test1 VALUES(1,2,1.1,2.2,'hello','world')}
|
||||||
|
}
|
||||||
|
ifcapable !floatingpoint {
|
||||||
|
execsql {CREATE TABLE test1(i1 int, i2 int, t1 text, t2 text)}
|
||||||
|
execsql {INSERT INTO test1 VALUES(1,2,'hello','world')}
|
||||||
|
}
|
||||||
|
|
||||||
proc test_expr {name settings expr result} {
|
proc test_expr {name settings expr result} {
|
||||||
do_test $name [format {
|
do_test $name [format {
|
||||||
execsql {BEGIN; UPDATE test1 SET %s; SELECT %s FROM test1; ROLLBACK;}
|
execsql {BEGIN; UPDATE test1 SET %s; SELECT %s FROM test1; ROLLBACK;}
|
||||||
@ -47,8 +54,10 @@ test_expr expr-1.18 {i1=20, i2=20} {i2!=i1} 0
|
|||||||
test_expr expr-1.19 {i1=20, i2=20} {i2=i1} 1
|
test_expr expr-1.19 {i1=20, i2=20} {i2=i1} 1
|
||||||
test_expr expr-1.20 {i1=20, i2=20} {i2<>i1} 0
|
test_expr expr-1.20 {i1=20, i2=20} {i2<>i1} 0
|
||||||
test_expr expr-1.21 {i1=20, i2=20} {i2==i1} 1
|
test_expr expr-1.21 {i1=20, i2=20} {i2==i1} 1
|
||||||
test_expr expr-1.22 {i1=1, i2=2, r1=3.0} {i1+i2*r1} {7.0}
|
ifcapable floatingpoint {
|
||||||
test_expr expr-1.23 {i1=1, i2=2, r1=3.0} {(i1+i2)*r1} {9.0}
|
test_expr expr-1.22 {i1=1, i2=2, r1=3.0} {i1+i2*r1} {7.0}
|
||||||
|
test_expr expr-1.23 {i1=1, i2=2, r1=3.0} {(i1+i2)*r1} {9.0}
|
||||||
|
}
|
||||||
test_expr expr-1.24 {i1=1, i2=2} {min(i1,i2,i1+i2,i1-i2)} {-1}
|
test_expr expr-1.24 {i1=1, i2=2} {min(i1,i2,i1+i2,i1-i2)} {-1}
|
||||||
test_expr expr-1.25 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}
|
test_expr expr-1.25 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}
|
||||||
test_expr expr-1.26 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}
|
test_expr expr-1.26 {i1=1, i2=2} {max(i1,i2,i1+i2,i1-i2)} {3}
|
||||||
@ -134,48 +143,62 @@ test_expr expr-1.101 {i1=0, i2=''} {i1=i2} 0
|
|||||||
|
|
||||||
# Check for proper handling of 64-bit integer values.
|
# Check for proper handling of 64-bit integer values.
|
||||||
#
|
#
|
||||||
test_expr expr-1.102 {i1=40, i2=1} {i2<<i1} 1099511627776
|
if {[working_64bit_int]} {
|
||||||
|
test_expr expr-1.102 {i1=40, i2=1} {i2<<i1} 1099511627776
|
||||||
|
}
|
||||||
|
|
||||||
test_expr expr-1.103 {i1=0} {(-2147483648.0 % -1)} 0.0
|
ifcapable floatingpoint {
|
||||||
test_expr expr-1.104 {i1=0} {(-9223372036854775808.0 % -1)} 0.0
|
test_expr expr-1.103 {i1=0} {(-2147483648.0 % -1)} 0.0
|
||||||
test_expr expr-1.105 {i1=0} {(-9223372036854775808.0 / -1)>1} 1
|
test_expr expr-1.104 {i1=0} {(-9223372036854775808.0 % -1)} 0.0
|
||||||
|
test_expr expr-1.105 {i1=0} {(-9223372036854775808.0 / -1)>1} 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if {[working_64bit_int]} {
|
||||||
|
test_expr expr-1.106 {i1=0} {(1<<63)/-1} -9223372036854775808
|
||||||
|
}
|
||||||
|
|
||||||
test_expr expr-1.106 {i1=0} {(1<<63)/-1} -9223372036854775808
|
|
||||||
test_expr expr-1.107 {i1=0} {(1<<63)%-1} 0
|
test_expr expr-1.107 {i1=0} {(1<<63)%-1} 0
|
||||||
test_expr expr-1.108 {i1=0} {1%0} {{}}
|
test_expr expr-1.108 {i1=0} {1%0} {{}}
|
||||||
test_expr expr-1.109 {i1=0} {1/0} {{}}
|
test_expr expr-1.109 {i1=0} {1/0} {{}}
|
||||||
test_expr expr-1.110 {i1=0} {-9223372036854775807/-1} 9223372036854775807
|
|
||||||
|
|
||||||
test_expr expr-2.1 {r1=1.23, r2=2.34} {r1+r2} 3.57
|
if {[working_64bit_int]} {
|
||||||
test_expr expr-2.2 {r1=1.23, r2=2.34} {r1-r2} -1.11
|
test_expr expr-1.110 {i1=0} {-9223372036854775807/-1} 9223372036854775807
|
||||||
test_expr expr-2.3 {r1=1.23, r2=2.34} {r1*r2} 2.8782
|
}
|
||||||
|
|
||||||
|
ifcapable floatingpoint {
|
||||||
|
test_expr expr-2.1 {r1=1.23, r2=2.34} {r1+r2} 3.57
|
||||||
|
test_expr expr-2.2 {r1=1.23, r2=2.34} {r1-r2} -1.11
|
||||||
|
test_expr expr-2.3 {r1=1.23, r2=2.34} {r1*r2} 2.8782
|
||||||
|
}
|
||||||
set tcl_precision 15
|
set tcl_precision 15
|
||||||
test_expr expr-2.4 {r1=1.23, r2=2.34} {r1/r2} 0.525641025641026
|
ifcapable floatingpoint {
|
||||||
test_expr expr-2.5 {r1=1.23, r2=2.34} {r2/r1} 1.90243902439024
|
test_expr expr-2.4 {r1=1.23, r2=2.34} {r1/r2} 0.525641025641026
|
||||||
test_expr expr-2.6 {r1=1.23, r2=2.34} {r2<r1} 0
|
test_expr expr-2.5 {r1=1.23, r2=2.34} {r2/r1} 1.90243902439024
|
||||||
test_expr expr-2.7 {r1=1.23, r2=2.34} {r2<=r1} 0
|
test_expr expr-2.6 {r1=1.23, r2=2.34} {r2<r1} 0
|
||||||
test_expr expr-2.8 {r1=1.23, r2=2.34} {r2>r1} 1
|
test_expr expr-2.7 {r1=1.23, r2=2.34} {r2<=r1} 0
|
||||||
test_expr expr-2.9 {r1=1.23, r2=2.34} {r2>=r1} 1
|
test_expr expr-2.8 {r1=1.23, r2=2.34} {r2>r1} 1
|
||||||
test_expr expr-2.10 {r1=1.23, r2=2.34} {r2!=r1} 1
|
test_expr expr-2.9 {r1=1.23, r2=2.34} {r2>=r1} 1
|
||||||
test_expr expr-2.11 {r1=1.23, r2=2.34} {r2=r1} 0
|
test_expr expr-2.10 {r1=1.23, r2=2.34} {r2!=r1} 1
|
||||||
test_expr expr-2.12 {r1=1.23, r2=2.34} {r2<>r1} 1
|
test_expr expr-2.11 {r1=1.23, r2=2.34} {r2=r1} 0
|
||||||
test_expr expr-2.13 {r1=1.23, r2=2.34} {r2==r1} 0
|
test_expr expr-2.12 {r1=1.23, r2=2.34} {r2<>r1} 1
|
||||||
test_expr expr-2.14 {r1=2.34, r2=2.34} {r2<r1} 0
|
test_expr expr-2.13 {r1=1.23, r2=2.34} {r2==r1} 0
|
||||||
test_expr expr-2.15 {r1=2.34, r2=2.34} {r2<=r1} 1
|
test_expr expr-2.14 {r1=2.34, r2=2.34} {r2<r1} 0
|
||||||
test_expr expr-2.16 {r1=2.34, r2=2.34} {r2>r1} 0
|
test_expr expr-2.15 {r1=2.34, r2=2.34} {r2<=r1} 1
|
||||||
test_expr expr-2.17 {r1=2.34, r2=2.34} {r2>=r1} 1
|
test_expr expr-2.16 {r1=2.34, r2=2.34} {r2>r1} 0
|
||||||
test_expr expr-2.18 {r1=2.34, r2=2.34} {r2!=r1} 0
|
test_expr expr-2.17 {r1=2.34, r2=2.34} {r2>=r1} 1
|
||||||
test_expr expr-2.19 {r1=2.34, r2=2.34} {r2=r1} 1
|
test_expr expr-2.18 {r1=2.34, r2=2.34} {r2!=r1} 0
|
||||||
test_expr expr-2.20 {r1=2.34, r2=2.34} {r2<>r1} 0
|
test_expr expr-2.19 {r1=2.34, r2=2.34} {r2=r1} 1
|
||||||
test_expr expr-2.21 {r1=2.34, r2=2.34} {r2==r1} 1
|
test_expr expr-2.20 {r1=2.34, r2=2.34} {r2<>r1} 0
|
||||||
test_expr expr-2.22 {r1=1.23, r2=2.34} {min(r1,r2,r1+r2,r1-r2)} {-1.11}
|
test_expr expr-2.21 {r1=2.34, r2=2.34} {r2==r1} 1
|
||||||
test_expr expr-2.23 {r1=1.23, r2=2.34} {max(r1,r2,r1+r2,r1-r2)} {3.57}
|
test_expr expr-2.22 {r1=1.23, r2=2.34} {min(r1,r2,r1+r2,r1-r2)} {-1.11}
|
||||||
test_expr expr-2.24 {r1=25.0, r2=11.0} {r1%r2} 3.0
|
test_expr expr-2.23 {r1=1.23, r2=2.34} {max(r1,r2,r1+r2,r1-r2)} {3.57}
|
||||||
test_expr expr-2.25 {r1=1.23, r2=NULL} {coalesce(r1+r2,99.0)} 99.0
|
test_expr expr-2.24 {r1=25.0, r2=11.0} {r1%r2} 3.0
|
||||||
test_expr expr-2.26 {r1=1e300, r2=1e300} {coalesce((r1*r2)*0.0,99.0)} 99.0
|
test_expr expr-2.25 {r1=1.23, r2=NULL} {coalesce(r1+r2,99.0)} 99.0
|
||||||
test_expr expr-2.26b {r1=1e300, r2=-1e300} {coalesce((r1*r2)*0.0,99.0)} 99.0
|
test_expr expr-2.26 {r1=1e300, r2=1e300} {coalesce((r1*r2)*0.0,99.0)} 99.0
|
||||||
test_expr expr-2.27 {r1=1.1, r2=0.0} {r1/r2} {{}}
|
test_expr expr-2.26b {r1=1e300, r2=-1e300} {coalesce((r1*r2)*0.0,99.0)} 99.0
|
||||||
test_expr expr-2.28 {r1=1.1, r2=0.0} {r1%r2} {{}}
|
test_expr expr-2.27 {r1=1.1, r2=0.0} {r1/r2} {{}}
|
||||||
|
test_expr expr-2.28 {r1=1.1, r2=0.0} {r1%r2} {{}}
|
||||||
|
}
|
||||||
|
|
||||||
test_expr expr-3.1 {t1='abc', t2='xyz'} {t1<t2} 1
|
test_expr expr-3.1 {t1='abc', t2='xyz'} {t1<t2} 1
|
||||||
test_expr expr-3.2 {t1='xyz', t2='abc'} {t1<t2} 0
|
test_expr expr-3.2 {t1='xyz', t2='abc'} {t1<t2} 0
|
||||||
@ -233,17 +256,20 @@ test_expr expr-4.6 {t1='0.000', t2='0.0'} {t1==t2} 0
|
|||||||
test_expr expr-4.7 {t1=' 0.000', t2=' 0.0'} {t1==t2} 0
|
test_expr expr-4.7 {t1=' 0.000', t2=' 0.0'} {t1==t2} 0
|
||||||
test_expr expr-4.8 {t1='0.0', t2='abc'} {t1<t2} 1
|
test_expr expr-4.8 {t1='0.0', t2='abc'} {t1<t2} 1
|
||||||
test_expr expr-4.9 {t1='0.0', t2='abc'} {t1==t2} 0
|
test_expr expr-4.9 {t1='0.0', t2='abc'} {t1==t2} 0
|
||||||
test_expr expr-4.10 {r1='0.0', r2='abc'} {r1>r2} 0
|
|
||||||
test_expr expr-4.11 {r1='abc', r2='Abc'} {r1<r2} 0
|
ifcapable floatingpoint {
|
||||||
test_expr expr-4.12 {r1='abc', r2='Abc'} {r1>r2} 1
|
test_expr expr-4.10 {r1='0.0', r2='abc'} {r1>r2} 0
|
||||||
test_expr expr-4.13 {r1='abc', r2='Bbc'} {r1<r2} 0
|
test_expr expr-4.11 {r1='abc', r2='Abc'} {r1<r2} 0
|
||||||
test_expr expr-4.14 {r1='abc', r2='Bbc'} {r1>r2} 1
|
test_expr expr-4.12 {r1='abc', r2='Abc'} {r1>r2} 1
|
||||||
test_expr expr-4.15 {r1='0', r2='0.0'} {r1==r2} 1
|
test_expr expr-4.13 {r1='abc', r2='Bbc'} {r1<r2} 0
|
||||||
test_expr expr-4.16 {r1='0.000', r2='0.0'} {r1==r2} 1
|
test_expr expr-4.14 {r1='abc', r2='Bbc'} {r1>r2} 1
|
||||||
test_expr expr-4.17 {r1=' 0.000', r2=' 0.0'} {r1==r2} 0
|
test_expr expr-4.15 {r1='0', r2='0.0'} {r1==r2} 1
|
||||||
test_expr expr-4.18 {r1='0.0', r2='abc'} {r1<r2} 1
|
test_expr expr-4.16 {r1='0.000', r2='0.0'} {r1==r2} 1
|
||||||
test_expr expr-4.19 {r1='0.0', r2='abc'} {r1==r2} 0
|
test_expr expr-4.17 {r1=' 0.000', r2=' 0.0'} {r1==r2} 0
|
||||||
test_expr expr-4.20 {r1='0.0', r2='abc'} {r1>r2} 0
|
test_expr expr-4.18 {r1='0.0', r2='abc'} {r1<r2} 1
|
||||||
|
test_expr expr-4.19 {r1='0.0', r2='abc'} {r1==r2} 0
|
||||||
|
test_expr expr-4.20 {r1='0.0', r2='abc'} {r1>r2} 0
|
||||||
|
}
|
||||||
|
|
||||||
# CSL is true if LIKE is case sensitive and false if not.
|
# CSL is true if LIKE is case sensitive and false if not.
|
||||||
# NCSL is the opposite. Use these variables as the result
|
# NCSL is the opposite. Use these variables as the result
|
||||||
@ -575,7 +601,9 @@ test_expr2 expr-7.36 {a<2 OR (a<0 OR b=0)} {{} 1}
|
|||||||
test_expr2 expr-7.37 {a<2 OR (b=0 OR a<0)} {{} 1}
|
test_expr2 expr-7.37 {a<2 OR (b=0 OR a<0)} {{} 1}
|
||||||
test_expr2 expr-7.38 {a<2 OR (a<0 AND b=0)} {1}
|
test_expr2 expr-7.38 {a<2 OR (a<0 AND b=0)} {1}
|
||||||
test_expr2 expr-7.39 {a<2 OR (b=0 AND a<0)} {1}
|
test_expr2 expr-7.39 {a<2 OR (b=0 AND a<0)} {1}
|
||||||
test_expr2 expr-7.40 {((a<2 OR a IS NULL) AND b<3) OR b>1e10} {{} 1}
|
ifcapable floatingpoint {
|
||||||
|
test_expr2 expr-7.40 {((a<2 OR a IS NULL) AND b<3) OR b>1e10} {{} 1}
|
||||||
|
}
|
||||||
test_expr2 expr-7.41 {a BETWEEN -1 AND 1} {1}
|
test_expr2 expr-7.41 {a BETWEEN -1 AND 1} {1}
|
||||||
test_expr2 expr-7.42 {a NOT BETWEEN 2 AND 100} {1}
|
test_expr2 expr-7.42 {a NOT BETWEEN 2 AND 100} {1}
|
||||||
test_expr2 expr-7.43 {(b+1234)||'this is a string that is at least 32 characters long' BETWEEN 1 AND 2} {}
|
test_expr2 expr-7.43 {(b+1234)||'this is a string that is at least 32 characters long' BETWEEN 1 AND 2} {}
|
||||||
@ -614,23 +642,28 @@ test_expr2 expr-7.68 {b = abs(+-++-2)} {1}
|
|||||||
test_expr2 expr-7.69 {b = abs(++++-2)} {1}
|
test_expr2 expr-7.69 {b = abs(++++-2)} {1}
|
||||||
test_expr2 expr-7.70 {b = 5 - abs(+3)} {1}
|
test_expr2 expr-7.70 {b = 5 - abs(+3)} {1}
|
||||||
test_expr2 expr-7.71 {b = 5 - abs(-3)} {1}
|
test_expr2 expr-7.71 {b = 5 - abs(-3)} {1}
|
||||||
test_expr2 expr-7.72 {b = abs(-2.0)} {1}
|
ifcapable floatingpoint {
|
||||||
|
test_expr2 expr-7.72 {b = abs(-2.0)} {1}
|
||||||
|
}
|
||||||
test_expr2 expr-7.73 {b = 6 - abs(-a)} {2}
|
test_expr2 expr-7.73 {b = 6 - abs(-a)} {2}
|
||||||
test_expr2 expr-7.74 {b = abs(8.0)} {3}
|
ifcapable floatingpoint {
|
||||||
|
test_expr2 expr-7.74 {b = abs(8.0)} {3}
|
||||||
|
}
|
||||||
|
|
||||||
# Test the CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP expressions.
|
# Test the CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP expressions.
|
||||||
#
|
#
|
||||||
set sqlite_current_time 1157124849
|
ifcapable {floatingpoint} {
|
||||||
do_test expr-8.1 {
|
set sqlite_current_time 1157124849
|
||||||
execsql {SELECT CURRENT_TIME}
|
do_test expr-8.1 {
|
||||||
} {15:34:09}
|
execsql {SELECT CURRENT_TIME}
|
||||||
do_test expr-8.2 {
|
} {15:34:09}
|
||||||
execsql {SELECT CURRENT_DATE}
|
do_test expr-8.2 {
|
||||||
} {2006-09-01}
|
execsql {SELECT CURRENT_DATE}
|
||||||
do_test expr-8.3 {
|
} {2006-09-01}
|
||||||
execsql {SELECT CURRENT_TIMESTAMP}
|
do_test expr-8.3 {
|
||||||
} {{2006-09-01 15:34:09}}
|
execsql {SELECT CURRENT_TIMESTAMP}
|
||||||
|
} {{2006-09-01 15:34:09}}
|
||||||
|
}
|
||||||
ifcapable datetime {
|
ifcapable datetime {
|
||||||
do_test expr-8.4 {
|
do_test expr-8.4 {
|
||||||
execsql {SELECT CURRENT_TIME==time('now');}
|
execsql {SELECT CURRENT_TIME==time('now');}
|
||||||
@ -644,9 +677,11 @@ ifcapable datetime {
|
|||||||
}
|
}
|
||||||
set sqlite_current_time 0
|
set sqlite_current_time 0
|
||||||
|
|
||||||
do_test expr-9.1 {
|
ifcapable floatingpoint {
|
||||||
execsql {SELECT round(-('-'||'123'))}
|
do_test expr-9.1 {
|
||||||
} 123.0
|
execsql {SELECT round(-('-'||'123'))}
|
||||||
|
} 123.0
|
||||||
|
}
|
||||||
|
|
||||||
# Test an error message that can be generated by the LIKE expression
|
# Test an error message that can be generated by the LIKE expression
|
||||||
do_test expr-10.1 {
|
do_test expr-10.1 {
|
||||||
@ -689,12 +724,14 @@ do_test expr-11.11 {
|
|||||||
do_test expr-11.12 {
|
do_test expr-11.12 {
|
||||||
execsql {SELECT typeof(-00000009223372036854775808)}
|
execsql {SELECT typeof(-00000009223372036854775808)}
|
||||||
} {integer}
|
} {integer}
|
||||||
do_test expr-11.13 {
|
ifcapable floatingpoint {
|
||||||
execsql {SELECT typeof(-9223372036854775809)}
|
do_test expr-11.13 {
|
||||||
} {real}
|
execsql {SELECT typeof(-9223372036854775809)}
|
||||||
do_test expr-11.14 {
|
} {real}
|
||||||
execsql {SELECT typeof(-00000009223372036854775809)}
|
do_test expr-11.14 {
|
||||||
} {real}
|
execsql {SELECT typeof(-00000009223372036854775809)}
|
||||||
|
} {real}
|
||||||
|
}
|
||||||
|
|
||||||
# These two statements used to leak memory (because of missing %destructor
|
# These two statements used to leak memory (because of missing %destructor
|
||||||
# directives in parse.y).
|
# directives in parse.y).
|
||||||
@ -709,37 +746,43 @@ do_test expr-12.2 {
|
|||||||
}
|
}
|
||||||
} {1 {near ")": syntax error}}
|
} {1 {near ")": syntax error}}
|
||||||
|
|
||||||
do_test expr-13.1 {
|
ifcapable floatingpoint {
|
||||||
execsql {
|
do_test expr-13.1 {
|
||||||
SELECT 12345678901234567890;
|
execsql {
|
||||||
}
|
SELECT 12345678901234567890;
|
||||||
} {1.23456789012346e+19}
|
}
|
||||||
|
} {1.23456789012346e+19}
|
||||||
|
}
|
||||||
|
|
||||||
# Implicit String->Integer conversion is used when possible.
|
# Implicit String->Integer conversion is used when possible.
|
||||||
#
|
#
|
||||||
do_test expr-13.2 {
|
if {[working_64bit_int]} {
|
||||||
execsql {
|
do_test expr-13.2 {
|
||||||
SELECT 0+'9223372036854775807'
|
execsql {
|
||||||
}
|
SELECT 0+'9223372036854775807'
|
||||||
} {9223372036854775807}
|
}
|
||||||
do_test expr-13.3 {
|
} {9223372036854775807}
|
||||||
execsql {
|
do_test expr-13.3 {
|
||||||
SELECT '9223372036854775807'+0
|
execsql {
|
||||||
}
|
SELECT '9223372036854775807'+0
|
||||||
} {9223372036854775807}
|
}
|
||||||
|
} {9223372036854775807}
|
||||||
|
}
|
||||||
|
|
||||||
# If the value is too large, use String->Float conversion.
|
# If the value is too large, use String->Float conversion.
|
||||||
#
|
#
|
||||||
do_test expr-13.4 {
|
ifcapable floatingpoint {
|
||||||
execsql {
|
do_test expr-13.4 {
|
||||||
SELECT 0+'9223372036854775808'
|
execsql {
|
||||||
}
|
SELECT 0+'9223372036854775808'
|
||||||
} {9.22337203685478e+18}
|
}
|
||||||
do_test expr-13.5 {
|
} {9.22337203685478e+18}
|
||||||
execsql {
|
do_test expr-13.5 {
|
||||||
SELECT '9223372036854775808'+0
|
execsql {
|
||||||
}
|
SELECT '9223372036854775808'+0
|
||||||
} {9.22337203685478e+18}
|
}
|
||||||
|
} {9.22337203685478e+18}
|
||||||
|
}
|
||||||
|
|
||||||
# Use String->float conversion if the value is explicitly a floating
|
# Use String->float conversion if the value is explicitly a floating
|
||||||
# point value.
|
# point value.
|
||||||
|
328
test/func.test
328
test/func.test
@ -11,7 +11,7 @@
|
|||||||
# This file implements regression tests for SQLite library. The
|
# This file implements regression tests for SQLite library. The
|
||||||
# focus of this file is testing built-in functions.
|
# focus of this file is testing built-in functions.
|
||||||
#
|
#
|
||||||
# $Id: func.test,v 1.90 2009/02/02 21:57:05 drh Exp $
|
# $Id: func.test,v 1.91 2009/02/04 03:59:25 shane Exp $
|
||||||
|
|
||||||
set testdir [file dirname $argv0]
|
set testdir [file dirname $argv0]
|
||||||
source $testdir/tester.tcl
|
source $testdir/tester.tcl
|
||||||
@ -149,24 +149,49 @@ do_test func-3.99 {
|
|||||||
|
|
||||||
# Test the abs() and round() functions.
|
# Test the abs() and round() functions.
|
||||||
#
|
#
|
||||||
do_test func-4.1 {
|
ifcapable !floatingpoint {
|
||||||
execsql {
|
do_test func-4.1 {
|
||||||
CREATE TABLE t1(a,b,c);
|
execsql {
|
||||||
INSERT INTO t1 VALUES(1,2,3);
|
CREATE TABLE t1(a,b,c);
|
||||||
INSERT INTO t1 VALUES(2,1.2345678901234,-12345.67890);
|
INSERT INTO t1 VALUES(1,2,3);
|
||||||
INSERT INTO t1 VALUES(3,-2,-5);
|
INSERT INTO t1 VALUES(2,12345678901234,-1234567890);
|
||||||
}
|
INSERT INTO t1 VALUES(3,-2,-5);
|
||||||
catchsql {SELECT abs(a,b) FROM t1}
|
}
|
||||||
} {1 {wrong number of arguments to function abs()}}
|
catchsql {SELECT abs(a,b) FROM t1}
|
||||||
|
} {1 {wrong number of arguments to function abs()}}
|
||||||
|
}
|
||||||
|
ifcapable floatingpoint {
|
||||||
|
do_test func-4.1 {
|
||||||
|
execsql {
|
||||||
|
CREATE TABLE t1(a,b,c);
|
||||||
|
INSERT INTO t1 VALUES(1,2,3);
|
||||||
|
INSERT INTO t1 VALUES(2,1.2345678901234,-12345.67890);
|
||||||
|
INSERT INTO t1 VALUES(3,-2,-5);
|
||||||
|
}
|
||||||
|
catchsql {SELECT abs(a,b) FROM t1}
|
||||||
|
} {1 {wrong number of arguments to function abs()}}
|
||||||
|
}
|
||||||
do_test func-4.2 {
|
do_test func-4.2 {
|
||||||
catchsql {SELECT abs() FROM t1}
|
catchsql {SELECT abs() FROM t1}
|
||||||
} {1 {wrong number of arguments to function abs()}}
|
} {1 {wrong number of arguments to function abs()}}
|
||||||
do_test func-4.3 {
|
ifcapable floatingpoint {
|
||||||
catchsql {SELECT abs(b) FROM t1 ORDER BY a}
|
do_test func-4.3 {
|
||||||
} {0 {2 1.2345678901234 2}}
|
catchsql {SELECT abs(b) FROM t1 ORDER BY a}
|
||||||
do_test func-4.4 {
|
} {0 {2 1.2345678901234 2}}
|
||||||
catchsql {SELECT abs(c) FROM t1 ORDER BY a}
|
do_test func-4.4 {
|
||||||
} {0 {3 12345.6789 5}}
|
catchsql {SELECT abs(c) FROM t1 ORDER BY a}
|
||||||
|
} {0 {3 12345.6789 5}}
|
||||||
|
}
|
||||||
|
ifcapable !floatingpoint {
|
||||||
|
if {[working_64bit_int]} {
|
||||||
|
do_test func-4.3 {
|
||||||
|
catchsql {SELECT abs(b) FROM t1 ORDER BY a}
|
||||||
|
} {0 {2 12345678901234 2}}
|
||||||
|
}
|
||||||
|
do_test func-4.4 {
|
||||||
|
catchsql {SELECT abs(c) FROM t1 ORDER BY a}
|
||||||
|
} {0 {3 1234567890 5}}
|
||||||
|
}
|
||||||
do_test func-4.4.1 {
|
do_test func-4.4.1 {
|
||||||
execsql {SELECT abs(a) FROM t2}
|
execsql {SELECT abs(a) FROM t2}
|
||||||
} {1 {} 345 {} 67890}
|
} {1 {} 345 {} 67890}
|
||||||
@ -174,40 +199,44 @@ do_test func-4.4.2 {
|
|||||||
execsql {SELECT abs(t1) FROM tbl1}
|
execsql {SELECT abs(t1) FROM tbl1}
|
||||||
} {0.0 0.0 0.0 0.0 0.0}
|
} {0.0 0.0 0.0 0.0 0.0}
|
||||||
|
|
||||||
do_test func-4.5 {
|
ifcapable floatingpoint {
|
||||||
catchsql {SELECT round(a,b,c) FROM t1}
|
do_test func-4.5 {
|
||||||
} {1 {wrong number of arguments to function round()}}
|
catchsql {SELECT round(a,b,c) FROM t1}
|
||||||
do_test func-4.6 {
|
} {1 {wrong number of arguments to function round()}}
|
||||||
catchsql {SELECT round(b,2) FROM t1 ORDER BY b}
|
do_test func-4.6 {
|
||||||
} {0 {-2.0 1.23 2.0}}
|
catchsql {SELECT round(b,2) FROM t1 ORDER BY b}
|
||||||
do_test func-4.7 {
|
} {0 {-2.0 1.23 2.0}}
|
||||||
catchsql {SELECT round(b,0) FROM t1 ORDER BY a}
|
do_test func-4.7 {
|
||||||
} {0 {2.0 1.0 -2.0}}
|
catchsql {SELECT round(b,0) FROM t1 ORDER BY a}
|
||||||
do_test func-4.8 {
|
} {0 {2.0 1.0 -2.0}}
|
||||||
catchsql {SELECT round(c) FROM t1 ORDER BY a}
|
do_test func-4.8 {
|
||||||
} {0 {3.0 -12346.0 -5.0}}
|
catchsql {SELECT round(c) FROM t1 ORDER BY a}
|
||||||
do_test func-4.9 {
|
} {0 {3.0 -12346.0 -5.0}}
|
||||||
catchsql {SELECT round(c,a) FROM t1 ORDER BY a}
|
do_test func-4.9 {
|
||||||
} {0 {3.0 -12345.68 -5.0}}
|
catchsql {SELECT round(c,a) FROM t1 ORDER BY a}
|
||||||
do_test func-4.10 {
|
} {0 {3.0 -12345.68 -5.0}}
|
||||||
catchsql {SELECT 'x' || round(c,a) || 'y' FROM t1 ORDER BY a}
|
do_test func-4.10 {
|
||||||
} {0 {x3.0y x-12345.68y x-5.0y}}
|
catchsql {SELECT 'x' || round(c,a) || 'y' FROM t1 ORDER BY a}
|
||||||
do_test func-4.11 {
|
} {0 {x3.0y x-12345.68y x-5.0y}}
|
||||||
catchsql {SELECT round() FROM t1 ORDER BY a}
|
do_test func-4.11 {
|
||||||
} {1 {wrong number of arguments to function round()}}
|
catchsql {SELECT round() FROM t1 ORDER BY a}
|
||||||
do_test func-4.12 {
|
} {1 {wrong number of arguments to function round()}}
|
||||||
execsql {SELECT coalesce(round(a,2),'nil') FROM t2}
|
do_test func-4.12 {
|
||||||
} {1.0 nil 345.0 nil 67890.0}
|
execsql {SELECT coalesce(round(a,2),'nil') FROM t2}
|
||||||
do_test func-4.13 {
|
} {1.0 nil 345.0 nil 67890.0}
|
||||||
execsql {SELECT round(t1,2) FROM tbl1}
|
do_test func-4.13 {
|
||||||
} {0.0 0.0 0.0 0.0 0.0}
|
execsql {SELECT round(t1,2) FROM tbl1}
|
||||||
do_test func-4.14 {
|
} {0.0 0.0 0.0 0.0 0.0}
|
||||||
execsql {SELECT typeof(round(5.1,1));}
|
do_test func-4.14 {
|
||||||
} {real}
|
execsql {SELECT typeof(round(5.1,1));}
|
||||||
do_test func-4.15 {
|
} {real}
|
||||||
execsql {SELECT typeof(round(5.1));}
|
do_test func-4.15 {
|
||||||
} {real}
|
execsql {SELECT typeof(round(5.1));}
|
||||||
|
} {real}
|
||||||
|
do_test func-4.16 {
|
||||||
|
catchsql {SELECT round(b,2.0) FROM t1 ORDER BY b}
|
||||||
|
} {0 {-2.0 1.23 2.0}}
|
||||||
|
}
|
||||||
|
|
||||||
# Test the upper() and lower() functions
|
# Test the upper() and lower() functions
|
||||||
#
|
#
|
||||||
@ -256,14 +285,26 @@ do_test func-7.1 {
|
|||||||
|
|
||||||
# Tests for aggregate functions and how they handle NULLs.
|
# Tests for aggregate functions and how they handle NULLs.
|
||||||
#
|
#
|
||||||
do_test func-8.1 {
|
ifcapable floatingpoint {
|
||||||
ifcapable explain {
|
do_test func-8.1 {
|
||||||
execsql {EXPLAIN SELECT sum(a) FROM t2;}
|
ifcapable explain {
|
||||||
}
|
execsql {EXPLAIN SELECT sum(a) FROM t2;}
|
||||||
execsql {
|
}
|
||||||
SELECT sum(a), count(a), round(avg(a),2), min(a), max(a), count(*) FROM t2;
|
execsql {
|
||||||
}
|
SELECT sum(a), count(a), round(avg(a),2), min(a), max(a), count(*) FROM t2;
|
||||||
} {68236 3 22745.33 1 67890 5}
|
}
|
||||||
|
} {68236 3 22745.33 1 67890 5}
|
||||||
|
}
|
||||||
|
ifcapable !floatingpoint {
|
||||||
|
do_test func-8.1 {
|
||||||
|
ifcapable explain {
|
||||||
|
execsql {EXPLAIN SELECT sum(a) FROM t2;}
|
||||||
|
}
|
||||||
|
execsql {
|
||||||
|
SELECT sum(a), count(a), avg(a), min(a), max(a), count(*) FROM t2;
|
||||||
|
}
|
||||||
|
} {68236 3 22745.0 1 67890 5}
|
||||||
|
}
|
||||||
do_test func-8.2 {
|
do_test func-8.2 {
|
||||||
execsql {
|
execsql {
|
||||||
SELECT max('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t2;
|
SELECT max('z+'||a||'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOP') FROM t2;
|
||||||
@ -309,6 +350,7 @@ ifcapable compound {
|
|||||||
UNION ALL SELECT -9223372036854775807)
|
UNION ALL SELECT -9223372036854775807)
|
||||||
}
|
}
|
||||||
} {real}
|
} {real}
|
||||||
|
ifcapable floatingpoint {
|
||||||
do_test func-8.8 {
|
do_test func-8.8 {
|
||||||
execsql {
|
execsql {
|
||||||
SELECT sum(x)>0.0 FROM (SELECT '9223372036' || '854775808' AS x
|
SELECT sum(x)>0.0 FROM (SELECT '9223372036' || '854775808' AS x
|
||||||
@ -316,6 +358,15 @@ ifcapable compound {
|
|||||||
}
|
}
|
||||||
} {1}
|
} {1}
|
||||||
}
|
}
|
||||||
|
ifcapable !floatingpoint {
|
||||||
|
do_test func-8.8 {
|
||||||
|
execsql {
|
||||||
|
SELECT sum(x)>0 FROM (SELECT '9223372036' || '854775808' AS x
|
||||||
|
UNION ALL SELECT -9223372036850000000)
|
||||||
|
}
|
||||||
|
} {1}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# How do you test the random() function in a meaningful, deterministic way?
|
# How do you test the random() function in a meaningful, deterministic way?
|
||||||
#
|
#
|
||||||
@ -406,32 +457,35 @@ do_test func-10.3 {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} {{}}
|
} {{}}
|
||||||
do_test func-10.4 {
|
|
||||||
execsql {
|
ifcapable floatingpoint {
|
||||||
SELECT testfunc(
|
do_test func-10.4 {
|
||||||
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
execsql {
|
||||||
'double', 1.234
|
SELECT testfunc(
|
||||||
);
|
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||||
}
|
'double', 1.234
|
||||||
} {1.234}
|
);
|
||||||
do_test func-10.5 {
|
}
|
||||||
execsql {
|
} {1.234}
|
||||||
SELECT testfunc(
|
do_test func-10.5 {
|
||||||
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
execsql {
|
||||||
'int', 1234,
|
SELECT testfunc(
|
||||||
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||||
'string', NULL,
|
'int', 1234,
|
||||||
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||||
'double', 1.234,
|
'string', NULL,
|
||||||
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||||
'int', 1234,
|
'double', 1.234,
|
||||||
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||||
'string', NULL,
|
'int', 1234,
|
||||||
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||||
'double', 1.234
|
'string', NULL,
|
||||||
);
|
'string', 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
|
||||||
}
|
'double', 1.234
|
||||||
} {1.234}
|
);
|
||||||
|
}
|
||||||
|
} {1.234}
|
||||||
|
}
|
||||||
|
|
||||||
# Test the built-in sqlite_version(*) SQL function.
|
# Test the built-in sqlite_version(*) SQL function.
|
||||||
#
|
#
|
||||||
@ -610,12 +664,14 @@ do_test func-18.1 {
|
|||||||
SELECT sum(x) FROM t5;
|
SELECT sum(x) FROM t5;
|
||||||
}
|
}
|
||||||
} {9902}
|
} {9902}
|
||||||
do_test func-18.2 {
|
ifcapable floatingpoint {
|
||||||
execsql {
|
do_test func-18.2 {
|
||||||
INSERT INTO t5 VALUES(0.0);
|
execsql {
|
||||||
SELECT sum(x) FROM t5;
|
INSERT INTO t5 VALUES(0.0);
|
||||||
}
|
SELECT sum(x) FROM t5;
|
||||||
} {9902.0}
|
}
|
||||||
|
} {9902.0}
|
||||||
|
}
|
||||||
|
|
||||||
# The sum of nothing is NULL. But the sum of all NULLs is NULL.
|
# The sum of nothing is NULL. But the sum of all NULLs is NULL.
|
||||||
#
|
#
|
||||||
@ -663,23 +719,39 @@ do_test func-18.11 {
|
|||||||
SELECT typeof(sum(x)) FROM t6
|
SELECT typeof(sum(x)) FROM t6
|
||||||
}
|
}
|
||||||
} integer
|
} integer
|
||||||
do_test func-18.12 {
|
ifcapable floatingpoint {
|
||||||
catchsql {
|
do_test func-18.12 {
|
||||||
INSERT INTO t6 VALUES(1<<62);
|
catchsql {
|
||||||
SELECT sum(x) - ((1<<62)*2.0+1) from t6;
|
INSERT INTO t6 VALUES(1<<62);
|
||||||
}
|
SELECT sum(x) - ((1<<62)*2.0+1) from t6;
|
||||||
} {1 {integer overflow}}
|
}
|
||||||
do_test func-18.13 {
|
} {1 {integer overflow}}
|
||||||
execsql {
|
do_test func-18.13 {
|
||||||
SELECT total(x) - ((1<<62)*2.0+1) FROM t6
|
execsql {
|
||||||
}
|
SELECT total(x) - ((1<<62)*2.0+1) FROM t6
|
||||||
} 0.0
|
}
|
||||||
do_test func-18.14 {
|
} 0.0
|
||||||
execsql {
|
}
|
||||||
SELECT sum(-9223372036854775805);
|
ifcapable !floatingpoint {
|
||||||
}
|
do_test func-18.12 {
|
||||||
} -9223372036854775805
|
catchsql {
|
||||||
|
INSERT INTO t6 VALUES(1<<62);
|
||||||
|
SELECT sum(x) - ((1<<62)*2+1) from t6;
|
||||||
|
}
|
||||||
|
} {1 {integer overflow}}
|
||||||
|
do_test func-18.13 {
|
||||||
|
execsql {
|
||||||
|
SELECT total(x) - ((1<<62)*2+1) FROM t6
|
||||||
|
}
|
||||||
|
} 0.0
|
||||||
|
}
|
||||||
|
if {[working_64bit_int]} {
|
||||||
|
do_test func-18.14 {
|
||||||
|
execsql {
|
||||||
|
SELECT sum(-9223372036854775805);
|
||||||
|
}
|
||||||
|
} -9223372036854775805
|
||||||
|
}
|
||||||
ifcapable compound&&subquery {
|
ifcapable compound&&subquery {
|
||||||
|
|
||||||
do_test func-18.15 {
|
do_test func-18.15 {
|
||||||
@ -689,20 +761,22 @@ do_test func-18.15 {
|
|||||||
SELECT 10 AS x);
|
SELECT 10 AS x);
|
||||||
}
|
}
|
||||||
} {1 {integer overflow}}
|
} {1 {integer overflow}}
|
||||||
do_test func-18.16 {
|
if {[working_64bit_int]} {
|
||||||
catchsql {
|
do_test func-18.16 {
|
||||||
SELECT sum(x) FROM
|
catchsql {
|
||||||
(SELECT 9223372036854775807 AS x UNION ALL
|
SELECT sum(x) FROM
|
||||||
SELECT -10 AS x);
|
(SELECT 9223372036854775807 AS x UNION ALL
|
||||||
}
|
SELECT -10 AS x);
|
||||||
} {0 9223372036854775797}
|
}
|
||||||
do_test func-18.17 {
|
} {0 9223372036854775797}
|
||||||
catchsql {
|
do_test func-18.17 {
|
||||||
SELECT sum(x) FROM
|
catchsql {
|
||||||
(SELECT -9223372036854775807 AS x UNION ALL
|
SELECT sum(x) FROM
|
||||||
SELECT 10 AS x);
|
(SELECT -9223372036854775807 AS x UNION ALL
|
||||||
}
|
SELECT 10 AS x);
|
||||||
} {0 -9223372036854775797}
|
}
|
||||||
|
} {0 -9223372036854775797}
|
||||||
|
}
|
||||||
do_test func-18.18 {
|
do_test func-18.18 {
|
||||||
catchsql {
|
catchsql {
|
||||||
SELECT sum(x) FROM
|
SELECT sum(x) FROM
|
||||||
@ -735,11 +809,13 @@ do_test func-18.22 {
|
|||||||
|
|
||||||
# Integer overflow on abs()
|
# Integer overflow on abs()
|
||||||
#
|
#
|
||||||
do_test func-18.31 {
|
if {[working_64bit_int]} {
|
||||||
catchsql {
|
do_test func-18.31 {
|
||||||
SELECT abs(-9223372036854775807);
|
catchsql {
|
||||||
}
|
SELECT abs(-9223372036854775807);
|
||||||
} {0 9223372036854775807}
|
}
|
||||||
|
} {0 9223372036854775807}
|
||||||
|
}
|
||||||
do_test func-18.32 {
|
do_test func-18.32 {
|
||||||
catchsql {
|
catchsql {
|
||||||
SELECT abs(-9223372036854775807-1);
|
SELECT abs(-9223372036854775807-1);
|
||||||
|
Reference in New Issue
Block a user