Re: SRF memory mgmt patch (was [HACKERS] Concern about - Mailing list pgsql-patches

From Joe Conway
Subject Re: SRF memory mgmt patch (was [HACKERS] Concern about
Date
Msg-id 3D6FBEBF.4000005@joeconway.com
Whole thread Raw
In response to SRF memory mgmt patch (was [HACKERS] Concern about memory management with SRFs)  (Joe Conway <mail@joeconway.com>)
Responses Re: SRF memory mgmt patch (was [HACKERS] Concern about  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-patches
Joe Conway wrote:
> Joe Conway wrote:
>
>> I'm looking at this now. I suspect the easy fix is to remove
>> ExecClearTuple from per_MultiFuncCall, but I'll try to understand
>> what's going on first.
>>
>
> On second thought, *all* functions failing is what you expected, right
> Tom? I just changed TupleGetDatum() as we discussed:
>
> #define TupleGetDatum(_slot, _tuple) \
>   PointerGetDatum(ExecStoreTuple(_tuple, _slot, InvalidBuffer, false))
>
> and now everything works again. Is this the preferred fix and/or is it
> worth spending more time to dig into this?

Here is a patch with the above mentioned fix. It also has an addition to
rangefuncs.sql and rangefuncs.out to ensure a C language table function
gets tested. I did this by adding
   SELECT * FROM pg_settings WHERE name LIKE 'enable%';
to the test. I think this should produce reasonably stable results, but
obviously will require some maintenance if we add/remove a GUC variable
matching this criteria. Alternative suggestions welcomed, but if there
are no objections, please commit.

Thanks,

Joe
Index: src/include/funcapi.h
===================================================================
RCS file: /opt/src/cvs/pgsql-server/src/include/funcapi.h,v
retrieving revision 1.6
diff -c -r1.6 funcapi.h
*** src/include/funcapi.h    29 Aug 2002 17:14:33 -0000    1.6
--- src/include/funcapi.h    30 Aug 2002 17:20:49 -0000
***************
*** 148,154 ****
  extern HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values);

  #define TupleGetDatum(_slot, _tuple) \
!     PointerGetDatum(ExecStoreTuple(_tuple, _slot, InvalidBuffer, true))


  /*----------
--- 148,154 ----
  extern HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values);

  #define TupleGetDatum(_slot, _tuple) \
!     PointerGetDatum(ExecStoreTuple(_tuple, _slot, InvalidBuffer, false))


  /*----------
Index: src/test/regress/expected/rangefuncs.out
===================================================================
RCS file: /opt/src/cvs/pgsql-server/src/test/regress/expected/rangefuncs.out,v
retrieving revision 1.4
diff -c -r1.4 rangefuncs.out
*** src/test/regress/expected/rangefuncs.out    29 Aug 2002 00:17:06 -0000    1.4
--- src/test/regress/expected/rangefuncs.out    30 Aug 2002 17:29:45 -0000
***************
*** 1,3 ****
--- 1,15 ----
+ SELECT * FROM pg_settings WHERE name LIKE 'enable%';
+        name       | setting
+ ------------------+---------
+  enable_hashjoin  | on
+  enable_indexscan | on
+  enable_mergejoin | on
+  enable_nestloop  | on
+  enable_seqscan   | on
+  enable_sort      | on
+  enable_tidscan   | on
+ (7 rows)
+
  CREATE TABLE foo2(fooid int, f2 int);
  INSERT INTO foo2 VALUES(1, 11);
  INSERT INTO foo2 VALUES(2, 22);
Index: src/test/regress/sql/rangefuncs.sql
===================================================================
RCS file: /opt/src/cvs/pgsql-server/src/test/regress/sql/rangefuncs.sql,v
retrieving revision 1.3
diff -c -r1.3 rangefuncs.sql
*** src/test/regress/sql/rangefuncs.sql    29 Aug 2002 00:17:06 -0000    1.3
--- src/test/regress/sql/rangefuncs.sql    30 Aug 2002 17:28:07 -0000
***************
*** 1,3 ****
--- 1,5 ----
+ SELECT * FROM pg_settings WHERE name LIKE 'enable%';
+
  CREATE TABLE foo2(fooid int, f2 int);
  INSERT INTO foo2 VALUES(1, 11);
  INSERT INTO foo2 VALUES(2, 22);

pgsql-patches by date:

Previous
From: Alvaro Herrera
Date:
Subject: Re: indisclustered and clusterdb
Next
From: Joe Conway
Date:
Subject: Re: SRF memory mgmt patch (was [HACKERS] Concern about