On Sat, Apr 25, 2015 at 06:15:25PM -0400, Tom Lane wrote:
> Robert Haas <[email protected]> writes:
> > No, I just misread your email. I thought you said you had attached
> > the patch; rereading it, I see that you said you had applied the
> > patch. Silly me.
>
> The real problem with this patch is it's wrong. Specifically, it broke
> the other case I mentioned in my original email:
>
> regression=# create table src2 (f1 int, primary key(oid)) with oids;
> ERROR: column "oid" named in key does not exist
> LINE 1: create table src2 (f1 int, primary key(oid)) with oids;
> ^
Wow, thanks for seeing that mistake. I had things just fine, but then I
decided to optimize it and forgot that this code is used in non-LIKE
situations. Reverted.
> That works in 9.4, and was still working in HEAD as of my original email.
> I think the patch's logic for attaching made-up OIDS options is actually
> backwards (it's adding TRUE where it should add FALSE and vice versa),
> but in any case I do not like the dependence on default_with_oids that
> was introduced by the patch. I am not sure there's any guarantee that
> default_with_oids can't change between parsing and execution of a CREATE
> TABLE command.
I have changed the default value back to the function call as it should
have been all along; patch attached. I will revisit this for 9.6
unless I hear otherwise.
--
Bruce Momjian <[email protected]> http://momjian.us
EnterpriseDB http://enterprisedb.com
+ Everyone has their own god. +
diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
new file mode 100644
index 1fc8c2c..40fa9d6
*** a/src/backend/parser/parse_utilcmd.c
--- b/src/backend/parser/parse_utilcmd.c
***************
*** 56,61 ****
--- 56,62 ----
#include "rewrite/rewriteManip.h"
#include "utils/acl.h"
#include "utils/builtins.h"
+ #include "utils/guc.h"
#include "utils/lsyscache.h"
#include "utils/rel.h"
#include "utils/syscache.h"
*************** transformCreateStmt(CreateStmt *stmt, co
*** 281,286 ****
--- 282,298 ----
* Output results.
*/
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 (!interpretOidsOption(stmt->options, true) && cxt.hasoids)
+ stmt->options = lappend(stmt->options, makeDefElem("oids",
+ (Node *)makeInteger(TRUE)));
+ else if (interpretOidsOption(stmt->options, true) && !cxt.hasoids)
+ stmt->options = lappend(stmt->options, makeDefElem("oids",
+ (Node *)makeInteger(FALSE)));
stmt->constraints = cxt.ckconstraints;
result = lappend(cxt.blist, stmt);
*************** transformTableLikeClause(CreateStmtConte
*** 849,854 ****
--- 861,868 ----
}
}
+ cxt->hasoids = relation->rd_rel->relhasoids;
+
/*
* Copy CHECK constraints if requested, being careful to adjust attribute
* numbers so they match the child.
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers