summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/src/sgml/indexam.sgml3
-rw-r--r--src/backend/access/spgist/spgscan.c8
2 files changed, 10 insertions, 1 deletions
diff --git a/doc/src/sgml/indexam.sgml b/doc/src/sgml/indexam.sgml
index 157047a23ab..faf890abd61 100644
--- a/doc/src/sgml/indexam.sgml
+++ b/doc/src/sgml/indexam.sgml
@@ -455,7 +455,8 @@ amendscan (IndexScanDesc scan);
</programlisting>
End a scan and release resources. The <literal>scan</> struct itself
should not be freed, but any locks or pins taken internally by the
- access method must be released.
+ access method must be released, as well as any other memory allocated
+ by <function>ambeginscan</function> and other scan-related functions.
</para>
<para>
diff --git a/src/backend/access/spgist/spgscan.c b/src/backend/access/spgist/spgscan.c
index 35cc41b3aab..21871dbfc1d 100644
--- a/src/backend/access/spgist/spgscan.c
+++ b/src/backend/access/spgist/spgscan.c
@@ -236,6 +236,14 @@ spgendscan(PG_FUNCTION_ARGS)
MemoryContextDelete(so->tempCxt);
+ if (so->keyData)
+ pfree(so->keyData);
+
+ if (so->state.deadTupleStorage)
+ pfree(so->state.deadTupleStorage);
+
+ pfree(so);
+
PG_RETURN_VOID();
}