pgjdbc/pgjdbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: SophiahHo (@SophiahHo) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] issue #3465: Metadata CHAR_OCTET_LENGTH is a positive number for non-character column types
Date: Thu, 19 Dec 2024 17:09:56 +0000
Message-ID: <[email protected]> (raw)

**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...-) 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
```


view thread (9+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: github://pgjdbc/pgjdbc
  Cc: [email protected], [email protected]
  Subject: Re: [pgjdbc/pgjdbc] issue #3465: Metadata CHAR_OCTET_LENGTH is a positive number for non-character column types
  In-Reply-To: <<[email protected]>>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox