You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to postgresql-ext...@googlegroups.com
Hi
today I commit a significant plpgsql_check update.
Now it checks a assignment and a return statement much more carefully: create or replace function f1() returns table(ax numeric, bx numeric) as $$ begin return query select * from tabret; return; end; $$ language plpgsql; select * from plpgsql_check_function('f1()', performance_warnings := true); plpgsql_check_function ----------------------------------------------------------------------------------- error:42804:3:RETURN QUERY:structure of query does not match function result type Detail: Returned type integer does not match expected type numeric in column 1. (2 rows)
create or replace function f1() returns void as $$ declare intval integer; begin intval := null; -- ok intval := 1; -- OK intval := '1'; -- OK intval := text '1'; -- not OK intval := current_date; -- not OK
select 1 into intval; -- OK select '1' into intval; -- OK select text '1' into intval; -- not OK end $$ language plpgsql; select * from plpgsql_check_function('f1()', performance_warnings := true); plpgsql_check_function ---------------------------------------------------------------------------------------------- performance:42804:7:assignment:target variable has different type then expression result Detail: assign "unknown" value to "integer" variable Hint: Hidden casting can be a performance issue. warning:42804:8:assignment:target variable has different type then expression result Detail: assign "text" value to "integer" variable Hint: The input expression type does not have an assignment cast to the target type. warning:42804:9:assignment:target variable has different type then expression result Detail: assign "date" value to "integer" variable Hint: There are no possible explicit coercion between those types, possibly bug! performance:42804:12:SQL statement:target variable has different type then expression result Detail: assign "unknown" value to "integer" variable Hint: Hidden casting can be a performance issue. warning:42804:13:SQL statement:target variable has different type then expression result Detail: assign "text" value to "integer" variable Hint: The input expression type does not have an assignment cast to the target type. (15 rows)