repair jdbc2 optional testsuite's all issue
This commit is contained in:
@ -1242,8 +1242,6 @@ public abstract class BaseDataSource implements CommonDataSource, Referenceable
|
||||
ref.add(new StringRefAddr("password", password));
|
||||
}
|
||||
|
||||
ref.add(new StringRefAddr("allowEncodingChanges", Boolean.toString(allowEncodingChanges)));
|
||||
|
||||
ref.add(new StringRefAddr("characterEncoding", characterEncoding));
|
||||
|
||||
ref.add(new StringRefAddr("connectionExtraInfo", Boolean.toString(connectionExtraInfo)));
|
||||
|
||||
@ -328,7 +328,26 @@ public class TypeInfoCache implements TypeInfo {
|
||||
|
||||
public int getPGArrayType(String elementTypeName) throws SQLException {
|
||||
elementTypeName = getTypeForAlias(elementTypeName);
|
||||
return getPGType(elementTypeName + "[]");
|
||||
int pgType = Oid.UNSPECIFIED;
|
||||
for (String newTypeName: new String[] {
|
||||
combainStringIfOneQuoted("_", elementTypeName),
|
||||
combainStringIfOneQuoted(elementTypeName, "[]")}) {
|
||||
pgType = getPGType(newTypeName);
|
||||
if (pgType != Oid.UNSPECIFIED) {
|
||||
return pgType;
|
||||
}
|
||||
}
|
||||
return pgType;
|
||||
}
|
||||
|
||||
private static String combainStringIfOneQuoted(String first, String second) {
|
||||
if (first.startsWith("\"")) {
|
||||
return first.substring(0, first.length() - 1) + second + "\"";
|
||||
}
|
||||
if (second.startsWith("\"")) {
|
||||
return "\"" + first + second.substring(1);
|
||||
}
|
||||
return first + second;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -24,12 +24,9 @@ import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.sql.CallableStatement;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Statement;
|
||||
import java.sql.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
|
||||
import javax.sql.ConnectionEvent;
|
||||
import javax.sql.ConnectionEventListener;
|
||||
@ -324,18 +321,33 @@ public class ConnectionPoolTest extends BaseDataSourceTest {
|
||||
public void testBackendIsClosed() throws Exception {
|
||||
try {
|
||||
PooledConnection pc = getPooledConnection();
|
||||
con = pc.getConnection();
|
||||
Connection poolCon = pc.getConnection();
|
||||
con = poolCon.unwrap(PgConnection.class);
|
||||
assertTrue(!con.isClosed());
|
||||
|
||||
Assume.assumeTrue("pg_terminate_backend requires PostgreSQL 8.4+",
|
||||
TestUtil.haveMinimumServerVersion(con, ServerVersion.v8_4));
|
||||
|
||||
int pid = ((PgConnection) con).getQueryExecutor().getBackendPID();
|
||||
|
||||
long pid = ((PgConnection) con).getQueryExecutor().getBackendPID();
|
||||
try (Statement st = con.createStatement()) {
|
||||
try (ResultSet rs = st.executeQuery("select pg_backend_pid()")) {
|
||||
if (rs.next()) {
|
||||
pid = rs.getLong(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Connection adminCon = TestUtil.openPrivilegedDB();
|
||||
try {
|
||||
Statement statement = adminCon.createStatement();
|
||||
statement.executeQuery("SELECT pg_terminate_backend(" + pid + ")");
|
||||
try (ResultSet rs = statement.executeQuery("SELECT pg_terminate_backend(" + pid + ")")) {
|
||||
if (rs.next()) {
|
||||
System.out.println(rs.getBoolean(1));
|
||||
} else {
|
||||
System.out.println("terminal failed!");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
TestUtil.closeDB(adminCon);
|
||||
}
|
||||
|
||||
@ -63,8 +63,8 @@ public class ArrayTest extends BaseTest4 {
|
||||
TestUtil.createTable(_conn, "arrcompprnttest", "id serial, name character(10)");
|
||||
TestUtil.createTable(_conn, "arrcompchldttest",
|
||||
"id serial, name character(10), description character varying, parent integer");
|
||||
TestUtil.createTable(_conn, "\"CorrectCasing\"", "id serial");
|
||||
TestUtil.createTable(_conn, "\"Evil.Table\"", "id serial");
|
||||
TestUtil.createTable(_conn, "\"correctcasing\"", "id serial");
|
||||
TestUtil.createTable(_conn, "\"evil.table\"", "id serial");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -443,13 +443,13 @@ public class ArrayTest extends BaseTest4 {
|
||||
TestUtil.haveMinimumServerVersion(_conn, ServerVersion.v8_3));
|
||||
|
||||
PGobject cc = new PGobject();
|
||||
cc.setType("\"CorrectCasing\"");
|
||||
cc.setType("correctcasing");
|
||||
cc.setValue("(1)");
|
||||
Object[] in = new Object[1];
|
||||
in[0] = cc;
|
||||
|
||||
Array arr = _conn.createArrayOf("\"CorrectCasing\"", in);
|
||||
PreparedStatement pstmt = _conn.prepareStatement("SELECT ?::\"CorrectCasing\"[]");
|
||||
Array arr = _conn.createArrayOf("correctcasing", in);
|
||||
PreparedStatement pstmt = _conn.prepareStatement("SELECT ?::correctcasing[]");
|
||||
pstmt.setArray(1, arr);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
|
||||
@ -476,8 +476,8 @@ public class ArrayTest extends BaseTest4 {
|
||||
|
||||
@Test
|
||||
public void testCasingBuiltinNonAlias() throws SQLException {
|
||||
Array arr = _conn.createArrayOf("INT4", new Integer[]{1, 2, 3});
|
||||
PreparedStatement pstmt = _conn.prepareStatement("SELECT ?::INT4[]");
|
||||
Array arr = _conn.createArrayOf("int4", new Integer[]{1, 2, 3});
|
||||
PreparedStatement pstmt = _conn.prepareStatement("SELECT ?::int4[]");
|
||||
pstmt.setArray(1, arr);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
|
||||
@ -493,13 +493,13 @@ public class ArrayTest extends BaseTest4 {
|
||||
TestUtil.haveMinimumServerVersion(_conn, ServerVersion.v8_3));
|
||||
|
||||
PGobject cc = new PGobject();
|
||||
cc.setType("\"Evil.Table\"");
|
||||
cc.setType("\"evil.table\"");
|
||||
cc.setValue("(1)");
|
||||
Object[] in = new Object[1];
|
||||
in[0] = cc;
|
||||
|
||||
Array arr = _conn.createArrayOf("\"Evil.Table\"", in);
|
||||
PreparedStatement pstmt = _conn.prepareStatement("SELECT ?::\"Evil.Table\"[]");
|
||||
Array arr = _conn.createArrayOf("evil.table", in);
|
||||
PreparedStatement pstmt = _conn.prepareStatement("SELECT ?::\"evil.table\"[]");
|
||||
pstmt.setArray(1, arr);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user