Should we document the behaviour of TRUNCATE skipping repeated relations?

From: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Should we document the behaviour of TRUNCATE skipping repeated relations?
Date: 2021-04-27 14:07:27
Message-ID: CALj2ACULUgJPt-FT-eUHC1ArKmcFX0qxEdmPFkrc2HtQ6Aa7UQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

The TRUNCATE command currently skips processing repeated relations
(see if (list_member_oid(relids, myrelid)) continue; in
ExecuteTruncate) because the same relation can't be truncated more
than once as it will be under "use" during the txn. For instance, in
the following use cases 1) TRUNCATE foo, foo; 2) TRUNCATE foo, ONLY
foo, foo; first instance of relation foo is taken into consideration
for processing and other relation instances ( and options specified if
any) are ignored.

I feel that users should be aware of this behaviour so that they can
correct the commands if written in such a way and don't report
unexpected behaviour especially for the use cases like (2) where they
might expect ONLY foo behaviour but it is skipped by the server.
AFAICS, I don't find it anywhere in the docs, should we document it as
a note?

Thoughts?

With Regards,
Bharath Rupireddy.
EnterpriseDB: http://www.enterprisedb.com

Browse pgsql-hackers by date

  From Date Subject
Next Message PG Doc comments form 2021-04-27 14:26:48 Clarify how triggers relate to transactions
Previous Message Amit Langote 2021-04-27 14:06:09 Re: ALTER TABLE .. DETACH PARTITION CONCURRENTLY