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 1uxFSB-00CPQS-Um for pgsql-general@arkaria.postgresql.org; Sat, 13 Sep 2025 01:53:27 +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 1uxFS8-004pug-96 for pgsql-general@arkaria.postgresql.org; Sat, 13 Sep 2025 01:53:25 +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 1uxFS7-004puU-UE for pgsql-general@lists.postgresql.org; Sat, 13 Sep 2025 01:53:24 +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 1uxFS3-000WIQ-3B for pgsql-general@postgresql.org; Sat, 13 Sep 2025 01:53:23 +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 58D1rHBC2683919; Fri, 12 Sep 2025 21:53:17 -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: <501ee89ad54184804d14b416781dafd340c789d3.camel@cybertec.at> References: <77a63548783dd4007ee479a4c5ed300629aaa776.camel@cybertec.at> <2109533.1757686026@sss.pgh.pa.us> <2c58dcdba889f5b28df5ad9d21b5ea2d0ac63a9a.camel@cybertec.at> <2673230.1757722323@sss.pgh.pa.us> <501ee89ad54184804d14b416781dafd340c789d3.camel@cybertec.at> Comments: In-reply-to Laurenz Albe message dated "Sat, 13 Sep 2025 03:17:17 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2683917.1757728397.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Fri, 12 Sep 2025 21:53:17 -0400 Message-ID: <2683918.1757728397@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 20:12 -0400, Tom Lane wrote: >> Should not we be setting charclass_start to 1 after incrementing >> charclass_depth? > What I call "charclass depth" is misleading, I am afraid. > Really, it should be "bracket depth". Only the outermost pair of bracke= ts > starts an actual character class. Example: > []abc[:digit:]] > A caret or closing bracket right after the inner opening bracket wouldn'= t > be a special character, and I think it would never be legal. Ah, got it. But this logic definitely deserves more comments. What do you think of something like if (pchar =3D=3D ']' && charclass_start > 2) { /* found the real end of a bracket pair */ charclass_depth--; /* past start of outer brackets, so keep charclass_start >= 2 */ } else if (pchar =3D=3D '[') { /* start of a nested bracket pair */ charclass_depth++; /* leading ^ or ] in this context is not special */ charclass_start =3D 3; } else if (pchar =3D=3D '^') { /* okay to increment charclass_start even if already > 1 *= / charclass_start++; } else { /* otherwise (including case of leading ']') */ charclass_start =3D 3; /* definitely past the start */ } > Perhaps s/charclass_depth/bracket_depth/ would be a good idea. Wouldn't object to that. Maybe we can think of a better name for "charclass_start" too --- that sounds like a boolean condition. The best I'm coming up with right now is "charclass_count", but that's not that helpful. regards, tom lane