]> granicus.if.org Git - postgresql/commitdiff
Unbreak unlogged tables.
authorRobert Haas <rhaas@postgresql.org>
Fri, 22 Jul 2011 20:15:43 +0000 (16:15 -0400)
committerRobert Haas <rhaas@postgresql.org>
Fri, 22 Jul 2011 20:15:43 +0000 (16:15 -0400)
I broke this in commit 5da79169d3e9f0fab47da03318c44075b3f824c5, which
was obviously insufficiently well tested.  Add some regression tests
in the hope of making future slip-ups more likely to be noticed.

src/backend/catalog/namespace.c
src/test/regress/expected/create_table.out
src/test/regress/sql/create_table.sql

index dec608c9076d8bf4b4f1dba370a897549497e3f5..2386a894356939de55064f349e93d6cb1b2bf79b 100644 (file)
@@ -506,9 +506,10 @@ RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
                                                 errmsg("cannot create relations in temporary schemas of other sessions")));
                        break;
                default:
-                       ereport(ERROR,
-                                       (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
-                                        errmsg("only temporary relations may be created in temporary schemas")));
+                       if (isAnyTempNamespace(nspid))
+                               ereport(ERROR,
+                                               (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
+                                                errmsg("only temporary relations may be created in temporary schemas")));
        }
 }
 
index 62010a14821a7a2f51f7d6335fa4f1a1997f86da..b1dedd469d77163cc51f93bbe7f0c422199879d6 100644 (file)
@@ -204,3 +204,14 @@ CREATE TABLE IF NOT EXISTS test_tsvector(
        t text
 );
 NOTICE:  relation "test_tsvector" already exists, skipping
+CREATE UNLOGGED TABLE unlogged1 (a int);                       -- OK
+INSERT INTO unlogged1 VALUES (42);
+CREATE UNLOGGED TABLE public.unlogged2 (a int);                -- also OK
+CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int);       -- not OK
+ERROR:  only temporary relations may be created in temporary schemas
+CREATE TABLE pg_temp.implicity_temp (a int);           -- OK
+CREATE TEMP TABLE explicitly_temp (a int);                     -- also OK
+CREATE TEMP TABLE pg_temp.doubly_temp (a int);         -- also OK
+CREATE TEMP TABLE public.temp_to_perm (a int);         -- not OK
+ERROR:  cannot create temporary relation in non-temporary schema
+DROP TABLE unlogged1, public.unlogged2;
index e622b1f0f5bd410cb1d1cef9d7c98f111e8cab5d..c1b2acf94de9e47d11a1db72985b1dc201e62717 100644 (file)
@@ -240,3 +240,13 @@ CREATE TABLE IF NOT EXISTS test_tsvector(
 CREATE TABLE IF NOT EXISTS test_tsvector(
        t text
 );
+
+CREATE UNLOGGED TABLE unlogged1 (a int);                       -- OK
+INSERT INTO unlogged1 VALUES (42);
+CREATE UNLOGGED TABLE public.unlogged2 (a int);                -- also OK
+CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int);       -- not OK
+CREATE TABLE pg_temp.implicity_temp (a int);           -- OK
+CREATE TEMP TABLE explicitly_temp (a int);                     -- also OK
+CREATE TEMP TABLE pg_temp.doubly_temp (a int);         -- also OK
+CREATE TEMP TABLE public.temp_to_perm (a int);         -- not OK
+DROP TABLE unlogged1, public.unlogged2;