Commit 0d22987a authored by Robert Haas's avatar Robert Haas

Add a convenience routine makeFuncCall to reduce duplication.

David Fetter and Andrew Gierth, reviewed by Jeevan Chalke
parent 3132a9b7
...@@ -508,3 +508,28 @@ makeDefElemExtended(char *nameSpace, char *name, Node *arg, ...@@ -508,3 +508,28 @@ makeDefElemExtended(char *nameSpace, char *name, Node *arg,
return res; return res;
} }
/*
* makeFuncCall -
*
* Initialize a FuncCall struct with the information every caller must
* supply. Any non-default parameters have to be handled by the
* caller.
*
*/
FuncCall *
makeFuncCall(List *name, List *args, int location)
{
FuncCall *n = makeNode(FuncCall);
n->funcname = name;
n->args = args;
n->location = location;
n->agg_order = NIL;
n->agg_star = FALSE;
n->agg_distinct = FALSE;
n->func_variadic = FALSE;
n->over = NULL;
return n;
}
This diff is collapsed.
...@@ -448,16 +448,9 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column) ...@@ -448,16 +448,9 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
castnode->typeName = SystemTypeName("regclass"); castnode->typeName = SystemTypeName("regclass");
castnode->arg = (Node *) snamenode; castnode->arg = (Node *) snamenode;
castnode->location = -1; castnode->location = -1;
funccallnode = makeNode(FuncCall); funccallnode = makeFuncCall(SystemFuncName("nextval"),
funccallnode->funcname = SystemFuncName("nextval"); list_make1(castnode),
funccallnode->args = list_make1(castnode); -1);
funccallnode->agg_order = NIL;
funccallnode->agg_star = false;
funccallnode->agg_distinct = false;
funccallnode->func_variadic = false;
funccallnode->over = NULL;
funccallnode->location = -1;
constraint = makeNode(Constraint); constraint = makeNode(Constraint);
constraint->contype = CONSTR_DEFAULT; constraint->contype = CONSTR_DEFAULT;
constraint->location = -1; constraint->location = -1;
......
...@@ -75,6 +75,8 @@ extern TypeName *makeTypeNameFromOid(Oid typeOid, int32 typmod); ...@@ -75,6 +75,8 @@ extern TypeName *makeTypeNameFromOid(Oid typeOid, int32 typmod);
extern FuncExpr *makeFuncExpr(Oid funcid, Oid rettype, List *args, extern FuncExpr *makeFuncExpr(Oid funcid, Oid rettype, List *args,
Oid funccollid, Oid inputcollid, CoercionForm fformat); Oid funccollid, Oid inputcollid, CoercionForm fformat);
extern FuncCall *makeFuncCall(List *name, List *args, int location);
extern DefElem *makeDefElem(char *name, Node *arg); extern DefElem *makeDefElem(char *name, Node *arg);
extern DefElem *makeDefElemExtended(char *nameSpace, char *name, Node *arg, extern DefElem *makeDefElemExtended(char *nameSpace, char *name, Node *arg,
DefElemAction defaction); DefElemAction defaction);
......
...@@ -285,6 +285,11 @@ typedef struct CollateClause ...@@ -285,6 +285,11 @@ typedef struct CollateClause
* construct *must* be an aggregate call. Otherwise, it might be either an * construct *must* be an aggregate call. Otherwise, it might be either an
* aggregate or some other kind of function. However, if OVER is present * aggregate or some other kind of function. However, if OVER is present
* it had better be an aggregate or window function. * it had better be an aggregate or window function.
*
* Normally, you'd initialize this via makeFuncCall() and then only
* change the parts of the struct its defaults don't match afterwards
* if needed.
*
*/ */
typedef struct FuncCall typedef struct FuncCall
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment