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
duckdb::ClientContext Class Reference
Inheritance diagram for duckdb::ClientContext:
Collaboration diagram for duckdb::ClientContext:

Public Member Functions

DUCKDB_API ClientContext (shared_ptr< DatabaseInstance > db)
 
MetaTransactionActiveTransaction ()
 
DUCKDB_API void Interrupt ()
 Interrupt execution of a query.
 
DUCKDB_API bool IsInterrupted () const
 
DUCKDB_API void ClearInterrupt ()
 
DUCKDB_API void CancelTransaction ()
 
DUCKDB_API void EnableProfiling ()
 Enable query profiling.
 
DUCKDB_API void DisableProfiling ()
 Disable query profiling.
 
DUCKDB_API unique_ptr< QueryResultQuery (const string &query, QueryParameters query_parameters)
 
DUCKDB_API unique_ptr< QueryResultQuery (unique_ptr< SQLStatement > statement, QueryParameters query_parameters)
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (const string &query, QueryParameters query_parameters)
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (unique_ptr< SQLStatement > statement, QueryParameters query_parameters)
 Issues a query to the database and returns a Pending Query Result.
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (unique_ptr< SQLStatement > statement, case_insensitive_map_t< BoundParameterData > &values, QueryParameters query_parameters)
 Create a pending query with a list of parameters.
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (const string &query, case_insensitive_map_t< BoundParameterData > &values, QueryParameters query_parameters)
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (const string &query, PendingQueryParameters parameters)
 
DUCKDB_API void Destroy ()
 Destroy the client context.
 
DUCKDB_API unique_ptr< TableDescriptionTableInfo (const string &database_name, const string &schema_name, const string &table_name)
 Get the table info of a specific table, or nullptr if it cannot be found.
 
DUCKDB_API unique_ptr< TableDescriptionTableInfo (const string &schema_name, const string &table_name)
 Get the table info of a specific table, or nullptr if it cannot be found. Uses INVALID_CATALOG.
 
DUCKDB_API void Append (unique_ptr< SQLStatement > stmt)
 Executes a query with the given collection "attached" to the query using a CTE.
 
DUCKDB_API void Append (TableDescription &description, ColumnDataCollection &collection)
 Appends a ColumnDataCollection to the described table.
 
DUCKDB_API void TryBindRelation (Relation &relation, vector< ColumnDefinition > &result_columns)
 
DUCKDB_API void InternalTryBindRelation (Relation &relation, vector< ColumnDefinition > &result_columns)
 Internal function for try bind relation. It does not require a client-context lock.
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (const shared_ptr< Relation > &relation, QueryParameters query_parameters)
 Execute a relation.
 
DUCKDB_API unique_ptr< QueryResultExecute (const shared_ptr< Relation > &relation)
 
DUCKDB_API unique_ptr< PreparedStatementPrepare (const string &query)
 Prepare a query.
 
DUCKDB_API unique_ptr< PreparedStatementPrepare (unique_ptr< SQLStatement > statement)
 Directly prepare a SQL statement.
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (const string &query, shared_ptr< PreparedStatementData > &prepared, const PendingQueryParameters &parameters)
 
DUCKDB_API unique_ptr< QueryResultExecute (const string &query, shared_ptr< PreparedStatementData > &prepared, case_insensitive_map_t< BoundParameterData > &values, QueryParameters query_parameters=QueryResultOutputType::ALLOW_STREAMING)
 
DUCKDB_API unique_ptr< QueryResultExecute (const string &query, shared_ptr< PreparedStatementData > &prepared, const PendingQueryParameters &parameters)
 
DUCKDB_API QueryProgress GetQueryProgress ()
 Gets current percentage of the query's progress, returns 0 in case the progress bar is disabled.
 
DUCKDB_API void RegisterFunction (CreateFunctionInfo &info)
 Register function in the temporary schema.
 
DUCKDB_API vector< unique_ptr< SQLStatement > > ParseStatements (const string &query)
 Parse statements from a query.
 
DUCKDB_API unique_ptr< LogicalOperatorExtractPlan (const string &query)
 Extract the logical plan of a query.
 
DUCKDB_API void PreprocessStatements (vector< unique_ptr< SQLStatement > > &statements)
 
DUCKDB_API void RunFunctionInTransaction (const std::function< void(void)> &fun, bool requires_valid_transaction=true)
 
DUCKDB_API void RunFunctionInTransactionInternal (ClientContextLock &lock, const std::function< void(void)> &fun, bool requires_valid_transaction=true)
 Same as RunFunctionInTransaction, but does not obtain a lock on the client context or check for validation.
 
DUCKDB_API SettingLookupResult TryGetCurrentSetting (const string &key, Value &result) const
 Equivalent to CURRENT_SETTING(key) SQL function.
 
DUCKDB_API SettingLookupResult TryGetCurrentUserSetting (idx_t setting_index, Value &result) const
 Returns the value of the current setting set by the user - if the user has set it.
 
DUCKDB_API ParserOptions GetParserOptions () const
 Returns the parser options for this client context.
 
