pg_dump: Add ExecuteSqlCopy and simplify ExecuteSqlQuery

Started by Corey Huinker11 months ago2 messageshackers
Jump to latest
#1Corey Huinker
corey.huinker@gmail.com

The thread about tablecmds.c being too large for some code inspection
tooling got me thinking about ways to improve the second worst offender:
pg_dump.c.

Those investigations of mine haven't yet revealed a way to split the file
that I find effective, let alone helpful. However, it has shown me a few
patterns within pg_dump.c that I'm proposing to change.

Of the current 84 calls to the convenience routine ExecuteSqlQuery(), 83 of
them are regular queries which expect a result of PGRES_TUPLES_OK. The
other one expects PGRES_COPY_OUT. So it seems worthwhile to remove the
parameter entirely and assume the caller wants PGRES_TUPLES_OK. For the one
exception, ExecuteSqlCopy() is created, though one could argue that we
might just do without the convenience routine altogether. Patch attached.

Attachments:

t52914_1
v1-0001-Split-ExecuteSqlCopy-from-ExecuteSqlQuery.patchtext/x-patch; charset=US-ASCII; name=v1-0001-Split-ExecuteSqlCopy-from-ExecuteSqlQuery.patchDownload+97-89
#2Andreas Karlsson
andreas.karlsson@percona.com
In reply to: Corey Huinker (#1)
Re: pg_dump: Add ExecuteSqlCopy and simplify ExecuteSqlQuery

On 12/16/25 10:38 PM, Corey Huinker wrote:

Of the current 84 calls to the convenience routine ExecuteSqlQuery(), 83
of them are regular queries which expect a result of PGRES_TUPLES_OK.
The other one expects PGRES_COPY_OUT. So it seems worthwhile to remove
the parameter entirely and assume the caller wants PGRES_TUPLES_OK. For
the one exception, ExecuteSqlCopy() is created, though one could argue
that we might just do without the convenience routine altogether. Patch
attached.

The patch looks fine and if I had written it from scratch I would
probably have done it like in the patch but I do not think the code
churn is worth what to me feels like a minuscule improvement.

What does others think?

Andreas