Hello > > CREATE OR REPLACE FUNCTION t(i integer) RETURNS integer > LANGUAGE plpgsql STRICT AS > $$DECLARE j integer; > BEGIN > IF i=1 THEN > FOR I IN 1..4 BY -1 LOOP > RAISE NOTICE '%', i; > END LOOP; > RETURN -1; > ELSE > RETURN 2*i; > END IF; > END;$$; > > CHECK FUNCTION t(integer); -- no error > > SELECT t(1); > ERROR: BY value of FOR loop must be greater than zero > CONTEXT: PL/pgSQL function "t" line 4 at FOR with integer loop variable > > 2) > > CREATE OR REPLACE FUNCTION t(i integer) RETURNS integer > LANGUAGE plpgsql STRICT AS > $$DECLARE j integer; > BEGIN > IF i=1 THEN > j=9999999999999999999; > RETURN j; > ELSE > RETURN 2*i; > END IF; > END;$$; > > CHECK FUNCTION t(integer); -- no error > > SELECT t(1); > ERROR: value "9999999999999999999" is out of range for type integer > CONTEXT: PL/pgSQL function "t" line 4 at assignment >
This kind of check are little bit difficult. It is solveable but I would to have a skelet in core, and then this skelet can be enhanced step by step. Where is problem? PL/pgSQL usually don't work with numeric constant. Almost all numbers are expressions - and checking function ensure only semantic validity of expression, but don't try to evaluate expression. So isn't possible to check runtime errors now. Regards Pavel -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers