pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedBUG #16268: SPI_getvalue requires IsTransactionState but TextDatumGetCString of SPI_getbinval - not!
2+ messages / 2 participants
[nested] [flat]
* BUG #16268: SPI_getvalue requires IsTransactionState but TextDatumGetCString of SPI_getbinval - not!
@ 2020-02-20 05:06 PG Bug reporting form <noreply@postgresql.org>
2020-02-20 05:31 ` Re: BUG #16268: SPI_getvalue requires IsTransactionState but TextDatumGetCString of SPI_getbinval - not! Michael Paquier <michael@paquier.xyz>
0 siblings, 1 reply; 2+ messages in thread
From: PG Bug reporting form @ 2020-02-20 05:06 UTC (permalink / raw)
To: pgsql-bugs@lists.postgresql.org; +Cc: rekgrpth@gmail.com
The following bug has been logged on the website:
Bug reference: 16268
Logged by: RekGRpth
Email address: rekgrpth@gmail.com
PostgreSQL version: 12.2
Operating system: Docker alpine edge
Description:
const char *data = SPI_getvalue(SPI_tuptable->vals[row],
SPI_tuptable->tupdesc, SPI_fnumber(SPI_tuptable->tupdesc, "data"));
raise TRAP: FailedAssertion("!(IsTransactionState())", File: "catcache.c",
Line: 1213)
but
const char *data = SPI_getvalue_my(SPI_tuptable->vals[row],
SPI_tuptable->tupdesc, SPI_fnumber(SPI_tuptable->tupdesc, "data"));
where
char *SPI_getvalue_my(HeapTuple tuple, TupleDesc tupdesc, int fnumber) {
bool isnull;
Datum datum = SPI_getbinval(tuple, tupdesc, fnumber, &isnull);
if (isnull) return NULL;
return TextDatumGetCString(datum);
}
works ok
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: BUG #16268: SPI_getvalue requires IsTransactionState but TextDatumGetCString of SPI_getbinval - not!
2020-02-20 05:06 BUG #16268: SPI_getvalue requires IsTransactionState but TextDatumGetCString of SPI_getbinval - not! PG Bug reporting form <noreply@postgresql.org>
@ 2020-02-20 05:31 ` Michael Paquier <michael@paquier.xyz>
0 siblings, 0 replies; 2+ messages in thread
From: Michael Paquier @ 2020-02-20 05:31 UTC (permalink / raw)
To: rekgrpth@gmail.com; pgsql-bugs@lists.postgresql.org
On Thu, Feb 20, 2020 at 05:06:24AM +0000, PG Bug reporting form wrote:
> const char *data = SPI_getvalue(SPI_tuptable->vals[row],
> SPI_tuptable->tupdesc, SPI_fnumber(SPI_tuptable->tupdesc, "data"));
>
> raise TRAP: FailedAssertion("!(IsTransactionState())", File: "catcache.c",
> Line: 1213)
Catalog cache lookups have to happen in the context of a transaction,
this is what this assertion failure means, so your code is doing
something incorrect. We have such examples of short-term transactions
opened in the PostgreSQL code for some cache lookups.
IdentifySystem() in walsender.c looking for the database name is one
such example (see StartTransactionCommand and CommitTransactionCommand).
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2020-02-20 05:31 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-02-20 05:06 BUG #16268: SPI_getvalue requires IsTransactionState but TextDatumGetCString of SPI_getbinval - not! PG Bug reporting form <noreply@postgresql.org>
2020-02-20 05:31 ` Michael Paquier <michael@paquier.xyz>
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