mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +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:
@ -2755,6 +2755,7 @@ _copyDropStmt(DropStmt *from)
|
||||
DropStmt *newnode = makeNode(DropStmt);
|
||||
|
||||
COPY_NODE_FIELD(objects);
|
||||
COPY_NODE_FIELD(arguments);
|
||||
COPY_SCALAR_FIELD(removeType);
|
||||
COPY_SCALAR_FIELD(behavior);
|
||||
COPY_SCALAR_FIELD(missing_ok);
|
||||
@ -2878,20 +2879,6 @@ _copyAlterFunctionStmt(AlterFunctionStmt *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static RemoveFuncStmt *
|
||||
_copyRemoveFuncStmt(RemoveFuncStmt *from)
|
||||
{
|
||||
RemoveFuncStmt *newnode = makeNode(RemoveFuncStmt);
|
||||
|
||||
COPY_SCALAR_FIELD(kind);
|
||||
COPY_NODE_FIELD(name);
|
||||
COPY_NODE_FIELD(args);
|
||||
COPY_SCALAR_FIELD(behavior);
|
||||
COPY_SCALAR_FIELD(missing_ok);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static DoStmt *
|
||||
_copyDoStmt(DoStmt *from)
|
||||
{
|
||||
@ -2902,32 +2889,6 @@ _copyDoStmt(DoStmt *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static RemoveOpClassStmt *
|
||||
_copyRemoveOpClassStmt(RemoveOpClassStmt *from)
|
||||
{
|
||||
RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
|
||||
|
||||
COPY_NODE_FIELD(opclassname);
|
||||
COPY_STRING_FIELD(amname);
|
||||
COPY_SCALAR_FIELD(behavior);
|
||||
COPY_SCALAR_FIELD(missing_ok);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static RemoveOpFamilyStmt *
|
||||
_copyRemoveOpFamilyStmt(RemoveOpFamilyStmt *from)
|
||||
{
|
||||
RemoveOpFamilyStmt *newnode = makeNode(RemoveOpFamilyStmt);
|
||||
|
||||
COPY_NODE_FIELD(opfamilyname);
|
||||
COPY_STRING_FIELD(amname);
|
||||
COPY_SCALAR_FIELD(behavior);
|
||||
COPY_SCALAR_FIELD(missing_ok);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static RenameStmt *
|
||||
_copyRenameStmt(RenameStmt *from)
|
||||
{
|
||||
@ -3391,18 +3352,6 @@ _copyAlterFdwStmt(AlterFdwStmt *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static DropFdwStmt *
|
||||
_copyDropFdwStmt(DropFdwStmt *from)
|
||||
{
|
||||
DropFdwStmt *newnode = makeNode(DropFdwStmt);
|
||||
|
||||
COPY_STRING_FIELD(fdwname);
|
||||
COPY_SCALAR_FIELD(missing_ok);
|
||||
COPY_SCALAR_FIELD(behavior);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static CreateForeignServerStmt *
|
||||
_copyCreateForeignServerStmt(CreateForeignServerStmt *from)
|
||||
{
|
||||
@ -3430,18 +3379,6 @@ _copyAlterForeignServerStmt(AlterForeignServerStmt *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static DropForeignServerStmt *
|
||||
_copyDropForeignServerStmt(DropForeignServerStmt *from)
|
||||
{
|
||||
DropForeignServerStmt *newnode = makeNode(DropForeignServerStmt);
|
||||
|
||||
COPY_STRING_FIELD(servername);
|
||||
COPY_SCALAR_FIELD(missing_ok);
|
||||
COPY_SCALAR_FIELD(behavior);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static CreateUserMappingStmt *
|
||||
_copyCreateUserMappingStmt(CreateUserMappingStmt *from)
|
||||
{
|
||||
@ -3513,20 +3450,6 @@ _copyCreateTrigStmt(CreateTrigStmt *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static DropPropertyStmt *
|
||||
_copyDropPropertyStmt(DropPropertyStmt *from)
|
||||
{
|
||||
DropPropertyStmt *newnode = makeNode(DropPropertyStmt);
|
||||
|
||||
COPY_NODE_FIELD(relation);
|
||||
COPY_STRING_FIELD(property);
|
||||
COPY_SCALAR_FIELD(removeType);
|
||||
COPY_SCALAR_FIELD(behavior);
|
||||
COPY_SCALAR_FIELD(missing_ok);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static CreatePLangStmt *
|
||||
_copyCreatePLangStmt(CreatePLangStmt *from)
|
||||
{
|
||||
@ -3542,18 +3465,6 @@ _copyCreatePLangStmt(CreatePLangStmt *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static DropPLangStmt *
|
||||
_copyDropPLangStmt(DropPLangStmt *from)
|
||||
{
|
||||
DropPLangStmt *newnode = makeNode(DropPLangStmt);
|
||||
|
||||
COPY_STRING_FIELD(plname);
|
||||
COPY_SCALAR_FIELD(behavior);
|
||||
COPY_SCALAR_FIELD(missing_ok);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static CreateRoleStmt *
|
||||
_copyCreateRoleStmt(CreateRoleStmt *from)
|
||||
{
|
||||
@ -3678,19 +3589,6 @@ _copyCreateCastStmt(CreateCastStmt *from)
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static DropCastStmt *
|
||||
_copyDropCastStmt(DropCastStmt *from)
|
||||
{
|
||||
DropCastStmt *newnode = makeNode(DropCastStmt);
|
||||
|
||||
COPY_NODE_FIELD(sourcetype);
|
||||
COPY_NODE_FIELD(targettype);
|
||||
COPY_SCALAR_FIELD(behavior);
|
||||
COPY_SCALAR_FIELD(missing_ok);
|
||||
|
||||
return newnode;
|
||||
}
|
||||
|
||||
static PrepareStmt *
|
||||
_copyPrepareStmt(PrepareStmt *from)
|
||||
{
|
||||
@ -4266,18 +4164,9 @@ copyObject(void *from)
|
||||
case T_AlterFunctionStmt:
|
||||
retval = _copyAlterFunctionStmt(from);
|
||||
break;
|
||||
case T_RemoveFuncStmt:
|
||||
retval = _copyRemoveFuncStmt(from);
|
||||
break;
|
||||
case T_DoStmt:
|
||||
retval = _copyDoStmt(from);
|
||||
break;
|
||||
case T_RemoveOpClassStmt:
|
||||
retval = _copyRemoveOpClassStmt(from);
|
||||
break;
|
||||
case T_RemoveOpFamilyStmt:
|
||||
retval = _copyRemoveOpFamilyStmt(from);
|
||||
break;
|
||||
case T_RenameStmt:
|
||||
retval = _copyRenameStmt(from);
|
||||
break;
|
||||
@ -4392,18 +4281,12 @@ copyObject(void *from)
|
||||
case T_AlterFdwStmt:
|
||||
retval = _copyAlterFdwStmt(from);
|
||||
break;
|
||||
case T_DropFdwStmt:
|
||||
retval = _copyDropFdwStmt(from);
|
||||
break;
|
||||
case T_CreateForeignServerStmt:
|
||||
retval = _copyCreateForeignServerStmt(from);
|
||||
break;
|
||||
case T_AlterForeignServerStmt:
|
||||
retval = _copyAlterForeignServerStmt(from);
|
||||
break;
|
||||
case T_DropForeignServerStmt:
|
||||
retval = _copyDropForeignServerStmt(from);
|
||||
break;
|
||||
case T_CreateUserMappingStmt:
|
||||
retval = _copyCreateUserMappingStmt(from);
|
||||
break;
|
||||
@ -4419,15 +4302,9 @@ copyObject(void *from)
|
||||
case T_CreateTrigStmt:
|
||||
retval = _copyCreateTrigStmt(from);
|
||||
break;
|
||||
case T_DropPropertyStmt:
|
||||
retval = _copyDropPropertyStmt(from);
|
||||
break;
|
||||
case T_CreatePLangStmt:
|
||||
retval = _copyCreatePLangStmt(from);
|
||||
break;
|
||||
case T_DropPLangStmt:
|
||||
retval = _copyDropPLangStmt(from);
|
||||
break;
|
||||
case T_CreateRoleStmt:
|
||||
retval = _copyCreateRoleStmt(from);
|
||||
break;
|
||||
@ -4461,9 +4338,6 @@ copyObject(void *from)
|
||||
case T_CreateCastStmt:
|
||||
retval = _copyCreateCastStmt(from);
|
||||
break;
|
||||
case T_DropCastStmt:
|
||||
retval = _copyDropCastStmt(from);
|
||||
break;
|
||||
case T_PrepareStmt:
|
||||
retval = _copyPrepareStmt(from);
|
||||
break;
|
||||
|
Reference in New Issue
Block a user