Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
index-functions.html487 linesDownload Raw Back to html
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>64.2. Index Access Method Functions</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="index-api.html" title="64.1. Basic API Structure for Indexes" /><link rel="next" href="index-scanning.html" title="64.3. Index Scanning" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">64.2. Index Access Method Functions</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="index-api.html" title="64.1. Basic API Structure for Indexes">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="indexam.html" title="Chapter 64. Index Access Method Interface Definition">Up</a></td><th width="60%" align="center">Chapter 64. Index Access Method Interface Definition</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="index-scanning.html" title="64.3. Index Scanning">Next</a></td></tr></table><hr /></div><div class="sect1" id="INDEX-FUNCTIONS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">64.2. Index Access Method Functions <a href="#INDEX-FUNCTIONS" class="id_link">#</a></h2></div></div></div><p>3   The index construction and maintenance functions that an index access4   method must provide in <code class="structname">IndexAmRoutine</code> are:5  </p><p>6</p><pre class="programlisting">7IndexBuildResult *8ambuild (Relation heapRelation,9         Relation indexRelation,10         IndexInfo *indexInfo);11</pre><p>12   Build a new index.  The index relation has been physically created,13   but is empty.  It must be filled in with whatever fixed data the14   access method requires, plus entries for all tuples already existing15   in the table.  Ordinarily the <code class="function">ambuild</code> function will call16   <code class="function">table_index_build_scan()</code> to scan the table for existing tuples17   and compute the keys that need to be inserted into the index.18   The function must return a palloc'd struct containing statistics about19   the new index.20  </p><p>21</p><pre class="programlisting">22void23ambuildempty (Relation indexRelation);24</pre><p>25   Build an empty index, and write it to the initialization fork (<code class="symbol">INIT_FORKNUM</code>)26   of the given relation.  This method is called only for unlogged indexes; the27   empty index written to the initialization fork will be copied over the main28   relation fork on each server restart.29  </p><p>30</p><pre class="programlisting">31bool32aminsert (Relation indexRelation,33          Datum *values,34          bool *isnull,35          ItemPointer heap_tid,36          Relation heapRelation,37          IndexUniqueCheck checkUnique,38          bool indexUnchanged,39          IndexInfo *indexInfo);40</pre><p>41   Insert a new tuple into an existing index.  The <code class="literal">values</code> and42   <code class="literal">isnull</code> arrays give the key values to be indexed, and43   <code class="literal">heap_tid</code> is the TID to be indexed.44   If the access method supports unique indexes (its45   <code class="structfield">amcanunique</code> flag is true) then46   <code class="literal">checkUnique</code> indicates the type of uniqueness check to47   perform.  This varies depending on whether the unique constraint is48   deferrable; see <a class="xref" href="index-unique-checks.html" title="64.5. Index Uniqueness Checks">Section 64.5</a> for details.49   Normally the access method only needs the <code class="literal">heapRelation</code>50   parameter when performing uniqueness checking (since then it will have to51   look into the heap to verify tuple liveness).52  </p><p>53   The <code class="literal">indexUnchanged</code> Boolean value gives a hint54   about the nature of the tuple to be indexed.  When it is true,55   the tuple is a duplicate of some existing tuple in the index.  The56   new tuple is a logically unchanged successor MVCC tuple version.  This57   happens when an <code class="command">UPDATE</code> takes place that does not58   modify any columns covered by the index, but nevertheless requires a59   new version in the index.  The index AM may use this hint to decide60   to apply bottom-up index deletion in parts of the index where many61   versions of the same logical row accumulate.  Note that updating a non-key62   column or a column that only appears in a partial index predicate does not63   affect the value of <code class="literal">indexUnchanged</code>.  The core code64   determines each tuple's <code class="literal">indexUnchanged</code> value using a low65   overhead approach that allows both false positives and false negatives.66   Index AMs must not treat <code class="literal">indexUnchanged</code> as an67   authoritative source of information about tuple visibility or versioning.68  </p><p>69   The function's Boolean result value is significant only when70   <code class="literal">checkUnique</code> is <code class="literal">UNIQUE_CHECK_PARTIAL</code>.71   In this case a true result means the new entry is known unique, whereas72   false means it might be non-unique (and a deferred uniqueness check must73   be scheduled).  For other cases a constant false result is recommended.74  </p><p>75   Some indexes might not index all tuples.  If the tuple is not to be76   indexed, <code class="function">aminsert</code> should just return without doing anything.77  </p><p>78   If the index AM wishes to cache data across successive index insertions79   within an SQL statement, it can allocate space80   in <code class="literal">indexInfo-&gt;ii_Context</code> and store a pointer to the81   data in <code class="literal">indexInfo-&gt;ii_AmCache</code> (which will be NULL82   initially).83  </p><p>84</p><pre class="programlisting">85IndexBulkDeleteResult *86ambulkdelete (IndexVacuumInfo *info,87              IndexBulkDeleteResult *stats,88              IndexBulkDeleteCallback callback,89              void *callback_state);90</pre><p>91   Delete tuple(s) from the index.  This is a <span class="quote">“<span class="quote">bulk delete</span>”</span> operation92   that is intended to be implemented by scanning the whole index and checking93   each entry to see if it should be deleted.94   The passed-in <code class="literal">callback</code> function must be called, in the style95   <code class="literal">callback(<em class="replaceable"><code>TID</code></em>, callback_state) returns bool</code>,96   to determine whether any particular index entry, as identified by its97   referenced TID, is to be deleted.  Must return either NULL or a palloc'd98   struct containing statistics about the effects of the deletion operation.99   It is OK to return NULL if no information needs to be passed on to100   <code class="function">amvacuumcleanup</code>.101  </p><p>102   Because of limited <code class="varname">maintenance_work_mem</code>,103   <code class="function">ambulkdelete</code> might need to be called more than once when many104   tuples are to be deleted.  The <code class="literal">stats</code> argument is the result105   of the previous call for this index (it is NULL for the first call within a106   <code class="command">VACUUM</code> operation).  This allows the AM to accumulate statistics107   across the whole operation.  Typically, <code class="function">ambulkdelete</code> will108   modify and return the same struct if the passed <code class="literal">stats</code> is not109   null.110  </p><p>111</p><pre class="programlisting">112IndexBulkDeleteResult *113amvacuumcleanup (IndexVacuumInfo *info,114                 IndexBulkDeleteResult *stats);115</pre><p>116   Clean up after a <code class="command">VACUUM</code> operation (zero or more117   <code class="function">ambulkdelete</code> calls).  This does not have to do anything118   beyond returning index statistics, but it might perform bulk cleanup119   such as reclaiming empty index pages.  <code class="literal">stats</code> is whatever the120   last <code class="function">ambulkdelete</code> call returned, or NULL if121   <code class="function">ambulkdelete</code> was not called because no tuples needed to be122   deleted.  If the result is not NULL it must be a palloc'd struct.123   The statistics it contains will be used to update <code class="structname">pg_class</code>,124   and will be reported by <code class="command">VACUUM</code> if <code class="literal">VERBOSE</code> is given.125   It is OK to return NULL if the index was not changed at all during the126   <code class="command">VACUUM</code> operation, but otherwise correct stats should127   be returned.128  </p><p>129   <code class="function">amvacuumcleanup</code> will also be called at completion of an130   <code class="command">ANALYZE</code> operation.  In this case <code class="literal">stats</code> is always131   NULL and any return value will be ignored.  This case can be distinguished132   by checking <code class="literal">info-&gt;analyze_only</code>.  It is recommended133   that the access method do nothing except post-insert cleanup in such a134   call, and that only in an autovacuum worker process.135  </p><p>136</p><pre class="programlisting">137bool138amcanreturn (Relation indexRelation, int attno);139</pre><p>140   Check whether the index can support <a class="link" href="indexes-index-only-scans.html" title="11.9. Index-Only Scans and Covering Indexes"><em class="firstterm">index-only scans</em></a> on141   the given column, by returning the column's original indexed value.142   The attribute number is 1-based, i.e., the first column's attno is 1.143   Returns true if supported, else false.144   This function should always return true for included columns145   (if those are supported), since there's little point in an included146   column that can't be retrieved.147   If the access method does not support index-only scans at all,148   the <code class="structfield">amcanreturn</code> field in its <code class="structname">IndexAmRoutine</code>149   struct can be set to NULL.150  </p><p>151</p><pre class="programlisting">152void153amcostestimate (PlannerInfo *root,154                IndexPath *path,155                double loop_count,156                Cost *indexStartupCost,157                Cost *indexTotalCost,158                Selectivity *indexSelectivity,159                double *indexCorrelation,160                double *indexPages);161</pre><p>162   Estimate the costs of an index scan.  This function is described fully163   in <a class="xref" href="index-cost-estimation.html" title="64.6. Index Cost Estimation Functions">Section 64.6</a>, below.164  </p><p>165</p><pre class="programlisting">166bytea *167amoptions (ArrayType *reloptions,168           bool validate);169</pre><p>170   Parse and validate the reloptions array for an index.  This is called only171   when a non-null reloptions array exists for the index.172   <em class="parameter"><code>reloptions</code></em> is a <code class="type">text</code> array containing entries of the173   form <em class="replaceable"><code>name</code></em><code class="literal">=</code><em class="replaceable"><code>value</code></em>.174   The function should construct a <code class="type">bytea</code> value, which will be copied175   into the <code class="structfield">rd_options</code> field of the index's relcache entry.176   The data contents of the <code class="type">bytea</code> value are open for the access177   method to define; most of the standard access methods use struct178   <code class="structname">StdRdOptions</code>.179   When <em class="parameter"><code>validate</code></em> is true, the function should report a suitable180   error message if any of the options are unrecognized or have invalid181   values; when <em class="parameter"><code>validate</code></em> is false, invalid entries should be182   silently ignored.  (<em class="parameter"><code>validate</code></em> is false when loading options183   already stored in <code class="structname">pg_catalog</code>; an invalid entry could only184   be found if the access method has changed its rules for options, and in185   that case ignoring obsolete entries is appropriate.)186   It is OK to return NULL if default behavior is wanted.187  </p><p>188</p><pre class="programlisting">189bool190amproperty (Oid index_oid, int attno,191            IndexAMProperty prop, const char *propname,192            bool *res, bool *isnull);193</pre><p>194   The <code class="function">amproperty</code> method allows index access methods to override195   the default behavior of <code class="function">pg_index_column_has_property</code>196   and related functions.197   If the access method does not have any special behavior for index property198   inquiries, the <code class="structfield">amproperty</code> field in199   its <code class="structname">IndexAmRoutine</code> struct can be set to NULL.200   Otherwise, the <code class="function">amproperty</code> method will be called with201   <em class="parameter"><code>index_oid</code></em> and <em class="parameter"><code>attno</code></em> both zero for202   <code class="function">pg_indexam_has_property</code> calls,203   or with <em class="parameter"><code>index_oid</code></em> valid and <em class="parameter"><code>attno</code></em> zero for204   <code class="function">pg_index_has_property</code> calls,205   or with <em class="parameter"><code>index_oid</code></em> valid and <em class="parameter"><code>attno</code></em> greater than206   zero for <code class="function">pg_index_column_has_property</code> calls.207   <em class="parameter"><code>prop</code></em> is an enum value identifying the property being tested,208   while <em class="parameter"><code>propname</code></em> is the original property name string.209   If the core code does not recognize the property name210   then <em class="parameter"><code>prop</code></em> is <code class="literal">AMPROP_UNKNOWN</code>.211   Access methods can define custom property names by212   checking <em class="parameter"><code>propname</code></em> for a match (use <code class="function">pg_strcasecmp</code>213   to match, for consistency with the core code); for names known to the core214   code, it's better to inspect <em class="parameter"><code>prop</code></em>.215   If the <code class="structfield">amproperty</code> method returns <code class="literal">true</code> then216   it has determined the property test result: it must set <code class="literal">*res</code>217   to the Boolean value to return, or set <code class="literal">*isnull</code>218   to <code class="literal">true</code> to return a NULL.  (Both of the referenced variables219   are initialized to <code class="literal">false</code> before the call.)220   If the <code class="structfield">amproperty</code> method returns <code class="literal">false</code> then221   the core code will proceed with its normal logic for determining the222   property test result.223  </p><p>224   Access methods that support ordering operators should225   implement <code class="literal">AMPROP_DISTANCE_ORDERABLE</code> property testing, as the226   core code does not know how to do that and will return NULL.  It may227   also be advantageous to implement <code class="literal">AMPROP_RETURNABLE</code> testing,228   if that can be done more cheaply than by opening the index and calling229   <code class="function">amcanreturn</code>, which is the core code's default behavior.230   The default behavior should be satisfactory for all other standard231   properties.232  </p><p>233</p><pre class="programlisting">234char *235ambuildphasename (int64 phasenum);236</pre><p>237   Return the textual name of the given build phase number.238   The phase numbers are those reported during an index build via the239   <code class="function">pgstat_progress_update_param</code> interface.240   The phase names are then exposed in the241   <code class="structname">pg_stat_progress_create_index</code> view.242  </p><p>243</p><pre class="programlisting">244bool245amvalidate (Oid opclassoid);246</pre><p>247   Validate the catalog entries for the specified operator class, so far as248   the access method can reasonably do that.  For example, this might include249   testing that all required support functions are provided.250   The <code class="function">amvalidate</code> function must return false if the opclass is251   invalid.  Problems should be reported with <code class="function">ereport</code>252   messages, typically at <code class="literal">INFO</code> level.253  </p><p>254</p><pre class="programlisting">255void256amadjustmembers (Oid opfamilyoid,257                 Oid opclassoid,258                 List *operators,259                 List *functions);260</pre><p>261   Validate proposed new operator and function members of an operator family,262   so far as the access method can reasonably do that, and set their263   dependency types if the default is not satisfactory.  This is called264   during <code class="command">CREATE OPERATOR CLASS</code> and during265   <code class="command">ALTER OPERATOR FAMILY ADD</code>; in the latter266   case <em class="parameter"><code>opclassoid</code></em> is <code class="literal">InvalidOid</code>.267   The <code class="type">List</code> arguments are lists268   of <code class="structname">OpFamilyMember</code> structs, as defined269   in <code class="filename">amapi.h</code>.270 271   Tests done by this function will typically be a subset of those272   performed by <code class="function">amvalidate</code>,273   since <code class="function">amadjustmembers</code> cannot assume that it is274   seeing a complete set of members.  For example, it would be reasonable275   to check the signature of a support function, but not to check whether276   all required support functions are provided.  Any problems can be277   reported by throwing an error.278 279   The dependency-related fields of280   the <code class="structname">OpFamilyMember</code> structs are initialized by281   the core code to create hard dependencies on the opclass if this282   is <code class="command">CREATE OPERATOR CLASS</code>, or soft dependencies on the283   opfamily if this is <code class="command">ALTER OPERATOR FAMILY ADD</code>.284   <code class="function">amadjustmembers</code> can adjust these fields if some other285   behavior is more appropriate.  For example, GIN, GiST, and SP-GiST286   always set operator members to have soft dependencies on the opfamily,287   since the connection between an operator and an opclass is relatively288   weak in these index types; so it is reasonable to allow operator members289   to be added and removed freely.  Optional support functions are typically290   also given soft dependencies, so that they can be removed if necessary.291  </p><p>292   The purpose of an index, of course, is to support scans for tuples matching293   an indexable <code class="literal">WHERE</code> condition, often called a294   <em class="firstterm">qualifier</em> or <em class="firstterm">scan key</em>.  The semantics of295   index scanning are described more fully in <a class="xref" href="index-scanning.html" title="64.3. Index Scanning">Section 64.3</a>,296   below.  An index access method can support <span class="quote">“<span class="quote">plain</span>”</span> index scans,297   <span class="quote">“<span class="quote">bitmap</span>”</span> index scans, or both.  The scan-related functions that an298   index access method must or may provide are:299  </p><p>300</p><pre class="programlisting">301IndexScanDesc302ambeginscan (Relation indexRelation,303             int nkeys,304             int norderbys);305</pre><p>306   Prepare for an index scan.  The <code class="literal">nkeys</code> and <code class="literal">norderbys</code>307   parameters indicate the number of quals and ordering operators that will be308   used in the scan; these may be useful for space allocation purposes.309   Note that the actual values of the scan keys aren't provided yet.310   The result must be a palloc'd struct.311   For implementation reasons the index access method312   <span class="emphasis"><em>must</em></span> create this struct by calling313   <code class="function">RelationGetIndexScan()</code>.  In most cases314   <code class="function">ambeginscan</code> does little beyond making that call and perhaps315   acquiring locks;316   the interesting parts of index-scan startup are in <code class="function">amrescan</code>.317  </p><p>318</p><pre class="programlisting">319void320amrescan (IndexScanDesc scan,321          ScanKey keys,322          int nkeys,323          ScanKey orderbys,324          int norderbys);325</pre><p>326   Start or restart an index scan, possibly with new scan keys.  (To restart327   using previously-passed keys, NULL is passed for <code class="literal">keys</code> and/or328   <code class="literal">orderbys</code>.)  Note that it is not allowed for329   the number of keys or order-by operators to be larger than330   what was passed to <code class="function">ambeginscan</code>.  In practice the restart331   feature is used when a new outer tuple is selected by a nested-loop join332   and so a new key comparison value is needed, but the scan key structure333   remains the same.334  </p><p>335</p><pre class="programlisting">336bool337amgettuple (IndexScanDesc scan,338            ScanDirection direction);339</pre><p>340   Fetch the next tuple in the given scan, moving in the given341   direction (forward or backward in the index).  Returns true if a tuple was342   obtained, false if no matching tuples remain.  In the true case the tuple343   TID is stored into the <code class="literal">scan</code> structure.  Note that344   <span class="quote">“<span class="quote">success</span>”</span> means only that the index contains an entry that matches345   the scan keys, not that the tuple necessarily still exists in the heap or346   will pass the caller's snapshot test.  On success, <code class="function">amgettuple</code>347   must also set <code class="literal">scan-&gt;xs_recheck</code> to true or false.348   False means it is certain that the index entry matches the scan keys.349   True means this is not certain, and the conditions represented by the350   scan keys must be rechecked against the heap tuple after fetching it.351   This provision supports <span class="quote">“<span class="quote">lossy</span>”</span> index operators.352   Note that rechecking will extend only to the scan conditions; a partial353   index predicate (if any) is never rechecked by <code class="function">amgettuple</code>354   callers.355  </p><p>356   If the index supports <a class="link" href="indexes-index-only-scans.html" title="11.9. Index-Only Scans and Covering Indexes">index-only357   scans</a> (i.e., <code class="function">amcanreturn</code> returns true for any358   of its columns),359   then on success the AM must also check <code class="literal">scan-&gt;xs_want_itup</code>,360   and if that is true it must return the originally indexed data for the361   index entry.  Columns for which <code class="function">amcanreturn</code> returns362   false can be returned as nulls.363   The data can be returned in the form of an364   <code class="structname">IndexTuple</code> pointer stored at <code class="literal">scan-&gt;xs_itup</code>,365   with tuple descriptor <code class="literal">scan-&gt;xs_itupdesc</code>; or in the form of366   a <code class="structname">HeapTuple</code> pointer stored at <code class="literal">scan-&gt;xs_hitup</code>,367   with tuple descriptor <code class="literal">scan-&gt;xs_hitupdesc</code>.  (The latter368   format should be used when reconstructing data that might possibly not fit369   into an <code class="structname">IndexTuple</code>.)  In either case,370   management of the data referenced by the pointer is the access method's371   responsibility.  The data must remain good at least until the next372   <code class="function">amgettuple</code>, <code class="function">amrescan</code>, or <code class="function">amendscan</code>373   call for the scan.374  </p><p>375   The <code class="function">amgettuple</code> function need only be provided if the access376   method supports <span class="quote">“<span class="quote">plain</span>”</span> index scans.  If it doesn't, the377   <code class="structfield">amgettuple</code> field in its <code class="structname">IndexAmRoutine</code>378   struct must be set to NULL.379  </p><p>380</p><pre class="programlisting">381int64382amgetbitmap (IndexScanDesc scan,383             TIDBitmap *tbm);384</pre><p>385   Fetch all tuples in the given scan and add them to the caller-supplied386   <code class="type">TIDBitmap</code> (that is, OR the set of tuple IDs into whatever set is already387   in the bitmap).  The number of tuples fetched is returned (this might be388   just an approximate count, for instance some AMs do not detect duplicates).389   While inserting tuple IDs into the bitmap, <code class="function">amgetbitmap</code> can390   indicate that rechecking of the scan conditions is required for specific391   tuple IDs.  This is analogous to the <code class="literal">xs_recheck</code> output parameter392   of <code class="function">amgettuple</code>.  Note: in the current implementation, support393   for this feature is conflated with support for lossy storage of the bitmap394   itself, and therefore callers recheck both the scan conditions and the395   partial index predicate (if any) for recheckable tuples.  That might not396   always be true, however.397   <code class="function">amgetbitmap</code> and398   <code class="function">amgettuple</code> cannot be used in the same index scan; there399   are other restrictions too when using <code class="function">amgetbitmap</code>, as explained400   in <a class="xref" href="index-scanning.html" title="64.3. Index Scanning">Section 64.3</a>.401  </p><p>402   The <code class="function">amgetbitmap</code> function need only be provided if the access403   method supports <span class="quote">“<span class="quote">bitmap</span>”</span> index scans.  If it doesn't, the404   <code class="structfield">amgetbitmap</code> field in its <code class="structname">IndexAmRoutine</code>405   struct must be set to NULL.406  </p><p>407</p><pre class="programlisting">408void409amendscan (IndexScanDesc scan);410</pre><p>411   End a scan and release resources.  The <code class="literal">scan</code> struct itself412   should not be freed, but any locks or pins taken internally by the413   access method must be released, as well as any other memory allocated414   by <code class="function">ambeginscan</code> and other scan-related functions.415  </p><p>416</p><pre class="programlisting">417void418ammarkpos (IndexScanDesc scan);419</pre><p>420   Mark current scan position.  The access method need only support one421   remembered scan position per scan.422  </p><p>423   The <code class="function">ammarkpos</code> function need only be provided if the access424   method supports ordered scans.  If it doesn't,425   the <code class="structfield">ammarkpos</code> field in its <code class="structname">IndexAmRoutine</code>426   struct may be set to NULL.427  </p><p>428</p><pre class="programlisting">429void430amrestrpos (IndexScanDesc scan);431</pre><p>432   Restore the scan to the most recently marked position.433  </p><p>434   The <code class="function">amrestrpos</code> function need only be provided if the access435   method supports ordered scans.  If it doesn't,436   the <code class="structfield">amrestrpos</code> field in its <code class="structname">IndexAmRoutine</code>437   struct may be set to NULL.438  </p><p>439   In addition to supporting ordinary index scans, some types of index440   may wish to support <em class="firstterm">parallel index scans</em>, which allow441   multiple backends to cooperate in performing an index scan.  The442   index access method should arrange things so that each cooperating443   process returns a subset of the tuples that would be performed by444   an ordinary, non-parallel index scan, but in such a way that the445   union of those subsets is equal to the set of tuples that would be446   returned by an ordinary, non-parallel index scan.  Furthermore, while447   there need not be any global ordering of tuples returned by a parallel448   scan, the ordering of that subset of tuples returned within each449   cooperating backend must match the requested ordering.  The following450   functions may be implemented to support parallel index scans:451  </p><p>452</p><pre class="programlisting">453Size454amestimateparallelscan (void);455</pre><p>456   Estimate and return the number of bytes of dynamic shared memory which457   the access method will be needed to perform a parallel scan.  (This number458   is in addition to, not in lieu of, the amount of space needed for459   AM-independent data in <code class="structname">ParallelIndexScanDescData</code>.)460  </p><p>461   It is not necessary to implement this function for access methods which462   do not support parallel scans or for which the number of additional bytes463   of storage required is zero.464  </p><p>465</p><pre class="programlisting">466void467aminitparallelscan (void *target);468</pre><p>469   This function will be called to initialize dynamic shared memory at the470   beginning of a parallel scan.  <em class="parameter"><code>target</code></em> will point to at least471   the number of bytes previously returned by472   <code class="function">amestimateparallelscan</code>, and this function may use that473   amount of space to store whatever data it wishes.474  </p><p>475   It is not necessary to implement this function for access methods which476   do not support parallel scans or in cases where the shared memory space477   required needs no initialization.478  </p><p>479</p><pre class="programlisting">480void481amparallelrescan (IndexScanDesc scan);482</pre><p>483   This function, if implemented, will be called when a parallel index scan484   must be restarted.  It should reset any shared state set up by485   <code class="function">aminitparallelscan</code> such that the scan will be restarted from486   the beginning.487  </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="index-api.html" title="64.1. Basic API Structure for Indexes">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="indexam.html" title="Chapter 64. Index Access Method Interface Definition">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="index-scanning.html" title="64.3. Index Scanning">Next</a></td></tr><tr><td width="40%" align="left" valign="top">64.1. Basic API Structure for Indexes </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 64.3. Index Scanning</td></tr></table></div></body></html>
codekingpro/portable-devtools · Team Ai