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

Use extended error codes #119

Merged
merged 1 commit into from
Jul 1, 2016

Conversation

reftel
Copy link
Contributor

@reftel reftel commented Jun 13, 2016

Enable extended error code reporting in sqlite, and new error enum values in SQLiteErrorCode.java. The extended error code is held in a new member of SQLiteErrorCode, so that the code member retains its old behaviour, so that existing clients which depend on that are not affected. The message returned by toString does however change for errors for which there now are more detailed descriptions.

@reftel
Copy link
Contributor Author

reftel commented Jun 13, 2016

It looks like the TravisCI builds do not recompile NativeDB.c. Is that correct? If so, how can I get the PR builds passing?

@reftel
Copy link
Contributor Author

reftel commented Jun 13, 2016

The TravisCI build fix in PR #120 should make this one pass.

@gitblit
Copy link
Collaborator

gitblit commented Jun 22, 2016

Looks like you'll need to rebase this PR on master in order for Travis to be happy.


public final int code;
public final int extended;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why we need to maintain both code and extended?

Copy link
Contributor Author

@reftel reftel Jun 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an incomplete attempt at maintaining backwards compatibility. I'll rework it, hopefully by Monday.

Just to make sure: we still want user code doing SQLiteErrorCode.getErrorCode(ex.getErrorCode()) on an exception caused by an extended code like SQLITE_BUSY_RECOVERY get the non-extended instance (in this caseSQLITE_BUSY) by default, right? Otherwise code that does that and compares the result with an instance of SQLiteErrorCode to determine how to handle the exception would suddenly fail, so we should have some kind of setting for getting the extended code instances instaed, correct?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. My understanding was incomplete. I think your solution is probably fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have an updated version that adds an internal pragma for enabling/disabling use of extended result codes as SQLException vendor codes (but still uses the extended result code to build the message text for the exception).
Would you like it as a force-push that replaces the commit in this PR, or as a new commit on top of this broken one?

@reftel reftel force-pushed the feature/extended_error_codes branch from 8aad3be to 5219094 Compare June 23, 2016 05:32
@gitblit gitblit added this to the 3.13.0 milestone Jun 23, 2016
@reftel reftel force-pushed the feature/extended_error_codes branch from 5219094 to 6afed0a Compare June 27, 2016 20:56
@gitblit
Copy link
Collaborator

gitblit commented Jun 29, 2016

Go ahead and force-push to this PR so we can keep the conversation together.

I'm not sure it needs to be as complicated as you've implemented with a new PRAGMA. Seems like we could always set the extended result code and have accessor methods to return the basic result code and extended result code. Or have I missed something important?

@reftel
Copy link
Contributor Author

reftel commented Jun 29, 2016

We could, but changing what we use as vendor code could be seen as a breaking API change. If that's fine, then it's a lot simpler: just use extended result codes all the time. If not, then using extended result codes instead of legacy error codes as the vendor code must be opt-in.

So: does sqlite-jdbc guarantee stability of vendor codes of SQLExceptions?

@gitblit
Copy link
Collaborator

gitblit commented Jun 29, 2016

does sqlite-jdbc guarantee stability of vendor codes of SQLExceptions?

I don't see that sqlite-jdbc has specified any stability guarantees, but that doesn't mean it shouldn't. (Fixing #110 could be painful, though.)

What if we implemented a SQLiteException subclass of SQLException which returned the standard result code for getErrorCode and offered a getExtendedCode accessor for the more granular error? Maybe this subclass should have the SQLiteErrorCode instance?

Or maybe the answer is using proper SQLState codes (#77) in conjunction with the extended result codes?

@reftel reftel force-pushed the feature/extended_error_codes branch from 6afed0a to 7509994 Compare June 29, 2016 19:20
@reftel
Copy link
Contributor Author

reftel commented Jun 29, 2016

Something like this then?

I believe SQLState is a different thing. We should provide the exact sqlite result code to applications that are OK with database-specific code for figuring out exactly what went wrong. We should probably also provide SQLState codes for applications that are OK with general descriptions of what happened as long as they don't have to add database-specific code.

@gitblit
Copy link
Collaborator

gitblit commented Jun 30, 2016

Yes, that looks good to me. @xerial Do you have an opinion?

@gitblit gitblit merged commit ba561b8 into xerial:master Jul 1, 2016
@gitblit
Copy link
Collaborator

gitblit commented Jul 1, 2016

Nice. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants