Skip to content

Commit fdb96ae

Browse files
committed
[Issue #76] add database name to checkdb messages about successful/failed amcheck for an index
1 parent fcc1c4b commit fdb96ae

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

Diff for: src/backup.c

+23-12
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ static void do_block_validation(void);
107107
static void do_amcheck(void);
108108
static void *check_files(void *arg);
109109
static void *check_indexes(void *arg);
110-
static parray* get_index_list(PGresult* res_db, int db_number,
111-
bool first_db_with_amcheck, PGconn* db_conn);
110+
static parray* get_index_list(PGresult* res_db,
111+
bool first_db_with_amcheck, PGconn* db_conn, char *dbname);
112112
static bool amcheck_one_index(backup_files_arg *arguments,
113113
pg_indexEntry *ind);
114114

@@ -730,15 +730,18 @@ do_amcheck(void)
730730
for(i = 0; i < n_databases; i++)
731731
{
732732
int j;
733+
char *dbname;
733734

734735
if (index_list != NULL)
735736
{
736737
free(index_list);
737738
index_list = NULL;
738739
}
739740

740-
index_list = get_index_list(res_db, i,
741-
first_db_with_amcheck, db_conn);
741+
dbname = PQgetvalue(res_db, i, 0);
742+
743+
index_list = get_index_list(res_db,
744+
first_db_with_amcheck, db_conn, dbname);
742745

743746
if (index_list == NULL)
744747
{
@@ -787,6 +790,11 @@ do_amcheck(void)
787790
check_isok = false;
788791
}
789792

793+
if (check_isok)
794+
elog(INFO, "Amcheck succeeded for database '%s'", dbname);
795+
else
796+
elog(WARNING, "Amcheck failed for database '%s'", dbname);
797+
790798
/* cleanup */
791799
pgut_disconnect(db_conn);
792800

@@ -3176,15 +3184,13 @@ check_external_for_tablespaces(parray *external_list)
31763184

31773185
/* Get index list for given database */
31783186
static parray*
3179-
get_index_list(PGresult *res_db, int db_number,
3180-
bool first_db_with_amcheck, PGconn *db_conn)
3187+
get_index_list(PGresult *res_db, bool first_db_with_amcheck,
3188+
PGconn *db_conn, char *dbname)
31813189
{
31823190
PGresult *res;
31833191
char *nspname = NULL;
31843192
int i;
31853193

3186-
dbname = PQgetvalue(res_db, db_number, 0);
3187-
31883194
db_conn = pgut_connect(instance_config.pghost, instance_config.pgport,
31893195
dbname,
31903196
instance_config.pguser);
@@ -3326,19 +3332,24 @@ amcheck_one_index(backup_files_arg *arguments,
33263332

33273333
if (PQresultStatus(res) != PGRES_TUPLES_OK)
33283334
{
3329-
elog(WARNING, "Thread [%d]. Amcheck failed for index: '%s.%s': %s",
3330-
arguments->thread_num, ind->amcheck_nspname,
3335+
elog(WARNING, "Thread [%d]. Amcheck failed in database '%s' for index: '%s.%s': %s",
3336+
arguments->thread_num,
3337+
ind->dbname,
3338+
ind->amcheck_nspname,
33313339
ind->name, PQresultErrorMessage(res));
33323340

33333341
pfree(params[0]);
3342+
pfree(query);
33343343
PQclear(res);
33353344
return false;
33363345
}
33373346
else
3338-
elog(LOG, "Thread [%d]. Amcheck succeeded for index: '%s.%s'",
3339-
arguments->thread_num, ind->amcheck_nspname, ind->name);
3347+
elog(LOG, "Thread [%d]. Amcheck succeeded in database '%s' for index: '%s.%s'",
3348+
arguments->thread_num, ind->dbname,
3349+
ind->amcheck_nspname, ind->name);
33403350

33413351
pfree(params[0]);
3352+
pfree(query);
33423353
PQclear(res);
33433354
return true;
33443355
}

0 commit comments

Comments
 (0)