mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
transformCreateSchemaStmtElements has always believed that it is supposed to re-order the subcommands of CREATE SCHEMA into a safe execution order. However, it is nowhere near being capable of doing that correctly. Nor is there reason to think that it ever will be, or that that is a well-defined requirement. (The SQL standard does say that it should be possible to do foreign-key forward references within CREATE SCHEMA, but it's not clear that the text requires anything more than that.) Moreover, the problem will get worse as we add more subcommand types. Let's just drop the whole idea and execute the commands in the order given, which seems like a much less astonishment-prone definition anyway. The foreign-key issue will be handled in a follow-up patch. This will result in a release-note-worthy incompatibility, which is that forward references like CREATE SCHEMA myschema CREATE VIEW myview AS SELECT * FROM mytable CREATE TABLE mytable (...); used to work and no longer will. Considering how many closely related variants never worked, this isn't much of a loss. Along the way, pass down a ParseState so that we can provide an error cursor for "wrong schema name" and related errors, and fix transformCreateSchemaStmtElements so that it doesn't scribble on the parsetree passed to it. Author: Tom Lane <tgl@sss.pgh.pa.us> Reviewed-by: Kirill Reshke <reshkekirill@gmail.com> Reviewed-by: Jian He <jian.universality@gmail.com> Discussion: https://postgr.es/m/1075425.1732993688@sss.pgh.pa.us
46 lines
1.7 KiB
C
46 lines
1.7 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* parse_utilcmd.h
|
|
* parse analysis for utility commands
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/parser/parse_utilcmd.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef PARSE_UTILCMD_H
|
|
#define PARSE_UTILCMD_H
|
|
|
|
#include "parser/parse_node.h"
|
|
|
|
typedef struct AttrMap AttrMap; /* avoid including attmap.h here */
|
|
|
|
|
|
extern List *transformCreateStmt(CreateStmt *stmt, const char *queryString);
|
|
extern AlterTableStmt *transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
|
|
const char *queryString,
|
|
List **beforeStmts,
|
|
List **afterStmts);
|
|
extern IndexStmt *transformIndexStmt(Oid relid, IndexStmt *stmt,
|
|
const char *queryString);
|
|
extern CreateStatsStmt *transformStatsStmt(Oid relid, CreateStatsStmt *stmt,
|
|
const char *queryString);
|
|
extern void transformRuleStmt(RuleStmt *stmt, const char *queryString,
|
|
List **actions, Node **whereClause);
|
|
extern List *transformCreateSchemaStmtElements(ParseState *pstate,
|
|
List *schemaElts,
|
|
const char *schemaName);
|
|
extern PartitionBoundSpec *transformPartitionBound(ParseState *pstate, Relation parent,
|
|
PartitionBoundSpec *spec);
|
|
extern List *expandTableLikeClause(RangeVar *heapRel,
|
|
TableLikeClause *table_like_clause);
|
|
extern IndexStmt *generateClonedIndexStmt(RangeVar *heapRel,
|
|
Relation source_idx,
|
|
const AttrMap *attmap,
|
|
Oid *constraintOid);
|
|
|
|
#endif /* PARSE_UTILCMD_H */
|