Re: replication commands and log_statements

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: Fujii Masao <masao(dot)fujii(at)gmail(dot)com>
Cc: Stephen Frost <sfrost(at)snowman(dot)net>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Bruce Momjian <bruce(at)momjian(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Abhijit Menon-Sen <ams(at)2ndquadrant(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Magnus Hagander <magnus(at)hagander(dot)net>
Subject: Re: replication commands and log_statements
Date: 2014-08-14 01:51:39
Message-ID: CAB7nPqRVX5PMf2BBU+GHcVsQL+Ud6tA35HxLQ+46Dqe5NcvTTg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Aug 14, 2014 at 10:40 AM, Fujii Masao <masao(dot)fujii(at)gmail(dot)com> wrote:
> On Thu, Aug 14, 2014 at 9:26 AM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
>> * Amit Kapila (amit(dot)kapila16(at)gmail(dot)com) wrote:
>>> On Wed, Aug 13, 2014 at 4:24 AM, Stephen Frost <sfrost(at)snowman(dot)net> wrote:
>>> > Not entirely sure what you're referring to as 'internally generated'
>>> > here..
>>>
>>> Here 'internally generated' means that user doesn't execute those
>>> statements, rather the replication/backup code form these statements
>>> (IDENTIFY_SYSTEM, TIMELINE_HISTORY, BASE_BACKUP, ...)
>>> and send to server to get the appropriate results.
>>
>> You could argue the same about pg_dump.. I'd not thought of it before,
>> but it might be kind of neat to have psql support "connect in
>> replication mode" and then allow the user to run replication commands.
>
> You can do that by specifying "replication=1" as the conninfo when
> exexcuting psql. For example,
>
> $ psql -d "replication=1"
> psql (9.5devel)
> Type "help" for help.
>
> postgres=# IDENTIFY_SYSTEM;
> systemid | timeline | xlogpos | dbname
> ---------------------+----------+-----------+--------
> 6047222920639525794 | 1 | 0/1711678 |
> (1 row)
More details here:
http://www.postgresql.org/docs/9.4/static/protocol-replication.html

Note as well that not all the commands work though:
=# START_REPLICATION PHYSICAL 0/0;
unexpected PQresultStatus: 8
=# START_REPLICATION PHYSICAL 0/0;
PQexec not allowed during COPY BOTH
We may do something to improve about that but I am not sure it is worth it.
Regards,
--
Michael

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-08-14 02:36:45 Re: jsonb format is pessimal for toast compression
Previous Message Michael Paquier 2014-08-14 01:48:14 Re: option -T in pg_basebackup doesn't work on windows