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 1rtKDe-00Dz4Q-K2 for pgsql-hackers@arkaria.postgresql.org; Sun, 07 Apr 2024 04:33: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 1rtKDd-0031X3-DY for pgsql-hackers@arkaria.postgresql.org; Sun, 07 Apr 2024 04:33: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 1rtKDd-0031Wv-4Z for pgsql-hackers@lists.postgresql.org; Sun, 07 Apr 2024 04:33:25 +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.94.2) (envelope-from ) id 1rtKDW-001H1B-72 for pgsql-hackers@lists.postgresql.org; Sun, 07 Apr 2024 04:33:24 +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 4374XCdo2730344; Sun, 7 Apr 2024 00:33:13 -0400 From: Tom Lane To: Erik Wienhold cc: Michal Bartak , pgsql-hackers@lists.postgresql.org Subject: Re: CASE control block broken by a single line comment In-reply-to: References: Comments: In-reply-to Erik Wienhold message dated "Sat, 06 Apr 2024 23:14:23 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2730342.1712464392.1@sss.pgh.pa.us> Date: Sun, 07 Apr 2024 00:33:12 -0400 Message-ID: <2730343.1712464392@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Erik Wienhold writes: > On 2024-04-06 20:14 +0200, Michal Bartak wrote: >> The issue described bellow exists in postgresql ver 16.2 (found in some >> previous major versions) > Can confirm also on master. I'm sure it's been there a while :-( > I'm surprised that the comment is not skipped by the scanner at this > point. Maybe because the parser just reads the raw expression between > WHEN and THEN with plpgsql_append_source_text via read_sql_construct. > How about the attached patch? It's a workaround by simply adding a line > feed character between the raw expression and the closing parenthesis. I don't have time to look into this on this deadline weekend, but what's bothering me about this report is the worry that we've made the same mistake elsewhere, or will do so in future. I suspect it'd be much more robust if we could remove the comment from the expr->query string. No idea how hard that is. regards, tom lane