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 1wgTCN-006Coz-0B for pgsql-bugs@arkaria.postgresql.org; Sun, 05 Jul 2026 20:12:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wgTCK-00DX9n-0X for pgsql-bugs@arkaria.postgresql.org; Sun, 05 Jul 2026 20:12:16 +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 1wgTCJ-00DX9f-2w for pgsql-bugs@lists.postgresql.org; Sun, 05 Jul 2026 20:12:15 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wgTCG-00000001va8-1yPL for pgsql-bugs@lists.postgresql.org; Sun, 05 Jul 2026 20:12:14 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.18.1/8.18.1) with ESMTP id 665KC6nJ777940; Sun, 5 Jul 2026 16:12:06 -0400 From: Tom Lane To: Ayush Tiwari cc: 3020001251@tju.edu.cn, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19525: In `contrib/dict_int`, handling a token whose first byte is a null byte causes `pnstrdup()` . In-reply-to: References: <19525-b0be8e4eb7dbaf07@postgresql.org> Comments: In-reply-to Ayush Tiwari message dated "Thu, 18 Jun 2026 20:11:32 +0530" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <777938.1783282326.1@sss.pgh.pa.us> Date: Sun, 05 Jul 2026 16:12:06 -0400 Message-ID: <777939.1783282326@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Ayush Tiwari writes: > On Thu, 18 Jun 2026 at 18:54, PG Bug reporting form > wrote: >> -- 3. Create a C helper (raw_lexize.so) that invokes the lexize callback >> with >> -- a raw bytea token, bypassing the text encoding layer. >> CREATE FUNCTION raw_lexize(dict regdictionary, token bytea) >> RETURNS text[] AS 'raw_lexize', 'raw_lexize' LANGUAGE C STRICT; > Your analysis seems right to me. It is not. I do not think this is a bug; if it is a bug we have got probably hundreds of places that'd have to be fixed. The general rule in Postgres is that we do not permit embedded nulls in text values. The fact that a misguided superuser can break that rule doesn't make it a bug for code to depend on it. (There are approximately an infinite number of ways for a misguided superuser to break Postgres, just as the root user can destroy a Unix system many times over.) So I see no value in this proposed change in dintdict_lexize. But the one in dxsyn_lexize seems worthwhile, just because it makes that code shorter, simpler, and faster. Since that's mostly an example module, I don't feel a need to back-patch, but I'll go commit that to HEAD. regards, tom lane