Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit83011ce

Browse files
committed
Rework grammar for REINDEX
The part of grammar have grown needlessly duplicative and more complexthat necessary. Rewrite.Reviewed-by: Michaël Paquier <michael@paquier.xyz>Discussion:https://postgr.es/m/20220721174212.cmitjpuimx6ssyyj@alvherre.pgsql
1 parent0b292be commit83011ce

File tree

4 files changed

+38
-58
lines changed

4 files changed

+38
-58
lines changed

‎doc/src/sgml/ref/reindex.sgml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ PostgreSQL documentation
2222
<refsynopsisdiv>
2323
<synopsis>
2424
REINDEX [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] { INDEX | TABLE | SCHEMA } [ CONCURRENTLY ] <replaceable class="parameter">name</replaceable>
25-
REINDEX [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] { DATABASE | SYSTEM } [ CONCURRENTLY ] [ <replaceable class="parameter">name</replaceable> ]
25+
REINDEX [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] DATABASE [ CONCURRENTLY ] [ <replaceable class="parameter">name</replaceable> ]
26+
REINDEX [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] SYSTEM [ <replaceable class="parameter">name</replaceable> ]
2627

2728
<phrase>where <replaceable class="parameter">option</replaceable> can be one of:</phrase>
2829

‎src/backend/parser/gram.y

Lines changed: 28 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
336336

337337
%type<str>opt_single_name
338338
%type<list>opt_qualified_name
339-
%type<boolean>opt_concurrently
339+
%type<boolean>opt_concurrently
340340
%type<dbehavior>opt_drop_behavior
341341

342342
%type<node>alter_column_defaultopclass_itemopclass_dropalter_using
@@ -564,7 +564,8 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
564564
%type<defelt>generic_option_elemalter_generic_option_elem
565565
%type<list>generic_option_listalter_generic_option_list
566566

567-
%type<ival>reindex_target_typereindex_target_multitablereindex_name_optional
567+
%type<ival>reindex_target_type
568+
%type<list>opt_reindex_option_list
568569

569570
%type<node>copy_generic_opt_argcopy_generic_opt_arg_list_item
570571
%type<defelt>copy_generic_opt_elem
@@ -9091,94 +9092,64 @@ DropTransformStmt: DROP TRANSFORM opt_if_exists FOR Typename LANGUAGE name opt_d
90919092
*
90929093
*QUERY:
90939094
*
9094-
*REINDEX [ (options) ] type [CONCURRENTLY] <name>
9095+
*REINDEX [ (options) ] {TABLE | INDEX | SCHEMA} [CONCURRENTLY] <name>
9096+
*REINDEX [ (options) ] DATABASE [CONCURRENTLY] [<name>]
9097+
*REINDEX [ (options) ] SYSTEM [<name>]
90959098
*****************************************************************************/
90969099

