Thread: Patch to check whether we are in TX when to lo_*

Patch to check whether we are in TX when to lo_*

From
Denis Perchine
Date:
Hello,

here is the patch attached which do check in each BLOB operation, if we are
in transaction, and raise an error otherwise. This will prevent such mistakes.

--
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------

Attachment

Re: Patch to check whether we are in TX when to lo_*

From
Tom Lane
Date:
Denis Perchine <dyp@perchine.com> writes:
> here is the patch attached which do check in each BLOB operation, if
> we are in transaction, and raise an error otherwise. This will prevent
> such mistakes.

Hmm.  I'm not sure if this is a good idea, or just overprotective
nannyism.  Comments anyone?

As is, it's certainly undesirable because it will break backend
lo_export and lo_import, neither of which need to be in an xact block.
Perhaps that could be worked around somehow, but is it worth the
trouble?

            regards, tom lane

Re: Patch to check whether we are in TX when to lo_*

From
Denis Perchine
Date:
> > here is the patch attached which do check in each BLOB operation, if
> > we are in transaction, and raise an error otherwise. This will prevent
> > such mistakes.
>
> Hmm.  I'm not sure if this is a good idea, or just overprotective
> nannyism.  Comments anyone?
>
> As is, it's certainly undesirable because it will break backend
> lo_export and lo_import, neither of which need to be in an xact block.
> Perhaps that could be worked around somehow, but is it worth the
> trouble?

Hmmm... Actually you always should do BLOB operations in TX. I added this
check because some time ago I spent quite long time when I tried to figure
out what was wrong with my small test code. It successfully opens BLOB, but
then it complains about unknown fd. The reason was that I did this outside of
TX. After each command TX was automatically commited, and all fd's was
cleaned up. It is not so easy to detect such problem if you do not know the
code...

--
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: dyp@perchine.com
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------