On Mon, Aug 18, 2014 at 2:38 PM, Michael Paquier
<michael.paqu...@gmail.com> wrote:
> On Fri, Aug 15, 2014 at 5:17 PM, Michael Paquier
> <michael.paqu...@gmail.com> wrote:
>> Thanks for your review.
>>
>> On Fri, Aug 15, 2014 at 12:56 AM,  <furu...@pm.nttdata.co.jp> wrote:
>>> At consistency with pg_recvlogical, do you think about --start?
>> I did not add that for the sake of backward-compatibility as in
>> pg_recvlogical an action is mandatory. It is not the case now of
>> pg_receivexlog.
>>
>>> [postgres postgresql-6aa6158]$ make > /dev/null
>>> streamutil.c: In function 'CreateReplicationSlot':
>>> streamutil.c:244: warning: suggest parentheses around '&&' within '||'
>> I see. Here is a rebased patch.
>
> Looking more at the code, IDENTIFY_SYSTEM management can be unified
> into a single function. So I have written a newer version of the patch
> grouping IDENTIFY_SYSTEM call into a single function for both
> utilities, fixing at the same time a couple of other issues:
> - correct use of TimelineID in code
> - IDENTIFY_SYSTEM checks were incorrect (even in HEAD). The following
> check was done but in 9.4 this command returns 4 fields:
> (PQntuples(res) != 1 || PQnfields(res) < 3)
> That's not directly related to this patch, but making some corrections
> is not going to hurt..

Good catch! I found that libpqwalreceiver.c, etc have the same problem.
It's better to fix this separately. Patch attached.

Regards,

-- 
Fujii Masao
*** a/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
--- b/src/backend/replication/libpqwalreceiver/libpqwalreceiver.c
***************
*** 131,137 **** libpqrcv_identify_system(TimeLineID *primary_tli)
  						"the primary server: %s",
  						PQerrorMessage(streamConn))));
  	}
! 	if (PQnfields(res) < 3 || PQntuples(res) != 1)
  	{
  		int			ntuples = PQntuples(res);
  		int			nfields = PQnfields(res);
--- 131,137 ----
  						"the primary server: %s",
  						PQerrorMessage(streamConn))));
  	}
! 	if (PQnfields(res) < 4 || PQntuples(res) != 1)
  	{
  		int			ntuples = PQntuples(res);
  		int			nfields = PQnfields(res);
***************
*** 140,146 **** libpqrcv_identify_system(TimeLineID *primary_tli)
  		ereport(ERROR,
  				(errmsg("invalid response from primary server"),
  				 errdetail("Could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields.",
! 						   ntuples, nfields, 3, 1)));
  	}
  	primary_sysid = PQgetvalue(res, 0, 0);
  	*primary_tli = pg_atoi(PQgetvalue(res, 0, 1), 4, 0);
--- 140,146 ----
  		ereport(ERROR,
  				(errmsg("invalid response from primary server"),
  				 errdetail("Could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields.",
! 						   ntuples, nfields, 4, 1)));
  	}
  	primary_sysid = PQgetvalue(res, 0, 0);
  	*primary_tli = pg_atoi(PQgetvalue(res, 0, 1), 4, 0);
*** a/src/bin/pg_basebackup/pg_basebackup.c
--- b/src/bin/pg_basebackup/pg_basebackup.c
***************
*** 1644,1654 **** BaseBackup(void)
  				progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
  		disconnect_and_exit(1);
  	}
! 	if (PQntuples(res) != 1 || PQnfields(res) < 3)
  	{
  		fprintf(stderr,
  				_("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
! 				progname, PQntuples(res), PQnfields(res), 1, 3);
  		disconnect_and_exit(1);
  	}
  	sysidentifier = pg_strdup(PQgetvalue(res, 0, 0));
--- 1644,1654 ----
  				progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
  		disconnect_and_exit(1);
  	}
! 	if (PQntuples(res) != 1 || PQnfields(res) < 4)
  	{
  		fprintf(stderr,
  				_("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
! 				progname, PQntuples(res), PQnfields(res), 1, 4);
  		disconnect_and_exit(1);
  	}
  	sysidentifier = pg_strdup(PQgetvalue(res, 0, 0));
*** a/src/bin/pg_basebackup/pg_receivexlog.c
--- b/src/bin/pg_basebackup/pg_receivexlog.c
***************
*** 290,300 **** StreamLog(void)
  				progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
  		disconnect_and_exit(1);
  	}
! 	if (PQntuples(res) != 1 || PQnfields(res) < 3)
  	{
  		fprintf(stderr,
  				_("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
! 				progname, PQntuples(res), PQnfields(res), 1, 3);
  		disconnect_and_exit(1);
  	}
  	servertli = atoi(PQgetvalue(res, 0, 1));
--- 290,300 ----
  				progname, "IDENTIFY_SYSTEM", PQerrorMessage(conn));
  		disconnect_and_exit(1);
  	}
! 	if (PQntuples(res) != 1 || PQnfields(res) < 4)
  	{
  		fprintf(stderr,
  				_("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
! 				progname, PQntuples(res), PQnfields(res), 1, 4);
  		disconnect_and_exit(1);
  	}
  	servertli = atoi(PQgetvalue(res, 0, 1));
*** a/src/bin/pg_basebackup/receivelog.c
--- b/src/bin/pg_basebackup/receivelog.c
***************
*** 499,509 **** ReceiveXlogStream(PGconn *conn, XLogRecPtr startpos, uint32 timeline,
  			PQclear(res);
  			return false;
  		}
! 		if (PQntuples(res) != 1 || PQnfields(res) < 3)
  		{
  			fprintf(stderr,
  					_("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
! 					progname, PQntuples(res), PQnfields(res), 1, 3);
  			PQclear(res);
  			return false;
  		}
--- 499,509 ----
  			PQclear(res);
  			return false;
  		}
! 		if (PQntuples(res) != 1 || PQnfields(res) < 4)
  		{
  			fprintf(stderr,
  					_("%s: could not identify system: got %d rows and %d fields, expected %d rows and %d or more fields\n"),
! 					progname, PQntuples(res), PQnfields(res), 1, 4);
  			PQclear(res);
  			return false;
  		}
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to