From: | Albe Laurenz <laurenz(dot)albe(at)wien(dot)gv(dot)at> |
---|---|
To: | "'davidb(at)pfxcorp(dot)com'" <davidb(at)pfxcorp(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: How do BEGIN/COMMIT/ABORT operate in a nested SPI query? |
Date: | 2016-04-20 07:41:41 |
Message-ID: | A737B7A37273E048B164557ADEF4A58B53841F58@ntex2010i.host.magwien.gv.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
David Bennett wrote:
> > From: Albe Laurenz [mailto:laurenz(dot)albe(at)wien(dot)gv(dot)at]
> >
> > > I am attempting to create a new language implementation. The language
> > > is Andl (andl.org) so the handler is plandl.
> > > This is a question about executing SPI queries from inside plandl.
> > >
> > > The documentation makes it clear that SPI allows nested queries; that
> > > in some instances it will be necessary to call SPI_push() and
> > > SPI_pop(), but in others this will be handled automatically. Se
> > http://www.postgresql.org/docs/9.5/interactive/spi-spi-push.html.
> > >
> > > It is an important design feature of plandl to allow nested queries.
> > >
> > > My question is: where are the transaction boundaries if the
> > > inner/outer query do or do not contain BEGIN/ABORT/COMMIT? Do they
> > > nest, or does an inner COMMIT finish a transaction started by an outer
> > BEGIN, or is it ignored?
> >
> > You cannot have BEGIN or COMMIT inside a function.
>
> Are you sure you meant it like that? I already have BEGIN/COMMIT inside a function and it works
> perfectly. If it did not, then it would be impossible to use BEGIN/COMMIT in any language handler,
> since every call to a language handler is a call to a function.
>
> Did you mean 'inside a nested function'? Or something else?
I guess I'm out of my depth when it comes to language handlers...
But I cannot see how you can have BEGIN or COMMIT called from inside one.
Doesn't it look like that:
BEGIN;
SELECT my_andl_function();
COMMIT;
Since there are no autonomous transactions in PostgreSQL, how can you have
BEGIN and COMMIT called from the code that is invoked by "SELECT my_andl_function()"?
Yours,
Laurenz Albe
From | Date | Subject | |
---|---|---|---|
Next Message | Alex Ignatov | 2016-04-20 07:43:43 | Initdb --data-checksums by default |
Previous Message | John R Pierce | 2016-04-20 07:37:54 | Re: Enhancement Request |