pgpool2.git / summary / log / commit / refs
commit 26ed7692523b80139847accd56cc414e92eafdcd
Author: Tatsuo Ishii <ishii@postgresql.org>
Date: Sun Jun 30 08:25:45 2013 +0000
Add regression test for bug#63.
test/regression/tests/056.bug63/jdbctest2.java | 66 ++++++++++++++++++++++++++
test/regression/tests/056.bug63/test.sh | 45 ++++++++++++++++++
2 files changed, 111 insertions(+)
diff --git a/test/regression/tests/056.bug63/jdbctest2.java b/test/regression/tests/056.bug63/jdbctest2.java
new file mode 100644
index 000000000..8f8b6efa8
--- /dev/null
+++ b/test/regression/tests/056.bug63/jdbctest2.java
@@ -0,0 +1,66 @@
+/*
+
+# su - postgres
+
+$ pgbench -i
+
+$ cat jdbctest.prop
+jdbc.url=jdbc:postgresql://localhost:9999/postgres
+jdbc.user=postgres
+jdbc.password=postgres
+
+$ cat run.sh
+java -Djdbc.drivers=org.postgresql.Driver \
+ -classpath .:./postgresql-9.0-802.jdbc4.jar \
+ "jdbctest2"
+
+*/
+
+import java.sql.*;
+import javax.sql.*;
+import java.util.*;
+import java.io.*;
+
+public class jdbctest2 {
+ 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 sql2 = "SELECT aid, bid, abalance, filler FROM pgbench_accounts WHERE aid != ? LIMIT ?";
+ PreparedStatement pst2 = conn.prepareStatement(sql2);
+ int aid = 1, lim = 7000, c = 0;
+ ResultSet rs;
+ String tmp;
+
+ for (c = 0; c < 200; ++c) {
+ aid = (int) Math.floor(Math.random() * 50000) + 1;
+ lim = 7500 + (int) Math.floor(Math.random() * 1000) + 1;
+ System.out.println("aid:" + aid + " lim:" + lim);
+ System.out.flush();
+ pst2.setInt(1, aid);
+ pst2.setInt(2, lim);
+ rs = pst2.executeQuery();
+ while (rs.next()) {
+ tmp = rs.getString(4);
+ }
+ rs.close();
+ }
+ pst2.close();
+ conn.close();
+
+
+ } catch (Exception e) {
+ System.err.println("jdbctest: ERROR: " + e);
+ System.exit(1);
+ }
+ }
+}
diff --git a/test/regression/tests/056.bug63/test.sh b/test/regression/tests/056.bug63/test.sh
new file mode 100755
index 000000000..f3647ecca
--- /dev/null
+++ b/test/regression/tests/056.bug63/test.sh
@@ -0,0 +1,45 @@
+#! /bin/sh
+#-------------------------------------------------------------------
+# test script for bug#63
+# On memory query cache occasionally segfaults.
+#
+# Fixed in: http://git.postgresql.org/gitweb/?p=pgpool2.git;a=commit;h=d428c5c27600dd82161dda6a240737d88db78732
+# requires Java PostgreSQL JDBC driver.
+JDBC_DRIVER=/usr/local/pgsql/share/postgresql-9.2-1002.jdbc4.jar
+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 ../jdbctest2.java .
+javac jdbctest2.java
+export CLASSPATH=.:$JDBC_DRIVER
+./startall
+wait_for_pgpool_startup
+
+pgbench -i test
+java jdbctest2
+
+if [ $? != 0 ];then
+ ./shutdownall
+ exit 1
+fi
+
+./shutdownall
+exit 0
[parent: d428c5c27600]