Re: Index AM API cleanup

Peter Eisentraut <peter@eisentraut.org>

From: Peter Eisentraut <peter@eisentraut.org>
To: PostgreSQL Hackers <pgsql-hackers@postgresql.org>
Cc: Mark Dilger <mark.dilger@enterprisedb.com>, Andrew Dunstan <andrew@dunslane.net>, Alex Wang <alex.wang@enterprisedb.com>, Paul A Jungwirth <pj@illuminatedcomputing.com>
Date: 2025-01-25T07:18:53Z
Lists: pgsql-hackers

Attachments

I've been working on integrating Mark's "Index AM API cleanup" patch set 
with the existing gist strategy number mapping from Paul's application 
time patch set.  Here is what I've come up with.

The previously committed patch (v19.1) already changed the gist strategy 
number mapping to use the (Row)CompareType, as in Mark's proposal.

In this patch set, I'm attaching the existing standalone gist translate 
function as the index AM API function for the gist index AM.  And then 
all existing callers are changed to call through the index AM API 
functions provided by Mark's patch set.

Patches 0001, 0002, 0003 are some preparatory renaming and refactoring 
patches.

Patches 0004 and 0005 are patch v19-0008 from Mark's (via Andrew) v19 
patch set, split into two patches, and with some function renaming from 
my side.

Patch 0006 then pulls it all together.  The key change is that we also 
need to pass the opclass to the index AM API functions, so that access 
methods like gist can use it.  Actually, I changed that to pass opfamily 
and opcintype instead.  I think this matches better with the rest of the 
"Index AM API cleanup" patch set, because it's more common to have the 
opfamily and type handy than the opclass.  (And internally, the gist 
support function is attached to the opfamily anyway, so it's actually 
simpler that way.)

I think this fits together quite well now.  Several places where gist 
was hardcoded are now fully (or mostly) independent of gist.  Also, the 
somewhat hackish get_equal_strategy_number() in the logical replication 
code disappears completely and is replaced by a proper index AM API 
function.  (This also takes care of patch v19-0011 from Mark's patch set.)

Also, since we have already built out test coverage for the 
GistTranslate* stuff, the new index-AM-level translate functionality 
gets to use this test coverage for free.

Thoughts?


[0]: 
https://www.postgresql.org/message-id/ad628976-8b33-468d-8e52-3fbfcff89103%40dunslane.net

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Relax ordering-related hardcoded btree requirements in planning

  2. Support non-btree indexes in get_actual_variable_range()

  3. Convert PathKey to use CompareType

  4. Generalize index support in network support function

  5. Update a code comment

  6. Allow non-btree unique indexes for matviews

  7. Allow non-btree unique indexes for partition keys

  8. Add some opfamily support functions to lsyscache.c

  9. Simplify and generalize PrepareSortSupportFromIndexRel()

  10. Generalize hash and ordering support in amapi

  11. Drop opcintype from index AM strategy translation API

  12. Allow non-btree speculative insertion indexes

  13. Support non-btree indexes for foreign keys

  14. Integrate GistTranslateCompareType() into IndexAmTranslateCompareType()

  15. Convert strategies to and from compare types

  16. Move CompareType to separate header file

  17. Add get_opfamily_name() function

  18. Rename GistTranslateStratnum() to GistTranslateCompareType()

  19. Change gist stratnum function to use CompareType

  20. Rename RowCompareType to CompareType

  21. Improve slightly misleading internal error message

  22. Track scan reversals in MergeJoin

  23. Track sort direction in SortGroupClause

  24. Add stratnum GiST support function

  25. Add amgettreeheight index AM API routine