Skip to content

Commit 1d11dc5

Browse files
committed
Bugfix. Implement deep copy of uint64 list.
Each element here is dynamically allocated in some memory context. If we copy the list in another memctx we should allocate memory for new elements too.
1 parent 80bcf2d commit 1d11dc5

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

‎hash.c

+23
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,29 @@ list_member_uint64(const List *list, uint64 datum)
9898
return false;
9999
}
100100

101+
/*
102+
* Deep copy of uint64 list.
103+
* Each element here is dynamically allocated in some memory context.
104+
* If we copy the list in another memctx we should allocate memory for new
105+
* elements too.
106+
*/
107+
List *
108+
list_copy_uint64(List *list)
109+
{
110+
ListCell *lc;
111+
List *nlist = NIL;
112+
113+
foreach(lc, list)
114+
{
115+
uint64 *val = palloc(sizeof(uint64));
116+
117+
*val = *(uint64 *) lfirst(lc);
118+
nlist = lappend(nlist, (void *) val);
119+
}
120+
121+
return nlist;
122+
}
123+
101124
List *
102125
lappend_uint64(List *list, uint64 datum)
103126
{

‎hash.h

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
extern uint64 get_query_hash(Query *parse, const char *query_text);
77
extern bool list_member_uint64(const List *list, uint64 datum);
8+
extern List *list_copy_uint64(List *list);
89
extern List *lappend_uint64(List *list, uint64 datum);
910
extern List *ldelete_uint64(List *list, uint64 datum);
1011
extern int get_fss_for_object(List *relsigns, List *clauselist,

‎path_utils.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ AQOnodeCopy(struct ExtensibleNode *enew, const struct ExtensibleNode *eold)
578578
/* These lists couldn't contain AQO nodes. Use basic machinery */
579579
new->rels = palloc(sizeof(RelSortOut));
580580
new->rels->hrels = list_copy(old->rels->hrels);
581-
new->rels->signatures = list_copy(old->rels->signatures);
581+
new->rels->signatures = list_copy_uint64(old->rels->signatures);
582582

583583
new->clauses = copyObject(old->clauses);
584584
new->grouping_exprs = copyObject(old->grouping_exprs);

0 commit comments

Comments
 (0)