Skip to content

Commit a8409dd

Browse files
committed
Merge branch 'amitlan-master'
2 parents d3a99db + ffb1980 commit a8409dd

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

bin/pg_repack.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,8 @@ static char *
243243
utoa(unsigned int value, char *buffer)
244244
{
245245
sprintf(buffer, "%u", value);
246-
/* XXX: originally, we would just return buffer here without
247-
* the pgut_strdup(). But repack_cleanup_callback() seems to
248-
* depend on getting back a freshly strdup'd copy of buffer,
249-
* not sure why. So now we are leaking a tiny bit of memory
250-
* with each utoa() call.
251-
*/
252-
return pgut_strdup(buffer);
246+
247+
return buffer;
253248
}
254249

255250
static pgut_option options[] =
@@ -1397,7 +1392,7 @@ repack_one_table(repack_table *table, const char *orderby)
13971392
elog(DEBUG2, "---- drop ----");
13981393

13991394
command("BEGIN ISOLATION LEVEL READ COMMITTED", 0, NULL);
1400-
params[1] = utoa(temp_obj_num, buffer);
1395+
params[1] = utoa(temp_obj_num, indexbuffer);
14011396
command("SELECT repack.repack_drop($1, $2)", 2, params);
14021397
command("COMMIT", 0, NULL);
14031398
temp_obj_num = 0; /* reset temporary object counter after cleanup */
@@ -1708,11 +1703,12 @@ repack_cleanup_callback(bool fatal, void *userdata)
17081703
Oid target_table = *(Oid *) userdata;
17091704
const char *params[2];
17101705
char buffer[12];
1706+
char num_buff[12];
17111707

17121708
if(fatal)
17131709
{
17141710
params[0] = utoa(target_table, buffer);
1715-
params[1] = utoa(temp_obj_num, buffer);
1711+
params[1] = utoa(temp_obj_num, num_buff);
17161712

17171713
/* testing PQstatus() of connection and conn2, as we do
17181714
* in repack_cleanup(), doesn't seem to work here,
@@ -1738,6 +1734,7 @@ repack_cleanup(bool fatal, const repack_table *table)
17381734
else
17391735
{
17401736
char buffer[12];
1737+
char num_buff[12];
17411738
const char *params[2];
17421739

17431740
/* Try reconnection if not available. */
@@ -1747,7 +1744,7 @@ repack_cleanup(bool fatal, const repack_table *table)
17471744

17481745
/* do cleanup */
17491746
params[0] = utoa(table->target_oid, buffer);
1750-
params[1] = utoa(temp_obj_num, buffer);
1747+
params[1] = utoa(temp_obj_num, num_buff);
17511748
command("SELECT repack.repack_drop($1, $2)", 2, params);
17521749
temp_obj_num = 0; /* reset temporary object counter after cleanup */
17531750
}

0 commit comments

Comments
 (0)