System views for versions reporting
Dmitry Dolgov <9erthalion6@gmail.com>
From: Dmitry Dolgov <9erthalion6@gmail.com>
To: pgsql-hackers@postgresql.org
Date: 2024-10-06T15:36:49Z
Lists: pgsql-hackers
Attachments
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