Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10

From: YasonTR <yasontr(at)protonmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10
Date: 2017-10-24 15:47:33
Message-ID: j9WVrqf9R9p8t103UQjQsp4u5-T579pZ-z8vB4vCYeApzBrqtr8XTQeWWWjlqRs0Lk2Fm8Oilxv6y2VC6q0hAy2V48i9a3xqDJ2ZMnrK_Q8=@protonmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi David, Tom,

Thanks for information. I could have found it in the docs, but in hindsight, I did really think about the necessity to to distinguish between the case with just one column and the case with multiple columns. It's clear for me now.

Warm regards,

YasonTR

>-------- Original Message --------
>Subject: Re: [BUGS] Possible regression in 'UPDATE ... SET () = ' with just one single column/row value since v10
>Local Time: October 24, 2017 5:21 PM
>UTC Time: October 24, 2017 3:21 PM
>From: tgl(at)sss(dot)pgh(dot)pa(dot)us
>To: David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com>
>YasonTR <yasontr(at)protonmail(dot)com>, pgsql-bugs(at)postgresql(dot)org <pgsql-bugs(at)postgresql(dot)org>
>
>"David G. Johnston" david(dot)g(dot)johnston(at)gmail(dot)com writes:
>>On Tue, Oct 24, 2017 at 7:55 AM, YasonTR yasontr(at)protonmail(dot)com wrote:
>>>I get your reference to the spec, but why is it working without ROW() when
>>> multiple columns are involved? For example: "UPDATE my_table SET (a, b) =
>>> (x, y)" works on v10 (afaik).
>>>
>>> "The key word ROW is optional when there is more than one expression in
>>> the list."
>>>
>>> Right. This was not one of the SQL committee's better syntax choices,
>>> in my book --- allowing ROW to be optional makes the single-column case
>>> a weird exception, since then and only then ROW is required to make it a
>>> row constructor and not just an expression with useless extra parens.
>>>
>>> The spec says that the source value for a parenthesized SET list
>>> is a <contextually typed row value expression>. Pre-v10, we handled
>>> this with a grammar hack that looked specifically for a parenthesized
>>> list of expressions, and as it happened it would accept a single
>>> parenthesized expression as well. Now it's expecting a normal
>>> row constructor, which can be one of
>>> ROW(one_expr)
>>> ROW(an_expr, another_expr [, ...])
>>> (an_expr, another_expr [, ...])
>>>
>>> regards, tom lane
>>>
>>>
>>> --
>>> Sent via pgsql-bugs mailing list (pgsql-bugs(at)postgresql(dot)org)
>>> To make changes to your subscription:
>>>http://www.postgresql.org/mailpref/pgsql-bugs
>>>

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message andreigorita 2017-10-24 15:53:58 BUG #14870: wrong query results when using WITH with UPDATE
Previous Message Tom Lane 2017-10-24 15:21:26 Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10