terraware
Database
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
addauth
Description
args: auth_token - Adds an authorization token to be used in the current transaction.
Parameters
Name
Type
Mode
$1
text
IN
Definition
DECLARE lockid alias for $1; okay boolean; myrec record; BEGIN -- check to see if table exists -- if not, CREATE TEMP TABLE mylock (transid xid, lockcode text) okay := 'f'; FOR myrec IN SELECT * FROM pg_class WHERE relname = 'temp_lock_have_table' LOOP okay := 't'; END LOOP; IF (okay <> 't') THEN CREATE TEMP TABLE temp_lock_have_table (transid xid, lockcode text); -- this will only work from pgsql7.4 up -- ON COMMIT DELETE ROWS; END IF; -- INSERT INTO mylock VALUES ( $1) -- EXECUTE 'INSERT INTO temp_lock_have_table VALUES ( '|| -- quote_literal(getTransactionID()) || ',' || -- quote_literal(lockid) ||')'; INSERT INTO temp_lock_have_table VALUES (getTransactionID(), lockid); RETURN true::boolean; END;