pgsql: Rearrange the querytree representation of ORDER BY/GROUP

Поиск
Список
Период
Сортировка
От tgl@postgresql.org (Tom Lane)
Тема pgsql: Rearrange the querytree representation of ORDER BY/GROUP
Дата
Msg-id 20080802213201.41EF4754A87@cvs.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Log Message:
-----------
Rearrange the querytree representation of ORDER BY/GROUP BY/DISTINCT items
as per my recent proposal:

1. Fold SortClause and GroupClause into a single node type SortGroupClause.
We were already relying on them to be struct-equivalent, so using two node
tags wasn't accomplishing much except to get in the way of comparing items
with equal().

2. Add an "eqop" field to SortGroupClause to carry the associated equality
operator.  This is cheap for the parser to get at the same time it's looking
up the sort operator, and storing it eliminates the need for repeated
not-so-cheap lookups during planning.  In future this will also let us
represent GROUP/DISTINCT operations on datatypes that have hash opclasses
but no btree opclasses (ie, they have equality but no natural sort order).
The previous representation simply didn't work for that, since its only
indicator of comparison semantics was a sort operator.

3. Add a hasDistinctOn boolean to struct Query to explicitly record whether
the distinctClause came from DISTINCT or DISTINCT ON.  This allows removing
some complicated and not 100% bulletproof code that attempted to figure
that out from the distinctClause alone.

This patch doesn't in itself create any new capability, but it's necessary
infrastructure for future attempts to use hash-based grouping for DISTINCT
and UNION/INTERSECT/EXCEPT.

Modified Files:
--------------
    pgsql/src/backend/catalog:
        dependency.c (r1.76 -> r1.77)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/catalog/dependency.c?r1=1.76&r2=1.77)
    pgsql/src/backend/commands:
        analyze.c (r1.123 -> r1.124)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/analyze.c?r1=1.123&r2=1.124)
    pgsql/src/backend/executor:
        nodeAgg.c (r1.158 -> r1.159)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeAgg.c?r1=1.158&r2=1.159)
    pgsql/src/backend/nodes:
        copyfuncs.c (r1.395 -> r1.396)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/copyfuncs.c?r1=1.395&r2=1.396)
        equalfuncs.c (r1.324 -> r1.325)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/equalfuncs.c?r1=1.324&r2=1.325)
        outfuncs.c (r1.328 -> r1.329)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/outfuncs.c?r1=1.328&r2=1.329)
        readfuncs.c (r1.210 -> r1.211)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/nodes/readfuncs.c?r1=1.210&r2=1.211)
    pgsql/src/backend/optimizer:
        README (r1.46 -> r1.47)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/README?r1=1.46&r2=1.47)
    pgsql/src/backend/optimizer/path:
        allpaths.c (r1.171 -> r1.172)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/allpaths.c?r1=1.171&r2=1.172)
        equivclass.c (r1.10 -> r1.11)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/equivclass.c?r1=1.10&r2=1.11)
        pathkeys.c (r1.93 -> r1.94)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/path/pathkeys.c?r1=1.93&r2=1.94)
    pgsql/src/backend/optimizer/plan:
        createplan.c (r1.241 -> r1.242)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/createplan.c?r1=1.241&r2=1.242)
        planagg.c (r1.41 -> r1.42)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/planagg.c?r1=1.41&r2=1.42)
        planner.c (r1.235 -> r1.236)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/plan/planner.c?r1=1.235&r2=1.236)
    pgsql/src/backend/optimizer/prep:
        prepunion.c (r1.148 -> r1.149)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/prep/prepunion.c?r1=1.148&r2=1.149)
    pgsql/src/backend/optimizer/util:
        clauses.c (r1.259 -> r1.260)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/util/clauses.c?r1=1.259&r2=1.260)
        pathnode.c (r1.143 -> r1.144)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/util/pathnode.c?r1=1.143&r2=1.144)
        tlist.c (r1.78 -> r1.79)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/optimizer/util/tlist.c?r1=1.78&r2=1.79)
    pgsql/src/backend/parser:
        analyze.c (r1.374 -> r1.375)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/analyze.c?r1=1.374&r2=1.375)
        parse_agg.c (r1.79 -> r1.80)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_agg.c?r1=1.79&r2=1.80)
        parse_clause.c (r1.171 -> r1.172)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_clause.c?r1=1.171&r2=1.172)
        parse_oper.c (r1.102 -> r1.103)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/parser/parse_oper.c?r1=1.102&r2=1.103)
    pgsql/src/backend/utils/adt:
        ruleutils.c (r1.278 -> r1.279)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/ruleutils.c?r1=1.278&r2=1.279)
    pgsql/src/backend/utils/cache:
        lsyscache.c (r1.158 -> r1.159)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/cache/lsyscache.c?r1=1.158&r2=1.159)
    pgsql/src/include/catalog:
        catversion.h (r1.473 -> r1.474)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/catversion.h?r1=1.473&r2=1.474)
    pgsql/src/include/nodes:
        nodes.h (r1.206 -> r1.207)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/nodes/nodes.h?r1=1.206&r2=1.207)
        parsenodes.h (r1.369 -> r1.370)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/nodes/parsenodes.h?r1=1.369&r2=1.370)
        primnodes.h (r1.137 -> r1.138)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/nodes/primnodes.h?r1=1.137&r2=1.138)
    pgsql/src/include/optimizer:
        clauses.h (r1.90 -> r1.91)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/optimizer/clauses.h?r1=1.90&r2=1.91)
        tlist.h (r1.49 -> r1.50)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/optimizer/tlist.h?r1=1.49&r2=1.50)
    pgsql/src/include/parser:
        parse_clause.h (r1.50 -> r1.51)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/parser/parse_clause.h?r1=1.50&r2=1.51)
        parse_oper.h (r1.42 -> r1.43)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/parser/parse_oper.h?r1=1.42&r2=1.43)
    pgsql/src/include/utils:
        lsyscache.h (r1.124 -> r1.125)
        (http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/lsyscache.h?r1=1.124&r2=1.125)

В списке pgsql-committers по дате отправления:

Предыдущее
От: richtej@pgfoundry.org (User Richtej)
Дата:
Сообщение: pgsphere - pgsphere: Update README
Следующее
От: tgl@postgresql.org (Tom Lane)
Дата:
Сообщение: pgsql: Fix copy-and-pasteo that's causing pg_regress to lie about which