pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: Refactor libpqwalreceiver
5+ messages / 4 participants
[nested] [flat]

* pgsql: Refactor libpqwalreceiver
@ 2016-12-02 01:29  Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 1 reply; 5+ messages in thread

From: Peter Eisentraut @ 2016-12-02 01:29 UTC (permalink / raw)
  To: pgsql-committers

Refactor libpqwalreceiver

The whole walreceiver API is now wrapped into a struct, like most of our
other loadable module APIs.  The libpq connection is no longer a global
variable in libpqwalreceiver.  Instead, it is encapsulated into a struct
that is passed around the functions.  This allows multiple walreceivers
to run at the same time.

Add some rudimentary support for logical replication connections to
libpqwalreceiver.

These changes are mostly cosmetic and are going to be useful for the
future logical replication patches.

From: Petr Jelinek <petr@2ndquadrant.com>

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/78c8c814390f14398e8fd43fe7282cb2e260b50f

Modified Files
--------------
.../libpqwalreceiver/libpqwalreceiver.c            | 266 ++++++++++++---------
src/backend/replication/walreceiver.c              |  59 +++--
src/include/replication/walreceiver.h              |  83 +++++--
3 files changed, 235 insertions(+), 173 deletions(-)


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


^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Refactor libpqwalreceiver
@ 2016-12-02 02:59  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Peter Eisentraut <peter_e@gmx.net>
  0 siblings, 1 reply; 5+ messages in thread

From: Tom Lane @ 2016-12-02 02:59 UTC (permalink / raw)
  To: Peter Eisentraut <peter_e@gmx.net>; +Cc: pgsql-committers

Peter Eisentraut <peter_e@gmx.net> writes:
> Refactor libpqwalreceiver

Buildfarm results indicate this broke the Windows build.

			regards, tom lane


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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Refactor libpqwalreceiver
@ 2016-12-02 04:17  Alvaro Herrera <alvherre@2ndquadrant.com>
  parent: Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 5+ messages in thread

From: Alvaro Herrera @ 2016-12-02 04:17 UTC (permalink / raw)
  To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Peter Eisentraut <peter_e@gmx.net>; pgsql-committers

Tom Lane wrote:
> Peter Eisentraut <peter_e@gmx.net> writes:
> > Refactor libpqwalreceiver
> 
> Buildfarm results indicate this broke the Windows build.

src/backend/replication/walreceiver.c(296): error C2039: 'pgwin32_connect' : is not a member of 'WalReceiverFunctionsType' [c:\prog\bf\root\HEAD\pgsql.build\postgres.vcxproj]
          c:\prog\bf\root\HEAD\pgsql.build\src\include\replication/walreceiver.h(163) : see declaration of 'WalReceiverFunctionsType'
src/backend/replication/walreceiver.c(1152): warning C4003: not enough actual parameters for macro 'send' [c:\prog\bf\root\HEAD\pgsql.build\postgres.vcxproj]
src/backend/replication/walreceiver.c(1152): error C2039: 'pgwin32_send' : is not a member of 'WalReceiverFunctionsType' [c:\prog\bf\root\HEAD\pgsql.build\postgres.vcxproj]
          c:\prog\bf\root\HEAD\pgsql.build\src\include\replication/walreceiver.h(163) : see declaration of 'WalReceiverFunctionsType'
src/backend/replication/walreceiver.c(1152): error C2059: syntax error : ')' [c:\prog\bf\root\HEAD\pgsql.build\postgres.vcxproj]
src/backend/replication/walreceiver.c(1230): warning C4003: not enough actual parameters for macro 'send' [c:\prog\bf\root\HEAD\pgsql.build\postgres.vcxproj]
src/backend/replication/walreceiver.c(1230): error C2039: 'pgwin32_send' : is not a member of 'WalReceiverFunctionsType' [c:\prog\bf\root\HEAD\pgsql.build\postgres.vcxproj]
          c:\prog\bf\root\HEAD\pgsql.build\src\include\replication/walreceiver.h(163) : see declaration of 'WalReceiverFunctionsType'
src/backend/replication/walreceiver.c(1230): error C2059: syntax error : ')' [c:\prog\bf\root\HEAD\pgsql.build\postgres.vcxproj]

That's because win32.h has this line:

