diff options
| author | Robert Haas <rhaas@postgresql.org> | 2013-10-07 15:38:49 -0400 |
|---|---|---|
| committer | Robert Haas <rhaas@postgresql.org> | 2013-10-07 15:38:49 -0400 |
| commit | 689746c045b169edbc694d6cf9176fe5f6c0b264 (patch) | |
| tree | 0501eabc6099224e77c243cd200ef6c779605251 /doc/src | |
| parent | c01262a82484106111a81dca8c922fd5670b644d (diff) | |
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
Diffstat (limited to 'doc/src')
| -rw-r--r-- | doc/src/sgml/plpgsql.sgml | 24 |
1 files changed, 24 insertions, 0 deletions
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 @@ -1077,6 +1077,30 @@ END; </para> <para> + If <literal>print_strict_params</> is enabled for the function, + you will get information about the parameters passed to the + query in the <literal>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 + <varname>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: +<programlisting> +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; +</programlisting> + </para> + + <para> For <command>INSERT</>/<command>UPDATE</>/<command>DELETE</> with <literal>RETURNING</>, <application>PL/pgSQL</application> reports an error for more than one returned row, even when |