DUCKDB_API bool IsActiveResult (ClientContextLock &lock, BaseQueryResult &result)
 Whether or not the given result object (streaming query result or pending query result) is active.
 
ExecutorGetExecutor ()
 Returns the current executor.
 
LoggerGetLogger () const
 Return the current logger.
 
const string & GetCurrentQuery ()
 Returns the current query string (if any)
 
connection_t GetConnectionId () const
 
DUCKDB_API unordered_set< string > GetTableNames (const string &query, const bool qualified=false)
 
DUCKDB_API ClientProperties GetClientProperties ()
 
DUCKDB_API bool ExecutionIsFinished ()
 Returns true if execution of the current query is finished.
 
DUCKDB_API void ProcessError (ErrorData &error, const string &query) const
 Process an error for display to the user.
 
DUCKDB_API LogicalType ParseLogicalType (const string &type)
 
- Public Member Functions inherited from duckdb::enable_shared_from_this< ClientContext >
shared_ptr< ClientContextshared_from_this ()
 
shared_ptr< ClientContext constshared_from_this () const
 

Public Attributes

shared_ptr< DatabaseInstancedb
 The database that this client is connected to.
 
atomic< bool > interrupted
 Whether or not the query is interrupted.
 
unique_ptr< RegisteredStateManagerregistered_state
 Set of optional states (e.g. Caches) that can be held by the ClientContext.
 
shared_ptr< Loggerlogger
 The logger to be used by this ClientContext.
 
ClientConfig config
 The client configuration.
 
unique_ptr< ClientDataclient_data
 The set of client-specific data.
 
TransactionContext transaction
 Data for the currently running transaction.
 

Private Member Functions

vector< unique_ptr< SQLStatement > > ParseStatements (ClientContextLock &lock, const string &query)
 Parse statements and resolve pragmas from a query.
 
unique_ptr< PendingQueryResultPendingQueryInternal (ClientContextLock &lock, unique_ptr< SQLStatement > statement, const PendingQueryParameters &parameters, bool verify=true)
 Issues a query to the database and returns a Pending Query Result.
 
unique_ptr< QueryResultExecutePendingQueryInternal (ClientContextLock &lock, PendingQueryResult &query)
 
vector< unique_ptr< SQLStatement > > ParseStatementsInternal (ClientContextLock &lock, const string &query)
 Parse statements from a query.
 
ErrorData VerifyQuery (ClientContextLock &lock, const string &query, unique_ptr< SQLStatement > statement, PendingQueryParameters parameters)
 
void InitialCleanup (ClientContextLock &lock)
 
void CleanupInternal (ClientContextLock &lock, BaseQueryResult *result=nullptr, bool invalidate_transaction=false)
 Internal clean up, does not lock. Caller must hold the context_lock.
 
unique_ptr< PendingQueryResultPendingStatementOrPreparedStatement (ClientContextLock &lock, const string &query, unique_ptr< SQLStatement > statement, shared_ptr< PreparedStatementData > &prepared, const PendingQueryParameters &parameters)
 
unique_ptr< PendingQueryResultPendingPreparedStatement (ClientContextLock &lock, const string &query, shared_ptr< PreparedStatementData > statement_p, const PendingQueryParameters &parameters)
 
unique_ptr< PendingQueryResultPendingPreparedStatementInternal (ClientContextLock &lock, shared_ptr< PreparedStatementData > statement_data_p, const PendingQueryParameters &parameters)
 
void CheckIfPreparedStatementIsExecutable (PreparedStatementData &statement)
 
shared_ptr< PreparedStatementDataCreatePreparedStatement (ClientContextLock &lock, const string &query, unique_ptr< SQLStatement > statement, PendingQueryParameters parameters, PreparedStatementMode mode=PreparedStatementMode::PREPARE_ONLY)
 Internally prepare a SQL statement. Caller must hold the context_lock.
 
unique_ptr< PendingQueryResultPendingStatementInternal (ClientContextLock &lock, const string &query, unique_ptr< SQLStatement > statement, const PendingQueryParameters &parameters)
 
unique_ptr< QueryResultRunStatementInternal (ClientContextLock &lock, const string &query, unique_ptr< SQLStatement > statement, const PendingQueryParameters &parameters, bool verify=true)
 
unique_ptr< PreparedStatementPrepareInternal (ClientContextLock &lock, unique_ptr< SQLStatement > statement)
 
void LogQueryInternal (ClientContextLock &lock, const string &query)
 
unique_ptr< QueryResultFetchResultInternal (ClientContextLock &lock, PendingQueryResult &pending)
 
unique_ptr< ClientContextLockLockContext ()
 
void BeginQueryInternal (ClientContextLock &lock, const string &query)
 
ErrorData EndQueryInternal (ClientContextLock &lock, bool success, bool invalidate_transaction, optional_ptr< ErrorData > previous_error)
 
void WaitForTask (ClientContextLock &lock, BaseQueryResult &result)
 Wait until a task is available to execute.
 
PendingExecutionResult ExecuteTaskInternal (ClientContextLock &lock, BaseQueryResult &result, bool dry_run=false)
 
unique_ptr< PendingQueryResultPendingStatementOrPreparedStatementInternal (ClientContextLock &lock, const string &query, unique_ptr< SQLStatement > statement, shared_ptr< PreparedStatementData > &prepared, const PendingQueryParameters &parameters)
 
unique_ptr< PendingQueryResultPendingQueryPreparedInternal (ClientContextLock &lock, const string &query, shared_ptr< PreparedStatementData > &prepared, const PendingQueryParameters &parameters)
 
unique_ptr< PendingQueryResultPendingQueryInternal (ClientContextLock &, const shared_ptr< Relation > &relation, QueryParameters query_parameters)
 
void RebindPreparedStatement (ClientContextLock &lock, const string &query, shared_ptr< PreparedStatementData > &prepared, const PendingQueryParameters &parameters)
 
template<class T >
unique_ptr< T > ErrorResult (ErrorData error, const string &query=string())
 
shared_ptr< PreparedStatementDataCreatePreparedStatementInternal (ClientContextLock &lock, const string &query, unique_ptr< SQLStatement > statement, PendingQueryParameters parameters)
 
bool ErrorInvalidatesTransaction (ExceptionType type)
 

Private Attributes

mutex context_lock
 Lock on using the ClientContext in parallel.
 
unique_ptr< ActiveQueryContextactive_query
 The currently active query context.
 
QueryProgress query_progress
 The current query progress.
 
connection_t connection_id
 The connection corresponding to this client context.
 

Friends

class PendingQueryResult
 
class BufferedData
 
class SimpleBufferedData
 
class BatchedBufferedData
 
class StreamQueryResult
 
class ConnectionManager
 

Additional Inherited Members

- Protected Member Functions inherited from duckdb::enable_shared_from_this< ClientContext >
 enable_shared_from_this (enable_shared_from_this const &) noexcept
 
enable_shared_from_thisoperator= (enable_shared_from_this const &) noexcept
 

Detailed Description

The ClientContext holds information relevant to the current client session during execution

Member Function Documentation

◆ ActiveTransaction()

MetaTransaction & duckdb::ClientContext::ActiveTransaction ( )
inline
41583 {
41584 return transaction.ActiveTransaction();
41585 }
TransactionContext transaction
Data for the currently running transaction.
Definition duckdb.hpp:41580

◆ Query()

DUCKDB_API unique_ptr< QueryResult > duckdb::ClientContext::Query ( const string &  query,
QueryParameters  query_parameters 
)

Issue a query, returning a QueryResult. The QueryResult can be either a StreamQueryResult or a MaterializedQueryResult. The StreamQueryResult will only be returned in the case of a successful SELECT statement.

◆ PendingQuery() [1/2]

DUCKDB_API unique_ptr< PendingQueryResult > duckdb::ClientContext::PendingQuery ( const string &  query,
QueryParameters  query_parameters 
)

Issues a query to the database and returns a Pending Query Result. Note that "query" may only contain a single statement.

◆ TryBindRelation()

DUCKDB_API void duckdb::ClientContext::TryBindRelation ( Relation relation,
vector< ColumnDefinition > &  result_columns 
)

Try to bind a relation in the current client context; either throws an exception or fills the result_columns list with the set of returned columns

◆ PendingQuery() [2/2]

DUCKDB_API unique_ptr< PendingQueryResult > duckdb::ClientContext::PendingQuery ( const string &  query,
shared_ptr< PreparedStatementData > &  prepared,
const PendingQueryParameters parameters 
)

Create a pending query result from a prepared statement with the given name and set of parameters It is possible that the prepared statement will be re-bound. This will generally happen if the catalog is modified in between the prepared statement being bound and the prepared statement being run.

◆ Execute()

DUCKDB_API unique_ptr< QueryResult > duckdb::ClientContext::Execute ( const string &  query,
shared_ptr< PreparedStatementData > &  prepared,
case_insensitive_map_t< BoundParameterData > &  values,
QueryParameters  query_parameters = QueryResultOutputType::ALLOW_STREAMING 
)

Execute a prepared statement with the given name and set of parameters It is possible that the prepared statement will be re-bound. This will generally happen if the catalog is modified in between the prepared statement being bound and the prepared statement being run.

◆ RunFunctionInTransaction()

DUCKDB_API void duckdb::ClientContext::RunFunctionInTransaction ( const std::function< void(void)> &  fun,
bool  requires_valid_transaction = true 
)

Runs a function with a valid transaction context, potentially starting a transaction if the context is in auto commit mode.

◆ GetTableNames()

DUCKDB_API unordered_set< string > duckdb::ClientContext::GetTableNames ( const string &  query,
const bool  qualified = false 
)

Fetch the set of tables names of the query. Returns the fully qualified, escaped table names, if qualified is set to true, else returns the not qualified, not escaped table names.

◆ VerifyQuery()

ErrorData duckdb::ClientContext::VerifyQuery ( ClientContextLock lock,
const string &  query,
unique_ptr< SQLStatement statement,
PendingQueryParameters  parameters 
)
private

Perform aggressive query verification of a SELECT statement. Only called when query_verification_enabled is true.


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