Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0bd3606

Browse files
author
Neil Conway
committed
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
1 parentcd1702d commit0bd3606

File tree

5 files changed

+39
-42
lines changed

5 files changed

+39
-42
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.95 2004/01/10 23:28:44 neilc Exp $
11+
* $PostgreSQL: pgsql/src/backend/commands/tablecmds.c,v 1.96 2004/01/23 02:13:11 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -39,6 +39,7 @@
3939
#include"optimizer/plancat.h"
4040
#include"optimizer/prep.h"
4141
#include"parser/gramparse.h"
42+
#include"parser/parse_clause.h"
4243
#include"parser/parse_coerce.h"
4344
#include"parser/parse_expr.h"
4445
#include"parser/parse_oper.h"
@@ -47,7 +48,6 @@
4748
#include"utils/acl.h"
4849
#include"utils/builtins.h"
4950
#include"utils/fmgroids.h"
50-
#include"utils/guc.h"
5151
#include"utils/inval.h"
5252
#include"utils/lsyscache.h"
5353
#include"utils/relcache.h"
@@ -189,22 +189,7 @@ DefineRelation(CreateStmt *stmt, char relkind)
189189
if (parentHasOids)
190190
descriptor->tdhasoid= true;
191191
else
192-
{
193-
switch (stmt->hasoids)
194-
{
195-
caseMUST_HAVE_OIDS:
196-
descriptor->tdhasoid= true;
197-
break;
198-
199-
caseMUST_NOT_HAVE_OIDS:
200-
descriptor->tdhasoid= false;
201-
break;
202-
203-
caseDEFAULT_OIDS:
204-
descriptor->tdhasoid=default_with_oids;
205-
break;
206-
}
207-
}
192+
descriptor->tdhasoid=interpretOidsOption(stmt->hasoids);
208193

209194
if (old_constraints!=NIL)
210195
{

‎src/backend/parser/analyze.c

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
*$PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.296 2004/01/14 23:01:55 tgl Exp $
9+
*$PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.297 2004/01/23 02:13:12 neilc Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -142,6 +142,7 @@ static void release_pstate_resources(ParseState *pstate);
142142
staticFromExpr*makeFromExpr(List*fromlist,Node*quals);
143143
staticboolcheck_parameter_resolution_walker(Node*node,
144144
check_parameter_resolution_context*context);
145+
staticchar*makeObjectName(char*name1,char*name2,char*typename);
145146

146147

147148
/*
@@ -735,7 +736,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
735736
*from the truncated characters.Currently it seems best to keep it simple,
736737
*so that the generated names are easily predictable by a person.
737738
*/
738-
char*
739+
staticchar*
739740
makeObjectName(char*name1,char*name2,char*typename)
740741
{
741742
char*name;
@@ -859,7 +860,6 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt,
859860
cxt.stmtType="CREATE TABLE";
860861
cxt.relation=stmt->relation;
861862
cxt.inhRelations=stmt->inhRelations;
862-
cxt.hasoids=stmt->hasoids;
863863
cxt.relOid=InvalidOid;
864864
cxt.columns=NIL;
865865
cxt.ckconstraints=NIL;
@@ -868,6 +868,7 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt,
868868
cxt.blist=NIL;
869869
cxt.alist=NIL;
870870
cxt.pkey=NULL;
871+
cxt.hasoids=interpretOidsOption(stmt->hasoids);
871872

872873
/*
873874
* Run through each primary element in the table creation clause.
@@ -1979,20 +1980,7 @@ transformSelectStmt(ParseState *pstate, SelectStmt *stmt)
19791980
if (stmt->intoColNames)
19801981
applyColumnNames(qry->targetList,stmt->intoColNames);
19811982

1982-
switch (stmt->intoHasOids)
1983-
{
1984-
caseMUST_HAVE_OIDS:
1985-
qry->intoHasOids= true;
1986-
break;
1987-
1988-
caseMUST_NOT_HAVE_OIDS:
1989-
qry->intoHasOids= false;
1990-
break;
1991-
1992-
caseDEFAULT_OIDS:
1993-
qry->intoHasOids=default_with_oids;
1994-
break;
1995-
}
1983+
qry->intoHasOids=interpretOidsOption(stmt->intoHasOids);
19961984

19971985
/* mark column origins */
19981986
markTargetListOrigins(pstate,qry->targetList);

‎src/backend/parser/parse_clause.c

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.126 2004/01/14 23:01:55 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.127 2004/01/23 02:13:12 neilc Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -191,7 +191,33 @@ interpretInhOption(InhOption inhOpt)
191191
caseINH_DEFAULT:
192192
returnSQL_inheritance;
193193
}
194-
elog(ERROR,"bogus InhOption value");
194+
elog(ERROR,"bogus InhOption value: %d",inhOpt);
195+
return false;/* keep compiler quiet */
196+
}
197+
198+
/*
199+
* Given an enum that indicates whether WITH / WITHOUT OIDS was
200+
* specified by the user, return true iff the specified table/result
201+
* set should be created with OIDs. This needs to be done after
202+
* parsing the query string because the return value can depend upon
203+
* the default_with_oids GUC var.
204+
*/
205+
bool
206+
interpretOidsOption(ContainsOidsopt)
207+
{
208+
switch (opt)
209+
{
210+
caseMUST_HAVE_OIDS:
211+
return true;
212+
213+
caseMUST_NOT_HAVE_OIDS:
214+
return false;
215+
216+
caseDEFAULT_OIDS:
217+
returndefault_with_oids;
218+
}
219+
220+
elog(ERROR,"bogus ContainsOids value: %d",opt);
195221
return false;/* keep compiler quiet */
196222
}
197223

‎src/include/parser/analyze.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
88
*
9-
* $PostgreSQL: pgsql/src/include/parser/analyze.h,v 1.24 2003/11/29 22:41:09 pgsql Exp $
9+
* $PostgreSQL: pgsql/src/include/parser/analyze.h,v 1.25 2004/01/23 02:13:12 neilc Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -24,7 +24,4 @@ extern List *analyzeCreateSchemaStmt(CreateSchemaStmt *stmt);
2424

2525
externvoidCheckSelectForUpdate(Query*qry);
2626

27-
/* This was exported to allow ADD CONSTRAINT to make use of it */
28-
externchar*makeObjectName(char*name1,char*name2,char*typename);
29-
3027
#endif/* ANALYZE_H */

‎src/include/parser/parse_clause.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/include/parser/parse_clause.h,v 1.39 2004/01/14 23:01:55 tgl Exp $
10+
* $PostgreSQL: pgsql/src/include/parser/parse_clause.h,v 1.40 2004/01/23 02:13:12 neilc Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -20,6 +20,7 @@ extern void transformFromClause(ParseState *pstate, List *frmList);
2020
externintsetTargetTable(ParseState*pstate,RangeVar*relation,
2121
boolinh,boolalsoSource,AclModerequiredPerms);
2222
externboolinterpretInhOption(InhOptioninhOpt);
23+
externboolinterpretOidsOption(ContainsOidsopt);
2324

2425
externNode*transformWhereClause(ParseState*pstate,Node*clause,
2526
constchar*constructName);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp