mirror of
https://github.com/postgres/postgres.git
synced 2026-01-27 21:43:08 +03:00
GROUP BY ALL is a form of GROUP BY that adds any TargetExpr that does not contain an aggregate or window function into the groupClause of the query, making it exactly equivalent to specifying those same expressions in an explicit GROUP BY list. This feature is useful for certain kinds of data exploration. It's already present in some other DBMSes, and the SQL committee recently accepted it into the standard, so we can be reasonably confident in the syntax being stable. We do have to invent part of the semantics, as the standard doesn't allow for expressions in GROUP BY, so they haven't specified what to do with window functions. We assume that those should be treated like aggregates, i.e., left out of the constructed GROUP BY list. In passing, wordsmith some existing documentation about GROUP BY, and update some neglected synopsis entries in select_into.sgml. Author: David Christensen <david@pgguru.net> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/CAHM0NXjz0kDwtzoe-fnHAqPB1qA8_VJN0XAmCgUZ+iPnvP5LbA@mail.gmail.com
59 lines
2.3 KiB
C
59 lines
2.3 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* parse_clause.h
|
|
* handle clauses in parser
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/parser/parse_clause.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef PARSE_CLAUSE_H
|
|
#define PARSE_CLAUSE_H
|
|
|
|
#include "parser/parse_node.h"
|
|
|
|
extern void transformFromClause(ParseState *pstate, List *frmList);
|
|
extern int setTargetTable(ParseState *pstate, RangeVar *relation,
|
|
bool inh, bool alsoSource, AclMode requiredPerms);
|
|
|
|
extern Node *transformWhereClause(ParseState *pstate, Node *clause,
|
|
ParseExprKind exprKind, const char *constructName);
|
|
extern Node *transformLimitClause(ParseState *pstate, Node *clause,
|
|
ParseExprKind exprKind, const char *constructName,
|
|
LimitOption limitOption);
|
|
extern List *transformGroupClause(ParseState *pstate, List *grouplist,
|
|
bool groupByAll,
|
|
List **groupingSets,
|
|
List **targetlist, List *sortClause,
|
|
ParseExprKind exprKind, bool useSQL99);
|
|
extern List *transformSortClause(ParseState *pstate, List *orderlist,
|
|
List **targetlist, ParseExprKind exprKind,
|
|
bool useSQL99);
|
|
|
|
extern List *transformWindowDefinitions(ParseState *pstate,
|
|
List *windowdefs,
|
|
List **targetlist);
|
|
|
|
extern List *transformDistinctClause(ParseState *pstate,
|
|
List **targetlist, List *sortClause, bool is_agg);
|
|
extern List *transformDistinctOnClause(ParseState *pstate, List *distinctlist,
|
|
List **targetlist, List *sortClause);
|
|
extern void transformOnConflictArbiter(ParseState *pstate,
|
|
OnConflictClause *onConflictClause,
|
|
List **arbiterExpr, Node **arbiterWhere,
|
|
Oid *constraint);
|
|
|
|
extern List *addTargetToSortList(ParseState *pstate, TargetEntry *tle,
|
|
List *sortlist, List *targetlist, SortBy *sortby);
|
|
extern Index assignSortGroupRef(TargetEntry *tle, List *tlist);
|
|
extern bool targetIsInSortList(TargetEntry *tle, Oid sortop, List *sortList);
|
|
|
|
/* functions in parse_jsontable.c */
|
|
extern ParseNamespaceItem *transformJsonTable(ParseState *pstate, JsonTable *jt);
|
|
|
|
#endif /* PARSE_CLAUSE_H */
|