Skip to content

Commit 673eac7

Browse files
committed
Change 'have_error' to 'ret' for simplicity.
1 parent d79d342 commit 673eac7

File tree

1 file changed

+5
-19
lines changed

1 file changed

+5
-19
lines changed

bin/pg_repack.c

Lines changed: 5 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -965,7 +965,7 @@ repack_one_table(const repack_table *table, const char *orderby)
965965
char *vxid = NULL;
966966
char buffer[12];
967967
StringInfoData sql;
968-
bool have_error = false;
968+
bool ret = false;
969969

970970
/* Keep track of whether we have gotten through setup to install
971971
* the z_repack_trigger, log table, etc. ourselves. We don't want to
@@ -1015,21 +1015,18 @@ repack_one_table(const repack_table *table, const char *orderby)
10151015
if (PQresultStatus(res) != PGRES_TUPLES_OK)
10161016
{
10171017
elog(ERROR, "%s", PQerrorMessage(connection));
1018-
have_error = true;
10191018
goto cleanup;
10201019
}
10211020
else if (strcmp(getstr(res, 0, 0), "t") != 0)
10221021
{
10231022
elog(WARNING, "Another pg_repack command may be running on the table. Please try again later.");
1024-
have_error = true;
10251023
goto cleanup;
10261024
}
10271025
CLEARPGRES(res);
10281026

10291027
if (!(lock_exclusive(connection, utoa(table->target_oid, buffer), table->lock_table, TRUE)))
10301028
{
10311029
elog(WARNING, "lock_exclusive() failed for %s", table->target_name);
1032-
have_error = true;
10331030
goto cleanup;
10341031
}
10351032

@@ -1069,7 +1066,6 @@ repack_one_table(const repack_table *table, const char *orderby)
10691066
PQgetvalue(res, 0, 0), table->target_name)));
10701067
}
10711068

1072-
have_error = true;
10731069
goto cleanup;
10741070
}
10751071
CLEARPGRES(res);
@@ -1108,14 +1104,12 @@ repack_one_table(const repack_table *table, const char *orderby)
11081104
if (PQsetnonblocking(conn2, 1))
11091105
{
11101106
elog(WARNING, "Unable to set conn2 nonblocking.");
1111-
have_error = true;
11121107
goto cleanup;
11131108
}
11141109
if (!(PQsendQuery(conn2, sql.data)))
11151110
{
11161111
elog(WARNING, "Error sending async query: %s\n%s", sql.data,
11171112
PQerrorMessage(conn2));
1118-
have_error = true;
11191113
goto cleanup;
11201114
}
11211115

@@ -1132,7 +1126,6 @@ repack_one_table(const repack_table *table, const char *orderby)
11321126
if (!(kill_ddl(connection, table->target_oid, true)))
11331127
{
11341128
elog(WARNING, "kill_ddl() failed.");
1135-
have_error = true;
11361129
goto cleanup;
11371130
}
11381131

@@ -1156,7 +1149,6 @@ repack_one_table(const repack_table *table, const char *orderby)
11561149
if (PQresultStatus(res) != PGRES_COMMAND_OK)
11571150
{
11581151
elog(WARNING, "Error with LOCK TABLE: %s", PQerrorMessage(conn2));
1159-
have_error = true;
11601152
goto cleanup;
11611153
}
11621154
CLEARPGRES(res);
@@ -1166,7 +1158,6 @@ repack_one_table(const repack_table *table, const char *orderby)
11661158
if (PQsetnonblocking(conn2, 0))
11671159
{
11681160
elog(WARNING, "Unable to set conn2 blocking.");
1169-
have_error = true;
11701161
goto cleanup;
11711162
}
11721163

@@ -1194,7 +1185,6 @@ repack_one_table(const repack_table *table, const char *orderby)
11941185
{
11951186
elog(WARNING, "Unable to allocate vxid, length: %d\n",
11961187
PQgetlength(res, 0, 0));
1197-
have_error = true;
11981188
goto cleanup;
11991189
}
12001190
CLEARPGRES(res);
@@ -1219,10 +1209,7 @@ repack_one_table(const repack_table *table, const char *orderby)
12191209
* AccessShare lock.
12201210
*/
12211211
if (!(lock_access_share(connection, table->target_oid, table->target_name)))
1222-
{
1223-
have_error = true;
12241212
goto cleanup;
1225-
}
12261213

12271214
command(table->create_table, 0, NULL);
12281215
printfStringInfo(&sql, "SELECT repack.disable_autovacuum('repack.table_%u')", table->target_oid);
@@ -1234,10 +1221,9 @@ repack_one_table(const repack_table *table, const char *orderby)
12341221
/*
12351222
* 3. Create indexes on temp table.
12361223
*/
1237-
if (!rebuild_indexes(table)) {
1238-
have_error = true;
1224+
if (!rebuild_indexes(table))
12391225
goto cleanup;
1240-
}
1226+
12411227
CLEARPGRES(res);
12421228

12431229
/*
@@ -1294,7 +1280,6 @@ repack_one_table(const repack_table *table, const char *orderby)
12941280
{
12951281
elog(WARNING, "lock_exclusive() failed in conn2 for %s",
12961282
table->target_name);
1297-
have_error = true;
12981283
goto cleanup;
12991284
}
13001285

@@ -1330,6 +1315,7 @@ repack_one_table(const repack_table *table, const char *orderby)
13301315
/* Release advisory lock on table. */
13311316
res = pgut_execute(connection, "SELECT pg_advisory_unlock($1::bigint)",
13321317
1, params);
1318+
ret = true;
13331319

13341320
cleanup:
13351321
CLEARPGRES(res);
@@ -1344,7 +1330,7 @@ repack_one_table(const repack_table *table, const char *orderby)
13441330
/* XXX: distinguish between fatal and non-fatal errors via the first
13451331
* arg to repack_cleanup().
13461332
*/
1347-
if (have_error && table_init)
1333+
if ((!ret) && table_init)
13481334
repack_cleanup(false, table);
13491335
}
13501336

0 commit comments

Comments
 (0)