ADBC
Arrow Database Connectivity
Loading...
Searching...
No Matches
Database Initialization

Classes

struct  AdbcDatabase
 An instance of a database. More...
 

Functions

AdbcStatusCode AdbcDatabaseNew (struct AdbcDatabase *database, struct AdbcError *error)
 Allocate a new (but uninitialized) database.
 
AdbcStatusCode AdbcDatabaseGetOption (struct AdbcDatabase *database, const char *key, char *value, size_t *length, struct AdbcError *error)
 Get a string option of the database.
 
AdbcStatusCode AdbcDatabaseGetOptionBytes (struct AdbcDatabase *database, const char *key, uint8_t *value, size_t *length, struct AdbcError *error)
 Get a bytestring option of the database.
 
AdbcStatusCode AdbcDatabaseGetOptionDouble (struct AdbcDatabase *database, const char *key, double *value, struct AdbcError *error)
 Get a double option of the database.
 
AdbcStatusCode AdbcDatabaseGetOptionInt (struct AdbcDatabase *database, const char *key, int64_t *value, struct AdbcError *error)
 Get an integer option of the database.
 
AdbcStatusCode AdbcDatabaseSetOption (struct AdbcDatabase *database, const char *key, const char *value, struct AdbcError *error)
 Set a char* option.
 
AdbcStatusCode AdbcDatabaseSetOptionBytes (struct AdbcDatabase *database, const char *key, const uint8_t *value, size_t length, struct AdbcError *error)
 Set a bytestring option on a database.
 
AdbcStatusCode AdbcDatabaseSetOptionDouble (struct AdbcDatabase *database, const char *key, double value, struct AdbcError *error)
 Set a double option on a database.
 
AdbcStatusCode AdbcDatabaseSetOptionInt (struct AdbcDatabase *database, const char *key, int64_t value, struct AdbcError *error)
 Set an integer option on a database.
 
AdbcStatusCode AdbcDatabaseInit (struct AdbcDatabase *database, struct AdbcError *error)
 Finish setting options and initialize the database.
 
AdbcStatusCode AdbcDatabaseRelease (struct AdbcDatabase *database, struct AdbcError *error)
 Destroy this database. No connections may exist.
 

Detailed Description

Clients first initialize a database, then create a connection (below). This gives the implementation a place to initialize and own any common connection state. For example, in-memory databases can place ownership of the actual database in this object.


Class Documentation

◆ AdbcDatabase

struct AdbcDatabase

An instance of a database.

Must be kept alive as long as any connections exist.

Public Attributes

void * private_data
 Opaque implementation-defined state. This field is NULLPTR iff the connection is unintialized/freed.
 
struct AdbcDriverprivate_driver
 The associated driver (used by the driver manager to help track state).
 

Member Data Documentation

◆ private_data

void* AdbcDatabase::private_data

Opaque implementation-defined state. This field is NULLPTR iff the connection is unintialized/freed.

◆ private_driver

struct AdbcDriver* AdbcDatabase::private_driver

The associated driver (used by the driver manager to help track state).

Function Documentation

◆ AdbcDatabaseGetOption()

AdbcStatusCode AdbcDatabaseGetOption ( struct AdbcDatabase * database,
const char * key,
char * value,
size_t * length,
struct AdbcError * error )

Get a string option of the database.

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]databaseThe database.
[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.

◆ AdbcDatabaseGetOptionBytes()

AdbcStatusCode AdbcDatabaseGetOptionBytes ( struct AdbcDatabase * database,
const char * key,
uint8_t * value,
size_t * length,
struct AdbcError * error )

Get a bytestring option of the database.

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]databaseThe database.
[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.

◆ AdbcDatabaseGetOptionDouble()

AdbcStatusCode AdbcDatabaseGetOptionDouble ( struct AdbcDatabase * database,
const char * key,
double * value,
struct AdbcError * error )

Get a double option of the database.

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 double representation of an integer option.)

Since
ADBC API revision 1.1.0
Parameters
[in]databaseThe database.
[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.

◆ AdbcDatabaseGetOptionInt()

AdbcStatusCode AdbcDatabaseGetOptionInt ( struct AdbcDatabase * database,
const char * key,
int64_t * value,
struct AdbcError * error )

Get an integer option of the database.

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 integer representation of a double option.)

Since
ADBC API revision 1.1.0
Parameters
[in]databaseThe database.
[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.

◆ AdbcDatabaseInit()

AdbcStatusCode AdbcDatabaseInit ( struct AdbcDatabase * database,
struct AdbcError * error )

Finish setting options and initialize the database.

Some drivers may support setting options after initialization as well.

◆ AdbcDatabaseNew()

AdbcStatusCode AdbcDatabaseNew ( struct AdbcDatabase * database,
struct AdbcError * error )

Allocate a new (but uninitialized) database.

Callers pass in a zero-initialized AdbcDatabase.

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 AdbcDatabaseRelease is called.

◆ AdbcDatabaseRelease()

AdbcStatusCode AdbcDatabaseRelease ( struct AdbcDatabase * database,
struct AdbcError * error )

Destroy this database. No connections may exist.

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

◆ AdbcDatabaseSetOption()

AdbcStatusCode AdbcDatabaseSetOption ( struct AdbcDatabase * database,
const char * key,
const char * value,
struct AdbcError * error )

Set a char* option.

Options may be set before AdbcDatabaseInit. Some drivers may support setting options after initialization as well.

Parameters
[in]databaseThe database.
[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

◆ AdbcDatabaseSetOptionBytes()

AdbcStatusCode AdbcDatabaseSetOptionBytes ( struct AdbcDatabase * database,
const char * key,
const uint8_t * value,
size_t length,
struct AdbcError * error )

Set a bytestring option on a database.

Since
ADBC API revision 1.1.0
Parameters
[in]databaseThe database.
[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

◆ AdbcDatabaseSetOptionDouble()

AdbcStatusCode AdbcDatabaseSetOptionDouble ( struct AdbcDatabase * database,
const char * key,
double value,
struct AdbcError * error )

Set a double option on a database.

Since
ADBC API revision 1.1.0
Parameters
[in]databaseThe database.
[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

◆ AdbcDatabaseSetOptionInt()

AdbcStatusCode AdbcDatabaseSetOptionInt ( struct AdbcDatabase * database,
const char * key,
int64_t value,
struct AdbcError * error )

Set an integer option on a database.

Since
ADBC API revision 1.1.0
Parameters
[in]databaseThe database.
[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