mirror of
https://github.com/postgres/postgres.git
synced 2025-08-28 18:48:04 +03:00
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.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.124 2008/07/30 17:05:05 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/include/utils/lsyscache.h,v 1.125 2008/08/02 21:32:01 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ extern bool get_ordering_op_properties(Oid opno,
|
||||
Oid *opfamily, Oid *opcintype, int16 *strategy);
|
||||
extern bool get_compare_function_for_ordering_op(Oid opno,
|
||||
Oid *cmpfunc, bool *reverse);
|
||||
extern Oid get_equality_op_for_ordering_op(Oid opno);
|
||||
extern Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse);
|
||||
extern Oid get_ordering_op_for_equality_op(Oid opno, bool use_lhs_type);
|
||||
extern List *get_mergejoin_opfamilies(Oid opno);
|
||||
extern bool get_compatible_hash_operators(Oid opno,
|
||||
@@ -47,7 +47,7 @@ extern bool get_op_hash_functions(Oid opno,
|
||||
RegProcedure *lhs_procno, RegProcedure *rhs_procno);
|
||||
extern void get_op_btree_interpretation(Oid opno,
|
||||
List **opfamilies, List **opstrats);
|
||||
extern bool ops_in_same_btree_opfamily(Oid opno1, Oid opno2);
|
||||
extern bool equality_ops_are_compatible(Oid opno1, Oid opno2);
|
||||
extern Oid get_opfamily_proc(Oid opfamily, Oid lefttype, Oid righttype,
|
||||
int16 procnum);
|
||||
extern char *get_attname(Oid relid, AttrNumber attnum);
|
||||
|
Reference in New Issue
Block a user