From e83c4f3a9e2c2fb48ddd2d18446b813b07714da3 Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 21 Sep 2009 16:34:24 +0000 Subject: [PATCH] Fix compilation with both OMIT_UTF16 and ENABLE_STAT2 defined. Ticket [56928bd084ea530eb8a0b3ebe5d2d9033fb1de7f|56928bd084]. FossilOrigin-Name: cd850d49a12a2852258cbd7d5db56715132dff17 --- manifest | 14 ++++----- manifest.uuid | 2 +- src/where.c | 9 ++++-- test/analyze2.test | 74 ++++++++++++++++++++++++---------------------- 4 files changed, 52 insertions(+), 47 deletions(-) diff --git a/manifest b/manifest index 44c01c515e..8bac991d11 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\scompilation\swith\sOMIT_TRIGGER\sdefined.\sTicket\s[1ff6d29030e9757d052af0f394e56bea96b8b59b|1ff6d29030]. -D 2009-09-21T16:06:04 +C Fix\scompilation\swith\sboth\sOMIT_UTF16\sand\sENABLE_STAT2\sdefined.\sTicket\s[56928bd084ea530eb8a0b3ebe5d2d9033fb1de7f|56928bd084]. +D 2009-09-21T16:34:24 F Makefile.arm-wince-mingw32ce-gcc fcd5e9cd67fe88836360bb4f9ef4cb7f8e2fb5a0 F Makefile.in 4ca3f1dd6efa2075bcb27f4dc43eef749877740d F Makefile.linux-gcc d53183f4aa6a9192d249731c90dbdffbd2c68654 @@ -215,7 +215,7 @@ F src/vdbeblob.c 3ba0f7ba1b3afce2d37a18e4f437992d430f0eae F src/vdbemem.c 0ff2b209fccade3ff6709286057b82ed7f6c1e70 F src/vtab.c 3e54fe39374e5feb8b174de32a90e7a21966025d F src/walker.c 1edca756275f158b80f20eb6f104c8d3fcc96a04 -F src/where.c 68db8ab9b465f595043d05ff697b953268485df4 +F src/where.c 53e2620985fc691b62e811cb25c46cd6f4dd7f77 F test/aggerror.test a867e273ef9e3d7919f03ef4f0e8c0d2767944f2 F test/alias.test 4529fbc152f190268a15f9384a5651bbbabc9d87 F test/all.test 14165b3e32715b700b5f0cbf8f6e3833dda0be45 @@ -225,7 +225,7 @@ F test/alter3.test 25b95a136708f22b87184fa6a4309eea03d65153 F test/alter4.test 9386ffd1e9c7245f43eca412b2058d747509cc1f F test/altermalloc.test e81ac9657ed25c6c5bb09bebfa5a047cd8e4acfc F test/analyze.test ad5329098fe4de4a96852231d53e3e9e6283ad4b -F test/analyze2.test 297d3d63f2f50976c606227040fe36605745d9dd +F test/analyze2.test a2ad7b0a4e13801ee3968fe70f22aff52326569c F test/async.test 8c75d31b8330f8b70cf2571b014d4476a063efdb F test/async2.test bf5e2ca2c96763b4cba3d016249ad7259a5603b6 F test/async3.test 93edaa9122f498e56ea98c36c72abc407f4fb11e @@ -752,7 +752,7 @@ F tool/speedtest2.tcl ee2149167303ba8e95af97873c575c3e0fab58ff F tool/speedtest8.c 2902c46588c40b55661e471d7a86e4dd71a18224 F tool/speedtest8inst1.c 293327bc76823f473684d589a8160bde1f52c14e F tool/vdbe-compress.tcl d70ea6d8a19e3571d7ab8c9b75cba86d1173ff0f -P aab7a4b3c91e0a149f6499660892d09c17b010e3 -R eef3003df0ef45e48c1734d43e99f3d8 +P fb6ceed388f6d75bdc2ac2f43e5c98da74e2a448 +R 899a06e4349a5ceabc5fe389e0c0c2ac U dan -Z b8e6deab4beb9073bd74dfe36506533c +Z 4dbd21536703b59a6c4c05ce1d53ee70 diff --git a/manifest.uuid b/manifest.uuid index 8ccad2fd9f..db528ce92f 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -fb6ceed388f6d75bdc2ac2f43e5c98da74e2a448 \ No newline at end of file +cd850d49a12a2852258cbd7d5db56715132dff17 \ No newline at end of file diff --git a/src/where.c b/src/where.c index 702bdaf035..c67a56964e 100644 --- a/src/where.c +++ b/src/where.c @@ -1956,9 +1956,8 @@ static int whereRangeRegion( int eSampletype = aSample[i].eType; if( eSampletype==SQLITE_NULL || eSampletypeenc==SQLITE_UTF8 ){ - r = pColl->xCmp(pColl->pUser, aSample[i].nByte, aSample[i].u.z, n, z); - }else{ +#ifndef SQLITE_OMIT_UTF16 + if( pColl->enc!=SQLITE_UTF8 ){ int nSample; char *zSample = sqlite3Utf8to16( db, pColl->enc, aSample[i].u.z, aSample[i].nByte, &nSample @@ -1969,6 +1968,10 @@ static int whereRangeRegion( } r = pColl->xCmp(pColl->pUser, nSample, zSample, n, z); sqlite3DbFree(db, zSample); + }else +#endif + { + r = pColl->xCmp(pColl->pUser, aSample[i].nByte, aSample[i].u.z, n, z); } if( r>0 ) break; } diff --git a/test/analyze2.test b/test/analyze2.test index 84cd76bceb..b149fe068b 100644 --- a/test/analyze2.test +++ b/test/analyze2.test @@ -227,42 +227,44 @@ do_test analyze2-4.5 { eqp "SELECT * FROM t3 WHERE a > 'A' AND a < 'c' AND b > 'A' AND b < 'c'" } {0 0 {TABLE t3 WITH INDEX t3a}} -proc test_collate {enc lhs rhs} { - # puts $enc - return [string compare $lhs $rhs] +ifcapable utf16 { + proc test_collate {enc lhs rhs} { + # puts $enc + return [string compare $lhs $rhs] + } + do_test analyze2-5.1 { + add_test_collate db 0 0 1 + execsql { CREATE TABLE t4(x COLLATE test_collate) } + execsql { CREATE INDEX t4x ON t4(x) } + set alphabet [list a b c d e f g h i j] + execsql BEGIN + for {set i 0} {$i < 1000} {incr i} { + set str [lindex $alphabet [expr ($i/100)%10]] + append str [lindex $alphabet [expr ($i/ 10)%10]] + append str [lindex $alphabet [expr ($i/ 1)%10]] + execsql { INSERT INTO t4 VALUES($str) } + } + execsql COMMIT + execsql ANALYZE + } {} + do_test analyze2-5.2 { + execsql { + SELECT tbl,idx,group_concat(sample,' ') + FROM sqlite_stat2 + WHERE tbl = 't4' + GROUP BY tbl,idx + } + } {t4 t4x {afa bej cej dej eej fej gej hej iej jej}} + do_test analyze2-5.3 { + eqp "SELECT * FROM t4 WHERE x>'ccc'" + } {0 0 {TABLE t4 WITH INDEX t4x}} + do_test analyze2-5.4 { + eqp "SELECT * FROM t4 AS t41, t4 AS t42 WHERE t41.x>'ccc' AND t42.x>'ggg'" + } {0 1 {TABLE t4 AS t42 WITH INDEX t4x} 1 0 {TABLE t4 AS t41 WITH INDEX t4x}} + do_test analyze2-5.5 { + eqp "SELECT * FROM t4 AS t41, t4 AS t42 WHERE t41.x>'ddd' AND t42.x>'ccc'" + } {0 0 {TABLE t4 AS t41 WITH INDEX t4x} 1 1 {TABLE t4 AS t42 WITH INDEX t4x}} } -do_test analyze2-5.1 { - add_test_collate db 0 0 1 - execsql { CREATE TABLE t4(x COLLATE test_collate) } - execsql { CREATE INDEX t4x ON t4(x) } - set alphabet [list a b c d e f g h i j] - execsql BEGIN - for {set i 0} {$i < 1000} {incr i} { - set str [lindex $alphabet [expr ($i/100)%10]] - append str [lindex $alphabet [expr ($i/ 10)%10]] - append str [lindex $alphabet [expr ($i/ 1)%10]] - execsql { INSERT INTO t4 VALUES($str) } - } - execsql COMMIT - execsql ANALYZE -} {} -do_test analyze2-5.2 { - execsql { - SELECT tbl,idx,group_concat(sample,' ') - FROM sqlite_stat2 - WHERE tbl = 't4' - GROUP BY tbl,idx - } -} {t4 t4x {afa bej cej dej eej fej gej hej iej jej}} -do_test analyze2-5.3 { - eqp "SELECT * FROM t4 WHERE x>'ccc'" -} {0 0 {TABLE t4 WITH INDEX t4x}} -do_test analyze2-5.4 { - eqp "SELECT * FROM t4 AS t41, t4 AS t42 WHERE t41.x>'ccc' AND t42.x>'ggg'" -} {0 1 {TABLE t4 AS t42 WITH INDEX t4x} 1 0 {TABLE t4 AS t41 WITH INDEX t4x}} -do_test analyze2-5.5 { - eqp "SELECT * FROM t4 AS t41, t4 AS t42 WHERE t41.x>'ddd' AND t42.x>'ccc'" -} {0 0 {TABLE t4 AS t41 WITH INDEX t4x} 1 1 {TABLE t4 AS t42 WITH INDEX t4x}} #-------------------------------------------------------------------- # These tests, analyze2-6.*, verify that the library behaves correctly @@ -278,7 +280,7 @@ do_test analyze2-5.5 { # do_test analyze2-6.0 { execsql { - DROP TABLE t4; + DROP TABLE IF EXISTS t4; CREATE TABLE t5(a, b); CREATE INDEX t5i ON t5(a, b); CREATE TABLE t6(a, b); CREATE INDEX t6i ON t6(a, b); }