Fix bug in Tid scan.
authorFujii Masao
Fri, 7 Feb 2020 13:00:21 +0000 (22:00 +0900)
committerFujii Masao
Fri, 7 Feb 2020 13:07:44 +0000 (22:07 +0900)
commit598b466e80d9f46aa1472d4f1adb1df90be8c260
tree91fd3af04e3ba0c7bbf6edc8d4f235295e88d286
parent2f4733993a967ce7f89d1a02c9f12988e9b7ff6f
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
src/backend/executor/nodeTidscan.c
src/backend/utils/adt/tid.c
src/include/access/tableam.h
src/test/regress/expected/tidscan.out
src/test/regress/sql/tidscan.sql