|
56 | 56 | #include "rewrite/rewriteManip.h"
|
57 | 57 | #include "utils/acl.h"
|
58 | 58 | #include "utils/builtins.h"
|
| 59 | +#include "utils/guc.h" |
59 | 60 | #include "utils/lsyscache.h"
|
60 | 61 | #include "utils/rel.h"
|
61 | 62 | #include "utils/syscache.h"
|
@@ -222,7 +223,7 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
|
222 | 223 | cxt.blist = NIL;
|
223 | 224 | cxt.alist = NIL;
|
224 | 225 | cxt.pkey = NULL;
|
225 |
| - cxt.hasoids = interpretOidsOption(stmt->options, true); |
| 226 | + cxt.hasoids = default_with_oids; |
226 | 227 |
|
227 | 228 | Assert(!stmt->ofTypename || !stmt->inhRelations); /* grammar enforces */
|
228 | 229 |
|
@@ -281,6 +282,17 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
|
281 | 282 | * Output results.
|
282 | 283 | */
|
283 | 284 | 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 | + else if (!cxt.hasoids && interpretOidsOption(stmt->options, true)) |
| 294 | + stmt->options = lappend(stmt->options, makeDefElem("oids", |
| 295 | + (Node *)makeInteger(FALSE))); |
284 | 296 | stmt->constraints = cxt.ckconstraints;
|
285 | 297 |
|
286 | 298 | result = lappend(cxt.blist, stmt);
|
@@ -849,6 +861,8 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla
|
849 | 861 | }
|
850 | 862 | }
|
851 | 863 |
|
| 864 | + cxt->hasoids = relation->rd_rel->relhasoids; |
| 865 | + |
852 | 866 | /*
|
853 | 867 | * Copy CHECK constraints if requested, being careful to adjust attribute
|
854 | 868 | * numbers so they match the child.
|
|
0 commit comments