1996-08-28 03:59:28 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
1999-02-14 00:22:53 +01:00
|
|
|
* makefuncs.h
|
2019-07-29 02:58:49 +02:00
|
|
|
* prototypes for the creator functions of various nodes
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*
|
2019-01-02 18:44:25 +01:00
|
|
|
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
|
2000-01-26 06:58:53 +01:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/nodes/makefuncs.h
|
1996-08-28 03:59:28 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef MAKEFUNC_H
|
|
|
|
#define MAKEFUNC_H
|
|
|
|
|
2019-07-29 02:58:49 +02:00
|
|
|
#include "nodes/execnodes.h"
|
1999-07-16 01:04:24 +02:00
|
|
|
#include "nodes/parsenodes.h"
|
1996-08-28 03:59:28 +02:00
|
|
|
|
Extend pg_cast castimplicit column to a three-way value; this allows us
to be flexible about assignment casts without introducing ambiguity in
operator/function resolution. Introduce a well-defined promotion hierarchy
for numeric datatypes (int2->int4->int8->numeric->float4->float8).
Change make_const to initially label numeric literals as int4, int8, or
numeric (never float8 anymore).
Explicitly mark Func and RelabelType nodes to indicate whether they came
from a function call, explicit cast, or implicit cast; use this to do
reverse-listing more accurately and without so many heuristics.
Explicit casts to char, varchar, bit, varbit will truncate or pad without
raising an error (the pre-7.2 behavior), while assigning to a column without
any explicit cast will still raise an error for wrong-length data like 7.3.
This more nearly follows the SQL spec than 7.2 behavior (we should be
reporting a 'completion condition' in the explicit-cast cases, but we have
no mechanism for that, so just do silent truncation).
Fix some problems with enforcement of typmod for array elements;
it didn't work at all in 'UPDATE ... SET array[n] = foo', for example.
Provide a generalized array_length_coerce() function to replace the
specialized per-array-type functions that used to be needed (and were
missing for NUMERIC as well as all the datetime types).
Add missing conversions int8<->float4, text<->numeric, oid<->int8.
initdb forced.
2002-09-18 23:35:25 +02:00
|
|
|
|
2003-02-10 05:44:47 +01:00
|
|
|
extern A_Expr *makeA_Expr(A_Expr_Kind kind, List *name,
|
2019-05-22 19:04:48 +02:00
|
|
|
Node *lexpr, Node *rexpr, int location);
|
2002-04-17 01:08:12 +02:00
|
|
|
|
2011-09-11 20:54:32 +02:00
|
|
|
extern A_Expr *makeSimpleA_Expr(A_Expr_Kind kind, char *name,
|
2019-05-22 19:04:48 +02:00
|
|
|
Node *lexpr, Node *rexpr, int location);
|
2002-04-17 01:08:12 +02:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
extern Var *makeVar(Index varno,
|
2019-05-22 19:04:48 +02:00
|
|
|
AttrNumber varattno,
|
|
|
|
Oid vartype,
|
|
|
|
int32 vartypmod,
|
|
|
|
Oid varcollid,
|
|
|
|
Index varlevelsup);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2010-08-27 22:30:08 +02:00
|
|
|
extern Var *makeVarFromTargetEntry(Index varno,
|
2019-05-22 19:04:48 +02:00
|
|
|
TargetEntry *tle);
|
2010-08-27 22:30:08 +02:00
|
|
|
|
2010-10-19 21:08:37 +02:00
|
|
|
extern Var *makeWholeRowVar(RangeTblEntry *rte,
|
2019-05-22 19:04:48 +02:00
|
|
|
Index varno,
|
|
|
|
Index varlevelsup,
|
|
|
|
bool allowScalar);
|
2010-10-19 21:08:37 +02:00
|
|
|
|
2005-04-06 18:34:07 +02:00
|
|
|
extern TargetEntry *makeTargetEntry(Expr *expr,
|
2019-05-22 19:04:48 +02:00
|
|
|
AttrNumber resno,
|
|
|
|
char *resname,
|
|
|
|
bool resjunk);
|
1998-07-20 22:48:54 +02:00
|
|
|
|
2005-04-06 18:34:07 +02:00
|
|
|
extern TargetEntry *flatCopyTargetEntry(TargetEntry *src_tle);
|
1996-08-28 03:59:28 +02:00
|
|
|
|
2007-06-24 00:12:52 +02:00
|
|
|
extern FromExpr *makeFromExpr(List *fromlist, Node *quals);
|
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
extern Const *makeConst(Oid consttype,
|
2019-05-22 19:04:48 +02:00
|
|
|
int32 consttypmod,
|
|
|
|
Oid constcollid,
|
|
|
|
int constlen,
|
|
|
|
Datum constvalue,
|
|
|
|
bool constisnull,
|
|
|
|
bool constbyval);
|
1997-09-07 07:04:48 +02:00
|
|
|
|
2011-03-26 01:10:42 +01:00
|
|
|
extern Const *makeNullConst(Oid consttype, int32 consttypmod, Oid constcollid);
|
2000-11-16 23:30:52 +01:00
|
|
|
|
2004-05-11 00:44:49 +02:00
|
|
|
extern Node *makeBoolConst(bool value, bool isnull);
|
|
|
|
|
2008-08-29 01:09:48 +02:00
|
|
|
extern Expr *makeBoolExpr(BoolExprType boolop, List *args, int location);
|
2002-12-12 16:49:42 +01:00
|
|
|
|
2002-03-21 17:02:16 +01:00
|
|
|
extern Alias *makeAlias(const char *aliasname, List *colnames);
|
2001-10-28 07:26:15 +01:00
|
|
|
|
2002-12-12 16:49:42 +01:00
|
|
|
extern RelabelType *makeRelabelType(Expr *arg, Oid rtype, int32 rtypmod,
|
2019-05-22 19:04:48 +02:00
|
|
|
Oid rcollid, CoercionForm rformat);
|
2002-03-20 20:45:13 +01:00
|
|
|
|
2008-09-01 22:42:46 +02:00
|
|
|
extern RangeVar *makeRangeVar(char *schemaname, char *relname, int location);
|
2002-03-22 03:56:37 +01:00
|
|
|
|
2002-03-29 20:06:29 +01:00
|
|
|
extern TypeName *makeTypeName(char *typnam);
|
2006-03-14 23:48:25 +01:00
|
|
|
extern TypeName *makeTypeNameFromNameList(List *names);
|
Remove collation information from TypeName, where it does not belong.
The initial collations patch treated a COLLATE spec as part of a TypeName,
following what can only be described as brain fade on the part of the SQL
committee. It's a lot more reasonable to treat COLLATE as a syntactically
separate object, so that it can be added in only the productions where it
actually belongs, rather than needing to reject it in a boatload of places
where it doesn't belong (something the original patch mostly failed to do).
In addition this change lets us meet the spec's requirement to allow
COLLATE anywhere in the clauses of a ColumnDef, and it avoids unfriendly
behavior for constructs such as "foo::type COLLATE collation".
To do this, pull collation information out of TypeName and put it in
ColumnDef instead, thus reverting most of the collation-related changes in
parse_type.c's API. I made one additional structural change, which was to
use a ColumnDef as an intermediate node in AT_AlterColumnType AlterTableCmd
nodes. This provides enough room to get rid of the "transform" wart in
AlterTableCmd too, since the ColumnDef can carry the USING expression
easily enough.
Also fix some other minor bugs that have crept in in the same areas,
like failure to copy recently-added fields of ColumnDef in copyfuncs.c.
While at it, document the formerly secret ability to specify a collation
in ALTER TABLE ALTER COLUMN TYPE, ALTER TYPE ADD ATTRIBUTE, and
ALTER TYPE ALTER ATTRIBUTE TYPE; and correct some misstatements about
what the default collation selection will be when COLLATE is omitted.
BTW, the three-parameter form of format_type() should go away too,
since it just contributes to the confusion in this area; but I'll do
that in a separate patch.
2011-03-10 04:38:52 +01:00
|
|
|
extern TypeName *makeTypeNameFromOid(Oid typeOid, int32 typmod);
|
2002-03-29 20:06:29 +01:00
|
|
|
|
2016-06-27 21:57:21 +02:00
|
|
|
extern ColumnDef *makeColumnDef(const char *colname,
|
2019-05-22 19:04:48 +02:00
|
|
|
Oid typeOid, int32 typmod, Oid collOid);
|
2016-06-27 21:57:21 +02:00
|
|
|
|
2011-03-20 01:29:08 +01:00
|
|
|
extern FuncExpr *makeFuncExpr(Oid funcid, Oid rettype, List *args,
|
2019-05-22 19:04:48 +02:00
|
|
|
Oid funccollid, Oid inputcollid, CoercionForm fformat);
|
2003-07-01 21:10:53 +02:00
|
|
|
|
2013-07-01 20:41:33 +02:00
|
|
|
extern FuncCall *makeFuncCall(List *name, List *args, int location);
|
|
|
|
|
2019-01-29 21:26:44 +01:00
|
|
|
extern Expr *make_opclause(Oid opno, Oid opresulttype, bool opretset,
|
2019-05-22 19:04:48 +02:00
|
|
|
Expr *leftop, Expr *rightop,
|
|
|
|
Oid opcollid, Oid inputcollid);
|
2019-01-29 21:26:44 +01:00
|
|
|
|
|
|
|
extern Expr *make_andclause(List *andclauses);
|
|
|
|
extern Expr *make_orclause(List *orclauses);
|
|
|
|
extern Expr *make_notclause(Expr *notclause);
|
|
|
|
|
|
|
|
extern Node *make_and_qual(Node *qual1, Node *qual2);
|
|
|
|
extern Expr *make_ands_explicit(List *andclauses);
|
|
|
|
extern List *make_ands_implicit(Expr *clause);
|
|
|
|
|
2019-07-29 02:58:49 +02:00
|
|
|
extern IndexInfo *makeIndexInfo(int numattrs, int numkeyattrs, Oid amoid,
|
|
|
|
List *expressions, List *predicates,
|
|
|
|
bool unique, bool isready, bool concurrent);
|
|
|
|
|
2016-09-06 18:00:00 +02:00
|
|
|
extern DefElem *makeDefElem(char *name, Node *arg, int location);
|
2009-07-16 08:33:46 +02:00
|
|
|
extern DefElem *makeDefElemExtended(char *nameSpace, char *name, Node *arg,
|
2019-05-22 19:04:48 +02:00
|
|
|
DefElemAction defaction, int location);
|
2009-02-02 20:31:40 +01:00
|
|
|
|
Support GROUPING SETS, CUBE and ROLLUP.
This SQL standard functionality allows to aggregate data by different
GROUP BY clauses at once. Each grouping set returns rows with columns
grouped by in other sets set to NULL.
This could previously be achieved by doing each grouping as a separate
query, conjoined by UNION ALLs. Besides being considerably more concise,
grouping sets will in many cases be faster, requiring only one scan over
the underlying data.
The current implementation of grouping sets only supports using sorting
for input. Individual sets that share a sort order are computed in one
pass. If there are sets that don't share a sort order, additional sort &
aggregation steps are performed. These additional passes are sourced by
the previous sort step; thus avoiding repeated scans of the source data.
The code is structured in a way that adding support for purely using
hash aggregation or a mix of hashing and sorting is possible. Sorting
was chosen to be supported first, as it is the most generic method of
implementation.
Instead of, as in an earlier versions of the patch, representing the
chain of sort and aggregation steps as full blown planner and executor
nodes, all but the first sort are performed inside the aggregation node
itself. This avoids the need to do some unusual gymnastics to handle
having to return aggregated and non-aggregated tuples from underlying
nodes, as well as having to shut down underlying nodes early to limit
memory usage. The optimizer still builds Sort/Agg node to describe each
phase, but they're not part of the plan tree, but instead additional
data for the aggregation node. They're a convenient and preexisting way
to describe aggregation and sorting. The first (and possibly only) sort
step is still performed as a separate execution step. That retains
similarity with existing group by plans, makes rescans fairly simple,
avoids very deep plans (leading to slow explains) and easily allows to
avoid the sorting step if the underlying data is sorted by other means.
A somewhat ugly side of this patch is having to deal with a grammar
ambiguity between the new CUBE keyword and the cube extension/functions
named cube (and rollup). To avoid breaking existing deployments of the
cube extension it has not been renamed, neither has cube been made a
reserved keyword. Instead precedence hacking is used to make GROUP BY
cube(..) refer to the CUBE grouping sets feature, and not the function
cube(). To actually group by a function cube(), unlikely as that might
be, the function name has to be quoted.
Needs a catversion bump because stored rules may change.
Author: Andrew Gierth and Atri Sharma, with contributions from Andres Freund
Reviewed-By: Andres Freund, Noah Misch, Tom Lane, Svenne Krap, Tomas
Vondra, Erik Rijkers, Marti Raudsepp, Pavel Stehule
Discussion: CAOeZVidmVRe2jU6aMk_5qkxnB7dfmPROzM7Ur8JPW5j8Y5X-Lw@mail.gmail.com
2015-05-16 03:40:59 +02:00
|
|
|
extern GroupingSet *makeGroupingSet(GroupingSetKind kind, List *content, int location);
|
|
|
|
|
2017-10-04 00:53:44 +02:00
|
|
|
extern VacuumRelation *makeVacuumRelation(RangeVar *relation, Oid oid, List *va_cols);
|
|
|
|
|
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 21:18:54 +02:00
|
|
|
#endif /* MAKEFUNC_H */
|