Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: null pointer exception from PgResultSetMetaData when there's no column metadata #1615

merged 2 commits into from Dec 5, 2019


Copy link

@IvyDev0 IvyDev0 commented Nov 22, 2019

As described in #1613 and a previous PR #663, the driver throws null pointer exception when building the results for queries without column metadata, e.g. SELECT <x> FROM <table name> <x>, where <x> is not a column name but an alias of the table. It should just return the whole table. (There might be other queries that can also reproduce this issue.)

However the above PR only fix one place where field.getMetadata() is null. There are four more places might cause the NPE.
In this minor fix, we return "" as the columnName, schemaName, tableName if the metadata is null, and ResultSetMetaData.columnNullable for nullable.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  1. Does your submission pass tests?
  2. Does mvn checkstyle:check pass ?
  3. Have you added your new test classes to an existing test suite in alphabetical order?

Changes to Existing Features:

  • Does this break existing behaviour? If so please explain.
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

Copy link

@AppVeyorBot AppVeyorBot commented Nov 22, 2019

Copy link

@davecramer davecramer commented Nov 22, 2019


@davecramer davecramer closed this Nov 22, 2019
Copy link

@davecramer davecramer commented Dec 5, 2019

Now I'm wondering why I closed it ?

@davecramer davecramer reopened this Dec 5, 2019
@davecramer davecramer merged commit 08bd46b into pgjdbc:master Dec 5, 2019
1 check was pending
davecramer pushed a commit to davecramer/pgjdbc that referenced this issue Jul 5, 2021
…column metadata (pgjdbc#1615)

* fix all possible NPE in PgResultSetMetaData when there's column metadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

Successfully merging this pull request may close these issues.

None yet

4 participants