Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
Managing Statements
Collaboration diagram for Managing Statements:

Modules

 Partitioned Results
 
 SQL Semantics
 
 Substrait Semantics
 

Classes

struct  AdbcStatement
 A container for all state needed to execute a database query, such as the query itself, parameters for prepared statements, driver parameters, etc. More...
 

Functions

ADBC_EXPORT AdbcStatusCode AdbcStatementNew (struct AdbcConnection *connection, struct AdbcStatement *statement, struct AdbcError *error)
 Create a new statement for a given connection.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementRelease (struct AdbcStatement *statement, struct AdbcError *error)
 Destroy a statement.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementExecuteQuery (struct AdbcStatement *statement, struct ArrowArrayStream *out, int64_t *rows_affected, struct AdbcError *error)
 Execute a statement and get the results.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementExecuteSchema (struct AdbcStatement *statement, struct ArrowSchema *schema, struct AdbcError *error)
 Get the schema of the result set of a query without executing it.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementPrepare (struct AdbcStatement *statement, struct AdbcError *error)
 Turn this statement into a prepared statement to be executed multiple times.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementBind (struct AdbcStatement *statement, struct ArrowArray *values, struct ArrowSchema *schema, struct AdbcError *error)
 Bind Arrow data. This can be used for bulk inserts or prepared statements.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementBindStream (struct AdbcStatement *statement, struct ArrowArrayStream *stream, struct AdbcError *error)
 Bind Arrow data. This can be used for bulk inserts or prepared statements.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementCancel (struct AdbcStatement *statement, struct AdbcError *error)
 Cancel execution of an in-progress query.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementGetOption (struct AdbcStatement *statement, const char *key, char *value, size_t *length, struct AdbcError *error)
 Get a string option of the statement.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementGetOptionBytes (struct AdbcStatement *statement, const char *key, uint8_t *value, size_t *length, struct AdbcError *error)
 Get a bytestring option of the statement.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementGetOptionInt (struct AdbcStatement *statement, const char *key, int64_t *value, struct AdbcError *error)
 Get an integer option of the statement.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementGetOptionDouble (struct AdbcStatement *statement, const char *key, double *value, struct AdbcError *error)
 Get a double option of the statement.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementGetParameterSchema (struct AdbcStatement *statement, struct ArrowSchema *schema, struct AdbcError *error)
 Get the schema for bound parameters.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementSetOption (struct AdbcStatement *statement, const char *key, const char *value, struct AdbcError *error)
 Set a string option on a statement.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementSetOptionBytes (struct AdbcStatement *statement, const char *key, const uint8_t *value, size_t length, struct AdbcError *error)
 Set a bytestring option on a statement.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementSetOptionInt (struct AdbcStatement *statement, const char *key, int64_t value, struct AdbcError *error)
 Set an integer option on a statement.
 
ADBC_EXPORT AdbcStatusCode AdbcStatementSetOptionDouble (struct AdbcStatement *statement, const char *key, double value, struct AdbcError *error)
 Set a double option on a statement.
 

Detailed Description

Applications should first initialize a statement with AdbcStatementNew. Then, the statement should be configured with functions like AdbcStatementSetSqlQuery and AdbcStatementSetOption. Finally, the statement can be executed with AdbcStatementExecuteQuery (or call AdbcStatementPrepare first to turn it into a prepared statement instead).

Function Documentation

◆ AdbcStatementNew()

ADBC_EXPORT AdbcStatusCode AdbcStatementNew ( struct AdbcConnection connection,
struct AdbcStatement statement,
struct AdbcError error 
)

Create a new statement for a given connection.

Callers pass in a zero-initialized AdbcStatement.

Drivers should allocate their internal data structure and set the private_data field to point to the newly allocated struct. This struct should be released when AdbcStatementRelease is called.

◆ AdbcStatementRelease()

ADBC_EXPORT AdbcStatusCode AdbcStatementRelease ( struct AdbcStatement statement,
struct AdbcError error 
)

Destroy a statement.

Parameters
[in]statementThe statement to release.
[out]errorAn optional location to return an error message if necessary.

◆ AdbcStatementExecuteQuery()

ADBC_EXPORT AdbcStatusCode AdbcStatementExecuteQuery ( struct AdbcStatement statement,
struct ArrowArrayStream out,
int64_t rows_affected,
struct AdbcError error 
)

Execute a statement and get the results.

This invalidates any prior result sets. This AdbcStatement must outlive the returned ArrowArrayStream.

Since ADBC 1.1.0: releasing the returned ArrowArrayStream without consuming it fully is equivalent to calling AdbcStatementCancel.

Parameters
[in]statementThe statement to execute.
[out]outThe results. Pass NULL if the client does not expect a result set.
[out]rows_affectedThe number of rows affected if known, else -1. Pass NULL if the client does not want this information.
[out]errorAn optional location to return an error message if necessary.

◆ AdbcStatementExecuteSchema()

