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 #3659: NullPointerException in getTables getMetaData: Off-by-one difference between ResultSetMetaData size and getColumnCount()
Date: Thu, 12 Jun 2025 20:16:05 +0000
Message-ID: <[email protected]> (raw)

**Describe the issue**
NullPointerException due to off-by-one difference between ResultSetMetaData size and getColumnCount() in getTables' getMetaData.

**Driver Version?** 
42.7.7

**Java Version?**
17

**To Reproduce**
Steps to reproduce the behaviour:

```java
        ResultSet rs = connection.getMetaData().getTables(
                "WrongCatalog", // catalog
                null, // schemaPattern
                null, // tableNamePattern
                null // types
        );
        ResultSetMetaData rsmd = rs.getMetaData();
        for (int col = 1; col <= rsmd.getColumnCount(); col++){
            System.out.println(col + ". " + rsmd.getColumnLabel(col));
        }
```

Result:
```
java.lang.NullPointerException: Cannot invoke "org.postgresql.core.Field.getColumnLabel()" because "field" is null
```

**Expected behaviour**
No exception


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 #3659: NullPointerException in getTables getMetaData: Off-by-one difference between ResultSetMetaData size and getColumnCount()
  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