Re: plpgsql variable assignment with union is broken

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: easteregg(at)verfriemelt(dot)org
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org
Subject: Re: plpgsql variable assignment with union is broken
Date: 2021-01-05 21:40:46
Message-ID: 3425546.1609882846@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

easteregg(at)verfriemelt(dot)org writes:
> i found, that the behaviour of variable assignment in combination with union is not working anymore:
> DO $$
> DECLARE t bool;
> begin
> t := a FROM ( SELECT true WHERE false ) t(a) UNION SELECT true AS a;
> END $$;

> is this an intended change or is it a bug?

It's an intended change, or at least I considered the case and thought
that it was useless because assignment will reject any result with more
than one row. Do you have any non-toy example that wouldn't be as
clear or clearer without using UNION? The above sure seems like an
example of awful SQL code.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2021-01-05 21:48:00 Re: set_config() documentation clarification
Previous Message Paul Martinez 2021-01-05 21:40:38 [PATCH] Partial foreign key updates in referential integrity triggers