diff --git a/src/box/sql/vdbe.c b/src/box/sql/vdbe.c index 738448e0927e0db3935cb876de8ed2417bdd5ec2..5ab97794021737dfb3bb2e3c74af8a59f05d8917 100644 --- a/src/box/sql/vdbe.c +++ b/src/box/sql/vdbe.c @@ -320,6 +320,8 @@ mem_apply_type(struct Mem *record, enum field_type type) switch (type) { case FIELD_TYPE_INTEGER: case FIELD_TYPE_UNSIGNED: + if ((record->flags & (MEM_Bool | MEM_Blob)) != 0) + return -1; if ((record->flags & MEM_UInt) == MEM_UInt) return 0; if ((record->flags & MEM_Real) == MEM_Real) { @@ -332,8 +334,13 @@ mem_apply_type(struct Mem *record, enum field_type type) mem_set_u64(record, u); return 0; } - if (sqlVdbeMemIntegerify(record) != 0) - return -1; + if ((record->flags & MEM_Str) != 0) { + bool is_neg; + int64_t i; + if (sql_atoi64(record->z, &i, &is_neg, record->n) != 0) + return -1; + mem_set_int(record, i, is_neg); + } if ((record->flags & MEM_Int) == MEM_Int) { if (type == FIELD_TYPE_UNSIGNED) return -1; diff --git a/src/box/sql/vdbeInt.h b/src/box/sql/vdbeInt.h index 38305ce1dbfaeac6c441a40ede01be0fb91a8065..2c50b6768c81426c48a340e7dd6a76eefce66532 100644 --- a/src/box/sql/vdbeInt.h +++ b/src/box/sql/vdbeInt.h @@ -525,7 +525,6 @@ int sqlVdbeMemMakeWriteable(Mem *); int sqlVdbeMemStringify(Mem *); int sqlVdbeIntValue(Mem *, int64_t *, bool *is_neg); -int sqlVdbeMemIntegerify(struct Mem *pMem); int sqlVdbeRealValue(Mem *, double *); int diff --git a/src/box/sql/vdbemem.c b/src/box/sql/vdbemem.c index 7490f5ddafd3bed9030989ddefc2aa24e10c3f6f..8dad2db9a10ba8079c55d92f9e250f31270a27f0 100644 --- a/src/box/sql/vdbemem.c +++ b/src/box/sql/vdbemem.c @@ -550,35 +550,6 @@ mem_apply_integer_type(Mem *pMem) return rc; } -/* - * Convert pMem to type integer. Invalidate any prior representations. - */ -int -sqlVdbeMemIntegerify(struct Mem *pMem) -{ - assert(EIGHT_BYTE_ALIGNMENT(pMem)); - - int64_t i; - bool is_neg; - if (sqlVdbeIntValue(pMem, &i, &is_neg) == 0) { - mem_set_int(pMem, i, is_neg); - return 0; - } - - double d; - if (sqlVdbeRealValue(pMem, &d) != 0) - return -1; - if (d < INT64_MAX && d >= INT64_MIN) { - mem_set_int(pMem, d, d <= -1); - return 0; - } - if (d >= INT64_MAX && d < UINT64_MAX) { - mem_set_u64(pMem, d); - return 0; - } - return -1; -} - /* * Convert pMem so that it is of type MEM_Real. * Invalidate any prior representations. diff --git a/test/sql-tap/e_select1.test.lua b/test/sql-tap/e_select1.test.lua index c1818ddb1b6a3ea849240ab1eda47ee6caa194e0..1d3b964b9204888a176baf85676f8c3afa4b80f3 100755 --- a/test/sql-tap/e_select1.test.lua +++ b/test/sql-tap/e_select1.test.lua @@ -2195,7 +2195,7 @@ test:do_select_tests( {"1", "SELECT b FROM f1 ORDER BY a LIMIT 0 ", {}}, {"2", "SELECT b FROM f1 ORDER BY a DESC LIMIT 4 ", {"z", "y", "x", "w"}}, {"3", "SELECT b FROM f1 ORDER BY a DESC LIMIT 8 ", {"z", "y", "x", "w", "v", "u", "t", "s"}}, - {"4", "SELECT b FROM f1 ORDER BY a DESC LIMIT '12.0' ", {"z", y, "x", "w", "v", "u", "t", "s", "r", "q", "p", "o"}}, + {"4", "SELECT b FROM f1 ORDER BY a DESC LIMIT '12' ", {"z", y, "x", "w", "v", "u", "t", "s", "r", "q", "p", "o"}}, }) -- EVIDENCE-OF: R-54935-19057 Or, if the SELECT statement would return diff --git a/test/sql-tap/intpkey.test.lua b/test/sql-tap/intpkey.test.lua index bec26708e2b3f650a5c1cae513eb2701feb96c96..b6b186632ad4baf52cf701a229fb92c26ab360f2 100755 --- a/test/sql-tap/intpkey.test.lua +++ b/test/sql-tap/intpkey.test.lua @@ -788,7 +788,7 @@ test:do_execsql_test( test:do_execsql_test( "intpkey-13.2", [[ - INSERT INTO t1 VALUES('1.0',2,3); + INSERT INTO t1 VALUES('1',2,3); SELECT * FROM t1 WHERE a=1; ]], { -- <intpkey-13.2> diff --git a/test/sql-tap/join.test.lua b/test/sql-tap/join.test.lua index 4f014e08676a5afe31cc8a02e0bcc88fc910efe3..840b780a3ac5429cf0d554a0b4a5820d68caaee5 100755 --- a/test/sql-tap/join.test.lua +++ b/test/sql-tap/join.test.lua @@ -1017,7 +1017,7 @@ test:do_test( return test:execsql [[ CREATE TABLE t1(a TEXT primary key, b TEXT); CREATE TABLE t2(b INTEGER primary key, a TEXT); - INSERT INTO t1 VALUES('one', '1.0'); + INSERT INTO t1 VALUES('one', '1'); INSERT INTO t1 VALUES('two', '2'); INSERT INTO t2 VALUES(1, 'one'); INSERT INTO t2 VALUES(2, 'two'); @@ -1034,7 +1034,7 @@ test:do_execsql_test( SELECT * FROM t1 NATURAL JOIN t2 ]], { -- <join-11.9> - "one", "1.0", "two", "2" + "one", "1", "two", "2" -- </join-11.9> }) diff --git a/test/sql-tap/subquery.test.lua b/test/sql-tap/subquery.test.lua index 6bedf5879a74382a6b20c8ad30c19b3097192dc0..15c4c82761ced791d1ef231d54b5475760400f85 100755 --- a/test/sql-tap/subquery.test.lua +++ b/test/sql-tap/subquery.test.lua @@ -342,7 +342,7 @@ test:do_execsql_test( INSERT INTO t3 VALUES(10); CREATE TABLE t4(x TEXT PRIMARY KEY); - INSERT INTO t4 VALUES('10.0'); + INSERT INTO t4 VALUES('10'); ]], { -- <subquery-2.5.1> @@ -363,7 +363,7 @@ test:do_test( ]] end, { -- <subquery-2.5.2> - "10.0" + "10" -- </subquery-2.5.2> }) @@ -378,7 +378,7 @@ test:do_test( ]] end, { -- <subquery-2.5.3.1> - "10.0" + "10" -- </subquery-2.5.3.1> }) diff --git a/test/sql-tap/tkt-9a8b09f8e6.test.lua b/test/sql-tap/tkt-9a8b09f8e6.test.lua index db0881caaf7f936632f4d04ed682c00dc4b96a5e..cb5348ab49a98f538bad4b61096bbd0aa26a5f85 100755 --- a/test/sql-tap/tkt-9a8b09f8e6.test.lua +++ b/test/sql-tap/tkt-9a8b09f8e6.test.lua @@ -196,7 +196,7 @@ test:do_execsql_test( test:do_execsql_test( 3.4, [[ - SELECT x FROM t2 WHERE x IN ('1.0'); + SELECT x FROM t2 WHERE x IN ('1'); ]], { -- <3.4> 1 @@ -236,7 +236,7 @@ test:do_execsql_test( test:do_execsql_test( 3.8, [[ - SELECT x FROM t2 WHERE '1.0' IN (x); + SELECT x FROM t2 WHERE '1' IN (x); ]], { -- <3.8> 1