#define connect(s, name, namelen) pgwin32_connect(s, name, namelen)

which breaks the use of "connect" as a struct member name (same with send).
The easiest fix seems to rename the struct members.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: pgsql: Refactor libpqwalreceiver
@ 2016-12-02 11:40  Petr Jelinek <petr.jelinek@2ndquadrant.com>
  parent: Alvaro Herrera <alvherre@2ndquadrant.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Petr Jelinek @ 2016-12-02 11:40 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@2ndquadrant.com>; Tom Lane <tgl@sss.pgh.pa.us>; +Cc: Peter Eisentraut <peter_e@gmx.net>; pgsql-committers

On 02/12/16 05:17, Alvaro Herrera wrote:
> Tom Lane wrote:
>> Peter Eisentraut <peter_e@gmx.net> writes:
>>> Refactor libpqwalreceiver
>>
>> Buildfarm results indicate this broke the Windows build.
> 
> src/backend/replication/walreceiver.c(296): error C2039: 'pgwin32_connect' : is not a member of 'WalReceiverFunctionsType' [c:\prog\bf\root\HEAD\pgsql.build\postgres.vcxproj]
>           c:\prog\bf\root\HEAD\pgsql.build\src\include\replication/walreceiver.h(163) : see declaration of 'WalReceiverFunctionsType'
> src/backend/replication/walreceiver.c(1152): warning C4003: not enough actual parameters for macro 'send' [c:\prog\bf\root\HEAD\pgsql.build\postgres.vcxproj]
> src/backend/replication/walreceiver.c(1152): error C2039: 'pgwin32_send' : is not a member of 'WalReceiverFunctionsType' [c:\prog\bf\root\HEAD\pgsql.build\postgres.vcxproj]
>           c:\prog\bf\root\HEAD\pgsql.build\src\include\replication/walreceiver.h(163) : see declaration of 'WalReceiverFunctionsType'
> src/backend/replication/walreceiver.c(1152): error C2059: syntax error : ')' [c:\prog\bf\root\HEAD\pgsql.build\postgres.vcxproj]
> src/backend/replication/walreceiver.c(1230): warning C4003: not enough actual parameters for macro 'send' [c:\prog\bf\root\HEAD\pgsql.build\postgres.vcxproj]
> src/backend/replication/walreceiver.c(1230): error C2039: 'pgwin32_send' : is not a member of 'WalReceiverFunctionsType' [c:\prog\bf\root\HEAD\pgsql.build\postgres.vcxproj]
>           c:\prog\bf\root\HEAD\pgsql.build\src\include\replication/walreceiver.h(163) : see declaration of 'WalReceiverFunctionsType'
> src/backend/replication/walreceiver.c(1230): error C2059: syntax error : ')' [c:\prog\bf\root\HEAD\pgsql.build\postgres.vcxproj]
> 
> That's because win32.h has this line:
> 
> #define connect(s, name, namelen) pgwin32_connect(s, name, namelen)
> 
> which breaks the use of "connect" as a struct member name (same with send).
> The easiest fix seems to rename the struct members.
> 

Hi,

Yes, that seems to be the case.

Something as simple as attached should do.

-- 
  Petr Jelinek                  http://www.2ndQuadrant.com/
  PostgreSQL Development, 24x7 Support, Training & Services

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

Attachments:

