[HACKERS] initdb: Improve error recovery.

2014-11-27 Thread Mats Erik Andersson
Hello there,

I would like to improve error recovery of initdb when the
password file is empty. The present code declares Error 0
as the cause of failure. It suffices to use ferrer() since
fgets() returns NULL also at a premature EOF.

In addition, a minor case is the need of a line feed in
order to print the error message on a line of its own
seems desirable.

Best regards,
  Mats Erik Andersson


From 5ffe171fb63497a5e2d9d9233282504da0044b8e Mon Sep 17 00:00:00 2001
From: Mats Erik Andersson b...@gisladisker.se
Date: Thu, 27 Nov 2014 12:08:31 +0100
Subject: [PATCH] initdb: Improve error recovery.

In case --pwfile encounters an empty file, this should be
pointed out, not reporting the cause as Error 0 which is
the claim by strerror(). The return value of fgets() is NULL
at EOF, so ferror() must be used to tell the conditions apart.

Insert a line break to interrupt finalize the message m ...
whenever the bki_file is missing.
---
 src/bin/initdb/initdb.c |4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index 3b52867..b76fb3b 100644
--- a/src/bin/initdb/initdb.c
+++ b/src/bin/initdb/initdb.c
@@ -1509,6 +1509,7 @@ bootstrap_template1(void)
 
if (strcmp(headerline, *bki_lines) != 0)
{
+   fprintf(stderr, \n);
fprintf(stderr,
_(%s: input file \%s\ does not belong to 
PostgreSQL %s\n
  Check your installation or specify the 
correct path 
@@ -1663,7 +1664,8 @@ get_set_pwd(void)
if (!fgets(pwdbuf, sizeof(pwdbuf), pwf))
{
fprintf(stderr, _(%s: could not read password from 
file \%s\: %s\n),
-   progname, pwfilename, strerror(errno));
+   progname, pwfilename,
+   ferror(pwf) ? strerror(errno) : 
_(empty file));
exit_nicely();
}
fclose(pwf);
-- 
1.7.3.2



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


[HACKERS] pg_isready: Missing translation macros.

2014-11-27 Thread Mats Erik Andersson
Hello there,

the text response of pg_isready is hard coded in English.
These short snippets really ought to be localized as well.

Best regards,
  Mats Erik Andersson


From eca5f0d8b72b7ae5508af2850977d999a0f2bca4 Mon Sep 17 00:00:00 2001
From: Mats Erik Andersson b...@gisladisker.se
Date: Thu, 27 Nov 2014 11:58:34 +0100
Subject: [PATCH] pg_isready: Missing translation macro.

Mark also response messages as translatable
text snippets.
---
 src/bin/scripts/pg_isready.c |   10 +-
 1 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/bin/scripts/pg_isready.c b/src/bin/scripts/pg_isready.c
index 7707bf1..9da3971 100644
--- a/src/bin/scripts/pg_isready.c
+++ b/src/bin/scripts/pg_isready.c
@@ -196,19 +196,19 @@ main(int argc, char **argv)
switch (rv)
{
case PQPING_OK:
-   printf(accepting connections\n);
+   printf(_(accepting connections\n));
break;
case PQPING_REJECT:
-   printf(rejecting connections\n);
+   printf(_(rejecting connections\n));
break;
case PQPING_NO_RESPONSE:
-   printf(no response\n);
+   printf(_(no response\n));
break;
case PQPING_NO_ATTEMPT:
-   printf(no attempt\n);
+   printf(_(no attempt\n));
break;
default:
-   printf(unknown\n);
+   printf(_(unknown response\n));
}
}
 
-- 
1.7.3.2



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


[HACKERS] vacuumdb: Help text for --analyze-only.

2014-11-17 Thread Mats Erik Andersson
Hello there,

I observe that the help text of vacuumdb for --analyze,
--analyze-only, and --analyze-in-stages could do with
a little clarification in order to be self-documenting
and thus improve the user experience of vacuumdb.

The problem is that the sole addition of the word only to
an otherwise identical text for --analyze and --analyze-only
seems rather obscure. My suggestion follows.

Best regards,
  Mats Erik Andersson
diff --git a/src/bin/scripts/vacuumdb.c b/src/bin/scripts/vacuumdb.c
index 86e6ab3..a07f081 100644
--- a/src/bin/scripts/vacuumdb.c
+++ b/src/bin/scripts/vacuumdb.c
@@ -435,9 +435,9 @@ help(const char *progname)
 	printf(_(  -v, --verbose   write a lot of output\n));
 	printf(_(  -V, --version   output version information, then exit\n));
 	printf(_(  -z, --analyze   update optimizer statistics\n));
-	printf(_(  -Z, --analyze-only  only update optimizer statistics\n));
-	printf(_(  --analyze-in-stages only update optimizer statistics, in multiple\n
-		 stages for faster results\n));
+	printf(_(  -Z, --analyze-only  only update optimizer statistics; no vacuum\n));
+	printf(_(  --analyze-in-stages only update statistics, but in multiple\n
+		 stages for faster results; no vacuum\n));
 	printf(_(  -?, --help  show this help, then exit\n));
 	printf(_(\nConnection options:\n));
 	printf(_(  -h, --host=HOSTNAME   database server host or socket directory\n));

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