diff options
author | Alexander Korotkov | 2024-03-25 09:35:30 +0000 |
---|---|---|
committer | Alexander Korotkov | 2024-03-25 09:40:25 +0000 |
commit | cc0e7ebd304a24815c0531000a4c3693878cd96c (patch) | |
tree | 0c237891e16c8229ab9735034df7efc071dfb67a | |
parent | 6190d828cd25ae20c0a8548765a0e1b880f1f66d (diff) |
reindexdb: Fix warning about uninitialized indices_tables_cell
Initialize indices_tables_cell with NULL to silence the warning. Also,
refactor the place of the first assignment of indices_tables_cell.
Reported-by: Thomas Munro, David Rowley, Tom Lane, Richard Guo
Discussion: https://postgr.es/m/2348025.1711332418%40sss.pgh.pa.us
Discussion: https://postgr.es/m/E1roXs4-005UdX-1V%40gemulon.postgresql.org
-rw-r--r-- | src/bin/scripts/reindexdb.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/bin/scripts/reindexdb.c b/src/bin/scripts/reindexdb.c index a46b07d97a..904c196fbb 100644 --- a/src/bin/scripts/reindexdb.c +++ b/src/bin/scripts/reindexdb.c @@ -277,7 +277,7 @@ reindex_one_database(ConnParams *cparams, ReindexType type, { PGconn *conn; SimpleStringListCell *cell; - SimpleStringListCell *indices_tables_cell; + SimpleStringListCell *indices_tables_cell = NULL; bool parallel = concurrentCons > 1; SimpleStringList *process_list = user_list; SimpleStringList *indices_tables_list = NULL; @@ -366,12 +366,20 @@ reindex_one_database(ConnParams *cparams, ReindexType type, indices_tables_list = get_parallel_object_list(conn, process_type, user_list, echo); - if (indices_tables_list) - indices_tables_cell = indices_tables_list->head; - - /* Bail out if nothing to process */ - if (process_list == NULL) + /* + * Bail out if nothing to process. 'user_list' was modified + * in-place, so check if it has at least one cell. + */ + if (user_list->head == NULL) return; + + /* + * Assuming 'user_list' is not empty, 'indices_tables_list' + * shouldn't be empty as well. + */ + Assert(indices_tables_list != NULL); + indices_tables_cell = indices_tables_list->head; + break; case REINDEX_SYSTEM: |