diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-04-09 20:35:55 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-04-09 20:35:55 +0000 |
commit | f2d70d32ebd6c38d4fe93c1a684f5f29e5e76938 (patch) | |
tree | 5d041018177cdf6e9ca3ef0cc2eafac580a5bb0b /src/backend/nodes | |
parent | c419c224142eb4bbf6e9a47d2d3626f212fda0fc (diff) | |
download | postgresql-f2d70d32ebd6c38d4fe93c1a684f5f29e5e76938.tar.gz postgresql-f2d70d32ebd6c38d4fe93c1a684f5f29e5e76938.zip |
Functions live in namespaces. Qualified function names work, eg
SELECT schema1.func2(...). Aggregate names can be qualified at the
syntactic level, but the qualification is ignored for the moment.
Diffstat (limited to 'src/backend/nodes')
-rw-r--r-- | src/backend/nodes/copyfuncs.c | 30 | ||||
-rw-r--r-- | src/backend/nodes/equalfuncs.c | 24 | ||||
-rw-r--r-- | src/backend/nodes/list.c | 32 | ||||
-rw-r--r-- | src/backend/nodes/outfuncs.c | 6 |
4 files changed, 58 insertions, 34 deletions
diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index b633b02b79d..873658774ca 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.175 2002/04/05 11:56:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.176 2002/04/09 20:35:49 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1587,8 +1587,7 @@ _copyFuncCall(FuncCall *from) { FuncCall *newnode = makeNode(FuncCall); - if (from->funcname) - newnode->funcname = pstrdup(from->funcname); + Node_Copy(from, newnode, funcname); Node_Copy(from, newnode, args); newnode->agg_star = from->agg_star; newnode->agg_distinct = from->agg_distinct; @@ -1719,6 +1718,7 @@ _copyIndexElem(IndexElem *from) if (from->name) newnode->name = pstrdup(from->name); + Node_Copy(from, newnode, funcname); Node_Copy(from, newnode, args); if (from->class) newnode->class = pstrdup(from->class); @@ -1940,8 +1940,7 @@ _copyFuncWithArgs(FuncWithArgs *from) { FuncWithArgs *newnode = makeNode(FuncWithArgs); - if (from->funcname) - newnode->funcname = pstrdup(from->funcname); + Node_Copy(from, newnode, funcname); Node_Copy(from, newnode, funcargs); return newnode; @@ -2052,13 +2051,10 @@ _copyCommentStmt(CommentStmt *from) CommentStmt *newnode = makeNode(CommentStmt); newnode->objtype = from->objtype; - if (from->objschema) - newnode->objschema = pstrdup(from->objschema); - newnode->objname = pstrdup(from->objname); - if (from->objproperty) - newnode->objproperty = pstrdup(from->objproperty); - Node_Copy(from, newnode, objlist); - newnode->comment = pstrdup(from->comment); + Node_Copy(from, newnode, objname); + Node_Copy(from, newnode, objargs); + if (from->comment) + newnode->comment = pstrdup(from->comment); return newnode; } @@ -2114,7 +2110,7 @@ _copyRemoveAggrStmt(RemoveAggrStmt *from) { RemoveAggrStmt *newnode = makeNode(RemoveAggrStmt); - newnode->aggname = pstrdup(from->aggname); + Node_Copy(from, newnode, aggname); Node_Copy(from, newnode, aggtype); return newnode; @@ -2125,7 +2121,7 @@ _copyRemoveFuncStmt(RemoveFuncStmt *from) { RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt); - newnode->funcname = pstrdup(from->funcname); + Node_Copy(from, newnode, funcname); Node_Copy(from, newnode, args); return newnode; @@ -2370,8 +2366,7 @@ _copyCreateTrigStmt(CreateTrigStmt *from) if (from->trigname) newnode->trigname = pstrdup(from->trigname); Node_Copy(from, newnode, relation); - if (from->funcname) - newnode->funcname = pstrdup(from->funcname); + Node_Copy(from, newnode, funcname); Node_Copy(from, newnode, args); newnode->before = from->before; newnode->row = from->row; @@ -2411,8 +2406,7 @@ _copyCreatePLangStmt(CreatePLangStmt *from) if (from->plname) newnode->plname = pstrdup(from->plname); - if (from->plhandler) - newnode->plhandler = pstrdup(from->plhandler); + Node_Copy(from, newnode, plhandler); if (from->plcompiler) newnode->plcompiler = pstrdup(from->plcompiler); newnode->pltrusted = from->pltrusted; diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index eceb8cb36f7..9458ebc5b95 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -20,7 +20,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.123 2002/04/05 11:56:50 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.124 2002/04/09 20:35:50 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -769,7 +769,7 @@ _equalPrivGrantee(PrivGrantee *a, PrivGrantee *b) static bool _equalFuncWithArgs(FuncWithArgs *a, FuncWithArgs *b) { - return equalstr(a->funcname, b->funcname) + return equal(a->funcname, b->funcname) && equal(a->funcargs, b->funcargs); } @@ -877,13 +877,9 @@ _equalCommentStmt(CommentStmt *a, CommentStmt *b) { if (a->objtype != b->objtype) return false; - if (!equalstr(a->objname, b->objname)) + if (!equal(a->objname, b->objname)) return false; - if (!equalstr(a->objschema, b->objschema)) - return false; - if (!equalstr(a->objproperty, b->objproperty)) - return false; - if (!equal(a->objlist, b->objlist)) + if (!equal(a->objargs, b->objargs)) return false; if (!equalstr(a->comment, b->comment)) return false; @@ -953,7 +949,7 @@ _equalProcedureStmt(ProcedureStmt *a, ProcedureStmt *b) static bool _equalRemoveAggrStmt(RemoveAggrStmt *a, RemoveAggrStmt *b) { - if (!equalstr(a->aggname, b->aggname)) + if (!equal(a->aggname, b->aggname)) return false; if (!equal(a->aggtype, b->aggtype)) return false; @@ -964,7 +960,7 @@ _equalRemoveAggrStmt(RemoveAggrStmt *a, RemoveAggrStmt *b) static bool _equalRemoveFuncStmt(RemoveFuncStmt *a, RemoveFuncStmt *b) { - if (!equalstr(a->funcname, b->funcname)) + if (!equal(a->funcname, b->funcname)) return false; if (!equal(a->args, b->args)) return false; @@ -1207,7 +1203,7 @@ _equalCreateTrigStmt(CreateTrigStmt *a, CreateTrigStmt *b) return false; if (!equal(a->relation, b->relation)) return false; - if (!equalstr(a->funcname, b->funcname)) + if (!equal(a->funcname, b->funcname)) return false; if (!equal(a->args, b->args)) return false; @@ -1253,7 +1249,7 @@ _equalCreatePLangStmt(CreatePLangStmt *a, CreatePLangStmt *b) { if (!equalstr(a->plname, b->plname)) return false; - if (!equalstr(a->plhandler, b->plhandler)) + if (!equal(a->plhandler, b->plhandler)) return false; if (!equalstr(a->plcompiler, b->plcompiler)) return false; @@ -1463,7 +1459,7 @@ _equalIdent(Ident *a, Ident *b) static bool _equalFuncCall(FuncCall *a, FuncCall *b) { - if (!equalstr(a->funcname, b->funcname)) + if (!equal(a->funcname, b->funcname)) return false; if (!equal(a->args, b->args)) return false; @@ -1601,6 +1597,8 @@ _equalIndexElem(IndexElem *a, IndexElem *b) { if (!equalstr(a->name, b->name)) return false; + if (!equal(a->funcname, b->funcname)) + return false; if (!equal(a->args, b->args)) return false; if (!equalstr(a->class, b->class)) diff --git a/src/backend/nodes/list.c b/src/backend/nodes/list.c index 9b588150fda..a61991f38fa 100644 --- a/src/backend/nodes/list.c +++ b/src/backend/nodes/list.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.39 2001/03/22 03:59:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.40 2002/04/09 20:35:50 tgl Exp $ * * NOTES * XXX a few of the following functions are duplicated to handle @@ -234,6 +234,36 @@ length(List *l) } /* + * llast + * + * Get the last element of l ... error if empty list + */ +void * +llast(List *l) +{ + if (l == NIL) + elog(ERROR, "llast: empty list"); + while (lnext(l) != NIL) + l = lnext(l); + return lfirst(l); +} + +/* + * llasti + * + * As above, but for integer lists + */ +int +llasti(List *l) +{ + if (l == NIL) + elog(ERROR, "llasti: empty list"); + while (lnext(l) != NIL) + l = lnext(l); + return lfirsti(l); +} + +/* * freeList * * Free the List nodes of a list diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 20d25c64397..a495f5ed10b 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.152 2002/03/29 19:06:09 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.153 2002/04/09 20:35:50 tgl Exp $ * * NOTES * Every (plan) node in POSTGRES has an associated "out" routine which @@ -160,7 +160,7 @@ static void _outFuncCall(StringInfo str, FuncCall *node) { appendStringInfo(str, "FUNCTION "); - _outToken(str, node->funcname); + _outNode(str, node->funcname); appendStringInfo(str, " :args "); _outNode(str, node->args); appendStringInfo(str, " :agg_star %s :agg_distinct %s ", @@ -213,6 +213,8 @@ _outIndexElem(StringInfo str, IndexElem *node) { appendStringInfo(str, " INDEXELEM :name "); _outToken(str, node->name); + appendStringInfo(str, " :funcname "); + _outNode(str, node->funcname); appendStringInfo(str, " :args "); _outNode(str, node->args); appendStringInfo(str, " :class "); |