-
Notifications
You must be signed in to change notification settings - Fork 96
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
feat(c/driver/postgresql,python): implement error_details spec #946
Conversation
185cd60
to
15bc1e7
Compare
15bc1e7
to
92ed576
Compare
I'm not too happy with how error_details works in C++. As you can see here, it's rather messy/stateful, and it's easy to forget to clear the state. However, it seems hard to do it any other way, unless we break ABI for AdbcError. I thought we could try something like changing /// \brief A detailed error message for an operation.
struct ADBC_EXPORT AdbcError {
/// \brief The error message.
char* message;
/// \brief A vendor-specific error code, if applicable.
int32_t vendor_code;
/// \brief A SQLSTATE error code, if provided, as defined by the
/// SQL:2003 standard. If not set, it should be set to
/// "\0\0\0\0\0".
char sqlstate[5];
/// \brief Release the contained error.
///
/// Unlike other structures, this is an embedded callback to make it
/// easier for the driver manager and driver to cooperate.
void (*release)(struct AdbcError* error);
}; to this: /// \brief A detailed error message for an operation.
struct ADBC_EXPORT AdbcError {
/// \brief The error message.
char* message;
/// \brief Driver-specific state.
void* private_data;
/// \brief A SQLSTATE error code, if provided, as defined by the
/// SQL:2003 standard. If not set, it should be set to
/// "\0\0\0\0\0".
char sqlstate[5];
/// \brief Release the contained error.
///
/// Unlike other structures, this is an embedded callback to make it
/// easier for the driver manager and driver to cooperate.
void (*release)(struct AdbcError* error);
};
const char* AdbcErrorGetDetail(size_t index);
// ... Having a On a 64-bit platform, AdbcError is already 32 bytes, but We could perhaps recycle Or we can continue as-is, and accept the API wart. CC @pitrou @zeroshade @ywc88 for opinions here. |
Oh, and @kou I'm not sure if you've been following this too closely, but if you have ideas here I'd appreciate them! |
How about adding a new member instead of recycling struct ADBC_EXPORT AdbcError {
/// \brief The error message.
char* message;
/// \brief A vendor-specific error code, if applicable.
int32_t vendor_code;
/// \brief A SQLSTATE error code, if provided, as defined by the
/// SQL:2003 standard. If not set, it should be set to
/// "\0\0\0\0\0".
char sqlstate[5];
/// \brief Release the contained error.
///
/// Unlike other structures, this is an embedded callback to make it
/// easier for the driver manager and driver to cooperate.
void (*release)(struct AdbcError* error);
/// \brief Driver-specific state.
void* private_data;
}; We use a special |
Hmm, so the caller would have to initialize the struct with the special vendor code to tell the driver/driver manager the size of the struct - effectively the same strategy we're doing with AdbcDriver. It's a little inconvenient as a C/C++ user (I should really go tackle #598!) but would be consistent with what we are already doing. I don't dislike it :) If there's no objections I'll go sketch out how that looks next week. |
It's a little unfortunate that we have this amount of API baggage already (I do regret making this 1.0.0 instead of 0.1.0...), but I suppose we can let things prove out for a while longer and then roll up a 2.0.0 (maybe once we have async APIs that we're happy with as well?) |
Ah... We may want to provide an initialization macro for convenient but it may not reduce the migration cost so much...: #define ARROW_ADBC_ERROR_INIT {NULL, ADBC_ERROR_VENDOR_CODE_USE_PRIVATE_DATA, "\0\0\0\0\0", NULL}
// struct AdbcError error = {0};
struct AdbcError error = ARROW_ADBC_ERROR_INIT; |
Fixes #939.
Fixes #942.