[pgpool-committers: 9309] pgpool: Judge multi statement query using psqlscan.

Tatsuo Ishii ishii at sraoss.co.jp
Wed Apr 19 10:56:40 JST 2023


Judge multi statement query using psqlscan.

Psqlscan is a module in the PostgreSQL source tree. It is essentially
subset of PostgreSQL SQL scanner but it is specialized for detecting
the end of each SQL statement. Therefore we can count the number of
SQL statements in a query string by using it.
Note that we use psqlscan only when query string is large.

Because psqlscan is not designed as an external library, it is hard to
call it from outside of PostgreSQL source tree. So I decided to import
psqlscan source code. This module consists of multiple files.  Program
sources are deployed in src/utils directory and header files are
deployed in src/include/utils directory.

psqlscan module was originally designed for frontend programs and uses
malloc directly. So I changed them so that it calls palloc and
friends. Additionally pgstrcasecmp.c and pqexpbuffer.c are also
imported. They are used by psqlscan.

The example usage of psqlscan can be found in
multi_statement_query():src/protocol/pool_proto_modules.c.

Discussion:
https://www.pgpool.net/pipermail/pgpool-hackers/2023-February/004291.html
Discussion: https://www.pgpool.net/pipermail/pgpool-hackers/2023-April/004320.html

Branch
------
V4_2_STABLE

Details
-------
https://git.postgresql.org/gitweb?p=pgpool2.git;a=commitdiff;h=ea63203c27349758aa0c416b6a4031793b57ff70

Modified Files
--------------
src/Makefile.am                   |    9 +-
src/include/utils/pgstrcasecmp.h  |   22 +
src/include/utils/pqexpbuffer.h   |  192 +++++
src/include/utils/psqlscan.h      |   90 +++
src/include/utils/psqlscan_int.h  |  157 ++++
src/protocol/pool_proto_modules.c |  185 ++++-
src/utils/pgstrcasecmp.c          |  154 ++++
src/utils/pqexpbuffer.c           |  418 ++++++++++
src/utils/psqlscan.l              | 1620 +++++++++++++++++++++++++++++++++++++
9 files changed, 2829 insertions(+), 18 deletions(-)



More information about the pgpool-committers mailing list