From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@postgresql.org
Subject: pgsql: Replace uses of SPI_modifytuple that intend to allocate in curre
Date: Tue, 08 Nov 2016 20:36:53 +0000
Message-ID: <E1c4D8X-0002wP-TD@gemulon.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-committers>
Replace uses of SPI_modifytuple that intend to allocate in current context.
Invent a new function heap_modify_tuple_by_cols() that is functionally
equivalent to SPI_modifytuple except that it always allocates its result
by simple palloc. I chose however to make the API details a bit more
like heap_modify_tuple: pass a tupdesc rather than a Relation, and use
bool convention for the isnull array.
Use this function in place of SPI_modifytuple at all call sites where the
intended behavior is to allocate in current context. (There actually are
only two call sites left that depend on the old behavior, which makes me
wonder if we should just drop this function rather than keep it.)
This new function is easier to use than heap_modify_tuple() for purposes
of replacing a single column (or, really, any fixed number of columns).
There are a number of places where it would simplify the code to change
over, but I resisted that temptation for the moment ... everywhere except
in plpgsql's exec_assign_value(); changing that might offer some small
performance benefit, so I did it.
This is on the way to removing SPI_push/SPI_pop, but it seems like
good code cleanup in its own right.
Discussion: <9633.1478552022@sss.pgh.pa.us>
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/9257f0787257022e31c61cd77449127adfccf37f
Modified Files
--------------
contrib/spi/autoinc.c | 13 ++++---
contrib/spi/insert_username.c | 12 +++----
contrib/spi/moddatetime.c | 21 ++++-------
contrib/spi/timetravel.c | 25 ++++++-------
doc/src/sgml/spi.sgml | 5 +--
src/backend/access/common/heaptuple.c | 66 +++++++++++++++++++++++++++++++++++
src/backend/utils/adt/tsvector_op.c | 16 ++++-----
src/include/access/htup_details.h | 6 ++++
src/pl/plpgsql/src/pl_exec.c | 57 ++++++++++--------------------
src/test/regress/regress.c | 11 ++----
10 files changed, 137 insertions(+), 95 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-committers@postgresql.org
Cc: tgl@sss.pgh.pa.us
Subject: Re: pgsql: Replace uses of SPI_modifytuple that intend to allocate in curre
In-Reply-To: <E1c4D8X-0002wP-TD@gemulon.postgresql.org>
References: <E1c4D8X-0002wP-TD@gemulon.postgresql.org>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox