Message-ID: From: "tomdcc (@tomdcc)" To: "pgjdbc/pgjdbc" Date: Tue, 19 Jan 2021 04:16:01 +0000 Subject: [pgjdbc/pgjdbc] issue #2027: PgDatabaseMetaData.getTables returns null table type for partitioned indexes List-Id: X-GitHub-Author-Id: 432578 X-GitHub-Author-Login: tomdcc X-GitHub-Issue: 2027 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: closed X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/2027 Content-Type: text/plain; charset=utf-8 **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.