ADBC_EXPORT AdbcStatusCode AdbcStatementExecuteSchema ( struct AdbcStatement statement,
struct ArrowSchema schema,
struct AdbcError error 
)

Get the schema of the result set of a query without executing it.

This invalidates any prior result sets.

Depending on the driver, this may require first executing AdbcStatementPrepare.

Since
ADBC API revision 1.1.0
Parameters
[in]statementThe statement to execute.
[out]outThe result schema.
[out]errorAn optional location to return an error message if necessary.
Returns
ADBC_STATUS_NOT_IMPLEMENTED if the driver does not support this.

◆ AdbcStatementPrepare()

ADBC_EXPORT AdbcStatusCode AdbcStatementPrepare ( struct AdbcStatement statement,
struct AdbcError error 
)

Turn this statement into a prepared statement to be executed multiple times.

This invalidates any prior result sets.

◆ AdbcStatementBind()

ADBC_EXPORT AdbcStatusCode AdbcStatementBind ( struct AdbcStatement statement,
struct ArrowArray values,
struct ArrowSchema schema,
struct AdbcError error 
)

Bind Arrow data. This can be used for bulk inserts or prepared statements.

Parameters
[in]statementThe statement to bind to.
[in]valuesThe values to bind. The driver will call the release callback itself, although it may not do this until the statement is released.
[in]schemaThe schema of the values to bind.
[out]errorAn optional location to return an error message if necessary.

◆ AdbcStatementBindStream()

ADBC_EXPORT AdbcStatusCode AdbcStatementBindStream ( struct AdbcStatement statement,
struct ArrowArrayStream stream,
struct AdbcError error 
)

Bind Arrow data. This can be used for bulk inserts or prepared statements.

Parameters
[in]statementThe statement to bind to.
[in]streamThe values to bind. The driver will call the release callback itself, although it may not do this until the statement is released.
[out]errorAn optional location to return an error message if necessary.

◆ AdbcStatementCancel()

ADBC_EXPORT AdbcStatusCode AdbcStatementCancel ( struct AdbcStatement statement,
struct AdbcError error 
)

Cancel execution of an in-progress query.

This can be called during AdbcStatementExecuteQuery (or similar), or while consuming an ArrowArrayStream returned from such. Calling this function should make the other functions return ADBC_STATUS_CANCELLED (from ADBC functions) or ECANCELED (from methods of ArrowArrayStream). (It is not guaranteed to, for instance, the result set may be buffered in memory already.)

This must always be thread-safe (other operations are not). It is not necessarily signal-safe.

Since
ADBC API revision 1.1.0
Parameters
[in]statementThe statement to cancel.
[out]errorAn optional location to return an error message if necessary.
Returns
ADBC_STATUS_INVALID_STATE if there is no query to cancel.
ADBC_STATUS_UNKNOWN if the query could not be cancelled.

◆ AdbcStatementGetOption()

ADBC_EXPORT AdbcStatusCode AdbcStatementGetOption ( struct AdbcStatement statement,
const char *  key,
char *  value,
size_t *  length,
struct AdbcError error 
)

Get a string option of the statement.

This must always be thread-safe (other operations are not), though given the semantics here, it is not recommended to call GetOption concurrently with itself.

length must be provided and must be the size of the buffer pointed to by value. If there is sufficient space, the driver will copy the option value (including the null terminator) to buffer and set length to the size of the actual value. If the buffer is too small, no data will be written and length will be set to the required length.

In other words:

  • If output length <= input length, value will contain a value with length bytes.
  • If output length > input length, nothing has been written to value.

For standard options, drivers must always support getting the option value (if they support getting option values at all) via the type specified in the option. (For example, an option set via SetOptionDouble must be retrievable via GetOptionDouble.) Drivers may also support getting a converted option value via other getters if needed. (For example, getting the string representation of a double option.)

Since
ADBC API revision 1.1.0
Parameters
[in]statementThe statement.
[in]keyThe option to get.
[out]valueThe option value.
[in,out]lengthThe length of value.
[out]errorAn optional location to return an error message if necessary.
Returns
ADBC_STATUS_NOT_FOUND if the option is not recognized.

◆ AdbcStatementGetOptionBytes()

ADBC_EXPORT AdbcStatusCode AdbcStatementGetOptionBytes ( struct AdbcStatement statement,
const char *  key,
uint8_t value,
size_t *  length,
struct AdbcError error 
)

Get a bytestring option of the statement.

This must always be thread-safe (other operations are not), though given the semantics here, it is not recommended to call GetOptionBytes concurrently with itself.

length must be provided and must be the size of the buffer pointed to by value. If there is sufficient space, the driver will copy the option value to buffer and set length to the size of the actual value. If the buffer is too small, no data will be written and length will be set to the required length.

In other words:

  • If output length <= input length, value will contain a value with length bytes.
  • If output length > input length, nothing has been written to value.

For standard options, drivers must always support getting the option value (if they support getting option values at all) via the type specified in the option. (For example, an option set via SetOptionDouble must be retrievable via GetOptionDouble.) Drivers may also support getting a converted option value via other getters if needed. (For example, getting the string representation of a double option.)

