Re: Surprising behaviour of \set AUTOCOMMIT ON

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Daniel Verite" <daniel(at)manitou-mail(dot)org>
Cc: "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Rahila Syed" <rahilasyed90(at)gmail(dot)com>, "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Surprising behaviour of \set AUTOCOMMIT ON
Date: 2016-09-15 17:39:00
Message-ID: 4695.1473961140@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

"Daniel Verite" <daniel(at)manitou-mail(dot)org> writes:
> It looks easy to make the hooks return a bool, and when returning false,
> cancel the assignment of the variable.

Yeah, that's about how I was envisioning it too.

> I volunteer to write that patch.

Thanks.

> It would close the hazard that exists today of an internal psql flag
> getting decorrelated from the corresponding variable, due to feeding
> it with a wrong value, or in the case of autocommit, in the wrong
> context.

If we want to get to the situation that the variable's value always
reflects the internal state, then we should reject deleting the variable
too. Currently that's allowed; I was unsure whether we should still
permit it, but this line of thought says no.

Another issue is what to do in SetVariableAssignHook(). Currently,
that's only invoked immediately after creating the variable space
so it will always go through the hook(NULL) call, which the hook
will think means deletion and then fail for, given the above change.

What might be cleanest is to modify SetVariableAssignHook so that it
is passed both the initial value and the hook (deleting the separate
initial-value-setting calls that currently exist near startup.c:40).
If the hook rejects the initial value, that would be grounds for
fatal exit.

> Also with that, the behavior of ParseVariableBool() assuming "on"
> when it's being fed with junk could be changed.

Right.

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-09-15 17:51:36 Re: LOCK TABLE .. DEFERRABLE
Previous Message Heikki Linnakangas 2016-09-15 17:21:56 Re: [COMMITTERS] pgsql: Support OpenSSL 1.1.0.