OSDN Git Service

From: David Hartwig <daybee@bellatlantic.net>
authorMarc G. Fournier <scrappy@hub.org>
Wed, 5 Aug 1998 04:49:19 +0000 (04:49 +0000)
committerMarc G. Fournier <scrappy@hub.org>
Wed, 5 Aug 1998 04:49:19 +0000 (04:49 +0000)
commita1627a1d64da72723d61e1ff033bf00ea05a82d0
tree4ecfc8645a11c0f0dbc118e1d6332a92c957605b
parent186aeb1d671d68bb0c5f8e6d31b091add3a80f81
From: David Hartwig <daybee@bellatlantic.net>

I have attached a patch to allow GROUP BY and/or ORDER BY function or
expressions.  Note worthy items:

1. The expression or function need not be in the target list.
Example:
            SELECT  name FROM foo GROUP BY lower(name);

2.   Simplified the grammar to use expressions only.

3.  Cleaned up earlier patch in this area to make use of existing
utility functions.

3.  Reduced some of the members in the SortGroupBy parse node.   The
original data members were redundant with the new expression node.
(MUST do a "make clean" now)

4.  Added a new parse node "JoinUsing".   The JOIN USING clause was
overloading this SortGroupBy structure.   With the afore mentioned
reduction of members, the two clauses lost all their commonality.

5.  A bug still exist where, if a function or expression is GROUPed BY,
and an aggregate function does not include a attribute from the
expression or function, the backend crashes.   (or something like
that)   The bug pre-dates this patch.    Example:

    SELECT lower(a) AS lowcase, count(b) FROM foo GROUP BY lowcase;
                 *** BOOM  ***

    --Also when not in target list
    SELECT  count(b) FROM foo GROUP BY lower(a);
                *** BOOM  AGAIN ***
src/backend/parser/gram.y
src/backend/parser/parse_clause.c
src/backend/parser/parse_target.c
src/include/nodes/nodes.h
src/include/nodes/parsenodes.h
src/include/parser/parse_target.h
src/test/regress/expected/select_implicit.out
src/test/regress/sql/select_implicit.sql