Since
ADBC API revision 1.1.0
Parameters
[in]statementThe statement.
[in]keyThe option to get.
[out]valueThe option value.
[in,out]lengthThe option value length.
[out]errorAn optional location to return an error message if necessary.
Returns
ADBC_STATUS_NOT_FOUND if the option is not recognized.

◆ AdbcStatementGetOptionInt()

ADBC_EXPORT AdbcStatusCode AdbcStatementGetOptionInt ( struct AdbcStatement statement,
const char *  key,
int64_t value,
struct AdbcError error 
)

Get an integer option of the statement.

This must always be thread-safe (other operations are not).

For standard options, drivers must always support getting the option value (if they support getting option values at all) via the type specified in the option. (For example, an option set via SetOptionDouble must be retrievable via GetOptionDouble.) Drivers may also support getting a converted option value via other getters if needed. (For example, getting the string representation of a double option.)

Since
ADBC API revision 1.1.0
Parameters
[in]statementThe statement.
[in]keyThe option to get.
[out]valueThe option value.
[out]errorAn optional location to return an error message if necessary.
Returns
ADBC_STATUS_NOT_FOUND if the option is not recognized.

◆ AdbcStatementGetOptionDouble()

ADBC_EXPORT AdbcStatusCode AdbcStatementGetOptionDouble ( struct AdbcStatement statement,
const char *  key,
double *  value,
struct AdbcError error 
)

Get a double option of the statement.

This must always be thread-safe (other operations are not).

For standard options, drivers must always support getting the option value (if they support getting option values at all) via the type specified in the option. (For example, an option set via SetOptionDouble must be retrievable via GetOptionDouble.) Drivers may also support getting a converted option value via other getters if needed. (For example, getting the string representation of a double option.)

Since
ADBC API revision 1.1.0
Parameters
[in]statementThe statement.
[in]keyThe option to get.
[out]valueThe option value.
[out]errorAn optional location to return an error message if necessary.
Returns
ADBC_STATUS_NOT_FOUND if the option is not recognized.

◆ AdbcStatementGetParameterSchema()

ADBC_EXPORT AdbcStatusCode AdbcStatementGetParameterSchema ( struct AdbcStatement statement,
struct ArrowSchema schema,
struct AdbcError error 
)

Get the schema for bound parameters.

This retrieves an Arrow schema describing the number, names, and types of the parameters in a parameterized statement. The fields of the schema should be in order of the ordinal position of the parameters; named parameters should appear only once.

If the parameter does not have a name, or the name cannot be determined, the name of the corresponding field in the schema will be an empty string. If the type cannot be determined, the type of the corresponding field will be NA (NullType).

This should be called after AdbcStatementPrepare.

Returns
ADBC_STATUS_NOT_IMPLEMENTED if the schema cannot be determined.

◆ AdbcStatementSetOption()

ADBC_EXPORT AdbcStatusCode AdbcStatementSetOption ( struct AdbcStatement statement,
const char *  key,
const char *  value,
struct AdbcError error 
)

Set a string option on a statement.

Parameters
[in]statementThe statement.
[in]keyThe option to set.
[in]valueThe option value.
[out]errorAn optional location to return an error message if necessary.
Returns
ADBC_STATUS_NOT_IMPLEMENTED if the option is not recognized.

◆ AdbcStatementSetOptionBytes()

ADBC_EXPORT AdbcStatusCode AdbcStatementSetOptionBytes ( struct AdbcStatement statement,
const char *  key,
const uint8_t value,
size_t  length,
struct AdbcError error 
)

Set a bytestring option on a statement.

Since
ADBC API revision 1.1.0
Parameters
[in]statementThe statement.
[in]keyThe option to set.
[in]valueThe option value.
[in]lengthThe option value length.
[out]errorAn optional location to return an error message if necessary.
Returns
ADBC_STATUS_NOT_IMPLEMENTED if the option is not recognized

◆ AdbcStatementSetOptionInt()

ADBC_EXPORT AdbcStatusCode AdbcStatementSetOptionInt ( struct AdbcStatement statement,
const char *  key,
int64_t  value,
struct AdbcError error 
)

Set an integer option on a statement.

Since
ADBC API revision 1.1.0
Parameters
[in]statementThe statement.
[in]keyThe option to set.
[in]valueThe option value.
[out]errorAn optional location to return an error message if necessary.
Returns
ADBC_STATUS_NOT_IMPLEMENTED if the option is not recognized

◆ AdbcStatementSetOptionDouble()

ADBC_EXPORT AdbcStatusCode AdbcStatementSetOptionDouble ( struct AdbcStatement statement,
const char *  key,
double  value,
struct AdbcError error 
)

Set a double option on a statement.

Since
ADBC API revision 1.1.0
Parameters
[in]statementThe statement.
[in]keyThe option to set.
[in]valueThe option value.
[out]errorAn optional location to return an error message if necessary.
Returns
ADBC_STATUS_NOT_IMPLEMENTED if the option is not recognized