2009-03-06 19:13:58 -05:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
*
|
|
|
|
|
* kwlist.h
|
|
|
|
|
*
|
|
|
|
|
* The keyword list is kept in its own source file for possible use by
|
|
|
|
|
* automatic tools. The exact representation of a keyword is determined
|
|
|
|
|
* by the PG_KEYWORD macro, which is not defined in this file; it can
|
|
|
|
|
* be defined by the caller for special purposes.
|
|
|
|
|
*
|
2017-01-03 13:48:53 -05:00
|
|
|
* Portions Copyright (c) 1996-2017, PostgreSQL Global Development Group
|
2009-03-06 19:13:58 -05:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
|
*
|
|
|
|
|
* IDENTIFICATION
|
2010-09-20 16:08:53 -04:00
|
|
|
* src/include/parser/kwlist.h
|
2009-03-06 19:13:58 -05:00
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* there is deliberately not an #ifndef KWLIST_H here */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* List of keyword (name, token-value, category) entries.
|
|
|
|
|
*
|
|
|
|
|
* !!WARNING!!: This list must be sorted by ASCII name, because binary
|
|
|
|
|
* search is used to locate entries.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/* name, value, category */
|
|
|
|
|
PG_KEYWORD("abort", ABORT_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("absolute", ABSOLUTE_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("access", ACCESS, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("action", ACTION, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("add", ADD_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("admin", ADMIN, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("after", AFTER, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("aggregate", AGGREGATE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("all", ALL, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("also", ALSO, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("alter", ALTER, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("always", ALWAYS, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("analyse", ANALYSE, RESERVED_KEYWORD) /* British spelling */
|
|
|
|
|
PG_KEYWORD("analyze", ANALYZE, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("and", AND, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("any", ANY, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("array", ARRAY, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("as", AS, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("asc", ASC, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("assertion", ASSERTION, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("assignment", ASSIGNMENT, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("asymmetric", ASYMMETRIC, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("at", AT, UNRESERVED_KEYWORD)
|
Implement table partitioning.
Table partitioning is like table inheritance and reuses much of the
existing infrastructure, but there are some important differences.
The parent is called a partitioned table and is always empty; it may
not have indexes or non-inherited constraints, since those make no
sense for a relation with no data of its own. The children are called
partitions and contain all of the actual data. Each partition has an
implicit partitioning constraint. Multiple inheritance is not
allowed, and partitioning and inheritance can't be mixed. Partitions
can't have extra columns and may not allow nulls unless the parent
does. Tuples inserted into the parent are automatically routed to the
correct partition, so tuple-routing ON INSERT triggers are not needed.
Tuple routing isn't yet supported for partitions which are foreign
tables, and it doesn't handle updates that cross partition boundaries.
Currently, tables can be range-partitioned or list-partitioned. List
partitioning is limited to a single column, but range partitioning can
involve multiple columns. A partitioning "column" can be an
expression.
Because table partitioning is less general than table inheritance, it
is hoped that it will be easier to reason about properties of
partitions, and therefore that this will serve as a better foundation
for a variety of possible optimizations, including query planner
optimizations. The tuple routing based which this patch does based on
the implicit partitioning constraints is an example of this, but it
seems likely that many other useful optimizations are also possible.
Amit Langote, reviewed and tested by Robert Haas, Ashutosh Bapat,
Amit Kapila, Rajkumar Raghuwanshi, Corey Huinker, Jaime Casanova,
Rushabh Lathia, Erik Rijkers, among others. Minor revisions by me.
2016-12-07 13:17:43 -05:00
|
|
|
PG_KEYWORD("attach", ATTACH, UNRESERVED_KEYWORD)
|
2010-09-26 07:41:03 -04:00
|
|
|
PG_KEYWORD("attribute", ATTRIBUTE, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("authorization", AUTHORIZATION, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("backward", BACKWARD, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("before", BEFORE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("begin", BEGIN_P, UNRESERVED_KEYWORD)
|
2010-02-12 12:33:21 -05:00
|
|
|
PG_KEYWORD("between", BETWEEN, COL_NAME_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("bigint", BIGINT, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("binary", BINARY, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("bit", BIT, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("boolean", BOOLEAN_P, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("both", BOTH, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("by", BY, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("cache", CACHE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("called", CALLED, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("cascade", CASCADE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("cascaded", CASCADED, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("case", CASE, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("cast", CAST, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("catalog", CATALOG_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("chain", CHAIN, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("char", CHAR_P, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("character", CHARACTER, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("characteristics", CHARACTERISTICS, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("check", CHECK, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("checkpoint", CHECKPOINT, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("class", CLASS, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("close", CLOSE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("cluster", CLUSTER, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("coalesce", COALESCE, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("collate", COLLATE, RESERVED_KEYWORD)
|
2012-05-16 13:19:44 -04:00
|
|
|
PG_KEYWORD("collation", COLLATION, TYPE_FUNC_NAME_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("column", COLUMN, RESERVED_KEYWORD)
|
2017-03-08 10:39:37 -05:00
|
|
|
PG_KEYWORD("columns", COLUMNS, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("comment", COMMENT, UNRESERVED_KEYWORD)
|
2009-10-12 15:49:24 -04:00
|
|
|
PG_KEYWORD("comments", COMMENTS, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("commit", COMMIT, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("committed", COMMITTED, UNRESERVED_KEYWORD)
|
2009-12-23 12:41:45 -05:00
|
|
|
PG_KEYWORD("concurrently", CONCURRENTLY, TYPE_FUNC_NAME_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("configuration", CONFIGURATION, UNRESERVED_KEYWORD)
|
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
|
|
|
PG_KEYWORD("conflict", CONFLICT, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("connection", CONNECTION, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("constraint", CONSTRAINT, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("constraints", CONSTRAINTS, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("content", CONTENT_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("continue", CONTINUE_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("conversion", CONVERSION_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("copy", COPY, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("cost", COST, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("create", CREATE, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("cross", CROSS, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("csv", CSV, UNRESERVED_KEYWORD)
|
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-15 21:40:59 -04:00
|
|
|
PG_KEYWORD("cube", CUBE, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("current", CURRENT_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("current_catalog", CURRENT_CATALOG, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("current_date", CURRENT_DATE, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("current_role", CURRENT_ROLE, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("current_schema", CURRENT_SCHEMA, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("current_time", CURRENT_TIME, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("current_timestamp", CURRENT_TIMESTAMP, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("current_user", CURRENT_USER, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("cursor", CURSOR, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("cycle", CYCLE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("data", DATA_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("database", DATABASE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("day", DAY_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("deallocate", DEALLOCATE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("dec", DEC, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("decimal", DECIMAL_P, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("declare", DECLARE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("default", DEFAULT, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("defaults", DEFAULTS, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("deferrable", DEFERRABLE, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("deferred", DEFERRED, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("definer", DEFINER, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("delete", DELETE_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("delimiter", DELIMITER, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("delimiters", DELIMITERS, UNRESERVED_KEYWORD)
|
2016-04-05 17:38:54 -04:00
|
|
|
PG_KEYWORD("depends", DEPENDS, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("desc", DESC, RESERVED_KEYWORD)
|
Implement table partitioning.
Table partitioning is like table inheritance and reuses much of the
existing infrastructure, but there are some important differences.
The parent is called a partitioned table and is always empty; it may
not have indexes or non-inherited constraints, since those make no
sense for a relation with no data of its own. The children are called
partitions and contain all of the actual data. Each partition has an
implicit partitioning constraint. Multiple inheritance is not
allowed, and partitioning and inheritance can't be mixed. Partitions
can't have extra columns and may not allow nulls unless the parent
does. Tuples inserted into the parent are automatically routed to the
correct partition, so tuple-routing ON INSERT triggers are not needed.
Tuple routing isn't yet supported for partitions which are foreign
tables, and it doesn't handle updates that cross partition boundaries.
Currently, tables can be range-partitioned or list-partitioned. List
partitioning is limited to a single column, but range partitioning can
involve multiple columns. A partitioning "column" can be an
expression.
Because table partitioning is less general than table inheritance, it
is hoped that it will be easier to reason about properties of
partitions, and therefore that this will serve as a better foundation
for a variety of possible optimizations, including query planner
optimizations. The tuple routing based which this patch does based on
the implicit partitioning constraints is an example of this, but it
seems likely that many other useful optimizations are also possible.
Amit Langote, reviewed and tested by Robert Haas, Ashutosh Bapat,
Amit Kapila, Rajkumar Raghuwanshi, Corey Huinker, Jaime Casanova,
Rushabh Lathia, Erik Rijkers, among others. Minor revisions by me.
2016-12-07 13:17:43 -05:00
|
|
|
PG_KEYWORD("detach", DETACH, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("dictionary", DICTIONARY, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("disable", DISABLE_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("discard", DISCARD, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("distinct", DISTINCT, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("do", DO, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("document", DOCUMENT_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("domain", DOMAIN_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("double", DOUBLE_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("drop", DROP, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("each", EACH, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("else", ELSE, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("enable", ENABLE_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("encoding", ENCODING, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("encrypted", ENCRYPTED, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("end", END_P, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("enum", ENUM_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("escape", ESCAPE, UNRESERVED_KEYWORD)
|
2012-07-18 10:16:16 -04:00
|
|
|
PG_KEYWORD("event", EVENT, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("except", EXCEPT, RESERVED_KEYWORD)
|
2009-12-07 00:22:23 -05:00
|
|
|
PG_KEYWORD("exclude", EXCLUDE, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("excluding", EXCLUDING, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("exclusive", EXCLUSIVE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("execute", EXECUTE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("exists", EXISTS, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("explain", EXPLAIN, UNRESERVED_KEYWORD)
|
2011-02-08 16:08:41 -05:00
|
|
|
PG_KEYWORD("extension", EXTENSION, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("external", EXTERNAL, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("extract", EXTRACT, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("false", FALSE_P, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("family", FAMILY, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("fetch", FETCH, RESERVED_KEYWORD)
|
2013-07-16 20:15:36 -04:00
|
|
|
PG_KEYWORD("filter", FILTER, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("first", FIRST_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("float", FLOAT_P, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("following", FOLLOWING, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("for", FOR, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("force", FORCE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("foreign", FOREIGN, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("forward", FORWARD, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("freeze", FREEZE, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("from", FROM, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("full", FULL, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("function", FUNCTION, UNRESERVED_KEYWORD)
|
2009-10-12 16:39:42 -04:00
|
|
|
PG_KEYWORD("functions", FUNCTIONS, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("global", GLOBAL, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("grant", GRANT, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("granted", GRANTED, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("greatest", GREATEST, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("group", GROUP_P, RESERVED_KEYWORD)
|
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-15 21:40:59 -04:00
|
|
|
PG_KEYWORD("grouping", GROUPING, COL_NAME_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("handler", HANDLER, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("having", HAVING, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("header", HEADER_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("hold", HOLD, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("hour", HOUR_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("identity", IDENTITY_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("if", IF_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("ilike", ILIKE, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("immediate", IMMEDIATE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("immutable", IMMUTABLE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("implicit", IMPLICIT_P, UNRESERVED_KEYWORD)
|
2014-07-10 15:01:31 -04:00
|
|
|
PG_KEYWORD("import", IMPORT_P, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("in", IN_P, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("including", INCLUDING, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("increment", INCREMENT, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("index", INDEX, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("indexes", INDEXES, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("inherit", INHERIT, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("inherits", INHERITS, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("initially", INITIALLY, RESERVED_KEYWORD)
|
2009-09-22 19:43:43 -04:00
|
|
|
PG_KEYWORD("inline", INLINE_P, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("inner", INNER_P, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("inout", INOUT, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("input", INPUT_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("insensitive", INSENSITIVE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("insert", INSERT, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("instead", INSTEAD, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("int", INT_P, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("integer", INTEGER, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("intersect", INTERSECT, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("interval", INTERVAL, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("into", INTO, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("invoker", INVOKER, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("is", IS, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("isnull", ISNULL, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("isolation", ISOLATION, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("join", JOIN, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("key", KEY, UNRESERVED_KEYWORD)
|
2010-09-27 20:55:27 -04:00
|
|
|
PG_KEYWORD("label", LABEL, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("language", LANGUAGE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("large", LARGE_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("last", LAST_P, UNRESERVED_KEYWORD)
|
2012-08-07 19:02:54 -04:00
|
|
|
PG_KEYWORD("lateral", LATERAL_P, RESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("leading", LEADING, RESERVED_KEYWORD)
|
2012-02-13 22:20:27 -05:00
|
|
|
PG_KEYWORD("leakproof", LEAKPROOF, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("least", LEAST, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("left", LEFT, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("level", LEVEL, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("like", LIKE, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("limit", LIMIT, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("listen", LISTEN, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("load", LOAD, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("local", LOCAL, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("localtime", LOCALTIME, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("localtimestamp", LOCALTIMESTAMP, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("location", LOCATION, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("lock", LOCK_P, UNRESERVED_KEYWORD)
|
2014-10-07 16:23:34 -04:00
|
|
|
PG_KEYWORD("locked", LOCKED, UNRESERVED_KEYWORD)
|
2014-08-22 14:27:00 -04:00
|
|
|
PG_KEYWORD("logged", LOGGED, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("mapping", MAPPING, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("match", MATCH, UNRESERVED_KEYWORD)
|
2013-03-03 19:23:31 -05:00
|
|
|
PG_KEYWORD("materialized", MATERIALIZED, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("maxvalue", MAXVALUE, UNRESERVED_KEYWORD)
|
2016-03-23 22:01:35 -04:00
|
|
|
PG_KEYWORD("method", METHOD, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("minute", MINUTE_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("minvalue", MINVALUE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("mode", MODE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("month", MONTH_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("move", MOVE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("name", NAME_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("names", NAMES, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("national", NATIONAL, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("natural", NATURAL, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("nchar", NCHAR, COL_NAME_KEYWORD)
|
2016-11-04 11:49:50 -04:00
|
|
|
PG_KEYWORD("new", NEW, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("next", NEXT, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("no", NO, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("none", NONE, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("not", NOT, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("nothing", NOTHING, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("notify", NOTIFY, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("notnull", NOTNULL, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("nowait", NOWAIT, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("null", NULL_P, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("nullif", NULLIF, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("nulls", NULLS_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("numeric", NUMERIC, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("object", OBJECT_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("of", OF, UNRESERVED_KEYWORD)
|
2010-10-22 10:37:38 -04:00
|
|
|
PG_KEYWORD("off", OFF, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("offset", OFFSET, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("oids", OIDS, UNRESERVED_KEYWORD)
|
2016-11-04 11:49:50 -04:00
|
|
|
PG_KEYWORD("old", OLD, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("on", ON, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("only", ONLY, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("operator", OPERATOR, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("option", OPTION, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("options", OPTIONS, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("or", OR, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("order", ORDER, RESERVED_KEYWORD)
|
2013-07-29 11:38:01 -04:00
|
|
|
PG_KEYWORD("ordinality", ORDINALITY, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("out", OUT_P, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("outer", OUTER_P, TYPE_FUNC_NAME_KEYWORD)
|
2013-06-28 10:18:00 -04:00
|
|
|
PG_KEYWORD("over", OVER, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("overlaps", OVERLAPS, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("overlay", OVERLAY, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("owned", OWNED, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("owner", OWNER, UNRESERVED_KEYWORD)
|
2015-09-16 15:38:47 -04:00
|
|
|
PG_KEYWORD("parallel", PARALLEL, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("parser", PARSER, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("partial", PARTIAL, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("partition", PARTITION, UNRESERVED_KEYWORD)
|
2010-08-05 00:21:54 -04:00
|
|
|
PG_KEYWORD("passing", PASSING, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("password", PASSWORD, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("placing", PLACING, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("plans", PLANS, UNRESERVED_KEYWORD)
|
Row-Level Security Policies (RLS)
Building on the updatable security-barrier views work, add the
ability to define policies on tables to limit the set of rows
which are returned from a query and which are allowed to be added
to a table. Expressions defined by the policy for filtering are
added to the security barrier quals of the query, while expressions
defined to check records being added to a table are added to the
with-check options of the query.
New top-level commands are CREATE/ALTER/DROP POLICY and are
controlled by the table owner. Row Security is able to be enabled
and disabled by the owner on a per-table basis using
ALTER TABLE .. ENABLE/DISABLE ROW SECURITY.
Per discussion, ROW SECURITY is disabled on tables by default and
must be enabled for policies on the table to be used. If no
policies exist on a table with ROW SECURITY enabled, a default-deny
policy is used and no records will be visible.
By default, row security is applied at all times except for the
table owner and the superuser. A new GUC, row_security, is added
which can be set to ON, OFF, or FORCE. When set to FORCE, row
security will be applied even for the table owner and superusers.
When set to OFF, row security will be disabled when allowed and an
error will be thrown if the user does not have rights to bypass row
security.
Per discussion, pg_dump sets row_security = OFF by default to ensure
that exports and backups will have all data in the table or will
error if there are insufficient privileges to bypass row security.
A new option has been added to pg_dump, --enable-row-security, to
ask pg_dump to export with row security enabled.
A new role capability, BYPASSRLS, which can only be set by the
superuser, is added to allow other users to be able to bypass row
security using row_security = OFF.
Many thanks to the various individuals who have helped with the
design, particularly Robert Haas for his feedback.
Authors include Craig Ringer, KaiGai Kohei, Adam Brightwell, Dean
Rasheed, with additional changes and rework by me.
Reviewers have included all of the above, Greg Smith,
Jeff McCormick, and Robert Haas.
2014-09-19 11:18:35 -04:00
|
|
|
PG_KEYWORD("policy", POLICY, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("position", POSITION, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("preceding", PRECEDING, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("precision", PRECISION, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("prepare", PREPARE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("prepared", PREPARED, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("preserve", PRESERVE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("primary", PRIMARY, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("prior", PRIOR, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("privileges", PRIVILEGES, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("procedural", PROCEDURAL, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("procedure", PROCEDURE, UNRESERVED_KEYWORD)
|
Add support for piping COPY to/from an external program.
This includes backend "COPY TO/FROM PROGRAM '...'" syntax, and corresponding
psql \copy syntax. Like with reading/writing files, the backend version is
superuser-only, and in the psql version, the program is run in the client.
In the passing, the psql \copy STDIN/STDOUT syntax is subtly changed: if you
the stdin/stdout is quoted, it's now interpreted as a filename. For example,
"\copy foo from 'stdin'" now reads from a file called 'stdin', not from
standard input. Before this, there was no way to specify a filename called
stdin, stdout, pstdin or pstdout.
This creates a new function in pgport, wait_result_to_str(), which can
be used to convert the exit status of a process, as returned by wait(3),
to a human-readable string.
Etsuro Fujita, reviewed by Amit Kapila.
2013-02-27 11:17:21 -05:00
|
|
|
PG_KEYWORD("program", PROGRAM, UNRESERVED_KEYWORD)
|
2017-01-19 12:00:00 -05:00
|
|
|
PG_KEYWORD("publication", PUBLICATION, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("quote", QUOTE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("range", RANGE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("read", READ, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("real", REAL, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("reassign", REASSIGN, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("recheck", RECHECK, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("recursive", RECURSIVE, UNRESERVED_KEYWORD)
|
2010-08-05 00:21:54 -04:00
|
|
|
PG_KEYWORD("ref", REF, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("references", REFERENCES, RESERVED_KEYWORD)
|
2016-11-04 11:49:50 -04:00
|
|
|
PG_KEYWORD("referencing", REFERENCING, UNRESERVED_KEYWORD)
|
2013-03-03 19:23:31 -05:00
|
|
|
PG_KEYWORD("refresh", REFRESH, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("reindex", REINDEX, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("relative", RELATIVE_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("release", RELEASE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("rename", RENAME, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("repeatable", REPEATABLE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("replace", REPLACE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("replica", REPLICA, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("reset", RESET, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("restart", RESTART, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("restrict", RESTRICT, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("returning", RETURNING, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("returns", RETURNS, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("revoke", REVOKE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("right", RIGHT, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("role", ROLE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("rollback", ROLLBACK, UNRESERVED_KEYWORD)
|
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-15 21:40:59 -04:00
|
|
|
PG_KEYWORD("rollup", ROLLUP, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("row", ROW, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("rows", ROWS, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("rule", RULE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("savepoint", SAVEPOINT, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("schema", SCHEMA, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("scroll", SCROLL, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("search", SEARCH, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("second", SECOND_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("security", SECURITY, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("select", SELECT, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("sequence", SEQUENCE, UNRESERVED_KEYWORD)
|
2009-10-12 16:39:42 -04:00
|
|
|
PG_KEYWORD("sequences", SEQUENCES, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("serializable", SERIALIZABLE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("server", SERVER, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("session", SESSION, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("session_user", SESSION_USER, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("set", SET, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("setof", SETOF, COL_NAME_KEYWORD)
|
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-15 21:40:59 -04:00
|
|
|
PG_KEYWORD("sets", SETS, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("share", SHARE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("show", SHOW, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("similar", SIMILAR, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("simple", SIMPLE, UNRESERVED_KEYWORD)
|
2014-10-07 16:23:34 -04:00
|
|
|
PG_KEYWORD("skip", SKIP, UNRESERVED_KEYWORD)
|
2017-01-19 12:00:00 -05:00
|
|
|
PG_KEYWORD("slot", SLOT, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("smallint", SMALLINT, COL_NAME_KEYWORD)
|
2011-10-22 18:22:45 -04:00
|
|
|
PG_KEYWORD("snapshot", SNAPSHOT, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("some", SOME, RESERVED_KEYWORD)
|
2015-04-26 10:33:14 -04:00
|
|
|
PG_KEYWORD("sql", SQL_P, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("stable", STABLE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("standalone", STANDALONE_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("start", START, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("statement", STATEMENT, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("statistics", STATISTICS, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("stdin", STDIN, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("stdout", STDOUT, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("storage", STORAGE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("strict", STRICT_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("strip", STRIP_P, UNRESERVED_KEYWORD)
|
2017-01-19 12:00:00 -05:00
|
|
|
PG_KEYWORD("subscription", SUBSCRIPTION, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("substring", SUBSTRING, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("symmetric", SYMMETRIC, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("sysid", SYSID, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("system", SYSTEM_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("table", TABLE, RESERVED_KEYWORD)
|
2009-10-12 16:39:42 -04:00
|
|
|
PG_KEYWORD("tables", TABLES, UNRESERVED_KEYWORD)
|
2015-05-15 14:37:10 -04:00
|
|
|
PG_KEYWORD("tablesample", TABLESAMPLE, TYPE_FUNC_NAME_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("tablespace", TABLESPACE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("temp", TEMP, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("template", TEMPLATE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("temporary", TEMPORARY, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("text", TEXT_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("then", THEN, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("time", TIME, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("timestamp", TIMESTAMP, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("to", TO, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("trailing", TRAILING, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("transaction", TRANSACTION, UNRESERVED_KEYWORD)
|
2015-04-26 10:33:14 -04:00
|
|
|
PG_KEYWORD("transform", TRANSFORM, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("treat", TREAT, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("trigger", TRIGGER, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("trim", TRIM, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("true", TRUE_P, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("truncate", TRUNCATE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("trusted", TRUSTED, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("type", TYPE_P, UNRESERVED_KEYWORD)
|
2011-12-19 17:05:19 -05:00
|
|
|
PG_KEYWORD("types", TYPES_P, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("unbounded", UNBOUNDED, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("uncommitted", UNCOMMITTED, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("unencrypted", UNENCRYPTED, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("union", UNION, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("unique", UNIQUE, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("unknown", UNKNOWN, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("unlisten", UNLISTEN, UNRESERVED_KEYWORD)
|
2010-12-29 06:48:53 -05:00
|
|
|
PG_KEYWORD("unlogged", UNLOGGED, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("until", UNTIL, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("update", UPDATE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("user", USER, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("using", USING, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("vacuum", VACUUM, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("valid", VALID, UNRESERVED_KEYWORD)
|
2011-02-08 07:23:20 -05:00
|
|
|
PG_KEYWORD("validate", VALIDATE, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("validator", VALIDATOR, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("value", VALUE_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("values", VALUES, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("varchar", VARCHAR, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("variadic", VARIADIC, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("varying", VARYING, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("verbose", VERBOSE, TYPE_FUNC_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("version", VERSION_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("view", VIEW, UNRESERVED_KEYWORD)
|
2014-01-18 18:56:40 -05:00
|
|
|
PG_KEYWORD("views", VIEWS, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("volatile", VOLATILE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("when", WHEN, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("where", WHERE, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("whitespace", WHITESPACE_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("window", WINDOW, RESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("with", WITH, RESERVED_KEYWORD)
|
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
|
|
|
PG_KEYWORD("within", WITHIN, UNRESERVED_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("without", WITHOUT, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("work", WORK, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("wrapper", WRAPPER, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("write", WRITE, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("xml", XML_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("xmlattributes", XMLATTRIBUTES, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("xmlconcat", XMLCONCAT, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("xmlelement", XMLELEMENT, COL_NAME_KEYWORD)
|
2010-08-05 00:21:54 -04:00
|
|
|
PG_KEYWORD("xmlexists", XMLEXISTS, COL_NAME_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("xmlforest", XMLFOREST, COL_NAME_KEYWORD)
|
2017-03-08 10:39:37 -05:00
|
|
|
PG_KEYWORD("xmlnamespaces", XMLNAMESPACES, COL_NAME_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("xmlparse", XMLPARSE, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("xmlpi", XMLPI, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("xmlroot", XMLROOT, COL_NAME_KEYWORD)
|
|
|
|
|
PG_KEYWORD("xmlserialize", XMLSERIALIZE, COL_NAME_KEYWORD)
|
2017-03-08 10:39:37 -05:00
|
|
|
PG_KEYWORD("xmltable", XMLTABLE, COL_NAME_KEYWORD)
|
2009-03-06 19:13:58 -05:00
|
|
|
PG_KEYWORD("year", YEAR_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("yes", YES_P, UNRESERVED_KEYWORD)
|
|
|
|
|
PG_KEYWORD("zone", ZONE, UNRESERVED_KEYWORD)
|