pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10
6+ messages / 3 participants
[nested] [flat]

* Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10
@ 2017-10-24 12:00 YasonTR <yasontr@protonmail.com>
  2017-10-24 14:18 ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: YasonTR @ 2017-10-24 12:00 UTC (permalink / raw)
  To: pgsql-bugs

Hi,

The following (odd) construction worked in pgv9.x: "UPDATE my_table SET (my_col) = (some value)". This no longer works in v10. It gives the error "source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression". It looks like it only breaks when the column list just holds one single column.

Possibly related to:

- https://www.postgresql.org/message-id/8542.1479742008%40sss.pgh.pa.us

- https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=906bfcad7

Let me know if you need more information.

Thank you. Warm regards,

YasonTR

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10
  2017-10-24 12:00 Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 YasonTR <yasontr@protonmail.com>
@ 2017-10-24 14:18 ` Tom Lane <tgl@sss.pgh.pa.us>
  2017-10-24 14:55   ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 YasonTR <yasontr@protonmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2017-10-24 14:18 UTC (permalink / raw)
  To: YasonTR <yasontr@protonmail.com>; +Cc: pgsql-bugs

YasonTR <yasontr@protonmail.com> writes:
> The following (odd) construction worked in pgv9.x: "UPDATE my_table SET (my_col) = (some value)". This no longer works in v10. It gives the error "source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression". It looks like it only breaks when the column list just holds one single column.

Yeah, IIRC this was an intentional change.  The fact that the previous
coding allowed you to do that was a mistake, because per spec you really
need to supply a row value when you parenthesize the SET column list.
As of v10 it should work to write
UPDATE my_table SET (my_col) = ROW(some value)

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10
  2017-10-24 12:00 Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 YasonTR <yasontr@protonmail.com>
  2017-10-24 14:18 ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-10-24 14:55   ` YasonTR <yasontr@protonmail.com>
  2017-10-24 15:07     ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 David G. Johnston <david.g.johnston@gmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: YasonTR @ 2017-10-24 14:55 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-bugs

Hi Tom,

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).

Thank you.

> -------- Original Message --------
> Subject: Re: [BUGS] Possible regression in 'UPDATE ... SET () = ' with just one single column/row value since v10
> Local Time: October 24, 2017 4:18 PM
> UTC Time: October 24, 2017 2:18 PM
> From: tgl@sss.pgh.pa.us
> To: YasonTR <yasontr@protonmail.com>
> pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
>
> YasonTR yasontr@protonmail.com writes:
>
>> The following (odd) construction worked in pgv9.x: "UPDATE my_table SET (my_col) = (some value)". This no longer works in v10. It gives the error "source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression". It looks like it only breaks when the column list just holds one single column.
>>
>> Yeah, IIRC this was an intentional change. The fact that the previous
>> coding allowed you to do that was a mistake, because per spec you really
>> need to supply a row value when you parenthesize the SET column list.
>> As of v10 it should work to write
>> UPDATE my_table SET (my_col) = ROW(some value)
>>
>> regards, tom lane
>>
>> --
>> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-bugs

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10
  2017-10-24 12:00 Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 YasonTR <yasontr@protonmail.com>
  2017-10-24 14:18 ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 Tom Lane <tgl@sss.pgh.pa.us>
  2017-10-24 14:55   ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 YasonTR <yasontr@protonmail.com>
@ 2017-10-24 15:07     ` David G. Johnston <david.g.johnston@gmail.com>
  2017-10-24 15:21       ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 6+ messages in thread

From: David G. Johnston @ 2017-10-24 15:07 UTC (permalink / raw)
  To: YasonTR <yasontr@protonmail.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-bugs

On Tue, Oct 24, 2017 at 7:55 AM, YasonTR <yasontr@protonmail.com> wrote:

> Hi Tom,
>
> 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).
>


​
https://www.postgresql.org/docs/10/static/sql-expressions.html#sql-syntax-row-constructors

"​The key word ROW is optional when there is more than one expression in
the list."

David J.

^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10
  2017-10-24 12:00 Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 YasonTR <yasontr@protonmail.com>
  2017-10-24 14:18 ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 Tom Lane <tgl@sss.pgh.pa.us>
  2017-10-24 14:55   ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 YasonTR <yasontr@protonmail.com>
  2017-10-24 15:07     ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 David G. Johnston <david.g.johnston@gmail.com>
@ 2017-10-24 15:21       ` Tom Lane <tgl@sss.pgh.pa.us>
  2017-10-24 15:47         ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 YasonTR <yasontr@protonmail.com>
  0 siblings, 1 reply; 6+ messages in thread

From: Tom Lane @ 2017-10-24 15:21 UTC (permalink / raw)
  To: David G. Johnston <david.g.johnston@gmail.com>; +Cc: YasonTR <yasontr@protonmail.com>; pgsql-bugs

"David G. Johnston" <david.g.johnston@gmail.com> writes:
> On Tue, Oct 24, 2017 at 7:55 AM, YasonTR <yasontr@protonmail.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@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 6+ messages in thread

* Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10
  2017-10-24 12:00 Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 YasonTR <yasontr@protonmail.com>
  2017-10-24 14:18 ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 Tom Lane <tgl@sss.pgh.pa.us>
  2017-10-24 14:55   ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 YasonTR <yasontr@protonmail.com>
  2017-10-24 15:07     ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 David G. Johnston <david.g.johnston@gmail.com>
  2017-10-24 15:21       ` Re: Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 Tom Lane <tgl@sss.pgh.pa.us>
@ 2017-10-24 15:47         ` YasonTR <yasontr@protonmail.com>
  0 siblings, 0 replies; 6+ messages in thread

From: YasonTR @ 2017-10-24 15:47 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: David G. Johnston <david.g.johnston@gmail.com>; 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@sss.pgh.pa.us
>To: David G. Johnston <david.g.johnston@gmail.com>
>YasonTR <yasontr@protonmail.com>, pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
>
>"David G. Johnston" david.g.johnston@gmail.com writes:
>>On Tue, Oct 24, 2017 at 7:55 AM, YasonTR yasontr@protonmail.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@postgresql.org)
>>> To make changes to your subscription:
>>>http://www.postgresql.org/mailpref/pgsql-bugs
>>>
-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs


^ permalink  raw  reply  [nested|flat] 6+ messages in thread


end of thread, other threads:[~2017-10-24 15:47 UTC | newest]

Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-10-24 12:00 Possible regression in 'UPDATE ... SET (<column list>) = <row expression>' with just one single column/row value since v10 YasonTR <yasontr@protonmail.com>
2017-10-24 14:18 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-10-24 14:55   ` YasonTR <yasontr@protonmail.com>
2017-10-24 15:07     ` David G. Johnston <david.g.johnston@gmail.com>
2017-10-24 15:21       ` Tom Lane <tgl@sss.pgh.pa.us>
2017-10-24 15:47         ` YasonTR <yasontr@protonmail.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox