From 821b821a2421beaa58225ff000833df69fb962c5 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 23 May 2015 15:22:25 -0400 Subject: Still more fixes for lossy-GiST-distance-functions patch. Fix confusion in documentation, substantial memory leakage if float8 or float4 are pass-by-reference, and assorted comments that were obsoleted by commit 98edd617f3b62a02cb2df9b418fcc4ece45c7ec0. --- src/backend/access/gist/gistscan.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/backend/access/gist/gistscan.c') diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c index d0fea2b86ce..beb402357c0 100644 --- a/src/backend/access/gist/gistscan.c +++ b/src/backend/access/gist/gistscan.c @@ -88,8 +88,9 @@ gistbeginscan(PG_FUNCTION_ARGS) so->qual_ok = true; /* in case there are zero keys */ if (scan->numberOfOrderBys > 0) { - scan->xs_orderbyvals = palloc(sizeof(Datum) * scan->numberOfOrderBys); + scan->xs_orderbyvals = palloc0(sizeof(Datum) * scan->numberOfOrderBys); scan->xs_orderbynulls = palloc(sizeof(bool) * scan->numberOfOrderBys); + memset(scan->xs_orderbynulls, true, sizeof(bool) * scan->numberOfOrderBys); } scan->opaque = so; @@ -284,6 +285,8 @@ gistrescan(PG_FUNCTION_ARGS) GIST_DISTANCE_PROC, skey->sk_attno, RelationGetRelationName(scan->indexRelation)); + fmgr_info_copy(&(skey->sk_func), finfo, so->giststate->scanCxt); + /* * Look up the datatype returned by the original ordering operator. * GiST always uses a float8 for the distance function, but the @@ -297,7 +300,6 @@ gistrescan(PG_FUNCTION_ARGS) * first time. */ so->orderByTypes[i] = get_func_rettype(skey->sk_func.fn_oid); - fmgr_info_copy(&(skey->sk_func), finfo, so->giststate->scanCxt); /* Restore prior fn_extra pointers, if not first time */ if (!first_time) -- cgit v1.2.3