aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2013-07-03 12:24:26 -0400
committerRobert Haas <rhaas@postgresql.org>2013-07-03 12:31:27 -0400
commit263645305b8f14a3821e04dffa96fa7c1bc2ae86 (patch)
tree4859864f7c45fb2e37999ba89a3b5c672c9a9acf /src
parent5530a826434a8d4bc6ba7387d05aa14755406199 (diff)
downloadpostgresql-263645305b8f14a3821e04dffa96fa7c1bc2ae86.tar.gz
postgresql-263645305b8f14a3821e04dffa96fa7c1bc2ae86.zip
Hopefully-portable regression tests for CREATE/ALTER/DROP COLLATION.
The collate.linux.utf8 test covers some of the same territory, but isn't portable and so probably does not get run often, or on non-Linux platforms. If this approach turns out to be sufficiently portable, we may want to look at trimming the redundant tests out of that file to avoid duplication. Robins Tharakan, reviewed by Michael Paquier and Fabien Coelho, with further changes and cleanup by me.
Diffstat (limited to 'src')
-rw-r--r--src/test/regress/expected/collate.out46
-rw-r--r--src/test/regress/sql/collate.sql45
2 files changed, 91 insertions, 0 deletions
diff --git a/src/test/regress/expected/collate.out b/src/test/regress/expected/collate.out
index 91d574dbe4c..59cfb6811c6 100644
--- a/src/test/regress/expected/collate.out
+++ b/src/test/regress/expected/collate.out
@@ -626,6 +626,51 @@ SELECT collation for ((SELECT b FROM collate_test1 LIMIT 1));
"C"
(1 row)
+-- CREATE COLLATE tests
+CREATE COLLATION collate_coll2 FROM "C";
+-- Ensure non-OWNER ROLEs are not able to ALTER/DROP COLLATION
+CREATE ROLE regress_rol_col1;
+GRANT USAGE ON SCHEMA collate_tests TO regress_rol_col1;
+SET ROLE regress_rol_col1;
+DROP COLLATION IF EXISTS collate_tests.collate_coll2;
+ERROR: must be owner of collation collate_tests.collate_coll2
+RESET ROLE;
+-- Ensure ALTER COLLATION SET SCHEMA works as expected
+CREATE SCHEMA collate_tests2;
+ALTER COLLATION collate_coll2 SET SCHEMA collate_tests2;
+DROP COLLATION collate_tests2.collate_coll2;
+DROP SCHEMA collate_tests2;
+-- Should work. Classic cases of CREATE/ALTER COLLATION
+CREATE COLLATION collate_coll3 (LOCALE = 'C');
+ALTER COLLATION collate_coll3 OWNER TO regress_rol_col1;
+ALTER COLLATION collate_coll3 RENAME TO collate_coll33;
+DROP COLLATION collate_coll33;
+-- Should fail. Give redundant options
+CREATE COLLATION collate_coll3a (LOCALE = 'C', LC_COLLATE = 'C', LC_CTYPE= 'C');
+ERROR: conflicting or redundant options
+-- Should fail. LC_COLLATE must be specified
+CREATE COLLATION collate_coll5 (LC_CTYPE= 'C');
+ERROR: parameter "lc_collate" must be specified
+-- Should fail. Give value options without value
+CREATE COLLATION collate_coll4a (LC_COLLATE = '');
+ERROR: parameter "lc_ctype" must be specified
+CREATE COLLATION collate_coll5a (LC_CTYPE= '');
+ERROR: parameter "lc_collate" must be specified
+-- Should fail. Give invalid option name
+CREATE COLLATION collate_coll6 (ASDF = 'C');
+ERROR: collation attribute "asdf" not recognized
+-- Ensure ROLEs without USAGE access can't CREATE/ALTER COLLATION
+CREATE SCHEMA collate_tests4;
+CREATE COLLATION collate_tests4.collate_coll9 (LOCALE = 'C');
+REVOKE USAGE ON SCHEMA collate_tests4 FROM regress_rol_col1;
+SET ROLE regress_rol_col1;
+ALTER COLLATION collate_tests4.collate_coll9 RENAME TO collate_coll9b;
+ERROR: permission denied for schema collate_tests4
+CREATE COLLATION collate_tests4.collate_coll10 (LOCALE = 'C');
+ERROR: permission denied for schema collate_tests4
+RESET ROLE;
+DROP SCHEMA collate_tests4 CASCADE;
+NOTICE: drop cascades to collation collate_coll9
--
-- Clean up. Many of these table names will be re-used if the user is
-- trying to run any platform-specific collation tests later, so we
@@ -648,3 +693,4 @@ drop cascades to function dup(anyelement)
drop cascades to table collate_test20
drop cascades to table collate_test21
drop cascades to table collate_test22
+DROP ROLE regress_rol_col1;
diff --git a/src/test/regress/sql/collate.sql b/src/test/regress/sql/collate.sql
index 63ab590f3a4..d1d44da69d6 100644
--- a/src/test/regress/sql/collate.sql
+++ b/src/test/regress/sql/collate.sql
@@ -231,6 +231,50 @@ SELECT collation for ('foo'::text);
SELECT collation for ((SELECT a FROM collate_test1 LIMIT 1)); -- non-collatable type - error
SELECT collation for ((SELECT b FROM collate_test1 LIMIT 1));
+-- CREATE COLLATE tests
+CREATE COLLATION collate_coll2 FROM "C";
+
+-- Ensure non-OWNER ROLEs are not able to ALTER/DROP COLLATION
+CREATE ROLE regress_rol_col1;
+GRANT USAGE ON SCHEMA collate_tests TO regress_rol_col1;
+SET ROLE regress_rol_col1;
+DROP COLLATION IF EXISTS collate_tests.collate_coll2;
+RESET ROLE;
+
+-- Ensure ALTER COLLATION SET SCHEMA works as expected
+CREATE SCHEMA collate_tests2;
+ALTER COLLATION collate_coll2 SET SCHEMA collate_tests2;
+DROP COLLATION collate_tests2.collate_coll2;
+DROP SCHEMA collate_tests2;
+
+-- Should work. Classic cases of CREATE/ALTER COLLATION
+CREATE COLLATION collate_coll3 (LOCALE = 'C');
+ALTER COLLATION collate_coll3 OWNER TO regress_rol_col1;
+ALTER COLLATION collate_coll3 RENAME TO collate_coll33;
+DROP COLLATION collate_coll33;
+
+-- Should fail. Give redundant options
+CREATE COLLATION collate_coll3a (LOCALE = 'C', LC_COLLATE = 'C', LC_CTYPE= 'C');
+
+-- Should fail. LC_COLLATE must be specified
+CREATE COLLATION collate_coll5 (LC_CTYPE= 'C');
+
+-- Should fail. Give value options without value
+CREATE COLLATION collate_coll4a (LC_COLLATE = '');
+CREATE COLLATION collate_coll5a (LC_CTYPE= '');
+
+-- Should fail. Give invalid option name
+CREATE COLLATION collate_coll6 (ASDF = 'C');
+
+-- Ensure ROLEs without USAGE access can't CREATE/ALTER COLLATION
+CREATE SCHEMA collate_tests4;
+CREATE COLLATION collate_tests4.collate_coll9 (LOCALE = 'C');
+REVOKE USAGE ON SCHEMA collate_tests4 FROM regress_rol_col1;
+SET ROLE regress_rol_col1;
+ALTER COLLATION collate_tests4.collate_coll9 RENAME TO collate_coll9b;
+CREATE COLLATION collate_tests4.collate_coll10 (LOCALE = 'C');
+RESET ROLE;
+DROP SCHEMA collate_tests4 CASCADE;
--
-- Clean up. Many of these table names will be re-used if the user is
@@ -238,3 +282,4 @@ SELECT collation for ((SELECT b FROM collate_test1 LIMIT 1));
-- must get rid of them.
--
DROP SCHEMA collate_tests CASCADE;
+DROP ROLE regress_rol_col1;