Re: Allow only certain query on replication slave

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: basti <mailinglist(at)unix-solution(dot)de>
Cc: PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Re: Allow only certain query on replication slave
Date: 2017-10-24 15:37:04
Message-ID: CAB7nPqQaNyi+Bp==g-wO8=1gwV6=0MJVhmX0Qe_4gm=VvOgdGA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, Oct 24, 2017 at 6:12 AM, basti <mailinglist(at)unix-solution(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Celia McInnis 2017-10-24 15:43:11 Re: using conda environment for plpython3u?
Previous Message basti 2017-10-24 13:12:02 Allow only certain query on replication slave