SPI_getvalue calls output function w/o pushing existing SPI connection + 2 extra issues

From: "J(dot) Greg Davidson" <jgd(at)well(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: SPI_getvalue calls output function w/o pushing existing SPI connection + 2 extra issues
Date: 2006-12-12 05:33:34
Message-ID: 1165901615.7709.92.camel@shevek.ifsrad.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I have a user defined type implemented in C and SPI which has been
crashing a lot. I found a small enough case to trace the whole thing
with gdb and found that while connected to SPI I was doing a get_value
on a type T implemented in C and SPI. SPI_getvalue led to a call to T's
output routine which called SPI_connect which failed because the
previous SPI connection was still in force. The whole transaction was
aborted, so without a long gdb session I wouldn't have caught it.
Ironically the call to SPI_getvalue was in my debugging code!

This behavior was unexpected and very hard to track down. If
SPI_getvalue is supposed to be this fragile, it would be good to
document that. I'm now experimenting with creating a wrapper function
which surrounds SPI_getvalue with SPI_push and SPI_pop.

On a related issue - it would be very handy to have something which can
be called or tested from a type extension module to find out if an SPI
connection exists. Such a feature would be especially useful for
asserts. As far as I can tell from reading the server code, any such
state is hidden in static variables.

Finally, I tried to submit this bug at
http://wwwmaster.postgresql.org/system/handleform.php
as requested by the documentation at PostgreSQL.org, but it rejected my
attempt saying "The email address you entered does not appear to be
valid." The email address in question is "jgd(at)well(dot)com" which is
indeed valid and is the one I use to receive postgresql mailing lists.

Thanks for reading this feedback and keep up the good work,

_Greg

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Pavel Golub 2006-12-12 08:44:13 User-defined type name begins with the underscore character (_) can be created
Previous Message Tom Lane 2006-12-12 00:58:22 Re: BUG #2823: API largeobject calls