Subject: [pgjdbc/pgjdbc] issue #2027: PgDatabaseMetaData.getTables returns null table type for partitioned indexes

From: "tomdcc (@tomdcc)" <[email-masked]>
Date: Tue, 19 Jan 2021 04:16:01 +0000

**Describe the issue**
`PgDatabaseMetaData.getTables()` returns a `TABLE_TYPE` of [`PARTITIONED TABLE`](https://github.com/pgjdbc/pgjdbc/blob/375cb37/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java#L1301) for partitioned tables, but there are a couple of other [possible values for `relkind`](https://github.com/postgres/postgres/blob/master/src/include/catalog/pg_class.h#L164-L173) that we don't currently support.

The one that I just bumped into is `I` for partitioned indexes. I propose that we return `PARTITIONED INDEX` for this case to be consistent with the behaviour for partitioned tables.

The other is `t` for some toast related tables. AFAICS in my db these only exist in the `toast` schema. This implies that we need another case [here](https://github.com/pgjdbc/pgjdbc/blob/375cb37/pgjdbc/src/main/java/org/postgresql/jdbc/PgDatabaseMetaData.java#L1286-L1287) that also returns `SYSTEM TOAST TABLE`. 

**Driver Version?** 
Currently using 42.2.18, but the code on master doesn't handle these.

**Java Version?**
11

**OS Version?**
N/A

**PostgreSQL Version?**
12

**To Reproduce**
Call `connection.getMetadata().getTables()` with some parameters that will match a partitioned index. Observe the null result in column `4` / `TABLE_TYPE`. I haven't tested it with toast tables, but have confirmed that tables with that `relkind` are in my db and that we don't currently handle that.

**Expected behaviour**
We return `PARTITIONED INDEX` AND `SYSTEM TOAST TABLE` for the two cases respectively.

---

From: "davecramer (@davecramer)" <[email-masked]>
Date: Tue, 19 Jan 2021 10:38:15 +0000

Seems like something worth doing.

---

From: "raminorujov (@raminorujov)" <[email-masked]>
Date: Tue, 15 Jul 2025 10:04:07 +0000

It is fixed already, can be closed.