Skip to content

Instantly share code, notes, and snippets.

@matthew-n
Last active August 5, 2017 03:43
Show Gist options
  • Save matthew-n/bcb474033038a5e24189036f1166a23a to your computer and use it in GitHub Desktop.
Save matthew-n/bcb474033038a5e24189036f1166a23a to your computer and use it in GitHub Desktop.
things not so obvious about plpgsql

End of §41.5.3 - INTO key word

When selecting into a variable it will emit under-select, and over selection if you use strict, as exception types.

SELECT _col_ into strict _v_something_
EXCEPTION
  WHEN NO_DATA_FOUND THEN
    RAISE ...
  WHEN TOO_MANY_ROWS THEN
    RAISE ...
END;

§41.6.2 - WHEN Statements

PLPGslq dosen't have fall through but dose have testing of multiple values, like an IN clause.

  CASE x
    WHEN 1,2 THEN ..
    ELSE
      ...

Exceptions too, just another kind of case statement.

  EXCEPTION
    WHEN CLASS_NAME_1, CLASS_NAME_2 THEN ..
    WHEN OTHER
      ...

§41.6.6 - Error Info

Lots of good stuff

§41.8.2 - Asserts

plpgsql.check_asserts := [ON|OFF]

End of §41.10.1 - Resolving variables and Columns

plpgsql.veriable_conflict := [error|user_variable|use_column]

§41.11.2 - Additional compile time checks

plpgsql.extra_warnings := [none|all| 'list,of,names,...'] plpgsql.extra_errors := [none|all| 'list,of,names,...']

Example:

  SET plpgsql.extra_warnings := 'shadowed_variables';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment