Re: Restore CurrentUserId only if 'prevUser' is valid when abort transaction

2018-11-13 Thread Michael Paquier
On Tue, Nov 13, 2018 at 04:08:04PM -0500, Tom Lane wrote: > Well, if it is an issue then it's an issue for back branches too. > It's fine, I think, as long as the warning stays a warning ... > but there are lots of ways in which trying to print a warning > might turn into an error. At the end I ha

Re: Restore CurrentUserId only if 'prevUser' is valid when abort transaction

2018-11-13 Thread Tom Lane
Michael Paquier writes: > On Mon, Nov 12, 2018 at 08:17:29PM -0500, Tom Lane wrote: >> I think the real bug here is that a bunch of potentially-failable >> operations have been thrown in before we've finished initializing the >> TransactionState to minimal sanity. (Inserting code with the aid of

Re: Restore CurrentUserId only if 'prevUser' is valid when abort transaction

2018-11-12 Thread Michael Paquier
On Mon, Nov 12, 2018 at 08:17:29PM -0500, Tom Lane wrote: > I don't like this too much, because it does not scale: there can be > only one action that can rely on executing "just before we switch to > TRANS_INPROGRESS". Okay. > I think the real bug here is that a bunch of potentially-failable > o

Re: Restore CurrentUserId only if 'prevUser' is valid when abort transaction

2018-11-12 Thread Tom Lane
Michael Paquier writes: > So, I have spent a couple of hours today looking a bit more at the > problem, and I have hacked the attached patch that I am pretty happy > with: I don't like this too much, because it does not scale: there can be only one action that can rely on executing "just before w

Re: Restore CurrentUserId only if 'prevUser' is valid when abort transaction

2018-10-23 Thread Michael Paquier
On Tue, Oct 23, 2018 at 02:40:30PM +0900, Michael Paquier wrote: > Actually, as StartSubTransaction also switches to TRANS_START for a > savepoint, if there is an error until the state is switched to > TRANS_INPROGRESS then the code would fail to switch back to > CurrentUserId even if it is set, an

Re: Restore CurrentUserId only if 'prevUser' is valid when abort transaction

2018-10-22 Thread Michael Paquier
On Fri, Oct 12, 2018 at 02:28:36PM +0800, Richard Guo wrote: > I think it is a better idea to avoid adjusting the state to TRANS_INPROGRESS > from TRANS_START when aborting a transaction, as your patch does, since its > only purpose is to suppress warning message. Actually, as StartSubTransaction

Re: Restore CurrentUserId only if 'prevUser' is valid when abort transaction

2018-10-11 Thread Richard Guo
Hi Michael, Thanks for your input. On Thu, Oct 11, 2018 at 11:38 AM, Michael Paquier wrote: > On Wed, Oct 10, 2018 at 03:37:50PM +0800, Richard Guo wrote: > > This is a follow-up to the issue described in thread > > https://www.postgresql.org/message-id/CAMbWs4-Mys%3DhBQSevTA8Zpd-TYFnb% > 3DXuHh

Re: Restore CurrentUserId only if 'prevUser' is valid when abort transaction

2018-10-10 Thread Michael Paquier
On Wed, Oct 10, 2018 at 03:37:50PM +0800, Richard Guo wrote: > This is a follow-up to the issue described in thread > https://www.postgresql.org/message-id/CAMbWs4-Mys%3DhBQSevTA8Zpd-TYFnb%3DXuHhN2TnktXMsfMUbjiQ%40mail.gmail.com > > In short, during the first transaction starting phase within a ba

Restore CurrentUserId only if 'prevUser' is valid when abort transaction

2018-10-10 Thread Richard Guo
Hi, This is a follow-up to the issue described in thread https://www.postgresql.org/message-id/CAMbWs4-Mys%3DhBQSevTA8Zpd-TYFnb%3DXuHhN2TnktXMsfMUbjiQ%40mail.gmail.com In short, during the first transaction starting phase within a backend, if there is an 'ereport' after setting transaction state