@@ -119,7 +119,7 @@ typedef enum
119119} PartType ;
120120
121121/*
122- * Child relation info for RANGE partitioning
122+ * Child relation info for RANGE partitioning.
123123 */
124124typedef struct
125125{
@@ -130,34 +130,38 @@ typedef struct
130130
131131/*
132132 * PartRelationInfo
133- * Per-relation partitioning information
133+ * Per-relation partitioning information.
134+ * Allows us to perform partition pruning.
134135 */
135136typedef struct
136137{
137138 Oid key ; /* partitioned table's Oid */
138- bool valid ; /* is this entry valid? */
139- bool enable_parent ; /* include parent to the plan */
139+ bool valid , /* is this entry valid? */
140+ enable_parent ; /* should plan include parent? */
140141
141142 PartType parttype ; /* partitioning type (HASH | RANGE) */
142143
144+ /* Partition dispatch info */
143145 uint32 children_count ;
144146 Oid * children ; /* Oids of child partitions */
145147 RangeEntry * ranges ; /* per-partition range entry or NULL */
146148
149+ /* Partitioning expression */
147150 const char * expr_cstr ; /* original expression */
148151 Node * expr ; /* planned expression */
149152 List * expr_vars ; /* vars from expression, lazy */
150153 Bitmapset * expr_atts ; /* attnums from expression */
151154
152- Oid atttype ; /* expression type */
153- int32 atttypmod ; /* expression type modifier */
154- bool attbyval ; /* is partitioned column stored by value? */
155- int16 attlen ; /* length of the partitioned column's type */
156- int attalign ; /* alignment of the part column's type */
157- Oid attcollid ; /* collation of the partitioned column */
155+ /* Partitioning expression's value */
156+ Oid ev_type ; /* expression type */
157+ int32 ev_typmod ; /* expression type modifier */
158+ bool ev_byval ; /* is expression's val stored by value? */
159+ int16 ev_len ; /* length of the expression val's type */
160+ int ev_align ; /* alignment of the expression val's type */
161+ Oid ev_collid ; /* collation of the expression val */
158162
159- Oid cmp_proc , /* comparison fuction for 'atttype ' */
160- hash_proc ; /* hash function for 'atttype ' */
163+ Oid cmp_proc , /* comparison fuction for 'ev_type ' */
164+ hash_proc ; /* hash function for 'ev_type ' */
161165} PartRelationInfo ;
162166
163167#define PART_EXPR_VARNO ( 1 )
@@ -176,6 +180,7 @@ typedef struct
176180/*
177181 * PartBoundInfo
178182 * Cached bounds of the specified partition.
183+ * Allows us to deminish overhead of check constraints.
179184 */
180185typedef struct
181186{
@@ -255,6 +260,7 @@ PrelExpressionForRelid(const PartRelationInfo *prel, Index rel_index)
255260{
256261 Node * expr ;
257262
263+ /* TODO: implement some kind of cache */
258264 if (rel_index != PART_EXPR_VARNO )
259265 {
260266 expr = copyObject (prel -> expr );
@@ -360,7 +366,7 @@ FreeRangesArray(PartRelationInfo *prel)
360366 if (prel -> ranges )
361367 {
362368 /* Remove persistent entries if not byVal */
363- if (!prel -> attbyval )
369+ if (!prel -> ev_byval )
364370 {
365371 for (i = 0 ; i < PrelChildrenCount (prel ); i ++ )
366372 {
@@ -370,8 +376,8 @@ FreeRangesArray(PartRelationInfo *prel)
370376 if (!OidIsValid (child ))
371377 continue ;
372378
373- FreeBound (& prel -> ranges [i ].min , prel -> attbyval );
374- FreeBound (& prel -> ranges [i ].max , prel -> attbyval );
379+ FreeBound (& prel -> ranges [i ].min , prel -> ev_byval );
380+ FreeBound (& prel -> ranges [i ].max , prel -> ev_byval );
375381 }
376382 }
377383
0 commit comments