diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-08-17 19:58:06 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-08-17 19:58:06 +0000 |
commit | ec646dbc65afc8c55118cb3fb75cb6fd18d78dd8 (patch) | |
tree | bd256cf157c4636382d59938162326fccc70b62c /src/backend/parser/parse_clause.c | |
parent | d89578ccbefb83aa9f9d1c00269cd866be2cc857 (diff) | |
download | postgresql-ec646dbc65afc8c55118cb3fb75cb6fd18d78dd8.tar.gz postgresql-ec646dbc65afc8c55118cb3fb75cb6fd18d78dd8.zip |
Create a 'type cache' that keeps track of the data needed for any particular
datatype by array_eq and array_cmp; use this to solve problems with memory
leaks in array indexing support. The parser's equality_oper and ordering_oper
routines also use the cache. Change the operator search algorithms to look
for appropriate btree or hash index opclasses, instead of assuming operators
named '<' or '=' have the right semantics. (ORDER BY ASC/DESC now also look
at opclasses, instead of assuming '<' and '>' are the right things.) Add
several more index opclasses so that there is no regression in functionality
for base datatypes. initdb forced due to catalog additions.
Diffstat (limited to 'src/backend/parser/parse_clause.c')
-rw-r--r-- | src/backend/parser/parse_clause.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index ebc3ed23eec..b31e70205dd 100644 --- a/src/backend/parser/parse_clause.c +++ b/src/backend/parser/parse_clause.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.121 2003/08/07 19:20:22 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.122 2003/08/17 19:58:05 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -1295,7 +1295,7 @@ transformSortClause(ParseState *pstate, foreach(olitem, orderlist) { - SortGroupBy *sortby = lfirst(olitem); + SortBy *sortby = lfirst(olitem); TargetEntry *tle; tle = findTargetlistEntry(pstate, sortby->node, @@ -1303,7 +1303,9 @@ transformSortClause(ParseState *pstate, sortlist = addTargetToSortList(pstate, tle, sortlist, targetlist, - sortby->useOp, resolveUnknown); + sortby->sortby_kind, + sortby->useOp, + resolveUnknown); } return sortlist; @@ -1409,7 +1411,7 @@ transformDistinctClause(ParseState *pstate, List *distinctlist, { *sortClause = addTargetToSortList(pstate, tle, *sortClause, targetlist, - NIL, true); + SORTBY_ASC, NIL, true); /* * Probably, the tle should always have been added at the @@ -1457,7 +1459,8 @@ addAllTargetsToSortList(ParseState *pstate, List *sortlist, if (!tle->resdom->resjunk) sortlist = addTargetToSortList(pstate, tle, sortlist, targetlist, - NIL, resolveUnknown); + SORTBY_ASC, NIL, + resolveUnknown); } return sortlist; } @@ -1478,7 +1481,8 @@ addAllTargetsToSortList(ParseState *pstate, List *sortlist, List * addTargetToSortList(ParseState *pstate, TargetEntry *tle, List *sortlist, List *targetlist, - List *opname, bool resolveUnknown) + int sortby_kind, List *sortby_opname, + bool resolveUnknown) { /* avoid making duplicate sortlist entries */ if (!targetIsInSortList(tle, sortlist)) @@ -1499,13 +1503,25 @@ addTargetToSortList(ParseState *pstate, TargetEntry *tle, sortcl->tleSortGroupRef = assignSortGroupRef(tle, targetlist); - if (opname) - sortcl->sortop = compatible_oper_opid(opname, - restype, - restype, - false); - else - sortcl->sortop = ordering_oper_opid(restype); + switch (sortby_kind) + { + case SORTBY_ASC: + sortcl->sortop = ordering_oper_opid(restype); + break; + case SORTBY_DESC: + sortcl->sortop = reverse_ordering_oper_opid(restype); + break; + case SORTBY_USING: + Assert(sortby_opname != NIL); + sortcl->sortop = compatible_oper_opid(sortby_opname, + restype, + restype, + false); + break; + default: + elog(ERROR, "unrecognized sortby_kind: %d", sortby_kind); + break; + } sortlist = lappend(sortlist, sortcl); } |