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.94.2) (envelope-from ) id 1uxDsC-00C9Sh-3L for pgsql-general@arkaria.postgresql.org; Sat, 13 Sep 2025 00:12:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1uxDs8-004VX4-Dw for pgsql-general@arkaria.postgresql.org; Sat, 13 Sep 2025 00:12:09 +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.94.2) (envelope-from ) id 1uxDs8-004VWw-2n for pgsql-general@lists.postgresql.org; Sat, 13 Sep 2025 00:12:08 +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.96) (envelope-from ) id 1uxDs4-000VZI-34 for pgsql-general@postgresql.org; Sat, 13 Sep 2025 00:12:08 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 58D0C3ir2673231; Fri, 12 Sep 2025 20:12:03 -0400 From: Tom Lane To: Laurenz Albe cc: Dominique Devienne , pgsql-general@postgresql.org Subject: Re: Latest patches break one of our unit-test, related to RLS In-reply-to: <2c58dcdba889f5b28df5ad9d21b5ea2d0ac63a9a.camel@cybertec.at> References: <77a63548783dd4007ee479a4c5ed300629aaa776.camel@cybertec.at> <2109533.1757686026@sss.pgh.pa.us> <2c58dcdba889f5b28df5ad9d21b5ea2d0ac63a9a.camel@cybertec.at> Comments: In-reply-to Laurenz Albe message dated "Sat, 13 Sep 2025 01:34:08 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2673229.1757722323.1@sss.pgh.pa.us> Date: Fri, 12 Sep 2025 20:12:03 -0400 Message-ID: <2673230.1757722323@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Laurenz Albe writes: > On Fri, 2025-09-12 at 10:07 -0400, Tom Lane wrote: >> The _ and % are not getting converted to their POSIX equivalents >> ("." and ".*"). > Indeed, and I have to take the blame for introducing a bug in a minor > release :^( > The attached patch should fix the problem. I had not particularly studied the new charclass-parsing logic. Looking at it now, this bit further down (lines 871ff) looks fishy: if (pchar == ']' && charclass_start > 2) charclass_depth--; else if (pchar == '[') charclass_depth++; /* * If there is a caret right after the opening bracket, it negates * the character class, but a following closing bracket should * still be treated as a normal character. That holds only for * the first caret, so only the values 1 and 2 mean that closing * brackets should be taken literally. */ if (pchar == '^') charclass_start++; else charclass_start = 3; /* definitely past the start */ Should not we be setting charclass_start to 1 after incrementing charclass_depth? That is, I'd be more comfortable if this logic looked like if (pchar == ']' && charclass_start > 2) charclass_depth--; else if (pchar == '[') { /* start of a nested character class */ charclass_depth++; charclass_start = 1; } else if (pchar == '^') charclass_start++; else charclass_start = 3; /* definitely past the start */ I haven't experimented, but it looks like this might misprocess ^ or ] at the start of a nested character class. regards, tom lane