]> granicus.if.org Git - postgresql/commitdiff
Add test case for collation mismatch in recursive query
authorPeter Eisentraut <peter_e@gmx.net>
Sat, 12 Mar 2011 08:07:23 +0000 (10:07 +0200)
committerPeter Eisentraut <peter_e@gmx.net>
Sat, 12 Mar 2011 08:07:23 +0000 (10:07 +0200)
This isn't very important by itself, but was left on my list of things
without test coverage for the collation feature.

src/test/regress/expected/collate.linux.utf8.out
src/test/regress/sql/collate.linux.utf8.sql

index 53595b6e10cfcad895f7bb1ec323f9e8f112b759..46a8207b7e07aa39ea76a0637f7b061bdc472e7c 100644 (file)
@@ -630,6 +630,16 @@ HINT:  You can override the collation by applying the COLLATE clause to one or b
 CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3; -- fail
 ERROR:  no collation was derived for column "b" with collatable type text
 HINT:  Use the COLLATE clause to set the collation explicitly.
+-- collation mismatch between recursive and non-recursive term
+WITH RECURSIVE foo(x) AS
+   (SELECT x FROM (VALUES('a' COLLATE "en_US"),('b')) t(x)
+   UNION ALL
+   SELECT (x || 'c') COLLATE "de_DE" FROM foo WHERE length(x) < 10)
+SELECT * FROM foo;
+ERROR:  recursive query "foo" column 1 has collation "en_US" in non-recursive term but collation "de_DE" overall
+LINE 2:    (SELECT x FROM (VALUES('a' COLLATE "en_US"),('b')) t(x)
+                   ^
+HINT:  Use the COLLATE clause to set the collation of the non-recursive term.
 -- casting
 SELECT CAST('42' AS text COLLATE "C");
 ERROR:  syntax error at or near "COLLATE"
index c70e5cefd5fca248edea7b7b1ae2e70c6aab2740..55af5091bc02b0d5bceb98c3d7eb52693b219f8a 100644 (file)
@@ -190,6 +190,13 @@ SELECT a, b FROM collate_test1 EXCEPT SELECT a, b FROM collate_test3 ORDER BY 2;
 
 CREATE TABLE test_u AS SELECT a, b FROM collate_test1 UNION ALL SELECT a, b FROM collate_test3; -- fail
 
+-- collation mismatch between recursive and non-recursive term
+WITH RECURSIVE foo(x) AS
+   (SELECT x FROM (VALUES('a' COLLATE "en_US"),('b')) t(x)
+   UNION ALL
+   SELECT (x || 'c') COLLATE "de_DE" FROM foo WHERE length(x) < 10)
+SELECT * FROM foo;
+
 
 -- casting