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

Commit69bef7f

Browse files
committed
Add CheckTableNotInUse calls in DROP TABLE and DROP INDEX.
Recent releases had a check on rel->rd_refcnt in heap_drop_with_catalog,but failed to cover the possibility of pending trigger events at DROP time.(Before 8.4 we didn't even check the refcnt.) When the trigger events wereeventually fired, you'd get "could not open relation with OID nnn" errors,as in recent report from strk. Better to throw a suitable error when theDROP is attempted.Also add a similar check in DROP INDEX.Back-patch to all supported branches.
1 parent13a9a7b commit69bef7f

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

‎src/backend/catalog/heap.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,13 @@ heap_drop_with_catalog(Oid relid)
12361236
*/
12371237
rel=relation_open(relid,AccessExclusiveLock);
12381238

1239+
/*
1240+
* There can no longer be anyone *else* touching the relation, but we
1241+
* might still have open queries or cursors, or pending trigger events,
1242+
* in our own session.
1243+
*/
1244+
CheckTableNotInUse(rel,"DROP TABLE");
1245+
12391246
/*
12401247
* Schedule unlinking of the relation's physical file at commit.
12411248
*/

‎src/backend/catalog/index.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,12 @@ index_drop(Oid indexId)
848848

849849
userIndexRelation=index_open(indexId,AccessExclusiveLock);
850850

851+
/*
852+
* There can no longer be anyone *else* touching the index, but we
853+
* might still have open queries using it in our own session.
854+
*/
855+
CheckTableNotInUse(userIndexRelation,"DROP INDEX");
856+
851857
/*
852858
* Schedule physical removal of the file
853859
*/

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp