Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit65c5fcd

Browse files
committed
Restructure index access method API to hide most of it at the C level.
This patch reduces pg_am to just two columns, a name and a handlerfunction. All the data formerly obtained from pg_am is now providedin a C struct returned by the handler function. This is similar tothe designs we've adopted for FDWs and tablesample methods. Thereare multiple advantages. For one, the index AM's support functionsare now simple C functions, making them faster to call and much lesserror-prone, since the C compiler can now check function signatures.For another, this will make it far more practical to define index accessmethods in installable extensions.A disadvantage is that SQL-level code can no longer see attributesof index AMs; in particular, some of the crosschecks in the opr_sanityregression test are no longer possible from SQL. We've addressed thatby adding a facility for the index AM to perform such checks instead.(Much more could be done in that line, but for now we're content if theamvalidate functions more or less replace what opr_sanity used to do.)We might also want to expose some sort of reporting functionality, butthis patch doesn't do that.Alexander Korotkov, reviewed by Petr Jelínek, and rather heavilyeditorialized on by me.
1 parent8d290c8 commit65c5fcd

File tree

93 files changed

+2494
-1925
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+2494
-1925
lines changed

‎contrib/pageinspect/btreefuncs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
#include"access/nbtree.h"
3131
#include"catalog/namespace.h"
32+
#include"catalog/pg_am.h"
3233
#include"funcapi.h"
3334
#include"miscadmin.h"
3435
#include"utils/builtins.h"

‎contrib/pgstattuple/pgstatindex.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include"access/htup_details.h"
3333
#include"access/nbtree.h"
3434
#include"catalog/namespace.h"
35+
#include"catalog/pg_am.h"
3536
#include"funcapi.h"
3637
#include"miscadmin.h"
3738
#include"storage/bufmgr.h"

‎contrib/pgstattuple/pgstattuple.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include"access/nbtree.h"
3030
#include"access/relscan.h"
3131
#include"catalog/namespace.h"
32+
#include"catalog/pg_am.h"
3233
#include"funcapi.h"
3334
#include"miscadmin.h"
3435
#include"storage/bufmgr.h"

‎doc/src/sgml/catalogs.sgml

Lines changed: 7 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -516,8 +516,8 @@
516516
<para>
517517
The catalog <structname>pg_am</structname> stores information about index
518518
access methods. There is one row for each index access method supported by
519-
the system. Thecontents of this catalogare discussed in detail in
520-
<xref linkend="indexam">.
519+
the system. Therequirements for index access methodsare discussed in
520+
detail in<xref linkend="indexam">.
521521
</para>
522522

523523
<table>
@@ -549,212 +549,13 @@
549549
</row>
550550

551551
<row>
552-
<entry><structfield>amstrategies</structfield></entry>
553-
<entry><type>int2</type></entry>
554-
<entry></entry>
555-
<entry>Number of operator strategies for this access method,
556-
or zero if access method does not have a fixed set of operator
557-
strategies</entry>
558-
</row>
559-
560-
<row>
561-
<entry><structfield>amsupport</structfield></entry>
562-
<entry><type>int2</type></entry>
563-
<entry></entry>
564-
<entry>Number of support routines for this access method</entry>
565-
</row>
566-
567-
<row>
568-
<entry><structfield>amcanorder</structfield></entry>
569-
<entry><type>bool</type></entry>
570-
<entry></entry>
571-
<entry>Does the access method support ordered scans sorted by the
572-
indexed column's value?</entry>
573-
</row>
574-
575-
<row>
576-
<entry><structfield>amcanorderbyop</structfield></entry>
577-
<entry><type>bool</type></entry>
578-
<entry></entry>
579-
<entry>Does the access method support ordered scans sorted by the result
580-
of an operator on the indexed column?</entry>
581-
</row>
582-
583-
<row>
584-
<entry><structfield>amcanbackward</structfield></entry>
585-
<entry><type>bool</type></entry>
586-
<entry></entry>
587-
<entry>Does the access method support backward scanning?</entry>
588-
</row>
589-
590-
<row>
591-
<entry><structfield>amcanunique</structfield></entry>
592-
<entry><type>bool</type></entry>
593-
<entry></entry>
594-
<entry>Does the access method support unique indexes?</entry>
595-
</row>
596-
597-
<row>
598-
<entry><structfield>amcanmulticol</structfield></entry>
599-
<entry><type>bool</type></entry>
600-
<entry></entry>
601-
<entry>Does the access method support multicolumn indexes?</entry>
602-
</row>
603-
604-
<row>
605-
<entry><structfield>amoptionalkey</structfield></entry>
606-
<entry><type>bool</type></entry>
607-
<entry></entry>
608-
<entry>Does the access method support a scan without any constraint
609-
for the first index column?</entry>
610-
</row>
611-
612-
<row>
613-
<entry><structfield>amsearcharray</structfield></entry>
614-
<entry><type>bool</type></entry>
615-
<entry></entry>
616-
<entry>Does the access method support <literal>ScalarArrayOpExpr</> searches?</entry>
617-
</row>
618-
619-
<row>
620-
<entry><structfield>amsearchnulls</structfield></entry>
621-
<entry><type>bool</type></entry>
622-
<entry></entry>
623-
<entry>Does the access method support <literal>IS NULL</>/<literal>NOT NULL</> searches?</entry>
624-
</row>
625-
626-
<row>
627-
<entry><structfield>amstorage</structfield></entry>
628-
<entry><type>bool</type></entry>
629-
<entry></entry>
630-
<entry>Can index storage data type differ from column data type?</entry>
631-
</row>
632-
633-
<row>
634-
<entry><structfield>amclusterable</structfield></entry>
635-
<entry><type>bool</type></entry>
636-
<entry></entry>
637-
<entry>Can an index of this type be clustered on?</entry>
638-
</row>
639-
640-
<row>
641-
<entry><structfield>ampredlocks</structfield></entry>
642-
<entry><type>bool</type></entry>
643-
<entry></entry>
644-
<entry>Does an index of this type manage fine-grained predicate locks?</entry>
645-
</row>
646-
647-
<row>
648-
<entry><structfield>amkeytype</structfield></entry>
552+
<entry><structfield>amhandler</structfield></entry>
649553
<entry><type>oid</type></entry>
650-
<entry><literal><link linkend="catalog-pg-type"><structname>pg_type</structname></link>.oid</literal></entry>
651-
<entry>Type of data stored in index, or zero if not a fixed type</entry>
652-
</row>
653-
654-
<row>
655-
<entry><structfield>aminsert</structfield></entry>
656-
<entry><type>regproc</type></entry>
657-
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
658-
<entry><quote>Insert this tuple</quote> function</entry>
659-
</row>
660-
661-
<row>
662-
<entry><structfield>ambeginscan</structfield></entry>
663-
<entry><type>regproc</type></entry>
664-
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
665-
<entry><quote>Prepare for index scan</quote> function</entry>
666-
</row>
667-
668-
<row>
669-
<entry><structfield>amgettuple</structfield></entry>
670-
<entry><type>regproc</type></entry>
671-
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
672-
<entry><quote>Next valid tuple</quote> function, or zero if none</entry>
673-
</row>
674-
675-
<row>
676-
<entry><structfield>amgetbitmap</structfield></entry>
677-
<entry><type>regproc</type></entry>
678-
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
679-
<entry><quote>Fetch all valid tuples</quote> function, or zero if none</entry>
680-
</row>
681-
682-
<row>
683-
<entry><structfield>amrescan</structfield></entry>
684-
<entry><type>regproc</type></entry>
685-
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
686-
<entry><quote>(Re)start index scan</quote> function</entry>
687-
</row>
688-
689-
<row>
690-
<entry><structfield>amendscan</structfield></entry>
691-
<entry><type>regproc</type></entry>
692-
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
693-
<entry><quote>Clean up after index scan</quote> function</entry>
694-
</row>
695-
696-
<row>
697-
<entry><structfield>ammarkpos</structfield></entry>
698-
<entry><type>regproc</type></entry>
699554
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
700-
<entry><quote>Mark current scan position</quote> function</entry>
701-
</row>
702-
703-
<row>
704-
<entry><structfield>amrestrpos</structfield></entry>
705-
<entry><type>regproc</type></entry>
706-
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
707-
<entry><quote>Restore marked scan position</quote> function</entry>
708-
</row>
709-
710-
<row>
711-
<entry><structfield>ambuild</structfield></entry>
712-
<entry><type>regproc</type></entry>
713-
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
714-
<entry><quote>Build new index</quote> function</entry>
715-
</row>
716-
717-
<row>
718-
<entry><structfield>ambuildempty</structfield></entry>
719-
<entry><type>regproc</type></entry>
720-
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
721-
<entry><quote>Build empty index</quote> function</entry>
722-
</row>
723-
724-
<row>
725-
<entry><structfield>ambulkdelete</structfield></entry>
726-
<entry><type>regproc</type></entry>
727-
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
728-
<entry>Bulk-delete function</entry>
729-
</row>
730-
731-
<row>
732-
<entry><structfield>amvacuumcleanup</structfield></entry>
733-
<entry><type>regproc</type></entry>
734-
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
735-
<entry>Post-<command>VACUUM</command> cleanup function</entry>
736-
</row>
737-
738-
<row>
739-
<entry><structfield>amcanreturn</structfield></entry>
740-
<entry><type>regproc</type></entry>
741-
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
742-
<entry>Function to check whether an index column supports index-only
743-
scans. Can be zero if index-only scans are never supported.</entry>
744-
</row>
745-
746-
<row>
747-
<entry><structfield>amcostestimate</structfield></entry>
748-
<entry><type>regproc</type></entry>
749-
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
750-
<entry>Function to estimate cost of an index scan</entry>
751-
</row>
752-
753-
<row>
754-
<entry><structfield>amoptions</structfield></entry>
755-
<entry><type>regproc</type></entry>
756-
<entry><literal><link linkend="catalog-pg-proc"><structname>pg_proc</structname></link>.oid</literal></entry>
757-
<entry>Function to parse and validate <structfield>reloptions</> for an index</entry>
555+
<entry>
556+
OID of a handler function that is responsible for supplying information
557+
about the access method
558+
</entry>
758559
</row>
759560

760561
</tbody>

‎doc/src/sgml/datatype.sgml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4632,6 +4632,10 @@ SELECT * FROM pg_attribute
46324632
<primary>fdw_handler</primary>
46334633
</indexterm>
46344634

4635+
<indexterm zone="datatype-pseudo">
4636+
<primary>index_am_handler</primary>
4637+
</indexterm>
4638+
46354639
<indexterm zone="datatype-pseudo">
46364640
<primary>tsm_handler</primary>
46374641
</indexterm>
@@ -4730,6 +4734,11 @@ SELECT * FROM pg_attribute
47304734
<entry>A foreign-data wrapper handler is declared to return <type>fdw_handler</>.</entry>
47314735
</row>
47324736

4737+
<row>
4738+
<entry><type>index_am_handler</></entry>
4739+
<entry>An index access method handler is declared to return <type>index_am_handler</>.</entry>
4740+
</row>
4741+
47334742
<row>
47344743
<entry><type>tsm_handler</></entry>
47354744
<entry>A tablesample method handler is declared to return <type>tsm_handler</>.</entry>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp