Skip to content

Invalid DB format exception (for 1.x DB in 2.x h2) should have a specific SQLException vendorCode #3468

@habbit-baggins

Description

@habbit-baggins

Currently the exception reported by the driver when trying to connect to a v1 database is a SQLException with the following properties:

  • Text: General error: "The write format 1 is smaller than the supported format 2 [2.1.210/5]" [50000-210]
  • SQLState: HY000
  • vendorCode: 50000, equal to org.h2.api.ErrorCode.GENERAL_ERROR_1
  • cause: MVStoreException with errorCode: 5, equal to org.h2.mvstore.DataUtils.ERROR_UNSUPPORTED_FORMAT.

Thus, the only way to discern that the reason for the exception is that the file uses an old format is by checking that there is a causing MVStoreException inside the SQLException, casting it and checking its error code. Given that MVStoreException and DataUtils are both outside the main or "api" packages, this method feels like it could fail in the very next version.

Instead, the vendorCode of this particular exception could be a specific value in the "fully public" ErrorCode class. There seems to be a FILE_VERSION_ERROR_1 member already (with value 90048) that could be reused, or if that is unwise because it is supposed to represent something else, a new value could be created.

Note: I only mention MVStore because that's what I use; I don't know if PageStore suffers from the same problem. I see that PageStore was removed from 2.0

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