1997-11-25 17:07:18 -05:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* parse_clause.h
|
2003-03-21 20:49:38 -05:00
|
|
|
* handle clauses in parser
|
1997-11-25 17:07:18 -05:00
|
|
|
*
|
|
|
|
|
*
|
2019-01-02 12:44:25 -05:00
|
|
|
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
|
2000-01-26 00:58:53 -05:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1997-11-25 17:07:18 -05:00
|
|
|
*
|
2010-09-20 16:08:53 -04:00
|
|
|
* src/include/parser/parse_clause.h
|
1997-11-25 17:07:18 -05:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
#ifndef PARSE_CLAUSE_H
|
|
|
|
|
#define PARSE_CLAUSE_H
|
|
|
|
|
|
1999-07-15 19:04:24 -04:00
|
|
|
#include "parser/parse_node.h"
|
1997-11-25 17:07:18 -05:00
|
|
|
|
2001-02-14 16:35:07 -05:00
|
|
|
extern void transformFromClause(ParseState *pstate, List *frmList);
|
2019-05-22 13:04:48 -04:00
|
|
|
extern int setTargetTable(ParseState *pstate, RangeVar *relation,
|
|
|
|
|
bool inh, bool alsoSource, AclMode requiredPerms);
|
2018-04-12 06:22:56 -04:00
|
|
|
|
2003-07-03 15:07:54 -04:00
|
|
|
extern Node *transformWhereClause(ParseState *pstate, Node *clause,
|
2019-05-22 13:04:48 -04:00
|
|
|
ParseExprKind exprKind, const char *constructName);
|
2003-07-03 15:07:54 -04:00
|
|
|
extern Node *transformLimitClause(ParseState *pstate, Node *clause,
|
2019-05-22 13:04:48 -04:00
|
|
|
ParseExprKind exprKind, const char *constructName);
|
1998-09-01 00:40:42 -04:00
|
|
|
extern List *transformGroupClause(ParseState *pstate, List *grouplist,
|
2019-05-22 13:04:48 -04:00
|
|
|
List **groupingSets,
|
|
|
|
|
List **targetlist, List *sortClause,
|
|
|
|
|
ParseExprKind exprKind, bool useSQL99);
|
1999-08-20 23:49:17 -04:00
|
|
|
extern List *transformSortClause(ParseState *pstate, List *orderlist,
|
2019-05-22 13:04:48 -04:00
|
|
|
List **targetlist, ParseExprKind exprKind,
|
|
|
|
|
bool useSQL99);
|
2008-12-28 13:54:01 -05:00
|
|
|
|
|
|
|
|
extern List *transformWindowDefinitions(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
List *windowdefs,
|
|
|
|
|
List **targetlist);
|
2008-12-28 13:54:01 -05:00
|
|
|
|
2008-08-02 17:32:01 -04:00
|
|
|
extern List *transformDistinctClause(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
List **targetlist, List *sortClause, bool is_agg);
|
2008-08-02 17:32:01 -04:00
|
|
|
extern List *transformDistinctOnClause(ParseState *pstate, List *distinctlist,
|
2019-05-22 13:04:48 -04:00
|
|
|
List **targetlist, List *sortClause);
|
Add support for INSERT ... ON CONFLICT DO NOTHING/UPDATE.
The newly added ON CONFLICT clause allows to specify an alternative to
raising a unique or exclusion constraint violation error when inserting.
ON CONFLICT refers to constraints that can either be specified using a
inference clause (by specifying the columns of a unique constraint) or
by naming a unique or exclusion constraint. DO NOTHING avoids the
constraint violation, without touching the pre-existing row. DO UPDATE
SET ... [WHERE ...] updates the pre-existing tuple, and has access to
both the tuple proposed for insertion and the existing tuple; the
optional WHERE clause can be used to prevent an update from being
executed. The UPDATE SET and WHERE clauses have access to the tuple
proposed for insertion using the "magic" EXCLUDED alias, and to the
pre-existing tuple using the table name or its alias.
This feature is often referred to as upsert.
This is implemented using a new infrastructure called "speculative
insertion". It is an optimistic variant of regular insertion that first
does a pre-check for existing tuples and then attempts an insert. If a
violating tuple was inserted concurrently, the speculatively inserted
tuple is deleted and a new attempt is made. If the pre-check finds a
matching tuple the alternative DO NOTHING or DO UPDATE action is taken.
If the insertion succeeds without detecting a conflict, the tuple is
deemed inserted.
To handle the possible ambiguity between the excluded alias and a table
named excluded, and for convenience with long relation names, INSERT
INTO now can alias its target table.
Bumps catversion as stored rules change.
Author: Peter Geoghegan, with significant contributions from Heikki
Linnakangas and Andres Freund. Testing infrastructure by Jeff Janes.
Reviewed-By: Heikki Linnakangas, Andres Freund, Robert Haas, Simon Riggs,
Dean Rasheed, Stephen Frost and many others.
2015-05-07 23:31:36 -04:00
|
|
|
extern void transformOnConflictArbiter(ParseState *pstate,
|
2019-05-22 13:04:48 -04:00
|
|
|
OnConflictClause *onConflictClause,
|
|
|
|
|
List **arbiterExpr, Node **arbiterWhere,
|
|
|
|
|
Oid *constraint);
|
1999-08-20 23:49:17 -04:00
|
|
|
|
Support ordered-set (WITHIN GROUP) aggregates.
This patch introduces generic support for ordered-set and hypothetical-set
aggregate functions, as well as implementations of the instances defined in
SQL:2008 (percentile_cont(), percentile_disc(), rank(), dense_rank(),
percent_rank(), cume_dist()). We also added mode() though it is not in the
spec, as well as versions of percentile_cont() and percentile_disc() that
can compute multiple percentile values in one pass over the data.
Unlike the original submission, this patch puts full control of the sorting
process in the hands of the aggregate's support functions. To allow the
support functions to find out how they're supposed to sort, a new API
function AggGetAggref() is added to nodeAgg.c. This allows retrieval of
the aggregate call's Aggref node, which may have other uses beyond the
immediate need. There is also support for ordered-set aggregates to
install cleanup callback functions, so that they can be sure that
infrastructure such as tuplesort objects gets cleaned up.
In passing, make some fixes in the recently-added support for variadic
aggregates, and make some editorial adjustments in the recent FILTER
additions for aggregates. Also, simplify use of IsBinaryCoercible() by
allowing it to succeed whenever the target type is ANY or ANYELEMENT.
It was inconsistent that it dealt with other polymorphic target types
but not these.
Atri Sharma and Andrew Gierth; reviewed by Pavel Stehule and Vik Fearing,
and rather heavily editorialized upon by Tom Lane
2013-12-23 16:11:35 -05:00
|
|
|
extern List *addTargetToSortList(ParseState *pstate, TargetEntry *tle,
|
2019-05-22 13:04:48 -04:00
|
|
|
List *sortlist, List *targetlist, SortBy *sortby);
|
1999-08-20 23:49:17 -04:00
|
|
|
extern Index assignSortGroupRef(TargetEntry *tle, List *tlist);
|
2007-01-08 21:14:16 -05:00
|
|
|
extern bool targetIsInSortList(TargetEntry *tle, Oid sortop, List *sortList);
|
2001-10-28 01:26:15 -05:00
|
|
|
|
Phase 2 of pgindent updates.
Change pg_bsd_indent to follow upstream rules for placement of comments
to the right of code, and remove pgindent hack that caused comments
following #endif to not obey the general rule.
Commit e3860ffa4dd0dad0dd9eea4be9cc1412373a8c89 wasn't actually using
the published version of pg_bsd_indent, but a hacked-up version that
tried to minimize the amount of movement of comments to the right of
code. The situation of interest is where such a comment has to be
moved to the right of its default placement at column 33 because there's
code there. BSD indent has always moved right in units of tab stops
in such cases --- but in the previous incarnation, indent was working
in 8-space tab stops, while now it knows we use 4-space tabs. So the
net result is that in about half the cases, such comments are placed
one tab stop left of before. This is better all around: it leaves
more room on the line for comment text, and it means that in such
cases the comment uniformly starts at the next 4-space tab stop after
the code, rather than sometimes one and sometimes two tabs after.
Also, ensure that comments following #endif are indented the same
as comments following other preprocessor commands such as #else.
That inconsistency turns out to have been self-inflicted damage
from a poorly-thought-through post-indent "fixup" in pgindent.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
2017-06-21 15:18:54 -04:00
|
|
|
#endif /* PARSE_CLAUSE_H */
|