Re: Boolean partitions syntax

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Boolean partitions syntax
Дата
Msg-id 24308.1524328093@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Boolean partitions syntax  (Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>)
Список pgsql-hackers
Amit Langote <Langote_Amit_f8@lab.ntt.co.jp> writes:
> [ v8-0001-Allow-generalized-expression-syntax-for-partition.patch ]

I find what you did to a_expr here to be pretty horrid.

I think what you should do is lose the partbound_datum and
PartitionRangeDatum productions altogether, replacing those with just
a_expr, as in the attached grammar-only patch.  This would result in
needing to identify MINVALUE and MAXVALUE during parse analysis, since
the grammar would just treat them as ColId expressions.  But since we're
not intending to ever allow any actual column references in partition
expressions, I don't see any harm in allowing parse analysis to treat
ColumnRefs containing those names as meaning the special items.
This is a little bit grotty, in that both MINVALUE and "minvalue" would
be recognized as the keyword, but it's sure a lot less messy than what's
there now.  And IIRC there are some other places where we're a bit
squishy about the difference between identifiers and keywords, too.

            regards, tom lane

diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index e548476..8b0680a 100644
*** a/src/backend/parser/gram.y
--- b/src/backend/parser/gram.y
*************** static Node *makeRecursiveViewSelect(cha
*** 581,588 ****
  %type <partelem>    part_elem
  %type <list>        part_params
  %type <partboundspec> PartitionBoundSpec
! %type <node>        partbound_datum PartitionRangeDatum
! %type <list>        hash_partbound partbound_datum_list range_datum_list
  %type <defelt>        hash_partbound_elem

  /*
--- 581,587 ----
  %type <partelem>    part_elem
  %type <list>        part_params
  %type <partboundspec> PartitionBoundSpec
! %type <list>        hash_partbound
  %type <defelt>        hash_partbound_elem

  /*
*************** PartitionBoundSpec:
*** 2739,2745 ****
                  }

              /* a LIST partition */
!             | FOR VALUES IN_P '(' partbound_datum_list ')'
                  {
                      PartitionBoundSpec *n = makeNode(PartitionBoundSpec);

--- 2738,2744 ----
                  }

              /* a LIST partition */
!             | FOR VALUES IN_P '(' expr_list ')'
                  {
                      PartitionBoundSpec *n = makeNode(PartitionBoundSpec);

*************** PartitionBoundSpec:
*** 2752,2758 ****
                  }

              /* a RANGE partition */
!             | FOR VALUES FROM '(' range_datum_list ')' TO '(' range_datum_list ')'
                  {
                      PartitionBoundSpec *n = makeNode(PartitionBoundSpec);

--- 2751,2757 ----
                  }

              /* a RANGE partition */
!             | FOR VALUES FROM '(' expr_list ')' TO '(' expr_list ')'
                  {
                      PartitionBoundSpec *n = makeNode(PartitionBoundSpec);

*************** hash_partbound:
*** 2795,2851 ****
              }
          ;

- partbound_datum:
-             Sconst            { $$ = makeStringConst($1, @1); }
-             | NumericOnly    { $$ = makeAConst($1, @1); }
-             | NULL_P        { $$ = makeNullAConst(@1); }
-         ;
-
- partbound_datum_list:
-             partbound_datum                        { $$ = list_make1($1); }
-             | partbound_datum_list ',' partbound_datum
-                                                 { $$ = lappend($1, $3); }
-         ;
-
- range_datum_list:
-             PartitionRangeDatum                    { $$ = list_make1($1); }
-             | range_datum_list ',' PartitionRangeDatum
-                                                 { $$ = lappend($1, $3); }
-         ;
-
- PartitionRangeDatum:
-             MINVALUE
-                 {
-                     PartitionRangeDatum *n = makeNode(PartitionRangeDatum);
-
-                     n->kind = PARTITION_RANGE_DATUM_MINVALUE;
-                     n->value = NULL;
-                     n->location = @1;
-
-                     $$ = (Node *) n;
-                 }
-             | MAXVALUE
-                 {
-                     PartitionRangeDatum *n = makeNode(PartitionRangeDatum);
-
-                     n->kind = PARTITION_RANGE_DATUM_MAXVALUE;
-                     n->value = NULL;
-                     n->location = @1;
-
-                     $$ = (Node *) n;
-                 }
-             | partbound_datum
-                 {
-                     PartitionRangeDatum *n = makeNode(PartitionRangeDatum);
-
-                     n->kind = PARTITION_RANGE_DATUM_VALUE;
-                     n->value = $1;
-                     n->location = @1;
-
-                     $$ = (Node *) n;
-                 }
-         ;
-
  /*****************************************************************************
   *
   *    ALTER TYPE
--- 2794,2799 ----

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Andrew Dunstan
Дата:
Сообщение: Re: Searching for: Fast windows buildfarm animal
Следующее
От: Tom Lane
Дата:
Сообщение: Re: Boolean partitions syntax