Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pc7OQ-0004MV-UA for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Mar 2023 16:20:54 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pc7OO-00045Z-PZ for pgsql-bugs@arkaria.postgresql.org; Tue, 14 Mar 2023 16:20:52 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pc7OO-00045Q-HH for pgsql-bugs@lists.postgresql.org; Tue, 14 Mar 2023 16:20:52 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pc7OJ-0002bm-Fc for pgsql-bugs@lists.postgresql.org; Tue, 14 Mar 2023 16:20:51 +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 32EGKkeY2692256; Tue, 14 Mar 2023 12:20:46 -0400 From: Tom Lane To: buschmann@nidsa.net cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17842: Adding a qual to a working query gets bogus syntax error In-reply-to: <17842-0697f895ced573ee@postgresql.org> References: <17842-0697f895ced573ee@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Tue, 14 Mar 2023 15:48:29 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <2692254.1678810846.1@sss.pgh.pa.us> Date: Tue, 14 Mar 2023 12:20:46 -0400 Message-ID: <2692255.1678810846@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > During refactoring our application I got a bogus syntax error when adding a > simple where-clause to a working query. My guess is that this: > ('0'||split_part(split_part(nline,'(',2),')',1))::smallint as nlen sometimes produces a string that fails to cast to smallint, which you accidentally don't notice because it never gets evaluated for troublesome values of nline --- until you add the "nlen > 0" condition. There isn't anything in your query that prevents that from being evaluated fairly early. This isn't a bug, or at least you have provided no data that would motivate (or indeed allow) anyone else to poke into it more closely. regards, tom lane