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

Commit4893552

Browse files
committed
Fix another bit of unlogged-table-induced breakage.
Per bug #6205, reported by Abel Abraham Camarillo Ojeda. This isn't aparticularly elegant fix, but I'm trying to minimize the chances ofcausing yet another round of breakage.Adjust regression tests to exercise this case.
1 parent2562dce commit4893552

File tree

3 files changed

+36
-22
lines changed

3 files changed

+36
-22
lines changed

‎src/backend/catalog/namespace.c

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ RangeVarGetRelid(const RangeVar *relation, LOCKMODE lockmode, bool missing_ok,
225225
boolnowait)
226226
{
227227
uint64inval_count;
228-
OidnamespaceId;
229228
OidrelId;
230229
OidoldRelId=InvalidOid;
231230
boolretry= false;
@@ -278,17 +277,27 @@ RangeVarGetRelid(const RangeVar *relation, LOCKMODE lockmode, bool missing_ok,
278277
*/
279278
if (relation->relpersistence==RELPERSISTENCE_TEMP)
280279
{
281-
if (relation->schemaname)
282-
ereport(ERROR,
283-
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
284-
errmsg("temporary tables cannot specify a schema name")));
285-
if (OidIsValid(myTempNamespace))
280+
if (!OidIsValid(myTempNamespace))
281+
relId=InvalidOid;/* this probably can't happen? */
282+
else
283+
{
284+
if (relation->schemaname)
285+
{
286+
OidnamespaceId;
287+
namespaceId=LookupExplicitNamespace(relation->schemaname);
288+
if (namespaceId!=myTempNamespace)
289+
ereport(ERROR,
290+
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
291+
errmsg("temporary tables cannot specify a schema name")));
292+
}
293+
286294
relId=get_relname_relid(relation->relname,myTempNamespace);
287-
else/* this probably can't happen? */
288-
relId=InvalidOid;
295+
}
289296
}
290297
elseif (relation->schemaname)
291298
{
299+
OidnamespaceId;
300+
292301
/* use exact schema given */
293302
namespaceId=LookupExplicitNamespace(relation->schemaname);
294303
relId=get_relname_relid(relation->relname,namespaceId);

‎src/test/regress/expected/create_table.out

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,14 +204,19 @@ 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
207+
CREATE UNLOGGED TABLE unlogged1 (a int primary key);-- OK
208+
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "unlogged1_pkey" for table "unlogged1"
208209
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
210+
CREATE UNLOGGED TABLE public.unlogged2 (a int primary key);-- also OK
211+
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "unlogged2_pkey" for table "unlogged2"
212+
CREATE UNLOGGED TABLE pg_temp.unlogged3 (a int primary key);-- not OK
211213
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
214+
CREATE TABLE pg_temp.implicitly_temp (a int primary key);-- OK
215+
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "implicitly_temp_pkey" for table "implicitly_temp"
216+
CREATE TEMP TABLE explicitly_temp (a int primary key);-- also OK
217+
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "explicitly_temp_pkey" for table "explicitly_temp"
218+
CREATE TEMP TABLE pg_temp.doubly_temp (a int primary key);-- also OK
219+
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "doubly_temp_pkey" for table "doubly_temp"
220+
CREATE TEMP TABLE public.temp_to_perm (a int primary key);-- not OK
216221
ERROR: cannot create temporary relation in non-temporary schema
217222
DROP TABLE unlogged1, public.unlogged2;

‎src/test/regress/sql/create_table.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,12 +241,12 @@ CREATE TABLE IF NOT EXISTS test_tsvector(
241241
ttext
242242
);
243243

244-
CREATE UNLOGGED TABLE unlogged1 (aint);-- OK
244+
CREATE UNLOGGED TABLE unlogged1 (aintprimary key);-- OK
245245
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
246+
CREATE UNLOGGED TABLEpublic.unlogged2 (aintprimary key);-- also OK
247+
CREATE UNLOGGED TABLEpg_temp.unlogged3 (aintprimary key);-- not OK
248+
CREATETABLEpg_temp.implicitly_temp (aintprimary key);-- OK
249+
CREATE TEMP TABLE explicitly_temp (aintprimary key);-- also OK
250+
CREATE TEMP TABLEpg_temp.doubly_temp (aintprimary key);-- also OK
251+
CREATE TEMP TABLEpublic.temp_to_perm (aintprimary key);-- not OK
252252
DROPTABLE unlogged1,public.unlogged2;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp