From 82ed20e15e52c67cea1e3b3b1b8795cdbd249c05 Mon Sep 17 00:00:00 2001
From: Michael Paquier <michael@paquier.xyz>
Date: Sat, 11 May 2019 13:01:29 +0900
Subject: [PATCH] Fix error reporting in reindexdb
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When failing to reindex a table, reindexdb would generate an extra error
message related to a database failure, which is misleading.

Backpatch all the way down, as this has been introduced by 85e9a5a0.

Discussion: https://postgr.es/m/CAOBaU_Yo61RwNO3cW6WVYWwH7EYMPuexhKqufb2nFGOdunbcHw@mail.gmail.com
Author: Julien Rouhaud
Reviewed-by: Daniel Gustafsson, Álvaro Herrera, Tom Lane, Michael
Paquier
Backpatch-through: 9.4
---
 src/bin/scripts/reindexdb.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c
index c95c1fff152..7c7a82ddb98 100644
--- a/src/bin/scripts/reindexdb.c
+++ b/src/bin/scripts/reindexdb.c
@@ -264,7 +264,7 @@ reindex_one_database(const char *name, const char *dbname, const char *type,
 		if (strcmp(type, "TABLE") == 0)
 			fprintf(stderr, _("%s: reindexing of table \"%s\" in database \"%s\" failed: %s"),
 					progname, name, PQdb(conn), PQerrorMessage(conn));
-		if (strcmp(type, "INDEX") == 0)
+		else if (strcmp(type, "INDEX") == 0)
 			fprintf(stderr, _("%s: reindexing of index \"%s\" in database \"%s\" failed: %s"),
 					progname, name, PQdb(conn), PQerrorMessage(conn));
 		else
-- 
GitLab