Patch: Pass IndexInfo correctly to aminsert for indexes on TOAST

From: "Ahuja, Nitin" <nitahuja(at)amazon(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Patch: Pass IndexInfo correctly to aminsert for indexes on TOAST
Date: 2018-02-23 02:13:08
Message-ID: 15A0E2BC-6CA5-4AE9-9454-41DDE80A1265@amazon.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-02-23 02:26:31 Re: [bug fix] Cascaded standby cannot start after a clean shutdown
Previous Message Etsuro Fujita 2018-02-23 02:09:15 Re: Incorrect grammar