Fix a false-positive in sqlite3ExprNeedsNoAffinityChange().
Ticket [ac184eb571d5e6e0] FossilOrigin-Name: e62eddbb048cbc2c15cb8eeb5b7a907e7cb08c21a27ebba96a069f62dbcb0f30
This commit is contained in:
parent
3e36480232
commit
af8664020a
14
manifest
14
manifest
@ -1,5 +1,5 @@
|
||||
C Fix\sthe\sOP_SeekGE,\sOP_SeekGT,\sOP_SeekLE,\sand\sOP_SeekLT\sopcodes\sso\sthat\sthey\npreserve\sthe\sdatatype\sof\sthe\svalue\sin\sthe\sregister\sused\sas\sthe\skey.\nTicket\s[d9f584e936c7a8d0]
|
||||
D 2019-08-22T00:53:16.723
|
||||
C Fix\sa\sfalse-positive\sin\ssqlite3ExprNeedsNoAffinityChange().\nTicket\s[ac184eb571d5e6e0]
|
||||
D 2019-08-22T11:11:28.880
|
||||
F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1
|
||||
F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea
|
||||
F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724
|
||||
@ -475,7 +475,7 @@ F src/date.c e1d8ac7102f3f283e63e13867acb0efa33861cf34f0faf4cdbaf9fa7a1eb7041
|
||||
F src/dbpage.c 135eb3b5e74f9ef74bde5cec2571192c90c86984fa534c88bf4a055076fa19b7
|
||||
F src/dbstat.c c12833de69cb655751487d2c5a59607e36be1c58ba1f4bd536609909ad47b319
|
||||
F src/delete.c d08c9e01a2664afd12edcfa3a9c6578517e8ff8735f35509582693adbe0edeaf
|
||||
F src/expr.c abef10556e47c3fca04de6a80d802d428e008ed61b4c76dd8439c189f4cd778f
|
||||
F src/expr.c 1888c5647ec7630703ce0574f6e6b351062b7e0f990667f3c069cc7e602566b1
|
||||
F src/fault.c 460f3e55994363812d9d60844b2a6de88826e007
|
||||
F src/fkey.c 6b79f4c2447691aa9ac86e2a6a774b65f3b3dd053d4220a4893051a0de20f82e
|
||||
F src/func.c 4ee36219698d50d672a28eca4adb0fd6b92e607a1883d318315e0d2fd5044467
|
||||
@ -615,7 +615,7 @@ F src/wherecode.c e1131fe94c8728cbecc707f6455afbda9418896497bdca2d49a04ce6c57999
|
||||
F src/whereexpr.c 5cce1fd11876086890a27c05e0cb75ca97ba64ba6984f72154039f1cfd2e69cc
|
||||
F src/window.c 07e1c15081a735750218185c6b17053c87ecb764d06ab2c0a1ce568a2b4688e5
|
||||
F test/8_3_names.test ebbb5cd36741350040fd28b432ceadf495be25b2
|
||||
F test/affinity2.test 34f2cf88e2a08d7a54a1fa2c9773ba81bf8b8216c0895e476118a1285540ee71
|
||||
F test/affinity2.test b03930d288e38b07f55023a58538ad174605695e98934bdab1facf6bd9ecc436
|
||||
F test/affinity3.test 6a101af2fc945ce2912f6fe54dd646018551710d
|
||||
F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2
|
||||
F test/aggnested.test 18b00de006597e960a6b27ccec51474ac66cf1070a87c1933e5694dc02190ef1
|
||||
@ -1836,7 +1836,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P d02490a2f0cae047087130b4ad8f55f265845c2ffb3bde3b7d507edb54acea6d
|
||||
R 9a1f89de468f638cf6272be3b894c4f7
|
||||
P 81b9f0f55042777b37de78069f7089041a9ee21dd0a0c86b879053fb46e140b4
|
||||
R a8ad8ca6cf470341d16a9de34fb069f4
|
||||
U drh
|
||||
Z 8cbd654fcd7e359876e90cf539c4f92a
|
||||
Z 2534526d731ee28f45a8990ce9a4aa42
|
||||
|
@ -1 +1 @@
|
||||
81b9f0f55042777b37de78069f7089041a9ee21dd0a0c86b879053fb46e140b4
|
||||
e62eddbb048cbc2c15cb8eeb5b7a907e7cb08c21a27ebba96a069f62dbcb0f30
|
10
src/expr.c
10
src/expr.c
@ -2159,8 +2159,12 @@ int sqlite3ExprCanBeNull(const Expr *p){
|
||||
*/
|
||||
int sqlite3ExprNeedsNoAffinityChange(const Expr *p, char aff){
|
||||
u8 op;
|
||||
int unaryMinus = 0;
|
||||
if( aff==SQLITE_AFF_BLOB ) return 1;
|
||||
while( p->op==TK_UPLUS || p->op==TK_UMINUS ){ p = p->pLeft; }
|
||||
while( p->op==TK_UPLUS || p->op==TK_UMINUS ){
|
||||
if( p->op==TK_UMINUS ) unaryMinus = 1;
|
||||
p = p->pLeft;
|
||||
}
|
||||
op = p->op;
|
||||
if( op==TK_REGISTER ) op = p->op2;
|
||||
switch( op ){
|
||||
@ -2171,10 +2175,10 @@ int sqlite3ExprNeedsNoAffinityChange(const Expr *p, char aff){
|
||||
return aff==SQLITE_AFF_REAL || aff==SQLITE_AFF_NUMERIC;
|
||||
}
|
||||
case TK_STRING: {
|
||||
return aff==SQLITE_AFF_TEXT;
|
||||
return !unaryMinus && aff==SQLITE_AFF_TEXT;
|
||||
}
|
||||
case TK_BLOB: {
|
||||
return 1;
|
||||
return !unaryMinus;
|
||||
}
|
||||
case TK_COLUMN: {
|
||||
assert( p->iTable>=0 ); /* p cannot be part of a CHECK constraint */
|
||||
|
@ -85,4 +85,36 @@ do_execsql_test 440 {
|
||||
SELECT * FROM t3 WHERE c='0' ORDER BY a;
|
||||
} {2 1 0 4 1 0}
|
||||
|
||||
# 2019-08-22 ticket https://sqlite.org/src/info/d99f1ffe836c591ac57f
|
||||
# False positive in sqlite3ExprNeedsNoAffinityChange()
|
||||
#
|
||||
do_execsql_test 500 {
|
||||
DROP TABLE IF EXISTS t0;
|
||||
CREATE TABLE t0(c0 TEXT UNIQUE, c1);
|
||||
INSERT INTO t0(c0) VALUES (-1);
|
||||
SELECT quote(- x'ce'), quote(t0.c0), quote(- x'ce' >= t0.c0) FROM t0;
|
||||
} {0 '-1' 1}
|
||||
do_execsql_test 501 {
|
||||
SELECT * FROM t0 WHERE - x'ce' >= t0.c0;
|
||||
} {-1 {}}
|
||||
do_execsql_test 502 {
|
||||
SELECT quote(+-+x'ce'), quote(t0.c0), quote(+-+x'ce' >= t0.c0) FROM t0;
|
||||
} {0 '-1' 1}
|
||||
do_execsql_test 503 {
|
||||
SELECT * FROM t0 WHERE +-+x'ce' >= t0.c0;
|
||||
} {-1 {}}
|
||||
do_execsql_test 504 {
|
||||
SELECT quote(- 'ce'), quote(t0.c0), quote(- 'ce' >= t0.c0) FROM t0;
|
||||
} {0 '-1' 1}
|
||||
do_execsql_test 505 {
|
||||
SELECT * FROM t0 WHERE - 'ce' >= t0.c0;
|
||||
} {-1 {}}
|
||||
do_execsql_test 506 {
|
||||
SELECT quote(+-+'ce'), quote(t0.c0), quote(+-+'ce' >= t0.c0) FROM t0;
|
||||
} {0 '-1' 1}
|
||||
do_execsql_test 507 {
|
||||
SELECT * FROM t0 WHERE +-+'ce' >= t0.c0;
|
||||
} {-1 {}}
|
||||
|
||||
|
||||
finish_test
|
||||
|
Loading…
Reference in New Issue
Block a user