Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9fab25c

Browse files
author
Amit Kapila
committed
Rearrange dropdb() to avoid errors after allowing other sessions to exit.
During Drop Database, it is better to error out before allowing othersessions to exit and forcefully terminating autovacuum workers. All theother errors except for checking subscriptions are already done before.Author: Amit KapilaDiscussion:https://postgr.es/m/CAA4eK1+qhLkCYG2oy9xug9ur_j=G2wQNRYAyd+-kZfZ1z42pLw@mail.gmail.com
1 parentef8fcbf commit9fab25c

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

‎src/backend/commands/dbcommands.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -896,19 +896,6 @@ dropdb(const char *dbname, bool missing_ok)
896896
nslots_active,nslots_active)));
897897
}
898898

899-
/*
900-
* Check for other backends in the target database. (Because we hold the
901-
* database lock, no new ones can start after this.)
902-
*
903-
* As in CREATE DATABASE, check this after other error conditions.
904-
*/
905-
if (CountOtherDBBackends(db_id,&notherbackends,&npreparedxacts))
906-
ereport(ERROR,
907-
(errcode(ERRCODE_OBJECT_IN_USE),
908-
errmsg("database \"%s\" is being accessed by other users",
909-
dbname),
910-
errdetail_busy_db(notherbackends,npreparedxacts)));
911-
912899
/*
913900
* Check if there are subscriptions defined in the target database.
914901
*
@@ -924,6 +911,19 @@ dropdb(const char *dbname, bool missing_ok)
924911
"There are %d subscriptions.",
925912
nsubscriptions,nsubscriptions)));
926913

914+
/*
915+
* Check for other backends in the target database. (Because we hold the
916+
* database lock, no new ones can start after this.)
917+
*
918+
* As in CREATE DATABASE, check this after other error conditions.
919+
*/
920+
if (CountOtherDBBackends(db_id,&notherbackends,&npreparedxacts))
921+
ereport(ERROR,
922+
(errcode(ERRCODE_OBJECT_IN_USE),
923+
errmsg("database \"%s\" is being accessed by other users",
924+
dbname),
925+
errdetail_busy_db(notherbackends,npreparedxacts)));
926+
927927
/*
928928
* Remove the database's tuple from pg_database.
929929
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp