SPI: ERROR: no snapshot has been set

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: SPI: ERROR: no snapshot has been set
Date: 2005-08-13 14:00:00
Message-ID: 20050813135956.GB24155@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

[Please CC any replies, thanks]

Hi,

I got this nice error, and according to Tom Lane[1]:

> Depending on what PG version you're using (which you did not say,
> naughty naughty) there are paths in interactive query entry that
> might try to execute datatype input functions before setting the
> query snapshot. But I don't believe it can happen down inside SPI.

[1] http://www.dbforums.com/archive/index.php/t-1065541.html

Good guess, I am inside a type input function trying to use SPI. My
questions are:

- I'm using 7.4, is this fixed/changed in later versions?
- I'm triggering it with: select 'hello'::mytype;

Is there an easy way of testing my function without triggering this?

select (select 'hello'::mytype); -- Same problem
select (select 'hello')::mytype -- gives something about casting unknown
\copy .. from stdin -- Works but is inconvenient

- 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?

Thanks in advance,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2005-08-13 14:09:35 Re: DROP OWNED BY
Previous Message William ZHANG 2005-08-13 12:47:30 Re: CREATE USER and pg_user