author | sl@SLION-WIN7.fritz.box |
Fri, 15 Jun 2012 03:10:57 +0200 | |
changeset 0 | bde4ae8d615e |
permissions | -rw-r--r-- |
sl@0 | 1 |
# |
sl@0 | 2 |
# 2007 June 20 |
sl@0 | 3 |
# |
sl@0 | 4 |
# The author disclaims copyright to this source code. In place of |
sl@0 | 5 |
# a legal notice, here is a blessing: |
sl@0 | 6 |
# |
sl@0 | 7 |
# May you do good and not evil. |
sl@0 | 8 |
# May you find forgiveness for yourself and forgive others. |
sl@0 | 9 |
# May you share freely, never taking more than you give. |
sl@0 | 10 |
# |
sl@0 | 11 |
#*********************************************************************** |
sl@0 | 12 |
# This file implements regression tests for SQLite library. The |
sl@0 | 13 |
# focus of this script is making sure collations pass through the |
sl@0 | 14 |
# unary + operator. |
sl@0 | 15 |
# |
sl@0 | 16 |
# $Id: collate8.test,v 1.2 2008/08/25 12:14:09 drh Exp $ |
sl@0 | 17 |
|
sl@0 | 18 |
set testdir [file dirname $argv0] |
sl@0 | 19 |
source $testdir/tester.tcl |
sl@0 | 20 |
|
sl@0 | 21 |
do_test collate8-1.1 { |
sl@0 | 22 |
execsql { |
sl@0 | 23 |
CREATE TABLE t1(a TEXT COLLATE nocase); |
sl@0 | 24 |
INSERT INTO t1 VALUES('aaa'); |
sl@0 | 25 |
INSERT INTO t1 VALUES('BBB'); |
sl@0 | 26 |
INSERT INTO t1 VALUES('ccc'); |
sl@0 | 27 |
INSERT INTO t1 VALUES('DDD'); |
sl@0 | 28 |
SELECT a FROM t1 ORDER BY a; |
sl@0 | 29 |
} |
sl@0 | 30 |
} {aaa BBB ccc DDD} |
sl@0 | 31 |
do_test collate8-1.2 { |
sl@0 | 32 |
execsql { |
sl@0 | 33 |
SELECT rowid FROM t1 WHERE a<'ccc' ORDER BY 1 |
sl@0 | 34 |
} |
sl@0 | 35 |
} {1 2} |
sl@0 | 36 |
do_test collate8-1.3 { |
sl@0 | 37 |
execsql { |
sl@0 | 38 |
SELECT rowid FROM t1 WHERE a<'ccc' COLLATE binary ORDER BY 1 |
sl@0 | 39 |
} |
sl@0 | 40 |
} {1 2 4} |
sl@0 | 41 |
do_test collate8-1.4 { |
sl@0 | 42 |
execsql { |
sl@0 | 43 |
SELECT rowid FROM t1 WHERE +a<'ccc' ORDER BY 1 |
sl@0 | 44 |
} |
sl@0 | 45 |
} {1 2} |
sl@0 | 46 |
do_test collate8-1.5 { |
sl@0 | 47 |
execsql { |
sl@0 | 48 |
SELECT a FROM t1 ORDER BY +a |
sl@0 | 49 |
} |
sl@0 | 50 |
} {aaa BBB ccc DDD} |
sl@0 | 51 |
do_test collate8-1.11 { |
sl@0 | 52 |
execsql { |
sl@0 | 53 |
SELECT a AS x FROM t1 ORDER BY "x"; |
sl@0 | 54 |
} |
sl@0 | 55 |
} {aaa BBB ccc DDD} |
sl@0 | 56 |
do_test collate8-1.12 { |
sl@0 | 57 |
execsql { |
sl@0 | 58 |
SELECT a AS x FROM t1 WHERE x<'ccc' ORDER BY 1 |
sl@0 | 59 |
} |
sl@0 | 60 |
} {aaa BBB} |
sl@0 | 61 |
do_test collate8-1.13 { |
sl@0 | 62 |
execsql { |
sl@0 | 63 |
SELECT a AS x FROM t1 WHERE x<'ccc' COLLATE binary ORDER BY [x] |
sl@0 | 64 |
} |
sl@0 | 65 |
} {aaa BBB DDD} |
sl@0 | 66 |
do_test collate8-1.14 { |
sl@0 | 67 |
execsql { |
sl@0 | 68 |
SELECT a AS x FROM t1 WHERE +x<'ccc' ORDER BY 1 |
sl@0 | 69 |
} |
sl@0 | 70 |
} {aaa BBB} |
sl@0 | 71 |
do_test collate8-1.15 { |
sl@0 | 72 |
execsql { |
sl@0 | 73 |
SELECT a AS x FROM t1 ORDER BY +x |
sl@0 | 74 |
} |
sl@0 | 75 |
} {aaa BBB ccc DDD} |
sl@0 | 76 |
|
sl@0 | 77 |
|
sl@0 | 78 |
# When a result-set column is aliased into a WHERE clause, make sure the |
sl@0 | 79 |
# collating sequence logic works correctly. |
sl@0 | 80 |
# |
sl@0 | 81 |
do_test collate8-2.1 { |
sl@0 | 82 |
execsql { |
sl@0 | 83 |
CREATE TABLE t2(a); |
sl@0 | 84 |
INSERT INTO t2 VALUES('abc'); |
sl@0 | 85 |
INSERT INTO t2 VALUES('ABC'); |
sl@0 | 86 |
SELECT a AS x FROM t2 WHERE x='abc'; |
sl@0 | 87 |
} |
sl@0 | 88 |
} {abc} |
sl@0 | 89 |
do_test collate8-2.2 { |
sl@0 | 90 |
execsql { |
sl@0 | 91 |
SELECT a AS x FROM t2 WHERE x='abc' COLLATE nocase; |
sl@0 | 92 |
} |
sl@0 | 93 |
} {abc ABC} |
sl@0 | 94 |
do_test collate8-2.3 { |
sl@0 | 95 |
execsql { |
sl@0 | 96 |
SELECT a AS x FROM t2 WHERE (x COLLATE nocase)='abc'; |
sl@0 | 97 |
} |
sl@0 | 98 |
} {abc ABC} |
sl@0 | 99 |
do_test collate8-2.4 { |
sl@0 | 100 |
execsql { |
sl@0 | 101 |
SELECT a COLLATE nocase AS x FROM t2 WHERE x='abc'; |
sl@0 | 102 |
} |
sl@0 | 103 |
} {abc ABC} |
sl@0 | 104 |
do_test collate8-2.5 { |
sl@0 | 105 |
execsql { |
sl@0 | 106 |
SELECT a COLLATE nocase AS x FROM t2 WHERE (x COLLATE binary)='abc'; |
sl@0 | 107 |
} |
sl@0 | 108 |
} {abc} |
sl@0 | 109 |
do_test collate8-2.6 { |
sl@0 | 110 |
execsql { |
sl@0 | 111 |
SELECT a COLLATE nocase AS x FROM t2 WHERE x='abc' COLLATE binary; |
sl@0 | 112 |
} |
sl@0 | 113 |
} {abc ABC} |
sl@0 | 114 |
do_test collate8-2.7 { |
sl@0 | 115 |
execsql { |
sl@0 | 116 |
SELECT * FROM t2 WHERE (a COLLATE nocase)='abc' COLLATE binary; |
sl@0 | 117 |
} |
sl@0 | 118 |
} {abc ABC} |
sl@0 | 119 |
do_test collate8-2.8 { |
sl@0 | 120 |
execsql { |
sl@0 | 121 |
SELECT a COLLATE nocase AS x FROM t2 WHERE 'abc'=x COLLATE binary; |
sl@0 | 122 |
} |
sl@0 | 123 |
} {abc} |
sl@0 | 124 |
|
sl@0 | 125 |
finish_test |