<div dir="ltr"><div><span style="font-family:arial,sans-serif;font-size:13px">Hi</span></div><div><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div>I am working on adding the exception manager in pgpool and my plan of action for this is to use the Postgres exception manager API (elog and friends). Since the exception manager in Postgres uses the long jump, so importing this API in pgpool will effect all existing pgpool code flows especially in case of an error. and lot of care will be required for this integration, and secondly the elog API along with its friends will touch almost all parts of pgpool source code which will add up to a very huge patch.</div>
<div>So instead throwing a very huge patch to the community my plan is to divide this task into multiple smaller sub tasks so that it would be easier maintain and review the patch.</div><div><br></div><div>Cut to the chase, attached is the <span style="font-size:13px;font-family:arial,sans-serif"> first of the series of related patches to come.This is the </span><span style="font-size:13px;font-family:arial,sans-serif">first cut patch for implementing the exception manager in pgpool. As described above the exception manager and related code is borrowed from PostgreSQL source code. </span></div>
<div style="font-family:arial,sans-serif;font-size:13px">and the exception manager (elog API) is very closely tied with memory manager in PostgreSQL (palloc API) so the patch also borrows the PG&#39;s memory manager. </div>
<div style="font-family:arial,sans-serif;font-size:13px"><br><div>Below is the little description of things part of this patch.<br><div><div><br></div><div>-- Exception manager API of Postgres is added to pgpool, The API consists of elog.c and elog.h files. Since this API is very extensive and is designed for PostgreSQL so to fit it properly into pgpool I have modified it a little bit, and most of the modifications are related to removal of code which is not required for pgpool. </div>
<div><br></div><div>-- Added on_proc_exit callback mechanism of Postgres. To facilitate the cleanup at exit time.</div><div><br></div></div></div><div>-- Added PostgreSQL&#39;s memory manager (palloc API). This includes the client side palloc functions placed in &#39;src/tools&#39; directory (fe_memutils)</div>
<div><br></div><div>-- Removed the existing memory manager which was very minimalistic and was not integrated in all parts of the code.</div><div><br></div><div>-- I have also tried to reflector some portions of code to make the code more readable at first glance. This includes</div>
<div><br></div><div>- dividing the main.c file into two files main.c and pgpool_main.c, Now the main.c file only contains the code related to early initialisations of pgpool and parsing the command line options and related code. The actual logic of the pgpool main process is moved to new pgpool_main.c file.</div>
<div>- breaking up some large functions in child.c into smaller functions.</div><div>- rewrite the pgpool&#39;s main loop logic to make the code more readable.</div><div><br></div><div><br></div><div>Remaining TODOs on this front.</div>
<div><br></div><div>-- The current patch only integrates the memory and exception manager in main process and connection creation segment of pgpool child process. integration of newly added APIs in pcp and worker child process codes will be done be next patch.</div>
<div><br></div><div>-- Integration of newly added API into query processor logic in child process. ( this will be the toughest part)<br></div><div><br></div><div>-- elog.c and elog.h files needs some cleanups and changes ( to remove unwanted functions and data members of ErrorData structure) but this will be done at the end when we will have 100% surety if something in there is required or not.</div>
<div><br></div><div><br></div><div>Thanks</div><div>Muhammad Usama</div><div><br></div></div></div>