mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-30 13:41:20 +02:00
Fix a minor bug introduced by the recent CREATE TABLE AS / WITH OIDS
patch: a 3-value enum was mistakenly assigned directly to a 'bool' in transformCreateStmt(). Along the way, change makeObjectName() to be static, as it isn't used outside analyze.c
This commit is contained in:
parent
cd1702dc3a
commit
0bd3606d72
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.95 2004/01/10 23:28:44 neilc Exp $
|
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.96 2004/01/23 02:13:11 neilc Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -39,6 +39,7 @@
|
|||||||
#include "optimizer/plancat.h"
|
#include "optimizer/plancat.h"
|
||||||
#include "optimizer/prep.h"
|
#include "optimizer/prep.h"
|
||||||
#include "parser/gramparse.h"
|
#include "parser/gramparse.h"
|
||||||
|
#include "parser/parse_clause.h"
|
||||||
#include "parser/parse_coerce.h"
|
#include "parser/parse_coerce.h"
|
||||||
#include "parser/parse_expr.h"
|
#include "parser/parse_expr.h"
|
||||||
#include "parser/parse_oper.h"
|
#include "parser/parse_oper.h"
|
||||||
@ -47,7 +48,6 @@
|
|||||||
#include "utils/acl.h"
|
#include "utils/acl.h"
|
||||||
#include "utils/builtins.h"
|
#include "utils/builtins.h"
|
||||||
#include "utils/fmgroids.h"
|
#include "utils/fmgroids.h"
|
||||||
#include "utils/guc.h"
|
|
||||||
#include "utils/inval.h"
|
#include "utils/inval.h"
|
||||||
#include "utils/lsyscache.h"
|
#include "utils/lsyscache.h"
|
||||||
#include "utils/relcache.h"
|
#include "utils/relcache.h"
|
||||||
@ -189,22 +189,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
|
|||||||
if (parentHasOids)
|
if (parentHasOids)
|
||||||
descriptor->tdhasoid = true;
|
descriptor->tdhasoid = true;
|
||||||
else
|
else
|
||||||
{
|
descriptor->tdhasoid = interpretOidsOption(stmt->hasoids);
|
||||||
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)
|
if (old_constraints != NIL)
|
||||||
{
|
{
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.296 2004/01/14 23:01:55 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.297 2004/01/23 02:13:12 neilc Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -142,6 +142,7 @@ static void release_pstate_resources(ParseState *pstate);
|
|||||||
static FromExpr *makeFromExpr(List *fromlist, Node *quals);
|
static FromExpr *makeFromExpr(List *fromlist, Node *quals);
|
||||||
static bool check_parameter_resolution_walker(Node *node,
|
static bool check_parameter_resolution_walker(Node *node,
|
||||||
check_parameter_resolution_context *context);
|
check_parameter_resolution_context *context);
|
||||||
|
static char *makeObjectName(char *name1, char *name2, char *typename);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -735,7 +736,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
|
|||||||
* from the truncated characters. Currently it seems best to keep it simple,
|
* from the truncated characters. Currently it seems best to keep it simple,
|
||||||
* so that the generated names are easily predictable by a person.
|
* so that the generated names are easily predictable by a person.
|
||||||
*/
|
*/
|
||||||
char *
|
static char *
|
||||||
makeObjectName(char *name1, char *name2, char *typename)
|
makeObjectName(char *name1, char *name2, char *typename)
|
||||||
{
|
{
|
||||||
char *name;
|
char *name;
|
||||||
@ -859,7 +860,6 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt,
|
|||||||
cxt.stmtType = "CREATE TABLE";
|
cxt.stmtType = "CREATE TABLE";
|
||||||
cxt.relation = stmt->relation;
|
cxt.relation = stmt->relation;
|
||||||
cxt.inhRelations = stmt->inhRelations;
|
cxt.inhRelations = stmt->inhRelations;
|
||||||
cxt.hasoids = stmt->hasoids;
|
|
||||||
cxt.relOid = InvalidOid;
|
cxt.relOid = InvalidOid;
|
||||||
cxt.columns = NIL;
|
cxt.columns = NIL;
|
||||||
cxt.ckconstraints = NIL;
|
cxt.ckconstraints = NIL;
|
||||||
@ -868,6 +868,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt,
|
|||||||
cxt.blist = NIL;
|
cxt.blist = NIL;
|
||||||
cxt.alist = NIL;
|
cxt.alist = NIL;
|
||||||
cxt.pkey = NULL;
|
cxt.pkey = NULL;
|
||||||
|
cxt.hasoids = interpretOidsOption(stmt->hasoids);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Run through each primary element in the table creation clause.
|
* Run through each primary element in the table creation clause.
|
||||||
@ -1979,20 +1980,7 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
|
|||||||
if (stmt->intoColNames)
|
if (stmt->intoColNames)
|
||||||
applyColumnNames(qry->targetList, stmt->intoColNames);
|
applyColumnNames(qry->targetList, stmt->intoColNames);
|
||||||
|
|
||||||
switch (stmt->intoHasOids)
|
qry->intoHasOids = interpretOidsOption(stmt->intoHasOids);
|
||||||
{
|
|
||||||
case MUST_HAVE_OIDS:
|
|
||||||
qry->intoHasOids = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case MUST_NOT_HAVE_OIDS:
|
|
||||||
qry->intoHasOids = false;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DEFAULT_OIDS:
|
|
||||||
qry->intoHasOids = default_with_oids;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* mark column origins */
|
/* mark column origins */
|
||||||
markTargetListOrigins(pstate, qry->targetList);
|
markTargetListOrigins(pstate, qry->targetList);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.126 2004/01/14 23:01:55 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.127 2004/01/23 02:13:12 neilc Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -191,7 +191,33 @@ interpretInhOption(InhOption inhOpt)
|
|||||||
case INH_DEFAULT:
|
case INH_DEFAULT:
|
||||||
return SQL_inheritance;
|
return SQL_inheritance;
|
||||||
}
|
}
|
||||||
elog(ERROR, "bogus InhOption value");
|
elog(ERROR, "bogus InhOption value: %d", inhOpt);
|
||||||
|
return false; /* keep compiler quiet */
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Given an enum that indicates whether WITH / WITHOUT OIDS was
|
||||||
|
* specified by the user, return true iff the specified table/result
|
||||||
|
* set should be created with OIDs. This needs to be done after
|
||||||
|
* parsing the query string because the return value can depend upon
|
||||||
|
* the default_with_oids GUC var.
|
||||||
|
*/
|
||||||
|
bool
|
||||||
|
interpretOidsOption(ContainsOids opt)
|
||||||
|
{
|
||||||
|
switch (opt)
|
||||||
|
{
|
||||||
|
case MUST_HAVE_OIDS:
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case MUST_NOT_HAVE_OIDS:
|
||||||
|
return false;
|
||||||
|
|
||||||
|
case DEFAULT_OIDS:
|
||||||
|
return default_with_oids;
|
||||||
|
}
|
||||||
|
|
||||||
|
elog(ERROR, "bogus ContainsOids value: %d", opt);
|
||||||
return false; /* keep compiler quiet */
|
return false; /* keep compiler quiet */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/parser/analyze.h,v 1.24 2003/11/29 22:41:09 pgsql Exp $
|
* $PostgreSQL: pgsql/src/include/parser/analyze.h,v 1.25 2004/01/23 02:13:12 neilc Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -24,7 +24,4 @@ extern List *analyzeCreateSchemaStmt(CreateSchemaStmt *stmt);
|
|||||||
|
|
||||||
extern void CheckSelectForUpdate(Query *qry);
|
extern void CheckSelectForUpdate(Query *qry);
|
||||||
|
|
||||||
/* This was exported to allow ADD CONSTRAINT to make use of it */
|
|
||||||
extern char *makeObjectName(char *name1, char *name2, char *typename);
|
|
||||||
|
|
||||||
#endif /* ANALYZE_H */
|
#endif /* ANALYZE_H */
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/parser/parse_clause.h,v 1.39 2004/01/14 23:01:55 tgl Exp $
|
* $PostgreSQL: pgsql/src/include/parser/parse_clause.h,v 1.40 2004/01/23 02:13:12 neilc Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -20,6 +20,7 @@ extern void transformFromClause(ParseState *pstate, List *frmList);
|
|||||||
extern int setTargetTable(ParseState *pstate, RangeVar *relation,
|
extern int setTargetTable(ParseState *pstate, RangeVar *relation,
|
||||||
bool inh, bool alsoSource, AclMode requiredPerms);
|
bool inh, bool alsoSource, AclMode requiredPerms);
|
||||||
extern bool interpretInhOption(InhOption inhOpt);
|
extern bool interpretInhOption(InhOption inhOpt);
|
||||||
|
extern bool interpretOidsOption(ContainsOids opt);
|
||||||
|
|
||||||
extern Node *transformWhereClause(ParseState *pstate, Node *clause,
|
extern Node *transformWhereClause(ParseState *pstate, Node *clause,
|
||||||
const char *constructName);
|
const char *constructName);
|
||||||
|
Loading…
Reference in New Issue
Block a user