Patch: Pass IndexInfo correctly to aminsert for indexes on TOAST - Mailing list pgsql-hackers

From Ahuja, Nitin
Subject Patch: Pass IndexInfo correctly to aminsert for indexes on TOAST
Date
Msg-id 15A0E2BC-6CA5-4AE9-9454-41DDE80A1265@amazon.com
Whole thread Raw
Responses Re: Patch: Pass IndexInfo correctly to aminsert for indexes on TOAST  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers

Hi,

I wanted to submit the below patch.

Patch Description
Currently, while saving the TOAST entry the call to index access method insert (aminsert) passed IndexInfo attribute as NULL. IndexInfo parameter was introduced in Postgres 10 for the aminsert method to allow caching data across aminsert calls within a single SQL statement. The IndexInfo is passed correctly for regular tuple insertion but not for TOAST entries. This currently prohibits aminsert method to be able to use IndexInfo for TOAST entries.

This patch correctly passes the built IndexInfo to aminsert for TOAST entries.

 

Context Diff for Patch Submission

 

*** postgres_patch/postgres/src/backend/access/heap/tuptoaster.c      2018-02-18 11:54:02.000000000 -0800

--- postgres/postgres/src/backend/access/heap/tuptoaster.c      2018-02-18 12:14:07.000000000 -0800

***************

*** 43,49 ****

  #include "utils/snapmgr.h"

  #include "utils/typcache.h"

  #include "utils/tqual.h"

- #include "catalog/index.h"

 

 

  #undef TOAST_DEBUG

--- 43,48 ----

***************

*** 1671,1677 ****

                                 * Create the index entry.  We cheat a little here by not using

                                 * FormIndexDatum: this relies on the knowledge that the index columns

                                 * are the same as the initial columns of the table for all the

!                               * indexes.

                                 *

                                 * Note also that there had better not be any user-created index on

                                 * the TOAST table, since we don't bother to update anything else.

--- 1670,1678 ----

                                 * Create the index entry.  We cheat a little here by not using

                                 * FormIndexDatum: this relies on the knowledge that the index columns

                                 * are the same as the initial columns of the table for all the

!                               * indexes.  We also cheat by not providing an IndexInfo: this is okay

!                               * for now because btree doesn't need one, but we might have to be

!                               * more honest someday.

                                 *

                                 * Note also that there had better not be any user-created index on

                                 * the TOAST table, since we don't bother to update anything else.

***************

*** 1685,1691 ****

                                                                                                                 toastrel,

                                                                                                                 toastidxs[i]->rd_index->indisunique ?

                                                                                                                 UNIQUE_CHECK_YES : UNIQUE_CHECK_NO,

!                                                                                                               BuildIndexInfo(toastidxs[i]));

                                }

 

                                /*

--- 1686,1692 ----

                                                                                                                 toastrel,

                                                                                                                 toastidxs[i]->rd_index->indisunique ?

                                                                                                                 UNIQUE_CHECK_YES : UNIQUE_CHECK_NO,

!                                                                                                               NULL);

                                }

 

                                /*




Thanks,
Nitin Ahuja

pgsql-hackers by date:

Previous
From: Etsuro Fujita
Date:
Subject: Re: Incorrect grammar
Next
From: Michael Paquier
Date:
Subject: Re: [bug fix] Cascaded standby cannot start after a clean shutdown