Re: BUG #15237: I got "ERROR: source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression"

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: 110876189(at)qq(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #15237: I got "ERROR: source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression"
Date: 2018-06-12 03:38:23
Message-ID: 22079.1528774703@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

=?utf-8?q?PG_Bug_reporting_form?= <noreply(at)postgresql(dot)org> writes:
> On PostgreSQL 11 Beta, I exec sql like "update
> fvt_obj_operate_update_table_033 set (c_int) = (20) where c_int = 20;",
> which only on column to set, got ""ERROR: source for a multiple-column
> UPDATE item must be a sub-SELECT or ROW() expression"".

It's telling you what to do: use a ROW() expression, ie

update fvt_obj_operate_update_table_033 set (c_int) = row(20)
where c_int = 20;

> But I exec sql like "update fvt_obj_operate_update_table_033 set
> (c_int,c_dp) = (20,1.11) where c_int = 20;", got successfull message.

(20) and row(20) are not the same thing, whereas (20,1.11) and
row(20,1.11) are the same thing. Don't blame us, it was the SQL
committee's idea that "ROW" should be optional for the latter.

> The cause of this error is because syntax rule conflict between "'(' a_expr
> ')' opt_indirection" and "implicit_row: '(' expr_list ',' a_expr ')'".I
> think "'(' a_expr ')'" is also a subset of row.
> I want to modify it, but didn‘t got a good idea.

Don't even think about it. It's unfixable without creating even worse
problems, like causing an extra pair of parentheses to change the meaning
of an expression.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrew Gierth 2018-06-12 10:28:38 Re: BUG #15237: I got "ERROR: source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression"
Previous Message PG Bug reporting form 2018-06-12 02:00:57 BUG #15237: I got "ERROR: source for a multiple-column UPDATE item must be a sub-SELECT or ROW() expression"

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2018-06-12 03:52:57 Re: Supporting tls-server-end-point as SCRAM channel binding for OpenSSL 1.0.0 and 1.0.1
Previous Message Thomas Munro 2018-06-12 03:31:07 Re: Checkpoint not retrying failed fsync?