Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6f1be5a

Browse files
committed
Unbreak unlogged tables.
I broke this in commit5da7916, whichwas obviously insufficiently well tested. Add some regression testsin the hope of making future slip-ups more likely to be noticed.
1 parent43aa40e commit6f1be5a

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
CREATETABLEIF NOT EXISTS test_tsvector(
241241
ttext
242242
);
243+
244+
CREATE UNLOGGED TABLE unlogged1 (aint);-- OK
245+
INSERT INTO unlogged1VALUES (42);
246+
CREATE UNLOGGED TABLEpublic.unlogged2 (aint);-- also OK
247+
CREATE UNLOGGED TABLEpg_temp.unlogged3 (aint);-- not OK
248+
CREATETABLEpg_temp.implicity_temp (aint);-- OK
249+
CREATE TEMP TABLE explicitly_temp (aint);-- also OK
250+
CREATE TEMP TABLEpg_temp.doubly_temp (aint);-- also OK
251+
CREATE TEMP TABLEpublic.temp_to_perm (aint);-- not OK
252+
DROPTABLE unlogged1,public.unlogged2;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp