Re: [HACKERS] Missing newlines in error messages

2016-12-15 Thread Magnus Hagander
On Thu, Dec 15, 2016 at 4:38 PM, Tom Lane  wrote:

> Magnus Hagander  writes:
> > While poking around the pg_basebackup code, I noticed there are a lot of
> > error messages are missing the \n at the end. Most of them are very
> > unlikely to happen, but in general I believe all error messages we print
> to
> > stderr from those binaries should have a newline at the end.
>
> > Is that wrong? :)
>
> I think you missed the fact that PQerrorMessage's result will already
> end with a newline.  So most (not all) of these look OK as they stand.
>

Ha, I knew there was something. But somehow I forgot about that one. I was
wondering why nobody had found it before :)

And yeah, that leaves just the one error that I actually bumped into.  I'll
go ahead and apply that one alone then.

Pah. Less coding on jetlag.

Thanks!

-- 
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/


Re: [HACKERS] Missing newlines in error messages

2016-12-15 Thread Tom Lane
Magnus Hagander  writes:
> While poking around the pg_basebackup code, I noticed there are a lot of
> error messages are missing the \n at the end. Most of them are very
> unlikely to happen, but in general I believe all error messages we print to
> stderr from those binaries should have a newline at the end.

> Is that wrong? :)

I think you missed the fact that PQerrorMessage's result will already
end with a newline.  So most (not all) of these look OK as they stand.

regards, tom lane


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


Re: [HACKERS] Missing newlines in error messages

2016-12-15 Thread Magnus Hagander
(oops, accidental send button press)


While poking around the pg_basebackup code, I noticed there are a lot of
error messages are missing the \n at the end. Most of them are very
unlikely to happen, but in general I believe all error messages we print to
stderr from those binaries should have a newline at the end.

Is that wrong? :)

Second -- if we were to backpatch something like the attached patch, is
that going to cause issues for translators?

On Thu, Dec 15, 2016 at 4:33 PM, Magnus Hagander 
wrote:

> While poking around the pg_basebackup code, I noticed there are a lot of
> error messa
>
> --
>  Magnus Hagander
>  Me: http://www.hagander.net/
>  Work: http://www.redpill-linpro.com/
>



-- 
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/
diff --git a/src/bin/pg_basebackup/pg_basebackup.c b/src/bin/pg_basebackup/pg_basebackup.c
index e2875df..f0f7126 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -192,7 +192,7 @@ cleanup_directories_atexit(void)
 
 	if (made_tablespace_dirs || found_tablespace_dirs)
 		fprintf(stderr,
-_("%s: changes to tablespace directories will not be undone"),
+_("%s: changes to tablespace directories will not be undone\n"),
 progname);
 }
 
@@ -1027,7 +1027,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
 	res = PQgetResult(conn);
 	if (PQresultStatus(res) != PGRES_COPY_OUT)
 	{
-		fprintf(stderr, _("%s: could not get COPY data stream: %s"),
+		fprintf(stderr, _("%s: could not get COPY data stream: %s\n"),
 progname, PQerrorMessage(conn));
 		disconnect_and_exit(1);
 	}
@@ -1108,7 +1108,7 @@ ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
 		}
 		else if (r == -2)
 		{
-			fprintf(stderr, _("%s: could not read COPY data: %s"),
+			fprintf(stderr, _("%s: could not read COPY data: %s\n"),
 	progname, PQerrorMessage(conn));
 			disconnect_and_exit(1);
 		}
@@ -1295,7 +1295,7 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
 	res = PQgetResult(conn);
 	if (PQresultStatus(res) != PGRES_COPY_OUT)
 	{
-		fprintf(stderr, _("%s: could not get COPY data stream: %s"),
+		fprintf(stderr, _("%s: could not get COPY data stream: %s\n"),
 progname, PQerrorMessage(conn));
 		disconnect_and_exit(1);
 	}
@@ -1324,7 +1324,7 @@ ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
 		}
 		else if (r == -2)
 		{
-			fprintf(stderr, _("%s: could not read COPY data: %s"),
+			fprintf(stderr, _("%s: could not read COPY data: %s\n"),
 	progname, PQerrorMessage(conn));
 			disconnect_and_exit(1);
 		}
@@ -1736,7 +1736,7 @@ BaseBackup(void)
 
 	if (PQsendQuery(conn, basebkp) == 0)
 	{
-		fprintf(stderr, _("%s: could not send replication command \"%s\": %s"),
+		fprintf(stderr, _("%s: could not send replication command \"%s\": %s\n"),
 progname, "BASE_BACKUP", PQerrorMessage(conn));
 		disconnect_and_exit(1);
 	}
@@ -1747,7 +1747,7 @@ BaseBackup(void)
 	res = PQgetResult(conn);
 	if (PQresultStatus(res) != PGRES_TUPLES_OK)
 	{
-		fprintf(stderr, _("%s: could not initiate base backup: %s"),
+		fprintf(stderr, _("%s: could not initiate base backup: %s\n"),
 progname, PQerrorMessage(conn));
 		disconnect_and_exit(1);
 	}
@@ -1783,7 +1783,7 @@ BaseBackup(void)
 	res = PQgetResult(conn);
 	if (PQresultStatus(res) != PGRES_TUPLES_OK)
 	{
-		fprintf(stderr, _("%s: could not get backup header: %s"),
+		fprintf(stderr, _("%s: could not get backup header: %s\n"),
 progname, PQerrorMessage(conn));
 		disconnect_and_exit(1);
 	}
@@ -1864,7 +1864,7 @@ BaseBackup(void)
 	if (PQresultStatus(res) != PGRES_TUPLES_OK)
 	{
 		fprintf(stderr,
-		 _("%s: could not get transaction log end position from server: %s"),
+		 _("%s: could not get transaction log end position from server: %s\n"),
 progname, PQerrorMessage(conn));
 		disconnect_and_exit(1);
 	}
@@ -1883,7 +1883,7 @@ BaseBackup(void)
 	res = PQgetResult(conn);
 	if (PQresultStatus(res) != PGRES_COMMAND_OK)
 	{
-		fprintf(stderr, _("%s: final receive failed: %s"),
+		fprintf(stderr, _("%s: final receive failed: %s\n"),
 progname, PQerrorMessage(conn));
 		disconnect_and_exit(1);
 	}
diff --git a/src/bin/pg_basebackup/pg_recvlogical.c b/src/bin/pg_basebackup/pg_recvlogical.c
index cb5f989..3b7e90a 100644
--- a/src/bin/pg_basebackup/pg_recvlogical.c
+++ b/src/bin/pg_basebackup/pg_recvlogical.c
@@ -151,7 +151,7 @@ sendFeedback(PGconn *conn, int64 now, bool force, bool replyRequested)
 
 	if (PQputCopyData(conn, replybuf, len) <= 0 || PQflush(conn))
 	{
-		fprintf(stderr, _("%s: could not send feedback packet: %s"),
+		fprintf(stderr, _("%s: could not send feedback packet: %s\n"),
 progname, PQerrorMessage(conn));
 		return false;
 	}
@@ -261,7 +261,7 @@ StreamLogicalLog(void)
 	res = PQexec(conn, query->data);
 	if (PQresultStatus(res) != PGRES_COPY_BOTH)
 	{
-		fprintf(stderr, _("%s: could not send replication command \"%s\": %s"),
+		fprintf(stderr, _("%s: could not send replication c

[HACKERS] Missing newlines in error messages

2016-12-15 Thread Magnus Hagander
While poking around the pg_basebackup code, I noticed there are a lot of
error messa

-- 
 Magnus Hagander
 Me: http://www.hagander.net/
 Work: http://www.redpill-linpro.com/