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

Commit898e0c6

Browse files
committed
Forbid DROP SCHEMA on temporary namespaces
This operation was possible for the owner of the schema or a superuser.Down to 9.4, doing this operation would cause inconsistencies in asession whose temporary schema was dropped, particularly if trying tocreate new temporary objects after the drop. A more annoyingconsequence is a crash of autovacuum on an assertion failure whenlogging information about an orphaned temp table dropped. Note thatbecause of246a6c8 (present in v11~), which has made the removal oforphaned temporary tables more aggressive, the failure could betriggered more easily, but it is possible to reproduce down to 9.4.Reported-by: Mahendra Singh, Prabhat SahuAuthor: Michael PaquierReviewed-by: Kyotaro Horiguchi, Mahendra SinghDiscussion:https://postgr.es/m/CAKYtNAr9Zq=1-ww4etHo-VCC-k120YxZy5OS01VkaLPaDbv2tg@mail.gmail.comBackpatch-through: 9.4
1 parent5c0a132 commit898e0c6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

‎src/backend/commands/dropcmds.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include"nodes/makefuncs.h"
2727
#include"parser/parse_type.h"
2828
#include"utils/builtins.h"
29+
#include"utils/lsyscache.h"
2930
#include"utils/syscache.h"
3031

3132

@@ -116,6 +117,21 @@ RemoveObjects(DropStmt *stmt)
116117
ReleaseSysCache(tup);
117118
}
118119

120+
/*
121+
* Prevent the drop of a temporary schema, be it owned by the current
122+
* session or another backend as this would mess up with the callback
123+
* registered to clean up temporary objects at the end of a session.
124+
* Note also that the creation of any follow-up temporary object would
125+
* result in inconsistencies within the session whose temporary schema
126+
* has been dropped.
127+
*/
128+
if (stmt->removeType==OBJECT_SCHEMA&&
129+
isAnyTempNamespace(address.objectId))
130+
ereport(ERROR,
131+
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
132+
errmsg("cannot drop temporary schema \"%s\"",
133+
get_namespace_name(address.objectId))));
134+
119135
/* Check permissions. */
120136
namespaceId=get_object_namespace(&address);
121137
if (!OidIsValid(namespaceId)||

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp