postgresql/src/bin
Tom Lane b6c7cfac88 Restore proper linkage of pg_char_to_encoding() and friends.
Back in the 8.3 era we discovered that it was problematic if
libpq.so had encoding ID assignments different from the backend,
which is possible because on some platforms libpq.so might be
of a different major version from the calling programs.
psql should use libpq's assignments, but initdb has to use the
backend's, else it will put wrong values into pg_database.
The solution devised in commit 8468146b0 relied on giving initdb
its own copy of encnames.c rather than relying on the functions
exported by libpq.  Later, that metamorphosed into ensuring that
libpgcommon got linked before libpq -- which made things OK for
initdb but broke psql.  We didn't notice for lack of any changes
in enum pg_enc since then.  Commit 06843df4a reversed that, fixing
the latent bug in psql but adding one in initdb.  The meson build
infrastructure is also not being sufficiently careful about link
order, and trying to make it so would be equally fragile.

Hence, let's use a new scheme based on giving the libpq-exported
symbols different real names than the same functions exported from
libpgcommon.a or libpgcommon_srv.a.  (We could distinguish those
two cases as well, but there seems no need to.)  libpq gets the
official names to avoid an ABI break for libpq clients, while the
other cases use #define's to make the real names "xxx_private"
rather than "xxx".  By controlling where the #define's are
applied, we can force any particular client program to use one
set or the other of the encnames.c functions.

We cannot back-patch this, since it'd be an ABI break for backend
loadable modules, but there seems little need to.  We're just
trying to ensure that the world is safe for hypothetical future
additions to enum pg_enc.

In passing this should fix "duplicate symbol" linker warnings
that we've been seeing on AIX buildfarm members since commit
06843df4a.  It's not very clear why that linker is complaining
now, when there were strictly *more* duplicates visible before,
but in any case this should remove the reason for complaint.

Patch by me; thanks to Andres Freund for review.

Discussion: https://postgr.es/m/2385119.1696354473@sss.pgh.pa.us
2023-10-07 12:08:10 -04:00
..
initdb Restore proper linkage of pg_char_to_encoding() and friends. 2023-10-07 12:08:10 -04:00
pg_amcheck Add some const qualifiers 2023-09-26 11:28:57 +01:00
pg_archivecleanup Translation updates 2023-08-07 12:39:30 +02:00
pg_basebackup Allow dbname in pg_basebackup/pg_receivewal connstring 2023-09-21 13:53:07 +02:00
pg_checksums Allow using syncfs() in frontend utilities. 2023-09-06 16:27:16 -07:00
pg_config Translation updates 2023-08-07 12:39:30 +02:00
pg_controldata Replace use of stat()[7] by -s switch in TAP tests to retrieve file size 2023-10-03 08:27:34 +09:00
pg_ctl Translation updates 2023-08-07 12:39:30 +02:00
pg_dump Fix omission of column-level privileges in selective pg_restore. 2023-10-02 13:27:58 -04:00
pg_resetwal Replace use of stat()[7] by -s switch in TAP tests to retrieve file size 2023-10-03 08:27:34 +09:00
pg_rewind Add some const qualifiers 2023-09-26 11:28:57 +01:00
pg_test_fsync Remove wal_sync_method=fsync_writethrough on Windows. 2023-07-14 12:30:13 +12:00
pg_test_timing Translation updates 2023-05-22 12:44:31 +02:00
pg_upgrade pg_upgrade: check for types removed in pg12 2023-09-25 14:27:33 +02:00
pg_verifybackup Improve JsonLexContext's freeability 2023-10-05 10:59:08 +02:00
pg_waldump Quote filenames in error messages 2023-09-14 11:17:33 +02:00
pgbench pgbench: Improve help output of -I option 2023-09-26 22:09:07 +01:00
pgevent Update copyright for 2023 2023-01-02 15:00:37 -05:00
psql Remove environment-variable-based defaults in psql --help 2023-10-06 11:54:36 +02:00
scripts vacuumdb: Reword --help message for clarity 2023-09-25 16:03:32 +02:00
Makefile Update copyright for 2023 2023-01-02 15:00:37 -05:00
meson.build Update copyright for 2023 2023-01-02 15:00:37 -05:00