Skip site navigation (1) Skip section navigation (2)

Re: PLpgSQL: list of scalars as row for assign stmt, fore and fors stm

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: "Pavel Stehule" <pavel(dot)stehule(at)hotmail(dot)com>
Cc: chriskl(at)familyhealth(dot)com(dot)au, pgsql-patches(at)postgresql(dot)org, neilc(at)samurai(dot)com
Subject: Re: PLpgSQL: list of scalars as row for assign stmt, fore and fors stm
Date: 2005-12-21 04:04:51
Message-ID: 8581.1135137891@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-patches
"Pavel Stehule" <pavel(dot)stehule(at)hotmail(dot)com> writes:
>>>> x, y := r;
> 
>>> That strikes me as a really bad idea.  It weakens both syntax and
>>> semantic error checking, to accomplish how much?
>> 
>> Could use PHP-style thingy:
>> LIST(x, y) := r;

Actually, ROW(x, y) would be the right spelling per SQL convention.

> It's inconsystency :-(.
> EXECUTE INTO and SELECT INTO use scalar of vectors without anything.

But in both of those cases there are required leading keywords to give
you some clue what's supposed to come next.  Allowing bare x, y at the
start of a statement is just a recipe for misconstruing stuff that was
intended as something else and is one or two punctuation characters shy
of perfection.

There is also the problem of insufficient semantic cross-checking.  A
record variable doesn't have any very well-defined order of fields, so
who's to say which value goes to x and which to y?  For that matter,
if I just have
	x := y
and y is a single-field rowtype, it'd be entirely unclear whether x is
to receive the row value or the field value.

I don't think this buys anything that is worth the can of worms we'd
be opening up.  The extension for FOR might be worth doing, but not
the assignment change.

And, to reiterate Andrew's point, this entire discussion should have
been held before you wrote a line of code.  It is utterly wrong
to be doing it in pgsql-patches.

			regards, tom lane

In response to

Responses

pgsql-patches by date

Next:From: Christopher Kings-LynneDate: 2005-12-21 04:09:02
Subject: Re: PLpgSQL: list of scalars as row for assign stmt, fore
Previous:From: Pavel StehuleDate: 2005-12-21 03:54:43
Subject: Re: PLpgSQL: list of scalars as row for assign stmt, fore and fors stm

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group