mirror of
https://github.com/postgres/postgres.git
synced 2025-07-03 20:02:46 +03:00
Introduce the 'force' option for the Drop Database command.
This new option terminates the other sessions connected to the target database and then drop it. To terminate other sessions, the current user must have desired permissions (same as pg_terminate_backend()). We don't allow to terminate the sessions if prepared transactions, active logical replication slots or subscriptions are present in the target database. Author: Pavel Stehule with changes by me Reviewed-by: Dilip Kumar, Vignesh C, Ibrar Ahmed, Anthony Nowocien, Ryan Lambert and Amit Kapila Discussion: https://postgr.es/m/CAP_rwwmLJJbn70vLOZFpxGw3XD7nLB_7+NKz46H5EOO2k5H7OQ@mail.gmail.com
This commit is contained in:
@ -310,6 +310,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
||||
%type <defelt> vac_analyze_option_elem
|
||||
%type <list> vac_analyze_option_list
|
||||
%type <node> vac_analyze_option_arg
|
||||
%type <defelt> drop_option
|
||||
%type <boolean> opt_or_replace
|
||||
opt_grant_grant_option opt_grant_admin_option
|
||||
opt_nowait opt_if_exists opt_with_data
|
||||
@ -406,6 +407,7 @@ static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
|
||||
TriggerTransitions TriggerReferencing
|
||||
publication_name_list
|
||||
vacuum_relation_list opt_vacuum_relation_list
|
||||
drop_option_list
|
||||
|
||||
%type <list> group_by_list
|
||||
%type <node> group_by_item empty_grouping_set rollup_clause cube_clause
|
||||
@ -10213,7 +10215,7 @@ AlterDatabaseSetStmt:
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* DROP DATABASE [ IF EXISTS ]
|
||||
* DROP DATABASE [ IF EXISTS ] dbname [ [ WITH ] ( options ) ]
|
||||
*
|
||||
* This is implicitly CASCADE, no need for drop behavior
|
||||
*****************************************************************************/
|
||||
@ -10223,6 +10225,7 @@ DropdbStmt: DROP DATABASE database_name
|
||||
DropdbStmt *n = makeNode(DropdbStmt);
|
||||
n->dbname = $3;
|
||||
n->missing_ok = false;
|
||||
n->options = NULL;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| DROP DATABASE IF_P EXISTS database_name
|
||||
@ -10230,10 +10233,48 @@ DropdbStmt: DROP DATABASE database_name
|
||||
DropdbStmt *n = makeNode(DropdbStmt);
|
||||
n->dbname = $5;
|
||||
n->missing_ok = true;
|
||||
n->options = NULL;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| DROP DATABASE database_name opt_with '(' drop_option_list ')'
|
||||
{
|
||||
DropdbStmt *n = makeNode(DropdbStmt);
|
||||
n->dbname = $3;
|
||||
n->missing_ok = false;
|
||||
n->options = $6;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
| DROP DATABASE IF_P EXISTS database_name opt_with '(' drop_option_list ')'
|
||||
{
|
||||
DropdbStmt *n = makeNode(DropdbStmt);
|
||||
n->dbname = $5;
|
||||
n->missing_ok = true;
|
||||
n->options = $8;
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
;
|
||||
|
||||
drop_option_list:
|
||||
drop_option
|
||||
{
|
||||
$$ = list_make1((Node *) $1);
|
||||
}
|
||||
| drop_option_list ',' drop_option
|
||||
{
|
||||
$$ = lappend($1, (Node *) $3);
|
||||
}
|
||||
;
|
||||
|
||||
/*
|
||||
* Currently only the FORCE option is supported, but the syntax is designed
|
||||
* to be extensible so that we can add more options in the future if required.
|
||||
*/
|
||||
drop_option:
|
||||
FORCE
|
||||
{
|
||||
$$ = makeDefElem("force", NULL, @1);
|
||||
}
|
||||
;
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
|
Reference in New Issue
Block a user