From 689746c045b169edbc694d6cf9176fe5f6c0b264 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Mon, 7 Oct 2013 15:38:49 -0400 Subject: plpgsql: Add new option print_strict_params. This option provides more detailed error messages when STRICT is used and the number of rows returned is not one. Marko Tiikkaja, reviewed by Ian Lawrence Barwick --- doc/src/sgml/plpgsql.sgml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'doc/src') diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index 0fe6bcf470d..ca2c2b5851b 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -1076,6 +1076,30 @@ END; always sets FOUND to true. + + If print_strict_params is enabled for the function, + you will get information about the parameters passed to the + query in the DETAIL part of the error message produced + when the requirements of STRICT are not met. You can change this + setting on a system-wide basis by setting + plpgsql.print_strict_params, though only subsequent + function compilations will be affected. You can also enable it + on a per-function basis by using a compiler option: + +CREATE FUNCTION get_userid(username text) RETURNS int +AS $$ +#print_strict_params on +DECLARE +userid int; +BEGIN + SELECT users.userid INTO STRICT userid + FROM users WHERE users.username = get_userid.username; + RETURN userid; +END +$$ LANGUAGE plpgsql; + + + For INSERT/UPDATE/DELETE with RETURNING, PL/pgSQL reports -- cgit v1.2.3