Skip to content

Commit 6f1be5a

Browse files
committed
Unbreak unlogged tables.
I broke this in commit 5da7916, which was obviously insufficiently well tested. Add some regression tests in the hope of making future slip-ups more likely to be noticed.
1 parent 43aa40e commit 6f1be5a

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/backend/catalog/namespace.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,10 @@ RangeVarAdjustRelationPersistence(RangeVar *newRelation, Oid nspid)
506506
errmsg("cannot create relations in temporary schemas of other sessions")));
507507
break;
508508
default:
509-
ereport(ERROR,
510-
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
511-
errmsg("only temporary relations may be created in temporary schemas")));
509+
if (isAnyTempNamespace(nspid))
510+
ereport(ERROR,
511+
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
512+
errmsg("only temporary relations may be created in temporary schemas")));
512513
}
513514
}
514515

src/test/regress/expected/create_table.out

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,14 @@ CREATE TABLE IF NOT EXISTS test_tsvector(
204204
t text
205205
);
206206
NOTICE: relation "test_tsvector" already exists, skipping
207+
CREATE UNLOGGED TABLE unlogged1 (a int); -- OK
208+
INSERT INTO unlogged1 VALUES (42);
209+
CREATE UNLOGGED TABLE public.unlogged2 (a int); -- also OK
210+
CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int); -- not OK
211+
ERROR: only temporary relations may be created in temporary schemas
212+
CREATE TABLE pg_temp.implicity_temp (a int); -- OK
213+
CREATE TEMP TABLE explicitly_temp (a int); -- also OK
214+
CREATE TEMP TABLE pg_temp.doubly_temp (a int); -- also OK
215+
CREATE TEMP TABLE public.temp_to_perm (a int); -- not OK
216+
ERROR: cannot create temporary relation in non-temporary schema
217+
DROP TABLE unlogged1, public.unlogged2;

src/test/regress/sql/create_table.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,3 +240,13 @@ CREATE TABLE IF NOT EXISTS test_tsvector(
240240
CREATE TABLE IF NOT EXISTS test_tsvector(
241241
t text
242242
);
243+
244+
CREATE UNLOGGED TABLE unlogged1 (a int); -- OK
245+
INSERT INTO unlogged1 VALUES (42);
246+
CREATE UNLOGGED TABLE public.unlogged2 (a int); -- also OK
247+
CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int); -- not OK
248+
CREATE TABLE pg_temp.implicity_temp (a int); -- OK
249+
CREATE TEMP TABLE explicitly_temp (a int); -- also OK
250+
CREATE TEMP TABLE pg_temp.doubly_temp (a int); -- also OK
251+
CREATE TEMP TABLE public.temp_to_perm (a int); -- not OK
252+
DROP TABLE unlogged1, public.unlogged2;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy