Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1Zjtg8-0008SX-Fn for pgsql-jdbc@arkaria.postgresql.org; Wed, 07 Oct 2015 18:43:04 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1Zjtg7-0005sg-Fy for pgsql-jdbc@arkaria.postgresql.org; Wed, 07 Oct 2015 18:43:03 +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) (envelope-from ) id 1Zjtfc-0005Kc-9t for pgsql-jdbc@postgresql.org; Wed, 07 Oct 2015 18:42:32 +0000 Received: from mail-ig0-f176.google.com ([209.85.213.176]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1ZjtfX-0000Md-6e for pgsql-jdbc@postgresql.org; Wed, 07 Oct 2015 18:42:31 +0000 Received: by igcpb10 with SMTP id pb10so118492084igc.1 for ; Wed, 07 Oct 2015 11:42:25 -0700 (PDT) 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:content-type; bh=S8+OkOeepvIT5OSXBXgnpGrn0Ps9lt1sEUN5leDl3dQ=; b=UzshH5hpErmeVAUUEckkZjKrGsr9c8/hLSXKyN//1isrqw/aJBS5L+K3dvEhjzIFhT Axc13Zzdmhd1dQkjAGpgL4BxbotvUkz485BAYteLzRu+9UL9APkEBgsBCXfxgCriqveD lkphXT+ZoLlZkoqsUM0DHY9GMSVycbQT+ckLFldPauEicXTlTJdZOlBc0RdJ26uxABp0 A8tgiD6s1WJ469YLIc6QX0JmpLfWqwfxLlUOo/StCMAd3soEKtP9tLuAJ3m9ORd4oeJB TR44ypGGVcXGAiJnGR7AouE3OTdyR7dUc8+uMphG28WSu4Ou2upYAjK6KyH0g3ggW0mc HmIQ== X-Gm-Message-State: ALoCoQkeAUR5DkuATi53QGsKSU+HAqayZjZ28dFmqrz50l2AH5D/KA+lKFKk9H7faYxt4R+Eqm4m X-Received: by 10.50.136.228 with SMTP id qd4mr3924664igb.83.1444243344840; Wed, 07 Oct 2015 11:42:24 -0700 (PDT) Received: from [10.78.246.53] ([74.202.208.74]) by smtp.googlemail.com with ESMTPSA id gy4sm1736464igb.6.2015.10.07.11.42.23 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Oct 2015 11:42:24 -0700 (PDT) Subject: Re: JDBC-94: "Multiple resultsets were returned by query" in query end with "; " To: Christopher BROWN , Dave Cramer References: <21DDBBC0-6A6E-4B9B-9A25-C0044EAF5250@gmail.com> Cc: Vladimir Sitnikov , Craig Ringer , Dang Minh Huong , "pgsql-jdbc@postgresql.org" From: Adam Rauch Message-ID: <5615678C.4000005@labkey.com> Date: Wed, 7 Oct 2015 11:42:20 -0700 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------060108000707050804090300" 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. --------------060108000707050804090300 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit I agree with Christopher. After upgrading to the latest JDBC driver our system started throwing these exceptions. It's not hard for us to fix (I can update our own framework code), but it seems unnecessary and is likely more difficult for others to address. Here's a simplified example of SQL-generatation code that runs afoul of this change: in our system, a logical insert at one layer may map to multiple database inserts (e.g., to a primary database table plus one or more property tables). The code generating the insert SQL terminates each INSERT with ";\n", for convenience and human readability. As a result, the final INSERT can end with a dangling "\n" that 1202 now rejects. Of course, we could duplicate a subsequent check and/or special case the last INSERT to remove the "\n", but the current code is cleaner. Adam On 10/7/2015 5:42 AM, Christopher BROWN wrote: > Hello, > > Developers that use the driver via a framework (open-source, in-house) > might not be in a position to change SQL, compared with developers > that are able to modify hand-written SQL, so it's probably best to > tolerate it by discarding any trailing semi-colon (with or without any > trailing whitespace) in the parser. > > I've also encountered coding practices (coding-style "standards") > where semi-colons are expected (some people just love terminating all > statements, not just Java, with semi-colons, even when it's not > strictly necessary (e.g.: JavaScript). > > So, my preference would be to maintain backwards-compatibility for > others, even if I don't have such an issue myself. > > -- > Christopher > > > On 7 October 2015 at 14:34, Dave Cramer > wrote: > > This is a very good question, but lots of people cut and paste SQL > into code ... sometimes the ; gets in there. > > Behaviour of previous version is important, but in this case It > may not be justified. > > Anyone else have an opinion ? > > Dave Cramer > > dave.cramer(at)credativ(dot)ca > http://www.credativ.ca > > On 7 October 2015 at 08:30, Vladimir Sitnikov > > > wrote: > > I wonder why pgjdbc would want to silently ignore that user error? > Is "behavior of previous version" a sole justification? > > I've drafted https://github.com/pgjdbc/pgjdbc/pull/386 to > cover that. > > Vladimir > > > --------------060108000707050804090300 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit I agree with Christopher. After upgrading to the latest JDBC driver our system started throwing these exceptions. It's not hard for us to fix (I can update our own framework code), but it seems unnecessary and is likely more difficult for others to address.

Here's a simplified example of SQL-generatation code that runs afoul of this change: in our system, a logical insert at one layer may map to multiple database inserts (e.g., to a primary database table plus one or more property tables). The code generating the insert SQL terminates each INSERT with ";\n", for convenience and human readability. As a result, the final INSERT can end with a dangling "\n" that 1202 now rejects. Of course, we could duplicate a subsequent check and/or special case the last INSERT to remove the "\n", but the current code is cleaner.

Adam

On 10/7/2015 5:42 AM, Christopher BROWN wrote:
Hello,

Developers that use the driver via a framework (open-source, in-house) might not be in a position to change SQL, compared with developers that are able to modify hand-written SQL, so it's probably best to tolerate it by discarding any trailing semi-colon (with or without any trailing whitespace) in the parser.

I've also encountered coding practices (coding-style "standards") where semi-colons are expected (some people just love terminating all statements, not just Java, with semi-colons, even when it's not strictly necessary (e.g.: JavaScript).

So, my preference would be to maintain backwards-compatibility for others, even if I don't have such an issue myself.

--
Christopher


On 7 October 2015 at 14:34, Dave Cramer <pg@fastcrypt.com> wrote:
This is a very good question, but lots of people cut and paste SQL into code ... sometimes the ; gets in there.

Behaviour of previous version is important, but in this case It may not be justified.

Anyone else have an opinion ?

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

On 7 October 2015 at 08:30, Vladimir Sitnikov <sitnikov.vladimir@gmail.com> wrote:
I wonder why pgjdbc would want to silently ignore that user error?
Is "behavior of previous version" a sole justification?

I've drafted https://github.com/pgjdbc/pgjdbc/pull/386 to cover that.

Vladimir



--------------060108000707050804090300--