diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2014-04-06 12:21:51 -0400 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2014-04-06 12:21:51 -0400 |
commit | 7d8f1de1bc04bf8ddda6548156ef32f46e13dd50 (patch) | |
tree | 915953680e01556710e9265fb259c990753358c2 /doc/src | |
parent | f14a6bbedb79adce2298d0d4f5e2abe8563e0eca (diff) | |
download | postgresql-7d8f1de1bc04bf8ddda6548156ef32f46e13dd50.tar.gz postgresql-7d8f1de1bc04bf8ddda6548156ef32f46e13dd50.zip |
Extra warnings and errors for PL/pgSQL
Infrastructure to allow
plpgsql.extra_warnings
plpgsql.extra_errors
Initial extra checks only for shadowed_variables
Marko Tiikkaja and Petr Jelinek
Reviewed by Simon Riggs and Pavel Stěhule
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/plpgsql.sgml | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index bddd4585283..a549a24eaef 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -4711,6 +4711,56 @@ a_output := a_output || $$ if v_$$ || referrer_keys.kind || $$ like '$$ </variablelist> </sect2> + <sect2 id="plpgsql-extra-checks"> + <title>Additional compile-time checks</title> + + <para> + To aid the user in finding instances of simple but common problems before + they cause harm, <application>PL/PgSQL</> provides additional + <replaceable>checks</>. When enabled, depending on the configuration, they + can be used to emit either a <literal>WARNING</> or an <literal>ERROR</> + during the compilation of a function. A function which has received + a <literal>WARNING</> can be executed without producing further messages, + so you are advised to test in a separate development environment. + </para> + + <para> + These additional checks are enabled through the configuration variables + <varname>plpgsql.extra_warnings</> for warnings and + <varname>plpgsql.extra_errors</> for errors. Both can be set either to + a comma-separated list of checks, <literal>"none"</> or <literal>"all"</>. + The default is <literal>"none"</>. Currently the list of available checks + includes only one: + <variablelist> + <varlistentry> + <term><varname>shadowed_variables</varname></term> + <listitem> + <para> + Checks if a declaration shadows a previously defined variable. + </para> + </listitem> + </varlistentry> + </variablelist> + + The following example shows the effect of <varname>plpgsql.extra_warnings</> + set to <varname>shadowed_variables</>: +<programlisting> +SET plpgsql.extra_warnings TO 'shadowed_variables'; + +CREATE FUNCTION foo(f1 int) RETURNS int AS $$ +DECLARE +f1 int; +BEGIN +RETURN f1; +END +$$ LANGUAGE plpgsql; +WARNING: variable "f1" shadows a previously defined variable +LINE 3: f1 int; + ^ +CREATE FUNCTION +</programlisting> + </para> + </sect2> </sect1> <!-- **** Porting from Oracle PL/SQL **** --> |