90979100
ReindexStmt:
9098-
REINDEXreindex_target_typeopt_concurrentlyqualified_name
9101+
REINDEXopt_reindex_option_listreindex_target_typeopt_concurrentlyqualified_name
90999102
{
91009103
ReindexStmt *n = makeNode(ReindexStmt);
91019104

9102-
n->kind =$2;
9103-
n->relation =$4;
9105+
n->kind =$3;
9106+
n->relation =$5;
91049107
n->name =NULL;
9105-
n->params =NIL;
9106-
if ($3)
9108+
n->params =$2;
9109+
if ($4)
91079110
n->params = lappend(n->params,
9108-
makeDefElem("concurrently",NULL, @3));
9111+
makeDefElem("concurrently",NULL, @4));
91099112
$$ = (Node *) n;
91109113
}
9111-
|REINDEXreindex_target_multitableopt_concurrentlyname
9114+
|REINDEXopt_reindex_option_listSCHEMAopt_concurrentlyname
91129115
{
91139116
ReindexStmt *n = makeNode(ReindexStmt);
91149117

9115-
n->kind =$2;
9116-
n->name =$4;
9118+
n->kind =REINDEX_OBJECT_SCHEMA;
9119+
n->name =$5;
91179120
n->relation =NULL;
9118-
n->params =NIL;
9119-
if ($3)
9121+
n->params =$2;
9122+
if ($4)
91209123
n->params = lappend(n->params,
9121-
makeDefElem("concurrently",NULL, @3));
9124+
makeDefElem("concurrently",NULL, @4));
91229125
$$ = (Node *) n;
91239126
}
9124-
|REINDEXreindex_name_optional
9125-
{
9126-
ReindexStmt *n = makeNode(ReindexStmt);
9127-
n->kind =$2;
9128-
n->name =NULL;
9129-
n->relation =NULL;
9130-
n->params = NIL;
9131-
$$ = (Node *)n;
9132-
}
9133-
|REINDEX'('utility_option_list')'reindex_name_optional
9127+
|REINDEXopt_reindex_option_listDATABASEopt_concurrentlyopt_single_name
91349128
{
91359129
ReindexStmt *n = makeNode(ReindexStmt);
9136-
n->kind =$5;
9130+
n->kind =REINDEX_OBJECT_DATABASE;
91379131
n->name =NULL;
91389132
n->relation =NULL;
9139-
n->params =$3;
9140-
$$ = (Node *)n;
9141-
}
9142-
|REINDEX'('utility_option_list')'reindex_target_typeopt_concurrentlyqualified_name
9143-
{
9144-
ReindexStmt *n = makeNode(ReindexStmt);
9145-
9146-
n->kind =$5;
9147-
n->relation =$7;
9148-
n->name =NULL;
9149-
n->params =$3;
9150-
if ($6)
9151-
n->params = lappend(n->params,
9152-
makeDefElem("concurrently",NULL, @6));
9133+
n->params =$2;
91539134
$$ = (Node *) n;
91549135
}
9155-
|REINDEX'('utility_option_list')'reindex_target_multitableopt_concurrentlyname
9136+
|REINDEXopt_reindex_option_listSYSTEM_Popt_single_name
91569137
{
91579138
ReindexStmt *n = makeNode(ReindexStmt);
9158-
9159-
n->kind =$5;
9160-
n->name =$7;
9139+
n->kind = REINDEX_OBJECT_SYSTEM;
9140+
n->name =NULL;
91619141
n->relation =NULL;
9162-
n->params =$3;
9163-
if ($6)
9164-
n->params = lappend(n->params,
9165-
makeDefElem("concurrently",NULL, @6));
9142+
n->params =$2;
91669143
$$ = (Node *) n;
91679144
}
91689145
;
91699146
reindex_target_type:
91709147
INDEX{$$ = REINDEX_OBJECT_INDEX; }
91719148
|TABLE{$$ = REINDEX_OBJECT_TABLE; }
91729149
;
9173-
reindex_target_multitable:
9174-
SCHEMA{$$ = REINDEX_OBJECT_SCHEMA; }
9175-
|SYSTEM_P{$$ = REINDEX_OBJECT_SYSTEM; }
9176-
|DATABASE{$$ = REINDEX_OBJECT_DATABASE; }
9177-
;
9178-
/* For these options the name is optional*/
9179-
reindex_name_optional:
9180-
SYSTEM_P{$$ = REINDEX_OBJECT_SYSTEM; }
9181-
|DATABASE{$$ = REINDEX_OBJECT_DATABASE; }
9150+
opt_reindex_option_list:
9151+
'('utility_option_list')'{$$ =$2; }
9152+
|/* EMPTY*/{$$ =NULL; }
91829153
;
91839154

91849155
/*****************************************************************************

‎src/test/regress/expected/create_index.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2521,6 +2521,12 @@ ERROR: cannot reindex system catalogs concurrently
25212521
REINDEX INDEX CONCURRENTLY pg_toast.pg_toast_1260_index; -- no catalog toast index
25222522
ERROR: cannot reindex system catalogs concurrently
25232523
REINDEX SYSTEM CONCURRENTLY postgres; -- not allowed for SYSTEM
2524+
ERROR: syntax error at or near "CONCURRENTLY"
2525+
LINE 1: REINDEX SYSTEM CONCURRENTLY postgres;
2526+
^
2527+
REINDEX (CONCURRENTLY) SYSTEM postgres; -- ditto
2528+
ERROR: cannot reindex system catalogs concurrently
2529+
REINDEX (CONCURRENTLY) SYSTEM; -- ditto
25242530
ERROR: cannot reindex system catalogs concurrently
25252531
-- Warns about catalog relations
25262532
REINDEX SCHEMA CONCURRENTLY pg_catalog;

‎src/test/regress/sql/create_index.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,8 @@ REINDEX INDEX CONCURRENTLY pg_class_oid_index; -- no catalog index
10721072
REINDEX TABLE CONCURRENTLYpg_toast.pg_toast_1260;-- no catalog toast table
10731073
REINDEX INDEX CONCURRENTLYpg_toast.pg_toast_1260_index;-- no catalog toast index
10741074
REINDEX SYSTEM CONCURRENTLY postgres;-- not allowed for SYSTEM
1075+
REINDEX (CONCURRENTLY) SYSTEM postgres;-- ditto
1076+
REINDEX (CONCURRENTLY) SYSTEM;-- ditto
10751077
-- Warns about catalog relations
10761078
REINDEX SCHEMA CONCURRENTLY pg_catalog;
10771079

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp