Ignore inherited temp relations from other sessions when truncating

Enterprise / PostgreSQL - Michael Paquier [paquier.xyz] - 27 December 2018 01:16 EST

Inheritance trees can include temporary tables if the parent is permanent, which makes possible the presence of multiple temporary children from different sessions. Trying to issue a TRUNCATE on the parent in this scenario causes a failure, so similarly to any other queries just ignore such cases, which makes TRUNCATE work transparently.

This makes truncation behave similarly to any other DML query working on the parent table with queries which need to be work on the children. A set of isolation tests is added to cover basic cases.

1e504f01da Ignore inherited temp relations from other sessions when truncating
src/backend/commands/tablecmds.c | 23 ++-
src/test/isolation/expected/inherit-temp.out | 217 +++++++++++++++++++++++++++
src/test/isolation/isolation_schedule | 1 +
src/test/isolation/specs/inherit-temp.spec | 78 ++++++++++
4 files changed, 316 insertions(+), 3 deletions(-)

Upstream: git.postgresql.org


  • Share