aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2011-07-22 16:15:43 -0400
committerRobert Haas <rhaas@postgresql.org>2011-07-22 16:15:43 -0400
commit6f1be5a67a758499beab0082b6e63b3040913268 (patch)
tree211592adc67a7607836c4f61ef0d324da1646422
parent43aa40e1551b9e8d30b376de6d6a9b976ae54332 (diff)
downloadpostgresql-6f1be5a67a758499beab0082b6e63b3040913268.tar.gz
postgresql-6f1be5a67a758499beab0082b6e63b3040913268.zip
Unbreak unlogged tables.
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.
-rw-r--r--src/backend/catalog/namespace.c7
-rw-r--r--src/test/regress/expected/create_table.out11
-rw-r--r--src/test/regress/sql/create_table.sql10
3 files changed, 25 insertions, 3 deletions
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c
index dec608c9076..2386a894356 100644
--- a/src/backend/catalog/namespace.c
+++ b/src/backend/catalog/namespace.c
@@ -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")));
}
}
diff --git a/src/test/regress/expected/create_table.out b/src/test/regress/expected/create_table.out
index 62010a14821..b1dedd469d7 100644
--- a/src/test/regress/expected/create_table.out
+++ b/src/test/regress/expected/create_table.out
@@ -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;
diff --git a/src/test/regress/sql/create_table.sql b/src/test/regress/sql/create_table.sql
index e622b1f0f5b..c1b2acf94de 100644
--- a/src/test/regress/sql/create_table.sql
+++ b/src/test/regress/sql/create_table.sql
@@ -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;