Skip to content

Commit 8337204

Browse files
committed
Some error handling cleanup for index building.
Don't bother doing a 'goto cleanup;' after an ereport(ERROR, ...).
1 parent 61bf8ac commit 8337204

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

bin/pg_repack.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,6 @@ repack_one_index(Oid table, const char *table_name, Oid index, const char *schem
16261626
{
16271627
ereport(ERROR, (errcode(EINVAL),
16281628
errmsg("unable to generate SQL to CREATE new index")));
1629-
goto cleanup;
16301629
}
16311630
create_idx = getstr(res, 0, 0);
16321631
CLEARPGRES(res);
@@ -1648,7 +1647,6 @@ repack_one_index(Oid table, const char *table_name, Oid index, const char *schem
16481647
" was interrupted and failed to clean up"
16491648
" the temporary objects. Please use \"DROP INDEX %s\""
16501649
" to remove this index.", temp_index.data)));
1651-
goto cleanup;
16521650
}
16531651
CLEARPGRES(res);
16541652

@@ -1669,6 +1667,8 @@ repack_one_index(Oid table, const char *table_name, Oid index, const char *schem
16691667
pgut_command(connection, "SELECT repack.repack_index_swap($1)", 1, params);
16701668
pgut_command(connection, "COMMIT", 0, NULL);
16711669

1670+
ret = true;
1671+
16721672
drop_idx:
16731673
initStringInfo(&sql);
16741674
#if PG_VERSION_NUM < 90200
@@ -1678,9 +1678,7 @@ repack_one_index(Oid table, const char *table_name, Oid index, const char *schem
16781678
#endif
16791679
appendStringInfo(&sql, "%s", temp_index.data);
16801680
command(sql.data, 0, NULL);
1681-
ret = true;
16821681

1683-
cleanup:
16841682
CLEARPGRES(res);
16851683
termStringInfo(&sql);
16861684
return ret;
@@ -1735,7 +1733,6 @@ repack_all_indexes(char *errbuf, size_t errsize)
17351733
ereport(ERROR,
17361734
(errcode(EINVAL),
17371735
errmsg("index \"%s\" does not exist.\n", r_index)));
1738-
goto cleanup;
17391736
}
17401737
}
17411738

@@ -1769,7 +1766,8 @@ repack_all_indexes(char *errbuf, size_t errsize)
17691766
num = PQntuples(res);
17701767
if (num == 0)
17711768
{
1772-
elog(WARNING, "\"%s\" does not have any indexes", table_list.head->val);
1769+
elog(WARNING, "\"%s\" does not have any indexes",
1770+
table_list.head->val);
17731771
ret = true;
17741772
goto cleanup;
17751773
}

0 commit comments

Comments
 (0)