Add regression test for bug #68.
authorTatsuo Ishii <ishii@postgresql.org>
Mon, 5 Aug 2013 12:40:34 +0000 (21:40 +0900)
committerTatsuo Ishii <ishii@postgresql.org>
Mon, 5 Aug 2013 12:41:41 +0000 (21:41 +0900)
test/regression/tests/058.bug68/jdbctest3.java [new file with mode: 0644]
test/regression/tests/058.bug68/test.sh [new file with mode: 0755]

diff --git a/test/regression/tests/058.bug68/jdbctest3.java b/test/regression/tests/058.bug68/jdbctest3.java
new file mode 100644 (file)
index 0000000..20cfb1a
--- /dev/null
@@ -0,0 +1,45 @@
+import java.sql.*;
+import javax.sql.*;
+import java.util.*;
+import java.io.*;
+public class jdbctest3 {
+  public static void main(String[] args) {
+    try {
+      Properties prop = new Properties();
+      prop.load(new FileInputStream("jdbctest.prop"));
+      String url = prop.getProperty("jdbc.url");
+      String user = prop.getProperty("jdbc.user");
+      String pwd = prop.getProperty("jdbc.password");
+      Connection conn = DriverManager.getConnection(url, user, pwd);
+      conn.setAutoCommit(false);
+      String sql_u = "UPDATE pgbench_accounts SET filler = 'x' WHERE aid = ?";
+      String sql_s = "SELECT * FROM pgbench_accounts WHERE aid != ? LIMIT 100";
+      PreparedStatement pst_u, pst_s;
+      int aid = 1, c1 = 0, c2 = 0;
+      ResultSet rs;
+      String tmp;
+      for (c1 = 0; c1 < 10 ; ++c1) {
+        pst_u = conn.prepareStatement(sql_u);
+        pst_s = conn.prepareStatement(sql_s);
+        aid = (int) Math.floor(Math.random() * 10) + 1;
+        pst_u.setInt(1, aid);
+        pst_u.executeUpdate();
+        for (c2 = 0; c2 < 10; ++c2) {
+          aid = (int) Math.floor(Math.random() * 10) + 1;
+          pst_s.setInt(1, aid);
+          rs = pst_s.executeQuery();
+          while (rs.next()) { tmp = rs.getString(4); }
+          rs.close();
+        }
+        conn.commit();
+        pst_u.close();
+        pst_s.close();
+      }
+      conn.close();
+    } catch (Exception e) {
+      System.err.println("jdbctest: ERROR: " + e);
+      e.printStackTrace();
+      System.exit(1);
+    }
+  }
+}
\ No newline at end of file
diff --git a/test/regression/tests/058.bug68/test.sh b/test/regression/tests/058.bug68/test.sh
new file mode 100755 (executable)
index 0000000..85ca7d8
--- /dev/null
@@ -0,0 +1,47 @@
+#! /bin/sh
+#-------------------------------------------------------------------
+# test script for bug#68
+# On memory query cache occasionally segfaults.
+#
+# Fixed in: http://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=d6592ea7a95ed48855332037bca285cc6f6a3547
+# requires Java PostgreSQL JDBC driver.
+PGBENCH=$PGBENCH_PATH
+
+
+WHOAMI=`whoami`
+source $TESTLIBS
+TESTDIR=testdir
+
+rm -fr $TESTDIR
+mkdir $TESTDIR
+cd $TESTDIR
+
+# create test environment
+echo -n "creating test environment..."
+sh $PGPOOL_SETUP -m s -n 1 || exit 1
+echo "done."
+
+source ./bashrc.ports
+
+export PGPORT=$PGPOOL_PORT
+
+echo "memory_cache_enabled = on" >> etc/pgpool.conf
+echo "jdbc.url=jdbc:postgresql://localhost:$PGPOOL_PORT/test" > jdbctest.prop
+echo "jdbc.user=$WHOAMI" >> jdbctest.prop
+echo "jdbc.password=" >> jdbctest.prop
+cp ../jdbctest3.java .
+javac jdbctest3.java
+export CLASSPATH=.:$JDBC_DRIVER
+./startall
+wait_for_pgpool_startup
+
+$PGBENCH -i test
+java jdbctest3
+
+if [ $? != 0 ];then
+       ./shutdownall
+       exit 1
+fi
+
+./shutdownall
+exit 0