Re: BUG #16006: Update queries fail on a table having any policywith a function that takes a whole-row var as arg

Поиск
Список
Период
Сортировка
От Andres Freund
Тема Re: BUG #16006: Update queries fail on a table having any policywith a function that takes a whole-row var as arg
Дата
Msg-id 20190912211047.kr7e4pn7iof76jfx@alap3.anarazel.de
обсуждение исходный текст
Ответ на Re: BUG #16006: Update queries fail on a table having any policy with a function that takes a whole-row var as arg  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: BUG #16006: Update queries fail on a table having any policy with a function that takes a whole-row var as arg
Список pgsql-bugs
Hi,

On 2019-09-12 16:33:55 -0400, Tom Lane wrote:
> PG Bug reporting form <noreply@postgresql.org> writes:
> > Update queries fail on a table having any policy with a function that takes
> > a whole-row var as argument.
> 
> Hm.  You really should have shown the failure you were seeing, but
> for the archives' sake: I can reproduce this on 9.5 and 9.6 (if I
> run the queries as non-superuser!), and it looks like
> 
> regression=> insert into usertable
values('key','field0','field1','field2','field3','field4','field5','field6','field7','field8','field9');
> INFO:  log: (key,field0,field1,field2,field3,field4,field5,field6,field7,field8,field9,"2019-09-12 16:29:37.511329")
> INSERT 0 1
> regression=> update usertable set field0 = 'f0';
> INFO:  log: (key,field0,field1,field2,field3,field4,field5,field6,field7,field8,field9,"2019-09-12 16:29:37.511329")
> ERROR:  table row type and query-specified row type do not match
> DETAIL:  Table has type tid at ordinal position 1, but query expects character varying.
> 
> Digging into this, it seems the short answer is "Andres should have
> back-patched 148e632c0".  The plan shape in 9.6.x is

Heh :/. I was wondering (and asking for input) at the time... The whole
business with parent nodes is somewhat fragile (cf 2abd7ae9b2 /
5f32b29c1819), which makes me generally a bit hesitant to backpatch.
But obviously it's needed here.


>  Update on usertable usertable_1  (cost=0.00..66.00 rows=70 width=366)
>    ->  Subquery Scan on usertable  (cost=0.00..66.00 rows=70 width=366)
>          ->  LockRows  (cost=0.00..65.30 rows=70 width=340)
>                ->  Seq Scan on usertable usertable_2  (cost=0.00..64.60 rows=70 width=340)
>                      Filter: log_record(usertable_2.*)
> 
> and because ExecInitModifyTable incorrectly passes the SubqueryScan
> as parent of the WCO expressions, the horrible examine-the-parent
> kluge in ExecEvalWholeRowVar fires, causing it to apply a completely
> inappropriate junkfilter to the scan tuple.  After which, of course,
> the tuple rowtype is wrong.

I don't quite understand how this "visibly" broke between 9.5.15 and
9.5.19 as the op reports? Haven't dug into it yet though.

Greetings,

Andres Freund



В списке pgsql-bugs по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #16006: Update queries fail on a table having any policy with a function that takes a whole-row var as arg
Следующее
От: Tom Lane
Дата:
Сообщение: Re: BUG #16006: Update queries fail on a table having any policy with a function that takes a whole-row var as arg