Re: SPI: ERROR: no snapshot has been set
От | Martijn van Oosterhout |
---|---|
Тема | Re: SPI: ERROR: no snapshot has been set |
Дата | |
Msg-id | 20050813165750.GC24155@svana.org обсуждение исходный текст |
Ответ на | Re: SPI: ERROR: no snapshot has been set (Tom Lane <tgl@sss.pgh.pa.us>) |
Ответы |
Re: SPI: ERROR: no snapshot has been set
|
Список | pgsql-hackers |
On Sat, Aug 13, 2005 at 12:36:42PM -0400, Tom Lane wrote: > 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. 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@svana.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.
В списке pgsql-hackers по дате отправления: