ADBC
Arrow Database Connectivity
Loading...
Searching...
No Matches
adbc::driver::Connection< Derived > Class Template Reference

The CRTP base implementation of an AdbcConnection. More...

#include <connection.h>

Inheritance diagram for adbc::driver::Connection< Derived >:
adbc::driver::ObjectBase

Public Types

enum class  AutocommitState { kAutocommit , kTransaction }
 Whether autocommit is enabled or not (by default: enabled). More...
 
using Base = Connection<Derived>
 

Public Member Functions

AdbcStatusCode Init (void *parent, AdbcError *error) override
 Initialize the object.
 
AdbcStatusCode Cancel (AdbcError *error)
 
AdbcStatusCode Commit (AdbcError *error)
 
AdbcStatusCode GetInfo (const uint32_t *info_codes, size_t info_codes_length, ArrowArrayStream *out, AdbcError *error)
 
AdbcStatusCode GetObjects (int c_depth, const char *catalog, const char *db_schema, const char *table_name, const char **table_type, const char *column_name, ArrowArrayStream *out, AdbcError *error)
 
Result< OptionGetOption (std::string_view key) override
 Get an option value.
 
AdbcStatusCode GetStatistics (const char *catalog, const char *db_schema, const char *table_name, char approximate, ArrowArrayStream *out, AdbcError *error)
 
AdbcStatusCode GetStatisticNames (ArrowArrayStream *out, AdbcError *error)
 
AdbcStatusCode GetTableSchema (const char *catalog, const char *db_schema, const char *table_name, ArrowSchema *schema, AdbcError *error)
 
AdbcStatusCode GetTableTypes (ArrowArrayStream *out, AdbcError *error)
 
AdbcStatusCode ReadPartition (const uint8_t *serialized_partition, size_t serialized_length, ArrowArrayStream *out, AdbcError *error)
 
AdbcStatusCode Release (AdbcError *error) override
 Finalize the object.
 
AdbcStatusCode Rollback (AdbcError *error)
 
AdbcStatusCode SetOption (std::string_view key, Option value, AdbcError *error) override
 Set an option value.
 
Status CommitImpl ()
 Commit the current transaction and begin a new transaction.
 
Result< std::optional< std::string > > GetCurrentCatalogImpl ()
 
Result< std::optional< std::string > > GetCurrentSchemaImpl ()
 
Result< std::unique_ptr< GetObjectsHelper > > GetObjectsImpl ()
 Query the database catalog.
 
Status GetTableSchemaImpl (std::optional< std::string_view > catalog, std::optional< std::string_view > db_schema, std::string_view table_name, ArrowSchema *schema)
 
Result< std::vector< std::string > > GetTableTypesImpl ()
 
Result< std::vector< InfoValue > > InfoImpl (const std::vector< uint32_t > &codes)
 
Status InitImpl (void *parent)
 
Status ReleaseImpl ()
 
Status RollbackImpl ()
 
Status SetOptionImpl (std::string_view key, Option value)
 
Status ToggleAutocommitImpl (bool enable_autocommit)
 

Protected Attributes

AutocommitState autocommit_ = AutocommitState::kAutocommit
 
- Protected Attributes inherited from adbc::driver::ObjectBase
LifecycleState lifecycle_state_
 

Private Member Functions

Derived & impl ()
 

Detailed Description

template<typename Derived>
class adbc::driver::Connection< Derived >

The CRTP base implementation of an AdbcConnection.

Derived should override and implement the Impl methods, but not others. Overridden methods should defer to the superclass version at the end. (The Base typedef is provided to make this easier.) Derived should also define a constexpr static symbol called kErrorPrefix that is used to construct error messages.

Member Enumeration Documentation

◆ AutocommitState

template<typename Derived >
enum class adbc::driver::Connection::AutocommitState
strong

Whether autocommit is enabled or not (by default: enabled).

Member Function Documentation

◆ CommitImpl()

template<typename Derived >
Status adbc::driver::Connection< Derived >::CommitImpl ( )
inline

Commit the current transaction and begin a new transaction.

Only called when autocommit is disabled.

◆ GetObjectsImpl()

template<typename Derived >
Result< std::unique_ptr< GetObjectsHelper > > adbc::driver::Connection< Derived >::GetObjectsImpl ( )
inline

Query the database catalog.

The default implementation assumes the underlying database allows querying the catalog in a certain manner, embodied in the helper class returned here. If the database can directly implement GetObjects, then directly override GetObjects instead of using this helper.

◆ GetOption()

template<typename Derived >
Result< Option > adbc::driver::Connection< Derived >::GetOption ( std::string_view key)
inlineoverridevirtual

Get an option value.

Reimplemented from adbc::driver::ObjectBase.

◆ Init()

template<typename Derived >
AdbcStatusCode adbc::driver::Connection< Derived >::Init ( void * parent,
AdbcError * error )
inlineoverridevirtual

Initialize the object.

Called after 0 or more SetOption calls. Generally, you won't need to override this directly. Instead, use the typed InitImpl provided by Database/Connection/Statement.

Parameters
[in]parentA pointer to the AdbcDatabase or AdbcConnection implementation as appropriate, or nullptr.

Reimplemented from adbc::driver::ObjectBase.

◆ Release()

template<typename Derived >
AdbcStatusCode adbc::driver::Connection< Derived >::Release ( AdbcError * error)
inlineoverridevirtual

Finalize the object.

This can be used to return an error if the object is not in a valid state (e.g. prevent closing a connection with open statements) or to clean up resources when resource cleanup could fail. Infallible resource cleanup (e.g. releasing memory) should generally be handled in the destructor.

Generally, you won't need to override this directly. Instead, use the typed ReleaseImpl provided by Database/Connection/Statement.

Reimplemented from adbc::driver::ObjectBase.

◆ SetOption()

template<typename Derived >
AdbcStatusCode adbc::driver::Connection< Derived >::SetOption ( std::string_view key,
Option value,
AdbcError * error )
inlineoverridevirtual

Set an option value.

Reimplemented from adbc::driver::ObjectBase.


The documentation for this class was generated from the following file: