Schema
public
Owner
albenard
Descriptions
args: a_schema_name, a_table_name, a_key_column_name - Creates trigger on a table to prevent/allow updates and deletes of rows based on authorization token.
Options
Option | Value |
---|---|
Returns |
integer |
Language |
plpgsql |
Parameters |
text text text |
Definition
CREATE OR REPLACE FUNCTION public.checkauth (
text,
text,
text
)
RETURNS integer AS
$span$
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;
$span$
LANGUAGE 'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST 100;
COMMENT ON FUNCTION public.checkauth(text, text, text)
IS 'args: a_schema_name, a_table_name, a_key_column_name - Creates trigger on a table to prevent/allow updates and deletes of rows based on authorization token.';
This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 26/02/2014 11:51 |