Обсуждение: pgsql: Allow generalized expression syntax for partition bounds

Поиск
Список
Период
Сортировка

pgsql: Allow generalized expression syntax for partition bounds

От
Peter Eisentraut
Дата:
Allow generalized expression syntax for partition bounds

Previously, only literals were allowed.  This change allows general
expressions, including functions calls, which are evaluated at the
time the DDL command is executed.

Besides offering some more functionality, it simplifies the parser
structures and removes some inconsistencies in how the literals were
handled.

Author: Kyotaro Horiguchi, Tom Lane, Amit Langote
Reviewed-by: Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
Discussion: https://www.postgresql.org/message-id/flat/9f88b5e0-6da2-5227-20d0-0d7012beaa1c@lab.ntt.co.jp/

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7c079d7417a8f2d4bf5144732e2f85117db9214f

Modified Files
--------------
doc/src/sgml/ref/alter_table.sgml          |   6 +-
doc/src/sgml/ref/create_table.sgml         |  19 +--
src/backend/commands/tablecmds.c           |   9 ++
src/backend/optimizer/util/clauses.c       |   4 +-
src/backend/parser/gram.y                  |  60 +-------
src/backend/parser/parse_agg.c             |  10 ++
src/backend/parser/parse_expr.c            |   5 +
src/backend/parser/parse_func.c            |   3 +
src/backend/parser/parse_utilcmd.c         | 213 +++++++++++++++++++----------
src/include/optimizer/clauses.h            |   3 +
src/include/parser/parse_node.h            |   1 +
src/include/utils/partcache.h              |   6 +
src/test/regress/expected/create_table.out |  91 +++++++++---
src/test/regress/sql/create_table.sql      |  51 ++++++-
14 files changed, 314 insertions(+), 167 deletions(-)


Re: pgsql: Allow generalized expression syntax for partition bounds

От
Michael Paquier
Дата:
On Fri, Jan 25, 2019 at 10:37:22AM +0000, Peter Eisentraut wrote:
> Allow generalized expression syntax for partition bounds
>
> Previously, only literals were allowed.  This change allows general
> expressions, including functions calls, which are evaluated at the
> time the DDL command is executed.
>
> Besides offering some more functionality, it simplifies the parser
> structures and removes some inconsistencies in how the literals were
> handled.

fulmar, magpie and treepie are unhappy after this commit, and all of
them have the same complaint related to the order consistency of
partitions showing up in psql:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=magpie&dt=2019-01-25%2011%3A04%3A07

    Partition key: LIST (a)
-Partitions: part_1 FOR VALUES IN (1),
+Partitions: part_null FOR VALUES IN (NULL),
+            part_1 FOR VALUES IN (1),
             part_2 FOR VALUES IN (2),
-            part_3 FOR VALUES IN (3),
-            part_null FOR VALUES IN (NULL)
+            part_3 FOR VALUES IN (3)
--
Michael

Вложения

Re: pgsql: Allow generalized expression syntax for partition bounds

От
Amit Langote
Дата:
On Sat, Jan 26, 2019 at 11:05 Michael Paquier <michael@paquier.xyz> wrote:
On Fri, Jan 25, 2019 at 10:37:22AM +0000, Peter Eisentraut wrote:
> Allow generalized expression syntax for partition bounds
>
> Previously, only literals were allowed.  This change allows general
> expressions, including functions calls, which are evaluated at the
> time the DDL command is executed.
>
> Besides offering some more functionality, it simplifies the parser
> structures and removes some inconsistencies in how the literals were
> handled.

fulmar, magpie and treepie are unhappy after this commit, and all of
them have the same complaint related to the order consistency of
partitions showing up in psql:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=magpie&dt=2019-01-25%2011%3A04%3A07

    Partition key: LIST (a)
-Partitions: part_1 FOR VALUES IN (1),
+Partitions: part_null FOR VALUES IN (NULL),
+            part_1 FOR VALUES IN (1),
             part_2 FOR VALUES IN (2),
-            part_3 FOR VALUES IN (3),
-            part_null FOR VALUES IN (NULL)
+            part_3 FOR VALUES IN (3)

Have sent the patch on the -hackers thread for this patch after Tom pointed out one of these failures.

Thanks,
Amit

Re: pgsql: Allow generalized expression syntax for partition bounds

От
Michael Paquier
Дата:
On Sat, Jan 26, 2019 at 11:53:17AM +0900, Amit Langote wrote:
> Have sent the patch on the -hackers thread for this patch after Tom
> pointed out one of these failures.

And I have commented on the patch.  I noticed the thread on -hackers
after going through the commits.
--
Michael

Вложения