[libpostgresql-jdbc-java] 29/128: Fixed my patch to deal with update counts over 2^32 Check to see if the update count is greater than Integer.MAX_VALUE before setting the update_count to Statement.SUCCESS_NO_INFO NumberFormatException will still be thrown if there is a problem parsing it.

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:18:27 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to annotated tag REL9_3_1100
in repository libpostgresql-jdbc-java.

commit c425bd7f348e58eea2cd3b2a626e37cf5b4d9319
Author: Dave Cramer <davecramer at gmail.com>
Date:   Fri Jan 11 13:21:56 2013 -0500

    Fixed my patch to deal with update counts over 2^32
    Check to see if the update count is greater than Integer.MAX_VALUE before
    setting the update_count to Statement.SUCCESS_NO_INFO
    NumberFormatException will still be thrown if there is a problem
    parsing it.
---
 org/postgresql/core/v2/QueryExecutorImpl.java | 10 ++++++++--
 org/postgresql/core/v3/QueryExecutorImpl.java | 10 ++++++++--
 2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/org/postgresql/core/v2/QueryExecutorImpl.java b/org/postgresql/core/v2/QueryExecutorImpl.java
index 24fb0dd..324d536 100644
--- a/org/postgresql/core/v2/QueryExecutorImpl.java
+++ b/org/postgresql/core/v2/QueryExecutorImpl.java
@@ -587,14 +587,20 @@ public class QueryExecutorImpl implements QueryExecutor {
         {
             try
             {
-                update_count = Integer.parseInt(status.substring(1 + status.lastIndexOf(' ')));
+                long updates = Long.parseLong(status.substring(1 + status.lastIndexOf(' ')));
+
+                // deal with situations where the update modifies more than 2^32 rows
+                if ( updates > Integer.MAX_VALUE )
+                    update_count = Statement.SUCCESS_NO_INFO;
+
                 if (status.startsWith("INSERT"))
                     insert_oid = Long.parseLong(status.substring(1 + status.indexOf(' '),
                                                 status.lastIndexOf(' ')));
             }
             catch (NumberFormatException nfe)
             {
-                update_count=Statement.SUCCESS_NO_INFO;
+                handler.handleError(new PSQLException(GT.tr("Unable to interpret the update count in command completion tag: {0}.", status), PSQLState.CONNECTION_FAILURE));
+                return ;
             }
         }
 
diff --git a/org/postgresql/core/v3/QueryExecutorImpl.java b/org/postgresql/core/v3/QueryExecutorImpl.java
index 3dee95d..e6f81db 100644
--- a/org/postgresql/core/v3/QueryExecutorImpl.java
+++ b/org/postgresql/core/v3/QueryExecutorImpl.java
@@ -2189,14 +2189,20 @@ public class QueryExecutorImpl implements QueryExecutor {
         {
             try
             {
-                update_count = Integer.parseInt(status.substring(1 + status.lastIndexOf(' ')));
+                long updates = Long.parseLong(status.substring(1 + status.lastIndexOf(' ')));
+                
+                // deal with situations where the update modifies more than 2^32 rows
+                if ( updates > Integer.MAX_VALUE )
+                    update_count = Statement.SUCCESS_NO_INFO;
+                
                 if (status.startsWith("INSERT"))
                     insert_oid = Long.parseLong(status.substring(1 + status.indexOf(' '),
                                                 status.lastIndexOf(' ')));
             }
             catch (NumberFormatException nfe)
             {
-                update_count=Statement.SUCCESS_NO_INFO;
+                handler.handleError(new PSQLException(GT.tr("Unable to interpret the update count in command completion tag: {0}.", status), PSQLState.CONNECTION_FAILURE));
+                return ;
             }
         }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git



More information about the pkg-java-commits mailing list