-- $Header$

DROP TABLE pgpool_catalog.insert_lock;

CREATE SCHEMA pgpool_catalog;
CREATE TABLE pgpool_catalog.insert_lock(reloid OID PRIMARY KEY);
 
-- this row is used as the row lock target when pgpool inserts new oid
INSERT INTO pgpool_catalog.insert_lock VALUES (0);

-- allow "SELECT ... FOR UPDATE" and "INSERT ..." to all roles
GRANT SELECT ON pgpool_catalog.insert_lock TO PUBLIC;
GRANT UPDATE ON pgpool_catalog.insert_lock TO PUBLIC;
GRANT INSERT ON pgpool_catalog.insert_lock TO PUBLIC;

-- Create lock control table for tables using sequence in native replication mode.

DROP TABLE pgpool_catalog.insert_lock;

CREATE SCHEMA pgpool_catalog;
CREATE TABLE pgpool_catalog.insert_lock(reloid OID PRIMARY KEY);
 
-- this row is used as the row lock target when pgpool inserts new oid
INSERT INTO pgpool_catalog.insert_lock VALUES (0);

-- allow "SELECT ... FOR UPDATE" and "INSERT ..." to all roles
GRANT USAGE ON SCHEMA pgpool_catalog TO PUBLIC;
GRANT SELECT ON pgpool_catalog.insert_lock TO PUBLIC;
GRANT UPDATE ON pgpool_catalog.insert_lock TO PUBLIC;
GRANT INSERT ON pgpool_catalog.insert_lock TO PUBLIC;

Fix that the script forgets to allow public access to pgpool_catalog.
Fix that the script forgets to allow public access to pgpool_catalog.

The bug prevents inserting data into user tables if pgpool_catalog is
created in native replication mode.  The bug was there from day 1. I
wonder why nobody noticed until today.  Per [pgpool-general-jp: 1229].
