mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
Further consolidation of DROP statement handling.
This gets rid of an impressive amount of duplicative code, with only minimal behavior changes. DROP FOREIGN DATA WRAPPER now requires object ownership rather than superuser privileges, matching the documentation we already have. We also eliminate the historical warning about dropping a built-in function as unuseful. All operations are now performed in the same order for all object types handled by dropcmds.c. KaiGai Kohei, with minor revisions by me
This commit is contained in:
@@ -1612,7 +1612,7 @@ typedef struct AlterExtensionContentsStmt
|
||||
} AlterExtensionContentsStmt;
|
||||
|
||||
/* ----------------------
|
||||
* Create/Drop FOREIGN DATA WRAPPER Statements
|
||||
* Create/Alter FOREIGN DATA WRAPPER Statements
|
||||
* ----------------------
|
||||
*/
|
||||
|
||||
@@ -1632,16 +1632,8 @@ typedef struct AlterFdwStmt
|
||||
List *options; /* generic options to FDW */
|
||||
} AlterFdwStmt;
|
||||
|
||||
typedef struct DropFdwStmt
|
||||
{
|
||||
NodeTag type;
|
||||
char *fdwname; /* foreign-data wrapper name */
|
||||
bool missing_ok; /* don't complain if missing */
|
||||
DropBehavior behavior; /* drop behavior - cascade/restrict */
|
||||
} DropFdwStmt;
|
||||
|
||||
/* ----------------------
|
||||
* Create/Drop FOREIGN SERVER Statements
|
||||
* Create/Alter FOREIGN SERVER Statements
|
||||
* ----------------------
|
||||
*/
|
||||
|
||||
@@ -1664,14 +1656,6 @@ typedef struct AlterForeignServerStmt
|
||||
bool has_version; /* version specified */
|
||||
} AlterForeignServerStmt;
|
||||
|
||||
typedef struct DropForeignServerStmt
|
||||
{
|
||||
NodeTag type;
|
||||
char *servername; /* server name */
|
||||
bool missing_ok; /* ignore missing servers */
|
||||
DropBehavior behavior; /* drop behavior - cascade/restrict */
|
||||
} DropForeignServerStmt;
|
||||
|
||||
/* ----------------------
|
||||
* Create FOREIGN TABLE Statements
|
||||
* ----------------------
|
||||
@@ -1739,7 +1723,7 @@ typedef struct CreateTrigStmt
|
||||
} CreateTrigStmt;
|
||||
|
||||
/* ----------------------
|
||||
* Create/Drop PROCEDURAL LANGUAGE Statements
|
||||
* Create PROCEDURAL LANGUAGE Statements
|
||||
* ----------------------
|
||||
*/
|
||||
typedef struct CreatePLangStmt
|
||||
@@ -1753,14 +1737,6 @@ typedef struct CreatePLangStmt
|
||||
bool pltrusted; /* PL is trusted */
|
||||
} CreatePLangStmt;
|
||||
|
||||
typedef struct DropPLangStmt
|
||||
{
|
||||
NodeTag type;
|
||||
char *plname; /* PL name */
|
||||
DropBehavior behavior; /* RESTRICT or CASCADE behavior */
|
||||
bool missing_ok; /* skip error if missing? */
|
||||
} DropPLangStmt;
|
||||
|
||||
/* ----------------------
|
||||
* Create/Alter/Drop Role Statements
|
||||
*
|
||||
@@ -1921,29 +1897,12 @@ typedef struct DropStmt
|
||||
{
|
||||
NodeTag type;
|
||||
List *objects; /* list of sublists of names (as Values) */
|
||||
List *arguments; /* list of sublists of arguments (as Values) */
|
||||
ObjectType removeType; /* object type */
|
||||
DropBehavior behavior; /* RESTRICT or CASCADE behavior */
|
||||
bool missing_ok; /* skip error if object is missing? */
|
||||
} DropStmt;
|
||||
|
||||
/* ----------------------
|
||||
* Drop Rule|Trigger Statement
|
||||
*
|
||||
* In general this may be used for dropping any property of a relation;
|
||||
* for example, someday soon we may have DROP ATTRIBUTE.
|
||||
* ----------------------
|
||||
*/
|
||||
|
||||
typedef struct DropPropertyStmt
|
||||
{
|
||||
NodeTag type;
|
||||
RangeVar *relation; /* owning relation */
|
||||
char *property; /* name of rule, trigger, etc */
|
||||
ObjectType removeType; /* OBJECT_RULE or OBJECT_TRIGGER */
|
||||
DropBehavior behavior; /* RESTRICT or CASCADE behavior */
|
||||
bool missing_ok; /* skip error if missing? */
|
||||
} DropPropertyStmt;
|
||||
|
||||
/* ----------------------
|
||||
* Truncate Table Statement
|
||||
* ----------------------
|
||||
@@ -2117,20 +2076,6 @@ typedef struct AlterFunctionStmt
|
||||
List *actions; /* list of DefElem */
|
||||
} AlterFunctionStmt;
|
||||
|
||||
/* ----------------------
|
||||
* Drop {Function|Aggregate|Operator} Statement
|
||||
* ----------------------
|
||||
*/
|
||||
typedef struct RemoveFuncStmt
|
||||
{
|
||||
NodeTag type;
|
||||
ObjectType kind; /* function, aggregate, operator */
|
||||
List *name; /* qualified name of object to drop */
|
||||
List *args; /* types of the arguments */
|
||||
DropBehavior behavior; /* RESTRICT or CASCADE behavior */
|
||||
bool missing_ok; /* skip error if missing? */
|
||||
} RemoveFuncStmt;
|
||||
|
||||
/* ----------------------
|
||||
* DO Statement
|
||||
*
|
||||
@@ -2151,32 +2096,6 @@ typedef struct InlineCodeBlock
|
||||
bool langIsTrusted; /* trusted property of the language */
|
||||
} InlineCodeBlock;
|
||||
|
||||
/* ----------------------
|
||||
* Drop Operator Class Statement
|
||||
* ----------------------
|
||||
*/
|
||||
typedef struct RemoveOpClassStmt
|
||||
{
|
||||
NodeTag type;
|
||||
List *opclassname; /* qualified name (list of Value strings) */
|
||||
char *amname; /* name of index AM opclass is for */
|
||||
DropBehavior behavior; /* RESTRICT or CASCADE behavior */
|
||||
bool missing_ok; /* skip error if missing? */
|
||||
} RemoveOpClassStmt;
|
||||
|
||||
/* ----------------------
|
||||
* Drop Operator Family Statement
|
||||
* ----------------------
|
||||
*/
|
||||
typedef struct RemoveOpFamilyStmt
|
||||
{
|
||||
NodeTag type;
|
||||
List *opfamilyname; /* qualified name (list of Value strings) */
|
||||
char *amname; /* name of index AM opfamily is for */
|
||||
DropBehavior behavior; /* RESTRICT or CASCADE behavior */
|
||||
bool missing_ok; /* skip error if missing? */
|
||||
} RemoveOpFamilyStmt;
|
||||
|
||||
/* ----------------------
|
||||
* Alter Object Rename Statement
|
||||
* ----------------------
|
||||
@@ -2557,20 +2476,6 @@ typedef struct CreateCastStmt
|
||||
bool inout;
|
||||
} CreateCastStmt;
|
||||
|
||||
/* ----------------------
|
||||
* DROP CAST Statement
|
||||
* ----------------------
|
||||
*/
|
||||
typedef struct DropCastStmt
|
||||
{
|
||||
NodeTag type;
|
||||
TypeName *sourcetype;
|
||||
TypeName *targettype;
|
||||
DropBehavior behavior;
|
||||
bool missing_ok; /* skip error if missing? */
|
||||
} DropCastStmt;
|
||||
|
||||
|
||||
/* ----------------------
|
||||
* PREPARE Statement
|
||||
* ----------------------
|
||||
|
||||
Reference in New Issue
Block a user