mirror of
https://github.com/postgres/postgres.git
synced 2025-09-08 00:47:37 +03:00
Make backend header files C++ safe
This alters various incidental uses of C++ key words to use other similar identifiers, so that a C++ compiler won't choke outright. You still (probably) need extern "C" { }; around the inclusion of backend headers. based on a patch by Kurt Harriman <harriman@acm.org> Also add a script cpluspluscheck to check for C++ compatibility in the future. As of right now, this passes without error for me.
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.669 2009/07/14 20:24:10 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.670 2009/07/16 06:33:43 petere Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -2127,7 +2127,7 @@ columnDef: ColId Typename ColQualList
|
||||
{
|
||||
ColumnDef *n = makeNode(ColumnDef);
|
||||
n->colname = $1;
|
||||
n->typename = $2;
|
||||
n->typeName = $2;
|
||||
n->constraints = $3;
|
||||
n->is_local = true;
|
||||
$$ = (Node *)n;
|
||||
@@ -2574,7 +2574,7 @@ CreateAsElement:
|
||||
{
|
||||
ColumnDef *n = makeNode(ColumnDef);
|
||||
n->colname = $1;
|
||||
n->typename = NULL;
|
||||
n->typeName = NULL;
|
||||
n->inhcount = 0;
|
||||
n->is_local = true;
|
||||
n->is_not_null = false;
|
||||
@@ -3461,7 +3461,7 @@ DefineStmt:
|
||||
| CREATE TYPE_P any_name AS ENUM_P '(' enum_val_list ')'
|
||||
{
|
||||
CreateEnumStmt *n = makeNode(CreateEnumStmt);
|
||||
n->typename = $3;
|
||||
n->typeName = $3;
|
||||
n->vals = $7;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
@@ -6144,7 +6144,7 @@ CreateDomainStmt:
|
||||
{
|
||||
CreateDomainStmt *n = makeNode(CreateDomainStmt);
|
||||
n->domainname = $3;
|
||||
n->typename = $5;
|
||||
n->typeName = $5;
|
||||
n->constraints = $6;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
@@ -6156,7 +6156,7 @@ AlterDomainStmt:
|
||||
{
|
||||
AlterDomainStmt *n = makeNode(AlterDomainStmt);
|
||||
n->subtype = 'T';
|
||||
n->typename = $3;
|
||||
n->typeName = $3;
|
||||
n->def = $4;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
@@ -6165,7 +6165,7 @@ AlterDomainStmt:
|
||||
{
|
||||
AlterDomainStmt *n = makeNode(AlterDomainStmt);
|
||||
n->subtype = 'N';
|
||||
n->typename = $3;
|
||||
n->typeName = $3;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
/* ALTER DOMAIN <domain> SET NOT NULL */
|
||||
@@ -6173,7 +6173,7 @@ AlterDomainStmt:
|
||||
{
|
||||
AlterDomainStmt *n = makeNode(AlterDomainStmt);
|
||||
n->subtype = 'O';
|
||||
n->typename = $3;
|
||||
n->typeName = $3;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
/* ALTER DOMAIN <domain> ADD CONSTRAINT ... */
|
||||
@@ -6181,7 +6181,7 @@ AlterDomainStmt:
|
||||
{
|
||||
AlterDomainStmt *n = makeNode(AlterDomainStmt);
|
||||
n->subtype = 'C';
|
||||
n->typename = $3;
|
||||
n->typeName = $3;
|
||||
n->def = $5;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
@@ -6190,7 +6190,7 @@ AlterDomainStmt:
|
||||
{
|
||||
AlterDomainStmt *n = makeNode(AlterDomainStmt);
|
||||
n->subtype = 'X';
|
||||
n->typename = $3;
|
||||
n->typeName = $3;
|
||||
n->name = $6;
|
||||
n->behavior = $7;
|
||||
$$ = (Node *)n;
|
||||
@@ -7463,7 +7463,7 @@ joined_table:
|
||||
n->isNatural = FALSE;
|
||||
n->larg = $1;
|
||||
n->rarg = $4;
|
||||
n->using = NIL;
|
||||
n->usingClause = NIL;
|
||||
n->quals = NULL;
|
||||
$$ = n;
|
||||
}
|
||||
@@ -7475,7 +7475,7 @@ joined_table:
|
||||
n->larg = $1;
|
||||
n->rarg = $4;
|
||||
if ($5 != NULL && IsA($5, List))
|
||||
n->using = (List *) $5; /* USING clause */
|
||||
n->usingClause = (List *) $5; /* USING clause */
|
||||
else
|
||||
n->quals = $5; /* ON clause */
|
||||
$$ = n;
|
||||
@@ -7489,7 +7489,7 @@ joined_table:
|
||||
n->larg = $1;
|
||||
n->rarg = $3;
|
||||
if ($4 != NULL && IsA($4, List))
|
||||
n->using = (List *) $4; /* USING clause */
|
||||
n->usingClause = (List *) $4; /* USING clause */
|
||||
else
|
||||
n->quals = $4; /* ON clause */
|
||||
$$ = n;
|
||||
@@ -7501,7 +7501,7 @@ joined_table:
|
||||
n->isNatural = TRUE;
|
||||
n->larg = $1;
|
||||
n->rarg = $5;
|
||||
n->using = NIL; /* figure out which columns later... */
|
||||
n->usingClause = NIL; /* figure out which columns later... */
|
||||
n->quals = NULL; /* fill later */
|
||||
$$ = n;
|
||||
}
|
||||
@@ -7513,7 +7513,7 @@ joined_table:
|
||||
n->isNatural = TRUE;
|
||||
n->larg = $1;
|
||||
n->rarg = $4;
|
||||
n->using = NIL; /* figure out which columns later... */
|
||||
n->usingClause = NIL; /* figure out which columns later... */
|
||||
n->quals = NULL; /* fill later */
|
||||
$$ = n;
|
||||
}
|
||||
@@ -7684,7 +7684,7 @@ TableFuncElement: ColId Typename
|
||||
{
|
||||
ColumnDef *n = makeNode(ColumnDef);
|
||||
n->colname = $1;
|
||||
n->typename = $2;
|
||||
n->typeName = $2;
|
||||
n->constraints = NIL;
|
||||
n->is_local = true;
|
||||
$$ = (Node *)n;
|
||||
@@ -9280,7 +9280,7 @@ func_expr: func_name '(' ')' over_clause
|
||||
XmlSerialize *n = makeNode(XmlSerialize);
|
||||
n->xmloption = $3;
|
||||
n->expr = $4;
|
||||
n->typename = $6;
|
||||
n->typeName = $6;
|
||||
n->location = @1;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
@@ -10668,7 +10668,7 @@ makeTypeCast(Node *arg, TypeName *typename, int location)
|
||||
{
|
||||
TypeCast *n = makeNode(TypeCast);
|
||||
n->arg = arg;
|
||||
n->typename = typename;
|
||||
n->typeName = typename;
|
||||
n->location = location;
|
||||
return (Node *) n;
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.189 2009/06/11 14:49:00 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.190 2009/07/16 06:33:43 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -796,7 +796,7 @@ transformFromClauseItem(ParseState *pstate, Node *n,
|
||||
ListCell *lx,
|
||||
*rx;
|
||||
|
||||
Assert(j->using == NIL); /* shouldn't have USING() too */
|
||||
Assert(j->usingClause == NIL); /* shouldn't have USING() too */
|
||||
|
||||
foreach(lx, l_colnames)
|
||||
{
|
||||
@@ -819,7 +819,7 @@ transformFromClauseItem(ParseState *pstate, Node *n,
|
||||
rlist = lappend(rlist, m_name);
|
||||
}
|
||||
|
||||
j->using = rlist;
|
||||
j->usingClause = rlist;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -828,14 +828,14 @@ transformFromClauseItem(ParseState *pstate, Node *n,
|
||||
res_colnames = NIL;
|
||||
res_colvars = NIL;
|
||||
|
||||
if (j->using)
|
||||
if (j->usingClause)
|
||||
{
|
||||
/*
|
||||
* JOIN/USING (or NATURAL JOIN, as transformed above). Transform
|
||||
* the list into an explicit ON-condition, and generate a list of
|
||||
* merged result columns.
|
||||
*/
|
||||
List *ucols = j->using;
|
||||
List *ucols = j->usingClause;
|
||||
List *l_usingvars = NIL;
|
||||
List *r_usingvars = NIL;
|
||||
ListCell *ucol;
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.241 2009/06/11 14:49:00 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.242 2009/07/16 06:33:43 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -159,7 +159,7 @@ transformExpr(ParseState *pstate, Node *expr)
|
||||
Oid elementType;
|
||||
int32 targetTypmod;
|
||||
|
||||
targetType = typenameTypeId(pstate, tc->typename,
|
||||
targetType = typenameTypeId(pstate, tc->typeName,
|
||||
&targetTypmod);
|
||||
elementType = get_element_type(targetType);
|
||||
if (OidIsValid(elementType))
|
||||
@@ -1773,7 +1773,7 @@ transformXmlSerialize(ParseState *pstate, XmlSerialize *xs)
|
||||
XMLOID,
|
||||
"XMLSERIALIZE"));
|
||||
|
||||
targetType = typenameTypeId(pstate, xs->typename, &targetTypmod);
|
||||
targetType = typenameTypeId(pstate, xs->typeName, &targetTypmod);
|
||||
|
||||
xexpr->xmloption = xs->xmloption;
|
||||
xexpr->location = xs->location;
|
||||
@@ -2000,7 +2000,7 @@ transformTypeCast(ParseState *pstate, TypeCast *tc)
|
||||
int32 targetTypmod;
|
||||
int location;
|
||||
|
||||
targetType = typenameTypeId(pstate, tc->typename, &targetTypmod);
|
||||
targetType = typenameTypeId(pstate, tc->typeName, &targetTypmod);
|
||||
|
||||
if (inputType == InvalidOid)
|
||||
return expr; /* do nothing if NULL input */
|
||||
@@ -2012,7 +2012,7 @@ transformTypeCast(ParseState *pstate, TypeCast *tc)
|
||||
*/
|
||||
location = tc->location;
|
||||
if (location < 0)
|
||||
location = tc->typename->location;
|
||||
location = tc->typeName->location;
|
||||
|
||||
result = coerce_to_target_type(pstate, expr, inputType,
|
||||
targetType, targetTypmod,
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.142 2009/06/11 14:49:00 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.143 2009/07/16 06:33:43 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1188,13 +1188,13 @@ addRangeTableEntryForFunction(ParseState *pstate,
|
||||
int32 attrtypmod;
|
||||
|
||||
attrname = pstrdup(n->colname);
|
||||
if (n->typename->setof)
|
||||
if (n->typeName->setof)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
|
||||
errmsg("column \"%s\" cannot be declared SETOF",
|
||||
attrname),
|
||||
parser_errposition(pstate, n->typename->location)));
|
||||
attrtype = typenameTypeId(pstate, n->typename, &attrtypmod);
|
||||
parser_errposition(pstate, n->typeName->location)));
|
||||
attrtype = typenameTypeId(pstate, n->typeName, &attrtypmod);
|
||||
eref->colnames = lappend(eref->colnames, makeString(attrname));
|
||||
rte->funccoltypes = lappend_oid(rte->funccoltypes, attrtype);
|
||||
rte->funccoltypmods = lappend_int(rte->funccoltypmods, attrtypmod);
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.171 2009/06/11 14:49:00 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.172 2009/07/16 06:33:43 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -1373,9 +1373,9 @@ FigureColnameInternal(Node *node, char **name)
|
||||
name);
|
||||
if (strength <= 1)
|
||||
{
|
||||
if (((TypeCast *) node)->typename != NULL)
|
||||
if (((TypeCast *) node)->typeName != NULL)
|
||||
{
|
||||
*name = strVal(llast(((TypeCast *) node)->typename->names));
|
||||
*name = strVal(llast(((TypeCast *) node)->typeName->names));
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.103 2009/06/11 14:49:00 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.104 2009/07/16 06:33:43 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "utils/syscache.h"
|
||||
|
||||
|
||||
static int32 typenameTypeMod(ParseState *pstate, const TypeName *typename,
|
||||
static int32 typenameTypeMod(ParseState *pstate, const TypeName *typeName,
|
||||
Type typ);
|
||||
|
||||
|
||||
@@ -54,57 +54,57 @@ static int32 typenameTypeMod(ParseState *pstate, const TypeName *typename,
|
||||
* pstate is only used for error location info, and may be NULL.
|
||||
*/
|
||||
Type
|
||||
LookupTypeName(ParseState *pstate, const TypeName *typename,
|
||||
LookupTypeName(ParseState *pstate, const TypeName *typeName,
|
||||
int32 *typmod_p)
|
||||
{
|
||||
Oid typoid;
|
||||
HeapTuple tup;
|
||||
int32 typmod;
|
||||
|
||||
if (typename->names == NIL)
|
||||
if (typeName->names == NIL)
|
||||
{
|
||||
/* We have the OID already if it's an internally generated TypeName */
|
||||
typoid = typename->typeid;
|
||||
typoid = typeName->typeOid;
|
||||
}
|
||||
else if (typename->pct_type)
|
||||
else if (typeName->pct_type)
|
||||
{
|
||||
/* Handle %TYPE reference to type of an existing field */
|
||||
RangeVar *rel = makeRangeVar(NULL, NULL, typename->location);
|
||||
RangeVar *rel = makeRangeVar(NULL, NULL, typeName->location);
|
||||
char *field = NULL;
|
||||
Oid relid;
|
||||
AttrNumber attnum;
|
||||
|
||||
/* deconstruct the name list */
|
||||
switch (list_length(typename->names))
|
||||
switch (list_length(typeName->names))
|
||||
{
|
||||
case 1:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("improper %%TYPE reference (too few dotted names): %s",
|
||||
NameListToString(typename->names)),
|
||||
parser_errposition(pstate, typename->location)));
|
||||
NameListToString(typeName->names)),
|
||||
parser_errposition(pstate, typeName->location)));
|
||||
break;
|
||||
case 2:
|
||||
rel->relname = strVal(linitial(typename->names));
|
||||
field = strVal(lsecond(typename->names));
|
||||
rel->relname = strVal(linitial(typeName->names));
|
||||
field = strVal(lsecond(typeName->names));
|
||||
break;
|
||||
case 3:
|
||||
rel->schemaname = strVal(linitial(typename->names));
|
||||
rel->relname = strVal(lsecond(typename->names));
|
||||
field = strVal(lthird(typename->names));
|
||||
rel->schemaname = strVal(linitial(typeName->names));
|
||||
rel->relname = strVal(lsecond(typeName->names));
|
||||
field = strVal(lthird(typeName->names));
|
||||
break;
|
||||
case 4:
|
||||
rel->catalogname = strVal(linitial(typename->names));
|
||||
rel->schemaname = strVal(lsecond(typename->names));
|
||||
rel->relname = strVal(lthird(typename->names));
|
||||
field = strVal(lfourth(typename->names));
|
||||
rel->catalogname = strVal(linitial(typeName->names));
|
||||
rel->schemaname = strVal(lsecond(typeName->names));
|
||||
rel->relname = strVal(lthird(typeName->names));
|
||||
field = strVal(lfourth(typeName->names));
|
||||
break;
|
||||
default:
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("improper %%TYPE reference (too many dotted names): %s",
|
||||
NameListToString(typename->names)),
|
||||
parser_errposition(pstate, typename->location)));
|
||||
NameListToString(typeName->names)),
|
||||
parser_errposition(pstate, typeName->location)));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -116,16 +116,16 @@ LookupTypeName(ParseState *pstate, const TypeName *typename,
|
||||
(errcode(ERRCODE_UNDEFINED_COLUMN),
|
||||
errmsg("column \"%s\" of relation \"%s\" does not exist",
|
||||
field, rel->relname),
|
||||
parser_errposition(pstate, typename->location)));
|
||||
parser_errposition(pstate, typeName->location)));
|
||||
typoid = get_atttype(relid, attnum);
|
||||
|
||||
/* this construct should never have an array indicator */
|
||||
Assert(typename->arrayBounds == NIL);
|
||||
Assert(typeName->arrayBounds == NIL);
|
||||
|
||||
/* emit nuisance notice (intentionally not errposition'd) */
|
||||
ereport(NOTICE,
|
||||
(errmsg("type reference %s converted to %s",
|
||||
TypeNameToString(typename),
|
||||
TypeNameToString(typeName),
|
||||
format_type_be(typoid))));
|
||||
}
|
||||
else
|
||||
@@ -135,7 +135,7 @@ LookupTypeName(ParseState *pstate, const TypeName *typename,
|
||||
char *typname;
|
||||
|
||||
/* deconstruct the name list */
|
||||
DeconstructQualifiedName(typename->names, &schemaname, &typname);
|
||||
DeconstructQualifiedName(typeName->names, &schemaname, &typname);
|
||||
|
||||
if (schemaname)
|
||||
{
|
||||
@@ -155,7 +155,7 @@ LookupTypeName(ParseState *pstate, const TypeName *typename,
|
||||
}
|
||||
|
||||
/* If an array reference, return the array type instead */
|
||||
if (typename->arrayBounds != NIL)
|
||||
if (typeName->arrayBounds != NIL)
|
||||
typoid = get_array_type(typoid);
|
||||
}
|
||||
|
||||
@@ -172,7 +172,7 @@ LookupTypeName(ParseState *pstate, const TypeName *typename,
|
||||
if (!HeapTupleIsValid(tup)) /* should not happen */
|
||||
elog(ERROR, "cache lookup failed for type %u", typoid);
|
||||
|
||||
typmod = typenameTypeMod(pstate, typename, (Type) tup);
|
||||
typmod = typenameTypeMod(pstate, typeName, (Type) tup);
|
||||
|
||||
if (typmod_p)
|
||||
*typmod_p = typmod;
|
||||
@@ -188,23 +188,23 @@ LookupTypeName(ParseState *pstate, const TypeName *typename,
|
||||
* Callers of this can therefore assume the result is a fully valid type.
|
||||
*/
|
||||
Type
|
||||
typenameType(ParseState *pstate, const TypeName *typename, int32 *typmod_p)
|
||||
typenameType(ParseState *pstate, const TypeName *typeName, int32 *typmod_p)
|
||||
{
|
||||
Type tup;
|
||||
|
||||
tup = LookupTypeName(pstate, typename, typmod_p);
|
||||
tup = LookupTypeName(pstate, typeName, typmod_p);
|
||||
if (tup == NULL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("type \"%s\" does not exist",
|
||||
TypeNameToString(typename)),
|
||||
parser_errposition(pstate, typename->location)));
|
||||
TypeNameToString(typeName)),
|
||||
parser_errposition(pstate, typeName->location)));
|
||||
if (!((Form_pg_type) GETSTRUCT(tup))->typisdefined)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||
errmsg("type \"%s\" is only a shell",
|
||||
TypeNameToString(typename)),
|
||||
parser_errposition(pstate, typename->location)));
|
||||
TypeNameToString(typeName)),
|
||||
parser_errposition(pstate, typeName->location)));
|
||||
return tup;
|
||||
}
|
||||
|
||||
@@ -215,12 +215,12 @@ typenameType(ParseState *pstate, const TypeName *typename, int32 *typmod_p)
|
||||
* not the syscache entry.
|
||||
*/
|
||||
Oid
|
||||
typenameTypeId(ParseState *pstate, const TypeName *typename, int32 *typmod_p)
|
||||
typenameTypeId(ParseState *pstate, const TypeName *typeName, int32 *typmod_p)
|
||||
{
|
||||
Oid typoid;
|
||||
Type tup;
|
||||
|
||||
tup = typenameType(pstate, typename, typmod_p);
|
||||
tup = typenameType(pstate, typeName, typmod_p);
|
||||
typoid = HeapTupleGetOid(tup);
|
||||
ReleaseSysCache(tup);
|
||||
|
||||
@@ -239,7 +239,7 @@ typenameTypeId(ParseState *pstate, const TypeName *typename, int32 *typmod_p)
|
||||
* pstate is only used for error location info, and may be NULL.
|
||||
*/
|
||||
static int32
|
||||
typenameTypeMod(ParseState *pstate, const TypeName *typename, Type typ)
|
||||
typenameTypeMod(ParseState *pstate, const TypeName *typeName, Type typ)
|
||||
{
|
||||
int32 result;
|
||||
Oid typmodin;
|
||||
@@ -250,8 +250,8 @@ typenameTypeMod(ParseState *pstate, const TypeName *typename, Type typ)
|
||||
ParseCallbackState pcbstate;
|
||||
|
||||
/* Return prespecified typmod if no typmod expressions */
|
||||
if (typename->typmods == NIL)
|
||||
return typename->typemod;
|
||||
if (typeName->typmods == NIL)
|
||||
return typeName->typemod;
|
||||
|
||||
/*
|
||||
* Else, type had better accept typmods. We give a special error message
|
||||
@@ -262,8 +262,8 @@ typenameTypeMod(ParseState *pstate, const TypeName *typename, Type typ)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("type modifier cannot be specified for shell type \"%s\"",
|
||||
TypeNameToString(typename)),
|
||||
parser_errposition(pstate, typename->location)));
|
||||
TypeNameToString(typeName)),
|
||||
parser_errposition(pstate, typeName->location)));
|
||||
|
||||
typmodin = ((Form_pg_type) GETSTRUCT(typ))->typmodin;
|
||||
|
||||
@@ -271,17 +271,17 @@ typenameTypeMod(ParseState *pstate, const TypeName *typename, Type typ)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("type modifier is not allowed for type \"%s\"",
|
||||
TypeNameToString(typename)),
|
||||
parser_errposition(pstate, typename->location)));
|
||||
TypeNameToString(typeName)),
|
||||
parser_errposition(pstate, typeName->location)));
|
||||
|
||||
/*
|
||||
* Convert the list of raw-grammar-output expressions to a cstring array.
|
||||
* Currently, we allow simple numeric constants, string literals, and
|
||||
* identifiers; possibly this list could be extended.
|
||||
*/
|
||||
datums = (Datum *) palloc(list_length(typename->typmods) * sizeof(Datum));
|
||||
datums = (Datum *) palloc(list_length(typeName->typmods) * sizeof(Datum));
|
||||
n = 0;
|
||||
foreach(l, typename->typmods)
|
||||
foreach(l, typeName->typmods)
|
||||
{
|
||||
Node *tm = (Node *) lfirst(l);
|
||||
char *cstr = NULL;
|
||||
@@ -314,7 +314,7 @@ typenameTypeMod(ParseState *pstate, const TypeName *typename, Type typ)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_SYNTAX_ERROR),
|
||||
errmsg("type modifiers must be simple constants or identifiers"),
|
||||
parser_errposition(pstate, typename->location)));
|
||||
parser_errposition(pstate, typeName->location)));
|
||||
datums[n++] = CStringGetDatum(cstr);
|
||||
}
|
||||
|
||||
@@ -323,7 +323,7 @@ typenameTypeMod(ParseState *pstate, const TypeName *typename, Type typ)
|
||||
-2, false, 'c');
|
||||
|
||||
/* arrange to report location if type's typmodin function fails */
|
||||
setup_parser_errposition_callback(&pcbstate, pstate, typename->location);
|
||||
setup_parser_errposition_callback(&pcbstate, pstate, typeName->location);
|
||||
|
||||
result = DatumGetInt32(OidFunctionCall1(typmodin,
|
||||
PointerGetDatum(arrtypmod)));
|
||||
@@ -345,16 +345,16 @@ typenameTypeMod(ParseState *pstate, const TypeName *typename, Type typ)
|
||||
* it is mostly used for reporting lookup errors.
|
||||
*/
|
||||
static void
|
||||
appendTypeNameToBuffer(const TypeName *typename, StringInfo string)
|
||||
appendTypeNameToBuffer(const TypeName *typeName, StringInfo string)
|
||||
{
|
||||
if (typename->names != NIL)
|
||||
if (typeName->names != NIL)
|
||||
{
|
||||
/* Emit possibly-qualified name as-is */
|
||||
ListCell *l;
|
||||
|
||||
foreach(l, typename->names)
|
||||
foreach(l, typeName->names)
|
||||
{
|
||||
if (l != list_head(typename->names))
|
||||
if (l != list_head(typeName->names))
|
||||
appendStringInfoChar(string, '.');
|
||||
appendStringInfoString(string, strVal(lfirst(l)));
|
||||
}
|
||||
@@ -362,17 +362,17 @@ appendTypeNameToBuffer(const TypeName *typename, StringInfo string)
|
||||
else
|
||||
{
|
||||
/* Look up internally-specified type */
|
||||
appendStringInfoString(string, format_type_be(typename->typeid));
|
||||
appendStringInfoString(string, format_type_be(typeName->typeOid));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add decoration as needed, but only for fields considered by
|
||||
* LookupTypeName
|
||||
*/
|
||||
if (typename->pct_type)
|
||||
if (typeName->pct_type)
|
||||
appendStringInfoString(string, "%TYPE");
|
||||
|
||||
if (typename->arrayBounds != NIL)
|
||||
if (typeName->arrayBounds != NIL)
|
||||
appendStringInfoString(string, "[]");
|
||||
}
|
||||
|
||||
@@ -384,12 +384,12 @@ appendTypeNameToBuffer(const TypeName *typename, StringInfo string)
|
||||
* it is mostly used for reporting lookup errors.
|
||||
*/
|
||||
char *
|
||||
TypeNameToString(const TypeName *typename)
|
||||
TypeNameToString(const TypeName *typeName)
|
||||
{
|
||||
StringInfoData string;
|
||||
|
||||
initStringInfo(&string);
|
||||
appendTypeNameToBuffer(typename, &string);
|
||||
appendTypeNameToBuffer(typeName, &string);
|
||||
return string.data;
|
||||
}
|
||||
|
||||
@@ -406,12 +406,12 @@ TypeNameListToString(List *typenames)
|
||||
initStringInfo(&string);
|
||||
foreach(l, typenames)
|
||||
{
|
||||
TypeName *typename = (TypeName *) lfirst(l);
|
||||
TypeName *typeName = (TypeName *) lfirst(l);
|
||||
|
||||
Assert(IsA(typename, TypeName));
|
||||
Assert(IsA(typeName, TypeName));
|
||||
if (l != list_head(typenames))
|
||||
appendStringInfoChar(&string, ',');
|
||||
appendTypeNameToBuffer(typename, &string);
|
||||
appendTypeNameToBuffer(typeName, &string);
|
||||
}
|
||||
return string.data;
|
||||
}
|
||||
@@ -575,7 +575,7 @@ parseTypeString(const char *str, Oid *type_id, int32 *typmod_p)
|
||||
SelectStmt *stmt;
|
||||
ResTarget *restarget;
|
||||
TypeCast *typecast;
|
||||
TypeName *typename;
|
||||
TypeName *typeName;
|
||||
ErrorContextCallback ptserrcontext;
|
||||
|
||||
/* make sure we give useful error for empty input */
|
||||
@@ -635,14 +635,14 @@ parseTypeString(const char *str, Oid *type_id, int32 *typmod_p)
|
||||
typecast->arg == NULL ||
|
||||
!IsA(typecast->arg, A_Const))
|
||||
goto fail;
|
||||
typename = typecast->typename;
|
||||
if (typename == NULL ||
|
||||
!IsA(typename, TypeName))
|
||||
typeName = typecast->typeName;
|
||||
if (typeName == NULL ||
|
||||
!IsA(typeName, TypeName))
|
||||
goto fail;
|
||||
if (typename->setof)
|
||||
if (typeName->setof)
|
||||
goto fail;
|
||||
|
||||
*type_id = typenameTypeId(NULL, typename, typmod_p);
|
||||
*type_id = typenameTypeId(NULL, typeName, typmod_p);
|
||||
|
||||
pfree(buf.data);
|
||||
|
||||
|
@@ -19,7 +19,7 @@
|
||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.22 2009/07/12 17:12:34 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/parser/parse_utilcmd.c,v 2.23 2009/07/16 06:33:43 petere Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -266,24 +266,24 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
||||
|
||||
/* Check for SERIAL pseudo-types */
|
||||
is_serial = false;
|
||||
if (list_length(column->typename->names) == 1 &&
|
||||
!column->typename->pct_type)
|
||||
if (list_length(column->typeName->names) == 1 &&
|
||||
!column->typeName->pct_type)
|
||||
{
|
||||
char *typname = strVal(linitial(column->typename->names));
|
||||
char *typname = strVal(linitial(column->typeName->names));
|
||||
|
||||
if (strcmp(typname, "serial") == 0 ||
|
||||
strcmp(typname, "serial4") == 0)
|
||||
{
|
||||
is_serial = true;
|
||||
column->typename->names = NIL;
|
||||
column->typename->typeid = INT4OID;
|
||||
column->typeName->names = NIL;
|
||||
column->typeName->typeOid = INT4OID;
|
||||
}
|
||||
else if (strcmp(typname, "bigserial") == 0 ||
|
||||
strcmp(typname, "serial8") == 0)
|
||||
{
|
||||
is_serial = true;
|
||||
column->typename->names = NIL;
|
||||
column->typename->typeid = INT8OID;
|
||||
column->typeName->names = NIL;
|
||||
column->typeName->typeOid = INT8OID;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -291,7 +291,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
||||
* typeid, LookupTypeName won't notice arrayBounds. We don't need any
|
||||
* special coding for serial(typmod) though.
|
||||
*/
|
||||
if (is_serial && column->typename->arrayBounds != NIL)
|
||||
if (is_serial && column->typeName->arrayBounds != NIL)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("array of serial is not implemented")));
|
||||
@@ -382,7 +382,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
|
||||
snamenode->val.val.str = qstring;
|
||||
snamenode->location = -1;
|
||||
castnode = makeNode(TypeCast);
|
||||
castnode->typename = SystemTypeName("regclass");
|
||||
castnode->typeName = SystemTypeName("regclass");
|
||||
castnode->arg = (Node *) snamenode;
|
||||
castnode->location = -1;
|
||||
funccallnode = makeNode(FuncCall);
|
||||
@@ -623,7 +623,7 @@ transformInhRelation(ParseState *pstate, CreateStmtContext *cxt,
|
||||
*/
|
||||
def = makeNode(ColumnDef);
|
||||
def->colname = pstrdup(attributeName);
|
||||
def->typename = makeTypeNameFromOid(attribute->atttypid,
|
||||
def->typeName = makeTypeNameFromOid(attribute->atttypid,
|
||||
attribute->atttypmod);
|
||||
def->inhcount = 0;
|
||||
def->is_local = true;
|
||||
@@ -1969,7 +1969,7 @@ transformColumnType(ParseState *pstate, ColumnDef *column)
|
||||
/*
|
||||
* All we really need to do here is verify that the type is valid.
|
||||
*/
|
||||
Type ctype = typenameType(pstate, column->typename, NULL);
|
||||
Type ctype = typenameType(pstate, column->typeName, NULL);
|
||||
|
||||
ReleaseSysCache(ctype);
|
||||
}
|
||||
|
Reference in New Issue
Block a user