1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-09 06:21:09 +03:00

Use the new List API function names throughout the backend, and disable the

list compatibility API by default. While doing this, I decided to keep
the llast() macro around and introduce llast_int() and llast_oid() variants.
This commit is contained in:
Neil Conway
2004-05-30 23:40:41 +00:00
parent ec0b1f2716
commit 72b6ad6313
83 changed files with 798 additions and 828 deletions

View File

@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.301 2004/05/26 04:41:29 neilc Exp $
* $PostgreSQL: pgsql/src/backend/parser/analyze.c,v 1.302 2004/05/30 23:40:32 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -248,12 +248,12 @@ do_parse_analyze(Node *parseTree, ParseState *pstate)
release_pstate_resources(pstate);
foreach(l, extras_before)
result = nconc(result, parse_sub_analyze(lfirst(l), pstate));
result = list_concat(result, parse_sub_analyze(lfirst(l), pstate));
result = lappend(result, query);
foreach(l, extras_after)
result = nconc(result, parse_sub_analyze(lfirst(l), pstate));
result = list_concat(result, parse_sub_analyze(lfirst(l), pstate));
/*
* Make sure that only the original query is marked original. We have
@@ -592,7 +592,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
true);
rtr = makeNode(RangeTblRef);
/* assume new rte is at end */
rtr->rtindex = length(pstate->p_rtable);
rtr->rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(rtr->rtindex, pstate->p_rtable));
pstate->p_joinlist = lappend(pstate->p_joinlist, rtr);
@@ -674,7 +674,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt,
Assert(IsA(col, ResTarget));
Assert(!tle->resdom->resjunk);
updateTargetListEntry(pstate, tle, col->name, lfirsti(attnos),
updateTargetListEntry(pstate, tle, col->name, lfirst_int(attnos),
col->indirection);
icols = lnext(icols);
@@ -874,8 +874,8 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt,
q->utilityStmt = (Node *) stmt;
stmt->tableElts = cxt.columns;
stmt->constraints = cxt.ckconstraints;
*extras_before = nconc(*extras_before, cxt.blist);
*extras_after = nconc(cxt.alist, *extras_after);
*extras_before = list_concat(*extras_before, cxt.blist);
*extras_after = list_concat(cxt.alist, *extras_after);
return q;
}
@@ -893,7 +893,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
/* Check for SERIAL pseudo-types */
is_serial = false;
if (length(column->typename->names) == 1)
if (list_length(column->typename->names) == 1)
{
char *typname = strVal(linitial(column->typename->names));
@@ -969,7 +969,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
snamenode->val.val.str = qstring;
funccallnode = makeNode(FuncCall);
funccallnode->funcname = SystemFuncName("nextval");
funccallnode->args = makeList1(snamenode);
funccallnode->args = list_make1(snamenode);
funccallnode->agg_star = false;
funccallnode->agg_distinct = false;
@@ -1004,7 +1004,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
{
FkConstraint *fkconstraint = (FkConstraint *) constraint;
fkconstraint->fk_attrs = makeList1(makeString(column->colname));
fkconstraint->fk_attrs = list_make1(makeString(column->colname));
cxt->fkconstraints = lappend(cxt->fkconstraints, fkconstraint);
continue;
}
@@ -1049,7 +1049,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
NULL,
"pkey");
if (constraint->keys == NIL)
constraint->keys = makeList1(makeString(column->colname));
constraint->keys = list_make1(makeString(column->colname));
cxt->ixconstraints = lappend(cxt->ixconstraints, constraint);
break;
@@ -1059,7 +1059,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt,
column->colname,
"key");
if (constraint->keys == NIL)
constraint->keys = makeList1(makeString(column->colname));
constraint->keys = list_make1(makeString(column->colname));
cxt->ixconstraints = lappend(cxt->ixconstraints, constraint);
break;
@@ -1437,7 +1437,7 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt)
if (cxt->pkey != NULL)
{
/* Make sure we keep the PKEY index in preference to others... */
cxt->alist = makeList1(cxt->pkey);
cxt->alist = list_make1(cxt->pkey);
}
foreach(l, indexlist)
@@ -1679,7 +1679,7 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt,
stmt->whereClause = transformWhereClause(pstate, stmt->whereClause,
"WHERE");
if (length(pstate->p_rtable) != 2) /* naughty, naughty... */
if (list_length(pstate->p_rtable) != 2) /* naughty, naughty... */
ereport(ERROR,
(errcode(ERRCODE_INVALID_OBJECT_DEFINITION),
errmsg("rule WHERE condition may not contain references to other relations")));
@@ -1708,7 +1708,7 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt,
nothing_qry->rtable = pstate->p_rtable;
nothing_qry->jointree = makeFromExpr(NIL, NULL); /* no join wanted */
stmt->actions = makeList1(nothing_qry);
stmt->actions = list_make1(nothing_qry);
}
else
{
@@ -2062,7 +2062,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
foreach(dtlist, sostmt->colTypes)
{
Oid colType = lfirsto(dtlist);
Oid colType = lfirst_oid(dtlist);
Resdom *leftResdom;
char *colName;
Resdom *resdom;
@@ -2123,10 +2123,10 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
jrtr->rtindex = 1; /* only entry in dummy rtable */
sv_rtable = pstate->p_rtable;
pstate->p_rtable = makeList1(jrte);
pstate->p_rtable = list_make1(jrte);
sv_namespace = pstate->p_namespace;
pstate->p_namespace = makeList1(jrtr);
pstate->p_namespace = list_make1(jrtr);
/*
* For now, we don't support resjunk sort clauses on the output of a
@@ -2134,7 +2134,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
* selecting an output column by name or number. Enforce by checking
* that transformSortClause doesn't add any items to tlist.
*/
tllen = length(qry->targetList);
tllen = list_length(qry->targetList);
qry->sortClause = transformSortClause(pstate,
sortClause,
@@ -2144,7 +2144,7 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt)
pstate->p_namespace = sv_namespace;
pstate->p_rtable = sv_rtable;
if (tllen != length(qry->targetList))
if (tllen != list_length(qry->targetList))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("ORDER BY on a UNION/INTERSECT/EXCEPT result must be on one of the result columns")));
@@ -2231,7 +2231,7 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt)
*/
selectList = parse_sub_analyze((Node *) stmt, pstate);
Assert(length(selectList) == 1);
Assert(list_length(selectList) == 1);
selectQuery = (Query *) linitial(selectList);
Assert(IsA(selectQuery, Query));
@@ -2253,7 +2253,7 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt)
* Make the leaf query be a subquery in the top-level rangetable.
*/
snprintf(selectName, sizeof(selectName), "*SELECT* %d",
length(pstate->p_rtable) + 1);
list_length(pstate->p_rtable) + 1);
rte = addRangeTableEntryForSubquery(pstate,
selectQuery,
makeAlias(selectName, NIL),
@@ -2265,7 +2265,7 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt)
*/
rtr = makeNode(RangeTblRef);
/* assume new rte is at end */
rtr->rtindex = length(pstate->p_rtable);
rtr->rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(rtr->rtindex, pstate->p_rtable));
return (Node *) rtr;
}
@@ -2298,7 +2298,7 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt)
*/
lcoltypes = getSetColTypes(pstate, op->larg);
rcoltypes = getSetColTypes(pstate, op->rarg);
if (length(lcoltypes) != length(rcoltypes))
if (list_length(lcoltypes) != list_length(rcoltypes))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("each %s query must have the same number of columns",
@@ -2307,13 +2307,13 @@ transformSetOperationTree(ParseState *pstate, SelectStmt *stmt)
op->colTypes = NIL;
forboth(l, lcoltypes, r, rcoltypes)
{
Oid lcoltype = lfirsto(l);
Oid rcoltype = lfirsto(r);
Oid lcoltype = lfirst_oid(l);
Oid rcoltype = lfirst_oid(r);
Oid rescoltype;
rescoltype = select_common_type(makeListo2(lcoltype, rcoltype),
rescoltype = select_common_type(list_make2_oid(lcoltype, rcoltype),
context);
op->colTypes = lappendo(op->colTypes, rescoltype);
op->colTypes = lappend_oid(op->colTypes, rescoltype);
}
return (Node *) op;
@@ -2344,7 +2344,7 @@ getSetColTypes(ParseState *pstate, Node *node)
if (resnode->resjunk)
continue;
result = lappendo(result, resnode->restype);
result = lappend_oid(result, resnode->restype);
}
return result;
}
@@ -2370,7 +2370,7 @@ applyColumnNames(List *dst, List *src)
ListCell *dst_item = list_head(dst);
ListCell *src_item = list_head(src);
if (length(src) > length(dst))
if (list_length(src) > list_length(dst))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("CREATE TABLE AS specifies too many column names")));
@@ -2632,8 +2632,8 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt,
qry->commandType = CMD_UTILITY;
qry->utilityStmt = (Node *) stmt;
*extras_before = nconc(*extras_before, cxt.blist);
*extras_after = nconc(cxt.alist, *extras_after);
*extras_before = list_concat(*extras_before, cxt.blist);
*extras_after = list_concat(cxt.alist, *extras_after);
return qry;
}
@@ -2681,7 +2681,7 @@ transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt)
result->utilityStmt = (Node *) stmt;
/* Transform list of TypeNames to list (and array) of type OIDs */
nargs = length(stmt->argtypes);
nargs = list_length(stmt->argtypes);
if (nargs)
{
@@ -2695,7 +2695,7 @@ transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt)
TypeName *tn = lfirst(l);
Oid toid = typenameTypeId(tn);
argtype_oids = lappendo(argtype_oids, toid);
argtype_oids = lappend_oid(argtype_oids, toid);
argtoids[i++] = toid;
}
}
@@ -2712,7 +2712,7 @@ transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt)
* Shouldn't get any extra statements, since grammar only allows
* OptimizableStmt
*/
if (length(queries) != 1)
if (list_length(queries) != 1)
elog(ERROR, "unexpected extra stuff in prepared statement");
stmt->query = linitial(queries);
@@ -2733,8 +2733,8 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt)
if (stmt->params || paramtypes)
{
int nparams = length(stmt->params);
int nexpected = length(paramtypes);
int nparams = list_length(stmt->params);
int nexpected = list_length(paramtypes);
ListCell *l, *l2;
int i = 1;
@@ -2749,7 +2749,7 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt)
forboth(l, stmt->params, l2, paramtypes)
{
Node *expr = lfirst(l);
Oid expected_type_id = lfirsto(l2);
Oid expected_type_id = lfirst_oid(l2);
Oid given_type_id;
expr = transformExpr(pstate, expr);
@@ -2838,8 +2838,8 @@ transformForUpdate(Query *qry, List *forUpdate)
switch (rte->rtekind)
{
case RTE_RELATION:
if (!intMember(i, rowMarks)) /* avoid duplicates */
rowMarks = lappendi(rowMarks, i);
if (!list_member_int(rowMarks, i)) /* avoid duplicates */
rowMarks = lappend_int(rowMarks, i);
rte->requiredPerms |= ACL_SELECT_FOR_UPDATE;
break;
case RTE_SUBQUERY:
@@ -2847,7 +2847,7 @@ transformForUpdate(Query *qry, List *forUpdate)
* FOR UPDATE of subquery is propagated to subquery's
* rels
*/
transformForUpdate(rte->subquery, makeList1(NULL));
transformForUpdate(rte->subquery, list_make1(NULL));
break;
default:
/* ignore JOIN, SPECIAL, FUNCTION RTEs */
@@ -2873,8 +2873,8 @@ transformForUpdate(Query *qry, List *forUpdate)
switch (rte->rtekind)
{
case RTE_RELATION:
if (!intMember(i, rowMarks)) /* avoid duplicates */
rowMarks = lappendi(rowMarks, i);
if (!list_member_int(rowMarks, i)) /* avoid duplicates */
rowMarks = lappend_int(rowMarks, i);
rte->requiredPerms |= ACL_SELECT_FOR_UPDATE;
break;
case RTE_SUBQUERY:
@@ -2882,7 +2882,7 @@ transformForUpdate(Query *qry, List *forUpdate)
* FOR UPDATE of subquery is propagated to
* subquery's rels
*/
transformForUpdate(rte->subquery, makeList1(NULL));
transformForUpdate(rte->subquery, list_make1(NULL));
break;
case RTE_JOIN:
ereport(ERROR,
@@ -3198,12 +3198,12 @@ analyzeCreateSchemaStmt(CreateSchemaStmt *stmt)
}
result = NIL;
result = nconc(result, cxt.sequences);
result = nconc(result, cxt.tables);
result = nconc(result, cxt.views);
result = nconc(result, cxt.indexes);
result = nconc(result, cxt.triggers);
result = nconc(result, cxt.grants);
result = list_concat(result, cxt.sequences);
result = list_concat(result, cxt.tables);
result = list_concat(result, cxt.views);
result = list_concat(result, cxt.indexes);
result = list_concat(result, cxt.triggers);
result = list_concat(result, cxt.grants);
return result;
}

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.457 2004/05/26 15:07:37 momjian Exp $
* $PostgreSQL: pgsql/src/backend/parser/gram.y,v 2.458 2004/05/30 23:40:34 neilc Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -480,7 +480,7 @@ stmtmulti: stmtmulti ';' stmt
}
| stmt
{ if ($1 != NULL)
$$ = makeList1($1);
$$ = list_make1($1);
else
$$ = NIL;
}
@@ -693,7 +693,7 @@ OptUserElem:
;
user_list: user_list ',' UserId { $$ = lappend($1, makeString($3)); }
| UserId { $$ = makeList1(makeString($1)); }
| UserId { $$ = list_make1(makeString($1)); }
;
@@ -878,7 +878,7 @@ set_rest: var_name TO var_list_or_default
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "timezone";
if ($3 != NULL)
n->args = makeList1($3);
n->args = list_make1($3);
$$ = n;
}
| TRANSACTION transaction_mode_list
@@ -900,14 +900,14 @@ set_rest: var_name TO var_list_or_default
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "client_encoding";
if ($2 != NULL)
n->args = makeList1(makeStringConst($2, NULL));
n->args = list_make1(makeStringConst($2, NULL));
$$ = n;
}
| SESSION AUTHORIZATION ColId_or_Sconst
{
VariableSetStmt *n = makeNode(VariableSetStmt);
n->name = "session_authorization";
n->args = makeList1(makeStringConst($3, NULL));
n->args = list_make1(makeStringConst($3, NULL));
$$ = n;
}
| SESSION AUTHORIZATION DEFAULT
@@ -937,7 +937,7 @@ var_list_or_default:
| DEFAULT { $$ = NIL; }
;
var_list: var_value { $$ = makeList1($1); }
var_list: var_value { $$ = list_make1($1); }
| var_list ',' var_value { $$ = lappend($1, $3); }
;
@@ -1153,7 +1153,7 @@ AlterTableStmt:
;
alter_table_cmds:
alter_table_cmd { $$ = makeList1($1); }
alter_table_cmd { $$ = list_make1($1); }
| alter_table_cmds ',' alter_table_cmd { $$ = lappend($1, $3); }
;
@@ -1348,7 +1348,7 @@ CopyStmt: COPY opt_binary qualified_name opt_column_list opt_oids
if ($8)
n->options = lappend(n->options, $8);
if ($10)
n->options = nconc(n->options, $10);
n->options = list_concat(n->options, $10);
$$ = (Node *)n;
}
;
@@ -1479,7 +1479,7 @@ CreateStmt: CREATE OptTemp TABLE qualified_name '(' OptTableElementList ')'
$4->istemp = $2;
n->relation = $4;
n->tableElts = $8;
n->inhRelations = makeList1($6);
n->inhRelations = list_make1($6);
n->constraints = NIL;
n->hasoids = $10;
n->oncommit = $11;
@@ -1511,7 +1511,7 @@ OptTableElementList:
TableElementList:
TableElement
{
$$ = makeList1($1);
$$ = list_make1($1);
}
| TableElementList ',' TableElement
{
@@ -1814,7 +1814,7 @@ opt_column_list:
;
columnList:
columnElem { $$ = makeList1($1); }
columnElem { $$ = list_make1($1); }
| columnList ',' columnElem { $$ = lappend($1, $3); }
;
@@ -1941,7 +1941,7 @@ OptCreateAs:
;
CreateAsList:
CreateAsElement { $$ = makeList1($1); }
CreateAsElement { $$ = list_make1($1); }
| CreateAsList ',' CreateAsElement { $$ = lappend($1, $3); }
;
@@ -2099,7 +2099,7 @@ opt_trusted:
*/
handler_name:
name
{ $$ = makeList1(makeString($1)); }
{ $$ = list_make1(makeString($1)); }
| dotted_name { $$ = $1; }
;
@@ -2236,7 +2236,7 @@ TriggerForType:
;
TriggerFuncArgs:
TriggerFuncArg { $$ = makeList1($1); }
TriggerFuncArg { $$ = list_make1($1); }
| TriggerFuncArgs ',' TriggerFuncArg { $$ = lappend($1, $3); }
| /*EMPTY*/ { $$ = NIL; }
;
@@ -2328,7 +2328,7 @@ CreateAssertStmt:
{
CreateTrigStmt *n = makeNode(CreateTrigStmt);
n->trigname = $3;
n->args = makeList1($6);
n->args = list_make1($6);
n->isconstraint = TRUE;
n->deferrable = ($8 & 1) != 0;
n->initdeferred = ($8 & 2) != 0;
@@ -2395,7 +2395,7 @@ DefineStmt:
RangeVar *r = makeNode(RangeVar);
/* can't use qualified_name, sigh */
switch (length($3))
switch (list_length($3))
{
case 1:
r->catalogname = NULL;
@@ -2428,7 +2428,7 @@ DefineStmt:
definition: '(' def_list ')' { $$ = $2; }
;
def_list: def_elem { $$ = makeList1($1); }
def_list: def_elem { $$ = list_make1($1); }
| def_list ',' def_elem { $$ = lappend($1, $3); }
;
@@ -2473,7 +2473,7 @@ CreateOpClassStmt:
;
opclass_item_list:
opclass_item { $$ = makeList1($1); }
opclass_item { $$ = list_make1($1); }
| opclass_item_list ',' opclass_item { $$ = lappend($1, $3); }
;
@@ -2566,11 +2566,11 @@ drop_type: TABLE { $$ = OBJECT_TABLE; }
;
any_name_list:
any_name { $$ = makeList1($1); }
any_name { $$ = list_make1($1); }
| any_name_list ',' any_name { $$ = lappend($1, $3); }
;
any_name: ColId { $$ = makeList1(makeString($1)); }
any_name: ColId { $$ = list_make1(makeString($1)); }
| dotted_name { $$ = $1; }
;
@@ -2623,7 +2623,7 @@ CommentStmt:
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_AGGREGATE;
n->objname = $4;
n->objargs = makeList1($6);
n->objargs = list_make1($6);
n->comment = $9;
$$ = (Node *) n;
}
@@ -2669,7 +2669,7 @@ CommentStmt:
/* Obsolete syntax supported for awhile for compatibility */
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_RULE;
n->objname = makeList1(makeString($4));
n->objname = list_make1(makeString($4));
n->objargs = NIL;
n->comment = $6;
$$ = (Node *) n;
@@ -2688,7 +2688,7 @@ CommentStmt:
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_OPCLASS;
n->objname = $5;
n->objargs = makeList1(makeString($7));
n->objargs = list_make1(makeString($7));
n->comment = $9;
$$ = (Node *) n;
}
@@ -2696,7 +2696,7 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_LARGEOBJECT;
n->objname = makeList1($5);
n->objname = list_make1($5);
n->objargs = NIL;
n->comment = $7;
$$ = (Node *) n;
@@ -2705,8 +2705,8 @@ CommentStmt:
{
CommentStmt *n = makeNode(CommentStmt);
n->objtype = OBJECT_CAST;
n->objname = makeList1($5);
n->objargs = makeList1($7);
n->objname = list_make1($5);
n->objargs = list_make1($7);
n->comment = $10;
$$ = (Node *) n;
}
@@ -2937,13 +2937,13 @@ RevokeStmt: REVOKE opt_revoke_grant_option privileges ON privilege_target
/* either ALL [PRIVILEGES] or a list of individual privileges */
privileges: privilege_list { $$ = $1; }
| ALL { $$ = makeListi1(ACL_ALL_RIGHTS); }
| ALL PRIVILEGES { $$ = makeListi1(ACL_ALL_RIGHTS); }
| ALL { $$ = list_make1_int(ACL_ALL_RIGHTS); }
| ALL PRIVILEGES { $$ = list_make1_int(ACL_ALL_RIGHTS); }
;
privilege_list:
privilege { $$ = makeListi1($1); }
| privilege_list ',' privilege { $$ = lappendi($1, $3); }
privilege { $$ = list_make1_int($1); }
| privilege_list ',' privilege { $$ = lappend_int($1, $3); }
;
/* Not all of these privilege types apply to all objects, but that
@@ -3013,7 +3013,7 @@ privilege_target:
grantee_list:
grantee { $$ = makeList1($1); }
grantee { $$ = list_make1($1); }
| grantee_list ',' grantee { $$ = lappend($1, $3); }
;
@@ -3054,7 +3054,7 @@ opt_revoke_grant_option:
function_with_argtypes_list:
function_with_argtypes { $$ = makeList1($1); }
function_with_argtypes { $$ = list_make1($1); }
| function_with_argtypes_list ',' function_with_argtypes
{ $$ = lappend($1, $3); }
;
@@ -3103,7 +3103,7 @@ access_method_clause:
| /*EMPTY*/ { $$ = DEFAULT_INDEX_TYPE; }
;
index_params: index_elem { $$ = makeList1($1); }
index_params: index_elem { $$ = list_make1($1); }
| index_params ',' index_elem { $$ = lappend($1, $3); }
;
@@ -3182,7 +3182,7 @@ func_args: '(' func_args_list ')' { $$ = $2; }
;
func_args_list:
func_arg { $$ = makeList1($1); }
func_arg { $$ = list_make1($1); }
| func_args_list ',' func_arg { $$ = lappend($1, $3); }
;
@@ -3259,7 +3259,7 @@ func_type: Typename { $$ = $1; }
createfunc_opt_list:
/* Must be at least one to prevent conflict */
createfunc_opt_item { $$ = makeList1($1); }
createfunc_opt_item { $$ = list_make1($1); }
| createfunc_opt_list createfunc_opt_item { $$ = lappend($1, $2); }
;
@@ -3314,10 +3314,10 @@ createfunc_opt_item:
}
;
func_as: Sconst { $$ = makeList1(makeString($1)); }
func_as: Sconst { $$ = list_make1(makeString($1)); }
| Sconst ',' Sconst
{
$$ = makeList2(makeString($1), makeString($3));
$$ = list_make2(makeString($1), makeString($3));
}
;
@@ -3384,16 +3384,16 @@ oper_argtypes:
errhint("Use NONE to denote the missing argument of a unary operator.")));
}
| Typename ',' Typename
{ $$ = makeList2($1, $3); }
{ $$ = list_make2($1, $3); }
| NONE ',' Typename /* left unary */
{ $$ = makeList2(NULL, $3); }
{ $$ = list_make2(NULL, $3); }
| Typename ',' NONE /* right unary */
{ $$ = makeList2($1, NULL); }
{ $$ = list_make2($1, NULL); }
;
any_operator:
all_Op
{ $$ = makeList1(makeString($1)); }
{ $$ = list_make1(makeString($1)); }
| ColId '.' any_operator
{ $$ = lcons(makeString($1), $3); }
;
@@ -3495,7 +3495,7 @@ RenameStmt: ALTER AGGREGATE func_name '(' aggr_argtype ')' RENAME TO name
RenameStmt *n = makeNode(RenameStmt);
n->renameType = OBJECT_AGGREGATE;
n->object = $3;
n->objarg = makeList1($5);
n->objarg = list_make1($5);
n->newname = $9;
$$ = (Node *)n;
}
@@ -3625,7 +3625,7 @@ RuleStmt: CREATE opt_or_replace RULE name AS
RuleActionList:
NOTHING { $$ = NIL; }
| RuleActionStmt { $$ = makeList1($1); }
| RuleActionStmt { $$ = list_make1($1); }
| '(' RuleActionMulti ')' { $$ = $2; }
;
@@ -3639,7 +3639,7 @@ RuleActionMulti:
}
| RuleActionStmtOrEmpty
{ if ($1 != NULL)
$$ = makeList1($1);
$$ = list_make1($1);
else
$$ = NIL;
}
@@ -3788,24 +3788,24 @@ opt_transaction: WORK {}
transaction_mode_list:
ISOLATION LEVEL iso_level
{ $$ = makeList1(makeDefElem("transaction_isolation",
makeStringConst($3, NULL))); }
{ $$ = list_make1(makeDefElem("transaction_isolation",
makeStringConst($3, NULL))); }
| transaction_access_mode
{ $$ = makeList1(makeDefElem("transaction_read_only",
makeIntConst($1))); }
{ $$ = list_make1(makeDefElem("transaction_read_only",
makeIntConst($1))); }
| ISOLATION LEVEL iso_level transaction_access_mode
{
$$ = makeList2(makeDefElem("transaction_isolation",
makeStringConst($3, NULL)),
makeDefElem("transaction_read_only",
makeIntConst($4)));
$$ = list_make2(makeDefElem("transaction_isolation",
makeStringConst($3, NULL)),
makeDefElem("transaction_read_only",
makeIntConst($4)));
}
| transaction_access_mode ISOLATION LEVEL iso_level
{
$$ = makeList2(makeDefElem("transaction_read_only",
makeIntConst($1)),
makeDefElem("transaction_isolation",
makeStringConst($4, NULL)));
$$ = list_make2(makeDefElem("transaction_read_only",
makeIntConst($1)),
makeDefElem("transaction_isolation",
makeStringConst($4, NULL)));
}
;
@@ -4258,7 +4258,7 @@ prep_type_clause: '(' prep_type_list ')' { $$ = $2; }
| /* EMPTY */ { $$ = NIL; }
;
prep_type_list: Typename { $$ = makeList1($1); }
prep_type_list: Typename { $$ = list_make1($1); }
| prep_type_list ',' Typename
{ $$ = lappend($1, $3); }
;
@@ -4380,7 +4380,7 @@ insert_rest:
;
insert_column_list:
insert_column_item { $$ = makeList1($1); }
insert_column_item { $$ = list_make1($1); }
| insert_column_list ',' insert_column_item
{ $$ = lappend($1, $3); }
;
@@ -4566,13 +4566,13 @@ select_no_parens:
| select_clause opt_sort_clause for_update_clause opt_select_limit
{
insertSelectOptions((SelectStmt *) $1, $2, $3,
nth(0, $4), nth(1, $4));
list_nth($4, 0), list_nth($4, 1));
$$ = $1;
}
| select_clause opt_sort_clause select_limit opt_for_update_clause
{
insertSelectOptions((SelectStmt *) $1, $2, $4,
nth(0, $3), nth(1, $3));
list_nth($3, 0), list_nth($3, 1));
$$ = $1;
}
;
@@ -4701,7 +4701,7 @@ opt_all: ALL { $$ = TRUE; }
* should be placed in the DISTINCT list during parsetree analysis.
*/
opt_distinct:
DISTINCT { $$ = makeList1(NIL); }
DISTINCT { $$ = list_make1(NIL); }
| DISTINCT ON '(' expr_list ')' { $$ = $4; }
| ALL { $$ = NIL; }
| /*EMPTY*/ { $$ = NIL; }
@@ -4717,7 +4717,7 @@ sort_clause:
;
sortby_list:
sortby { $$ = makeList1($1); }
sortby { $$ = list_make1($1); }
| sortby_list ',' sortby { $$ = lappend($1, $3); }
;
@@ -4754,13 +4754,13 @@ sortby: a_expr USING qual_all_Op
select_limit:
LIMIT select_limit_value OFFSET select_offset_value
{ $$ = makeList2($4, $2); }
{ $$ = list_make2($4, $2); }
| OFFSET select_offset_value LIMIT select_limit_value
{ $$ = makeList2($2, $4); }
{ $$ = list_make2($2, $4); }
| LIMIT select_limit_value
{ $$ = makeList2(NULL, $2); }
{ $$ = list_make2(NULL, $2); }
| OFFSET select_offset_value
{ $$ = makeList2($2, NULL); }
{ $$ = list_make2($2, NULL); }
| LIMIT select_limit_value ',' select_offset_value
{
/* Disabled because it was too confusing, bjm 2002-02-18 */
@@ -4774,7 +4774,7 @@ select_limit:
opt_select_limit:
select_limit { $$ = $1; }
| /* EMPTY */
{ $$ = makeList2(NULL,NULL); }
{ $$ = list_make2(NULL,NULL); }
;
select_limit_value:
@@ -4822,7 +4822,7 @@ opt_for_update_clause:
update_list:
OF name_list { $$ = $2; }
| /* EMPTY */ { $$ = makeList1(NULL); }
| /* EMPTY */ { $$ = list_make1(NULL); }
;
/*****************************************************************************
@@ -4839,7 +4839,7 @@ from_clause:
;
from_list:
table_ref { $$ = makeList1($1); }
table_ref { $$ = list_make1($1); }
| from_list ',' table_ref { $$ = lappend($1, $3); }
;
@@ -5151,7 +5151,7 @@ where_clause:
TableFuncElementList:
TableFuncElement
{
$$ = makeList1($1);
$$ = list_make1($1);
}
| TableFuncElementList ',' TableFuncElement
{
@@ -5195,13 +5195,13 @@ Typename: SimpleTypename opt_array_bounds
{
/* SQL99's redundant syntax */
$$ = $1;
$$->arrayBounds = makeList1(makeInteger($4));
$$->arrayBounds = list_make1(makeInteger($4));
}
| SETOF SimpleTypename ARRAY '[' Iconst ']'
{
/* SQL99's redundant syntax */
$$ = $2;
$$->arrayBounds = makeList1(makeInteger($5));
$$->arrayBounds = list_make1(makeInteger($5));
$$->setof = TRUE;
}
;
@@ -5755,7 +5755,7 @@ a_expr: c_expr { $$ = $1; }
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("timezone");
n->args = makeList2($5, $1);
n->args = list_make2($5, $1);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) n;
@@ -5820,7 +5820,7 @@ a_expr: c_expr { $$ = $1; }
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("like_escape");
n->args = makeList2($3, $5);
n->args = list_make2($3, $5);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~", $1, (Node *) n);
@@ -5831,7 +5831,7 @@ a_expr: c_expr { $$ = $1; }
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("like_escape");
n->args = makeList2($4, $6);
n->args = list_make2($4, $6);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~", $1, (Node *) n);
@@ -5842,7 +5842,7 @@ a_expr: c_expr { $$ = $1; }
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("like_escape");
n->args = makeList2($3, $5);
n->args = list_make2($3, $5);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~~*", $1, (Node *) n);
@@ -5853,7 +5853,7 @@ a_expr: c_expr { $$ = $1; }
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("like_escape");
n->args = makeList2($4, $6);
n->args = list_make2($4, $6);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~~*", $1, (Node *) n);
@@ -5865,7 +5865,7 @@ a_expr: c_expr { $$ = $1; }
FuncCall *n = makeNode(FuncCall);
c->val.type = T_Null;
n->funcname = SystemFuncName("similar_escape");
n->args = makeList2($4, (Node *) c);
n->args = list_make2($4, (Node *) c);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~", $1, (Node *) n);
@@ -5874,7 +5874,7 @@ a_expr: c_expr { $$ = $1; }
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("similar_escape");
n->args = makeList2($4, $6);
n->args = list_make2($4, $6);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "~", $1, (Node *) n);
@@ -5885,7 +5885,7 @@ a_expr: c_expr { $$ = $1; }
FuncCall *n = makeNode(FuncCall);
c->val.type = T_Null;
n->funcname = SystemFuncName("similar_escape");
n->args = makeList2($5, (Node *) c);
n->args = list_make2($5, (Node *) c);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~", $1, (Node *) n);
@@ -5894,7 +5894,7 @@ a_expr: c_expr { $$ = $1; }
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("similar_escape");
n->args = makeList2($5, $7);
n->args = list_make2($5, $7);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "!~", $1, (Node *) n);
@@ -6037,8 +6037,8 @@ a_expr: c_expr { $$ = $1; }
if (IsA($1, RowExpr))
n->lefthand = ((RowExpr *) $1)->args;
else
n->lefthand = makeList1($1);
n->operName = makeList1(makeString("="));
n->lefthand = list_make1($1);
n->operName = list_make1(makeString("="));
$$ = (Node *)n;
}
else
@@ -6068,8 +6068,8 @@ a_expr: c_expr { $$ = $1; }
if (IsA($1, RowExpr))
n->lefthand = ((RowExpr *) $1)->args;
else
n->lefthand = makeList1($1);
n->operName = makeList1(makeString("="));
n->lefthand = list_make1($1);
n->operName = list_make1(makeString("="));
/* Stick a NOT on top */
$$ = (Node *) makeA_Expr(AEXPR_NOT, NIL, NULL, (Node *) n);
}
@@ -6096,7 +6096,7 @@ a_expr: c_expr { $$ = $1; }
if (IsA($1, RowExpr))
n->lefthand = ((RowExpr *) $1)->args;
else
n->lefthand = makeList1($1);
n->lefthand = list_make1($1);
n->operName = $2;
n->subselect = $4;
$$ = (Node *)n;
@@ -6293,7 +6293,7 @@ c_expr: columnref { $$ = (Node *) $1; }
star->val.type = T_Integer;
star->val.val.ival = 1;
n->funcname = $1;
n->args = makeList1(star);
n->args = list_make1(star);
n->agg_star = TRUE;
n->agg_distinct = FALSE;
$$ = (Node *)n;
@@ -6625,7 +6625,7 @@ c_expr: columnref { $$ = (Node *) $1; }
* at the moment they result in the same thing.
*/
n->funcname = SystemFuncName(((Value *)llast($5->names))->val.str);
n->args = makeList1($3);
n->args = list_make1($3);
$$ = (Node *)n;
}
| TRIM '(' BOTH trim_list ')'
@@ -6676,7 +6676,7 @@ c_expr: columnref { $$ = (Node *) $1; }
c->val.val.str = NameListToQuotedString($5);
n->funcname = SystemFuncName("convert_using");
n->args = makeList2($3, c);
n->args = list_make2($3, c);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
$$ = (Node *)n;
@@ -6764,31 +6764,31 @@ MathOp: '+' { $$ = "+"; }
;
qual_Op: Op
{ $$ = makeList1(makeString($1)); }
{ $$ = list_make1(makeString($1)); }
| OPERATOR '(' any_operator ')'
{ $$ = $3; }
;
qual_all_Op:
all_Op
{ $$ = makeList1(makeString($1)); }
{ $$ = list_make1(makeString($1)); }
| OPERATOR '(' any_operator ')'
{ $$ = $3; }
;
subquery_Op:
all_Op
{ $$ = makeList1(makeString($1)); }
{ $$ = list_make1(makeString($1)); }
| OPERATOR '(' any_operator ')'
{ $$ = $3; }
| LIKE
{ $$ = makeList1(makeString("~~")); }
{ $$ = list_make1(makeString("~~")); }
| NOT LIKE
{ $$ = makeList1(makeString("!~~")); }
{ $$ = list_make1(makeString("!~~")); }
| ILIKE
{ $$ = makeList1(makeString("~~*")); }
{ $$ = list_make1(makeString("~~*")); }
| NOT ILIKE
{ $$ = makeList1(makeString("!~~*")); }
{ $$ = list_make1(makeString("!~~*")); }
/* cannot put SIMILAR TO here, because SIMILAR TO is a hack.
* the regular expression is preprocessed by a function (similar_escape),
* and the ~ operator for posix regular expressions is used.
@@ -6838,7 +6838,7 @@ extract_list:
A_Const *n = makeNode(A_Const);
n->val.type = T_String;
n->val.val.str = $1;
$$ = makeList2((Node *) n, $3);
$$ = list_make2((Node *) n, $3);
}
| /*EMPTY*/ { $$ = NIL; }
;
@@ -6849,12 +6849,12 @@ type_list: type_list ',' Typename
}
| Typename
{
$$ = makeList1($1);
$$ = list_make1($1);
}
;
array_expr_list: array_expr
{ $$ = makeList1($1); }
{ $$ = list_make1($1); }
| array_expr_list ',' array_expr
{ $$ = lappend($1, $3); }
;
@@ -6896,11 +6896,11 @@ extract_arg:
overlay_list:
a_expr overlay_placing substr_from substr_for
{
$$ = makeList4($1, $2, $3, $4);
$$ = list_make4($1, $2, $3, $4);
}
| a_expr overlay_placing substr_from
{
$$ = makeList3($1, $2, $3);
$$ = list_make3($1, $2, $3);
}
;
@@ -6912,7 +6912,7 @@ overlay_placing:
/* position_list uses b_expr not a_expr to avoid conflict with general IN */
position_list:
b_expr IN_P b_expr { $$ = makeList2($3, $1); }
b_expr IN_P b_expr { $$ = list_make2($3, $1); }
| /*EMPTY*/ { $$ = NIL; }
;
@@ -6930,22 +6930,22 @@ position_list:
substr_list:
a_expr substr_from substr_for
{
$$ = makeList3($1, $2, $3);
$$ = list_make3($1, $2, $3);
}
| a_expr substr_for substr_from
{
$$ = makeList3($1, $3, $2);
$$ = list_make3($1, $3, $2);
}
| a_expr substr_from
{
$$ = makeList2($1, $2);
$$ = list_make2($1, $2);
}
| a_expr substr_for
{
A_Const *n = makeNode(A_Const);
n->val.type = T_Integer;
n->val.val.ival = 1;
$$ = makeList3($1, (Node *)n, $2);
$$ = list_make3($1, (Node *)n, $2);
}
| expr_list
{
@@ -7019,7 +7019,7 @@ case_expr: CASE case_arg when_clause_list case_default END_P
when_clause_list:
/* There must be at least one */
when_clause { $$ = makeList1($1); }
when_clause { $$ = list_make1($1); }
| when_clause_list when_clause { $$ = lappend($1, $2); }
;
@@ -7050,7 +7050,7 @@ case_arg: a_expr { $$ = $1; }
columnref: relation_name opt_indirection
{
$$ = makeNode(ColumnRef);
$$->fields = makeList1(makeString($1));
$$->fields = list_make1(makeString($1));
$$->indirection = $2;
}
| dotted_name opt_indirection
@@ -7067,9 +7067,9 @@ dotted_name:
;
attrs: '.' attr_name
{ $$ = makeList1(makeString($2)); }
{ $$ = list_make1(makeString($2)); }
| '.' '*'
{ $$ = makeList1(makeString("*")); }
{ $$ = list_make1(makeString("*")); }
| '.' attr_name attrs
{ $$ = lcons(makeString($2), $3); }
;
@@ -7084,7 +7084,7 @@ attrs: '.' attr_name
/* Target lists as found in SELECT ... and INSERT VALUES ( ... ) */
target_list:
target_el { $$ = makeList1($1); }
target_el { $$ = list_make1($1); }
| target_list ',' target_el { $$ = lappend($1, $3); }
;
@@ -7106,7 +7106,7 @@ target_el: a_expr AS ColLabel
| '*'
{
ColumnRef *n = makeNode(ColumnRef);
n->fields = makeList1(makeString("*"));
n->fields = list_make1(makeString("*"));
n->indirection = NIL;
$$ = makeNode(ResTarget);
$$->name = NULL;
@@ -7122,7 +7122,7 @@ target_el: a_expr AS ColLabel
}
*/
update_target_list:
update_target_el { $$ = makeList1($1); }
update_target_el { $$ = list_make1($1); }
| update_target_list ',' update_target_el { $$ = lappend($1,$3); }
;
@@ -7145,7 +7145,7 @@ update_target_el:
;
insert_target_list:
insert_target_el { $$ = makeList1($1); }
insert_target_el { $$ = list_make1($1); }
| insert_target_list ',' insert_target_el { $$ = lappend($1, $3); }
;
@@ -7173,7 +7173,7 @@ relation_name:
;
qualified_name_list:
qualified_name { $$ = makeList1($1); }
qualified_name { $$ = list_make1($1); }
| qualified_name_list ',' qualified_name { $$ = lappend($1, $3); }
;
@@ -7188,7 +7188,7 @@ qualified_name:
| dotted_name
{
$$ = makeNode(RangeVar);
switch (length($1))
switch (list_length($1))
{
case 2:
$$->catalogname = NULL;
@@ -7211,7 +7211,7 @@ qualified_name:
;
name_list: name
{ $$ = makeList1(makeString($1)); }
{ $$ = list_make1(makeString($1)); }
| name_list ',' name
{ $$ = lappend($1, makeString($3)); }
;
@@ -7232,7 +7232,7 @@ index_name: ColId { $$ = $1; };
file_name: Sconst { $$ = $1; };
func_name: function_name
{ $$ = makeList1(makeString($1)); }
{ $$ = list_make1(makeString($1)); }
| dotted_name { $$ = $1; }
;
@@ -7924,19 +7924,19 @@ makeOverlaps(List *largs, List *rargs)
{
FuncCall *n = makeNode(FuncCall);
n->funcname = SystemFuncName("overlaps");
if (length(largs) == 1)
if (list_length(largs) == 1)
largs = lappend(largs, largs);
else if (length(largs) != 2)
else if (list_length(largs) != 2)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("wrong number of parameters on left side of OVERLAPS expression")));
if (length(rargs) == 1)
if (list_length(rargs) == 1)
rargs = lappend(rargs, rargs);
else if (length(rargs) != 2)
else if (list_length(rargs) != 2)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("wrong number of parameters on right side of OVERLAPS expression")));
n->args = nconc(largs, rargs);
n->args = list_concat(largs, rargs);
n->agg_star = FALSE;
n->agg_distinct = FALSE;
return n;
@@ -8041,7 +8041,7 @@ makeSetOp(SetOperation op, bool all, Node *larg, Node *rarg)
List *
SystemFuncName(char *name)
{
return makeList2(makeString("pg_catalog"), makeString(name));
return list_make2(makeString("pg_catalog"), makeString(name));
}
/* SystemTypeName()
@@ -8054,7 +8054,7 @@ SystemTypeName(char *name)
{
TypeName *n = makeNode(TypeName);
n->names = makeList2(makeString("pg_catalog"), makeString(name));
n->names = list_make2(makeString("pg_catalog"), makeString(name));
n->typmod = -1;
return n;
}

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.62 2004/05/26 04:41:29 neilc Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_agg.c,v 1.63 2004/05/30 23:40:34 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -307,7 +307,7 @@ check_ungrouped_columns_walker(Node *node,
/* Found an ungrouped local variable; generate error message */
Assert(var->varno > 0 &&
(int) var->varno <= length(context->pstate->p_rtable));
(int) var->varno <= list_length(context->pstate->p_rtable));
rte = rt_fetch(var->varno, context->pstate->p_rtable);
attname = get_rte_attribute_name(rte, var->varattno);
if (context->sublevels_up == 0)
@@ -394,10 +394,10 @@ build_aggregate_fnexprs(Oid agg_input_type,
arg1->paramid = -1;
arg1->paramtype = agg_input_type;
args = makeList2(arg0, arg1);
args = list_make2(arg0, arg1);
}
else
args = makeList1(arg0);
args = list_make1(arg0);
*transfnexpr = (Expr *) makeFuncExpr(transfn_oid,
agg_state_type,
@@ -418,7 +418,7 @@ build_aggregate_fnexprs(Oid agg_input_type,
arg0->paramkind = PARAM_EXEC;
arg0->paramid = -1;
arg0->paramtype = agg_state_type;
args = makeList1(arg0);
args = list_make1(arg0);
*finalfnexpr = (Expr *) makeFuncExpr(finalfn_oid,
agg_result_type,

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.130 2004/05/26 04:41:29 neilc Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_clause.c,v 1.131 2004/05/30 23:40:34 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -148,7 +148,7 @@ setTargetTable(ParseState *pstate, RangeVar *relation,
pstate->p_target_rangetblentry = rte;
/* assume new rte is at end */
rtindex = length(pstate->p_rtable);
rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(rtindex, pstate->p_rtable));
/*
@@ -233,7 +233,7 @@ extractRemainingColumns(List *common_colnames,
List *new_colvars = NIL;
ListCell *lnames, *lvars;
Assert(length(src_colnames) == length(src_colvars));
Assert(list_length(src_colnames) == list_length(src_colvars));
forboth(lnames, src_colnames, lvars, src_colvars)
{
@@ -336,7 +336,7 @@ transformJoinOnClause(ParseState *pstate, JoinExpr *j,
* to be added.
*/
save_namespace = pstate->p_namespace;
pstate->p_namespace = makeList2(j->larg, j->rarg);
pstate->p_namespace = list_make2(j->larg, j->rarg);
result = transformWhereClause(pstate, j->quals, "JOIN/ON");
@@ -353,7 +353,7 @@ transformJoinOnClause(ParseState *pstate, JoinExpr *j,
clause_varnos = pull_varnos(result);
while ((varno = bms_first_member(clause_varnos)) >= 0)
{
if (!intMember(varno, containedRels))
if (!list_member_int(containedRels, varno))
{
ereport(ERROR,
(errcode(ERRCODE_INVALID_COLUMN_REFERENCE),
@@ -391,7 +391,7 @@ transformTableEntry(ParseState *pstate, RangeVar *r)
*/
rtr = makeNode(RangeTblRef);
/* assume new rte is at end */
rtr->rtindex = length(pstate->p_rtable);
rtr->rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(rtr->rtindex, pstate->p_rtable));
return rtr;
@@ -429,7 +429,7 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r)
* are probably impossible given restrictions of the grammar, but
* check 'em anyway.
*/
if (length(parsetrees) != 1)
if (list_length(parsetrees) != 1)
elog(ERROR, "unexpected parse analysis result for subquery in FROM");
query = (Query *) linitial(parsetrees);
if (query == NULL || !IsA(query, Query))
@@ -476,7 +476,7 @@ transformRangeSubselect(ParseState *pstate, RangeSubselect *r)
*/
rtr = makeNode(RangeTblRef);
/* assume new rte is at end */
rtr->rtindex = length(pstate->p_rtable);
rtr->rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(rtr->rtindex, pstate->p_rtable));
return rtr;
@@ -556,7 +556,7 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r)
*/
rtr = makeNode(RangeTblRef);
/* assume new rte is at end */
rtr->rtindex = length(pstate->p_rtable);
rtr->rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(rtr->rtindex, pstate->p_rtable));
return rtr;
@@ -584,7 +584,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
RangeTblRef *rtr;
rtr = transformTableEntry(pstate, (RangeVar *) n);
*containedRels = makeListi1(rtr->rtindex);
*containedRels = list_make1_int(rtr->rtindex);
return (Node *) rtr;
}
else if (IsA(n, RangeSubselect))
@@ -593,7 +593,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
RangeTblRef *rtr;
rtr = transformRangeSubselect(pstate, (RangeSubselect *) n);
*containedRels = makeListi1(rtr->rtindex);
*containedRels = list_make1_int(rtr->rtindex);
return (Node *) rtr;
}
else if (IsA(n, RangeFunction))
@@ -602,7 +602,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
RangeTblRef *rtr;
rtr = transformRangeFunction(pstate, (RangeFunction *) n);
*containedRels = makeListi1(rtr->rtindex);
*containedRels = list_make1_int(rtr->rtindex);
return (Node *) rtr;
}
else if (IsA(n, JoinExpr))
@@ -632,7 +632,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
* Generate combined list of relation indexes for possible use by
* transformJoinOnClause below.
*/
my_containedRels = nconc(l_containedRels, r_containedRels);
my_containedRels = list_concat(l_containedRels, r_containedRels);
/*
* Check for conflicting refnames in left and right subtrees. Must
@@ -799,9 +799,9 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
errmsg("column \"%s\" specified in USING clause does not exist in right table",
u_colname)));
l_colvar = nth(l_index, l_colvars);
l_colvar = list_nth(l_colvars, l_index);
l_usingvars = lappend(l_usingvars, l_colvar);
r_colvar = nth(r_index, r_colvars);
r_colvar = list_nth(r_colvars, r_index);
r_usingvars = lappend(r_usingvars, r_colvar);
res_colnames = lappend(res_colnames, lfirst(ucol));
@@ -833,10 +833,10 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
extractRemainingColumns(res_colnames,
r_colnames, r_colvars,
&r_colnames, &r_colvars);
res_colnames = nconc(res_colnames, l_colnames);
res_colvars = nconc(res_colvars, l_colvars);
res_colnames = nconc(res_colnames, r_colnames);
res_colvars = nconc(res_colvars, r_colvars);
res_colnames = list_concat(res_colnames, l_colnames);
res_colvars = list_concat(res_colvars, l_colvars);
res_colnames = list_concat(res_colnames, r_colnames);
res_colvars = list_concat(res_colvars, r_colvars);
/*
* Check alias (AS clause), if any.
@@ -845,7 +845,7 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
{
if (j->alias->colnames != NIL)
{
if (length(j->alias->colnames) > length(res_colnames))
if (list_length(j->alias->colnames) > list_length(res_colnames))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("column alias list for \"%s\" has too many entries",
@@ -864,13 +864,13 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels)
true);
/* assume new rte is at end */
j->rtindex = length(pstate->p_rtable);
j->rtindex = list_length(pstate->p_rtable);
Assert(rte == rt_fetch(j->rtindex, pstate->p_rtable));
/*
* Include join RTE in returned containedRels list
*/
*containedRels = lconsi(j->rtindex, my_containedRels);
*containedRels = lcons_int(j->rtindex, my_containedRels);
return (Node *) j;
}
@@ -900,8 +900,8 @@ buildMergedJoinVar(ParseState *pstate, JoinType jointype,
outcoltypmod = l_colvar->vartypmod;
if (outcoltype != r_colvar->vartype)
{
outcoltype = select_common_type(makeListo2(l_colvar->vartype,
r_colvar->vartype),
outcoltype = select_common_type(list_make2_oid(l_colvar->vartype,
r_colvar->vartype),
"JOIN/USING");
outcoltypmod = -1; /* ie, unknown */
}
@@ -973,7 +973,7 @@ buildMergedJoinVar(ParseState *pstate, JoinType jointype,
CoalesceExpr *c = makeNode(CoalesceExpr);
c->coalescetype = outcoltype;
c->args = makeList2(l_node, r_node);
c->args = list_make2(l_node, r_node);
res_node = (Node *) c;
break;
}
@@ -1122,7 +1122,7 @@ findTargetlistEntry(ParseState *pstate, Node *node, List **tlist, int clause)
*----------
*/
if (IsA(node, ColumnRef) &&
length(((ColumnRef *) node)->fields) == 1 &&
list_length(((ColumnRef *) node)->fields) == 1 &&
((ColumnRef *) node)->indirection == NIL)
{
char *name = strVal(linitial(((ColumnRef *) node)->fields));

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.116 2004/05/26 04:41:30 neilc Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_coerce.c,v 2.117 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -245,7 +245,7 @@ coerce_type(ParseState *pstate, Node *node,
Oid baseTypeId = getBaseType(targetTypeId);
result = (Node *) makeFuncExpr(funcId, baseTypeId,
makeList1(node),
list_make1(node),
cformat);
/*
@@ -508,7 +508,7 @@ coerce_type_typmod(Node *node, Oid targetTypeId, int32 targetTypMod,
false,
true);
args = makeList2(node, cons);
args = list_make2(node, cons);
if (nargs == 3)
{
@@ -562,7 +562,7 @@ coerce_record_to_complex(ParseState *pstate, Node *node,
rte = GetRTEByRangeTablePosn(pstate,
((Var *) node)->varno,
((Var *) node)->varlevelsup);
nfields = length(rte->eref->colnames);
nfields = list_length(rte->eref->colnames);
for (nf = 1; nf <= nfields; nf++)
{
Oid vartype;
@@ -585,7 +585,7 @@ coerce_record_to_complex(ParseState *pstate, Node *node,
format_type_be(targetTypeId))));
tupdesc = lookup_rowtype_tupdesc(targetTypeId, -1);
if (length(args) != tupdesc->natts)
if (list_length(args) != tupdesc->natts)
ereport(ERROR,
(errcode(ERRCODE_CANNOT_COERCE),
errmsg("cannot cast type %s to %s",
@@ -728,7 +728,7 @@ select_common_type(List *typeids, const char *context)
for_each_cell(type_item, lnext(list_head(typeids)))
{
Oid ntype = getBaseType(lfirsto(type_item));
Oid ntype = getBaseType(lfirst_oid(type_item));
/* move on to next one if no new information... */
if ((ntype != InvalidOid) && (ntype != UNKNOWNOID) && (ntype != ptype))

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.171 2004/05/26 04:41:30 neilc Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_expr.c,v 1.172 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -153,8 +153,8 @@ transformExpr(ParseState *pstate, Node *expr)
foreach(fields, pref->fields)
{
result = ParseFuncOrColumn(pstate,
makeList1(lfirst(fields)),
makeList1(result),
list_make1(lfirst(fields)),
list_make1(result),
false, false, true);
}
/* handle subscripts, if any */
@@ -183,8 +183,8 @@ transformExpr(ParseState *pstate, Node *expr)
foreach(fields, efs->fields)
{
result = ParseFuncOrColumn(pstate,
makeList1(lfirst(fields)),
makeList1(result),
list_make1(lfirst(fields)),
list_make1(result),
false, false, true);
}
/* handle subscripts, if any */
@@ -218,7 +218,7 @@ transformExpr(ParseState *pstate, Node *expr)
* into IS NULL exprs.
*/
if (Transform_null_equals &&
length(a->name) == 1 &&
list_length(a->name) == 1 &&
strcmp(strVal(linitial(a->name)), "=") == 0 &&
(exprIsNullConstant(lexpr) ||
exprIsNullConstant(rexpr)))
@@ -284,8 +284,8 @@ transformExpr(ParseState *pstate, Node *expr)
rexpr = coerce_to_boolean(pstate, rexpr, "AND");
result = (Node *) makeBoolExpr(AND_EXPR,
makeList2(lexpr,
rexpr));
list_make2(lexpr,
rexpr));
}
break;
case AEXPR_OR:
@@ -299,8 +299,8 @@ transformExpr(ParseState *pstate, Node *expr)
rexpr = coerce_to_boolean(pstate, rexpr, "OR");
result = (Node *) makeBoolExpr(OR_EXPR,
makeList2(lexpr,
rexpr));
list_make2(lexpr,
rexpr));
}
break;
case AEXPR_NOT:
@@ -311,7 +311,7 @@ transformExpr(ParseState *pstate, Node *expr)
rexpr = coerce_to_boolean(pstate, rexpr, "NOT");
result = (Node *) makeBoolExpr(NOT_EXPR,
makeList1(rexpr));
list_make1(rexpr));
}
break;
case AEXPR_OP_ANY:
@@ -446,7 +446,7 @@ transformExpr(ParseState *pstate, Node *expr)
* XXX: repeated lappend() would no longer result in
* O(n^2) behavior; worth reconsidering this design?
*/
targs = listCopy(fn->args);
targs = list_copy(fn->args);
foreach(args, targs)
{
lfirst(args) = transformExpr(pstate,
@@ -474,7 +474,7 @@ transformExpr(ParseState *pstate, Node *expr)
}
pstate->p_hasSubLinks = true;
qtrees = parse_sub_analyze(sublink->subselect, pstate);
if (length(qtrees) != 1)
if (list_length(qtrees) != 1)
elog(ERROR, "bad query in sub-select");
qtree = (Query *) linitial(qtrees);
if (qtree->commandType != CMD_SELECT ||
@@ -530,7 +530,7 @@ transformExpr(ParseState *pstate, Node *expr)
/* ALL, ANY, or MULTIEXPR: generate operator list */
List *left_list = sublink->lefthand;
List *right_list = qtree->targetList;
int row_length = length(left_list);
int row_length = list_length(left_list);
bool needNot = false;
List *op = sublink->operName;
char *opname = strVal(llast(op));
@@ -548,11 +548,11 @@ transformExpr(ParseState *pstate, Node *expr)
* pre-7.4 Postgres.
*/
if (sublink->subLinkType == ALL_SUBLINK &&
length(op) == 1 && strcmp(opname, "<>") == 0)
list_length(op) == 1 && strcmp(opname, "<>") == 0)
{
sublink->subLinkType = ANY_SUBLINK;
opname = pstrdup("=");
op = makeList1(makeString(opname));
op = list_make1(makeString(opname));
sublink->operName = op;
needNot = true;
}
@@ -626,8 +626,8 @@ transformExpr(ParseState *pstate, Node *expr)
opname),
errhint("The operator of a quantified predicate subquery must return type boolean.")));
sublink->operOids = lappendo(sublink->operOids,
oprid(optup));
sublink->operOids = lappend_oid(sublink->operOids,
oprid(optup));
ReleaseSysCache(optup);
}
@@ -640,7 +640,7 @@ transformExpr(ParseState *pstate, Node *expr)
{
expr = coerce_to_boolean(pstate, expr, "NOT");
expr = (Node *) makeBoolExpr(NOT_EXPR,
makeList1(expr));
list_make1(expr));
}
}
result = (Node *) expr;
@@ -709,7 +709,7 @@ transformExpr(ParseState *pstate, Node *expr)
neww->result = (Expr *) transformExpr(pstate, warg);
newargs = lappend(newargs, neww);
typeids = lappendo(typeids, exprType((Node *) neww->result));
typeids = lappend_oid(typeids, exprType((Node *) neww->result));
}
newc->args = newargs;
@@ -731,7 +731,7 @@ transformExpr(ParseState *pstate, Node *expr)
* code worked before, but it seems a little bogus to me
* --- tgl
*/
typeids = lconso(exprType((Node *) newc->defresult), typeids);
typeids = lcons_oid(exprType((Node *) newc->defresult), typeids);
ptype = select_common_type(typeids, "CASE");
Assert(OidIsValid(ptype));
@@ -779,7 +779,7 @@ transformExpr(ParseState *pstate, Node *expr)
newe = transformExpr(pstate, e);
newelems = lappend(newelems, newe);
typeids = lappendo(typeids, exprType(newe));
typeids = lappend_oid(typeids, exprType(newe));
}
/* Select a common type for the elements */
@@ -868,7 +868,7 @@ transformExpr(ParseState *pstate, Node *expr)
newe = transformExpr(pstate, e);
newargs = lappend(newargs, newe);
typeids = lappendo(typeids, exprType(newe));
typeids = lappend_oid(typeids, exprType(newe));
}
newc->coalescetype = select_common_type(typeids, "COALESCE");
@@ -997,7 +997,7 @@ transformIndirection(ParseState *pstate, Node *basenode, List *indirection)
static Node *
transformColumnRef(ParseState *pstate, ColumnRef *cref)
{
int numnames = length(cref->fields);
int numnames = list_length(cref->fields);
Node *node;
int levels_up;
@@ -1095,8 +1095,8 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
*/
node = transformWholeRowRef(pstate, NULL, name1);
node = ParseFuncOrColumn(pstate,
makeList1(makeString(name2)),
makeList1(node),
list_make1(makeString(name2)),
list_make1(node),
false, false, true);
}
break;
@@ -1121,8 +1121,8 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
/* Try it as a function call */
node = transformWholeRowRef(pstate, name1, name2);
node = ParseFuncOrColumn(pstate,
makeList1(makeString(name3)),
makeList1(node),
list_make1(makeString(name3)),
list_make1(node),
false, false, true);
}
break;
@@ -1157,8 +1157,8 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref)
/* Try it as a function call */
node = transformWholeRowRef(pstate, name2, name3);
node = ParseFuncOrColumn(pstate,
makeList1(makeString(name4)),
makeList1(node),
list_make1(makeString(name4)),
list_make1(node),
false, false, true);
}
break;
@@ -1587,7 +1587,7 @@ exprIsLengthCoercion(Node *expr, int32 *coercedTypmod)
* second argument being an int4 constant, it can't have been created
* from a length coercion (it must be a type coercion, instead).
*/
nargs = length(func->args);
nargs = list_length(func->args);
if (nargs < 2 || nargs > 3)
return false;
@@ -1661,7 +1661,7 @@ make_row_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree)
largs = lrow->args;
rargs = rrow->args;
if (length(largs) != length(rargs))
if (list_length(largs) != list_length(rargs))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("unequal number of entries in row expression")));
@@ -1706,7 +1706,7 @@ make_row_op(ParseState *pstate, List *opname, Node *ltree, Node *rtree)
result = cmp;
else
result = (Node *) makeBoolExpr(boolop,
makeList2(result, cmp));
list_make2(result, cmp));
}
if (result == NULL)
@@ -1744,7 +1744,7 @@ make_row_distinct_op(ParseState *pstate, List *opname,
largs = lrow->args;
rargs = rrow->args;
if (length(largs) != length(rargs))
if (list_length(largs) != list_length(rargs))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("unequal number of entries in row expression")));
@@ -1760,7 +1760,7 @@ make_row_distinct_op(ParseState *pstate, List *opname,
result = cmp;
else
result = (Node *) makeBoolExpr(OR_EXPR,
makeList2(result, cmp));
list_make2(result, cmp));
}
if (result == NULL)

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.169 2004/05/26 04:41:30 neilc Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.170 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -69,7 +69,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
Oid funcid;
ListCell *l;
Node *first_arg = NULL;
int nargs = length(fargs);
int nargs = list_length(fargs);
int argn;
Oid actual_arg_types[FUNC_MAX_ARGS];
Oid *declared_arg_types;
@@ -101,7 +101,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
* then the "function call" could be a projection. We also check that
* there wasn't any aggregate decoration.
*/
if (nargs == 1 && !agg_star && !agg_distinct && length(funcname) == 1)
if (nargs == 1 && !agg_star && !agg_distinct && list_length(funcname) == 1)
{
Oid argtype = exprType(first_arg);
@@ -182,7 +182,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
if (is_column)
{
Assert(nargs == 1);
Assert(length(funcname) == 1);
Assert(list_length(funcname) == 1);
unknown_attribute(pstate, first_arg, strVal(linitial(funcname)));
}
@@ -974,8 +974,8 @@ find_inheritors(Oid relid, Oid **supervec)
else
*supervec = NULL;
freeList(visited);
freeList(queue);
list_free(visited);
list_free(queue);
return nvisited;
}
@@ -1400,7 +1400,7 @@ LookupFuncNameTypeNames(List *funcname, List *argtypes, bool noError)
ListCell *args_item;
MemSet(argoids, 0, FUNC_MAX_ARGS * sizeof(Oid));
argcount = length(argtypes);
argcount = list_length(argtypes);
if (argcount > FUNC_MAX_ARGS)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.77 2003/11/29 19:51:52 pgsql Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_oper.c,v 1.78 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -881,7 +881,7 @@ make_scalar_array_op(ParseState *pstate, List *opname,
tup = oper(opname, ltypeId, rtypeId, false);
opform = (Form_pg_operator) GETSTRUCT(tup);
args = makeList2(ltree, rtree);
args = list_make2(ltree, rtree);
actual_arg_types[0] = ltypeId;
actual_arg_types[1] = rtypeId;
declared_arg_types[0] = opform->oprleft;
@@ -960,7 +960,7 @@ make_op_expr(ParseState *pstate, Operator op,
if (rtree == NULL)
{
/* right operator */
args = makeList1(ltree);
args = list_make1(ltree);
actual_arg_types[0] = ltypeId;
declared_arg_types[0] = opform->oprleft;
nargs = 1;
@@ -968,7 +968,7 @@ make_op_expr(ParseState *pstate, Operator op,
else if (ltree == NULL)
{
/* left operator */
args = makeList1(rtree);
args = list_make1(rtree);
actual_arg_types[0] = rtypeId;
declared_arg_types[0] = opform->oprright;
nargs = 1;
@@ -976,7 +976,7 @@ make_op_expr(ParseState *pstate, Operator op,
else
{
/* otherwise, binary operator */
args = makeList2(ltree, rtree);
args = list_make2(ltree, rtree);
actual_arg_types[0] = ltypeId;
actual_arg_types[1] = rtypeId;
declared_arg_types[0] = opform->oprleft;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.95 2004/05/26 04:41:30 neilc Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_relation.c,v 1.96 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -436,7 +436,7 @@ GetRTEByRangeTablePosn(ParseState *pstate,
pstate = pstate->parentParseState;
Assert(pstate != NULL);
}
Assert(varno > 0 && varno <= length(pstate->p_rtable));
Assert(varno > 0 && varno <= list_length(pstate->p_rtable));
return rt_fetch(varno, pstate->p_rtable);
}
@@ -674,7 +674,7 @@ addRangeTableEntry(ParseState *pstate,
rte->relid = RelationGetRelid(rel);
eref = alias ? (Alias *) copyObject(alias) : makeAlias(refname, NIL);
numaliases = length(eref->colnames);
numaliases = list_length(eref->colnames);
/*
* Since the rel is open anyway, let's check that the number of column
@@ -768,7 +768,7 @@ addRangeTableEntryForRelation(ParseState *pstate,
rte->relid = relid;
eref = (Alias *) copyObject(alias);
numaliases = length(eref->colnames);
numaliases = list_length(eref->colnames);
/*
* Since the rel is open anyway, let's check that the number of column
@@ -849,7 +849,7 @@ addRangeTableEntryForSubquery(ParseState *pstate,
rte->alias = alias;
eref = copyObject(alias);
numaliases = length(eref->colnames);
numaliases = list_length(eref->colnames);
/* fill in any unspecified alias columns */
varattno = 0;
@@ -933,7 +933,7 @@ addRangeTableEntryForFunction(ParseState *pstate,
eref = alias ? (Alias *) copyObject(alias) : makeAlias(funcname, NIL);
rte->eref = eref;
numaliases = length(eref->colnames);
numaliases = list_length(eref->colnames);
/*
* Now determine if the function returns a simple or composite type,
@@ -1023,7 +1023,7 @@ addRangeTableEntryForFunction(ParseState *pstate,
errmsg("too many column aliases specified for function %s",
funcname)));
if (numaliases == 0)
eref->colnames = makeList1(makeString(eref->aliasname));
eref->colnames = list_make1(makeString(eref->aliasname));
}
else if (functyptype == 'p' && funcrettype == RECORDOID)
{
@@ -1097,12 +1097,12 @@ addRangeTableEntryForJoin(ParseState *pstate,
rte->alias = alias;
eref = alias ? (Alias *) copyObject(alias) : makeAlias("unnamed_join", NIL);
numaliases = length(eref->colnames);
numaliases = list_length(eref->colnames);
/* fill in any unspecified alias columns */
if (numaliases < length(colnames))
eref->colnames = nconc(eref->colnames,
list_copy_tail(colnames, numaliases));
if (numaliases < list_length(colnames))
eref->colnames = list_concat(eref->colnames,
list_copy_tail(colnames, numaliases));
rte->eref = eref;
@@ -1241,7 +1241,7 @@ expandRTE(ParseState *pstate, RangeTblEntry *rte,
rel = heap_open(rte->relid, AccessShareLock);
maxattrs = RelationGetNumberOfAttributes(rel);
numaliases = length(rte->eref->colnames);
numaliases = list_length(rte->eref->colnames);
for (varattno = 0; varattno < maxattrs; varattno++)
{
@@ -1255,7 +1255,7 @@ expandRTE(ParseState *pstate, RangeTblEntry *rte,
char *label;
if (varattno < numaliases)
label = strVal(nth(varattno, rte->eref->colnames));
label = strVal(list_nth(rte->eref->colnames, varattno));
else
label = NameStr(attr->attname);
*colnames = lappend(*colnames, makeString(pstrdup(label)));
@@ -1339,7 +1339,7 @@ expandRTE(ParseState *pstate, RangeTblEntry *rte,
rel = relation_open(funcrelid, AccessShareLock);
maxattrs = RelationGetNumberOfAttributes(rel);
numaliases = length(rte->eref->colnames);
numaliases = list_length(rte->eref->colnames);
for (varattno = 0; varattno < maxattrs; varattno++)
{
@@ -1353,7 +1353,7 @@ expandRTE(ParseState *pstate, RangeTblEntry *rte,
char *label;
if (varattno < numaliases)
label = strVal(nth(varattno, rte->eref->colnames));
label = strVal(list_nth(rte->eref->colnames, varattno));
else
label = NameStr(attr->attname);
*colnames = lappend(*colnames, makeString(pstrdup(label)));
@@ -1442,7 +1442,7 @@ expandRTE(ParseState *pstate, RangeTblEntry *rte,
ListCell *colname;
ListCell *aliasvar;
Assert(length(rte->eref->colnames) == length(rte->joinaliasvars));
Assert(list_length(rte->eref->colnames) == list_length(rte->joinaliasvars));
varattno = 0;
forboth (colname, rte->eref->colnames, aliasvar, rte->joinaliasvars)
@@ -1533,8 +1533,8 @@ get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
* If there is a user-written column alias, use it.
*/
if (rte->alias &&
attnum > 0 && attnum <= length(rte->alias->colnames))
return strVal(nth(attnum - 1, rte->alias->colnames));
attnum > 0 && attnum <= list_length(rte->alias->colnames))
return strVal(list_nth(rte->alias->colnames, attnum - 1));
/*
* If the RTE is a relation, go to the system catalogs not the
@@ -1549,8 +1549,8 @@ get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum)
* Otherwise use the column name from eref. There should always be
* one.
*/
if (attnum > 0 && attnum <= length(rte->eref->colnames))
return strVal(nth(attnum - 1, rte->eref->colnames));
if (attnum > 0 && attnum <= list_length(rte->eref->colnames))
return strVal(list_nth(rte->eref->colnames, attnum - 1));
/* else caller gave us a bogus attnum */
elog(ERROR, "invalid attnum %d for rangetable entry %s",
@@ -1665,7 +1665,7 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum,
}
else if (functyptype == 'p' && funcrettype == RECORDOID)
{
ColumnDef *colDef = nth(attnum - 1, coldeflist);
ColumnDef *colDef = list_nth(coldeflist, attnum - 1);
*vartype = typenameTypeId(colDef->typename);
*vartypmod = -1;
@@ -1684,8 +1684,8 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum,
*/
Node *aliasvar;
Assert(attnum > 0 && attnum <= length(rte->joinaliasvars));
aliasvar = (Node *) nth(attnum - 1, rte->joinaliasvars);
Assert(attnum > 0 && attnum <= list_length(rte->joinaliasvars));
aliasvar = (Node *) list_nth(rte->joinaliasvars, attnum - 1);
*vartype = exprType(aliasvar);
*vartypmod = exprTypmod(aliasvar);
}
@@ -1777,8 +1777,8 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum)
*
* Returns NULL if resno is not present in list.
*
* Note: we need to search, rather than just indexing with nth(), because
* not all tlists are sorted by resno.
* Note: we need to search, rather than just indexing with list_nth(),
* because not all tlists are sorted by resno.
*/
TargetEntry *
get_tle_by_resno(List *tlist, AttrNumber resno)

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.118 2004/05/26 04:41:30 neilc Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_target.c,v 1.119 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -108,7 +108,7 @@ transformTargetList(ParseState *pstate, List *targetlist)
if (strcmp(strVal(llast(fields)), "*") == 0)
{
int numnames = length(fields);
int numnames = list_length(fields);
if (numnames == 1)
{
@@ -268,8 +268,8 @@ markTargetListOrigin(ParseState *pstate, Resdom *res, Var *var)
/* Join RTE --- recursively inspect the alias variable */
Var *aliasvar;
Assert(attnum > 0 && attnum <= length(rte->joinaliasvars));
aliasvar = (Var *) nth(attnum - 1, rte->joinaliasvars);
Assert(attnum > 0 && attnum <= list_length(rte->joinaliasvars));
aliasvar = (Var *) list_nth(rte->joinaliasvars, attnum - 1);
markTargetListOrigin(pstate, res, aliasvar);
}
break;
@@ -460,7 +460,7 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
col->indirection = NIL;
col->val = NULL;
cols = lappend(cols, col);
*attrnos = lappendi(*attrnos, i + 1);
*attrnos = lappend_int(*attrnos, i + 1);
}
}
else
@@ -478,12 +478,12 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos)
/* Lookup column name, ereport on failure */
attrno = attnameAttNum(pstate->p_target_relation, name, false);
/* Check for duplicates */
if (intMember(attrno, *attrnos))
if (list_member_int(*attrnos, attrno))
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_COLUMN),
errmsg("column \"%s\" specified more than once",
name)));
*attrnos = lappendi(*attrnos, attrno);
*attrnos = lappend_int(*attrnos, attrno);
}
}
@@ -529,7 +529,7 @@ ExpandAllTables(ParseState *pstate)
continue;
found_table = true;
target = nconc(target, expandRelAttrs(pstate, rte));
target = list_concat(target, expandRelAttrs(pstate, rte));
}
/* Check for SELECT *; */

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.66 2004/05/26 04:41:30 neilc Exp $
* $PostgreSQL: pgsql/src/backend/parser/parse_type.c,v 1.67 2004/05/30 23:40:35 neilc Exp $
*
*-------------------------------------------------------------------------
*/
@@ -54,7 +54,7 @@ LookupTypeName(const TypeName *typename)
AttrNumber attnum;
/* deconstruct the name list */
switch (length(typename->names))
switch (list_length(typename->names))
{
case 1:
ereport(ERROR,
@@ -486,7 +486,7 @@ parseTypeString(const char *str, Oid *type_id, int32 *typmod)
* Make sure we got back exactly what we expected and no more;
* paranoia is justified since the string might contain anything.
*/
if (length(raw_parsetree_list) != 1)
if (list_length(raw_parsetree_list) != 1)
goto fail;
stmt = (SelectStmt *) linitial(raw_parsetree_list);
if (stmt == NULL ||
@@ -503,7 +503,7 @@ parseTypeString(const char *str, Oid *type_id, int32 *typmod)
stmt->forUpdate != NIL ||
stmt->op != SETOP_NONE)
goto fail;
if (length(stmt->targetList) != 1)
if (list_length(stmt->targetList) != 1)
goto fail;
restarget = (ResTarget *) linitial(stmt->targetList);
if (restarget == NULL ||