pgsql: Add functions to 'pageinspect' to inspect GiST indexes.

Started by Heikki Linnakangasover 5 years ago4 messagescomitters
Jump to latest
#1Heikki Linnakangas
heikki.linnakangas@enterprisedb.com

Add functions to 'pageinspect' to inspect GiST indexes.

Author: Andrey Borodin and me
Discussion: /messages/by-id/3E4F9093-A1B5-4DF8-A292-0B48692E3954@yandex-team.ru

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/756ab29124d7850d4392e2227b67b69b61576cd6

Modified Files
--------------
contrib/pageinspect/Makefile | 6 +-
contrib/pageinspect/expected/gist.out | 87 ++++++++
contrib/pageinspect/gistfuncs.c | 287 ++++++++++++++++++++++++++
contrib/pageinspect/pageinspect--1.8--1.9.sql | 41 ++++
contrib/pageinspect/pageinspect.control | 2 +-
contrib/pageinspect/sql/gist.sql | 18 ++
doc/src/sgml/pageinspect.sgml | 89 ++++++++
7 files changed, 527 insertions(+), 3 deletions(-)

In reply to: Heikki Linnakangas (#1)
Re: pgsql: Add functions to 'pageinspect' to inspect GiST indexes.

On Wed, Jan 13, 2021 at 12:36 AM Heikki Linnakangas
<heikki.linnakangas@iki.fi> wrote:

Add functions to 'pageinspect' to inspect GiST indexes.

Is gist_page_items() robust with deleted pages? I think that it's
unsafe to assume that deleted pages will have index tuples, since the
page contents will actually be a GISTDeletedPageContents.

Simplest fix would be to assume maxoff is 0 for the page, perhaps.
Right now we just use PageGetMaxOffsetNumber(), which implicitly
assumes that the page uses slotted tuples with an array of line
pointers (actually it can also deal with a zeroed page, but that's not
relevant here).

--
Peter Geoghegan

#3Andrey Borodin
amborodin@acm.org
In reply to: Peter Geoghegan (#2)
Re: pgsql: Add functions to 'pageinspect' to inspect GiST indexes.

12 февр. 2021 г., в 01:53, Peter Geoghegan <pg@bowt.ie> написал(а):

On Wed, Jan 13, 2021 at 12:36 AM Heikki Linnakangas
<heikki.linnakangas@iki.fi> wrote:

Add functions to 'pageinspect' to inspect GiST indexes.

Is gist_page_items() robust with deleted pages? I think that it's
unsafe to assume that deleted pages will have index tuples, since the
page contents will actually be a GISTDeletedPageContents.

Simplest fix would be to assume maxoff is 0 for the page, perhaps.
Right now we just use PageGetMaxOffsetNumber(), which implicitly
assumes that the page uses slotted tuples with an array of line
pointers (actually it can also deal with a zeroed page, but that's not
relevant here).

Thanks, Peter! I agree that taking PageGetMaxOffsetNumber() seems
incorrect for deleted page, because we set pd_lower for the deleted page.
Also, there was an idea to add a column for LP_DEAD.
As long as we are dealing with deleted data anyway, maybe let's add this column?
PFW both patches.

Thanks!

Best regards, Andrey Borodin.

Attachments:

0001-Prevent-pageinspect-from-using-maxoffset-on-GiST-del.patchapplication/octet-stream; name=0001-Prevent-pageinspect-from-using-maxoffset-on-GiST-del.patch; x-unix-mode=0644Download+10-3
0002-Add-bool-column-for-LP_DEAF-flag-to-GiST-pageinspect.patchapplication/octet-stream; name=0002-Add-bool-column-for-LP_DEAF-flag-to-GiST-pageinspect.patch; x-unix-mode=0644Download+28-23
In reply to: Andrey Borodin (#3)
Re: pgsql: Add functions to 'pageinspect' to inspect GiST indexes.

On Thu, Feb 11, 2021 at 9:22 PM Andrey Borodin <x4mmm@yandex-team.ru> wrote:

Thanks, Peter! I agree that taking PageGetMaxOffsetNumber() seems
incorrect for deleted page, because we set pd_lower for the deleted page.
Also, there was an idea to add a column for LP_DEAD.
As long as we are dealing with deleted data anyway, maybe let's add this column?
PFW both patches.

I pushed both of your patches this evening.

Thanks!
--
Peter Geoghegan