Skip to content

Commit

Permalink
test: materialized view privileges
Browse files Browse the repository at this point in the history
make "matviewtest" all lowercase so it can be found in pg catalog, which lowercases all names

fixes pgjdbc#2060
  • Loading branch information
mgrobaker committed Jul 6, 2021
1 parent f13ab15 commit eefbe02
Showing 1 changed file with 20 additions and 2 deletions.
Expand Up @@ -81,7 +81,7 @@ public void setUp() throws Exception {
TestUtil.createTable(con, "arraytable", "a numeric(5,2)[], b varchar(100)[]");
TestUtil.createTable(con, "intarraytable", "a int4[], b int4[][]");
TestUtil.createView(con, "viewtest", "SELECT id, quest FROM metadatatest");
TestUtil.createMaterializedView(con, "matViewtest", "SELECT id, quest FROM metadatatest");
TestUtil.createMaterializedView(con, "matviewtest", "SELECT id, quest FROM metadatatest");
TestUtil.dropType(con, "custom");
TestUtil.dropType(con, "_custom");
TestUtil.createCompositeType(con, "custom", "i int", false);
Expand Down Expand Up @@ -127,7 +127,7 @@ public void tearDown() throws Exception {
stmt.execute("DROP FUNCTION f4(int)");

TestUtil.dropView(con, "viewtest");
TestUtil.dropMaterializedView(con, "matViewtest");
TestUtil.dropMaterializedView(con, "matviewtest");
TestUtil.dropTable(con, "metadatatest");
TestUtil.dropTable(con, "sercoltest");
TestUtil.dropSequence(con, "sercoltest_b_seq");
Expand Down Expand Up @@ -648,6 +648,24 @@ public void testViewPrivileges() throws SQLException {
foundSelect);
}

@Test
public void testMaterializedViewPrivileges() throws SQLException {
DatabaseMetaData dbmd = con.getMetaData();
assertNotNull(dbmd);
ResultSet rs = dbmd.getTablePrivileges(null, null, "matviewtest");
boolean foundSelect = false;
while (rs.next()) {
if (rs.getString("GRANTEE").equals(TestUtil.getUser())
&& rs.getString("PRIVILEGE").equals("SELECT")) {
foundSelect = true;
}
}
rs.close();
// Test that the view owner has select priv
assertTrue("Couldn't find SELECT priv on table metadatatest for " + TestUtil.getUser(),
foundSelect);
}

@Test
public void testPrimaryKeys() throws SQLException {
// At the moment just test that no exceptions are thrown KJ
Expand Down

0 comments on commit eefbe02

Please sign in to comment.