
IF NOT EXISTS was ignored when specified in an EXPLAIN query for CREATE MATERIALIZED VIEW or CREATE TABLE AS. Hence, if this clause was specified, the caller would get a failure if the relation already exists instead of a success with a NOTICE message. This commit makes the behavior of IF NOT EXISTS in EXPLAIN consistent with the non-EXPLAIN'd DDL queries, preventing a failure with IF NOT EXISTS if the relation to-be-created already exists. The skip is done before the SELECT query used for the relation is planned or executed, and a "dummy" plan is generated instead depending on the format used by EXPLAIN. Author: Bharath Rupireddy Reviewed-by: Zhijie Hou, Michael Paquier Discussion: https://postgr.es/m/CALj2ACVa3oJ9O_wcGd+FtHWZds04dEKcakxphGz5POVgD4wC7Q@mail.gmail.com
35 lines
989 B
C
35 lines
989 B
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* createas.h
|
|
* prototypes for createas.c.
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/commands/createas.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef CREATEAS_H
|
|
#define CREATEAS_H
|
|
|
|
#include "catalog/objectaddress.h"
|
|
#include "nodes/params.h"
|
|
#include "parser/parse_node.h"
|
|
#include "tcop/dest.h"
|
|
#include "utils/queryenvironment.h"
|
|
|
|
|
|
extern ObjectAddress ExecCreateTableAs(ParseState *pstate, CreateTableAsStmt *stmt,
|
|
ParamListInfo params, QueryEnvironment *queryEnv,
|
|
QueryCompletion *qc);
|
|
|
|
extern int GetIntoRelEFlags(IntoClause *intoClause);
|
|
|
|
extern DestReceiver *CreateIntoRelDestReceiver(IntoClause *intoClause);
|
|
|
|
extern bool CreateTableAsRelExists(CreateTableAsStmt *ctas);
|
|
|
|
#endif /* CREATEAS_H */
|