Skip to content

Commit caa9e3d

Browse files
committed
tried to free
1 parent eb68823 commit caa9e3d

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

src/backend/access/smerge/smsort.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -824,8 +824,19 @@ sm_flush(Relation heapRel, SmMetadata* metadata) {
824824
_bt_spool(btspools[j], &(scan->xs_itup->t_tid), values, isnull);
825825
}
826826

827+
SmScanOpaque so = (SmScanOpaque) scan->opaque;
828+
827829
index_endscan(scan);
828-
index_close(indexRel, ExclusiveLock);
830+
if (so->bt_rel != NULL) {
831+
index_close(so->bt_rel, ExclusiveLock);
832+
pfree(so->bt_rel);
833+
so->bt_rel = NULL;
834+
}
835+
/* Release metadata */
836+
if (so->metadata != NULL)
837+
pfree(so->metadata);
838+
839+
pfree(so);
829840

830841

831842
tuplesort_performsort(btspools[j]->sortstate);
@@ -944,9 +955,19 @@ sm_flush(Relation heapRel, SmMetadata* metadata) {
944955
_bt_spool(btspools[j], &(scan->xs_itup->t_tid), values, isnull);
945956
}
946957

958+
SmScanOpaque so = (SmScanOpaque) scan->opaque;
959+
947960
index_endscan(scan);
948-
index_close(indexRel, ExclusiveLock);
961+
if (so->bt_rel != NULL) {
962+
index_close(so->bt_rel, ExclusiveLock);
963+
pfree(so->bt_rel);
964+
so->bt_rel = NULL;
965+
}
966+
/* Release metadata */
967+
if (so->metadata != NULL)
968+
pfree(so->metadata);
949969

970+
pfree(so);
950971

951972
tuplesort_performsort(btspools[j]->sortstate);
952973
}

0 commit comments

Comments
 (0)