diff options
author | Michael Paquier <michael@paquier.xyz> | 2019-02-15 17:12:24 +0900 |
---|---|---|
committer | Michael Paquier <michael@paquier.xyz> | 2019-02-15 17:12:24 +0900 |
commit | 331a613e9d363febfee8508e8de545fd84624758 (patch) | |
tree | 72b6f96f3f22a89108ac4c23ff102da192a67941 /src/backend | |
parent | 6c0fb941892519ad6b8873e99c4001404fb9a128 (diff) |
Fix support for CREATE TABLE IF NOT EXISTS AS EXECUTE
The grammar IF NOT EXISTS for CTAS is supported since 9.5 and documented
as such, however the case of using EXECUTE as query has never been
covered as EXECUTE CTAS statements and normal CTAS statements are parsed
separately.
Author: Andreas Karlsson
Discussion: https://postgr.es/m/2ddcc188-e37c-a0be-32bf-a56b07c3559e@proxel.se
Backpatch-through: 9.5
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/parser/gram.y | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index ef6bbe35d7f..7bb2b0b2a52 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -10700,11 +10700,29 @@ ExecuteStmt: EXECUTE name execute_param_clause ctas->into = $4; ctas->relkind = OBJECT_TABLE; ctas->is_select_into = false; + ctas->if_not_exists = false; /* cram additional flags into the IntoClause */ $4->rel->relpersistence = $2; $4->skipData = !($9); $$ = (Node *) ctas; } + | CREATE OptTemp TABLE IF_P NOT EXISTS create_as_target AS + EXECUTE name execute_param_clause opt_with_data + { + CreateTableAsStmt *ctas = makeNode(CreateTableAsStmt); + ExecuteStmt *n = makeNode(ExecuteStmt); + n->name = $10; + n->params = $11; + ctas->query = (Node *) n; + ctas->into = $7; + ctas->relkind = OBJECT_TABLE; + ctas->is_select_into = false; + ctas->if_not_exists = true; + /* cram additional flags into the IntoClause */ + $7->rel->relpersistence = $2; + $7->skipData = !($12); + $$ = (Node *) ctas; + } ; execute_param_clause: '(' expr_list ')' { $$ = $2; } |