From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | Joel Jacobson <joel(at)trustly(dot)com> |
Cc: | Heikki Linnakangas <hlinnakangas(at)vmware(dot)com>, Kevin Grittner <kgrittn(at)ymail(dot)com>, Marko Tiikkaja <marko(at)joh(dot)to>, Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: PL/pgSQL 2 |
Date: | 2014-09-02 16:26:24 |
Message-ID: | 5405EFB0.3030607@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On 09/02/2014 12:12 PM, Joel Jacobson wrote:
> On Tue, Sep 2, 2014 at 6:03 PM, Heikki Linnakangas
> <hlinnakangas(at)vmware(dot)com> wrote:
>> I think that would actually be a good way to enforce the rule that an UPDATE
>> only updates a single row. Just put a "ASSERT ROW_COUNT=1;" after the
>> update.
> So instead of one line of code, I would need to write two lines of
> code at almost *all* places where a currently have an UPDATE. :-(
> In that case, I think "RETURNING TRUE INTO STRICT _OK" is less ugly.
>
> I think the problem with my perspective is my ambitions. I use
> PL/pgSQL not as a secondary language, but it's my primary language for
> developing applications.
> For me, updating a row, is like setting a variable in a normal language.
> No normal language would require two rows to set a variable.
> It would be like having to do:
> my $var = 10;
> die unless $var == 10;
> in Perl to set a variable.
>
>
That's really a problem with your perspective. UPDATE is inherently set
oriented. It's emphatically NOT like setting a single variable.
I must have written tens, possibly hundreds of thousands of lines of
plpgsql, and this have never ever been a problem for me.
I'd be very opposed to adding some special new plpgsql-only syntax to
have UPDATE or DELETE error out if they affected more than a single row.
And as you and others have observed, you can do that now with the
"RETURNING true INTO STRICT ok" trick.
cheers
andrew
From | Date | Subject | |
---|---|---|---|
Next Message | Joel Jacobson | 2014-09-02 16:27:04 | Re: PL/pgSQL 2 |
Previous Message | Joel Jacobson | 2014-09-02 16:20:42 | Re: PL/pgSQL 2 |