From: drh Date: Thu, 13 Aug 2009 18:14:32 +0000 (+0000) Subject: Enhancements to the whereB.test to check more affinity corner cases. X-Git-Tag: fts3-refactor~271 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=320b3a7a3af09492c9b2e10441dac579f86f5806;p=thirdparty%2Fsqlite.git Enhancements to the whereB.test to check more affinity corner cases. FossilOrigin-Name: 1048459824746307c9e4296cbc21716bf8b5449d --- diff --git a/manifest b/manifest index 2654825fac..c044cfb58f 100644 --- a/manifest +++ b/manifest @@ -1,8 +1,8 @@ -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 -C Add\sa\stest\scase\sfor\sthe\saffinity\sproblem\sreported\sby\sticket\s[93fb9f89d6]. -D 2009-08-13T17:14:59 +C Enhancements\sto\sthe\swhereB.test\sto\scheck\smore\saffinity\scorner\scases. +D 2009-08-13T18:14:32 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in c606c9b502dfde3b9c3b2d23ed49f3737829693b F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -718,7 +718,7 @@ F test/where8.test 8d3704d04a683e792d373005f2e4e13bfd7e2dd5 F test/where8m.test da346596e19d54f0aba35ebade032a7c47d79739 F test/where9.test be19e1a92f80985c1a121b4678bf7d2123eaa623 F test/whereA.test 1d1674254614147c866ab9b59af6582f454a858c -F test/whereB.test 2177e36b7c91ecfa2f93451baaa999f92920e4b9 +F test/whereB.test ea2fef0038214300509711ede09677af4f2afad6 F test/wherelimit.test 5e9fd41e79bb2b2d588ed999d641d9c965619b31 F test/zeroblob.test caaecfb4f908f7bc086ed238668049f96774d688 F tool/diffdb.c 7524b1b5df217c20cd0431f6789851a4e0cb191b @@ -746,14 +746,14 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl 672f81d693a03f80f5ae60bfefacd8a349e76746 -P 86a06dd0494c2fe83d4fde517557600956cedd9e -R 0dee14fd47141ebb408793860d7adc78 +P 149ec24e61437fac2b0dd6239276d3aa543c56cb +R 1ea36fc2c7e0c32d5b2483eec1ce1a06 U drh -Z 12818b10386eaf5266bfaceb670cd6e6 +Z cdd6f1e89b3618add099c3116553394a -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) -iD8DBQFKhEoWoxKgR168RlERApGFAJ4vhn79VZ+xTwID/EoYDATCU6CmYwCfWfLb -UlueAOSuLnKpUnxIxdrIeU8= -=Gh8W +iD8DBQFKhFgLoxKgR168RlERAgjMAJ0e/xokwSjX2hsY3q8mvlUGu+555wCfZL+Z +ThH1uVO4nfptbHxSFohZy1U= +=PHPU -----END PGP SIGNATURE----- diff --git a/manifest.uuid b/manifest.uuid index 1cbc3509c5..74b1ddbe6f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -149ec24e61437fac2b0dd6239276d3aa543c56cb \ No newline at end of file +1048459824746307c9e4296cbc21716bf8b5449d \ No newline at end of file diff --git a/test/whereB.test b/test/whereB.test index fe7e33a646..c6e06e988a 100644 --- a/test/whereB.test +++ b/test/whereB.test @@ -16,100 +16,527 @@ set testdir [file dirname $argv0] source $testdir/tester.tcl +# For this set of tests: +# +# * t1.y holds an integer value with affinity NONE +# * t2.b holds a text value with affinity TEXT +# +# These values are not equal and because neither affinity is NUMERIC +# no type conversion occurs. +# do_test whereB-1.1 { db eval { CREATE TABLE t1(x,y); -- affinity of t1.y is NONE - INSERT INTO t1 VALUES(1,2); - INSERT INTO t1 VALUES(2,7); + INSERT INTO t1 VALUES(1,99); CREATE TABLE t2(a, b TEXT); -- affinity of t2.b is TEXT CREATE INDEX t2b ON t2(b); - INSERT INTO t2 VALUES(11,2); - INSERT INTO t2 VALUES(12,6); + INSERT INTO t2 VALUES(2,99); SELECT x, a, y=b FROM t1, t2 ORDER BY +x, +a; } -} {1 11 0 1 12 0 2 11 0 2 12 0} +} {1 2 0} do_test whereB-1.2 { db eval { - SELECT x, a, y=b FROM t1, t2 WHERE y=b ORDER BY +x, +a; + SELECT x, a, y=b FROM t1, t2 WHERE y=b; } } {} do_test whereB-1.3 { db eval { - SELECT x, a, y=b FROM t1, t2 WHERE b=y ORDER BY +x, +a; + SELECT x, a, y=b FROM t1, t2 WHERE b=y; } } {} do_test whereB-1.4 { db eval { - SELECT x, a, y=b FROM t1, t2 WHERE +y=+b ORDER BY +x, +a; + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; } } {} do_test whereB-1.100 { db eval { DROP INDEX t2b; - SELECT x, a, y=b FROM t1, t2 WHERE y=b ORDER BY +x, +a; + SELECT x, a, y=b FROM t1, t2 WHERE y=b; } } {} do_test whereB-1.101 { db eval { - SELECT x, a, y=b FROM t1, t2 WHERE b=y ORDER BY +x, +a; + SELECT x, a, y=b FROM t1, t2 WHERE b=y; } } {} do_test whereB-1.102 { db eval { - SELECT x, a, y=b FROM t1, t2 WHERE +y=+b ORDER BY +x, +a; + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; } } {} +# For this set of tests: +# +# * t1.y holds a text value with affinity TEXT +# * t2.b holds an integer value with affinity NONE +# +# These values are not equal and because neither affinity is NUMERIC +# no type conversion occurs. +# do_test whereB-2.1 { db eval { DROP TABLE t1; DROP TABLE t2; - CREATE TABLE t1(x,y); -- affinity of t1.y is NONE - INSERT INTO t1 VALUES(1,2); - INSERT INTO t1 VALUES(2,7); + CREATE TABLE t1(x, y TEXT); -- affinity of t1.y is TEXT + INSERT INTO t1 VALUES(1,99); - CREATE TABLE t2(a, b UNKNOWN); -- affinity of t2.b is NUMERIC + CREATE TABLE t2(a, b BLOB); -- affinity of t2.b is NONE CREATE INDEX t2b ON t2(b); - INSERT INTO t2 VALUES(11,2); - INSERT INTO t2 VALUES(12,6); + INSERT INTO t2 VALUES(2,99); SELECT x, a, y=b FROM t1, t2 ORDER BY +x, +a; } -} {1 11 1 1 12 0 2 11 0 2 12 0} +} {1 2 0} do_test whereB-2.2 { db eval { - SELECT x, a, y=b FROM t1, t2 WHERE y=b ORDER BY +x, +a; + SELECT x, a, y=b FROM t1, t2 WHERE y=b; } -} {1 11 1} +} {} do_test whereB-2.3 { db eval { - SELECT x, a, y=b FROM t1, t2 WHERE b=y ORDER BY +x, +a; + SELECT x, a, y=b FROM t1, t2 WHERE b=y; } -} {1 11 1} +} {} do_test whereB-2.4 { db eval { - SELECT x, a, y=b FROM t1, t2 WHERE +y=+b ORDER BY +x, +a; + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; } -} {1 11 1} +} {} do_test whereB-2.100 { db eval { DROP INDEX t2b; - SELECT x, a, y=b FROM t1, t2 WHERE y=b ORDER BY +x, +a; + SELECT x, a, y=b FROM t1, t2 WHERE y=b; } -} {1 11 1} +} {} do_test whereB-2.101 { db eval { - SELECT x, a, y=b FROM t1, t2 WHERE b=y ORDER BY +x, +a; + SELECT x, a, y=b FROM t1, t2 WHERE b=y; } -} {1 11 1} +} {} do_test whereB-2.102 { db eval { - SELECT x, a, y=b FROM t1, t2 WHERE +y=+b ORDER BY +x, +a; + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; + } +} {} + +# For this set of tests: +# +# * t1.y holds a text value with affinity NONE +# * t2.b holds an integer value with affinity NONE +# +# These values are not equal and because neither affinity is NUMERIC +# no type conversion occurs. +# +do_test whereB-3.1 { + db eval { + DROP TABLE t1; + DROP TABLE t2; + + CREATE TABLE t1(x, y BLOB); -- affinity of t1.y is NONE + INSERT INTO t1 VALUES(1,2); + + CREATE TABLE t2(a, b BLOB); -- affinity of t2.b is NONE + CREATE INDEX t2b ON t2(b); + INSERT INTO t2 VALUES(11,'2'); + + SELECT x, a, y=b FROM t1, t2; + } +} {1 11 0} +do_test whereB-3.2 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE y=b; + } +} {} +do_test whereB-3.3 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE b=y; + } +} {} +do_test whereB-3.4 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; + } +} {} +do_test whereB-3.100 { + db eval { + DROP INDEX t2b; + SELECT x, a, y=b FROM t1, t2 WHERE y=b; + } +} {} +do_test whereB-3.101 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE b=y; + } +} {} +do_test whereB-3.102 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; + } +} {} + + +# For this set of tests: +# +# * t1.y holds a text value with affinity NONE +# * t2.b holds an integer value with affinity NUMERIC +# +# Because t2.b has a numeric affinity, type conversion should occur +# and the two fields should be equal. +# +do_test whereB-4.1 { + db eval { + DROP TABLE t1; + DROP TABLE t2; + + CREATE TABLE t1(x, y BLOB); -- affinity of t1.y is NONE + INSERT INTO t1 VALUES(1,'99'); + + CREATE TABLE t2(a, b NUMERIC); -- affinity of t2.b is NUMERIC + CREATE INDEX t2b ON t2(b); + INSERT INTO t2 VALUES(2,99); + + SELECT x, a, y=b FROM t1, t2; + } +} {1 2 1} +do_test whereB-4.2 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE y=b; + } +} {1 2 1} +do_test whereB-4.3 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE b=y; + } +} {1 2 1} +do_test whereB-4.4 { + # In this case the unary "+" operator removes the column affinity so + # the columns compare false + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; + } +} {} +do_test whereB-4.100 { + db eval { + DROP INDEX t2b; + SELECT x, a, y=b FROM t1, t2 WHERE y=b; + } +} {1 2 1} +do_test whereB-4.101 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE b=y; + } +} {1 2 1} +do_test whereB-4.102 { + # In this case the unary "+" operator removes the column affinity so + # the columns compare false + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; + } +} {} + + + +# For this set of tests: +# +# * t1.y holds a text value with affinity NONE +# * t2.b holds an integer value with affinity INTEGER +# +# Because t2.b has a numeric affinity, type conversion should occur +# and the two fields should be equal. +# +do_test whereB-5.1 { + db eval { + DROP TABLE t1; + DROP TABLE t2; + + CREATE TABLE t1(x, y BLOB); -- affinity of t1.y is NONE + INSERT INTO t1 VALUES(1,'99'); + + CREATE TABLE t2(a, b INT); -- affinity of t2.b is INTEGER + CREATE INDEX t2b ON t2(b); + INSERT INTO t2 VALUES(2,99); + + SELECT x, a, y=b FROM t1, t2; + } +} {1 2 1} +do_test whereB-5.2 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE y=b; + } +} {1 2 1} +do_test whereB-5.3 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE b=y; + } +} {1 2 1} +do_test whereB-5.4 { + # In this case the unary "+" operator removes the column affinity so + # the columns compare false + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; } -} {1 11 1} +} {} +do_test whereB-5.100 { + db eval { + DROP INDEX t2b; + SELECT x, a, y=b FROM t1, t2 WHERE y=b; + } +} {1 2 1} +do_test whereB-5.101 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE b=y; + } +} {1 2 1} +do_test whereB-5.102 { + # In this case the unary "+" operator removes the column affinity so + # the columns compare false + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; + } +} {} + + +# For this set of tests: +# +# * t1.y holds a text value with affinity NONE +# * t2.b holds an integer value with affinity REAL +# +# Because t2.b has a numeric affinity, type conversion should occur +# and the two fields should be equal. +# +do_test whereB-6.1 { + db eval { + DROP TABLE t1; + DROP TABLE t2; + + CREATE TABLE t1(x, y BLOB); -- affinity of t1.y is NONE + INSERT INTO t1 VALUES(1,'99'); + + CREATE TABLE t2(a, b REAL); -- affinity of t2.b is REAL + CREATE INDEX t2b ON t2(b); + INSERT INTO t2 VALUES(2,99.0); + + SELECT x, a, y=b FROM t1, t2; + } +} {1 2 1} +do_test whereB-6.2 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE y=b; + } +} {1 2 1} +do_test whereB-6.3 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE b=y; + } +} {1 2 1} +do_test whereB-6.4 { + # In this case the unary "+" operator removes the column affinity so + # the columns compare false + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; + } +} {} +do_test whereB-6.100 { + db eval { + DROP INDEX t2b; + SELECT x, a, y=b FROM t1, t2 WHERE y=b; + } +} {1 2 1} +do_test whereB-6.101 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE b=y; + } +} {1 2 1} +do_test whereB-6.102 { + # In this case the unary "+" operator removes the column affinity so + # the columns compare false + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; + } +} {} + + +# For this set of tests: +# +# * t1.y holds an integer value with affinity NUMERIC +# * t2.b holds a text value with affinity NONE +# +# Because t1.y has a numeric affinity, type conversion should occur +# and the two fields should be equal. +# +do_test whereB-7.1 { + db eval { + DROP TABLE t1; + DROP TABLE t2; + + CREATE TABLE t1(x, y NUMERIC); -- affinity of t1.y is NUMERIC + INSERT INTO t1 VALUES(1,99); + + CREATE TABLE t2(a, b BLOB); -- affinity of t2.b is NONE + CREATE INDEX t2b ON t2(b); + INSERT INTO t2 VALUES(2,'99'); + + SELECT x, a, y=b FROM t1, t2; + } +} {1 2 1} +do_test whereB-7.2 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE y=b; + } +} {1 2 1} +do_test whereB-7.3 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE b=y; + } +} {1 2 1} +do_test whereB-7.4 { + # In this case the unary "+" operator removes the column affinity so + # the columns compare false + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; + } +} {} +do_test whereB-7.100 { + db eval { + DROP INDEX t2b; + SELECT x, a, y=b FROM t1, t2 WHERE y=b; + } +} {1 2 1} +do_test whereB-7.101 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE b=y; + } +} {1 2 1} +do_test whereB-7.102 { + # In this case the unary "+" operator removes the column affinity so + # the columns compare false + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; + } +} {} + +# For this set of tests: +# +# * t1.y holds an integer value with affinity INTEGER +# * t2.b holds a text value with affinity NONE +# +# Because t1.y has a numeric affinity, type conversion should occur +# and the two fields should be equal. +# +do_test whereB-8.1 { + db eval { + DROP TABLE t1; + DROP TABLE t2; + + CREATE TABLE t1(x, y INT); -- affinity of t1.y is INTEGER + INSERT INTO t1 VALUES(1,99); + + CREATE TABLE t2(a, b BLOB); -- affinity of t2.b is NONE + CREATE INDEX t2b ON t2(b); + INSERT INTO t2 VALUES(2,'99'); + + SELECT x, a, y=b FROM t1, t2; + } +} {1 2 1} +do_test whereB-8.2 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE y=b; + } +} {1 2 1} +do_test whereB-8.3 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE b=y; + } +} {1 2 1} +do_test whereB-8.4 { + # In this case the unary "+" operator removes the column affinity so + # the columns compare false + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; + } +} {} +do_test whereB-8.100 { + db eval { + DROP INDEX t2b; + SELECT x, a, y=b FROM t1, t2 WHERE y=b; + } +} {1 2 1} +do_test whereB-8.101 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE b=y; + } +} {1 2 1} +do_test whereB-8.102 { + # In this case the unary "+" operator removes the column affinity so + # the columns compare false + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; + } +} {} + +# For this set of tests: +# +# * t1.y holds an integer value with affinity REAL +# * t2.b holds a text value with affinity NONE +# +# Because t1.y has a numeric affinity, type conversion should occur +# and the two fields should be equal. +# +do_test whereB-9.1 { + db eval { + DROP TABLE t1; + DROP TABLE t2; + + CREATE TABLE t1(x, y REAL); -- affinity of t1.y is REAL + INSERT INTO t1 VALUES(1,99.0); + + CREATE TABLE t2(a, b BLOB); -- affinity of t2.b is NONE + CREATE INDEX t2b ON t2(b); + INSERT INTO t2 VALUES(2,'99'); + + SELECT x, a, y=b FROM t1, t2; + } +} {1 2 1} +do_test whereB-9.2 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE y=b; + } +} {1 2 1} +do_test whereB-9.3 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE b=y; + } +} {1 2 1} +do_test whereB-9.4 { + # In this case the unary "+" operator removes the column affinity so + # the columns compare false + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; + } +} {} +do_test whereB-9.100 { + db eval { + DROP INDEX t2b; + SELECT x, a, y=b FROM t1, t2 WHERE y=b; + } +} {1 2 1} +do_test whereB-9.101 { + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE b=y; + } +} {1 2 1} +do_test whereB-9.102 { + # In this case the unary "+" operator removes the column affinity so + # the columns compare false + db eval { + SELECT x, a, y=b FROM t1, t2 WHERE +y=+b; + } +} {} +