mirror of
https://github.com/postgres/postgres.git
synced 2025-09-11 00:12:06 +03:00
Patches submitted by Kris Jurka (jurka@ejurka.com) for the following bugs:
- Properly drop tables in jdbc regression tests with cascade for 7.3 - problem with Statement.execute() and executeUpdate() not clearing binds - problem with ResultSet not correctly handling default encoding - changes to correctly support show transaction isolation level in 7.3 - changed DatabaseMetaDataTest to handle differences in FK names in 7.3 - better fix for dynamically checking server NAME data length (With the fixes above the jdbc regression tests pass on jdbc2 and jdbc3 against both a 7.2 and 7.3 server) Patchs submitted by David Wall (d.wall@computer.org): - problem with getBlob when largeobject oid is null - improvements to BlobOutputStream Patch submitted by Haris Peco (snpe@snpe.co.yu): - problem with callable statement not supporting prepared statement methods Modified Files: jdbc/org/postgresql/Driver.java.in jdbc/org/postgresql/jdbc1/AbstractJdbc1Connection.java jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java jdbc/org/postgresql/jdbc2/AbstractJdbc2ResultSet.java jdbc/org/postgresql/jdbc2/AbstractJdbc2Statement.java jdbc/org/postgresql/jdbc2/Jdbc2ResultSet.java jdbc/org/postgresql/jdbc3/Jdbc3ResultSet.java jdbc/org/postgresql/largeobject/BlobOutputStream.java jdbc/org/postgresql/largeobject/LargeObject.java jdbc/org/postgresql/test/TestUtil.java jdbc/org/postgresql/test/jdbc2/DatabaseMetaDataTest.java jdbc/org/postgresql/test/jdbc2/UpdateableResultTest.java jdbc/org/postgresql/test/jdbc2/optional/BaseDataSourceTest.java jdbc/org/postgresql/test/jdbc2/optional/ConnectionPoolTest.java jdbc/org/postgresql/test/jdbc2/optional/SimpleDataSourceTest.java
This commit is contained in:
@@ -109,11 +109,26 @@ public class TestUtil
|
||||
Statement stmt = con.createStatement();
|
||||
try
|
||||
{
|
||||
stmt.executeUpdate("DROP TABLE " + table);
|
||||
String sql = "DROP TABLE " + table;
|
||||
if (con instanceof org.postgresql.jdbc1.AbstractJdbc1Connection && ((org.postgresql.jdbc1.AbstractJdbc1Connection)con).haveMinimumServerVersion("7.3")) {
|
||||
sql += " CASCADE ";
|
||||
}
|
||||
stmt.executeUpdate(sql);
|
||||
}
|
||||
catch (SQLException ex)
|
||||
{
|
||||
// ignore
|
||||
// Since every create table issues a drop table
|
||||
// it's easy to get a table doesn't exist error.
|
||||
// we want to ignore these, but if we're in a
|
||||
// transaction we need to restart.
|
||||
// If the test case wants to catch this error
|
||||
// itself it should issue the drop SQL directly.
|
||||
if (ex.getMessage().indexOf("does not exist") != -1) {
|
||||
if (!con.getAutoCommit()) {
|
||||
con.rollback();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException ex)
|
||||
|
@@ -9,7 +9,7 @@ import java.sql.*;
|
||||
*
|
||||
* PS: Do you know how difficult it is to type on a train? ;-)
|
||||
*
|
||||
* $Id: DatabaseMetaDataTest.java,v 1.13 2002/09/06 21:23:06 momjian Exp $
|
||||
* $Id: DatabaseMetaDataTest.java,v 1.14 2002/09/11 05:38:45 barry Exp $
|
||||
*/
|
||||
|
||||
public class DatabaseMetaDataTest extends TestCase
|
||||
@@ -264,7 +264,11 @@ public class DatabaseMetaDataTest extends TestCase
|
||||
assertTrue( fkColumnName.equals( "m" ) || fkColumnName.equals( "n" ) ) ;
|
||||
|
||||
String fkName = rs.getString( "FK_NAME" );
|
||||
assertTrue( fkName.equals( "<unnamed>") );
|
||||
if (((org.postgresql.jdbc1.AbstractJdbc1Connection)con1).haveMinimumServerVersion("7.3")) {
|
||||
assertTrue(fkName.startsWith("$1"));
|
||||
} else {
|
||||
assertTrue( fkName.startsWith( "<unnamed>") );
|
||||
}
|
||||
|
||||
String pkName = rs.getString( "PK_NAME" );
|
||||
assertTrue( pkName.equals("vv_pkey") );
|
||||
@@ -317,7 +321,7 @@ public class DatabaseMetaDataTest extends TestCase
|
||||
assertTrue( fkColumnName.equals( "people_id" ) || fkColumnName.equals( "policy_id" ) ) ;
|
||||
|
||||
String fkName = rs.getString( "FK_NAME" );
|
||||
assertTrue( fkName.equals( "people") || fkName.equals( "policy" ) );
|
||||
assertTrue( fkName.startsWith( "people") || fkName.startsWith( "policy" ) );
|
||||
|
||||
String pkName = rs.getString( "PK_NAME" );
|
||||
assertTrue( pkName.equals( "people_pkey") || pkName.equals( "policy_pkey" ) );
|
||||
@@ -337,7 +341,7 @@ public class DatabaseMetaDataTest extends TestCase
|
||||
assertTrue( rs.getString( "FKTABLE_NAME" ).equals( "users" ) );
|
||||
assertTrue( rs.getString( "FKCOLUMN_NAME" ).equals( "people_id" ) );
|
||||
|
||||
assertTrue( rs.getString( "FK_NAME" ).equals( "people" ) );
|
||||
assertTrue( rs.getString( "FK_NAME" ).startsWith( "people" ) );
|
||||
|
||||
|
||||
TestUtil.dropTable( con1, "users" );
|
||||
|
@@ -124,6 +124,7 @@ public class UpdateableResultTest extends TestCase
|
||||
st.close();
|
||||
|
||||
TestUtil.dropTable( con, "updateable" );
|
||||
TestUtil.dropTable( con, "second" );
|
||||
TestUtil.closeDB( con );
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package org.postgresql.test.jdbc2.optional;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import org.postgresql.test.JDBC2Tests;
|
||||
import org.postgresql.test.TestUtil;
|
||||
import org.postgresql.jdbc2.optional.SimpleDataSource;
|
||||
import org.postgresql.jdbc2.optional.BaseDataSource;
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.sql.*;
|
||||
* tests.
|
||||
*
|
||||
* @author Aaron Mulder (ammulder@chariotsolutions.com)
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
public abstract class BaseDataSourceTest extends TestCase
|
||||
{
|
||||
@@ -36,12 +36,12 @@ public abstract class BaseDataSourceTest extends TestCase
|
||||
*/
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
con = JDBC2Tests.openDB();
|
||||
JDBC2Tests.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
|
||||
con = TestUtil.openDB();
|
||||
TestUtil.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
|
||||
Statement stmt = con.createStatement();
|
||||
stmt.executeUpdate("INSERT INTO poolingtest VALUES (1, 'Test Row 1')");
|
||||
stmt.executeUpdate("INSERT INTO poolingtest VALUES (2, 'Test Row 2')");
|
||||
JDBC2Tests.closeDB(con);
|
||||
TestUtil.closeDB(con);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,9 +50,9 @@ public abstract class BaseDataSourceTest extends TestCase
|
||||
*/
|
||||
protected void tearDown() throws Exception
|
||||
{
|
||||
con = JDBC2Tests.openDB();
|
||||
JDBC2Tests.dropTable(con, "poolingtest");
|
||||
JDBC2Tests.closeDB(con);
|
||||
con = TestUtil.openDB();
|
||||
TestUtil.dropTable(con, "poolingtest");
|
||||
TestUtil.closeDB(con);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -142,8 +142,7 @@ public abstract class BaseDataSourceTest extends TestCase
|
||||
try
|
||||
{
|
||||
con = getDataSourceConnection();
|
||||
JDBC2Tests.dropTable(con, "poolingtest");
|
||||
JDBC2Tests.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
|
||||
TestUtil.createTable(con, "poolingtest", "id int4 not null primary key, name varchar(50)");
|
||||
con.close();
|
||||
}
|
||||
catch (SQLException e)
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package org.postgresql.test.jdbc2.optional;
|
||||
|
||||
import org.postgresql.jdbc2.optional.ConnectionPool;
|
||||
import org.postgresql.test.JDBC2Tests;
|
||||
import org.postgresql.test.TestUtil;
|
||||
import javax.sql.*;
|
||||
import java.sql.*;
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.sql.*;
|
||||
* interface to the PooledConnection is through the CPDS.
|
||||
*
|
||||
* @author Aaron Mulder (ammulder@chariotsolutions.com)
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
public class ConnectionPoolTest extends BaseDataSourceTest
|
||||
{
|
||||
@@ -31,7 +31,7 @@ public class ConnectionPoolTest extends BaseDataSourceTest
|
||||
if (bds == null)
|
||||
{
|
||||
bds = new ConnectionPool();
|
||||
String db = JDBC2Tests.getURL();
|
||||
String db = TestUtil.getURL();
|
||||
if (db.indexOf('/') > -1)
|
||||
{
|
||||
db = db.substring(db.lastIndexOf('/') + 1);
|
||||
@@ -41,8 +41,8 @@ public class ConnectionPoolTest extends BaseDataSourceTest
|
||||
db = db.substring(db.lastIndexOf(':') + 1);
|
||||
}
|
||||
bds.setDatabaseName(db);
|
||||
bds.setUser(JDBC2Tests.getUser());
|
||||
bds.setPassword(JDBC2Tests.getPassword());
|
||||
bds.setUser(TestUtil.getUser());
|
||||
bds.setPassword(TestUtil.getPassword());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package org.postgresql.test.jdbc2.optional;
|
||||
|
||||
import org.postgresql.test.JDBC2Tests;
|
||||
import org.postgresql.test.TestUtil;
|
||||
import org.postgresql.jdbc2.optional.SimpleDataSource;
|
||||
|
||||
/**
|
||||
@@ -8,7 +8,7 @@ import org.postgresql.jdbc2.optional.SimpleDataSource;
|
||||
* configuration logic.
|
||||
*
|
||||
* @author Aaron Mulder (ammulder@chariotsolutions.com)
|
||||
* @version $Revision: 1.2 $
|
||||
* @version $Revision: 1.3 $
|
||||
*/
|
||||
public class SimpleDataSourceTest extends BaseDataSourceTest
|
||||
{
|
||||
@@ -28,7 +28,7 @@ public class SimpleDataSourceTest extends BaseDataSourceTest
|
||||
if (bds == null)
|
||||
{
|
||||
bds = new SimpleDataSource();
|
||||
String db = JDBC2Tests.getURL();
|
||||
String db = TestUtil.getURL();
|
||||
if (db.indexOf('/') > -1)
|
||||
{
|
||||
db = db.substring(db.lastIndexOf('/') + 1);
|
||||
@@ -38,8 +38,8 @@ public class SimpleDataSourceTest extends BaseDataSourceTest
|
||||
db = db.substring(db.lastIndexOf(':') + 1);
|
||||
}
|
||||
bds.setDatabaseName(db);
|
||||
bds.setUser(JDBC2Tests.getUser());
|
||||
bds.setPassword(JDBC2Tests.getPassword());
|
||||
bds.setUser(TestUtil.getUser());
|
||||
bds.setPassword(TestUtil.getPassword());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user