psbl=# \df+ merge_blocklist List of functions Schema | Name | Result data type | Argument data types | Owner | Language | Source code | Description --------+-----------------+------------------+-----------------------------------+----------+----------+-------------+------------- public | merge_blocklist | void | inet, timestamp without time zone | postgres | plpgsql | BEGIN LOOP UPDATE blocklist SET expires = expiry_time WHERE ip = ipaddr; IF found THEN RETURN; END IF; BEGIN INSERT INTO blocklist(ip,expires) VALUES (ipaddr, expiry_time); RETURN; EXCEPTION WHEN unique_violation THEN -- do nothing END; END LOOP; END; | (1 row)