pgsql: Replace uses of SPI_modifytuple that intend to allocate in curre

Поиск
Список
Период
Сортировка
От Tom Lane
Тема pgsql: Replace uses of SPI_modifytuple that intend to allocate in curre
Дата
Msg-id E1c4D8X-0002wP-TD@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-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(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Robert Haas
Дата:
Сообщение: pgsql: psql: Tab completion for renaming enum values.
Следующее
От: Robert Haas
Дата:
Сообщение: pgsql: Fix typo.