From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 77D227034A; Tue, 26 Oct 2021 13:27:21 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 77D227034A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1635244041; bh=4B9luRcJcf48H7HD5d5/2jq+m6S87pnXwTo8H7rnv7U=; h=To:Cc:Date:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=NkxqMRooa/rzE6JnN6pPBmHIxZPl+fhRL8dOnK2YRNA6rYjsFTaJpjzTaJb758pqi LuViq9ek9bE1aF/GQjZ6cdp0yNzHsF+033Bza8G2RJ/Arx+qo5krjHbDmNZDsfy4+v NSevkDm1uP6ZmrbsoGnY2aLE3tyPi0On8EeLZDYs= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 13C9A7034A for ; Tue, 26 Oct 2021 13:27:19 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 13C9A7034A Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mfJfp-0004hN-OV; Tue, 26 Oct 2021 13:27:18 +0300 To: kyukhin@tarantool.org Cc: tarantool-patches@dev.tarantool.org Date: Tue, 26 Oct 2021 13:27:17 +0300 Message-Id: <2034015457e159e14c25cdfefa1d38a5864862a6.1635243948.git.imeevma@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD9D1D35DBD2D15487E109F535F427989191BFAC4E9BCE66C72182A05F538085040A21B87ABC697C74ABE522DB85731930B7AAC9618D9439E732748C070CE6FBF41 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7344E87C2CDB13504EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006377FBD0C19846D7D468638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D831FF7B96E3E3AF3266FC3B47F2F4EA28117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8BAA867293B0326636D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B62CFFCC7B69C47339089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-B7AD71C0: AC4F5C86D027EB782CDD5689AFBDA7A213B5FB47DCBC3458834459D11680B505F9998113803A6C33B2BFE6D5D915F83C X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C2749EEF4D85F8CCA3688F526B06FC0F8F22A1950D2FDC6039C2B6934AE262D3EE7EAB7254005DCED2BDA8865FF9E75031E0A4E2319210D9B64D260DF9561598F01A9E91200F654B09D02A5090F3BCDFA8E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34DFB7A809FB537087EC8F90D5A6309CAFC2F8B5BB24CBBA8C08056DF05FAD8AC7D0D792602E68F2FA1D7E09C32AA3244C7F80074D3AFF8FE02A123C49FC18EDC7F2F5F14F68F1805B729B2BEF169E0186 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXgcYNvpGtHQy0m9ufzWOgbJ X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5DB363409CE15E87B2004102F7469A0CB383D72C36FC87018B9F80AB2734326CD2FB559BB5D741EB96352A0ABBE4FDA4210A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: [Tarantool-patches] [PATCH v1 1/1] sql: introduce literals for DECIMAL X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Mergen Imeev via Tarantool-patches Reply-To: imeevma@tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Part of #6356 @TarantoolBot document Title: Literals for INTEGER, DECIMAL and DOUBLE The rules for parsing numeric values have changed: 1) a value consisting of digits without decimal point and exponent will be parsed as INTEGER; 2) a value consisting of digits and a decimal point will be parsed as DECIMAL; 3) a value consisting of digits, containing an exponent and possibly containing a decimal point, will be parsed as DOUBLE. --- https://github.com/tarantool/tarantool/issues/6356 https://github.com/tarantool/tarantool/tree/imeevma/gh-6356-literals-for-decimal .../gh-6356-literals-for-decimal.md | 4 + src/box/sql/expr.c | 31 ++++++ src/box/sql/parse.y | 4 + src/box/sql/tokenize.c | 2 +- src/box/sql/vdbe.c | 12 +++ src/box/sql/vdbe.h | 4 + src/box/sql/vdbeapi.c | 3 + src/box/sql/vdbeaux.c | 5 + test/sql-tap/cast.test.lua | 22 ++--- test/sql-tap/check.test.lua | 2 +- test/sql-tap/decimal.test.lua | 54 ++++++++++- test/sql-tap/default.test.lua | 4 +- test/sql-tap/e_select1.test.lua | 14 +-- test/sql-tap/func.test.lua | 18 ++-- test/sql-tap/func3.test.lua | 26 ++--- .../gh-5364-define-bit-wise-rules.test.lua | 8 +- ...-5756-implicit-cast-in-arithmetic.test.lua | 10 +- .../gh-6239-quote-with-double-arg.test.lua | 2 +- test/sql-tap/index1.test.lua | 2 +- test/sql-tap/insert3.test.lua | 3 +- test/sql-tap/lua_sql.test.lua | 4 +- test/sql-tap/metatypes.test.lua | 2 +- test/sql-tap/misc5.test.lua | 4 +- test/sql-tap/numcast.test.lua | 38 ++++---- test/sql-tap/select1.test.lua | 4 +- test/sql-tap/select4.test.lua | 2 +- test/sql-tap/selectB.test.lua | 6 +- test/sql-tap/sort.test.lua | 2 +- test/sql-tap/tkt-9a8b09f8e6.test.lua | 28 +++--- test/sql-tap/tkt-a8a0d2996a.test.lua | 2 +- test/sql-tap/types.test.lua | 2 +- test/sql-tap/uuid.test.lua | 10 +- test/sql-tap/whereA.test.lua | 2 +- test/sql-tap/whereG.test.lua | 10 +- test/sql-tap/with1.test.lua | 6 +- test/sql/boolean.result | 96 +++++++++---------- test/sql/func-recreate.result | 2 +- test/sql/func-recreate.test.lua | 2 +- test/sql/gh-3888-values-blob-assert.result | 2 +- test/sql/integer-overflow.result | 2 +- test/sql/integer-overflow.test.lua | 2 +- test/sql/misc.result | 18 +++- test/sql/misc.test.lua | 2 + test/sql/types.result | 51 +++++----- test/sql/types.test.lua | 10 +- 45 files changed, 335 insertions(+), 204 deletions(-) create mode 100644 changelogs/unreleased/gh-6356-literals-for-decimal.md diff --git a/changelogs/unreleased/gh-6356-literals-for-decimal.md b/changelogs/unreleased/gh-6356-literals-for-decimal.md new file mode 100644 index 000000000..24b8d7e40 --- /dev/null +++ b/changelogs/unreleased/gh-6356-literals-for-decimal.md @@ -0,0 +1,4 @@ +## feature/sql + +* A value consisting of digits and a decimal point is now parsed as + DECIMAL (gh-6456). diff --git a/src/box/sql/expr.c b/src/box/sql/expr.c index ee21c1ede..9e635a0f8 100644 --- a/src/box/sql/expr.c +++ b/src/box/sql/expr.c @@ -3286,6 +3286,30 @@ codeReal(Vdbe * v, const char *z, int negateFlag, int iMem) } } +static void +expr_code_dec(struct Parse *parser, struct Expr *expr, bool is_neg, int reg) +{ + const char *str = expr->u.zToken; + assert(str != NULL); + decimal_t *value = sqlDbMallocRawNN(sql_get(), sizeof(*value)); + if (value == NULL) + goto error; + if (is_neg) { + decimal_t dec; + if (decimal_from_string(&dec, str) == NULL) + goto error; + decimal_minus(value, &dec); + } else if (decimal_from_string(value, str) == NULL) { + goto error; + } + sqlVdbeAddOp4(parser->pVdbe, OP_Decimal, 0, reg, 0, (char *)value, + P4_DEC); + return; +error: + sqlDbFree(sql_get(), value); + parser->is_aborted = true; +} + /** * Generate an instruction that will put the integer describe by * text z[0..n-1] into register iMem. @@ -3725,6 +3749,10 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target) sqlVdbeAddOp2(v, OP_Bool, op == TK_TRUE, target); return target; } + case TK_DECIMAL:{ + expr_code_dec(pParse, pExpr, false, target); + return target; + } case TK_FLOAT:{ assert(!ExprHasProperty(pExpr, EP_IntValue)); codeReal(v, pExpr->u.zToken, 0, target); @@ -3884,6 +3912,9 @@ sqlExprCodeTarget(Parse * pParse, Expr * pExpr, int target) assert(!ExprHasProperty(pExpr, EP_IntValue)); codeReal(v, pLeft->u.zToken, 1, target); return target; + } else if (pLeft->op == TK_DECIMAL) { + expr_code_dec(pParse, pLeft, true, target); + return target; } else { tempX.op = TK_INTEGER; tempX.flags = EP_IntValue | EP_TokenOnly; diff --git a/src/box/sql/parse.y b/src/box/sql/parse.y index 337df4916..ae480a5d1 100644 --- a/src/box/sql/parse.y +++ b/src/box/sql/parse.y @@ -994,6 +994,9 @@ idlist(A) ::= nm(Y). { case TK_FLOAT: p->type = FIELD_TYPE_DOUBLE; break; + case TK_DECIMAL: + p->type = FIELD_TYPE_DECIMAL; + break; case TK_TRUE: case TK_FALSE: case TK_UNKNOWN: @@ -1071,6 +1074,7 @@ term(A) ::= STRING(X). {spanExpr(&A,pParse,@X,X);/*A-overwrites-X*/} term(A) ::= FALSE(X) . {spanExpr(&A,pParse,@X,X);/*A-overwrites-X*/} term(A) ::= TRUE(X) . {spanExpr(&A,pParse,@X,X);/*A-overwrites-X*/} term(A) ::= UNKNOWN(X) . {spanExpr(&A,pParse,@X,X);/*A-overwrites-X*/} +term(A) ::= DECIMAL(X) . {spanExpr(&A,pParse,@X,X);/*A-overwrites-X*/} term(A) ::= INTEGER(X). { A.pExpr = sql_expr_new_dequoted(pParse->db, TK_INTEGER, &X); diff --git a/src/box/sql/tokenize.c b/src/box/sql/tokenize.c index 0899cf23e..b3cf8f6e6 100644 --- a/src/box/sql/tokenize.c +++ b/src/box/sql/tokenize.c @@ -343,7 +343,7 @@ sql_token(const char *z, int *type, bool *is_reserved) if (z[i] == '.') { while (sqlIsdigit(z[++i])) { } - *type = TK_FLOAT; + *type = TK_DECIMAL; } if ((z[i] == 'e' || z[i] == 'E') && (sqlIsdigit(z[i + 1]) diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 44533fb3e..c70c1fb30 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -804,6 +804,18 @@ case OP_Real: { /* same as TK_FLOAT, out2 */ break; } +/** + * Opcode: Decimal * P2 * P4 * + * Synopsis: r[P2]=P4 + * + * P4 is a pointer to a DECIMAL value. Write that value into register P2. + */ +case OP_Decimal: { /* same as TK_DECIMAL, out2 */ + pOut = vdbe_prepare_null_out(p, pOp->p2); + mem_set_dec(pOut, pOp->p4.dec); + break; +} + /* Opcode: String8 * P2 * P4 * * Synopsis: r[P2]='P4' * diff --git a/src/box/sql/vdbe.h b/src/box/sql/vdbe.h index e40a1a0b3..121b86029 100644 --- a/src/box/sql/vdbe.h +++ b/src/box/sql/vdbe.h @@ -97,6 +97,8 @@ struct VdbeOp { * Information about ephemeral space field types and key parts. */ struct sql_space_info *space_info; + /** P4 contains address of decimal. */ + decimal_t *dec; } p4; #ifdef SQL_ENABLE_EXPLAIN_COMMENTS char *zComment; /* Comment to improve readability */ @@ -132,6 +134,8 @@ struct SubProgram { #define P4_COLLSEQ (-3) /* P4 is a pointer to a CollSeq structure */ /** P4 is a pointer to a func structure. */ #define P4_FUNC (-4) +/** P4 is a pointer to a decimal. */ +#define P4_DEC (-5) #define P4_MEM (-7) /* P4 is a pointer to a Mem* structure */ #define P4_TRANSIENT 0 /* P4 is a pointer to a transient string */ #define P4_REAL (-9) /* P4 is a 64-bit floating point value */ diff --git a/src/box/sql/vdbeapi.c b/src/box/sql/vdbeapi.c index 115940227..22c6bd656 100644 --- a/src/box/sql/vdbeapi.c +++ b/src/box/sql/vdbeapi.c @@ -563,6 +563,9 @@ sql_stmt_est_size(const struct sql_stmt *stmt) case P4_REAL: size += sizeof(*v->aOp[i].p4.pReal); break; + case P4_DEC: + size += sizeof(*v->aOp[i].p4.dec); + break; default: size += sizeof(v->aOp[i].p4.p); break; diff --git a/src/box/sql/vdbeaux.c b/src/box/sql/vdbeaux.c index 8148ed8b0..4ce08359c 100644 --- a/src/box/sql/vdbeaux.c +++ b/src/box/sql/vdbeaux.c @@ -605,6 +605,7 @@ freeP4(sql * db, int p4type, void *p4) freeP4FuncCtx(db, (sql_context *) p4); break; } + case P4_DEC: case P4_REAL: case P4_INT64: case P4_UINT64: @@ -1095,6 +1096,10 @@ displayP4(Op * pOp, char *zTemp, int nTemp) sqlXPrintf(&x, "%.16g", *pOp->p4.pReal); break; } + case P4_DEC:{ + sqlXPrintf(&x, "%s", decimal_str(pOp->p4.dec)); + break; + } case P4_MEM:{ const char *value = mem_str(pOp->p4.pMem); sqlStrAccumAppend(&x, value, strlen(value)); diff --git a/test/sql-tap/cast.test.lua b/test/sql-tap/cast.test.lua index 68d2ae585..d5c9cbbc6 100755 --- a/test/sql-tap/cast.test.lua +++ b/test/sql-tap/cast.test.lua @@ -307,7 +307,7 @@ test:do_execsql_test( test:do_execsql_test( "cast-1.31", [[ - SELECT 123.456 + SELECT 123.456e0 ]], { -- 123.456 @@ -317,7 +317,7 @@ test:do_execsql_test( test:do_execsql_test( "cast-1.32", [[ - SELECT typeof(123.456) + SELECT typeof(123.456e0) ]], { -- "double" @@ -337,7 +337,7 @@ test:do_execsql_test( test:do_execsql_test( "cast-1.34", [[ - SELECT typeof(CAST(123.456 AS text)) + SELECT typeof(CAST(123.456e0 AS text)) ]], { -- "string" @@ -347,7 +347,7 @@ test:do_execsql_test( test:do_execsql_test( "cast-1.35", [[ - SELECT CAST(123.456 AS NUMBER) + SELECT CAST(123.456e0 AS NUMBER) ]], { -- 123.456 @@ -357,7 +357,7 @@ test:do_execsql_test( test:do_execsql_test( "cast-1.36", [[ - SELECT typeof(CAST(123.456 AS DOUBLE)) + SELECT typeof(CAST(123.456e0 AS DOUBLE)) ]], { -- "double" @@ -367,7 +367,7 @@ test:do_execsql_test( test:do_execsql_test( "cast-1.37", [[ - SELECT CAST(123.456 AS SCALAR) + SELECT CAST(123.456e0 AS SCALAR) ]], { -- 123.456 @@ -377,7 +377,7 @@ test:do_execsql_test( test:do_execsql_test( "cast-1.38", [[ - SELECT typeof(CAST(123.456 AS SCALAR)) + SELECT typeof(CAST(123.456e0 AS SCALAR)) ]], { -- "scalar" @@ -387,7 +387,7 @@ test:do_execsql_test( test:do_execsql_test( "cast-1.39", [[ - SELECT CAST(123.456 AS integer) + SELECT CAST(123.456e0 AS integer) ]], { -- 123 @@ -397,7 +397,7 @@ test:do_execsql_test( test:do_execsql_test( "cast-1.38", [[ - SELECT typeof(CAST(123.456 AS integer)) + SELECT typeof(CAST(123.456e0 AS integer)) ]], { -- "integer" @@ -962,7 +962,7 @@ test:do_catchsql_test( test:do_catchsql_test( "cast-6.2.3", [[ - SELECT CAST(1.5 AS BOOLEAN); + SELECT CAST(1.5e0 AS BOOLEAN); ]], { 1, "Type mismatch: can not convert double(1.5) to boolean" }) @@ -1139,7 +1139,7 @@ test:do_catchsql_test( test:do_catchsql_test( "cast-10.4", [[ - SELECT '1' < 2.5; + SELECT '1' < 2.5e0; ]], { 1, "Type mismatch: can not convert double(2.5) to string" }) diff --git a/test/sql-tap/check.test.lua b/test/sql-tap/check.test.lua index f8dcb7f7b..6c0707f6b 100755 --- a/test/sql-tap/check.test.lua +++ b/test/sql-tap/check.test.lua @@ -207,7 +207,7 @@ test:do_execsql_test( CREATE TABLE t2( id INT primary key, x SCALAR CONSTRAINT one CHECK( typeof(coalesce(x,0))=='integer'), - y DOUBLE CONSTRAINT two CHECK( typeof(coalesce(y,0.1))=='double' ), + y DOUBLE CONSTRAINT two CHECK( typeof(coalesce(y,0.1e0))=='double' ), z SCALAR CONSTRAINT three CHECK( typeof(coalesce(z,''))=='string' ) ); ]], { diff --git a/test/sql-tap/decimal.test.lua b/test/sql-tap/decimal.test.lua index d422533d6..a6d66b75b 100755 --- a/test/sql-tap/decimal.test.lua +++ b/test/sql-tap/decimal.test.lua @@ -3,7 +3,7 @@ local build_path = os.getenv("BUILDDIR") package.cpath = build_path..'/test/sql-tap/?.so;'..build_path..'/test/sql-tap/?.dylib;'..package.cpath local test = require("sqltester") -test:plan(104) +test:plan(109) local dec = require("decimal") local dec1 = dec.new("111") @@ -684,7 +684,7 @@ test:do_catchsql_test( test:do_catchsql_test( "dec-11.2.4", [[ - INSERT INTO tsu VALUES ('4_double', 1.5); + INSERT INTO tsu VALUES ('4_double', 1.5e0); ]], { 1, "Type mismatch: can not convert double(1.5) to uuid" }) @@ -819,7 +819,7 @@ test:do_execsql_test( test:do_execsql_test( "dec-14.1.3", [[ - SELECT u - 0.5 FROM t2; + SELECT u - 0.5e0 FROM t2; ]], { 110.5, 3332.5, 55554.5 }) @@ -835,7 +835,7 @@ test:do_execsql_test( test:do_execsql_test( "dec-14.1.5", [[ - SELECT u / 1.0 FROM t2; + SELECT u / 1e0 FROM t2; ]], { 111, 3333, 55555 }) @@ -972,4 +972,50 @@ test:execsql([[ DROP TABLE t1; ]]) +-- +-- gh-6356: Make sure that numeric literals with a decimal point and no exponent +-- are treated as DECIMAL. +-- +test:do_execsql_test( + "dec-17.1", + [[ + SELECT 1.0, typeof(1.0); + ]], { + dec.new(1), 'decimal' + }) + +test:do_test( + "dec-17.2", + function() + return box.execute([[SELECT 1.0;]]).metadata + end, { + {name = "COLUMN_1", type = "decimal"} + }) + +test:do_execsql_test( + "dec-17.3", + [[ + SELECT typeof(1), typeof(1e0), typeof(1.0); + ]], { + "integer", "double", "decimal" + }) + +test:do_execsql_test( + "dec-17.4", + [[ + SELECT 999999999999999999999999999999999999.9; + ]], { + dec.new('999999999999999999999999999999999999.9') + }) + +-- Make sure that large number without a decimal point is not parsed as DECIMAL. +test:do_catchsql_test( + "dec-17.5", + [[ + SELECT 999999999999999999999999999999999999; + ]], { + 1, [[Integer literal 999999999999999999999999999999999999 exceeds ]].. + "the supported range [-9223372036854775808, 18446744073709551615]" + }) + test:finish_test() diff --git a/test/sql-tap/default.test.lua b/test/sql-tap/default.test.lua index 9c15220eb..da911c61b 100755 --- a/test/sql-tap/default.test.lua +++ b/test/sql-tap/default.test.lua @@ -105,11 +105,11 @@ test:do_execsql_test( b INT DEFAULT 12345 UNIQUE NOT NULL CHECK( b>=0 AND b<99999 ), c VARCHAR(123) DEFAULT 'hello' NOT NULL, d NUMBER, - e NUMBER DEFAULT 4.36, + e NUMBER DEFAULT 4.36e0, f VARCHAR(15), --COLLATE RTRIM, g INTEGER DEFAULT( 3600*12 ) ); - INSERT INTO t3 VALUES(null, 5, 'row1', 5.25, 8.67, '321', 432); + INSERT INTO t3 VALUES(null, 5, 'row1', 5.25e0, 8.67e0, '321', 432); SELECT a, typeof(a), b, typeof(b), c, typeof(c), d, typeof(d), e, typeof(e), f, typeof(f), g, typeof(g) FROM t3; diff --git a/test/sql-tap/e_select1.test.lua b/test/sql-tap/e_select1.test.lua index 9f10994ae..f78e2de7d 100755 --- a/test/sql-tap/e_select1.test.lua +++ b/test/sql-tap/e_select1.test.lua @@ -327,7 +327,7 @@ test:do_execsql_test( "e_select-1.4.0", [[ CREATE TABLE x1(id INT primary key, a TEXT , b TEXT ); - CREATE TABLE x2(id INT primary key, c NUMBER , d NUMBER , e NUMBER ); + CREATE TABLE x2(id INT primary key, c DOUBLE, d DOUBLE, e DOUBLE); CREATE TABLE x3(id INT primary key, f TEXT , g TEXT , h TEXT , i TEXT ); -- x1: 3 rows, 2 columns @@ -1482,8 +1482,8 @@ test:drop_all_tables() test:do_execsql_test( "e_select-7.4.0", [[ - CREATE TABLE q1(id INT primary key, a TEXT, b NUMBER, c NUMBER); - CREATE TABLE q2(id INT primary key, d TEXT, e NUMBER); + CREATE TABLE q1(id INT primary key, a TEXT, b DOUBLE, c DOUBLE); + CREATE TABLE q2(id INT primary key, d TEXT, e DOUBLE); CREATE TABLE q3(id INT primary key, f TEXT, g INT); INSERT INTO q1 VALUES(1, '16', -87.66, NULL); @@ -1632,7 +1632,7 @@ test:drop_all_tables() test:do_execsql_test( "e_select-7.10.0", [[ - CREATE TABLE w1(a TEXT PRIMARY KEY, b NUMBER); + CREATE TABLE w1(a TEXT PRIMARY KEY, b DOUBLE); CREATE TABLE w2(a INT PRIMARY KEY, b TEXT); INSERT INTO w1 VALUES('1', 4.1); @@ -1908,7 +1908,7 @@ test:do_select_tests( test:do_execsql_test( "e_select-8.8.0", [[ - CREATE TABLE d3(id INT primary key, a NUMBER); + CREATE TABLE d3(id INT primary key, a DOUBLE); INSERT INTO d3 VALUES(1, 0); INSERT INTO d3 VALUES(2, 14.1); INSERT INTO d3 VALUES(3, 13); @@ -2193,7 +2193,7 @@ for _, val in ipairs({ {"1", "SELECT b FROM f1 ORDER BY a LIMIT 'hello' "}, {"2", "SELECT b FROM f1 ORDER BY a LIMIT NULL "}, {"3", "SELECT b FROM f1 ORDER BY a LIMIT X'ABCD' "}, - {"4", "SELECT b FROM f1 ORDER BY a LIMIT 5.1 "}, + {"4", "SELECT b FROM f1 ORDER BY a LIMIT 5.1e0 "}, {"5", "SELECT b FROM f1 ORDER BY a LIMIT (SELECT group_concat(b) FROM f1)"}}) do local tn = val[1] local select = val[2] @@ -2248,7 +2248,7 @@ for _, val in ipairs({ {1, "SELECT b FROM f1 ORDER BY a LIMIT 2 OFFSET 'hello'"}, {2, "SELECT b FROM f1 ORDER BY a LIMIT 2 OFFSET NULL"}, {3, "SELECT b FROM f1 ORDER BY a LIMIT 2 OFFSET X'ABCD'"}, - {4, "SELECT b FROM f1 ORDER BY a LIMIT 2 OFFSET 5.1"}, + {4, "SELECT b FROM f1 ORDER BY a LIMIT 2 OFFSET 51e-1"}, {5, "SELECT b FROM f1 ORDER BY a LIMIT 2 OFFSET (SELECT group_concat(b) FROM f1)"}}) do local tn = val[1] local select = val[2] diff --git a/test/sql-tap/func.test.lua b/test/sql-tap/func.test.lua index 416f27d69..29e1c3de2 100755 --- a/test/sql-tap/func.test.lua +++ b/test/sql-tap/func.test.lua @@ -678,7 +678,7 @@ test:do_execsql_test( test:do_execsql_test( "func-4.35", [[ - SELECT round(1234567890123.445,2); + SELECT round(1234567890123.445e0,2); ]], { -- 1234567890123.45 @@ -708,7 +708,7 @@ test:do_execsql_test( test:do_execsql_test( "func-4.38", [[ - SELECT round(9999999999999.556,2); + SELECT round(9999999999999.556e0, 2); ]], { -- 9999999999999.56 @@ -1497,7 +1497,7 @@ test:do_execsql_test( "func-18.12", [[ INSERT INTO t6 VALUES(3, 1<<62); - SELECT sum(x) - ((1<<62)*2.0+1) from t6; + SELECT sum(x) - ((1 << 62) * 2e0 + 1) from t6; ]], { -- 0 @@ -2817,7 +2817,7 @@ test:do_execsql_test("func-77.1", "SELECT TOSTRING('1');", {'1'}) test:do_execsql_test("func-77.2", "SELECT TOSTRING('a');", {'a'}) test:do_catchsql_test("func-77.3", "SELECT TOSTRING(1);", {1, "Function 'TOSTRING' returned value of invalid type: expected string got unsigned"}) test:do_catchsql_test("func-77.4", "SELECT TOSTRING(-1);", {1, "Function 'TOSTRING' returned value of invalid type: expected string got integer"}) -test:do_catchsql_test("func-77.5", "SELECT TOSTRING(-1.1);", {1, "Function 'TOSTRING' returned value of invalid type: expected string got double"}) +test:do_catchsql_test("func-77.5", "SELECT TOSTRING(-1.1e0);", {1, "Function 'TOSTRING' returned value of invalid type: expected string got double"}) test:do_catchsql_test("func-77.6", "SELECT TOSTRING(TRUE);", {1, "Function 'TOSTRING' returned value of invalid type: expected string got boolean"}) test:do_execsql_test("func-77.7", "SELECT TOSTRING(NULL);", {""}) test:do_execsql_test("func-77.8", "SELECT TOSTRING(LUA('return nil'));", {""}) @@ -2837,7 +2837,7 @@ test:do_catchsql_test("func-78.1", "SELECT TOUNSIGNED('1');", {1, "Function 'TOU test:do_catchsql_test("func-78.2", "SELECT TOUNSIGNED('a');", {1, "Function 'TOUNSIGNED' returned value of invalid type: expected unsigned got string"}) test:do_execsql_test("func-78.3", "SELECT TOUNSIGNED(1);", {1}) test:do_catchsql_test("func-78.4", "SELECT TOUNSIGNED(-1);", {1, "Function 'TOUNSIGNED' returned value of invalid type: expected unsigned got integer"}) -test:do_catchsql_test("func-78.5", "SELECT TOUNSIGNED(-1.1);", {1, "Function 'TOUNSIGNED' returned value of invalid type: expected unsigned got double"}) +test:do_catchsql_test("func-78.5", "SELECT TOUNSIGNED(-1.1e0);", {1, "Function 'TOUNSIGNED' returned value of invalid type: expected unsigned got double"}) test:do_catchsql_test("func-78.6", "SELECT TOUNSIGNED(TRUE);", {1, "Function 'TOUNSIGNED' returned value of invalid type: expected unsigned got boolean"}) test:do_execsql_test("func-78.7", "SELECT TOUNSIGNED(NULL);", {""}) test:do_execsql_test("func-78.8", "SELECT TOUNSIGNED(LUA('return nil'));", {""}) @@ -2857,7 +2857,7 @@ test:do_catchsql_test("func-79.1", "SELECT TOINTEGER('1');", {1, "Function 'TOIN test:do_catchsql_test("func-79.2", "SELECT TOINTEGER('a');", {1, "Function 'TOINTEGER' returned value of invalid type: expected integer got string"}) test:do_execsql_test("func-79.3", "SELECT TOINTEGER(1);", {1}) test:do_execsql_test("func-79.4", "SELECT TOINTEGER(-1);", {-1}) -test:do_catchsql_test("func-79.5", "SELECT TOINTEGER(-1.1);", {1, "Function 'TOINTEGER' returned value of invalid type: expected integer got double"}) +test:do_catchsql_test("func-79.5", "SELECT TOINTEGER(-1.1e0);", {1, "Function 'TOINTEGER' returned value of invalid type: expected integer got double"}) test:do_catchsql_test("func-79.6", "SELECT TOINTEGER(TRUE);", {1, "Function 'TOINTEGER' returned value of invalid type: expected integer got boolean"}) test:do_execsql_test("func-79.7", "SELECT TOINTEGER(NULL);", {""}) test:do_execsql_test("func-79.8", "SELECT TOINTEGER(LUA('return nil'));", {""}) @@ -2877,7 +2877,7 @@ test:do_catchsql_test("func-80.1", "SELECT TONUMBER('1');", {1, "Function 'TONUM test:do_catchsql_test("func-80.2", "SELECT TONUMBER('a');", {1, "Function 'TONUMBER' returned value of invalid type: expected number got string"}) test:do_execsql_test("func-80.3", "SELECT TONUMBER(1);", {1}) test:do_execsql_test("func-80.4", "SELECT TONUMBER(-1);", {-1}) -test:do_execsql_test("func-80.5", "SELECT TONUMBER(-1.1);", {-1.1}) +test:do_execsql_test("func-80.5", "SELECT TONUMBER(-1.1e0);", {-1.1}) test:do_catchsql_test("func-80.6", "SELECT TONUMBER(TRUE);", {1, "Function 'TONUMBER' returned value of invalid type: expected number got boolean"}) test:do_execsql_test("func-80.7", "SELECT TONUMBER(NULL);", {""}) test:do_execsql_test("func-80.8", "SELECT TONUMBER(LUA('return nil'));", {""}) @@ -2897,7 +2897,7 @@ test:do_catchsql_test("func-81.1", "SELECT TOBOOLEAN('1');", {1, "Function 'TOBO test:do_catchsql_test("func-81.2", "SELECT TOBOOLEAN('a');", {1, "Function 'TOBOOLEAN' returned value of invalid type: expected boolean got string"}) test:do_catchsql_test("func-81.3", "SELECT TOBOOLEAN(1);", {1, "Function 'TOBOOLEAN' returned value of invalid type: expected boolean got unsigned"}) test:do_catchsql_test("func-81.4", "SELECT TOBOOLEAN(-1);", {1, "Function 'TOBOOLEAN' returned value of invalid type: expected boolean got integer"}) -test:do_catchsql_test("func-81.5", "SELECT TOBOOLEAN(-1.1);", {1, "Function 'TOBOOLEAN' returned value of invalid type: expected boolean got double"}) +test:do_catchsql_test("func-81.5", "SELECT TOBOOLEAN(-1.1e0);", {1, "Function 'TOBOOLEAN' returned value of invalid type: expected boolean got double"}) test:do_execsql_test("func-81.6", "SELECT TOBOOLEAN(TRUE);", {true}) test:do_execsql_test("func-81.7", "SELECT TOBOOLEAN(NULL);", {""}) test:do_execsql_test("func-81.8", "SELECT TOBOOLEAN(LUA('return nil'));", {""}) @@ -2917,7 +2917,7 @@ test:do_execsql_test("func-82.1", "SELECT TOSCALAR('1');", {'1'}) test:do_execsql_test("func-82.2", "SELECT TOSCALAR('a');", {'a'}) test:do_execsql_test("func-82.3", "SELECT TOSCALAR(1);", {1}) test:do_execsql_test("func-82.4", "SELECT TOSCALAR(-1);", {-1}) -test:do_execsql_test("func-82.5", "SELECT TOSCALAR(-1.1);", {-1.1}) +test:do_execsql_test("func-82.5", "SELECT TOSCALAR(-1.1e0);", {-1.1}) test:do_execsql_test("func-82.6", "SELECT TOSCALAR(TRUE);", {true}) test:do_execsql_test("func-82.7", "SELECT TOSCALAR(NULL);", {""}) test:do_execsql_test("func-82.8", "SELECT TOSCALAR(LUA('return nil'));", {""}) diff --git a/test/sql-tap/func3.test.lua b/test/sql-tap/func3.test.lua index 7f1d8d33c..8d6268bb7 100755 --- a/test/sql-tap/func3.test.lua +++ b/test/sql-tap/func3.test.lua @@ -28,7 +28,7 @@ test:plan(35) test:do_execsql_test( "func3-5.1", [[ - SELECT likelihood(9223372036854775807, 0.5); + SELECT likelihood(9223372036854775807, 0.5e0); ]], { -- 9223372036854775807LL @@ -38,7 +38,7 @@ test:do_execsql_test( test:do_execsql_test( "func3-5.2", [[ - SELECT likelihood(-9223372036854775808, 0.5); + SELECT likelihood(-9223372036854775808, 0.5e0); ]], { -- -9223372036854775808LL @@ -48,7 +48,7 @@ test:do_execsql_test( test:do_execsql_test( "func3-5.3", [[ - SELECT likelihood(14.125, 0.5); + SELECT likelihood(14.125e0, 0.5e0); ]], { -- 14.125 @@ -58,7 +58,7 @@ test:do_execsql_test( test:do_execsql_test( "func3-5.4", [[ - SELECT likelihood(NULL, 0.5); + SELECT likelihood(NULL, 0.5e0); ]], { -- "" @@ -68,7 +68,7 @@ test:do_execsql_test( test:do_execsql_test( "func3-5.5", [[ - SELECT likelihood('test-string', 0.5); + SELECT likelihood('test-string', 0.5e0); ]], { -- "test-string" @@ -78,7 +78,7 @@ test:do_execsql_test( test:do_execsql_test( "func3-5.6", [[ - SELECT quote(likelihood(x'010203000405', 0.5)); + SELECT quote(likelihood(x'010203000405', 0.5e0)); ]], { -- "X'010203000405'" @@ -91,7 +91,7 @@ test:do_execsql_test( test:do_execsql_test( "func3-5.7", [[ - SELECT likelihood(123, 1.0), likelihood(456, 0.0); + SELECT likelihood(123, 1e0), likelihood(456, 0e0); ]], { -- 123, 456 @@ -101,7 +101,7 @@ test:do_execsql_test( test:do_catchsql_test( "func3-5.8", [[ - SELECT likelihood(123, 1.000001); + SELECT likelihood(123, 1.000001e0); ]], { -- 1, "Illegal parameters, second argument to likelihood() must be a constant between 0.0 and 1.0" @@ -111,7 +111,7 @@ test:do_catchsql_test( test:do_catchsql_test( "func3-5.9", [[ - SELECT likelihood(123, -0.000001); + SELECT likelihood(123, -0.000001e0); ]], { -- 1, "Illegal parameters, second argument to likelihood() must be a constant between 0.0 and 1.0" @@ -121,7 +121,7 @@ test:do_catchsql_test( test:do_catchsql_test( "func3-5.10", [[ - SELECT likelihood(123, 0.5+0.3); + SELECT likelihood(123, 0.5e0 + 0.3e0); ]], { -- 1, "Illegal parameters, second argument to likelihood() must be a constant between 0.0 and 1.0" @@ -135,7 +135,7 @@ test:do_catchsql_test( test:do_test( "func3-5.20", function() - return test:execsql "EXPLAIN SELECT likelihood(LEAST(1.0+'2.0',4*11), 0.5)" + return test:execsql "EXPLAIN SELECT likelihood(LEAST(1.0+'2.0',4*11), 0.5e0)" end, test:execsql("EXPLAIN SELECT LEAST(1.0+'2.0',4*11)")) -- EVIDENCE-OF: R-11152-23456 The unlikely(X) function returns the @@ -164,7 +164,7 @@ test:do_execsql_test( test:do_execsql_test( "func3-5.32", [[ - SELECT unlikely(14.125); + SELECT unlikely(14.125e0); ]], { -- 14.125 @@ -237,7 +237,7 @@ test:do_execsql_test( test:do_execsql_test( "func3-5.52", [[ - SELECT likely(14.125); + SELECT likely(14.125e0); ]], { -- 14.125 diff --git a/test/sql-tap/gh-5364-define-bit-wise-rules.test.lua b/test/sql-tap/gh-5364-define-bit-wise-rules.test.lua index 37bf62487..2a6a60a81 100755 --- a/test/sql-tap/gh-5364-define-bit-wise-rules.test.lua +++ b/test/sql-tap/gh-5364-define-bit-wise-rules.test.lua @@ -25,7 +25,7 @@ test:do_catchsql_test( test:do_catchsql_test( "gh-5364-1.3", [[ - SELECT 9 >> 2.0; + SELECT 9 >> 2e0; ]], { 1, "Type mismatch: can not convert double(2.0) to unsigned" }) @@ -82,7 +82,7 @@ test:do_catchsql_test( test:do_catchsql_test( "gh-5364-2.3", [[ - SELECT 9 << 2.0; + SELECT 9 << 2e0; ]], { 1, "Type mismatch: can not convert double(2.0) to unsigned" }) @@ -139,7 +139,7 @@ test:do_catchsql_test( test:do_catchsql_test( "gh-5364-3.3", [[ - SELECT 9 & 2.0; + SELECT 9 & 2e0; ]], { 1, "Type mismatch: can not convert double(2.0) to unsigned" }) @@ -196,7 +196,7 @@ test:do_catchsql_test( test:do_catchsql_test( "gh-5364-4.3", [[ - SELECT 9 | 2.0; + SELECT 9 | 2e0; ]], { 1, "Type mismatch: can not convert double(2.0) to unsigned" }) diff --git a/test/sql-tap/gh-5756-implicit-cast-in-arithmetic.test.lua b/test/sql-tap/gh-5756-implicit-cast-in-arithmetic.test.lua index 390a2d9b2..bf636a261 100755 --- a/test/sql-tap/gh-5756-implicit-cast-in-arithmetic.test.lua +++ b/test/sql-tap/gh-5756-implicit-cast-in-arithmetic.test.lua @@ -25,7 +25,7 @@ test:do_execsql_test( test:do_execsql_test( "gh-5756-1.3", [[ - SELECT 9 + 2.0; + SELECT 9 + 2e0; ]], { 11 }) @@ -82,7 +82,7 @@ test:do_execsql_test( test:do_execsql_test( "gh-5756-2.3", [[ - SELECT 9 - 2.0; + SELECT 9 - 2e0; ]], { 7 }) @@ -139,7 +139,7 @@ test:do_execsql_test( test:do_execsql_test( "gh-5756-3.3", [[ - SELECT 9 * 2.0; + SELECT 9 * 2e0; ]], { 18 }) @@ -196,7 +196,7 @@ test:do_execsql_test( test:do_execsql_test( "gh-5756-4.3", [[ - SELECT 9 / 2.0; + SELECT 9 / 2e0; ]], { 4.5 }) @@ -253,7 +253,7 @@ test:do_execsql_test( test:do_catchsql_test( "gh-5756-5.3", [[ - SELECT 9 % 2.0; + SELECT 9 % 2e0; ]], { 1, "Type mismatch: can not convert double(2.0) to integer" }) diff --git a/test/sql-tap/gh-6239-quote-with-double-arg.test.lua b/test/sql-tap/gh-6239-quote-with-double-arg.test.lua index dab12253e..2642d799b 100755 --- a/test/sql-tap/gh-6239-quote-with-double-arg.test.lua +++ b/test/sql-tap/gh-6239-quote-with-double-arg.test.lua @@ -6,7 +6,7 @@ test:plan(1) test:do_execsql_test( "gh-6239", [[ - SELECT QUOTE(1.5), TYPEOF(QUOTE(1.5)); + SELECT QUOTE(1.5e0), TYPEOF(QUOTE(1.5e0)); ]], { 1.5, "double" }) diff --git a/test/sql-tap/index1.test.lua b/test/sql-tap/index1.test.lua index 3230556d1..3879481df 100755 --- a/test/sql-tap/index1.test.lua +++ b/test/sql-tap/index1.test.lua @@ -598,7 +598,7 @@ end test:do_execsql_test( "index-12.1", [[ - CREATE TABLE t4(id INT primary key, a NUMBER,b INT ); + CREATE TABLE t4(id INT primary key, a DOUBLE, b INT ); INSERT INTO t4 VALUES(1, 0.0, 1); INSERT INTO t4 VALUES(2, 0.00, 2); INSERT INTO t4 VALUES(4, -1.0, 4); diff --git a/test/sql-tap/insert3.test.lua b/test/sql-tap/insert3.test.lua index 062fb1e33..3547122f0 100755 --- a/test/sql-tap/insert3.test.lua +++ b/test/sql-tap/insert3.test.lua @@ -236,7 +236,8 @@ test:do_execsql_test( test:do_execsql_test( "insert3-3.7", [[ - CREATE TABLE t6(id INTEGER PRIMARY KEY AUTOINCREMENT, x INT ,y NUMBER DEFAULT 4.3, z TEXT DEFAULT 'hi'); + CREATE TABLE t6(id INTEGER PRIMARY KEY AUTOINCREMENT, x INT, + y DOUBLE DEFAULT 4.3, z TEXT DEFAULT 'hi'); INSERT INTO t6 DEFAULT VALUES; SELECT * FROM t6; ]], { diff --git a/test/sql-tap/lua_sql.test.lua b/test/sql-tap/lua_sql.test.lua index 993417414..d2dd6b679 100755 --- a/test/sql-tap/lua_sql.test.lua +++ b/test/sql-tap/lua_sql.test.lua @@ -39,8 +39,8 @@ test:do_catchsql_test( for _, val in ipairs({ {1, "'val'", "val"}, {2, 1, 1}, - {3, "1.0", 1}, - {4, 1.5, 1.5}, + {3, "1.0e0", 1}, + {4, 1.5, require('decimal').new(1.5)}, }) do local tn = val[1] local param = val[2] diff --git a/test/sql-tap/metatypes.test.lua b/test/sql-tap/metatypes.test.lua index 3e4091675..dfa5bbab4 100755 --- a/test/sql-tap/metatypes.test.lua +++ b/test/sql-tap/metatypes.test.lua @@ -14,7 +14,7 @@ test:do_execsql_test( "metatypes-1.1", [[ INSERT INTO t VALUES(1, 1, 1); - INSERT INTO t VALUES(2, 2.0, 2.0); + INSERT INTO t VALUES(2, 2e0, 2e0); INSERT INTO t(i, s) VALUES(3, '3'); INSERT INTO t(i, s) VALUES(4, true); INSERT INTO t(i, s) VALUES(5, x'35'); diff --git a/test/sql-tap/misc5.test.lua b/test/sql-tap/misc5.test.lua index 38eddfc64..159bccd8f 100755 --- a/test/sql-tap/misc5.test.lua +++ b/test/sql-tap/misc5.test.lua @@ -217,7 +217,7 @@ test:do_execsql_test( test:do_execsql_test( "misc5-5.1", [[ - SELECT .1 + SELECT 0.1e0 ]], { -- 0.1 @@ -227,7 +227,7 @@ test:do_execsql_test( test:do_execsql_test( "misc5-5.2", [[ - SELECT 2. + SELECT 2e0 ]], { -- 2.0 diff --git a/test/sql-tap/numcast.test.lua b/test/sql-tap/numcast.test.lua index 763708d76..62ea9e695 100755 --- a/test/sql-tap/numcast.test.lua +++ b/test/sql-tap/numcast.test.lua @@ -2,6 +2,8 @@ local test = require("sqltester") test:plan(26) +local dec = require('decimal') + --!./tcltestrunner.lua -- 2013 March 20 -- @@ -33,11 +35,11 @@ for _, enc in ipairs({"utf8"}) do return x end, enc) local data = { - {"1", "12345.0", 12345.0, 12345}, + {"1", "12345.0", dec.new(12345.0), 12345}, {"2", "12345.0e0", 12345.0, 12345}, {"3", "-12345.0e0", -12345.0, -12345}, - {"4", "-12345.25", -12345.25, -12345}, - {"5", "-12345.0", -12345.0, -12345}, + {"4", "-12345.25", dec.new(-12345.25), -12345}, + {"5", "-12345.0", dec.new(-12345.0), -12345}, } for _, val in ipairs(data) do local idx = val[1] @@ -71,7 +73,7 @@ end test:do_execsql_test( "cast-2.1", [[ - SELECT CAST((9223372036854775297.01) AS INTEGER); + SELECT CAST((9223372036854775297.01e0) AS INTEGER); ]], { 9223372036854775808ULL }) @@ -79,7 +81,7 @@ test:do_execsql_test( test:do_execsql_test( "cast-2.2", [[ - SELECT CAST((18000000000000000000.) AS INTEGER); + SELECT CAST((18000000000000000000e0) AS INTEGER); ]], { 18000000000000000000ULL }) @@ -87,7 +89,7 @@ test:do_execsql_test( test:do_execsql_test( "cast-2.3", [[ - SELECT CAST((9223372036854775297.01) AS UNSIGNED); + SELECT CAST((9223372036854775297.01e0) AS UNSIGNED); ]], { 9223372036854775808ULL }) @@ -95,7 +97,7 @@ test:do_execsql_test( test:do_execsql_test( "cast-2.4", [[ - SELECT CAST((18000000000000000000.) AS UNSIGNED); + SELECT CAST((18000000000000000000e0) AS UNSIGNED); ]], { 18000000000000000000ULL }) @@ -103,7 +105,7 @@ test:do_execsql_test( test:do_catchsql_test( "cast-2.5", [[ - SELECT CAST((20000000000000000000.) AS UNSIGNED); + SELECT CAST((20000000000000000000e0) AS UNSIGNED); ]], { 1,"Type mismatch: can not convert double(2.0e+19) to unsigned" }) @@ -112,7 +114,7 @@ test:do_execsql_test( "cast-2.6", [[ CREATE TABLE t (i INTEGER PRIMARY KEY); - INSERT INTO t VALUES(9223372036854775297.01); + INSERT INTO t VALUES(9223372036854775297.01e0); SELECT * FROM t; ]], { 9223372036854775808ULL @@ -121,7 +123,7 @@ test:do_execsql_test( test:do_execsql_test( "cast-2.7", [[ - INSERT INTO t VALUES(18000000000000000000.01); + INSERT INTO t VALUES(18000000000000000000.01e0); SELECT * FROM t; ]], { 9223372036854775808ULL,18000000000000000000ULL @@ -130,7 +132,7 @@ test:do_execsql_test( test:do_catchsql_test( "cast-2.8", [[ - INSERT INTO t VALUES(20000000000000000000.01); + INSERT INTO t VALUES(20000000000000000000.01e0); SELECT * FROM t; ]], { 1,"Type mismatch: can not convert double(2.0e+19) to integer" @@ -139,7 +141,7 @@ test:do_catchsql_test( test:do_catchsql_test( "cast-2.9", [[ - INSERT INTO t VALUES(2.1); + INSERT INTO t VALUES(2.1e0); ]], { 1, "Type mismatch: can not convert double(2.1) to integer" }) @@ -147,7 +149,7 @@ test:do_catchsql_test( test:do_execsql_test( "numcast-3.8", [[ - SELECT (1 + 0) / 3, (1 + 0.) / 3, (1 + 0) / 3.; + SELECT (1 + 0) / 3, (1 + 0e0) / 3, (1 + 0) / 3e0; ]], { 0, 0.33333333333333, 0.33333333333333 }) @@ -155,7 +157,7 @@ test:do_execsql_test( test:do_execsql_test( "numcast-3.9", [[ - SELECT (1 - 0) / 3, (1 - 0.) / 3, (1 - 0) / 3.; + SELECT (1 - 0) / 3, (1 - 0e0) / 3, (1 - 0) / 3e0; ]], { 0, 0.33333333333333, 0.33333333333333 }) @@ -163,7 +165,7 @@ test:do_execsql_test( test:do_execsql_test( "numcast-3.10", [[ - SELECT (1 * 1) / 3, (1 * 1.) / 3, (1 * 1) / 3.; + SELECT (1 * 1) / 3, (1 * 1e0) / 3, (1 * 1) / 3e0; ]], { 0, 0.33333333333333, 0.33333333333333 }) @@ -171,7 +173,7 @@ test:do_execsql_test( test:do_execsql_test( "numcast-3.11", [[ - SELECT (1 / 1) / 3, (1 / 1.) / 3, (1 / 1) / 3.; + SELECT (1 / 1) / 3, (1 / 1e0) / 3, (1 / 1) / 3e0; ]], { 0 , 0.33333333333333, 0.33333333333333 }) @@ -183,7 +185,7 @@ test:do_execsql_test( test:do_catchsql_test( "numcast-4", [[ - SELECT CAST(-2.5 AS UNSIGNED); + SELECT CAST(-2.5e0 AS UNSIGNED); ]], { 1, "Type mismatch: can not convert double(-2.5) to unsigned" }) @@ -195,7 +197,7 @@ test:do_catchsql_test( test:do_execsql_test( "numcast-5", [[ - SELECT CAST(-0.999 AS INTEGER), CAST(-0.111 AS UNSIGNED); + SELECT CAST(-0.999e0 AS INTEGER), CAST(-0.111e0 AS UNSIGNED); ]], { 0, 0 }) diff --git a/test/sql-tap/select1.test.lua b/test/sql-tap/select1.test.lua index e89c7d2f8..8164b8219 100755 --- a/test/sql-tap/select1.test.lua +++ b/test/sql-tap/select1.test.lua @@ -1157,7 +1157,7 @@ test:do_test( function() set_full_column_names(true) return test:execsql2 [[ - SELECT 123.45; + SELECT 123.45e0; ]] end, { -- @@ -1481,7 +1481,7 @@ test:do_catchsql_test( test:do_catchsql_test( "select1-8.1", [[ - SELECT f1 FROM test1 WHERE 4.3+2.4 OR 1 ORDER BY f1 + SELECT f1 FROM test1 WHERE 4.3e0+2.4e0 OR 1 ORDER BY f1 ]], { -- 1, 'Type mismatch: can not convert double(6.7) to boolean' diff --git a/test/sql-tap/select4.test.lua b/test/sql-tap/select4.test.lua index 465800940..384641e08 100755 --- a/test/sql-tap/select4.test.lua +++ b/test/sql-tap/select4.test.lua @@ -759,7 +759,7 @@ test:do_test( "select4-8.1", function() test:execsql [[ - CREATE TABLE t3(a text primary key, b NUMBER, c text); + CREATE TABLE t3(a text primary key, b DOUBLE, c text); START TRANSACTION; INSERT INTO t3 VALUES('1', 1.1, '1.1'); INSERT INTO t3 VALUES('2', 1.10, '1.10'); diff --git a/test/sql-tap/selectB.test.lua b/test/sql-tap/selectB.test.lua index 88f108f57..f5bd75cb8 100755 --- a/test/sql-tap/selectB.test.lua +++ b/test/sql-tap/selectB.test.lua @@ -443,7 +443,7 @@ for ii = 3, 6, 1 do SELECT x, y FROM ( SELECT a AS x, b AS y FROM t1 UNION ALL - SELECT a*10 + 0.1, f*10 + 0.1 FROM t1 JOIN t2 ON (c=d) + SELECT a*10 + 0.1e0, f*10 + 0.1e0 FROM t1 JOIN t2 ON (c=d) UNION ALL SELECT a*100, b*100 FROM t1 ) ORDER BY 1; @@ -457,7 +457,7 @@ for ii = 3, 6, 1 do SELECT x, y FROM ( SELECT a AS x, b AS y FROM t1 UNION ALL - SELECT a*10 + 0.1, f*10 + 0.1 FROM t1 LEFT JOIN t2 ON (c=d) + SELECT a*10 + 0.1e0, f*10 + 0.1e0 FROM t1 LEFT JOIN t2 ON (c=d) UNION ALL SELECT a*100, b*100 FROM t1 ) ORDER BY 1; @@ -471,7 +471,7 @@ for ii = 3, 6, 1 do SELECT x+y FROM ( SELECT a AS x, b AS y FROM t1 UNION ALL - SELECT a*10 + 0.1, f*10 + 0.1 FROM t1 LEFT JOIN t2 ON (c=d) + SELECT a*10 + 0.1e0, f*10 + 0.1e0 FROM t1 LEFT JOIN t2 ON (c=d) UNION ALL SELECT a*100, b*100 FROM t1 ) WHERE y+x IS NOT NULL ORDER BY 1; diff --git a/test/sql-tap/sort.test.lua b/test/sql-tap/sort.test.lua index 68a0ecbd2..d3f32bfb6 100755 --- a/test/sql-tap/sort.test.lua +++ b/test/sql-tap/sort.test.lua @@ -632,7 +632,7 @@ test:do_execsql_test( test:do_execsql_test( "sort-8.1", [[ - CREATE TABLE t5(a NUMBER, b text PRIMARY KEY); + CREATE TABLE t5(a DOUBLE, b text PRIMARY KEY); INSERT INTO t5 VALUES(100,'A1'); INSERT INTO t5 VALUES(100.0,'A2'); SELECT * FROM t5 ORDER BY a, b; diff --git a/test/sql-tap/tkt-9a8b09f8e6.test.lua b/test/sql-tap/tkt-9a8b09f8e6.test.lua index cc321c2f6..983c8df2a 100755 --- a/test/sql-tap/tkt-9a8b09f8e6.test.lua +++ b/test/sql-tap/tkt-9a8b09f8e6.test.lua @@ -46,7 +46,7 @@ test:do_execsql_test( test:do_execsql_test( 1.3, [[ - CREATE TABLE t3(x NUMBER primary key); + CREATE TABLE t3(x DOUBLE primary key); INSERT INTO t3 VALUES(1.0); ]], { -- <1.3> @@ -57,7 +57,7 @@ test:do_execsql_test( test:do_execsql_test( 1.4, [[ - CREATE TABLE t4(x NUMBER primary key); + CREATE TABLE t4(x DOUBLE primary key); INSERT INTO t4 VALUES(1.11); ]], { -- <1.4> @@ -92,7 +92,7 @@ test:do_catchsql_test( test:do_catchsql_test( 2.2, [[ - SELECT x FROM t1 WHERE x IN (1.0); + SELECT x FROM t1 WHERE x IN (1e0); ]], { -- <2.2> 1, "Type mismatch: can not convert double(1.0) to string" @@ -132,7 +132,7 @@ test:do_catchsql_test( test:do_catchsql_test( 2.6, [[ - SELECT x FROM t1 WHERE 1.0 IN (x); + SELECT x FROM t1 WHERE 1e0 IN (x); ]], { -- <2.6> 1, "Type mismatch: can not convert double(1.0) to string" @@ -225,7 +225,7 @@ test:do_catchsql_test( SELECT x FROM t3 WHERE x IN ('1'); ]], { -- <4.3> - 1, "Type mismatch: can not convert string('1') to number" + 1, "Type mismatch: can not convert string('1') to double" -- }) @@ -235,7 +235,7 @@ test:do_catchsql_test( SELECT x FROM t3 WHERE x IN ('1.0'); ]], { -- <4.4> - 1, "Type mismatch: can not convert string('1.0') to number" + 1, "Type mismatch: can not convert string('1.0') to double" -- }) @@ -265,7 +265,7 @@ test:do_catchsql_test( SELECT x FROM t3 WHERE '1' IN (x); ]], { -- <4.7> - 1, "Type mismatch: can not convert string('1') to number" + 1, "Type mismatch: can not convert string('1') to double" -- }) @@ -275,7 +275,7 @@ test:do_catchsql_test( SELECT x FROM t3 WHERE '1.0' IN (x); ]], { -- <4.8> - 1, "Type mismatch: can not convert string('1.0') to number" + 1, "Type mismatch: can not convert string('1.0') to double" -- }) @@ -305,7 +305,7 @@ test:do_catchsql_test( SELECT x FROM t4 WHERE x IN ('1'); ]], { -- <5.3> - 1, "Type mismatch: can not convert string('1') to number" + 1, "Type mismatch: can not convert string('1') to double" -- }) @@ -315,7 +315,7 @@ test:do_catchsql_test( SELECT x FROM t4 WHERE x IN ('1.0'); ]], { -- <5.4> - 1, "Type mismatch: can not convert string('1.0') to number" + 1, "Type mismatch: can not convert string('1.0') to double" -- }) @@ -335,7 +335,7 @@ test:do_catchsql_test( SELECT x FROM t4 WHERE x IN ('1.11'); ]], { -- <5.6> - 1, "Type mismatch: can not convert string('1.11') to number" + 1, "Type mismatch: can not convert string('1.11') to double" -- }) @@ -365,7 +365,7 @@ test:do_catchsql_test( SELECT x FROM t4 WHERE '1' IN (x); ]], { -- <5.9> - 1, "Type mismatch: can not convert string('1') to number" + 1, "Type mismatch: can not convert string('1') to double" -- }) @@ -375,7 +375,7 @@ test:do_catchsql_test( SELECT x FROM t4 WHERE '1.0' IN (x); ]], { -- <5.10> - 1, "Type mismatch: can not convert string('1.0') to number" + 1, "Type mismatch: can not convert string('1.0') to double" -- }) @@ -395,7 +395,7 @@ test:do_catchsql_test( SELECT x FROM t4 WHERE '1.11' IN (x); ]], { -- <5.12> - 1, "Type mismatch: can not convert string('1.11') to number" + 1, "Type mismatch: can not convert string('1.11') to double" -- }) diff --git a/test/sql-tap/tkt-a8a0d2996a.test.lua b/test/sql-tap/tkt-a8a0d2996a.test.lua index a40621f41..37dc377a8 100755 --- a/test/sql-tap/tkt-a8a0d2996a.test.lua +++ b/test/sql-tap/tkt-a8a0d2996a.test.lua @@ -125,7 +125,7 @@ test:do_catchsql_test( test:do_execsql_test( 4.0, [[ - SELECT 1+1.; + SELECT 1+1e0; ]], { -- <4.0> 2.0 diff --git a/test/sql-tap/types.test.lua b/test/sql-tap/types.test.lua index 4e98e18b1..b86fb4db3 100755 --- a/test/sql-tap/types.test.lua +++ b/test/sql-tap/types.test.lua @@ -165,7 +165,7 @@ test:do_execsql_test( test:do_execsql_test( "types-2.2.1", [[ - CREATE TABLE t2(id INT primary key, a NUMBER); + CREATE TABLE t2(id INT primary key, a DOUBLE); INSERT INTO t2 VALUES(1, 0.0); INSERT INTO t2 VALUES(2, 12345.678); INSERT INTO t2 VALUES(3, -12345.678); diff --git a/test/sql-tap/uuid.test.lua b/test/sql-tap/uuid.test.lua index fea9d9370..d6c53d123 100755 --- a/test/sql-tap/uuid.test.lua +++ b/test/sql-tap/uuid.test.lua @@ -339,7 +339,7 @@ test:do_catchsql_test( test:do_execsql_test( "uuid-6.1.15", [[ - SELECT LIKELIHOOD(u, 0.5) from t2; + SELECT LIKELIHOOD(u, 0.5e0) from t2; ]], { uuid1, uuid3, uuid2 }) @@ -651,7 +651,7 @@ test:do_catchsql_test( test:do_catchsql_test( "uuid-7.2.4", [[ - SELECT cast(1.5 AS UUID); + SELECT cast(1.5e0 AS UUID); ]], { 1, "Type mismatch: can not convert double(1.5) to uuid" }) @@ -804,7 +804,7 @@ test:do_catchsql_test( test:do_catchsql_test( "uuid-8.2.4", [[ - INSERT INTO tsu VALUES ('4_double', 1.5); + INSERT INTO tsu VALUES ('4_double', 1.5e0); ]], { 1, "Type mismatch: can not convert double(1.5) to uuid" }) @@ -1098,7 +1098,7 @@ test:do_catchsql_test( test:do_catchsql_test( "uuid-13.1.4", [[ - SELECT u > 1.5 FROM t2; + SELECT u > 1.5e0 FROM t2; ]], { 1, "Type mismatch: can not convert double(1.5) to uuid" }) @@ -1162,7 +1162,7 @@ test:do_catchsql_test( test:do_catchsql_test( "uuid-13.2.4", [[ - SELECT u = 1.5 FROM t2; + SELECT u = 1.5e0 FROM t2; ]], { 1, "Type mismatch: can not convert double(1.5) to uuid" }) diff --git a/test/sql-tap/whereA.test.lua b/test/sql-tap/whereA.test.lua index 58e5d3e0b..2c424454d 100755 --- a/test/sql-tap/whereA.test.lua +++ b/test/sql-tap/whereA.test.lua @@ -23,7 +23,7 @@ test:do_test( "whereA-1.1", function() return test:execsql [[ - CREATE TABLE t1(a INTEGER PRIMARY KEY, b NUMBER UNIQUE, c TEXT); + CREATE TABLE t1(a INTEGER PRIMARY KEY, b DOUBLE UNIQUE, c TEXT); INSERT INTO t1 VALUES(1,2,'3'); INSERT INTO t1 values(2,55,'world'); INSERT INTO t1 VALUES(3,4.53,NULL); diff --git a/test/sql-tap/whereG.test.lua b/test/sql-tap/whereG.test.lua index 49501a4a5..8d91b7978 100755 --- a/test/sql-tap/whereG.test.lua +++ b/test/sql-tap/whereG.test.lua @@ -103,7 +103,7 @@ test:do_eqp_test( [[ SELECT DISTINCT aname FROM album, composer, track - WHERE likelihood(cname LIKE '%bach%', 0.5) + WHERE likelihood(cname LIKE '%bach%', 0.5e0) AND composer.cid=track.cid AND album.aid=track.aid; ]], { @@ -117,7 +117,7 @@ test:do_execsql_test( [[ SELECT DISTINCT aname FROM album, composer, track - WHERE likelihood(cname LIKE '%bach%' COLLATE "unicode_ci", 0.5) + WHERE likelihood(cname LIKE '%bach%' COLLATE "unicode_ci", 0.5e0) AND composer.cid=track.cid AND album.aid=track.aid; ]], { @@ -187,7 +187,7 @@ test:do_catchsql_test( [[ SELECT DISTINCT aname FROM album, composer, track - WHERE likelihood(cname LIKE '%bach%', -0.01) + WHERE likelihood(cname LIKE '%bach%', -0.1e0) AND composer.cid=track.cid AND album.aid=track.aid; ]], { @@ -201,7 +201,7 @@ test:do_catchsql_test( [[ SELECT DISTINCT aname FROM album, composer, track - WHERE likelihood(cname LIKE '%bach%', 1.01) + WHERE likelihood(cname LIKE '%bach%', 1.01e0) AND composer.cid=track.cid AND album.aid=track.aid; ]], { @@ -370,7 +370,7 @@ test:do_execsql_test( test:do_execsql_test( "7.2", [[ - SELECT likelihood(a,0.5), x FROM t1, t2 ORDER BY 1, 2; + SELECT likelihood(a, 0.5e0), x FROM t1, t2 ORDER BY 1, 2; ]], { -- <7.2> 1, 3, 1, 4, 9, 3, 9, 4 diff --git a/test/sql-tap/with1.test.lua b/test/sql-tap/with1.test.lua index 761004b23..2aa9f0aca 100755 --- a/test/sql-tap/with1.test.lua +++ b/test/sql-tap/with1.test.lua @@ -534,10 +534,10 @@ test:do_catchsql_test(7.6, [[ -- test:do_execsql_test("8.1-mandelbrot", [[ WITH RECURSIVE - xaxis(x) AS (VALUES(-2.0) UNION ALL SELECT x+0.05 FROM xaxis WHERE x<1.2), - yaxis(y) AS (VALUES(-1.0) UNION ALL SELECT y+0.1 FROM yaxis WHERE y<1.0), + xaxis(x) AS (VALUES(-2e0) UNION ALL SELECT x + 0.05e0 FROM xaxis WHERE x < 1.2e0), + yaxis(y) AS (VALUES(-1e0) UNION ALL SELECT y + 0.1e0 FROM yaxis WHERE y < 1.0e0), m(iter, cx, cy, x, y) AS ( - SELECT 0, x, y, 0.0, 0.0 FROM xaxis, yaxis + SELECT 0, x, y, 0e0, 0e0 FROM xaxis, yaxis UNION ALL SELECT iter+1, cx, cy, x*x-y*y + cx, 2.0*x*y + cy FROM m WHERE (x*x + y*y) < 4.0 AND iter<28 diff --git a/test/sql/boolean.result b/test/sql/boolean.result index 75a091cce..984529f64 100644 --- a/test/sql/boolean.result +++ b/test/sql/boolean.result @@ -546,12 +546,12 @@ SELECT cast(0 AS BOOLEAN); SELECT cast(0.123 AS BOOLEAN); | --- | - null - | - 'Type mismatch: can not convert double(0.123) to boolean' + | - 'Type mismatch: can not convert decimal(0.123) to boolean' | ... SELECT cast(0.0 AS BOOLEAN); | --- | - null - | - 'Type mismatch: can not convert double(0.0) to boolean' + | - 'Type mismatch: can not convert decimal(0.0) to boolean' | ... SELECT cast('true' AS BOOLEAN), cast('false' AS BOOLEAN); | --- @@ -3920,7 +3920,7 @@ INSERT INTO t8 VALUES (4.56); SELECT true AND 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT false AND 2.3; | --- @@ -3933,17 +3933,17 @@ SELECT false AND 2.3; SELECT true OR 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT false OR 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT 2.3 AND true; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT 2.3 AND false; | --- @@ -3956,53 +3956,53 @@ SELECT 2.3 AND false; SELECT 2.3 OR true; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT 2.3 OR false; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a1, a1 AND 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a1, a1 OR 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a1, 2.3 AND a1 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a1, 2.3 OR a1 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a2, a2 AND 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a2, a2 OR 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a2, 2.3 AND a2 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a2, 2.3 OR a2 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT c, true AND c FROM t8; @@ -4140,12 +4140,12 @@ SELECT false / 2.3; SELECT true % 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to integer' + | - 'Type mismatch: can not convert decimal(2.3) to integer' | ... SELECT false % 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to integer' + | - 'Type mismatch: can not convert decimal(2.3) to integer' | ... SELECT 2.3 + true; | --- @@ -4221,7 +4221,7 @@ SELECT a1, a1 / 2.3 FROM t6 SELECT a1, a1 % 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to integer' + | - 'Type mismatch: can not convert decimal(2.3) to integer' | ... SELECT a1, 2.3 + a1 FROM t6 | --- @@ -4271,7 +4271,7 @@ SELECT a2, a2 / 2.3 FROM t6 SELECT a2, a2 % 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to integer' + | - 'Type mismatch: can not convert decimal(2.3) to integer' | ... SELECT a2, 2.3 + a2 FROM t6 | --- @@ -4504,22 +4504,22 @@ SELECT a2, c, c % a2 FROM t6, t8; SELECT true > 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT false > 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT true < 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT false < 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT 2.3 > true; | --- @@ -4545,12 +4545,12 @@ SELECT 2.3 < false; SELECT a1, a1 > 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a1, a1 < 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a1, 2.3 > a1 FROM t6 | --- @@ -4565,12 +4565,12 @@ SELECT a1, 2.3 < a1 FROM t6 SELECT a2, a2 > 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a2, a2 < 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a2, 2.3 > a2 FROM t6 | --- @@ -4668,22 +4668,22 @@ SELECT a2, c, c < a2 FROM t6, t8; SELECT true >= 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT false >= 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT true <= 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT false <= 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT 2.3 >= true; | --- @@ -4709,12 +4709,12 @@ SELECT 2.3 <= false; SELECT a1, a1 >= 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a1, a1 <= 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a1, 2.3 >= a1 FROM t6 | --- @@ -4729,12 +4729,12 @@ SELECT a1, 2.3 <= a1 FROM t6 SELECT a2, a2 >= 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a2, a2 <= 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a2, 2.3 >= a2 FROM t6 | --- @@ -4832,22 +4832,22 @@ SELECT a2, c, c <= a2 FROM t6, t8; SELECT true == 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT false == 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT true != 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT false != 2.3; | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT 2.3 == true; | --- @@ -4873,12 +4873,12 @@ SELECT 2.3 != false; SELECT a1, a1 == 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a1, a1 != 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a1, 2.3 == a1 FROM t6 | --- @@ -4893,12 +4893,12 @@ SELECT a1, 2.3 != a1 FROM t6 SELECT a2, a2 == 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a2, a2 != 2.3 FROM t6 | --- | - null - | - 'Type mismatch: can not convert double(2.3) to boolean' + | - 'Type mismatch: can not convert decimal(2.3) to boolean' | ... SELECT a2, 2.3 == a2 FROM t6 | --- @@ -5049,22 +5049,22 @@ SELECT a2 IN (SELECT c FROM t8) FROM t6 LIMIT 1; SELECT true BETWEEN 0.1 and 9.9; | --- | - null - | - 'Type mismatch: can not convert double(0.1) to boolean' + | - 'Type mismatch: can not convert decimal(0.1) to boolean' | ... SELECT false BETWEEN 0.1 and 9.9; | --- | - null - | - 'Type mismatch: can not convert double(0.1) to boolean' + | - 'Type mismatch: can not convert decimal(0.1) to boolean' | ... SELECT a1, a1 BETWEEN 0.1 and 9.9 FROM t6; | --- | - null - | - 'Type mismatch: can not convert double(0.1) to boolean' + | - 'Type mismatch: can not convert decimal(0.1) to boolean' | ... SELECT a2, a2 BETWEEN 0.1 and 9.9 FROM t6; | --- | - null - | - 'Type mismatch: can not convert double(0.1) to boolean' + | - 'Type mismatch: can not convert decimal(0.1) to boolean' | ... -- Check interaction of BOOLEAN and TEXT. diff --git a/test/sql/func-recreate.result b/test/sql/func-recreate.result index 5fd2b79c0..efc0a7493 100644 --- a/test/sql/func-recreate.result +++ b/test/sql/func-recreate.result @@ -25,7 +25,7 @@ test_run:cmd("setopt delimiter ''"); ch = fiber.channel(1) --- ... -_ = fiber.create(function () ch:put(box.execute('select WAITFOR(0.2)')) end) +_ = fiber.create(function () ch:put(box.execute('select WAITFOR(0.2e0)')) end) --- ... fiber.sleep(0.1) diff --git a/test/sql/func-recreate.test.lua b/test/sql/func-recreate.test.lua index b76789f86..d0132f120 100644 --- a/test/sql/func-recreate.test.lua +++ b/test/sql/func-recreate.test.lua @@ -13,7 +13,7 @@ test_run:cmd("setopt delimiter ''"); ch = fiber.channel(1) -_ = fiber.create(function () ch:put(box.execute('select WAITFOR(0.2)')) end) +_ = fiber.create(function () ch:put(box.execute('select WAITFOR(0.2e0)')) end) fiber.sleep(0.1) box.func.WAITFOR:drop() diff --git a/test/sql/gh-3888-values-blob-assert.result b/test/sql/gh-3888-values-blob-assert.result index 669f2eb2f..ce3f58cdc 100644 --- a/test/sql/gh-3888-values-blob-assert.result +++ b/test/sql/gh-3888-values-blob-assert.result @@ -69,7 +69,7 @@ box.execute('SELECT 3.14') --- - metadata: - name: COLUMN_1 - type: double + type: decimal rows: - [3.14] ... diff --git a/test/sql/integer-overflow.result b/test/sql/integer-overflow.result index 8cad30ef3..91958d4e9 100644 --- a/test/sql/integer-overflow.result +++ b/test/sql/integer-overflow.result @@ -114,7 +114,7 @@ box.execute('SELECT CAST(\'18446744073709551616\' AS INTEGER);') -- float 18446744073709551600 -> int (18446744073709551616), -- with error due to conversion = 16. -- -box.execute('SELECT CAST(18446744073709551600. AS INTEGER);') +box.execute('SELECT CAST(18446744073709551600e0 AS INTEGER);') --- - null - 'Type mismatch: can not convert double(1.84467440737096e+19) to integer' diff --git a/test/sql/integer-overflow.test.lua b/test/sql/integer-overflow.test.lua index 2ac97995a..5a9ebca19 100644 --- a/test/sql/integer-overflow.test.lua +++ b/test/sql/integer-overflow.test.lua @@ -32,7 +32,7 @@ box.execute('SELECT CAST(\'18446744073709551616\' AS INTEGER);') -- float 18446744073709551600 -> int (18446744073709551616), -- with error due to conversion = 16. -- -box.execute('SELECT CAST(18446744073709551600. AS INTEGER);') +box.execute('SELECT CAST(18446744073709551600e0 AS INTEGER);') -- gh-3810: make sure that if space contains integers in range -- [INT64_MAX, UINT64_MAX], they are handled inside SQL in a -- proper way, which now means that an error is raised. diff --git a/test/sql/misc.result b/test/sql/misc.result index 91464ec33..c3c0b161b 100644 --- a/test/sql/misc.result +++ b/test/sql/misc.result @@ -87,12 +87,28 @@ box.execute('SELECT 1.5;') --- - metadata: - name: COLUMN_1 - type: double + type: decimal rows: - [1.5] ... box.execute('SELECT 1.0;') --- +- metadata: + - name: COLUMN_1 + type: decimal + rows: + - [1.0] +... +box.execute('SELECT 1.5e0;') +--- +- metadata: + - name: COLUMN_1 + type: double + rows: + - [1.5] +... +box.execute('SELECT 1e0;') +--- - metadata: - name: COLUMN_1 type: double diff --git a/test/sql/misc.test.lua b/test/sql/misc.test.lua index 8de7366b1..8b34d1071 100644 --- a/test/sql/misc.test.lua +++ b/test/sql/misc.test.lua @@ -24,6 +24,8 @@ box.execute('CREATE TABLE test (id INTEGER PRIMARY KEY, b TEXT CONSTRAINT c1 COL box.execute('SELECT 1;') box.execute('SELECT 1.5;') box.execute('SELECT 1.0;') +box.execute('SELECT 1.5e0;') +box.execute('SELECT 1e0;') box.execute('SELECT \'abc\';') box.execute('SELECT X\'4D6564766564\'') diff --git a/test/sql/types.result b/test/sql/types.result index b8e0d1fcb..947795b03 100644 --- a/test/sql/types.result +++ b/test/sql/types.result @@ -163,7 +163,7 @@ box.execute("SELECT 'abc' || 1;") box.execute("SELECT 'abc' || 1.123;") --- - null -- 'Inconsistent types: expected string or varbinary got double(1.123)' +- 'Inconsistent types: expected string or varbinary got decimal(1.123)' ... box.execute("SELECT 1 || 'abc';") --- @@ -173,7 +173,7 @@ box.execute("SELECT 1 || 'abc';") box.execute("SELECT 1.123 || 'abc';") --- - null -- 'Inconsistent types: expected string or varbinary got double(1.123)' +- 'Inconsistent types: expected string or varbinary got decimal(1.123)' ... box.execute("SELECt 'a' || 'b' || 1;") --- @@ -298,7 +298,7 @@ box.execute('SELECT 1 + 1.1;') --- - metadata: - name: COLUMN_1 - type: double + type: decimal rows: - [2.1] ... @@ -346,7 +346,7 @@ box.execute("SELECT * FROM tboolean WHERE s1 = 1;") box.execute("SELECT * FROM tboolean WHERE s1 = 1.123;") --- - null -- 'Type mismatch: can not convert double(1.123) to boolean' +- 'Type mismatch: can not convert decimal(1.123) to boolean' ... box.space.TBOOLEAN:drop() --- @@ -463,7 +463,8 @@ box.execute("SELECT a FROM t1 WHERE a IN (1.1, 2.1);") - metadata: - name: A type: unsigned - rows: [] + rows: + - [1] ... s:drop() --- @@ -582,7 +583,7 @@ box.execute("SELECT 18446744073709551615 = null;") rows: - [null] ... -box.execute("SELECT 18446744073709551615 = 18446744073709551615.0;") +box.execute("SELECT 18446744073709551615 = 18446744073709551615e0;") --- - metadata: - name: COLUMN_1 @@ -590,7 +591,7 @@ box.execute("SELECT 18446744073709551615 = 18446744073709551615.0;") rows: - [false] ... -box.execute("SELECT 18446744073709551615.0 > 18446744073709551615") +box.execute("SELECT 18446744073709551615e0 > 18446744073709551615") --- - metadata: - name: COLUMN_1 @@ -598,7 +599,7 @@ box.execute("SELECT 18446744073709551615.0 > 18446744073709551615") rows: - [true] ... -box.execute("SELECT 18446744073709551615 IN ('18446744073709551615', 18446744073709551615.0)") +box.execute("SELECT 18446744073709551615 IN ('18446744073709551615', 18446744073709551615e0)") --- - null - 'Type mismatch: can not convert integer(18446744073709551615) to string' @@ -1075,7 +1076,7 @@ box.execute("SELECT CAST(1.5 AS UNSIGNED);") box.execute("SELECT CAST(-1.5 AS UNSIGNED);") --- - null -- 'Type mismatch: can not convert double(-1.5) to unsigned' +- 'Type mismatch: can not convert decimal(-1.5) to unsigned' ... box.execute("SELECT CAST(true AS UNSIGNED);") --- @@ -1192,7 +1193,7 @@ box.execute("INSERT INTO t VALUES(1, 1);") box.execute("INSERT INTO t VALUES(1, 1.123);") --- - null -- 'Type mismatch: can not convert double(1.123) to varbinary' +- 'Type mismatch: can not convert decimal(1.123) to varbinary' ... box.execute("INSERT INTO t VALUES(1, true);") --- @@ -1216,7 +1217,7 @@ box.execute("SELECT * FROM t WHERE v = 1") box.execute("SELECT * FROM t WHERE v = 1.123") --- - null -- 'Type mismatch: can not convert double(1.123) to varbinary' +- 'Type mismatch: can not convert decimal(1.123) to varbinary' ... box.execute("SELECT * FROM t WHERE v = 'str'") --- @@ -1424,7 +1425,7 @@ box.execute("SELECT CAST(1 AS VARBINARY);") box.execute("SELECT CAST(1.123 AS VARBINARY);") --- - null -- 'Type mismatch: can not convert double(1.123) to varbinary' +- 'Type mismatch: can not convert decimal(1.123) to varbinary' ... box.execute("SELECT CAST(true AS VARBINARY);") --- @@ -1657,15 +1658,15 @@ box.execute("SELECT 1.0;") --- - metadata: - name: COLUMN_1 - type: double + type: decimal rows: - - [1] + - [1.0] ... box.execute("SELECT .01;") --- - metadata: - name: COLUMN_1 - type: double + type: decimal rows: - [0.01] ... @@ -2031,11 +2032,11 @@ box.execute("SELECT 1.0, typeof(1.0);") --- - metadata: - name: COLUMN_1 - type: double + type: decimal - name: COLUMN_2 type: string rows: - - [1, 'double'] + - [1.0, 'decimal'] ... box.execute("SELECT CAST(2 AS DOUBLE), typeof(CAST(2 AS DOUBLE));") --- @@ -2146,7 +2147,7 @@ box.execute([[INSERT INTO ti(i) VALUES (11);]]) - 2 row_count: 1 ... -box.execute([[INSERT INTO ti(i) VALUES (100000000000000000000000000000000.1);]]) +box.execute([[INSERT INTO ti(i) VALUES (100000000000000000000000000000000.1e0);]]) --- - null - 'Type mismatch: can not convert double(1.0e+32) to integer' @@ -2248,7 +2249,7 @@ box.execute([[INSERT INTO tb(b) VALUES (11);]]) box.execute([[INSERT INTO tb(b) VALUES (22.2);]]) --- - null -- 'Type mismatch: can not convert double(22.2) to boolean' +- 'Type mismatch: can not convert decimal(22.2) to boolean' ... box.execute([[INSERT INTO tb(b) VALUES (true);]]) --- @@ -2291,7 +2292,7 @@ box.execute([[INSERT INTO tt(t) VALUES (11);]]) box.execute([[INSERT INTO tt(t) VALUES (22.2);]]) --- - null -- 'Type mismatch: can not convert double(22.2) to string' +- 'Type mismatch: can not convert decimal(22.2) to string' ... box.execute([[INSERT INTO tt(t) VALUES (true);]]) --- @@ -2334,7 +2335,7 @@ box.execute([[INSERT INTO tv(v) VALUES (11);]]) box.execute([[INSERT INTO tv(v) VALUES (22.2);]]) --- - null -- 'Type mismatch: can not convert double(22.2) to varbinary' +- 'Type mismatch: can not convert decimal(22.2) to varbinary' ... box.execute([[INSERT INTO tv(v) VALUES (true);]]) --- @@ -2501,7 +2502,7 @@ box.execute([[UPDATE ti SET i = 11 WHERE a = 1;]]) --- - row_count: 1 ... -box.execute([[UPDATE ti SET i = 100000000000000000000000000000000.1 WHERE a = 1;]]) +box.execute([[UPDATE ti SET i = 100000000000000000000000000000000.1e0 WHERE a = 1;]]) --- - null - 'Type mismatch: can not convert double(1.0e+32) to integer' @@ -2589,7 +2590,7 @@ box.execute([[UPDATE tb SET b = 11 WHERE a = 1;]]) box.execute([[UPDATE tb SET b = 22.2 WHERE a = 1;]]) --- - null -- 'Type mismatch: can not convert double(22.2) to boolean' +- 'Type mismatch: can not convert decimal(22.2) to boolean' ... box.execute([[UPDATE tb SET b = true WHERE a = 1;]]) --- @@ -2627,7 +2628,7 @@ box.execute([[UPDATE tt SET t = 11 WHERE a = 1;]]) box.execute([[UPDATE tt SET t = 22.2 WHERE a = 1;]]) --- - null -- 'Type mismatch: can not convert double(22.2) to string' +- 'Type mismatch: can not convert decimal(22.2) to string' ... box.execute([[UPDATE tt SET t = true WHERE a = 1;]]) --- @@ -2665,7 +2666,7 @@ box.execute([[UPDATE tv SET v = 11 WHERE a = 1;]]) box.execute([[UPDATE tv SET v = 22.2 WHERE a = 1;]]) --- - null -- 'Type mismatch: can not convert double(22.2) to varbinary' +- 'Type mismatch: can not convert decimal(22.2) to varbinary' ... box.execute([[UPDATE tv SET v = true WHERE a = 1;]]) --- diff --git a/test/sql/types.test.lua b/test/sql/types.test.lua index 0270d9f8a..e9b5012af 100644 --- a/test/sql/types.test.lua +++ b/test/sql/types.test.lua @@ -149,9 +149,9 @@ box.execute("SELECT -1 < 18446744073709551615;") box.execute("SELECT -1 > 18446744073709551615;") box.execute("SELECT 18446744073709551610 - 18446744073709551615;") box.execute("SELECT 18446744073709551615 = null;") -box.execute("SELECT 18446744073709551615 = 18446744073709551615.0;") -box.execute("SELECT 18446744073709551615.0 > 18446744073709551615") -box.execute("SELECT 18446744073709551615 IN ('18446744073709551615', 18446744073709551615.0)") +box.execute("SELECT 18446744073709551615 = 18446744073709551615e0;") +box.execute("SELECT 18446744073709551615e0 > 18446744073709551615") +box.execute("SELECT 18446744073709551615 IN ('18446744073709551615', 18446744073709551615e0)") box.execute("SELECT 1 LIMIT 18446744073709551615;") box.execute("SELECT 1 LIMIT 1 OFFSET 18446744073709551614;") box.execute("SELECT CAST('18446744073' || '709551616' AS INTEGER);") @@ -504,7 +504,7 @@ box.execute([[CREATE TABLE ts (a INT PRIMARY KEY AUTOINCREMENT, s SCALAR);]]) box.execute([[INSERT INTO ti(i) VALUES (NULL);]]) box.execute([[INSERT INTO ti(i) VALUES (11);]]) -box.execute([[INSERT INTO ti(i) VALUES (100000000000000000000000000000000.1);]]) +box.execute([[INSERT INTO ti(i) VALUES (100000000000000000000000000000000.1e0);]]) box.execute([[INSERT INTO ti(i) VALUES (33.0);]]) box.execute([[INSERT INTO ti(i) VALUES (true);]]) box.execute([[INSERT INTO ti(i) VALUES ('33');]]) @@ -569,7 +569,7 @@ box.execute([[SELECT * FROM ti, td, tb, tt, tv, ts;]]) box.execute([[UPDATE ti SET i = NULL WHERE a = 1;]]) box.execute([[UPDATE ti SET i = 11 WHERE a = 1;]]) -box.execute([[UPDATE ti SET i = 100000000000000000000000000000000.1 WHERE a = 1;]]) +box.execute([[UPDATE ti SET i = 100000000000000000000000000000000.1e0 WHERE a = 1;]]) box.execute([[UPDATE ti SET i = 33.0 WHERE a = 1;]]) box.execute([[UPDATE ti SET i = true WHERE a = 1;]]) box.execute([[UPDATE ti SET i = '33' WHERE a = 1;]]) -- 2.25.1