diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c
new file mode 100644
index 1fc8c2c..405c347
*** a/src/backend/parser/parse_utilcmd.c
--- b/src/backend/parser/parse_utilcmd.c
*************** 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 */
  
--- 222,228 ----
  	cxt.blist = NIL;
  	cxt.alist = NIL;
  	cxt.pkey = NULL;
! 	cxt.hasoids = false;
  
  	Assert(!stmt->ofTypename || !stmt->inhRelations);	/* grammar enforces */
  
*************** transformCreateStmt(CreateStmt *stmt, co
*** 281,286 ****
--- 281,290 ----
  	 * Output results.
  	 */
  	stmt->tableElts = cxt.columns;
+ 	/* add WITH OIDS, if necessary */
+ 	if (!interpretOidsOption(stmt->options, true) && cxt.hasoids)
+ 		stmt->options = lappend(stmt->options, makeDefElem("oids",
+ 								(Node *)makeInteger(TRUE)));
  	stmt->constraints = cxt.ckconstraints;
  
  	result = lappend(cxt.blist, stmt);
*************** transformTableLikeClause(CreateStmtConte
*** 849,854 ****
--- 853,860 ----
  		}
  	}
  
+ 	cxt->hasoids = relation->rd_rel->relhasoids;
+ 
  	/*
  	 * Copy CHECK constraints if requested, being careful to adjust attribute
  	 * numbers so they match the child.
