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

Commit854dd8c

Browse files
committed
Add parenthesized options syntax for ANALYZE.
This is analogous to the syntax allowed for VACUUM. This allows us toavoid making new options reserved keywords and makes it easier toallow arbitrary argument order. Oh, and it's consistent with the othercommands, too.Author: Nathan BossartReviewed-By: Michael Paquier, Masahiko SawadaDiscussion:https://postgr.es/m/D3FC73E2-9B1A-4DB4-8180-55F57D116B4E@amazon.com
1 parentb2a177b commit854dd8c

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

‎doc/src/sgml/ref/analyze.sgml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,14 @@ PostgreSQL documentation
2121

2222
<refsynopsisdiv>
2323
<synopsis>
24+
ANALYZE [ ( <replaceable class="parameter">option</replaceable> [, ...] ) ] [ <replaceable class="parameter">table_and_columns</replaceable> [, ...] ]
2425
ANALYZE [ VERBOSE ] [ <replaceable class="parameter">table_and_columns</replaceable> [, ...] ]
2526

26-
<phrase>where <replaceable class="parameter">table_and_columns</replaceable> is:</phrase>
27+
<phrase>where <replaceable class="parameter">option</replaceable> can be one of:</phrase>
28+
29+
VERBOSE
30+
31+
<phrase>and <replaceable class="parameter">table_and_columns</replaceable> is:</phrase>
2732

2833
<replaceable class="parameter">table_name</replaceable> [ ( <replaceable class="parameter">column_name</replaceable> [, ...] ) ]
2934
</synopsis>
@@ -49,6 +54,13 @@ ANALYZE [ VERBOSE ] [ <replaceable class="parameter">table_and_columns</replacea
4954
It is further possible to give a list of column names for a table,
5055
in which case only the statistics for those columns are collected.
5156
</para>
57+
58+
<para>
59+
When the option list is surrounded by parentheses, the options can be
60+
written in any order. The parenthesized syntax was added in
61+
<productname>PostgreSQL</productname> 11; the unparenthesized syntax
62+
is deprecated.
63+
</para>
5264
</refsect1>
5365

5466
<refsect1>

‎src/backend/parser/gram.y

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
306306

307307
%type<ival>opt_locklock_typecast_context
308308
%type<ival>vacuum_option_listvacuum_option_elem
309+
analyze_option_listanalyze_option_elem
309310
%type<boolean>opt_or_replace
310311
opt_grant_grant_optionopt_grant_admin_option
311312
opt_nowaitopt_if_existsopt_with_data
@@ -10551,6 +10552,22 @@ AnalyzeStmt: analyze_keyword opt_verbose opt_vacuum_relation_list
1055110552
n->rels =$3;
1055210553
$$ = (Node *)n;
1055310554
}
10555+
|analyze_keyword'('analyze_option_list')'opt_vacuum_relation_list
10556+
{
10557+
VacuumStmt *n = makeNode(VacuumStmt);
10558+
n->options = VACOPT_ANALYZE |$3;
10559+
n->rels =$5;
10560+
$$ = (Node *) n;
10561+
}
10562+
;
10563+
10564+
analyze_option_list:
10565+
analyze_option_elem{$$ =$1; }
10566+
|analyze_option_list','analyze_option_elem{$$ =$1 |$3; }
10567+
;
10568+
10569+
analyze_option_elem:
10570+
VERBOSE{$$ = VACOPT_VERBOSE; }
1055410571
;
1055510572

1055610573
analyze_keyword:

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,13 @@ ANALYZE vactst, does_not_exist, vacparted;
112112
ERROR: relation "does_not_exist" does not exist
113113
ANALYZE vactst (i), vacparted (does_not_exist);
114114
ERROR: column "does_not_exist" of relation "vacparted" does not exist
115+
-- parenthesized syntax for ANALYZE
116+
ANALYZE (VERBOSE) does_not_exist;
117+
ERROR: relation "does_not_exist" does not exist
118+
ANALYZE (nonexistant-arg) does_not_exist;
119+
ERROR: syntax error at or near "nonexistant"
120+
LINE 1: ANALYZE (nonexistant-arg) does_not_exist;
121+
^
115122
DROP TABLE vaccluster;
116123
DROP TABLE vactst;
117124
DROP TABLE vacparted;

‎src/test/regress/sql/vacuum.sql

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ ANALYZE vacparted (b), vactst;
8989
ANALYZE vactst, does_not_exist, vacparted;
9090
ANALYZE vactst (i), vacparted (does_not_exist);
9191

92+
-- parenthesized syntax for ANALYZE
93+
ANALYZE (VERBOSE) does_not_exist;
94+
ANALYZE (nonexistant-arg) does_not_exist;
95+
9296
DROPTABLE vaccluster;
9397
DROPTABLE vactst;
9498
DROPTABLE vacparted;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp