diff --git a/c/driver_manager/adbc_driver_manager.cc b/c/driver_manager/adbc_driver_manager.cc index 85110c6424..78836d5684 100644 --- a/c/driver_manager/adbc_driver_manager.cc +++ b/c/driver_manager/adbc_driver_manager.cc @@ -71,7 +71,14 @@ void ReleaseError(struct AdbcError* error) { } void SetError(struct AdbcError* error, const std::string& message) { + static const std::string kPrefix = "[Driver Manager] "; + if (!error) return; + if (error->release && error->release != ReleaseError) { + error->release(error); + error->release = nullptr; + } + if (error->message) { // Append std::string buffer = error->message; @@ -84,9 +91,11 @@ void SetError(struct AdbcError* error, const std::string& message) { buffer.copy(error->message, buffer.size()); error->message[buffer.size()] = '\0'; } else { - error->message = new char[message.size() + 1]; - message.copy(error->message, message.size()); - error->message[message.size()] = '\0'; + // Prepend a string to identify driver manager errors + error->message = new char[kPrefix.size() + message.size() + 1]; + kPrefix.copy(error->message, kPrefix.size()); + message.copy(error->message + kPrefix.size(), message.size()); + error->message[kPrefix.size() + message.size()] = '\0'; } error->release = ReleaseError; } @@ -314,108 +323,129 @@ void ErrorArrayStreamInit(struct ArrowArrayStream* out, AdbcStatusCode DatabaseGetOption(struct AdbcDatabase* database, const char* key, char* value, size_t* length, struct AdbcError* error) { + SetError(error, "AdbcDatabaseGetOption not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode DatabaseGetOptionBytes(struct AdbcDatabase* database, const char* key, uint8_t* value, size_t* length, struct AdbcError* error) { + SetError(error, "AdbcDatabaseGetOptionBytes not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode DatabaseGetOptionInt(struct AdbcDatabase* database, const char* key, int64_t* value, struct AdbcError* error) { + SetError(error, "AdbcDatabaseGetOptionInt not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode DatabaseGetOptionDouble(struct AdbcDatabase* database, const char* key, double* value, struct AdbcError* error) { + SetError(error, "AdbcDatabaseGetOptionDouble not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode DatabaseSetOption(struct AdbcDatabase* database, const char* key, const char* value, struct AdbcError* error) { + SetError(error, "AdbcDatabaseSetOption not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode DatabaseSetOptionBytes(struct AdbcDatabase* database, const char* key, const uint8_t* value, size_t length, struct AdbcError* error) { + SetError(error, "AdbcDatabaseSetOptionBytes not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode DatabaseSetOptionInt(struct AdbcDatabase* database, const char* key, int64_t value, struct AdbcError* error) { + SetError(error, "AdbcDatabaseSetOptionInt not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode DatabaseSetOptionDouble(struct AdbcDatabase* database, const char* key, double value, struct AdbcError* error) { + SetError(error, "AdbcDatabaseSetOptionDouble not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionCancel(struct AdbcConnection* connection, struct AdbcError* error) { + SetError(error, "AdbcConnectionCancel not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionCommit(struct AdbcConnection*, struct AdbcError* error) { + SetError(error, "AdbcConnectionCommit not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionGetInfo(struct AdbcConnection* connection, const uint32_t* info_codes, size_t info_codes_length, struct ArrowArrayStream* out, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetInfo not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionGetObjects(struct AdbcConnection*, int, const char*, const char*, const char*, const char**, const char*, struct ArrowArrayStream*, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetObjects not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionGetOption(struct AdbcConnection* connection, const char* key, char* value, size_t* length, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetOption not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode ConnectionGetOptionBytes(struct AdbcConnection* connection, const char* key, uint8_t* value, size_t* length, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetOptionBytes not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode ConnectionGetOptionInt(struct AdbcConnection* connection, const char* key, int64_t* value, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetOptionInt not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode ConnectionGetOptionDouble(struct AdbcConnection* connection, const char* key, double* value, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetOptionDouble not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode ConnectionGetStatistics(struct AdbcConnection*, const char*, const char*, const char*, char, struct ArrowArrayStream*, - struct AdbcError*) { + struct AdbcError* error) { + SetError(error, "AdbcConnectionGetStatistics not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionGetStatisticNames(struct AdbcConnection*, - struct ArrowArrayStream*, struct AdbcError*) { + struct ArrowArrayStream*, + struct AdbcError* error) { + SetError(error, "AdbcConnectionGetStatisticNames not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionGetTableSchema(struct AdbcConnection*, const char*, const char*, const char*, struct ArrowSchema*, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetTableSchema not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionGetTableTypes(struct AdbcConnection*, struct ArrowArrayStream*, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetTableTypes not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } @@ -424,45 +454,54 @@ AdbcStatusCode ConnectionReadPartition(struct AdbcConnection* connection, size_t serialized_length, struct ArrowArrayStream* out, struct AdbcError* error) { + SetError(error, "AdbcConnectionReadPartition not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionRollback(struct AdbcConnection*, struct AdbcError* error) { + SetError(error, "AdbcConnectionRollback not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionSetOption(struct AdbcConnection*, const char*, const char*, struct AdbcError* error) { + SetError(error, "AdbcConnectionSetOption not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionSetOptionBytes(struct AdbcConnection*, const char*, const uint8_t*, size_t, struct AdbcError* error) { + SetError(error, "AdbcConnectionSetOptionBytes not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionSetOptionInt(struct AdbcConnection* connection, const char* key, int64_t value, struct AdbcError* error) { + SetError(error, "AdbcConnectionSetOptionInt not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionSetOptionDouble(struct AdbcConnection* connection, const char* key, double value, struct AdbcError* error) { + SetError(error, "AdbcConnectionSetOptionDouble not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementBind(struct AdbcStatement*, struct ArrowArray*, struct ArrowSchema*, struct AdbcError* error) { + SetError(error, "AdbcStatementBind not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementBindStream(struct AdbcStatement*, struct ArrowArrayStream*, struct AdbcError* error) { + SetError(error, "AdbcStatementBindStream not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementCancel(struct AdbcStatement* statement, struct AdbcError* error) { + SetError(error, "AdbcStatementCancel not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } @@ -471,73 +510,87 @@ AdbcStatusCode StatementExecutePartitions(struct AdbcStatement* statement, struct AdbcPartitions* partitions, int64_t* rows_affected, struct AdbcError* error) { + SetError(error, "AdbcStatementExecutePartitions not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementExecuteSchema(struct AdbcStatement* statement, struct ArrowSchema* schema, struct AdbcError* error) { + SetError(error, "AdbcStatementExecuteSchema not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementGetOption(struct AdbcStatement* statement, const char* key, char* value, size_t* length, struct AdbcError* error) { + SetError(error, "AdbcStatementGetOption not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode StatementGetOptionBytes(struct AdbcStatement* statement, const char* key, uint8_t* value, size_t* length, struct AdbcError* error) { + SetError(error, "AdbcStatementGetOptionBytes not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode StatementGetOptionInt(struct AdbcStatement* statement, const char* key, int64_t* value, struct AdbcError* error) { + SetError(error, "AdbcStatementGetOptionInt not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode StatementGetOptionDouble(struct AdbcStatement* statement, const char* key, double* value, struct AdbcError* error) { + SetError(error, "AdbcStatementGetOptionDouble not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode StatementGetParameterSchema(struct AdbcStatement* statement, struct ArrowSchema* schema, struct AdbcError* error) { + SetError(error, "AdbcStatementGetParameterSchema not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementPrepare(struct AdbcStatement*, struct AdbcError* error) { + SetError(error, "AdbcStatementPrepare not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementSetOption(struct AdbcStatement*, const char*, const char*, struct AdbcError* error) { + SetError(error, "AdbcStatementSetOption not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementSetOptionBytes(struct AdbcStatement*, const char*, const uint8_t*, size_t, struct AdbcError* error) { + SetError(error, "AdbcStatementSetOptionBytes not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementSetOptionInt(struct AdbcStatement* statement, const char* key, int64_t value, struct AdbcError* error) { + SetError(error, "AdbcStatementSetOptionInt not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementSetOptionDouble(struct AdbcStatement* statement, const char* key, double value, struct AdbcError* error) { + SetError(error, "AdbcStatementSetOptionDouble not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementSetSqlQuery(struct AdbcStatement*, const char*, struct AdbcError* error) { + SetError(error, "AdbcStatementSetSqlQuery not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementSetSubstraitPlan(struct AdbcStatement*, const uint8_t*, size_t, struct AdbcError* error) { + SetError(error, "AdbcStatementSetSubstraitPlan not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } @@ -696,6 +749,7 @@ AdbcStatusCode AdbcDatabaseGetOption(struct AdbcDatabase* database, const char* } else { const auto it = args->options.find(key); if (it == args->options.end()) { + SetError(error, "Option not found"); return ADBC_STATUS_NOT_FOUND; } result = &it->second; @@ -720,6 +774,7 @@ AdbcStatusCode AdbcDatabaseGetOptionBytes(struct AdbcDatabase* database, const c const auto* args = reinterpret_cast(database->private_data); const auto it = args->bytes_options.find(key); if (it == args->options.end()) { + SetError(error, "Option not found"); return ADBC_STATUS_NOT_FOUND; } const std::string& result = it->second; @@ -741,6 +796,7 @@ AdbcStatusCode AdbcDatabaseGetOptionInt(struct AdbcDatabase* database, const cha const auto* args = reinterpret_cast(database->private_data); const auto it = args->int_options.find(key); if (it == args->int_options.end()) { + SetError(error, "Option not found"); return ADBC_STATUS_NOT_FOUND; } *value = it->second; @@ -756,6 +812,7 @@ AdbcStatusCode AdbcDatabaseGetOptionDouble(struct AdbcDatabase* database, const const auto* args = reinterpret_cast(database->private_data); const auto it = args->double_options.find(key); if (it == args->double_options.end()) { + SetError(error, "Option not found"); return ADBC_STATUS_NOT_FOUND; } *value = it->second; @@ -822,6 +879,7 @@ AdbcStatusCode AdbcDriverManagerDatabaseSetInitFunc(struct AdbcDatabase* databas AdbcDriverInitFunc init_func, struct AdbcError* error) { if (database->private_driver) { + SetError(error, "Cannot SetInitFunc after AdbcDatabaseInit"); return ADBC_STATUS_INVALID_STATE; } @@ -832,7 +890,7 @@ AdbcStatusCode AdbcDriverManagerDatabaseSetInitFunc(struct AdbcDatabase* databas AdbcStatusCode AdbcDatabaseInit(struct AdbcDatabase* database, struct AdbcError* error) { if (!database->private_data) { - SetError(error, "Must call AdbcDatabaseNew first"); + SetError(error, "Must call AdbcDatabaseNew before AdbcDatabaseInit"); return ADBC_STATUS_INVALID_STATE; } TempDatabase* args = reinterpret_cast(database->private_data); @@ -948,6 +1006,7 @@ AdbcStatusCode AdbcDatabaseRelease(struct AdbcDatabase* database, AdbcStatusCode AdbcConnectionCancel(struct AdbcConnection* connection, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionCancel: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -957,6 +1016,7 @@ AdbcStatusCode AdbcConnectionCancel(struct AdbcConnection* connection, AdbcStatusCode AdbcConnectionCommit(struct AdbcConnection* connection, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionCommit: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -968,6 +1028,7 @@ AdbcStatusCode AdbcConnectionGetInfo(struct AdbcConnection* connection, struct ArrowArrayStream* out, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionGetInfo: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -983,6 +1044,7 @@ AdbcStatusCode AdbcConnectionGetObjects(struct AdbcConnection* connection, int d struct ArrowArrayStream* stream, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionGetObjects: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1092,6 +1154,7 @@ AdbcStatusCode AdbcConnectionGetStatistics(struct AdbcConnection* connection, struct ArrowArrayStream* out, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionGetStatistics: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1105,6 +1168,7 @@ AdbcStatusCode AdbcConnectionGetStatisticNames(struct AdbcConnection* connection struct ArrowArrayStream* out, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionGetStatisticNames: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1119,6 +1183,7 @@ AdbcStatusCode AdbcConnectionGetTableSchema(struct AdbcConnection* connection, struct ArrowSchema* schema, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionGetTableSchema: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1130,6 +1195,7 @@ AdbcStatusCode AdbcConnectionGetTableTypes(struct AdbcConnection* connection, struct ArrowArrayStream* stream, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionGetTableTypes: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1204,6 +1270,7 @@ AdbcStatusCode AdbcConnectionReadPartition(struct AdbcConnection* connection, struct ArrowArrayStream* out, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionReadPartition: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1232,6 +1299,7 @@ AdbcStatusCode AdbcConnectionRelease(struct AdbcConnection* connection, AdbcStatusCode AdbcConnectionRollback(struct AdbcConnection* connection, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionRollback: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1312,6 +1380,7 @@ AdbcStatusCode AdbcStatementBind(struct AdbcStatement* statement, struct ArrowArray* values, struct ArrowSchema* schema, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementBind: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1322,6 +1391,7 @@ AdbcStatusCode AdbcStatementBindStream(struct AdbcStatement* statement, struct ArrowArrayStream* stream, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementBindStream: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1331,6 +1401,7 @@ AdbcStatusCode AdbcStatementBindStream(struct AdbcStatement* statement, AdbcStatusCode AdbcStatementCancel(struct AdbcStatement* statement, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementCancel: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1344,6 +1415,7 @@ AdbcStatusCode AdbcStatementExecutePartitions(struct AdbcStatement* statement, int64_t* rows_affected, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementExecutePartitions: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1356,6 +1428,7 @@ AdbcStatusCode AdbcStatementExecuteQuery(struct AdbcStatement* statement, int64_t* rows_affected, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementExecuteQuery: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1368,6 +1441,7 @@ AdbcStatusCode AdbcStatementExecuteSchema(struct AdbcStatement* statement, struct ArrowSchema* schema, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementExecuteSchema: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1378,6 +1452,7 @@ AdbcStatusCode AdbcStatementGetOption(struct AdbcStatement* statement, const cha char* value, size_t* length, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementGetOption: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1389,6 +1464,7 @@ AdbcStatusCode AdbcStatementGetOptionBytes(struct AdbcStatement* statement, const char* key, uint8_t* value, size_t* length, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementGetOptionBytes: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1399,6 +1475,7 @@ AdbcStatusCode AdbcStatementGetOptionBytes(struct AdbcStatement* statement, AdbcStatusCode AdbcStatementGetOptionInt(struct AdbcStatement* statement, const char* key, int64_t* value, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementGetOptionInt: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1409,6 +1486,7 @@ AdbcStatusCode AdbcStatementGetOptionDouble(struct AdbcStatement* statement, const char* key, double* value, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementGetOptionDouble: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1420,6 +1498,7 @@ AdbcStatusCode AdbcStatementGetParameterSchema(struct AdbcStatement* statement, struct ArrowSchema* schema, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementGetParameterSchema: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1430,6 +1509,7 @@ AdbcStatusCode AdbcStatementNew(struct AdbcConnection* connection, struct AdbcStatement* statement, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcStatementNew: must AdbcConnectionInit first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1441,6 +1521,7 @@ AdbcStatusCode AdbcStatementNew(struct AdbcConnection* connection, AdbcStatusCode AdbcStatementPrepare(struct AdbcStatement* statement, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementPrepare: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1450,6 +1531,7 @@ AdbcStatusCode AdbcStatementPrepare(struct AdbcStatement* statement, AdbcStatusCode AdbcStatementRelease(struct AdbcStatement* statement, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementRelease: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1461,6 +1543,7 @@ AdbcStatusCode AdbcStatementRelease(struct AdbcStatement* statement, AdbcStatusCode AdbcStatementSetOption(struct AdbcStatement* statement, const char* key, const char* value, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementSetOption: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1471,6 +1554,7 @@ AdbcStatusCode AdbcStatementSetOptionBytes(struct AdbcStatement* statement, const char* key, const uint8_t* value, size_t length, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementSetOptionBytes: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1481,6 +1565,7 @@ AdbcStatusCode AdbcStatementSetOptionBytes(struct AdbcStatement* statement, AdbcStatusCode AdbcStatementSetOptionInt(struct AdbcStatement* statement, const char* key, int64_t value, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementSetOptionInt: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1491,6 +1576,7 @@ AdbcStatusCode AdbcStatementSetOptionDouble(struct AdbcStatement* statement, const char* key, double value, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementSetOptionDouble: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1501,6 +1587,7 @@ AdbcStatusCode AdbcStatementSetOptionDouble(struct AdbcStatement* statement, AdbcStatusCode AdbcStatementSetSqlQuery(struct AdbcStatement* statement, const char* query, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementSetSqlQuery: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1511,6 +1598,7 @@ AdbcStatusCode AdbcStatementSetSubstraitPlan(struct AdbcStatement* statement, const uint8_t* plan, size_t length, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementSetSubstraitPlan: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); diff --git a/go/adbc/drivermgr/adbc_driver_manager.cc b/go/adbc/drivermgr/adbc_driver_manager.cc index 85110c6424..78836d5684 100644 --- a/go/adbc/drivermgr/adbc_driver_manager.cc +++ b/go/adbc/drivermgr/adbc_driver_manager.cc @@ -71,7 +71,14 @@ void ReleaseError(struct AdbcError* error) { } void SetError(struct AdbcError* error, const std::string& message) { + static const std::string kPrefix = "[Driver Manager] "; + if (!error) return; + if (error->release && error->release != ReleaseError) { + error->release(error); + error->release = nullptr; + } + if (error->message) { // Append std::string buffer = error->message; @@ -84,9 +91,11 @@ void SetError(struct AdbcError* error, const std::string& message) { buffer.copy(error->message, buffer.size()); error->message[buffer.size()] = '\0'; } else { - error->message = new char[message.size() + 1]; - message.copy(error->message, message.size()); - error->message[message.size()] = '\0'; + // Prepend a string to identify driver manager errors + error->message = new char[kPrefix.size() + message.size() + 1]; + kPrefix.copy(error->message, kPrefix.size()); + message.copy(error->message + kPrefix.size(), message.size()); + error->message[kPrefix.size() + message.size()] = '\0'; } error->release = ReleaseError; } @@ -314,108 +323,129 @@ void ErrorArrayStreamInit(struct ArrowArrayStream* out, AdbcStatusCode DatabaseGetOption(struct AdbcDatabase* database, const char* key, char* value, size_t* length, struct AdbcError* error) { + SetError(error, "AdbcDatabaseGetOption not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode DatabaseGetOptionBytes(struct AdbcDatabase* database, const char* key, uint8_t* value, size_t* length, struct AdbcError* error) { + SetError(error, "AdbcDatabaseGetOptionBytes not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode DatabaseGetOptionInt(struct AdbcDatabase* database, const char* key, int64_t* value, struct AdbcError* error) { + SetError(error, "AdbcDatabaseGetOptionInt not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode DatabaseGetOptionDouble(struct AdbcDatabase* database, const char* key, double* value, struct AdbcError* error) { + SetError(error, "AdbcDatabaseGetOptionDouble not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode DatabaseSetOption(struct AdbcDatabase* database, const char* key, const char* value, struct AdbcError* error) { + SetError(error, "AdbcDatabaseSetOption not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode DatabaseSetOptionBytes(struct AdbcDatabase* database, const char* key, const uint8_t* value, size_t length, struct AdbcError* error) { + SetError(error, "AdbcDatabaseSetOptionBytes not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode DatabaseSetOptionInt(struct AdbcDatabase* database, const char* key, int64_t value, struct AdbcError* error) { + SetError(error, "AdbcDatabaseSetOptionInt not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode DatabaseSetOptionDouble(struct AdbcDatabase* database, const char* key, double value, struct AdbcError* error) { + SetError(error, "AdbcDatabaseSetOptionDouble not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionCancel(struct AdbcConnection* connection, struct AdbcError* error) { + SetError(error, "AdbcConnectionCancel not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionCommit(struct AdbcConnection*, struct AdbcError* error) { + SetError(error, "AdbcConnectionCommit not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionGetInfo(struct AdbcConnection* connection, const uint32_t* info_codes, size_t info_codes_length, struct ArrowArrayStream* out, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetInfo not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionGetObjects(struct AdbcConnection*, int, const char*, const char*, const char*, const char**, const char*, struct ArrowArrayStream*, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetObjects not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionGetOption(struct AdbcConnection* connection, const char* key, char* value, size_t* length, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetOption not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode ConnectionGetOptionBytes(struct AdbcConnection* connection, const char* key, uint8_t* value, size_t* length, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetOptionBytes not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode ConnectionGetOptionInt(struct AdbcConnection* connection, const char* key, int64_t* value, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetOptionInt not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode ConnectionGetOptionDouble(struct AdbcConnection* connection, const char* key, double* value, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetOptionDouble not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode ConnectionGetStatistics(struct AdbcConnection*, const char*, const char*, const char*, char, struct ArrowArrayStream*, - struct AdbcError*) { + struct AdbcError* error) { + SetError(error, "AdbcConnectionGetStatistics not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionGetStatisticNames(struct AdbcConnection*, - struct ArrowArrayStream*, struct AdbcError*) { + struct ArrowArrayStream*, + struct AdbcError* error) { + SetError(error, "AdbcConnectionGetStatisticNames not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionGetTableSchema(struct AdbcConnection*, const char*, const char*, const char*, struct ArrowSchema*, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetTableSchema not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionGetTableTypes(struct AdbcConnection*, struct ArrowArrayStream*, struct AdbcError* error) { + SetError(error, "AdbcConnectionGetTableTypes not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } @@ -424,45 +454,54 @@ AdbcStatusCode ConnectionReadPartition(struct AdbcConnection* connection, size_t serialized_length, struct ArrowArrayStream* out, struct AdbcError* error) { + SetError(error, "AdbcConnectionReadPartition not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionRollback(struct AdbcConnection*, struct AdbcError* error) { + SetError(error, "AdbcConnectionRollback not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionSetOption(struct AdbcConnection*, const char*, const char*, struct AdbcError* error) { + SetError(error, "AdbcConnectionSetOption not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionSetOptionBytes(struct AdbcConnection*, const char*, const uint8_t*, size_t, struct AdbcError* error) { + SetError(error, "AdbcConnectionSetOptionBytes not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionSetOptionInt(struct AdbcConnection* connection, const char* key, int64_t value, struct AdbcError* error) { + SetError(error, "AdbcConnectionSetOptionInt not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode ConnectionSetOptionDouble(struct AdbcConnection* connection, const char* key, double value, struct AdbcError* error) { + SetError(error, "AdbcConnectionSetOptionDouble not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementBind(struct AdbcStatement*, struct ArrowArray*, struct ArrowSchema*, struct AdbcError* error) { + SetError(error, "AdbcStatementBind not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementBindStream(struct AdbcStatement*, struct ArrowArrayStream*, struct AdbcError* error) { + SetError(error, "AdbcStatementBindStream not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementCancel(struct AdbcStatement* statement, struct AdbcError* error) { + SetError(error, "AdbcStatementCancel not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } @@ -471,73 +510,87 @@ AdbcStatusCode StatementExecutePartitions(struct AdbcStatement* statement, struct AdbcPartitions* partitions, int64_t* rows_affected, struct AdbcError* error) { + SetError(error, "AdbcStatementExecutePartitions not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementExecuteSchema(struct AdbcStatement* statement, struct ArrowSchema* schema, struct AdbcError* error) { + SetError(error, "AdbcStatementExecuteSchema not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementGetOption(struct AdbcStatement* statement, const char* key, char* value, size_t* length, struct AdbcError* error) { + SetError(error, "AdbcStatementGetOption not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode StatementGetOptionBytes(struct AdbcStatement* statement, const char* key, uint8_t* value, size_t* length, struct AdbcError* error) { + SetError(error, "AdbcStatementGetOptionBytes not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode StatementGetOptionInt(struct AdbcStatement* statement, const char* key, int64_t* value, struct AdbcError* error) { + SetError(error, "AdbcStatementGetOptionInt not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode StatementGetOptionDouble(struct AdbcStatement* statement, const char* key, double* value, struct AdbcError* error) { + SetError(error, "AdbcStatementGetOptionDouble not implemented"); return ADBC_STATUS_NOT_FOUND; } AdbcStatusCode StatementGetParameterSchema(struct AdbcStatement* statement, struct ArrowSchema* schema, struct AdbcError* error) { + SetError(error, "AdbcStatementGetParameterSchema not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementPrepare(struct AdbcStatement*, struct AdbcError* error) { + SetError(error, "AdbcStatementPrepare not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementSetOption(struct AdbcStatement*, const char*, const char*, struct AdbcError* error) { + SetError(error, "AdbcStatementSetOption not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementSetOptionBytes(struct AdbcStatement*, const char*, const uint8_t*, size_t, struct AdbcError* error) { + SetError(error, "AdbcStatementSetOptionBytes not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementSetOptionInt(struct AdbcStatement* statement, const char* key, int64_t value, struct AdbcError* error) { + SetError(error, "AdbcStatementSetOptionInt not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementSetOptionDouble(struct AdbcStatement* statement, const char* key, double value, struct AdbcError* error) { + SetError(error, "AdbcStatementSetOptionDouble not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementSetSqlQuery(struct AdbcStatement*, const char*, struct AdbcError* error) { + SetError(error, "AdbcStatementSetSqlQuery not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } AdbcStatusCode StatementSetSubstraitPlan(struct AdbcStatement*, const uint8_t*, size_t, struct AdbcError* error) { + SetError(error, "AdbcStatementSetSubstraitPlan not implemented"); return ADBC_STATUS_NOT_IMPLEMENTED; } @@ -696,6 +749,7 @@ AdbcStatusCode AdbcDatabaseGetOption(struct AdbcDatabase* database, const char* } else { const auto it = args->options.find(key); if (it == args->options.end()) { + SetError(error, "Option not found"); return ADBC_STATUS_NOT_FOUND; } result = &it->second; @@ -720,6 +774,7 @@ AdbcStatusCode AdbcDatabaseGetOptionBytes(struct AdbcDatabase* database, const c const auto* args = reinterpret_cast(database->private_data); const auto it = args->bytes_options.find(key); if (it == args->options.end()) { + SetError(error, "Option not found"); return ADBC_STATUS_NOT_FOUND; } const std::string& result = it->second; @@ -741,6 +796,7 @@ AdbcStatusCode AdbcDatabaseGetOptionInt(struct AdbcDatabase* database, const cha const auto* args = reinterpret_cast(database->private_data); const auto it = args->int_options.find(key); if (it == args->int_options.end()) { + SetError(error, "Option not found"); return ADBC_STATUS_NOT_FOUND; } *value = it->second; @@ -756,6 +812,7 @@ AdbcStatusCode AdbcDatabaseGetOptionDouble(struct AdbcDatabase* database, const const auto* args = reinterpret_cast(database->private_data); const auto it = args->double_options.find(key); if (it == args->double_options.end()) { + SetError(error, "Option not found"); return ADBC_STATUS_NOT_FOUND; } *value = it->second; @@ -822,6 +879,7 @@ AdbcStatusCode AdbcDriverManagerDatabaseSetInitFunc(struct AdbcDatabase* databas AdbcDriverInitFunc init_func, struct AdbcError* error) { if (database->private_driver) { + SetError(error, "Cannot SetInitFunc after AdbcDatabaseInit"); return ADBC_STATUS_INVALID_STATE; } @@ -832,7 +890,7 @@ AdbcStatusCode AdbcDriverManagerDatabaseSetInitFunc(struct AdbcDatabase* databas AdbcStatusCode AdbcDatabaseInit(struct AdbcDatabase* database, struct AdbcError* error) { if (!database->private_data) { - SetError(error, "Must call AdbcDatabaseNew first"); + SetError(error, "Must call AdbcDatabaseNew before AdbcDatabaseInit"); return ADBC_STATUS_INVALID_STATE; } TempDatabase* args = reinterpret_cast(database->private_data); @@ -948,6 +1006,7 @@ AdbcStatusCode AdbcDatabaseRelease(struct AdbcDatabase* database, AdbcStatusCode AdbcConnectionCancel(struct AdbcConnection* connection, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionCancel: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -957,6 +1016,7 @@ AdbcStatusCode AdbcConnectionCancel(struct AdbcConnection* connection, AdbcStatusCode AdbcConnectionCommit(struct AdbcConnection* connection, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionCommit: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -968,6 +1028,7 @@ AdbcStatusCode AdbcConnectionGetInfo(struct AdbcConnection* connection, struct ArrowArrayStream* out, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionGetInfo: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -983,6 +1044,7 @@ AdbcStatusCode AdbcConnectionGetObjects(struct AdbcConnection* connection, int d struct ArrowArrayStream* stream, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionGetObjects: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1092,6 +1154,7 @@ AdbcStatusCode AdbcConnectionGetStatistics(struct AdbcConnection* connection, struct ArrowArrayStream* out, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionGetStatistics: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1105,6 +1168,7 @@ AdbcStatusCode AdbcConnectionGetStatisticNames(struct AdbcConnection* connection struct ArrowArrayStream* out, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionGetStatisticNames: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1119,6 +1183,7 @@ AdbcStatusCode AdbcConnectionGetTableSchema(struct AdbcConnection* connection, struct ArrowSchema* schema, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionGetTableSchema: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1130,6 +1195,7 @@ AdbcStatusCode AdbcConnectionGetTableTypes(struct AdbcConnection* connection, struct ArrowArrayStream* stream, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionGetTableTypes: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1204,6 +1270,7 @@ AdbcStatusCode AdbcConnectionReadPartition(struct AdbcConnection* connection, struct ArrowArrayStream* out, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionReadPartition: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1232,6 +1299,7 @@ AdbcStatusCode AdbcConnectionRelease(struct AdbcConnection* connection, AdbcStatusCode AdbcConnectionRollback(struct AdbcConnection* connection, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcConnectionRollback: must AdbcConnectionNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1312,6 +1380,7 @@ AdbcStatusCode AdbcStatementBind(struct AdbcStatement* statement, struct ArrowArray* values, struct ArrowSchema* schema, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementBind: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1322,6 +1391,7 @@ AdbcStatusCode AdbcStatementBindStream(struct AdbcStatement* statement, struct ArrowArrayStream* stream, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementBindStream: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1331,6 +1401,7 @@ AdbcStatusCode AdbcStatementBindStream(struct AdbcStatement* statement, AdbcStatusCode AdbcStatementCancel(struct AdbcStatement* statement, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementCancel: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1344,6 +1415,7 @@ AdbcStatusCode AdbcStatementExecutePartitions(struct AdbcStatement* statement, int64_t* rows_affected, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementExecutePartitions: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1356,6 +1428,7 @@ AdbcStatusCode AdbcStatementExecuteQuery(struct AdbcStatement* statement, int64_t* rows_affected, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementExecuteQuery: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1368,6 +1441,7 @@ AdbcStatusCode AdbcStatementExecuteSchema(struct AdbcStatement* statement, struct ArrowSchema* schema, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementExecuteSchema: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1378,6 +1452,7 @@ AdbcStatusCode AdbcStatementGetOption(struct AdbcStatement* statement, const cha char* value, size_t* length, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementGetOption: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1389,6 +1464,7 @@ AdbcStatusCode AdbcStatementGetOptionBytes(struct AdbcStatement* statement, const char* key, uint8_t* value, size_t* length, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementGetOptionBytes: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1399,6 +1475,7 @@ AdbcStatusCode AdbcStatementGetOptionBytes(struct AdbcStatement* statement, AdbcStatusCode AdbcStatementGetOptionInt(struct AdbcStatement* statement, const char* key, int64_t* value, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementGetOptionInt: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1409,6 +1486,7 @@ AdbcStatusCode AdbcStatementGetOptionDouble(struct AdbcStatement* statement, const char* key, double* value, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementGetOptionDouble: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1420,6 +1498,7 @@ AdbcStatusCode AdbcStatementGetParameterSchema(struct AdbcStatement* statement, struct ArrowSchema* schema, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementGetParameterSchema: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1430,6 +1509,7 @@ AdbcStatusCode AdbcStatementNew(struct AdbcConnection* connection, struct AdbcStatement* statement, struct AdbcError* error) { if (!connection->private_driver) { + SetError(error, "AdbcStatementNew: must AdbcConnectionInit first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, connection); @@ -1441,6 +1521,7 @@ AdbcStatusCode AdbcStatementNew(struct AdbcConnection* connection, AdbcStatusCode AdbcStatementPrepare(struct AdbcStatement* statement, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementPrepare: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1450,6 +1531,7 @@ AdbcStatusCode AdbcStatementPrepare(struct AdbcStatement* statement, AdbcStatusCode AdbcStatementRelease(struct AdbcStatement* statement, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementRelease: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1461,6 +1543,7 @@ AdbcStatusCode AdbcStatementRelease(struct AdbcStatement* statement, AdbcStatusCode AdbcStatementSetOption(struct AdbcStatement* statement, const char* key, const char* value, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementSetOption: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1471,6 +1554,7 @@ AdbcStatusCode AdbcStatementSetOptionBytes(struct AdbcStatement* statement, const char* key, const uint8_t* value, size_t length, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementSetOptionBytes: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1481,6 +1565,7 @@ AdbcStatusCode AdbcStatementSetOptionBytes(struct AdbcStatement* statement, AdbcStatusCode AdbcStatementSetOptionInt(struct AdbcStatement* statement, const char* key, int64_t value, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementSetOptionInt: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1491,6 +1576,7 @@ AdbcStatusCode AdbcStatementSetOptionDouble(struct AdbcStatement* statement, const char* key, double value, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementSetOptionDouble: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1501,6 +1587,7 @@ AdbcStatusCode AdbcStatementSetOptionDouble(struct AdbcStatement* statement, AdbcStatusCode AdbcStatementSetSqlQuery(struct AdbcStatement* statement, const char* query, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementSetSqlQuery: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); @@ -1511,6 +1598,7 @@ AdbcStatusCode AdbcStatementSetSubstraitPlan(struct AdbcStatement* statement, const uint8_t* plan, size_t length, struct AdbcError* error) { if (!statement->private_driver) { + SetError(error, "AdbcStatementSetSubstraitPlan: must AdbcStatementNew first"); return ADBC_STATUS_INVALID_STATE; } INIT_ERROR(error, statement); diff --git a/r/adbcdrivermanager/R/error.R b/r/adbcdrivermanager/R/error.R index 6ea20ec87d..a7c3eeb8d8 100644 --- a/r/adbcdrivermanager/R/error.R +++ b/r/adbcdrivermanager/R/error.R @@ -55,7 +55,11 @@ stop_for_error <- function(status, error) { error <- .Call(RAdbcErrorProxy, error) error$status <- status error$status_code_message <- .Call(RAdbcStatusCodeMessage, status) - msg <- if (!is.null(error$message)) error$message else error$status_code_message + if (!is.null(error$message)) { + msg <- paste(error$status_code_message, error$message, sep=": ") + } else { + msg <- error$status_code_message + } # Gives an error class like "adbc_status_invalid_state", "adbc_status", # "simpleError", ...