Another version of the patch is attached. Changes:
- clean up grammar so that read_sql_construct() is always called to read
a well-formed SQL expression. That way we can check for errors in
embedded SQL by just adding a single function call to
read_sql_construct(), rather than adding calls at most of its call
sites.
- changed location of array overflow checks per Tom
- mostly fixed error message formatting for syntax errors in PL/PgSQL. I
found this part of the ereport() framework rather confusing. The patch
currently emits errors like:
create function bad_sql1() returns int as $$
declare a int;
begin
a := 5;
Johnny Yuma;
a := 10;
return a;
end$$ language 'plpgsql';
ERROR: syntax error at or near "Johnny"
CONTEXT: SQL statement embedded in PL/PgSQL function "bad_sql1" near
line 4
Any suggestions for improvement would be welcome.
Barring any objections, I'd like to apply this patch to HEAD tomorrow.
-Neil