Re: Index AM API cleanup

Alexandra Wang <alexandra.wang.oss@gmail.com>

From: Alexandra Wang <alexandra.wang.oss@gmail.com>
To: Mark Dilger <mark.dilger@enterprisedb.com>
Cc: PostgreSQL Hackers <pgsql-hackers@postgresql.org>, Peter Eisentraut <peter.eisentraut@enterprisedb.com>, Andrew Dunstan <andrew.dunstan@enterprisedb.com>, Alex Wang <alex.wang@enterprisedb.com>
Date: 2024-09-04T14:15:06Z
Lists: pgsql-hackers
On Thu, Aug 22, 2024 at 11:28 AM Mark Dilger
<mark.dilger@enterprisedb.com> wrote:
> > On Aug 22, 2024, at 1:36 AM, Alexandra Wang <alexandra.wang.oss@gmail.com> wrote:
> > "make installcheck" for treeb is causing issues on my end. I can
> > investigate further if it’s not a problem for others.
>
> The test module index AMs are not intended for use in any installed database, so 'make installcheck' is unnecessary.  A mere 'make check' should suffice.  However, if you want to run it, you can install the modules, edit postgresql.conf to add 'treeb' to shared_preload_libraries, restart the server, and run 'make installcheck'.   This is necessary for 'treeb' because it requests shared memory, and that needs to be done at startup.

Thanks, Mark. This works, and I can run treeb now.

> The v18 patch set includes the changes your patches suggest, though I modified the approach a bit.  Specifically, rather than standardizing on '1.0.0' for the module versions, as your patches do, I went with '1.0', as is standard in other modules in neighboring directories.  The '1.0.0' numbering was something I had been using in versions 1..16 of this patch, and I only partially converted to '1.0' before posting v17, so sorry about that.  The v18 patch also has some whitespace fixes.
>
> To address your comments about the noise in the test failures, v18 modifies the clone_tests.pl script to do a little more work translating the expected output to expect the module's AM name ("xash", "xtree", "treeb", or whatnot) beyond what that script did in v17.

Thanks! I see fewer failures now.

There are a few occurrences of the following error when I run "make
check" in the xtree module:

+ERROR:  bogus RowCompare index qualification

I needed to specify `amroutine->amcancrosscompare = true;` in xtree.c
to eliminate them, as below:

diff --git a/src/test/modules/xtree/access/xtree.c
b/src/test/modules/xtree/access/xtree.c
index bd472edb04..960966801d 100644
--- a/src/test/modules/xtree/access/xtree.c
+++ b/src/test/modules/xtree/access/xtree.c
@@ -33,6 +33,7 @@ xtree_indexam_handler(PG_FUNCTION_ARGS)
        amroutine->amoptsprocnum = BTOPTIONS_PROC;
        amroutine->amcanorder = true;
        amroutine->amcanhash = false;
+       amroutine->amcancrosscompare = true;
        amroutine->amcanorderbyop = false;
        amroutine->amcanbackward = true;
        amroutine->amcanunique = true;

After adding that, the regression.diffs for the xtree and treeb
modules are identical in content, with only plan diffs remaining. I
think this change should be either part of
v18-0008-Generalize-hash-and-ordering-support-in-amapi.patch or a
separate commit, similar to
v18-0009-Adjust-treeb-to-use-amcanhash-and-amcancrosscomp.patch.

Best,
Alex



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