Description
noneFunction properties
| name | value |
|---|
| name | public.checkauth |
| return type | pg_catalog.int4
|
| language | SQL |
| deterministic | NO |
Usage
result = public.checkauth();
Code
CREATE FUNCTION checkauth(text, text, text) RETURNS integer
AS $_$
DECLARE
schema text;
BEGIN
IF NOT LongTransactionsEnabled() THEN
RAISE EXCEPTION 'Long transaction support disabled, use EnableLongTransaction() to enable.';
END IF;
if ( $1 != '' ) THEN
schema = $1;
ELSE
SELECT current_schema() into schema;
END IF;
-- TODO: check for an already existing trigger ?
EXECUTE 'CREATE TRIGGER check_auth BEFORE UPDATE OR DELETE ON '
|| quote_ident(schema) || '.' || quote_ident($2)
||' FOR EACH ROW EXECUTE PROCEDURE CheckAuthTrigger('
|| quote_literal($3) || ')';
RETURN 0;
END;
$_$
LANGUAGE plpgsql;