From dd79af99b14d07107e7cb575b4bca17d722f45fb Mon Sep 17 00:00:00 2001 From: Tatsuo Ishii Date: Mon, 5 Aug 2013 21:40:34 +0900 Subject: [PATCH] Add regression test for bug #68. --- .../regression/tests/058.bug68/jdbctest3.java | 45 ++++++++++++++++++ test/regression/tests/058.bug68/test.sh | 47 +++++++++++++++++++ 2 files changed, 92 insertions(+) create mode 100644 test/regression/tests/058.bug68/jdbctest3.java create mode 100755 test/regression/tests/058.bug68/test.sh diff --git a/test/regression/tests/058.bug68/jdbctest3.java b/test/regression/tests/058.bug68/jdbctest3.java new file mode 100644 index 000000000..20cfb1aae --- /dev/null +++ b/test/regression/tests/058.bug68/jdbctest3.java @@ -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 index 000000000..85ca7d886 --- /dev/null +++ b/test/regression/tests/058.bug68/test.sh @@ -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 -- 2.39.5