Skip to content

[BUG] JSQLParser 5.3 : PostgreSQL : COMMENT ON ... IS NULL (comment removal) fails to parse #2562

Description

@sundongkim-dev

Failing SQL Feature:

COMMENT ON <object> IS NULL cannot be parsed. In PostgreSQL, writing NULL in place of the text string is the way to remove a comment — per the COMMENT docs: "To remove a comment, write NULL in place of the text string." So a DDL stream that drops comments cannot be processed.

SQL Example:

COMMENT ON TABLE app.t IS NULL

fails on 5.3 and on current master (6c726d8) with:

net.sf.jsqlparser.parser.ParseException: Encountered: <K_NULL> / "NULL", at line 1, column 27, in lexical state DEFAULT.
Was expecting this terminal within expansion starting at 15161:20:
    <S_CHAR_LITERAL> ...

COMMENT ON COLUMN app.t.name IS NULL and COMMENT ON VIEW app.v IS NULL fail the same way. All string-literal forms parse fine, including the empty string (IS 'hello', IS '').

Software Information:

  • JSqlParser 5.3 (current Maven Central release); reproduced on master 6c726d8
  • PostgreSQL 18 (verified: COMMENT ON TABLE t IS NULL removes the comment, i.e. deletes the pg_description row; IS '' behaves the same)

I'll follow up with a PR (grammar + round-trip tests).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions