System views for versions reporting

From: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: System views for versions reporting
Date: 2024-10-06 15:36:49
Message-ID: vximpev4vsyqvzvjn3qxb2apltuaxw7j4uxc4lggyjh3ejjbzx@66clgfgm6vlk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Based on the feedback in [1], here is my attempt at implementing system
views for versions reporting. It adds pg_system_versions for showing
things like core version, compiler, LLVM, etc, and pg_system_libraries
for showing linked shared objects. I think everyone has ageed that the
first was a good idea, where the second was only suggested -- after some
thinking I find shared obects useful enough to include here as well.

The main idea is to facilitate bug reporting. In particular, in many JIT
related bug reports one of the first questions is often "which LLVM
version is used?". Gathering such information is a manual process,
mistakes could be made when veryfing llvm-config output or anywhere
else. Having a system view for such purposes makes the process a bit
more robust.

The first three patches are essential for this purpose, the fourth one
is somewhat independent and could be concidered in isolation. The output
looks like this :

=# select * from pg_system_versions;
name | version | type
----------+--------------+--------------
Arch | x86_64-linux | Compile Time
ICU | 15.1 | Compile Time
Core | 18devel | Compile Time
Compiler | gcc-14.0.1 | Compile Time
LLVM | 18.1.6 | Run Time

=# select * from pg_system_libraries;
name
-----------------------------
/lib64/libkrb5.so.3
/lib64/libz.so.1
linux-vdso.so.1
/lib64/libxml2.so.2
[...]

Any feedback is appreciated.

0001-Add-infrastructure-for-pg_system_versions-view

Prepares the infrastructure, adds the view without populating it with
the data just yet. The view is backed by a hash table, which contains
callbacks returning a version string for a particular component. The
idea is to allow some flexibility in reporting, making components
responsible for how and when the information is exposed. E.g. it allows
to say that the version is not available.

0002-Add-core-versions-to-pg_system_versions.patch

Actually populates the view with some predefined compile time versions.
The versions are registered in PostgresMain, right after
BeginReportingGUCOptions -- there is no strong reasoning for that except
that it looks fine to me, so feel free to suggest a better place.

0003-Add-JIT-provider-version-to-pg_system_versions.patch

Finally adds LLVM version into the view via extending set of JIT
provider callbacks. The registration is happening together with the core
versions from the previous patch, because the JIT provider itself is
initialized only when a first expression is getting compiled.

0004-Add-pg_system_libraries-view.patch

Strictly speaking independent from the above patches. Adds the view to
show linked shared objects by iterating dl_phdr_info with
dl_iterate_phdr. It belongs to the standard C library, so I assume it's
portable enough.

[1]: https://www.postgresql.org/message-id/flat/znc72ymyoelvk5rjk5ub254v3qvcczfrk6autygjdobfvx2e7p%40s3dssvf34twa

Attachment Content-Type Size
v1-0001-Add-infrastructure-for-pg_system_versions-view.patch text/plain 10.5 KB
v1-0002-Add-core-versions-to-pg_system_versions.patch text/plain 7.4 KB
v1-0003-Add-JIT-provider-version-to-pg_system_versions.patch text/plain 4.8 KB
v1-0004-Add-pg_system_libraries-view.patch text/plain 9.7 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Joe Conway 2024-10-06 16:01:29 Re: System views for versions reporting
Previous Message Guillaume Lelarge 2024-10-06 13:32:02 Re: Add parallel columns for pg_stat_statements