Prefix-WalReceiverFunctionsType-members-with-walrcv_.patch (application/x-patch, 3.3K) download From 6513f75c2e04c6db186f53528f5a6adfa93feabd Mon Sep 17 00:00:00 2001 From: Petr Jelinek <pjmodos@pjmodos.net> Date: Fri, 2 Dec 2016 12:37:00 +0100 Subject: [PATCH] Prefix WalReceiverFunctionsType members with walrcv_ This avoids naming conflicts on Windows introduced by 78c8c8143. --- src/include/replication/walreceiver.h | 36 +++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h index edb14b5..28dc1fc 100644 --- a/src/include/replication/walreceiver.h +++ b/src/include/replication/walreceiver.h @@ -161,37 +161,37 @@ typedef void (*walrcv_disconnect_fn) (WalReceiverConn *conn); typedef struct WalReceiverFunctionsType { - walrcv_connect_fn connect; - walrcv_get_conninfo_fn get_conninfo; - walrcv_identify_system_fn identify_system; - walrcv_readtimelinehistoryfile_fn readtimelinehistoryfile; - walrcv_startstreaming_fn startstreaming; - walrcv_endstreaming_fn endstreaming; - walrcv_receive_fn receive; - walrcv_send_fn send; - walrcv_disconnect_fn disconnect; + walrcv_connect_fn walrcv_connect; + walrcv_get_conninfo_fn walrcv_get_conninfo; + walrcv_identify_system_fn walrcv_identify_system; + walrcv_readtimelinehistoryfile_fn walrcv_readtimelinehistoryfile; + walrcv_startstreaming_fn walrcv_startstreaming; + walrcv_endstreaming_fn walrcv_endstreaming; + walrcv_receive_fn walrcv_receive; + walrcv_send_fn walrcv_send; + walrcv_disconnect_fn walrcv_disconnect; } WalReceiverFunctionsType; extern PGDLLIMPORT WalReceiverFunctionsType *WalReceiverFunctions; #define walrcv_connect(conninfo, logical, appname) \ - WalReceiverFunctions->connect(conninfo, logical, appname) + WalReceiverFunctions->walrcv_connect(conninfo, logical, appname) #define walrcv_get_conninfo(conn) \ - WalReceiverFunctions->get_conninfo(conn) + WalReceiverFunctions->walrcv_get_conninfo(conn) #define walrcv_identify_system(conn, primary_tli) \ - WalReceiverFunctions->identify_system(conn, primary_tli) + WalReceiverFunctions->walrcv_identify_system(conn, primary_tli) #define walrcv_readtimelinehistoryfile(conn, tli, filename, content, size) \ - WalReceiverFunctions->readtimelinehistoryfile(conn, tli, filename, content, size) + WalReceiverFunctions->walrcv_readtimelinehistoryfile(conn, tli, filename, content, size) #define walrcv_startstreaming(conn, tli, startpoint, slotname) \ - WalReceiverFunctions->startstreaming(conn, tli, startpoint, slotname) + WalReceiverFunctions->walrcv_startstreaming(conn, tli, startpoint, slotname) #define walrcv_endstreaming(conn, next_tli) \ - WalReceiverFunctions->endstreaming(conn, next_tli) + WalReceiverFunctions->walrcv_endstreaming(conn, next_tli) #define walrcv_receive(conn, buffer, wait_fd) \ - WalReceiverFunctions->receive(conn, buffer, wait_fd) + WalReceiverFunctions->walrcv_receive(conn, buffer, wait_fd) #define walrcv_send(conn, buffer, nbytes) \ - WalReceiverFunctions->send(conn, buffer, nbytes) + WalReceiverFunctions->walrcv_send(conn, buffer, nbytes) #define walrcv_disconnect(conn) \ - WalReceiverFunctions->disconnect(conn) + WalReceiverFunctions->walrcv_disconnect(conn) /* prototypes for functions in walreceiver.c */ extern void WalReceiverMain(void) pg_attribute_noreturn(); -- 2.7.4
^ permalink raw reply [nested|flat] 5+ messages in thread

* Re: pgsql: Refactor libpqwalreceiver
@ 2016-12-02 12:42  Alvaro Herrera <alvherre@2ndquadrant.com>
  parent: Petr Jelinek <petr.jelinek@2ndquadrant.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Alvaro Herrera @ 2016-12-02 12:42 UTC (permalink / raw)
  To: Petr Jelinek <petr.jelinek@2ndquadrant.com>; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; Peter Eisentraut <peter_e@gmx.net>; pgsql-committers

Petr Jelinek wrote:

> Yes, that seems to be the case.
> 
> Something as simple as attached should do.

Pushed.

-- 
Álvaro Herrera                https://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


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



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2016-12-02 12:42 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-12-02 01:29 pgsql: Refactor libpqwalreceiver Peter Eisentraut <peter_e@gmx.net>
2016-12-02 02:59 ` Tom Lane <tgl@sss.pgh.pa.us>
2016-12-02 04:17   ` Alvaro Herrera <alvherre@2ndquadrant.com>
2016-12-02 11:40     ` Petr Jelinek <petr.jelinek@2ndquadrant.com>
2016-12-02 12:42       ` Alvaro Herrera <alvherre@2ndquadrant.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox