diff options
author | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2017-06-22 13:17:08 -0400 |
---|---|---|
committer | Alvaro Herrera <alvherre@alvh.no-ip.org> | 2017-06-22 13:17:08 -0400 |
commit | 5dfd564b1001f20c9def6ae938a92f39ddbd9984 (patch) | |
tree | beb94359ff42b479a82f11cea42413cad446df1e /src/backend/parser | |
parent | 2c77903b2bfba01f159138ba34b95d4b470395a8 (diff) |
Fix IF NOT EXISTS in CREATE STATISTICS
I misplaced the IF NOT EXISTS clause in commit 7b504eb282, before the
word STATISTICS. Put it where it belongs.
Patch written independently by Amit Langote and myself. I adopted his
submitted test case with a slight edit also.
Reported-by: Bruno Wolff III
Discussion: https://postgr.es/m/20170621004237.GB8337@wolff.to
Diffstat (limited to 'src/backend/parser')
-rw-r--r-- | src/backend/parser/gram.y | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index ada95e5bc37..0f3998ff893 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -3834,7 +3834,7 @@ ExistingIndex: USING INDEX index_name { $$ = $3; } /***************************************************************************** * * QUERY : - * CREATE STATISTICS stats_name [(stat types)] + * CREATE STATISTICS [IF NOT EXISTS] stats_name [(stat types)] * ON expression-list FROM from_list * * Note: the expectation here is that the clauses after ON are a subset of @@ -3846,15 +3846,26 @@ ExistingIndex: USING INDEX index_name { $$ = $3; } *****************************************************************************/ CreateStatsStmt: - CREATE opt_if_not_exists STATISTICS any_name + CREATE STATISTICS any_name opt_name_list ON expr_list FROM from_list { CreateStatsStmt *n = makeNode(CreateStatsStmt); - n->defnames = $4; - n->stat_types = $5; - n->exprs = $7; - n->relations = $9; - n->if_not_exists = $2; + n->defnames = $3; + n->stat_types = $4; + n->exprs = $6; + n->relations = $8; + n->if_not_exists = false; + $$ = (Node *)n; + } + | CREATE STATISTICS IF_P NOT EXISTS any_name + opt_name_list ON expr_list FROM from_list + { + CreateStatsStmt *n = makeNode(CreateStatsStmt); + n->defnames = $6; + n->stat_types = $7; + n->exprs = $9; + n->relations = $11; + n->if_not_exists = true; $$ = (Node *)n; } ; |