Avoid duplicate file references in backend .pot file

Started by Peter Eisentraut21 days ago4 messageshackers
Jump to latest
#1Peter Eisentraut
peter@eisentraut.org

The list of files for the backend's message catalog is collected with
find, which also lists symlinks, namely the generated files that are
linked from src/include/utils/ to src/backend/utils/ (such as
guc_tables.inc.c) and the port/pg_sema.c and port/pg_shmem.c links
created by configure. Since the link targets are found under their real
names as well, xgettext processed those files twice, resulting in
duplicate "#:" references like

#: ../include/utils/guc_tables.inc.c:410 utils/guc_tables.inc.c:410

This is an old problem, but the introduction of guc_tables.inc.c in PG19
has made it much more noticeable.

I propose the attached patch to fix this by restricting find to regular
files.

Attachments:

t254515_1
0001-Avoid-duplicate-file-references-in-backend-.pot-file.patchtext/plain; charset=UTF-8; name=0001-Avoid-duplicate-file-references-in-backend-.pot-file.patchDownload+1-2
#2Chao Li
li.evan.chao@gmail.com
In reply to: Peter Eisentraut (#1)
Re: Avoid duplicate file references in backend .pot file

On Nov 2, 2026, at 18:35, Peter Eisentraut <peter@eisentraut.org> wrote:

The list of files for the backend's message catalog is collected with find, which also lists symlinks, namely the generated files that are linked from src/include/utils/ to src/backend/utils/ (such as guc_tables.inc.c) and the port/pg_sema.c and port/pg_shmem.c links created by configure. Since the link targets are found under their real names as well, xgettext processed those files twice, resulting in duplicate "#:" references like

#: ../include/utils/guc_tables.inc.c:410 utils/guc_tables.inc.c:410

This is an old problem, but the introduction of guc_tables.inc.c in PG19 has made it much more noticeable.

I propose the attached patch to fix this by restricting find to regular files.
<0001-Avoid-duplicate-file-references-in-backend-.pot-file.patch>

LGTM. I tested in this way:
```
% ls -l src/include/utils/guc_tables.inc.c
lrwxr-xr-x@ 1 chaol staff 43 Nov 3 13:27 src/include/utils/guc_tables.inc.c -> ../../../src/backend/utils/guc_tables.inc.c

% find src/backend src/common src/port src/include \
\( -name '*.c' -o -name 'proctypelist.h' \) \
-print | grep guc_tables.inc.c
src/backend/utils/guc_tables.inc.c
src/include/utils/guc_tables.inc.c

% find src/backend src/common src/port src/include -type f \
\( -name '*.c' -o -name 'proctypelist.h' \) \
-print | grep guc_tables.inc.c
src/backend/utils/guc_tables.inc.c
```

Without -type f, find lists both the regular file and the symbolic link. With -type f, it lists only the regular file, as expected.

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

#3Jonathan Gonzalez V.
jonathan@abdiel.eu
In reply to: Peter Eisentraut (#1)
Re: Avoid duplicate file references in backend .pot file

Hello!

Peter Eisentraut <peter@eisentraut.org> writes:

The list of files for the backend's message catalog is collected with find,
which also lists symlinks, namely the generated files that are linked from
src/include/utils/ to src/backend/utils/ (such as guc_tables.inc.c) and the
port/pg_sema.c and port/pg_shmem.c links created by configure. Since the link
targets are found under their real names as well, xgettext processed those files
twice, resulting in duplicate "#:" references like

#: ../include/utils/guc_tables.inc.c:410 utils/guc_tables.inc.c:410

This is an old problem, but the introduction of guc_tables.inc.c in PG19 has
made it much more noticeable.

I propose the attached patch to fix this by restricting find to regular files.

gettext-files: generated-parser-sources generated-headers
-	find $(srcdir) $(srcdir)/../common $(srcdir)/../port $(srcdir)/../include/ \( -name '*.c' -o -name "proctypelist.h" \) -print | LC_ALL=C sort >$@
+	find $(srcdir) $(srcdir)/../common $(srcdir)/../port $(srcdir)/../include/ -type f \( -name '*.c' -o -name "proctypelist.h" \) -print | LC_ALL=C sort >$@

This make a lot of sense to me, I've tested and found that

./../include/utils/pgstat_wait_event.c
./../include/utils/wait_event_funcs_data.c

both were also symlinks.

This case totally escaped to my tests the last I checked that file! Work
as expected!

Regards,
--
Jonathan Gonzalez V.
EDB
https://www.enterprisedb.com

#4Peter Eisentraut
peter@eisentraut.org
In reply to: Chao Li (#2)
Re: Avoid duplicate file references in backend .pot file

On 03.11.26 08:13, Chao Li wrote:

On Nov 2, 2026, at 18:35, Peter Eisentraut <peter@eisentraut.org> wrote:

The list of files for the backend's message catalog is collected with find, which also lists symlinks, namely the generated files that are linked from src/include/utils/ to src/backend/utils/ (such as guc_tables.inc.c) and the port/pg_sema.c and port/pg_shmem.c links created by configure. Since the link targets are found under their real names as well, xgettext processed those files twice, resulting in duplicate "#:" references like

#: ../include/utils/guc_tables.inc.c:410 utils/guc_tables.inc.c:410

This is an old problem, but the introduction of guc_tables.inc.c in PG19 has made it much more noticeable.

I propose the attached patch to fix this by restricting find to regular files.
<0001-Avoid-duplicate-file-references-in-backend-.pot-file.patch>

LGTM. I tested in this way:

committed