Is it safe to ignore the return value of SPI_finish and SPI_execute?

From: Mark Dilger <hornschnorter(at)gmail(dot)com>
To: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Is it safe to ignore the return value of SPI_finish and SPI_execute?
Date: 2019-05-17 18:00:52
Message-ID: 04E56988-5025-48CF-85E2-02301ACD0D59@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hackers,

most places that use SPI_connect ... SPI_finish check the
return value of SPI_finish and elog if it failed. There
are a few places that do not, and it is unclear to me
why this is safe. SPI_finish appears to be needed to
clean up memory contexts.

Examples can be found in:
src/backend/utils/adt/xml.c
src/backend/utils/adt/tsvector_op.c
src/backend/utils/adt/tsquery_rewrite.c
src/test/regress/regress.c
contrib/spi/refint.c

The return value of SPI_execute is ignored in one spot:
src/backend/utils/adt/xml.c circa line 2465.

I checked the archives and did not see any discussion
about this in the past. Please excuse me if this has
been asked before.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2019-05-17 18:11:30 Re: pgindent run next week?
Previous Message Bruce Momjian 2019-05-17 17:49:47 Re: pgindent run next week?