Skip to content
Permalink
Browse files

Remove tests that use oids fixes #1347 (#1348)

* remove oid usage from tests as it is no longer possible to create user tables WITH OIDS

* see https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=578b229718e8f15fa779e20f086c4b6bb3776106

* remove TestUtil function to create tables with oids
  • Loading branch information...
davecramer committed Nov 22, 2018
1 parent f3ade07 commit da4d6577f4c0acaadb703b40d267395bb45418f8
@@ -389,19 +389,11 @@ public static void dropSchema(Connection con, String schema) throws SQLException
}
}

/*
* Helper - creates a test table for use by a test
*/
public static void createTable(Connection con, String table, String columns) throws SQLException {
// by default we don't request oids.
createTable(con, table, columns, false);
}

/*
* Helper - creates a test table for use by a test
*/
public static void createTable(Connection con, String table, String columns, boolean withOids)
throws SQLException {
public static void createTable(Connection con, String table, String columns) throws SQLException {
Statement st = con.createStatement();
try {
// Drop the table
@@ -410,10 +402,6 @@ public static void createTable(Connection con, String table, String columns, boo
// Now create the table
String sql = "CREATE TABLE " + table + " (" + columns + ")";

if (withOids) {
sql += " WITH OIDS";
}

st.executeUpdate(sql);
} finally {
closeQuietly(st);
@@ -70,7 +70,7 @@ protected void updateProperties(Properties props) {
public void setUp() throws Exception {
super.setUp();
conn = con;
TestUtil.createTable(conn, "rsmd1", "a int primary key, b text, c decimal(10,2)", true);
TestUtil.createTable(conn, "rsmd1", "a int primary key, b text, c decimal(10,2)");
TestUtil.createTable(conn, "rsmd_cache", "a int primary key");
TestUtil.createTable(conn, "timetest",
"tm time(3), tmtz timetz, ts timestamp without time zone, tstz timestamp(6) with time zone");
@@ -110,7 +110,7 @@ public void tearDown() throws SQLException {
@Test
public void testStandardResultSet() throws SQLException {
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT a,b,c,a+c as total,oid,b as d FROM rsmd1");
ResultSet rs = stmt.executeQuery("SELECT a,b,c,a+c as total, b as d FROM rsmd1");
runStandardTests(rs.getMetaData());
rs.close();
stmt.close();
@@ -121,23 +121,22 @@ public void testPreparedResultSet() throws SQLException {
assumePreparedStatementMetadataSupported();

PreparedStatement pstmt =
conn.prepareStatement("SELECT a,b,c,a+c as total,oid,b as d FROM rsmd1 WHERE b = ?");
conn.prepareStatement("SELECT a,b,c,a+c as total, b as d FROM rsmd1 WHERE b = ?");
runStandardTests(pstmt.getMetaData());
pstmt.close();
}

private void runStandardTests(ResultSetMetaData rsmd) throws SQLException {
PGResultSetMetaData pgrsmd = (PGResultSetMetaData) rsmd;

assertEquals(6, rsmd.getColumnCount());
assertEquals(5, rsmd.getColumnCount());

assertEquals("a", rsmd.getColumnLabel(1));
assertEquals("total", rsmd.getColumnLabel(4));

assertEquals("a", rsmd.getColumnName(1));
assertEquals("oid", rsmd.getColumnName(5));
assertEquals("", pgrsmd.getBaseColumnName(4));
assertEquals("b", pgrsmd.getBaseColumnName(6));
assertEquals("b", pgrsmd.getBaseColumnName(5));

assertEquals(Types.INTEGER, rsmd.getColumnType(1));
assertEquals(Types.VARCHAR, rsmd.getColumnType(2));
@@ -37,8 +37,7 @@
public void setUp() throws Exception {
super.setUp();
TestUtil.createTable(con, "updateable",
"id int primary key, name text, notselected text, ts timestamp with time zone, intarr int[]",
true);
"id int primary key, name text, notselected text, ts timestamp with time zone, intarr int[]");
TestUtil.createTable(con, "second", "id1 int primary key, name1 text");
TestUtil.createTable(con, "stream", "id int primary key, asi text, chr text, bin bytea");
TestUtil.createTable(con, "multicol", "id1 int not null, id2 int not null, val text");
@@ -330,7 +329,7 @@ public void testUpdateable() throws SQLException {
} catch (SQLException ex) {
}

rs = st.executeQuery("select oid,* from updateable");
rs = st.executeQuery("select * from updateable");
assertTrue(rs.first());
rs.updateInt("id", 3);
rs.updateString("name", "dave3");

0 comments on commit da4d657

Please sign in to comment.
You can’t perform that action at this time.