Message-ID: From: "SophiahHo (@SophiahHo)" To: "pgjdbc/pgjdbc" Date: Thu, 19 Dec 2024 17:09:56 +0000 Subject: [pgjdbc/pgjdbc] issue #3465: Metadata CHAR_OCTET_LENGTH is a positive number for non-character column types List-Id: X-GitHub-Assignees: tirthgajera X-GitHub-Author-Id: 182134868 X-GitHub-Author-Login: SophiahHo X-GitHub-Issue: 3465 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: open X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3465 Content-Type: text/plain; charset=utf-8 **Describe the issue** The method getColumns in pgjdbc's implementation of DatabaseMetaData returns `10` for CHAR_OCTET_LENGTH for column type `integer[]`. The JDBC spec [getColumns](https://docs.oracle.com/javase/8/docs/api/java/sql/DatabaseMetaData.html#getColumns-java.lang.String-java.lang.String-java.lang.String-java.lang.String-) says: > CHAR_OCTET_LENGTH int => for char types the maximum number of bytes in the column For non-character types, the returned value should be null. **Driver Version?** 42.7.4 **Java Version?** 17 **PostgreSQL Version?** 13.13 **To Reproduce** Create a table with an `integer[]` column type in your postgres DB's "public" schema: ```sql create table myintegerarray (myintarray integer[]); ``` Java: ```java String tablePattern = "myintegerarray"; ResultSet rs = connection.getMetaData().getColumns(null, "public", tablePattern, null); rs.next(); System.out.println(rs.getString(16)); // CHAR_OCTET_LENGTH ``` Output: ``` 10 ``` **Expected behaviour** Output: ``` null ```