Re: SPI: ERROR: no snapshot has been set - Mailing list pgsql-hackers

From Tom Lane
Subject Re: SPI: ERROR: no snapshot has been set
Date
Msg-id 8046.1123951002@sss.pgh.pa.us
Whole thread Raw
In response to SPI: ERROR: no snapshot has been set  (Martijn van Oosterhout <kleptog@svana.org>)
Responses Re: SPI: ERROR: no snapshot has been set
List pgsql-hackers
Martijn van Oosterhout <kleptog@svana.org> writes:
> - Is there a way to detect if a snapshot has been started and creating
> one if there hasn't. I've seen the snapshot related functions but I
> don't feel comfortable sticking them in my type input function just to
> fix this. Is it safe?

This would be a pretty bad idea IMHO.  The setting of the first snapshot
in a transaction is a significant event, and it should not happen in
random places like type-specific input functions.

A long-term solution to this might be to do what's envisioned in this
comment in parse_coerce.c:
        * XXX if the typinput function is not immutable, we really ought to        * postpone evaluation of the
functioncall until runtime. But        * there is no way to represent a typinput function call as an        *
expressiontree, because C-string values are not Datums. (XXX        * This *is* possible as of 7.3, do we want to do
it?)

I'm a bit concerned about the possible side-effects of this on existing
behavior, though.  In particular constructs like'now'::timestamp
would change behavior subtly.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: psql SET/RESET/SHOW tab completion
Next
From: Tom Lane
Date:
Subject: Re: psql SET/RESET/SHOW tab completion