Skip to content

Commit 5ff1421

Browse files
committed
[CONJ-1108] Database metadata listing TEMPORARY tables/sequences - ensure null handling
1 parent 52ab8d3 commit 5ff1421

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/main/java/org/mariadb/jdbc/DatabaseMetaData.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,12 +738,11 @@ public ResultSet getTables(
738738
StringBuilder sqlType =
739739
new StringBuilder(((firstCondition) ? " WHERE " : " AND ") + " TABLE_TYPE IN (");
740740
for (String s : types) {
741-
if (mustAddType) sqlType.append(",");
742-
mustAddType = true;
743741
if (s == null) {
744-
mustAddType = false;
745742
continue;
746743
}
744+
if (mustAddType) sqlType.append(",");
745+
mustAddType = true;
747746
switch (s) {
748747
case "TABLE":
749748
sqlType.append("'BASE TABLE','SYSTEM VERSIONED'");

src/test/java/org/mariadb/jdbc/integration/DatabaseMetadataTest.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2749,7 +2749,6 @@ public void testTemporaryTables() throws SQLException {
27492749
assertEquals("LOCAL TEMPORARY", rs.getString("TABLE_TYPE"));
27502750
assertFalse(rs.next());
27512751

2752-
27532752
rs = dbmd.getTables(null, null, "testTemporary%", new String[]{"TEMPORARY"});
27542753
assertTrue(rs.next());
27552754
assertEquals("testtemporarytables",rs.getString("TABLE_NAME").toLowerCase());
@@ -2758,6 +2757,18 @@ public void testTemporaryTables() throws SQLException {
27582757

27592758
rs = dbmd.getTables(null, null, "testTemporary%", new String[]{"TABLE"});
27602759
assertFalse(rs.next());
2760+
2761+
rs = dbmd.getTables(null, null, "testTemporary%", new String[]{"TEMPORARY", "TABLE"});
2762+
assertTrue(rs.next());
2763+
assertEquals("testtemporarytables",rs.getString("TABLE_NAME").toLowerCase());
2764+
assertEquals("LOCAL TEMPORARY", rs.getString("TABLE_TYPE"));
2765+
assertFalse(rs.next());
2766+
2767+
rs = dbmd.getTables(null, null, "testTemporary%", new String[]{"TEMPORARY", null, "TABLE"});
2768+
assertTrue(rs.next());
2769+
assertEquals("testtemporarytables",rs.getString("TABLE_NAME").toLowerCase());
2770+
assertEquals("LOCAL TEMPORARY", rs.getString("TABLE_TYPE"));
2771+
assertFalse(rs.next());
27612772
}
27622773

27632774
}

0 commit comments

Comments
 (0)