Hi, Peter and Richard On Thu, 01 May 2025 at 12:13, Peter Eisentraut <pe...@eisentraut.org> wrote: > On 30.04.25 17:48, Japin Li wrote: >> While working on [1], I found outdated comments in IndexInfo. >> The attached patch corrects them. >> [1] >> https://www.postgresql.org/message-id/2A40921D-83AB-411E-ADA6-7E509A46F1E4%40logansw.com > > Maybe these per-column comments should be moved inline, similar to, > for example, ResultRelInfo later in the file. That would make > maintaining them easier.
Thank you for the review. The v2 patch set is attached. v2-0001 remains unchanged; v2-0002 has been modified according to your feedback. -- Regrads, Japin Li
>From 5b5065c2c63c8bbe808aae0645e0534e8aee5f24 Mon Sep 17 00:00:00 2001 From: Japin Li <japi...@hotmail.com> Date: Wed, 30 Apr 2025 23:33:04 +0800 Subject: [PATCH v2 1/2] Fix outdated comments for IndexInfo * Commit 78416235713 removed the ii_OpclassOptions field. * Commit 94aa7cc5f70 added the ii_NullsNotDistinct field. * Commit fc0438b4e80 added the ii_WithoutOverlaps field. All previous comments were not updated accordingly. --- src/include/nodes/execnodes.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 5b6cadb5a6c..076ffa45d60 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -174,13 +174,14 @@ typedef struct ExprState * UniqueProcs * UniqueStrats * Unique is it a unique index? - * OpclassOptions opclass-specific options, or NULL if none + * NullsNotDistinct is unique nulls distinct? * ReadyForInserts is it valid for inserts? * CheckedUnchanged IndexUnchanged status determined yet? * IndexUnchanged aminsert hint, cached for retail inserts * Concurrent are we doing a concurrent index build? * BrokenHotChain did we detect any broken HOT chains? * Summarizing is it a summarizing index? + * WithoutOverlaps is it a without overlaps index? * ParallelWorkers # of workers requested (excludes leader) * Am Oid of index AM * AmCache private cache area for index AM -- 2.43.0
>From 77fafd7e2225de84c28b5d24f904cc877a66d067 Mon Sep 17 00:00:00 2001 From: Japin Li <japi...@hotmail.com> Date: Thu, 1 May 2025 21:32:20 +0800 Subject: [PATCH v2 2/2] Use per-column comments for IndexInfo --- src/include/nodes/execnodes.h | 64 +++++++++++++++++------------------ 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 076ffa45d60..09db43fffd3 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -158,35 +158,6 @@ typedef struct ExprState * entries for a particular index. Used for both index_build and * retail creation of index entries. * - * NumIndexAttrs total number of columns in this index - * NumIndexKeyAttrs number of key columns in index - * IndexAttrNumbers underlying-rel attribute numbers used as keys - * (zeroes indicate expressions). It also contains - * info about included columns. - * Expressions expr trees for expression entries, or NIL if none - * ExpressionsState exec state for expressions, or NIL if none - * Predicate partial-index predicate, or NIL if none - * PredicateState exec state for predicate, or NIL if none - * ExclusionOps Per-column exclusion operators, or NULL if none - * ExclusionProcs Underlying function OIDs for ExclusionOps - * ExclusionStrats Opclass strategy numbers for ExclusionOps - * UniqueOps These are like Exclusion*, but for unique indexes - * UniqueProcs - * UniqueStrats - * Unique is it a unique index? - * NullsNotDistinct is unique nulls distinct? - * ReadyForInserts is it valid for inserts? - * CheckedUnchanged IndexUnchanged status determined yet? - * IndexUnchanged aminsert hint, cached for retail inserts - * Concurrent are we doing a concurrent index build? - * BrokenHotChain did we detect any broken HOT chains? - * Summarizing is it a summarizing index? - * WithoutOverlaps is it a without overlaps index? - * ParallelWorkers # of workers requested (excludes leader) - * Am Oid of index AM - * AmCache private cache area for index AM - * Context memory context holding this IndexInfo - * * ii_Concurrent, ii_BrokenHotChain, and ii_ParallelWorkers are used only * during index build; they're conventionally zeroed otherwise. * ---------------- @@ -196,30 +167,59 @@ typedef struct IndexInfo NodeTag type; int ii_NumIndexAttrs; /* total number of columns in index */ int ii_NumIndexKeyAttrs; /* number of key columns in index */ + /* + * Underlying-rel attribute numbers used as keys (zeroes indicate + * expressions). It also contains info about included columns. + */ AttrNumber ii_IndexAttrNumbers[INDEX_MAX_KEYS]; + + /* expr trees for expression entries, or NIL if none */ List *ii_Expressions; /* list of Expr */ + /* exec state for expressions, or NIL if none */ List *ii_ExpressionsState; /* list of ExprState */ + + /* partial-index predicate, or NIL if none */ List *ii_Predicate; /* list of Expr */ + /* exec state for expressions, or NIL if none */ ExprState *ii_PredicateState; + + /* Per-column exclusion operators, or NULL if none */ Oid *ii_ExclusionOps; /* array with one entry per column */ + /* Underlying function OIDs for ExclusionOps */ Oid *ii_ExclusionProcs; /* array with one entry per column */ + /* Opclass strategy numbers for ExclusionOps */ uint16 *ii_ExclusionStrats; /* array with one entry per column */ + + /* These are like Exclusion*, but for unique indexes */ Oid *ii_UniqueOps; /* array with one entry per column */ Oid *ii_UniqueProcs; /* array with one entry per column */ uint16 *ii_UniqueStrats; /* array with one entry per column */ + + /* is it a unique index? */ bool ii_Unique; + /* is unique nulls distinct? */ bool ii_NullsNotDistinct; + /* is it valid for inserts? */ bool ii_ReadyForInserts; + /* IndexUnchanged status determined yet? */ bool ii_CheckedUnchanged; + /* aminsert hint, cached for retail inserts */ bool ii_IndexUnchanged; + /* are we doing a concurrent index build? */ bool ii_Concurrent; + /* did we detect any broken HOT chains? */ bool ii_BrokenHotChain; + /* is it a summarizing index? */ bool ii_Summarizing; + /* is it a without overlaps index? */ bool ii_WithoutOverlaps; + /* # of workers requested (excludes leader) */ int ii_ParallelWorkers; - Oid ii_Am; - void *ii_AmCache; - MemoryContext ii_Context; + + Oid ii_Am; /* Oid of index AM */ + void *ii_AmCache; /* private cache area for index AM */ + + MemoryContext ii_Context; /* memory context holding this IndexInfo */ } IndexInfo; /* ---------------- -- 2.43.0