Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 24503fa

Browse files
committed
reindexdb: move PQfinish() calls to the right place
get_parallel_object_list() has no business closing a connection it did not create. Make things more sensible by closing the connection at the level where it is created, in reindex_one_database(). Extracted from a larger patch by the same author. However, the patch as submitted not only was not described as containing this change, but in addition it contained a fatal flaw whereby reindexdb would crash and fail across all of its TAP test, which is why I list myself as co-author. Author: Ranier Vilela <ranier.vf@gmail.com> Author: Álvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://postgr.es/m/CAEudQArfqr0-s0VVPSEh=0kgOgBJvFNdGW=xSL5rBcr0WDMQYQ@mail.gmail.com
1 parent 0f21db3 commit 24503fa

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/bin/scripts/reindexdb.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,10 @@ reindex_one_database(ConnParams *cparams, ReindexType type,
339339

340340
/* Bail out if nothing to process */
341341
if (process_list == NULL)
342+
{
343+
PQfinish(conn);
342344
return;
345+
}
343346
break;
344347

345348
case REINDEX_SCHEMA:
@@ -352,7 +355,10 @@ reindex_one_database(ConnParams *cparams, ReindexType type,
352355

353356
/* Bail out if nothing to process */
354357
if (process_list == NULL)
358+
{
359+
PQfinish(conn);
355360
return;
361+
}
356362
break;
357363

358364
case REINDEX_INDEX:
@@ -370,7 +376,10 @@ reindex_one_database(ConnParams *cparams, ReindexType type,
370376
* in-place, so check if it has at least one cell.
371377
*/
372378
if (user_list->head == NULL)
379+
{
380+
PQfinish(conn);
373381
return;
382+
}
374383

375384
/*
376385
* Assuming 'user_list' is not empty, 'indices_tables_list'
@@ -416,6 +425,7 @@ reindex_one_database(ConnParams *cparams, ReindexType type,
416425

417426
sa = ParallelSlotsSetup(concurrentCons, cparams, progname, echo, NULL);
418427
ParallelSlotsAdoptConn(sa, conn);
428+
conn = NULL;
419429

420430
cell = process_list->head;
421431
do
@@ -765,7 +775,6 @@ get_parallel_object_list(PGconn *conn, ReindexType type,
765775
if (ntups == 0)
766776
{
767777
PQclear(res);
768-
PQfinish(conn);
769778
return NULL;
770779
}
771780

0 commit comments

Comments
 (0)