@@ -130,22 +130,22 @@ get_selectivities(PlannerInfo *root,
130
130
/*
131
131
* Based on the hashTupleDesc() routine
132
132
*/
133
- static uint64
133
+ static uint32
134
134
hashTempTupleDesc (TupleDesc desc )
135
135
{
136
- uint64 s ;
136
+ uint32 s ;
137
137
int i ;
138
138
139
139
s = hash_combine (0 , hash_uint32 (desc -> natts ));
140
140
141
141
for (i = 0 ; i < desc -> natts ; ++ i )
142
142
{
143
143
const char * attname = NameStr (TupleDescAttr (desc , i )-> attname );
144
- uint64 s1 ;
144
+ uint32 s1 ;
145
145
146
- s = hash_combine64 (s , hash_uint32 (TupleDescAttr (desc , i )-> atttypid ));
147
- s1 = hash_bytes_extended ((const unsigned char * ) attname , strlen (attname ), 0 );
148
- s = hash_combine64 (s , s1 );
146
+ s = hash_combine (s , hash_uint32 (TupleDescAttr (desc , i )-> atttypid ));
147
+ s1 = hash_bytes ((const unsigned char * ) attname , strlen (attname ));
148
+ s = hash_combine (s , s1 );
149
149
}
150
150
return s ;
151
151
}
@@ -181,8 +181,8 @@ get_list_of_relids(PlannerInfo *root, Relids relids, RelSortOut *rels)
181
181
182
182
if (!OidIsValid (entry -> relid ))
183
183
{
184
- /* Invalid oid */
185
- hashes = lappend_uint64 (hashes , ( UINT64_MAX / 7 ) );
184
+ /* TODO: Explain this logic. */
185
+ hashes = lappend_int (hashes , INT32_MAX / 3 );
186
186
continue ;
187
187
}
188
188
@@ -207,7 +207,7 @@ get_list_of_relids(PlannerInfo *root, Relids relids, RelSortOut *rels)
207
207
trel = relation_open (entry -> relid , NoLock );
208
208
tdesc = RelationGetDescr (trel );
209
209
Assert (CheckRelationLockedByMe (trel , AccessShareLock , true));
210
- hashes = lappend_uint64 (hashes , hashTempTupleDesc (tdesc ));
210
+ hashes = lappend_int (hashes , hashTempTupleDesc (tdesc ));
211
211
relation_close (trel , NoLock );
212
212
}
213
213
else
@@ -217,9 +217,9 @@ get_list_of_relids(PlannerInfo *root, Relids relids, RelSortOut *rels)
217
217
get_namespace_name (get_rel_namespace (entry -> relid )),
218
218
relrewrite ? get_rel_name (relrewrite ) : relname );
219
219
220
- hashes = lappend_uint64 (hashes , DatumGetInt64 ( hash_any_extended (
220
+ hashes = lappend_int (hashes , DatumGetInt32 ( hash_any (
221
221
(unsigned char * ) relname ,
222
- strlen (relname ), 0 )));
222
+ strlen (relname ))));
223
223
224
224
hrels = lappend_oid (hrels , entry -> relid );
225
225
}
@@ -569,7 +569,7 @@ AQOnodeCopy(struct ExtensibleNode *enew, const struct ExtensibleNode *eold)
569
569
/* These lists couldn't contain AQO nodes. Use basic machinery */
570
570
new -> rels = palloc (sizeof (RelSortOut ));
571
571
new -> rels -> hrels = list_copy (old -> rels -> hrels );
572
- new -> rels -> signatures = list_copy_uint64 (old -> rels -> signatures );
572
+ new -> rels -> signatures = list_copy (old -> rels -> signatures );
573
573
574
574
new -> clauses = copyObject (old -> clauses );
575
575
new -> grouping_exprs = copyObject (old -> grouping_exprs );
@@ -604,21 +604,24 @@ AQOnodeEqual(const struct ExtensibleNode *a, const struct ExtensibleNode *b)
604
604
#define WRITE_FLOAT_FIELD (fldname ,format ) \
605
605
appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
606
606
607
+ /*
608
+ * Serialize AQO plan node to a string.
609
+ *
610
+ * Right now we can't correctly serialize all fields of the node. Taking into
611
+ * account that this action needed when a plan moves into parallel workers or
612
+ * just during debugging, we serialize it only partially, just for debug
613
+ * purposes.
614
+ * Some extensions may manipulate by parts of serialized plan too.
615
+ */
607
616
static void
608
617
AQOnodeOut (struct StringInfoData * str , const struct ExtensibleNode * enode )
609
618
{
610
619
AQOPlanNode * node = (AQOPlanNode * ) enode ;
611
620
612
- Assert (0 );
613
- WRITE_BOOL_FIELD (had_path );
614
- WRITE_NODE_FIELD (rels );
615
- WRITE_NODE_FIELD (clauses );
616
- WRITE_NODE_FIELD (selectivities );
617
- WRITE_NODE_FIELD (grouping_exprs );
618
-
619
- WRITE_ENUM_FIELD (jointype , JoinType );
620
- WRITE_FLOAT_FIELD (parallel_divisor , "%.5f" );
621
- WRITE_BOOL_FIELD (was_parametrized );
621
+ node -> had_path = false;
622
+ node -> jointype = 0 ;
623
+ node -> parallel_divisor = 1.0 ;
624
+ node -> was_parametrized = false;
622
625
623
626
/* For Adaptive optimization DEBUG purposes */
624
627
WRITE_INT_FIELD (fss );
@@ -655,24 +658,28 @@ AQOnodeOut(struct StringInfoData *str, const struct ExtensibleNode *enode)
655
658
(void ) token ; /* in case not used elsewhere */ \
656
659
local_node -> fldname = nodeRead (NULL , 0 )
657
660
661
+ /*
662
+ * Deserialize AQO plan node from a string to internal representation.
663
+ *
664
+ * Should work in coherence with AQOnodeOut().
665
+ */
658
666
static void
659
667
AQOnodeRead (struct ExtensibleNode * enode )
660
668
{
661
669
AQOPlanNode * local_node = (AQOPlanNode * ) enode ;
662
670
const char * token ;
663
671
int length ;
664
672
665
- Assert (0 );
666
673
READ_BOOL_FIELD (had_path );
667
- READ_NODE_FIELD (rels );
668
- READ_NODE_FIELD (clauses );
669
- READ_NODE_FIELD (selectivities );
670
- READ_NODE_FIELD (grouping_exprs );
671
-
672
674
READ_ENUM_FIELD (jointype , JoinType );
673
675
READ_FLOAT_FIELD (parallel_divisor );
674
676
READ_BOOL_FIELD (was_parametrized );
675
677
678
+ local_node -> rels = palloc0 (sizeof (RelSortOut ));
679
+ local_node -> clauses = NIL ;
680
+ local_node -> selectivities = NIL ;
681
+ local_node -> grouping_exprs = NIL ;
682
+
676
683
/* For Adaptive optimization DEBUG purposes */
677
684
READ_INT_FIELD (fss );
678
685
READ_FLOAT_FIELD (prediction );
0 commit comments