Refactoring postgres_fdw/connection.c - Mailing list pgsql-hackers

From Fujii Masao
Subject Refactoring postgres_fdw/connection.c
Date
Msg-id 8cbc84da-148d-bfe3-dc58-c95e01b51d90@oss.nttdata.com
Whole thread Raw
Responses Re: Refactoring postgres_fdw/connection.c
Re: Refactoring postgres_fdw/connection.c
List pgsql-hackers
Hi,

When reviewing the postgres_fdw parallel-abort patch [1], I found that
there are several duplicate codes in postgres_fdw/connection.c.
Which seems to make it harder to review the patch changing connection.c.
So I'd like to remove such duplicate codes and refactor the functions
in connection.c. I attached the following three patches.

There are two functions, pgfdw_get_result() and pgfdw_get_cleanup_result(),
to get a query result. They have almost the same code, call PQisBusy(),
WaitLatchOrSocket(), PQconsumeInput() and PQgetResult() in the loop,
but only pgfdw_get_cleanup_result() allows its callers to specify the timeout.
0001 patch transforms pgfdw_get_cleanup_result() to the common function
to get a query result and makes pgfdw_get_result() use it instead of
its own (duplicate) code. The patch also renames pgfdw_get_cleanup_result()
to pgfdw_get_result_timed().

pgfdw_xact_callback() and pgfdw_subxact_callback() have similar codes to
issue COMMIT or RELEASE SAVEPOINT commands. 0002 patch adds the common function,
pgfdw_exec_pre_commit(), for that purpose, and changes those functions
so that they use the common one.

pgfdw_finish_pre_commit_cleanup() and pgfdw_finish_pre_subcommit_cleanup()
have similar codes to wait for the results of COMMIT or RELEASE SAVEPOINT commands.
0003 patch adds the common function, pgfdw_finish_pre_commit(), for that purpose,
and replaces those functions with the common one.
That is, pgfdw_finish_pre_commit_cleanup() and pgfdw_finish_pre_subcommit_cleanup()
are no longer necessary and 0003 patch removes them.

[1] https://commitfest.postgresql.org/38/3392/

Regards,

-- 
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Attachment

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: fairywren hung in pg_basebackup tests
Next
From: Andrew Dunstan
Date:
Subject: Re: fairywren hung in pg_basebackup tests