pggeodb.nancy.inra.fr/db_robot - db_robot on pggeodb.nancy.inra.fr
Previous topic Chapter index Next topic

Function: enablelongtransactions

 

 

Schema

public

 

Owner

albenard

 

Descriptions

Enable long transaction support. This function creates the required metadata tables, needs to be called once before using the other functions in this section. Calling it twice is harmless.

 

Options

Option

Value

Returns

text

Language

plpgsql

Parameters

There are no parameters for function enablelongtransactions

 

Definition

CREATE OR REPLACE FUNCTION public.enablelongtransactions (
)
RETURNS text AS
$span$
DECLARE

"query" text;
exists bool;
rec RECORD;

BEGIN

exists
= 'f';
FOR rec IN SELECT * FROM pg_class WHERE relname = 'authorization_table'
LOOP
exists = 't';
END LOOP;

IF NOT exists
THEN

"query" = 'CREATE TABLE authorization_table (
toid oid, -- table oid
rid text, -- row id
expires timestamp,
authid text
)'
;
EXECUTE "query";
END IF;

exists = 'f';
FOR rec IN SELECT * FROM pg_class WHERE relname = 'authorized_tables'
LOOP
exists = 't';
END LOOP;

IF NOT exists THEN
"query" = 'CREATE VIEW authorized_tables AS ' ||
'SELECT ' ||
'n.nspname as schema, ' ||
'c.relname as table, trim(' ||
quote_literal(chr(92) || '000') ||
' from t.tgargs) as id_column ' ||
'FROM pg_trigger t, pg_class c, pg_proc p ' ||
', pg_namespace n ' ||
'WHERE p.proname = ' || quote_literal('checkauthtrigger') ||
' AND c.relnamespace = n.oid' ||
' AND t.tgfoid = p.oid and t.tgrelid = c.oid';
EXECUTE "query";
END IF;

RETURN 'Long transactions support enabled';
END;
$span$
LANGUAGE
'plpgsql'
VOLATILE
CALLED ON NULL INPUT
SECURITY INVOKER
COST
100;

COMMENT ON FUNCTION public.enablelongtransactions()
IS 'Enable long transaction support. This function creates the required metadata tables, needs to be called once before using the other functions in this section. Calling it twice is harmless.';

This file was generated with SQL Manager for PostgreSQL (www.pgsqlmanager.com) at 26/02/2014 11:51
Previous topic Chapter index Next topic