Modify enum tests to not rely on SAVEPOINT
authorTomas Vondra <tomas@2ndquadrant.com>
Sun, 16 Jul 2017 14:22:46 +0000 (16:22 +0200)
committerTomas Vondra <tomas@2ndquadrant.com>
Sun, 16 Jul 2017 14:22:46 +0000 (16:22 +0200)
Postgres-XL does not support SAVEPOINT (or subtransactions in general).
Some regression tests use this to test cases that are expected to fail,
and we want to keep testing that. So instead of removing the tests,
split them into independent transactions (and tweak the expected output
accordingly).

Note: The tests are still failing, though. Apparently XL does not undo
the effect of ALTER TYPE ... ADD VALUE on rollback.

src/test/regress/expected/enum.out
src/test/regress/sql/enum.sql

index 1d4e28177ad609ec498203135c3fb7496b439328..1f6f267d23a31c07fe2003c53a0e72ba640306da 100644 (file)
@@ -585,13 +585,14 @@ CREATE TYPE bogus AS ENUM('good');
 -- but we can't use them
 BEGIN;
 ALTER TYPE bogus ADD VALUE 'new';
-SAVEPOINT x;
 SELECT 'new'::bogus;  -- unsafe
 ERROR:  unsafe use of new value "new" of enum type bogus
 LINE 1: SELECT 'new'::bogus;
                ^
 HINT:  New enum values must be committed before they can be used.
-ROLLBACK TO x;
+ROLLBACK;
+BEGIN;
+ALTER TYPE bogus ADD VALUE 'new';
 SELECT enum_first(null::bogus);  -- safe
  enum_first 
 ------------
@@ -601,18 +602,17 @@ SELECT enum_first(null::bogus);  -- safe
 SELECT enum_last(null::bogus);  -- unsafe
 ERROR:  unsafe use of new value "new" of enum type bogus
 HINT:  New enum values must be committed before they can be used.
-ROLLBACK TO x;
+ROLLBACK;
+BEGIN;
+ALTER TYPE bogus ADD VALUE 'new';
 SELECT enum_range(null::bogus);  -- unsafe
 ERROR:  unsafe use of new value "new" of enum type bogus
 HINT:  New enum values must be committed before they can be used.
-ROLLBACK TO x;
 COMMIT;
 SELECT 'new'::bogus;  -- now safe
- bogus 
--------
- new
-(1 row)
-
+ERROR:  invalid input value for enum bogus: "new"
+LINE 1: SELECT 'new'::bogus;
+               ^
 SELECT enumlabel, enumsortorder
 FROM pg_enum
 WHERE enumtypid = 'bogus'::regtype
@@ -620,8 +620,7 @@ ORDER BY 2;
  enumlabel | enumsortorder 
 -----------+---------------
  good      |             1
- new       |             2
-(2 rows)
+(1 row)
 
 -- check that we recognize the case where the enum already existed but was
 -- modified in the current txn; this should not be considered safe
index b103b002bdbc5d87e5c75396d6547c58934fa03a..d983de894b8861adb18b5eccd495e067feaf1852 100644 (file)
@@ -277,15 +277,20 @@ CREATE TYPE bogus AS ENUM('good');
 -- but we can't use them
 BEGIN;
 ALTER TYPE bogus ADD VALUE 'new';
-SAVEPOINT x;
 SELECT 'new'::bogus;  -- unsafe
-ROLLBACK TO x;
+ROLLBACK;
+
+BEGIN;
+ALTER TYPE bogus ADD VALUE 'new';
 SELECT enum_first(null::bogus);  -- safe
 SELECT enum_last(null::bogus);  -- unsafe
-ROLLBACK TO x;
+ROLLBACK;
+
+BEGIN;
+ALTER TYPE bogus ADD VALUE 'new';
 SELECT enum_range(null::bogus);  -- unsafe
-ROLLBACK TO x;
 COMMIT;
+
 SELECT 'new'::bogus;  -- now safe
 SELECT enumlabel, enumsortorder
 FROM pg_enum