Re: Rationalizing code-sharing among src/bin/ directories

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: Rationalizing code-sharing among src/bin/ directories
Date: 2016-03-24 15:52:10
Message-ID: 2885.1458834730@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I wrote:
> I have a modest proposal for improving this: let's move all the code
> that's currently shared by two or more src/bin/ subdirectories into a
> new directory, say src/feutils, and build it into a ".a" library in
> the same way that src/common/ is handled.

Moving along on this project: I'm looking at pg_dump's dumputils.c/.h,
which contains a fair amount of generally-useful stuff but also some
stuff that seems to have no earthly use outside pg_dump/pg_dumpall.
In particular I do not see the point of moving these things to a shared
directory:

PGDUMP_STRFTIME_FMT macro

extern bool buildACLCommands(const char *name, const char *subname,
const char *type, const char *acls, const char *owner,
const char *prefix, int remoteVersion,
PQExpBuffer sql);
extern bool buildDefaultACLCommands(const char *type, const char *nspname,
const char *acls, const char *owner,
int remoteVersion,
PQExpBuffer sql);
extern void buildShSecLabelQuery(PGconn *conn, const char *catalog_name,
uint32 objectId, PQExpBuffer sql);
extern void emitShSecLabels(PGconn *conn, PGresult *res,
PQExpBuffer buffer, const char *target, const char *objname);

What I propose doing is leaving the above-listed items in
pg_dump/dumputils.h/.c, and moving the rest of what's in those files
to new files src/include/fe_utils/string_utils.h and
src/fe_utils/string_utils.c. This name is a bit arbitrary, but most of
what's there is string processing of some flavor or other, with some list
processing thrown in for good measure. If anyone's got a different color
to paint this bikeshed, please speak up.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2016-03-24 15:53:58 Re: Rationalizing code-sharing among src/bin/ directories
Previous Message Robert Haas 2016-03-24 15:51:25 Re: Rationalizing code-sharing among src/bin/ directories