Re: SPI: ERROR: no snapshot has been set

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: SPI: ERROR: no snapshot has been set
Date: 2005-08-13 16:57:51
Message-ID: 20050813165750.GC24155@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Aug 13, 2005 at 12:36:42PM -0400, Tom Lane wrote:
> Martijn van Oosterhout <kleptog(at)svana(dot)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.

I figured as much. In that case I've been thinking something like:

if (SerializableSnapshot == NULL)
elog( ERROR, "Sorry, 'const'::mytype constructs are not supported in first "
"transaction, please use mytype('const'::text)" );

I hope this works, I havn't gotten around to the casts yet, I hope
non-immutable casts are called late enough. Annoyingly, it breaks a
straight:

INSERT INTO table VALUES ('const','const','const',...)

Which is what GUI frontends are going to try to do... My alternative is
to cache results but that would make whether it works sporadic and
unpredictable.

> A long-term solution to this might be to do what's envisioned in this
> comment in parse_coerce.c:

<snip>

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

It's a good idea, eventually. All it would do is change the time it's
evaluated, and in that example it doesn't change since 'now' is the
transaction start time. However, in general it is a change of
behaviour.

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.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Fuhr 2005-08-13 17:04:18 Re: psql SET/RESET/SHOW tab completion
Previous Message Tom Lane 2005-08-13 16:41:51 Re: psql SET/RESET/SHOW tab completion