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

Commit81a23dd

Browse files
committed
Avoid unnecessary table open/close in TRUNCATE command.
ExecuteTruncate() filters out the duplicate tables specifiedin the TRUNCATE command, for example in the case where "TRUNCATE foo, foo"is executed. Such duplicate tables obviously don't need to be openedand closed because they are skipped. But previously it always openedthe tables before checking whether they were duplicated ones or not,and then closed them if they were. That is, the duplicated tables wereopened and closed unnecessarily.This commit changes ExecuteTruncate() so that it opens the tableafter it confirms that table is not duplicated one, which leads toavoid unnecessary table open/close.Do not back-patch because such unnecessary table open/close is nota bug though it exists in older versions.Author: Bharath RupireddyReviewed-by: Amul Sul, Fujii MasaoDiscussion:https://postgr.es/m/CALj2ACUdBO_sXJTa08OZ0YT0qk7F_gAmRa9hT4dxRcgPS4nsZA@mail.gmail.com
1 parent08aa89b commit81a23dd

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1639,15 +1639,12 @@ ExecuteTruncate(TruncateStmt *stmt)
16391639
0, RangeVarCallbackForTruncate,
16401640
NULL);
16411641

1642-
/* open the relation, we already hold a lock on it */
1643-
rel = table_open(myrelid, NoLock);
1644-
16451642
/* don't throw error for "TRUNCATE foo, foo" */
16461643
if (list_member_oid(relids, myrelid))
1647-
{
1648-
table_close(rel, lockmode);
16491644
continue;
1650-
}
1645+
1646+
/* open the relation, we already hold a lock on it */
1647+
rel = table_open(myrelid, NoLock);
16511648

16521649
/*
16531650
* RangeVarGetRelidExtended() has done most checks with its callback,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp