Heikki Linnakangas <heikki.linnakan...@enterprisedb.com> writes: > While testing the recent issue with unknown params in EXECUTE USING, I > accidentally did this:
> EXECUTE 'SELECT ''foo'' || $1' USING 'bar' INTO t; > The mistake I made? I put the USING and INTO clauses in wrong order, > INTO needs to go first. We should throw an error on that, but it looks > like the INTO clause is just silently ignored. This is more interesting than it looks. It appears that the plpgsql parser interprets the USING's argument expression as being 'bar' INTO t so it generates a plplgsql expression with query SELECT 'bar' INTO t and the only reason that you don't get a failure is that exec_simple_check_plan fails to notice the intoClause, so it thinks this represents a "simple expression", which means it evaluates the 'bar' subexpression and ignores the INTO altogether. That's certainly a bug in exec_simple_check_plan :-( I think that accepting this order of the clauses would require some duplication of code in the stmt_dynexecute production. It might be worth doing anyway, because if you made this mistake then certainly others will. regards, tom lane -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers