Re: plpgsql.extra_warnings='num_into_expressions' - Mailing list pgsql-hackers

From Heikki Linnakangas
Subject Re: plpgsql.extra_warnings='num_into_expressions'
Date
Msg-id 53F5C7AD.7080402@vmware.com
Whole thread Raw
In response to Re: plpgsql.extra_warnings='num_into_expressions'  (Marko Tiikkaja <marko@joh.to>)
Responses Re: plpgsql.extra_warnings='num_into_expressions'
List pgsql-hackers
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




pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: option -T in pg_basebackup doesn't work on windows
Next
From: Andreas 'ads' Scherbaum
Date:
Subject: Re: documentation update for doc/src/sgml/func.sgml