Re: [GENERAL] Allow only certain query on replication slave - Mailing list pgsql-general

From Michael Paquier
Subject Re: [GENERAL] Allow only certain query on replication slave
Date
Msg-id CAB7nPqQaNyi+Bp==g-wO8=1gwV6=0MJVhmX0Qe_4gm=VvOgdGA@mail.gmail.com
Whole thread Raw
In response to [GENERAL] Allow only certain query on replication slave  (basti <mailinglist@unix-solution.de>)
List pgsql-general
On Tue, Oct 24, 2017 at 6:12 AM, basti <mailinglist@unix-solution.de> wrote:
> I have a Postgres slave (wal replication) and want no query on it, expect
>
> - SELECT pg_last_xlog_receive_location()
> - SELECT pg_last_xlog_replay_location()
>
> When I set hot_standby = off in postgres.conf nobody can query the
> replication cluster.
>
> Is there a way to allow only the above query and deny all other?

There is a trick you could use here with two hooks: the planner hook
and the utility hook. The idea is to filter all queries and refuse
them when RecoveryInProgress() is satisfied. The parsed tree can be
used in the planner hook to check for those functions and accept them.
-- 
Michael


-- 
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

pgsql-general by date:

Previous
From: basti
Date:
Subject: [GENERAL] Allow only certain query on replication slave
Next
From: Celia McInnis
Date:
Subject: Re: [GENERAL] using conda environment for plpython3u?