Question about WalSndWriteData

Поиск
Список
Период
Сортировка
От Konstantin Knizhnik
Тема Question about WalSndWriteData
Дата
Msg-id ce2bc24e-9fe4-28ad-6f9e-f8bf842a96af@postgrespro.ru
обсуждение исходный текст
Ответы Re: Question about WalSndWriteData  (Peter Eisentraut <peter.eisentraut@2ndquadrant.com>)
Список pgsql-hackers
Hi hackes,

I confused by the following code in WalSndWriteData:

     /* output previously gathered data in a CopyData packet */
     pq_putmessage_noblock('d', ctx->out->data, ctx->out->len);

     /*
      * Fill the send timestamp last, so that it is taken as late as 
possible.
      * This is somewhat ugly, but the protocol is set as it's already 
used for
      * several releases by streaming physical replication.
      */
     resetStringInfo(&tmpbuf);
     now = GetCurrentTimestamp();
     pq_sendint64(&tmpbuf, now);
     memcpy(&ctx->out->data[1 + sizeof(int64) + sizeof(int64)],
            tmpbuf.data, sizeof(int64));


pq_putmessage_noblock copies data from ctx->out buffer to libpq buffers.
After it we write timestamp to ctx->out buffer.
And comments says that we should do it "as late as possible".
But this timestamp is not included in the copy data packet which is 
already copied to libpq connection buffer.
And next WalSndPrepareWrite call will reset ctx->out buffer.

So I wonder what is the reason of writing timestamp in ctx->out buffer 
after processing it by pq_putmessage_noblock?

-- 
Konstantin Knizhnik
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: SSL passphrase prompt external command
Следующее
От: Peter Eisentraut
Дата:
Сообщение: Re: fixing more format truncation issues