Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vMUlx-00BkFo-04 for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Nov 2025 17:18:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vMUlu-008Rh7-1m for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Nov 2025 17:18:10 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vMUlu-008Rgy-0c for pgsql-hackers@lists.postgresql.org; Fri, 21 Nov 2025 17:18:10 +0000 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vMUls-000kwL-1Z for pgsql-hackers@postgresql.org; Fri, 21 Nov 2025 17:18:10 +0000 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-b472842981fso288131766b.1 for ; Fri, 21 Nov 2025 09:18:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1763745487; x=1764350287; darn=postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=CAObT7+csrOG8FimMEK/Q46XLlYihrqlpglqtHAbGMA=; b=YGj82GPvvNZaaCbuBXFpDF5hpM7x0H0XqUW79ck5Biwbb1DyUqbHRmHZOgM/Pa/haD 4ibGTrdU6P6geI60tqI4ZbZRzZpnit104jDxMKolgwJDduTc/hXnkVLQ1Ze4ZBjmyxEd 5Mw/ErxmVhpliqPW5ou+Rnb+bnMYkubsTgLIBO235NgXmDdso7LQ1LjTWFTndsiy7P3j hJXh7U4N4+L13Ek50pkBOxAYlwgrPdPPstdtedVSgyUD5Nb/usFRj53v45lcb+PW9Kt9 Frr8Kqcb4aDLzgrg3fn8x7GT1rETe1VVSiihQK11rVz4ibzGMWzCKFP5dX6H7gAhFSi5 cdIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1763745487; x=1764350287; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=CAObT7+csrOG8FimMEK/Q46XLlYihrqlpglqtHAbGMA=; b=knP0fOrN9dYcw0kns3tgUCm5UzAOcD+JkzOCO8At2VWSTgndY8RrqwnsZAUqTWOZy5 989jNVoNsn2aPtI8IzqUsX4Gm3r4YskvOHzhJls4YxWnl3WvmpGHrRQtwovEj9+XFXGP CNVhsAYGxBNM/xtOPRqxSIEJ7c+eOQ14yN0XxHBJWkdB3i8g0cXmN2VirATGFQ6wAdn6 4W7i8vps8djs/c29vUjS5djOT+l1+JbkIUmsOv6RgHlKkEoCsCRVEuaOMjvoZWyZtLRI Xwg44RvrHuTQSoaZlGx7L01O11wWJFsRl0L+9ZjUdRK4BaqOqdEymQvA3k9OKbBJAMXC 2U0w== X-Forwarded-Encrypted: i=1; AJvYcCXH6RLwXxxxr04NOeMTTjB8zbfSFBVs8WWz2aGHzk7uu0QItjHnXFxEBKr4ItxPO42DYis9dcse/A0a2vCU@postgresql.org X-Gm-Message-State: AOJu0YycE2P1xWk6oIp/ddfp1dOGKrol4+xZTqgmsXr8X4Ohm+aAPPoS 7kTpTyd+fOxz8GBAGYDg6hchpiDh/AJTukiPvc1t/9PIEIOXIqDn2+xjxRcxusY5n4Y= X-Gm-Gg: ASbGnctAloeVK4BjZxKYZxtS37ETvgU2pWHe+0tGSEhT6FbRVQTNbFTBXkIQdYOK5u3 KobNaQkE3FhUoUqAJM9SSeDq13qyOkcpzIDiveAKmIsVpYuSE8hXapAwZR6S9Uy4is7HS6sJ6QP bEDudp6zTvVrPL4ysaiUkG3BLzt4NggUvjzAntM4/N46/ib1uGsHhU8ZX8xJT/D2+kxBt/nfUvM Ygme0b0VPnEWpjkcNs/Z/zoVjPBYUZkadOOaij++4m3lW8JFuxYC2obhNqRtdcy11e3sbTet15t ZfigtbS9/NDCUxb8nJzFi6s0lfMSX7luqhRMokT/uHPA/uVp+AM4Vk7Xu3R9rnbuwuz+ANyNX+S YVn/Xxejvn/lo1xZlZLGPumSZaBiHj6ToUa6lFPnFryKfdNu9oN2FW3JxsoNW/IF1xHSAZPJcFj BRTTxfFa49nJfKf4WI5vPt0gs72qgHFbhok1KvO1eAQNlFW3dN X-Google-Smtp-Source: AGHT+IFo3LZdxhxzKFmt+MfQXl7mCPtuqgOF0UllSkUbN5qE5lnt/QAQ1h6NTYKAsG1GfxzJhbHIBg== X-Received: by 2002:a17:907:3c86:b0:b70:df0d:e2e9 with SMTP id a640c23a62f3a-b767186f2c9mr390193166b.44.1763745487015; Fri, 21 Nov 2025 09:18:07 -0800 (PST) Received: from laurenz.albe-K4N0CV00F97414D ([194.182.8.84]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-b7654ff3987sm510015566b.48.2025.11.21.09.18.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 Nov 2025 09:18:06 -0800 (PST) Message-ID: <270874d71328295c571ea760ac06ce747ef11821.camel@cybertec.at> Subject: Re: System views for versions reporting From: Laurenz Albe To: Dmitry Dolgov <9erthalion6@gmail.com> Cc: Tom Lane , jian he , Joe Conway , pgsql-hackers@postgresql.org Date: Fri, 21 Nov 2025 18:18:06 +0100 In-Reply-To: References: <5jhyl6p3nwcaxczfxuh25q42q6bqlaxyqyfqtw4tldvmm24bw2@rfii5tkwn5rg> <866452.1742768493@sss.pgh.pa.us> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, 2025-11-21 at 15:21 +0100, Dmitry Dolgov wrote: > > > + ctl.hcxt =3D CurrentMemoryContext; > >=20 > > That hashtable should stick around for the entire life time of the back= end. > > Wouldn't it be better to explicitly name the correct memory context, ra= ther > > that to rely on being called with "CurrentMemoryContext" set correctly? >=20 > Looking at this closely, I think it's not even necessary to specify a > memory context here -- in this case hash_create will create a private > memory context for this hash table from TopMemoryContext. That is fine. I just think that using CurrentMemoryContext a) opens a wind= ow for mistakes if you call the function from the wrong place and b) makes it less clear to the reader where the hash table will be created. > > > + if (found) > > > + elog(ERROR, "duplicated system version"); > >=20 > > Is that a problem? Why throw an error? >=20 > It was originally a problem for 0004, and propagated here as well. But I > still see some value in it, because I can't imagine why registering the > same version twice might be a reasonable use cases. Do you have some > examples for such cases in mind? No, I don't think that there are any use cases. But registering the same version twice will just overwrite the old value, which is redundant, but no problem. It would be bad coding though, so perhaps an Assert() would be th= e better choice. That would avoid the (tiny) overhead of the check in production builds. > > > --- a/src/test/regress/sql/sysviews.sql > > > +++ b/src/test/regress/sql/sysviews.sql > > > + > > > +-- 5 core versions should be present: architecture, ICU, core, compi= ler and > > > +-- glibc. If built with JIT support, one more record will be display= ed > > > +-- containing LLVM version. > > > +select count(*) >=3D 5 as ok FROM pg_system_versions; > >=20 > > If you really think that a regression test for selecting from the view > > is useful, use "SELECT EXISTS (TABLE pg_system_versions)". =20 > > Are you sure that the regression tests will always run with ICU enabled= ? >=20 > Not with ICU, but at least the core and compiler version are always > going to be present, hence the check for number of records. Any > alternative suggestions for better testing coverage? I made my suggestion in the paragraph above. I think it is sufficient to c= heck that you can select from the view at all, never mind how many columns there= are. > > > --- a/src/backend/jit/jit.c > > > +++ b/src/backend/jit/jit.c > > > + > > > +/* > > > + * Return JIT provider's version string for troubleshooting purposes= . > > > + */ > > > +const char * > > > +jit_get_version(bool *available) > > > +{ > > > + if (provider_init()) > > > + return provider.get_version(available); > > > + > > > + *available =3D false; > > > + return ""; > > > +} > >=20 > > I think it would be better to do do the "available" dance here rather t= han > > delegating it to get_version(). get_version() can simply return NULL i= f there > > is no version available. >=20 > I don't have any preferences here and can move it. But just out of > curiosity, can you elaborate what benefits do you see in moving the > "available" logic in jit_get_version? I don't have a hard technical argument for that. My gut feeling is the fol= lowing: jit_get_version() belongs to the pg_system_versions machinery, so it should= deal with the "available" that belongs to that API. jit_get_version() belongs t= o the JIT implementation. I won't object if you feel strongly that it should be the way it is now, si= nce that is more a matter of taste than anything else. Yours, Laurenz Albe