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

Commitd992f8a

Browse files
committed
Honor OID status of CREATE LIKE'd tables
Previously, tables created by CREATE LIKE never had OIDs.Report by Tom Lane
1 parent00882d9 commitd992f8a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

‎src/backend/parser/parse_utilcmd.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include"rewrite/rewriteManip.h"
5757
#include"utils/acl.h"
5858
#include"utils/builtins.h"
59+
#include"utils/guc.h"
5960
#include"utils/lsyscache.h"
6061
#include"utils/rel.h"
6162
#include"utils/syscache.h"
@@ -222,7 +223,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
222223
cxt.blist=NIL;
223224
cxt.alist=NIL;
224225
cxt.pkey=NULL;
225-
cxt.hasoids=interpretOidsOption(stmt->options, true);
226+
cxt.hasoids=default_with_oids;
226227

227228
Assert(!stmt->ofTypename|| !stmt->inhRelations);/* grammar enforces */
228229

@@ -281,6 +282,17 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
281282
* Output results.
282283
*/
283284
stmt->tableElts=cxt.columns;
285+
/*
286+
* Add WITH/WITHOUT OIDS, if necessary. A literal statement-specified
287+
* WITH/WITHOUT OIDS will still take precedence because the first
288+
* matching "oids" in "options" is used.
289+
*/
290+
if (cxt.hasoids&& !interpretOidsOption(stmt->options, true))
291+
stmt->options=lappend(stmt->options,makeDefElem("oids",
292+
(Node*)makeInteger(TRUE)));
293+
elseif (!cxt.hasoids&&interpretOidsOption(stmt->options, true))
294+
stmt->options=lappend(stmt->options,makeDefElem("oids",
295+
(Node*)makeInteger(FALSE)));
284296
stmt->constraints=cxt.ckconstraints;
285297

286298
result=lappend(cxt.blist,stmt);
@@ -849,6 +861,8 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
849861
}
850862
}
851863

864+
cxt->hasoids=relation->rd_rel->relhasoids;
865+
852866
/*
853867
* Copy CHECK constraints if requested, being careful to adjust attribute
854868
* numbers so they match the child.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp