[libpostgresql-jdbc-java] 11/13: Do escape processing on batch Statements prior to execution. This already worked for PreparedStatements, but not plain Statements.

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


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

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

commit aaa38c4f1cbbd4717dca7ccfcaa9d842255facc9
Author: Kris Jurka <books at ejurka.com>
Date:   Fri Jul 27 09:01:59 2007 +0000

    Do escape processing on batch Statements prior to execution.  This
    already worked for PreparedStatements, but not plain Statements.
    
    Reported by Hui Ye
---
 org/postgresql/jdbc2/AbstractJdbc2Statement.java |  4 +++-
 org/postgresql/test/jdbc2/BatchExecuteTest.java  | 25 +++++++++++++++++++++++-
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/org/postgresql/jdbc2/AbstractJdbc2Statement.java b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
index 47b15b0..a7df317 100644
--- a/org/postgresql/jdbc2/AbstractJdbc2Statement.java
+++ b/org/postgresql/jdbc2/AbstractJdbc2Statement.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.84.2.10 2007/03/29 04:28:02 jurka Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java,v 1.84.2.11 2007/06/22 21:37:47 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -2443,6 +2443,8 @@ public abstract class AbstractJdbc2Statement implements BaseStatement
             batchParameters = new ArrayList();
         }
 
+        p_sql = replaceProcessing(p_sql);
+
         batchStatements.add(connection.getQueryExecutor().createSimpleQuery(p_sql));
         batchParameters.add(null);
     }
diff --git a/org/postgresql/test/jdbc2/BatchExecuteTest.java b/org/postgresql/test/jdbc2/BatchExecuteTest.java
index 6174627..e4a58c0 100644
--- a/org/postgresql/test/jdbc2/BatchExecuteTest.java
+++ b/org/postgresql/test/jdbc2/BatchExecuteTest.java
@@ -3,7 +3,7 @@
 * Copyright (c) 2004-2005, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
-*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/BatchExecuteTest.java,v 1.13 2005/07/04 18:50:29 davec Exp $
+*   $PostgreSQL: pgjdbc/org/postgresql/test/jdbc2/BatchExecuteTest.java,v 1.14 2005/08/12 18:21:11 jurka Exp $
 *
 *-------------------------------------------------------------------------
 */
@@ -258,4 +258,27 @@ public class BatchExecuteTest extends TestCase
         stmt.close();
     }
 
+    public void testBatchEscapeProcessing() throws SQLException
+    {
+        Statement stmt = con.createStatement();
+        stmt.execute("CREATE TEMP TABLE batchescape (d date)");
+
+        stmt.addBatch("INSERT INTO batchescape (d) VALUES ({d '2007-11-20'})");
+        stmt.executeBatch();
+
+        PreparedStatement pstmt = con.prepareStatement("INSERT INTO batchescape (d) VALUES ({d '2007-11-20'})");
+        pstmt.addBatch();
+        pstmt.executeBatch();
+        pstmt.close();
+
+        ResultSet rs = stmt.executeQuery("SELECT d FROM batchescape");
+        assertTrue(rs.next());
+        assertEquals("2007-11-20", rs.getString(1));
+        assertTrue(rs.next());
+        assertEquals("2007-11-20", rs.getString(1));
+        assertTrue(!rs.next());
+        rs.close();
+        stmt.close();
+    }
+
 }

-- 
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