Message-ID: From: "SophiahHo (@SophiahHo)" To: "pgjdbc/pgjdbc" Date: Thu, 12 Jun 2025 20:16:05 +0000 Subject: [pgjdbc/pgjdbc] issue #3659: NullPointerException in getTables getMetaData: Off-by-one difference between ResultSetMetaData size and getColumnCount() List-Id: X-GitHub-Author-Id: 182134868 X-GitHub-Author-Login: SophiahHo X-GitHub-Issue: 3659 X-GitHub-Repo: pgjdbc/pgjdbc X-GitHub-State: closed X-GitHub-Type: issue X-GitHub-Url: https://github.com/pgjdbc/pgjdbc/issues/3659 Content-Type: text/plain; charset=utf-8 **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