Re: posgres 12 bug (partitioned table)

From: Soumyadeep Chakraborty <soumyadeep2007(at)gmail(dot)com>
To: Pavel Biryukov <79166341370(at)yandex(dot)ru>
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, daniel(at)yesql(dot)se
Subject: Re: posgres 12 bug (partitioned table)
Date: 2020-07-06 22:45:23
Message-ID: CAE-ML+_Cd8h75eQnxs2TdzKYjoT0AbN64+z7QfZVYBsu1+09ww@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Hello,

ccing pgsql-hackers(at)postgresql(dot)org

Upon investigation, it seems that the problem is caused by the
following:

The slot passed to the call to ExecProcessReturning() inside
ExecInsert() is often a virtual tuple table slot. If there are system
columns other than ctid and tableOid referenced in the RETURNING clause
(not only xmin as in the bug report), it will lead to the ERROR as
mentioned in this thread as virtual tuple table slots don't really store
such columns. (ctid and tableOid are present directly in the
TupleTableSlot struct and can be satisfied from there: refer:
slot_getsysattr()))

I have attached two alternate patches to solve the problem. Both patches
use and share a mechanism to detect if there are any such system
columns. This is done inside ExecBuildProjectionInfo() and we store this
info inside the ProjectionInfo struct. Then based on this info, system
columns are populated in a suitable slot, which is then passed on to
ExecProcessReturning(). (If it is deemed that this operation only be
done for RETURNING, we can just as easily do it in the callsite for
ExecBuildProjectionInfo() in ExecInitModifyTable() for RETURNING instead
of doing it inside ExecBuildProjectionInfo())

The first patch [1] explicitly creates a heap tuple table slot, fills in the
system column values as we would do during heap_prepare_insert() and
then passes that slot to ExecProcessReturning(). (We use a heap tuple table
slot as it is guaranteed to support these attributes).

The second patch [2] instead of relying on a heap tuple table slot,
relies on ExecGetReturningSlot() for the right slot and
table_tuple_fetch_row_version() to supply the system column values. It
does make the assumption that the AM would supply a slot that will have
these system columns.

[1] v1-0001-Explicitly-supply-system-columns-for-INSERT.RETUR.patch
[2] v1-0001-Use-table_tuple_fetch_row_version-to-supply-INSER.patch

Regards,
Soumyadeep (VMware)

Attachment Content-Type Size
v1-0001-Explicitly-supply-system-columns-for-INSERT.RETUR.patch application/x-patch 5.2 KB
v1-0001-Use-table_tuple_fetch_row_version-to-supply-INSER.patch application/octet-stream 5.0 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Igor Federizi 2020-07-07 01:33:48 Installation error
Previous Message Tom Lane 2020-07-06 20:22:39 Re: [bug] Table not have typarray when created by single user mode

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2020-07-06 22:46:23 Re: Multi-byte character case-folding
Previous Message Tom Lane 2020-07-06 22:08:54 Re: Change a constraint's index - ALTER TABLE ... ALTER CONSTRAINT ... USING INDEX ...