Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1be3Uh-0008Cd-4a for pgsql-jdbc@arkaria.postgresql.org; Sun, 28 Aug 2016 17:03:39 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1be3Ug-0008Ha-IY for pgsql-jdbc@arkaria.postgresql.org; Sun, 28 Aug 2016 17:03:38 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1be3UB-0007kE-Vo for pgsql-jdbc@postgresql.org; Sun, 28 Aug 2016 17:03:08 +0000 Received: from mail-pf0-x22f.google.com ([2607:f8b0:400e:c00::22f]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84_2) (envelope-from ) id 1be3U7-0003hx-Fg for pgsql-jdbc@postgresql.org; Sun, 28 Aug 2016 17:03:07 +0000 Received: by mail-pf0-x22f.google.com with SMTP id p64so43851253pfb.1 for ; Sun, 28 Aug 2016 10:03:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=labkey-com.20150623.gappssmtp.com; s=20150623; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to; bh=Y24Kmxvc98AYq5b/p3sk8V7l3IKrZYn9CPgZXGpkdWs=; b=UEtjj14p7GrRxn4QuBRCF18bdUU5vCwYGtk2fQ3lCsh0DJDe+CoGod7GWEFcilmYq5 9xDbEtSMMqHcecgakYBO4/SUzvCe0vJ4zjE7HSKzvc3wFH0qnHr9xuFeSXkq85ef1yAB fPOInzPu+/crDR7oICt0WpykkWAS0I2lxMU0R9ma/mXH/FYV4QtMNYCcMPQMsmWgOC8Z bODMkHRi60NIy7R/9sZd4sxiXx8DAUrp5rdmLSuyEdVA/KtIgbd4ugkIvtxdQaXb5Pv2 aF1F181oYR6lE/3g+IXsIh+eGs312t1DTcmbevKMA0ShZORRASw1bUhOMMK/5YiiSfF9 xLhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to; bh=Y24Kmxvc98AYq5b/p3sk8V7l3IKrZYn9CPgZXGpkdWs=; b=h9olIjoFgoCiSCqoOK8MO+0zs/ZfhgZ23VWUTX1MdWttlpliBwTZ0uwVlezuqNh8bQ ZLqzeAA4hibAlG/oSsshEIMjMbzkRPZyW5RrDn4GlWGhCEWD59RyvJk20KrhGZEBzBAj 4ceBSmn98mikCJdJttan47U74voYkxOZJehGV5VgrleoB24r5Dnq7TRS1/Fh24GjgKGY tkbYKSq899lwRc1y4d2AI69Hc+hy3RNYFe8oCGQpRc5bUvg31z5xGLm7XRDpHxHYfuKs sLy6FAe1UDFnlJ78VEogVol4WOat/nxjGXSK8t+NSjExpUDyyuG2eiwDfF07Cs3clsO8 4fAg== X-Gm-Message-State: AE9vXwNaNbHlfKq15WvptG9MvIc0kWqGeEoNQ0LrRzsWrySqg/97eXoXKNmFysD3P6d6cQ== X-Received: by 10.98.47.132 with SMTP id v126mr25147974pfv.152.1472403781028; Sun, 28 Aug 2016 10:03:01 -0700 (PDT) Received: from [152.117.208.8] (GUES2088.plu.edu. [152.117.208.8]) by smtp.googlemail.com with ESMTPSA id 81sm42964408pfm.90.2016.08.28.10.02.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Aug 2016 10:03:00 -0700 (PDT) Subject: Re: Simple queries with JDBC escaped scalar functions result in exceptions To: Vladimir Sitnikov , Andreas Joseph Krogh References: Cc: "pgsql-jdbc@postgresql.org" , Dave Cramer From: Adam Rauch Message-ID: Date: Sun, 28 Aug 2016 10:02:55 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------FB0505858C4DE9261348DE26" X-Pg-Spam-Score: -2.6 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org This is a multi-part message in MIME format. --------------FB0505858C4DE9261348DE26 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Thanks, Vladimir! Local build of 9.4.1210-SNAPSHOT works great; all my legal test queries execute successfully now. Just FYI, the new driver threw java.lang.ArrayIndexOutOfBoundsException with an _illegal_ query: SELECT /* /* */ 1 java.lang.ArrayIndexOutOfBoundsException at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:597) at java.lang.StringBuilder.append(StringBuilder.java:190) at org.postgresql.core.Parser.parseSql(Parser.java:1037) at org.postgresql.core.Parser.replaceProcessing(Parser.java:974) at org.postgresql.core.CachedQueryCreateAction.create(CachedQueryCreateAction.java:43) at org.postgresql.core.CachedQueryCreateAction.create(CachedQueryCreateAction.java:19) at org.postgresql.util.LruCache.borrow(LruCache.java:118) at org.postgresql.core.QueryExecutorBase.borrowQuery(QueryExecutorBase.java:261) at org.postgresql.jdbc.PgConnection.borrowQuery(PgConnection.java:146) at org.postgresql.jdbc.PgPreparedStatement.(PgPreparedStatement.java:91) at org.postgresql.jdbc.PgConnection.prepareStatement(PgConnection.java:1259) at org.postgresql.jdbc.PgConnection.prepareStatement(PgConnection.java:1625) at org.postgresql.jdbc.PgConnection.prepareStatement(PgConnection.java:418) I'm not suggesting this needs to be addressed... unbalanced comments will of course be rejected by the server anyway. Thanks, Adam On 8/28/2016 8:00 AM, Vladimir Sitnikov wrote: > >The dollar sign ($) is the only case we came across in our test environments, but it looks > like a single quote (') or double quote (") in a comment also trips up > the parser. As do the two-character combinations {D, {E, {F, {O, and > {T... and their lowercase equivalents. A full set of test queries that > fail when executed via postgresql-9.4.1209.jar: > > Thanks for the analysis. > > I think > https://github.com/pgjdbc/pgjdbc/commit/2d9b313160dc5b73df2ae9001795592b37e8e8e0 should > fix the issue. > > The fix is available in 9.4.1210-SNAPSHOT > > Vladimir --------------FB0505858C4DE9261348DE26 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit

Thanks, Vladimir! Local build of 9.4.1210-SNAPSHOT works great; all my legal test queries execute successfully now.

Just FYI, the new driver threw java.lang.ArrayIndexOutOfBoundsException with an illegal query: SELECT /* /* */ 1

java.lang.ArrayIndexOutOfBoundsException
    at java.lang.AbstractStringBuilder.append(AbstractStringBuilder.java:597)
    at java.lang.StringBuilder.append(StringBuilder.java:190)
    at org.postgresql.core.Parser.parseSql(Parser.java:1037)
    at org.postgresql.core.Parser.replaceProcessing(Parser.java:974)
    at org.postgresql.core.CachedQueryCreateAction.create(CachedQueryCreateAction.java:43)
    at org.postgresql.core.CachedQueryCreateAction.create(CachedQueryCreateAction.java:19)
    at org.postgresql.util.LruCache.borrow(LruCache.java:118)
    at org.postgresql.core.QueryExecutorBase.borrowQuery(QueryExecutorBase.java:261)
    at org.postgresql.jdbc.PgConnection.borrowQuery(PgConnection.java:146)
    at org.postgresql.jdbc.PgPreparedStatement.<init>(PgPreparedStatement.java:91)
    at org.postgresql.jdbc.PgConnection.prepareStatement(PgConnection.java:1259)
    at org.postgresql.jdbc.PgConnection.prepareStatement(PgConnection.java:1625)
    at org.postgresql.jdbc.PgConnection.prepareStatement(PgConnection.java:418)

I'm not suggesting this needs to be addressed... unbalanced comments will of course be rejected by the server anyway.

Thanks,
Adam

On 8/28/2016 8:00 AM, Vladimir Sitnikov wrote:
>The dollar sign ($) is the only case we came across in our test environments, but it looks like a single quote (') or double quote (") in a comment also trips up the parser. As do the two-character combinations {D, {E, {F, {O, and {T... and their lowercase equivalents. A full set of test queries that fail when executed via postgresql-9.4.1209.jar:

Thanks for the analysis.


The fix is available in 9.4.1210-SNAPSHOT

Vladimir

--------------FB0505858C4DE9261348DE26--