mirror of
https://github.com/postgres/postgres.git
synced 2025-06-16 06:01:02 +03:00
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
This commit is contained in:
@ -339,7 +339,10 @@ reindex_one_database(ConnParams *cparams, ReindexType type,
|
|||||||
|
|
||||||
/* Bail out if nothing to process */
|
/* Bail out if nothing to process */
|
||||||
if (process_list == NULL)
|
if (process_list == NULL)
|
||||||
|
{
|
||||||
|
PQfinish(conn);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REINDEX_SCHEMA:
|
case REINDEX_SCHEMA:
|
||||||
@ -352,7 +355,10 @@ reindex_one_database(ConnParams *cparams, ReindexType type,
|
|||||||
|
|
||||||
/* Bail out if nothing to process */
|
/* Bail out if nothing to process */
|
||||||
if (process_list == NULL)
|
if (process_list == NULL)
|
||||||
|
{
|
||||||
|
PQfinish(conn);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case REINDEX_INDEX:
|
case REINDEX_INDEX:
|
||||||
@ -370,7 +376,10 @@ reindex_one_database(ConnParams *cparams, ReindexType type,
|
|||||||
* in-place, so check if it has at least one cell.
|
* in-place, so check if it has at least one cell.
|
||||||
*/
|
*/
|
||||||
if (user_list->head == NULL)
|
if (user_list->head == NULL)
|
||||||
|
{
|
||||||
|
PQfinish(conn);
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Assuming 'user_list' is not empty, 'indices_tables_list'
|
* Assuming 'user_list' is not empty, 'indices_tables_list'
|
||||||
@ -416,6 +425,7 @@ reindex_one_database(ConnParams *cparams, ReindexType type,
|
|||||||
|
|
||||||
sa = ParallelSlotsSetup(concurrentCons, cparams, progname, echo, NULL);
|
sa = ParallelSlotsSetup(concurrentCons, cparams, progname, echo, NULL);
|
||||||
ParallelSlotsAdoptConn(sa, conn);
|
ParallelSlotsAdoptConn(sa, conn);
|
||||||
|
conn = NULL;
|
||||||
|
|
||||||
cell = process_list->head;
|
cell = process_list->head;
|
||||||
do
|
do
|
||||||
@ -765,7 +775,6 @@ get_parallel_object_list(PGconn *conn, ReindexType type,
|
|||||||
if (ntups == 0)
|
if (ntups == 0)
|
||||||
{
|
{
|
||||||
PQclear(res);
|
PQclear(res);
|
||||||
PQfinish(conn);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user