aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/tid.c
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2020-02-07 22:00:21 +0900
committerFujii Masao <fujii@postgresql.org>2020-02-07 22:07:44 +0900
commit598b466e80d9f46aa1472d4f1adb1df90be8c260 (patch)
tree91fd3af04e3ba0c7bbf6edc8d4f235295e88d286 /src/backend/utils/adt/tid.c
parent2f4733993a967ce7f89d1a02c9f12988e9b7ff6f (diff)
downloadpostgresql-598b466e80d9f46aa1472d4f1adb1df90be8c260.tar.gz
postgresql-598b466e80d9f46aa1472d4f1adb1df90be8c260.zip
Fix bug in Tid scan.
Commit 147e3722f7 changed Tid scan so that it calls table_beginscan() and uses the scan option for seq scan. This change caused two issues. (1) The change caused Tid scan to take a predicate lock on the entire relation in serializable transaction even when relation-level lock is not necessary. This could lead to an unexpected serialization error. (2) The change caused Tid scan to increment the number of seq_scan in pg_stat_*_tables views even though it's not seq scan. This could confuse the users. This commit adds the scan option for Tid scan and makes Tid scan use it, to avoid those issues. Back-patch to v12, where the bug was introduced. Author: Tatsuhito Kasahara Reviewed-by: Kyotaro Horiguchi, Masahiko Sawada, Fujii Masao Discussion: https://postgr.es/m/CAP0=ZVKy+gTbFmB6X_UW0pP3WaeJ-fkUWHoD-pExS=at3CY76g@mail.gmail.com
Diffstat (limited to 'src/backend/utils/adt/tid.c')
-rw-r--r--src/backend/utils/adt/tid.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c
index 039ddc86a85..2bba09feaad 100644
--- a/src/backend/utils/adt/tid.c
+++ b/src/backend/utils/adt/tid.c
@@ -381,7 +381,7 @@ currtid_byreloid(PG_FUNCTION_ARGS)
ItemPointerCopy(tid, result);
snapshot = RegisterSnapshot(GetLatestSnapshot());
- scan = table_beginscan(rel, snapshot, 0, NULL);
+ scan = table_beginscan_tid(rel, snapshot);
table_tuple_get_latest_tid(scan, result);
table_endscan(scan);
UnregisterSnapshot(snapshot);
@@ -419,7 +419,7 @@ currtid_byrelname(PG_FUNCTION_ARGS)
ItemPointerCopy(tid, result);
snapshot = RegisterSnapshot(GetLatestSnapshot());
- scan = table_beginscan(rel, snapshot, 0, NULL);
+ scan = table_beginscan_tid(rel, snapshot);
table_tuple_get_latest_tid(scan, result);
table_endscan(scan);
UnregisterSnapshot(snapshot);