Commit 6f1be5a6 authored by Robert Haas's avatar Robert Haas

Unbreak unlogged tables.

I broke this in commit 5da79169, which
was obviously insufficiently well tested.  Add some regression tests
in the hope of making future slip-ups more likely to be noticed.
parent 43aa40e1
...@@ -506,9 +506,10 @@ RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid) ...@@ -506,9 +506,10 @@ RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
errmsg("cannot create relations in temporary schemas of other sessions"))); errmsg("cannot create relations in temporary schemas of other sessions")));
break; break;
default: default:
ereport(ERROR, if (isAnyTempNamespace(nspid))
(errcode(ERRCODE_INVALID_TABLE_DEFINITION), ereport(ERROR,
errmsg("only temporary relations may be created in temporary schemas"))); (errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("only temporary relations may be created in temporary schemas")));
} }
} }
......
...@@ -204,3 +204,14 @@ CREATE TABLE IF NOT EXISTS test_tsvector( ...@@ -204,3 +204,14 @@ CREATE TABLE IF NOT EXISTS test_tsvector(
t text t text
); );
NOTICE: relation "test_tsvector" already exists, skipping 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;
...@@ -240,3 +240,13 @@ CREATE TABLE IF NOT EXISTS test_tsvector( ...@@ -240,3 +240,13 @@ CREATE TABLE IF NOT EXISTS test_tsvector(
CREATE TABLE IF NOT EXISTS test_tsvector( CREATE TABLE IF NOT EXISTS test_tsvector(
t text 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;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment