@@ -135,22 +135,22 @@ get_selectivities(PlannerInfo *root,
135
135
/*
136
136
* Based on the hashTupleDesc() routine
137
137
*/
138
- static uint64
138
+ static uint32
139
139
hashTempTupleDesc (TupleDesc desc )
140
140
{
141
- uint64 s ;
141
+ uint32 s ;
142
142
int i ;
143
143
144
144
s = hash_combine (0 , hash_uint32 (desc -> natts ));
145
145
146
146
for (i = 0 ; i < desc -> natts ; ++ i )
147
147
{
148
148
const char * attname = NameStr (TupleDescAttr (desc , i )-> attname );
149
- uint64 s1 ;
149
+ uint32 s1 ;
150
150
151
- s = hash_combine64 (s , hash_uint32 (TupleDescAttr (desc , i )-> atttypid ));
152
- s1 = hash_bytes_extended ((const unsigned char * ) attname , strlen (attname ), 0 );
153
- s = hash_combine64 (s , s1 );
151
+ s = hash_combine (s , hash_uint32 (TupleDescAttr (desc , i )-> atttypid ));
152
+ s1 = hash_bytes ((const unsigned char * ) attname , strlen (attname ));
153
+ s = hash_combine (s , s1 );
154
154
}
155
155
return s ;
156
156
}
@@ -186,8 +186,8 @@ get_list_of_relids(PlannerInfo *root, Relids relids, RelSortOut *rels)
186
186
187
187
if (!OidIsValid (entry -> relid ))
188
188
{
189
- /* Invalid oid */
190
- hashes = lappend_uint64 (hashes , ( UINT64_MAX / 7 ) );
189
+ /* TODO: Explain this logic. */
190
+ hashes = lappend_int (hashes , INT32_MAX / 3 );
191
191
continue ;
192
192
}
193
193
@@ -212,7 +212,7 @@ get_list_of_relids(PlannerInfo *root, Relids relids, RelSortOut *rels)
212
212
trel = relation_open (entry -> relid , NoLock );
213
213
tdesc = RelationGetDescr (trel );
214
214
Assert (CheckRelationLockedByMe (trel , AccessShareLock , true));
215
- hashes = lappend_uint64 (hashes , hashTempTupleDesc (tdesc ));
215
+ hashes = lappend_int (hashes , hashTempTupleDesc (tdesc ));
216
216
relation_close (trel , NoLock );
217
217
}
218
218
else
@@ -222,9 +222,9 @@ get_list_of_relids(PlannerInfo *root, Relids relids, RelSortOut *rels)
222
222
get_namespace_name (get_rel_namespace (entry -> relid )),
223
223
relrewrite ? get_rel_name (relrewrite ) : relname );
224
224
225
- hashes = lappend_uint64 (hashes , DatumGetInt64 ( hash_any_extended (
225
+ hashes = lappend_int (hashes , DatumGetInt32 ( hash_any (
226
226
(unsigned char * ) relname ,
227
- strlen (relname ), 0 )));
227
+ strlen (relname ))));
228
228
229
229
hrels = lappend_oid (hrels , entry -> relid );
230
230
}
@@ -591,7 +591,7 @@ AQOnodeCopy(struct ExtensibleNode *enew, const struct ExtensibleNode *eold)
591
591
/* These lists couldn't contain AQO nodes. Use basic machinery */
592
592
new -> rels = palloc (sizeof (RelSortOut ));
593
593
new -> rels -> hrels = list_copy (old -> rels -> hrels );
594
- new -> rels -> signatures = list_copy_uint64 (old -> rels -> signatures );
594
+ new -> rels -> signatures = list_copy (old -> rels -> signatures );
595
595
596
596
new -> clauses = copyObject (old -> clauses );
597
597
new -> grouping_exprs = copyObject (old -> grouping_exprs );
@@ -626,21 +626,24 @@ AQOnodeEqual(const struct ExtensibleNode *a, const struct ExtensibleNode *b)
626
626
#define WRITE_FLOAT_FIELD (fldname ,format ) \
627
627
appendStringInfo(str, " :" CppAsString(fldname) " " format, node->fldname)
628
628
629
+ /*
630
+ * Serialize AQO plan node to a string.
631
+ *
632
+ * Right now we can't correctly serialize all fields of the node. Taking into
633
+ * account that this action needed when a plan moves into parallel workers or
634
+ * just during debugging, we serialize it only partially, just for debug
635
+ * purposes.
636
+ * Some extensions may manipulate by parts of serialized plan too.
637
+ */
629
638
static void
630
639
AQOnodeOut (struct StringInfoData * str , const struct ExtensibleNode * enode )
631
640
{
632
641
AQOPlanNode * node = (AQOPlanNode * ) enode ;
633
642
634
- Assert (0 );
635
- WRITE_BOOL_FIELD (had_path );
636
- WRITE_NODE_FIELD (rels );
637
- WRITE_NODE_FIELD (clauses );
638
- WRITE_NODE_FIELD (selectivities );
639
- WRITE_NODE_FIELD (grouping_exprs );
640
-
641
- WRITE_ENUM_FIELD (jointype , JoinType );
642
- WRITE_FLOAT_FIELD (parallel_divisor , "%.5f" );
643
- WRITE_BOOL_FIELD (was_parametrized );
643
+ node -> had_path = false;
644
+ node -> jointype = 0 ;
645
+ node -> parallel_divisor = 1.0 ;
646
+ node -> was_parametrized = false;
644
647
645
648
/* For Adaptive optimization DEBUG purposes */
646
649
WRITE_INT_FIELD (fss );
@@ -677,24 +680,28 @@ AQOnodeOut(struct StringInfoData *str, const struct ExtensibleNode *enode)
677
680
(void ) token ; /* in case not used elsewhere */ \
678
681
local_node -> fldname = nodeRead (NULL , 0 )
679
682
683
+ /*
684
+ * Deserialize AQO plan node from a string to internal representation.
685
+ *
686
+ * Should work in coherence with AQOnodeOut().
687
+ */
680
688
static void
681
689
AQOnodeRead (struct ExtensibleNode * enode )
682
690
{
683
691
AQOPlanNode * local_node = (AQOPlanNode * ) enode ;
684
692
const char * token ;
685
693
int length ;
686
694
687
- Assert (0 );
688
695
READ_BOOL_FIELD (had_path );
689
- READ_NODE_FIELD (rels );
690
- READ_NODE_FIELD (clauses );
691
- READ_NODE_FIELD (selectivities );
692
- READ_NODE_FIELD (grouping_exprs );
693
-
694
696
READ_ENUM_FIELD (jointype , JoinType );
695
697
READ_FLOAT_FIELD (parallel_divisor );
696
698
READ_BOOL_FIELD (was_parametrized );
697
699
700
+ local_node -> rels = palloc0 (sizeof (RelSortOut ));
701
+ local_node -> clauses = NIL ;
702
+ local_node -> selectivities = NIL ;
703
+ local_node -> grouping_exprs = NIL ;
704
+
698
705
/* For Adaptive optimization DEBUG purposes */
699
706
READ_INT_FIELD (fss );
700
707
READ_FLOAT_FIELD (prediction );
0 commit comments