On 08/07/2014 01:11 AM, Marko Tiikkaja wrote:
On 7/21/14, 10:56 PM, I wrote:
Here's a patch which allows you to notice those annoying bugs with INTO
slightly more quickly.  Adding to the next commit phest.


New version, fixed bugs with set operations and VALUES lists.

Looks good.

It seems weird to pass a PLpgSQL_row struct to check_sql_expr. check_sql_expr only needs to know how many attributes is expected to be in the target list, so it would be more natural to just pass an "int expected_natts".

Once you do that, you could trivially also add checking for other cases, e.g:

do $$
declare
  i int4;
begin
  -- fails at runtime, because "SELECT 1,3" returns two attributes,
  -- but FOR expects 1
  for i in 1,3..(2) loop
    raise notice 'foo %', i;
  end loop;
end;
$$;

There's probably more checking like that that you could add, but that can be done as add-on patches, if ever. The INTO mistake happens a lot more easily.

- Heikki



--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to