1
0
mirror of https://github.com/sqlite/sqlite.git synced 2025-08-01 06:27:03 +03:00

Fix datatype reporting and collating sequence selection so that it works

correctly on views and with the UNION, EXCEPT, and INTERCEPT operators. (CVS 839)

FossilOrigin-Name: 71cc292dce59cf8224b205d1cdbff59ad12f1043
This commit is contained in:
drh
2003-01-18 20:11:05 +00:00
parent be4f31c226
commit fcb78a4900
13 changed files with 299 additions and 96 deletions

View File

@ -13,7 +13,7 @@
# This file implements tests for miscellanous features that were
# left out of other test files.
#
# $Id: misc1.test,v 1.17 2002/12/07 21:45:14 drh Exp $
# $Id: misc1.test,v 1.18 2003/01/18 20:11:07 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -376,11 +376,16 @@ do_test misc1-12.9 {
SELECT min(z), max(z), count(z) FROM t7 GROUP BY y ORDER BY 1;
}
} {1 2 2 3 4 2}
# This used to be an error. But we changed the code so that arbitrary
# identifiers can be used as a collating sequence. Collation is by text
# if the identifier contains "text", "blob", or "clob" and is numeric
# otherwise.
do_test misc1-12.10 {
catchsql {
SELECT * FROM t6 ORDER BY a COLLATE unknown;
}
} {1 {unknown collating type: unknown}}
} {0 {0 0.0 y 0}}
do_test misc1-12.11 {
execsql {
CREATE TABLE t8(x TEXT COLLATE numeric, y INTEGER COLLATE text, z);

View File

@ -12,7 +12,7 @@
#
# This file implements tests for the PRAGMA command.
#
# $Id: pragma.test,v 1.2 2003/01/11 14:19:52 drh Exp $
# $Id: pragma.test,v 1.3 2003/01/18 20:11:07 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -129,7 +129,7 @@ do_test pragma-1.12 {
PRAGMA empty_result_callbacks=on;
}
sqlite_datatypes $::DB {SELECT * FROM sqlite_master}
} {NUMERIC NUMERIC NUMERIC NUMERIC NUMERIC}
} {text text text integer text}
do_test pragma-1.13 {
execsql {
CREATE TABLE t1(
@ -143,7 +143,7 @@ do_test pragma-1.13 {
);
}
sqlite_datatypes $::DB {SELECT * FROM t1}
} {NUMERIC TEXT NUMERIC TEXT TEXT TEXT TEXT}
} {INTEGER TEXT WHATEVER CLOB BLOB VARCHAR(123) nVaRcHaR(432)}
do_test pragma-1.14 {
sqlite_datatypes $::DB {
SELECT 1, 'hello', NULL
@ -154,6 +154,33 @@ do_test pragma-1.15 {
SELECT 1+2 AS X, 'hello' || 5 AS Y, NULL AS Z
}
} {NUMERIC TEXT TEXT}
do_test pragma-1.16 {
execsql {
CREATE VIEW v1 AS SELECT a+b, b||c, * FROM t1;
}
sqlite_datatypes $::DB {SELECT * FROM v1}
} {NUMERIC TEXT INTEGER TEXT WHATEVER CLOB BLOB VARCHAR(123) nVaRcHaR(432)}
do_test pragma-1.17 {
sqlite_datatypes $::DB {
SELECT d,e FROM t1 UNION SELECT a,c FROM t1
}
} {INTEGER WHATEVER}
do_test pragma-1.18 {
sqlite_datatypes $::DB {
SELECT d,e FROM t1 EXCEPT SELECT c,e FROM t1
}
} {WHATEVER BLOB}
do_test pragma-1.19 {
sqlite_datatypes $::DB {
SELECT d,e FROM t1 INTERSECT SELECT c,e FROM t1
}
} {WHATEVER BLOB}
do_test pragma-1.20 {
sqlite_datatypes $::DB {
SELECT d,e FROM t1 INTERSECT SELECT c,e FROM v1
}
} {WHATEVER BLOB}
finish_test

View File

@ -11,7 +11,7 @@
# This file implements regression tests for SQLite library. The
# focus of this file is testing the CREATE TABLE statement.
#
# $Id: sort.test,v 1.7 2002/08/26 19:55:11 drh Exp $
# $Id: sort.test,v 1.8 2003/01/18 20:11:07 drh Exp $
set testdir [file dirname $argv0]
source $testdir/tester.tcl
@ -267,4 +267,84 @@ do_test sort-6.4 {
}
} {4 1 6 5 3 2}
do_test sort-7.1 {
execsql {
CREATE TABLE t4(
a INTEGER,
b VARCHAR(30)
);
INSERT INTO t4 VALUES(1,1);
INSERT INTO t4 VALUES(2,2);
INSERT INTO t4 VALUES(11,11);
INSERT INTO t4 VALUES(12,12);
SELECT a FROM t4 ORDER BY 1;
}
} {1 2 11 12}
do_test sort-7.2 {
execsql {
SELECT b FROM t4 ORDER BY 1
}
} {1 11 12 2}
do_test sort-7.3 {
execsql {
CREATE VIEW v4 AS SELECT * FROM t4;
SELECT a FROM v4 ORDER BY 1;
}
} {1 2 11 12}
do_test sort-7.4 {
execsql {
SELECT b FROM v4 ORDER BY 1;
}
} {1 11 12 2}
do_test sort-7.5 {
execsql {
SELECT a FROM t4 UNION SELECT a FROM v4 ORDER BY 1;
}
} {1 2 11 12}
do_test sort-7.6 {
execsql {
SELECT b FROM t4 UNION SELECT a FROM v4 ORDER BY 1;
}
} {1 2 11 12}
do_test sort-7.7 {
execsql {
SELECT a FROM t4 UNION SELECT b FROM v4 ORDER BY 1;
}
} {1 2 11 12}
do_test sort-7.8 {
execsql {
SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1;
}
} {1 11 12 2}
do_test sort-7.9 {
execsql {
SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE numeric;
}
} {1 2 11 12}
do_test sort-7.10 {
execsql {
SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE integer;
}
} {1 2 11 12}
do_test sort-7.11 {
execsql {
SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE text;
}
} {1 11 12 2}
do_test sort-7.12 {
execsql {
SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE blob;
}
} {1 11 12 2}
do_test sort-7.13 {
execsql {
SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE clob;
}
} {1 11 12 2}
do_test sort-7.14 {
execsql {
SELECT b FROM t4 UNION SELECT b FROM v4 ORDER BY 1 COLLATE varchar;
}
} {1 11 12 2}
finish_test