mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Implement "WITH / WITHOID OIDS" clause for CREATE TABLE AS. This is
intended to allow application authors to insulate themselves from changes to the default value of 'default_with_oids' in future releases of PostgreSQL. This patch also fixes a bug in the earlier implementation of the 'default_with_oids' GUC variable: code in gram.y should not examine the value of GUC variables directly due to synchronization issues.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.107 2004/01/07 18:56:25 neilc Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/sequence.c,v 1.108 2004/01/10 23:28:44 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -178,7 +178,7 @@ DefineSequence(CreateSeqStmt *seq)
|
||||
stmt->relation = seq->sequence;
|
||||
stmt->inhRelations = NIL;
|
||||
stmt->constraints = NIL;
|
||||
stmt->hasoids = false;
|
||||
stmt->hasoids = MUST_NOT_HAVE_OIDS;
|
||||
stmt->oncommit = ONCOMMIT_NOOP;
|
||||
|
||||
seqoid = DefineRelation(stmt, RELKIND_SEQUENCE);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.94 2003/11/29 19:51:47 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.95 2004/01/10 23:28:44 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -47,6 +47,7 @@
|
||||
#include "utils/acl.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/fmgroids.h"
|
||||
#include "utils/guc.h"
|
||||
#include "utils/inval.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/relcache.h"
|
||||
@@ -185,7 +186,25 @@ DefineRelation(CreateStmt *stmt, char relkind)
|
||||
*/
|
||||
descriptor = BuildDescForRelation(schema);
|
||||
|
||||
descriptor->tdhasoid = (stmt->hasoids || parentHasOids);
|
||||
if (parentHasOids)
|
||||
descriptor->tdhasoid = true;
|
||||
else
|
||||
{
|
||||
switch (stmt->hasoids)
|
||||
{
|
||||
case MUST_HAVE_OIDS:
|
||||
descriptor->tdhasoid = true;
|
||||
break;
|
||||
|
||||
case MUST_NOT_HAVE_OIDS:
|
||||
descriptor->tdhasoid = false;
|
||||
break;
|
||||
|
||||
case DEFAULT_OIDS:
|
||||
descriptor->tdhasoid = default_with_oids;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (old_constraints != NIL)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.51 2003/11/29 19:51:47 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/typecmds.c,v 1.52 2004/01/10 23:28:44 neilc Exp $
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The "DefineFoo" routines take the parse tree and pick out the
|
||||
@@ -1066,7 +1066,7 @@ DefineCompositeType(const RangeVar *typevar, List *coldeflist)
|
||||
createStmt->tableElts = coldeflist;
|
||||
createStmt->inhRelations = NIL;
|
||||
createStmt->constraints = NIL;
|
||||
createStmt->hasoids = false;
|
||||
createStmt->hasoids = MUST_NOT_HAVE_OIDS;
|
||||
createStmt->oncommit = ONCOMMIT_NOOP;
|
||||
|
||||
/*
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.79 2003/11/29 19:51:48 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/view.c,v 1.80 2004/01/10 23:28:44 neilc Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -141,7 +141,7 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace)
|
||||
createStmt->tableElts = attrList;
|
||||
createStmt->inhRelations = NIL;
|
||||
createStmt->constraints = NIL;
|
||||
createStmt->hasoids = false;
|
||||
createStmt->hasoids = MUST_NOT_HAVE_OIDS;
|
||||
createStmt->oncommit = ONCOMMIT_NOOP;
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user