You can configure EDB SPL Check's behavior inside a checked function with a pragma function. Like the pragma feature for PL/SQL or ADA languages, EDB SPL Check provides pragma functionality. EDB SPL Check detects functions named spl_check_pragma and takes options from the parameters of the function. These EDB SPL Check options are valid to add to the end of this group of statements:

CREATE OR REPLACE FUNCTION test()
RETURNS void AS $$
BEGIN
  ...
  -- for following statements disable check
  PERFORM spl_check_pragma('disable:check');
  ...
  -- enable check again
  PERFORM spl_check_pragma('enable:check');
  ...
END;
$$ LANGUAGE edbspl;

The function spl_check_pragma is an immutable function that returns 1. It's defined by EDB SPL Check. You can declare alternative spl_check_pragma functions like:

CREATE OR REPLACE FUNCTION spl_check_pragma(VARIADIC args[])
RETURNS int AS $$
SELECT 1
$$ LANGUAGE sql IMMUTABLE;

You can use a pragma function when declaring a part of the top block sets options on a function level:

CREATE OR REPLACE FUNCTION test()
RETURNS void AS $$
DECLARE
  aux int := spl_check_pragma('disable:extra_warnings');
  ...

You can also use a shorter syntax with pragmas:

CREATE OR REPLACE FUNCTION test()
RETURNS void AS $$
DECLARE r record;
BEGIN
  PERFORM 'PRAGMA:TYPE:r (a int, b int)';
  PERFORM 'PRAGMA:TABLE: x (like pg_class)';
  ...

Supported pragmas

echo:str

Prints the string for testing. In the string, use variables like @@id, @@name, or @@signature.

status:check, status:tracer, status:other_warnings, status:performance_warnings, status:extra_warnings, status:security_warnings

Outputs the current value.

enable:other_warnings, enable:performance_warnings, enable:extra_warnings, enable:security_warnings

Enables warnings.

disable:check,disable:tracer, disable:other_warnings, disable:performance_warnings, disable:extra_warnings, disable:security_warnings

Disables the hint returning from an anyelement function. Place the pragma before the RETURN statement.

type:varname typename or type:varname (fieldname type, ...)

Sets type to the record-type variable.

table: name (column_name type, ...) or table: name (like tablename)

Creates an ephemeral temporary table. If you want to specify a schema, it allows only thepg_temp schema.

sequence: name

Creates an ephemeral temporary sequence.

Note

Pragmas enable:tracer and disable:tracer are active for Postgres versions 12 and later.


Could this page be better? Report a problem or suggest an addition!