On Thu, Apr  9, 2015 at 12:32:23PM -0300, Alvaro Herrera wrote:
> Bruce Momjian wrote:
> 
> > Should this be listed in the release notes as a backward-incompatibility?
> 
> Isn't this a backpatchable bug fix?

Uh, I don't think so.  I think users are used to the existing behavior
and changing it on them will cause more harm than good.  Also, we have
had zero field reports about this problem.

The updated attached patch handles cases where the default_with_oids =
true.

-- 
  Bruce Momjian  <br...@momjian.us>        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..6a72f15
*** 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
*** 222,228 ****
  	cxt.blist = NIL;
  	cxt.alist = NIL;
  	cxt.pkey = NULL;
! 	cxt.hasoids = interpretOidsOption(stmt->options, true);
  
  	Assert(!stmt->ofTypename || !stmt->inhRelations);	/* grammar enforces */
  
--- 223,229 ----
  	cxt.blist = NIL;
  	cxt.alist = NIL;
  	cxt.pkey = NULL;
! 	cxt.hasoids = default_with_oids;
  
  	Assert(!stmt->ofTypename || !stmt->inhRelations);	/* grammar enforces */
  
*************** 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)));
+ 	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 (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to