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

Commitb651b2a

Browse files
committed
Make sure we give an appropriate user-facing error when attempting
to drop a table that is referenced by an open cursor. Fix unstableecpg regression test result that was produced by this oversight.
1 parent2a6108a commitb651b2a

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

‎src/backend/catalog/heap.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.346 2008/11/27 15:59:28 heikki Exp $
11+
* $PostgreSQL: pgsql/src/backend/catalog/heap.c,v 1.347 2008/11/29 00:13:21 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -1412,6 +1412,17 @@ heap_drop_with_catalog(Oid relid)
14121412
*/
14131413
rel=relation_open(relid,AccessExclusiveLock);
14141414

1415+
/*
1416+
* There can no longer be anyone *else* touching the relation, but we
1417+
* might still have open queries or cursors in our own session.
1418+
*/
1419+
if (rel->rd_refcnt!=1)
1420+
ereport(ERROR,
1421+
(errcode(ERRCODE_OBJECT_IN_USE),
1422+
errmsg("cannot drop \"%s\" because "
1423+
"it is being used by active queries in this session",
1424+
RelationGetRelationName(rel))));
1425+
14151426
/*
14161427
* Schedule unlinking of the relation's physical files at commit.
14171428
*/

‎src/interfaces/ecpg/test/expected/sql-fetch.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,10 @@
138138
[NO_PID]: sqlca: code: 0, state: 00000
139139
[NO_PID]: ecpg_execute on line 53: using PQexec
140140
[NO_PID]: sqlca: code: 0, state: 00000
141-
[NO_PID]: ecpg_check_PQresult on line 53: ERROR:relation 16491isstill open
141+
[NO_PID]: ecpg_check_PQresult on line 53: ERROR:cannot drop "my_table" because itisbeing used by active queries in this session
142142
[NO_PID]: sqlca: code: 0, state: 00000
143-
[NO_PID]: raising sqlstateXX000 (sqlcode -400) on line 53:relation 16491isstill open on line 53
144-
[NO_PID]: sqlca: code: -400, state:XX000
145-
sql error:relation 16491isstill open on line 53
143+
[NO_PID]: raising sqlstate55006 (sqlcode -400) on line 53:cannot drop "my_table" because itisbeing used by active queries in this session on line 53
144+
[NO_PID]: sqlca: code: -400, state:55006
145+
sql error:cannot drop "my_table" because itisbeing used by active queries in this session on line 53
146146
[NO_PID]: ecpg_finish: connection regress1 closed
147147
[NO_PID]: sqlca: code: 0, state: 00000

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp