mirror of
https://github.com/postgres/postgres.git
synced 2025-06-17 17:02:08 +03:00
Honor OID status of CREATE LIKE'd tables
Previously, tables created by CREATE LIKE never had OIDs. Report by Tom Lane
This commit is contained in:
@ -56,6 +56,7 @@
|
|||||||
#include "rewrite/rewriteManip.h"
|
#include "rewrite/rewriteManip.h"
|
||||||
#include "utils/acl.h"
|
#include "utils/acl.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
|
#include "utils/guc.h"
|
||||||
#include "utils/lsyscache.h"
|
#include "utils/lsyscache.h"
|
||||||
#include "utils/rel.h"
|
#include "utils/rel.h"
|
||||||
#include "utils/syscache.h"
|
#include "utils/syscache.h"
|
||||||
@ -222,7 +223,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
|
|||||||
cxt.blist = NIL;
|
cxt.blist = NIL;
|
||||||
cxt.alist = NIL;
|
cxt.alist = NIL;
|
||||||
cxt.pkey = NULL;
|
cxt.pkey = NULL;
|
||||||
cxt.hasoids = interpretOidsOption(stmt->options, true);
|
cxt.hasoids = default_with_oids;
|
||||||
|
|
||||||
Assert(!stmt->ofTypename || !stmt->inhRelations); /* grammar enforces */
|
Assert(!stmt->ofTypename || !stmt->inhRelations); /* grammar enforces */
|
||||||
|
|
||||||
@ -281,6 +282,17 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
|
|||||||
* Output results.
|
* Output results.
|
||||||
*/
|
*/
|
||||||
stmt->tableElts = cxt.columns;
|
stmt->tableElts = cxt.columns;
|
||||||
|
/*
|
||||||
|
* Add WITH/WITHOUT OIDS, if necessary. A literal statement-specified
|
||||||
|
* WITH/WITHOUT OIDS will still take precedence because the first
|
||||||
|
* matching "oids" in "options" is used.
|
||||||
|
*/
|
||||||
|
if (cxt.hasoids && !interpretOidsOption(stmt->options, true))
|
||||||
|
stmt->options = lappend(stmt->options, makeDefElem("oids",
|
||||||
|
(Node *)makeInteger(TRUE)));
|
||||||
|
else if (!cxt.hasoids && interpretOidsOption(stmt->options, true))
|
||||||
|
stmt->options = lappend(stmt->options, makeDefElem("oids",
|
||||||
|
(Node *)makeInteger(FALSE)));
|
||||||
stmt->constraints = cxt.ckconstraints;
|
stmt->constraints = cxt.ckconstraints;
|
||||||
|
|
||||||
result = lappend(cxt.blist, stmt);
|
result = lappend(cxt.blist, stmt);
|
||||||
@ -849,6 +861,8 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cxt->hasoids = relation->rd_rel->relhasoids;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copy CHECK constraints if requested, being careful to adjust attribute
|
* Copy CHECK constraints if requested, being careful to adjust attribute
|
||||||
* numbers so they match the child.
|
* numbers so they match the child.
|
||||||
|
Reference in New Issue
Block a user