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

Commit0bd11d9

Browse files
committed
Add comments warning against generalizing default_with_oids.
pg_dump has historically assumed that default_with_oids affects only plaintables and not other relkinds. Conceivably we could make it apply to somenewly invented relkind if we did so from the get-go, but changing thebehavior for existing object types will break existing dump scripts.Add code comments warning about this interaction.Also, make sure that default_with_oids doesn't cause parse_utilcmd.c tothink that CREATE FOREIGN TABLE will create an OID column. I think this isonly a latent bug right now, since we don't allow UNIQUE/PKEY constraintsin CREATE FOREIGN TABLE, but it's better to be consistent and future-proof.
1 parent04f1542 commit0bd11d9

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,6 +579,14 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
579579
*/
580580
descriptor=BuildDescForRelation(schema);
581581

582+
/*
583+
* Notice that we allow OIDs here only for plain tables, even though some
584+
* other relkinds can support them. This is necessary because the
585+
* default_with_oids GUC must apply only to plain tables and not any other
586+
* relkind; doing otherwise would break existing pg_dump files. We could
587+
* allow explicit "WITH OIDS" while not allowing default_with_oids to
588+
* affect other relkinds, but it would complicate interpretOidsOption().
589+
*/
582590
localHasOids=interpretOidsOption(stmt->options,
583591
(relkind==RELKIND_RELATION));
584592
descriptor->tdhasoid= (localHasOids||parentOidCount>0);

‎src/backend/parser/parse_utilcmd.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,18 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
222222
cxt.blist=NIL;
223223
cxt.alist=NIL;
224224
cxt.pkey=NULL;
225-
cxt.hasoids=interpretOidsOption(stmt->options, true);
225+
226+
/*
227+
* Notice that we allow OIDs here only for plain tables, even though
228+
* foreign tables also support them. This is necessary because the
229+
* default_with_oids GUC must apply only to plain tables and not any other
230+
* relkind; doing otherwise would break existing pg_dump files. We could
231+
* allow explicit "WITH OIDS" while not allowing default_with_oids to
232+
* affect other relkinds, but it would complicate interpretOidsOption(),
233+
* and right now there's no WITH OIDS option in CREATE FOREIGN TABLE
234+
* anyway.
235+
*/
236+
cxt.hasoids=interpretOidsOption(stmt->options, !cxt.isforeign);
226237

227238
Assert(!stmt->ofTypename|| !stmt->inhRelations);/* grammar enforces */
228239

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp