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::PreparedStatement Class Reference

A prepared statement. More...

Collaboration diagram for duckdb::PreparedStatement:

Public Member Functions

DUCKDB_API PreparedStatement (shared_ptr< ClientContext > context, shared_ptr< PreparedStatementData > data, string query, case_insensitive_map_t< idx_t > named_param_map)
 Create a successfully prepared prepared statement object with the given name.
 
DUCKDB_API PreparedStatement (ErrorData error)
 Create a prepared statement that was not successfully prepared.
 
DUCKDB_API const string & GetError ()
 Returns the stored error message.
 
DUCKDB_API ErrorDataGetErrorObject ()
 Returns the stored error object.
 
DUCKDB_API bool HasError () const
 Returns whether or not an error occurred.
 
DUCKDB_API idx_t ColumnCount ()
 Returns the number of columns in the result.
 
DUCKDB_API StatementType GetStatementType ()
 Returns the statement type of the underlying prepared statement object.
 
DUCKDB_API StatementProperties GetStatementProperties ()
 Returns the underlying statement properties.
 
DUCKDB_API const vector< LogicalType > & GetTypes ()
 Returns the result SQL types of the prepared statement.
 
DUCKDB_API const vector< string > & GetNames ()
 Returns the result names of the prepared statement.
 
DUCKDB_API case_insensitive_map_t< LogicalTypeGetExpectedParameterTypes () const
 Returns the map of parameter index to the expected type of parameter.
 
template<typename... ARGS>
unique_ptr< PendingQueryResultPendingQuery (ARGS... args)
 Create a pending query result of the prepared statement with the given set of arguments.
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (vector< Value > &values, bool allow_stream_result=true)
 Create a pending query result of the prepared statement with the given set of arguments.
 
DUCKDB_API unique_ptr< PendingQueryResultPendingQuery (case_insensitive_map_t< BoundParameterData > &named_values, bool allow_stream_result=true)
 Create a pending query result of the prepared statement with the given set named arguments.
 
DUCKDB_API unique_ptr< QueryResultExecute (vector< Value > &values, bool allow_stream_result=true)
 Execute the prepared statement with the given set of values.
 
DUCKDB_API unique_ptr< QueryResultExecute (case_insensitive_map_t< BoundParameterData > &named_values, bool allow_stream_result=true)
 Execute the prepared statement with the given set of named+unnamed values.
 
template<typename... ARGS>
unique_ptr< QueryResultExecute (ARGS... args)
 Execute the prepared statement with the given set of arguments.
 

Static Public Member Functions

template<class PAYLOAD >
static string ExcessValuesException (const case_insensitive_map_t< idx_t > &parameters, const case_insensitive_map_t< PAYLOAD > &values)
 
template<class PAYLOAD >
static string MissingValuesException (const case_insensitive_map_t< idx_t > &parameters, const case_insensitive_map_t< PAYLOAD > &values)
 
template<class PAYLOAD >
static void VerifyParameters (const case_insensitive_map_t< PAYLOAD > &provided, const case_insensitive_map_t< idx_t > &expected)
 
static bool CanCachePlan (const LogicalOperator &op)
 Returns whether or not we can / want to cache a logical plan.
 

Public Attributes

shared_ptr< ClientContextcontext
 The client context this prepared statement belongs to.
 
shared_ptr< PreparedStatementDatadata
 The prepared statement data.
 
string query
 The query that is being prepared.
 
bool success
 Whether or not the statement was successfully prepared.
 
ErrorData error
 The error message (if success = false)
 
case_insensitive_map_t< idx_tnamed_param_map
 The parameter mapping.
 

Private Member Functions

unique_ptr< PendingQueryResultPendingQueryRecursive (vector< Value > &values)
 
template<typename T , typename... ARGS>
unique_ptr< PendingQueryResultPendingQueryRecursive (vector< Value > &values, T value, ARGS... args)
 
unique_ptr< QueryResultExecuteRecursive (vector< Value > &values)
 
template<typename T , typename... ARGS>
unique_ptr< QueryResultExecuteRecursive (vector< Value > &values, T value, ARGS... args)
 

Detailed Description

A prepared statement.

Member Function Documentation

◆ PendingQuery()

template<typename... ARGS>
unique_ptr< PendingQueryResult > duckdb::PreparedStatement::PendingQuery ( ARGS...  args)
inline

Create a pending query result of the prepared statement with the given set of arguments.

27320 {
27321 vector<Value> values;
27322 return PendingQueryRecursive(values, args...);
27323 }

◆ Execute()

template<typename... ARGS>
unique_ptr< QueryResult > duckdb::PreparedStatement::Execute ( ARGS...  args)
inline

Execute the prepared statement with the given set of arguments.

27341 {
27342 vector<Value> values;
27343 return ExecuteRecursive(values, args...);
27344 }

◆ ExcessValuesException()

template<class PAYLOAD >
static string duckdb::PreparedStatement::ExcessValuesException ( const case_insensitive_map_t< idx_t > &  parameters,
const case_insensitive_map_t< PAYLOAD > &  values 
)
inlinestatic
27348 {
27349 // Too many values
27350 set<string> excess_set;
27351 for (auto &pair : values) {
27352 auto &name = pair.first;
27353 if (!parameters.count(name)) {
27354 excess_set.insert(name);
27355 }
27356 }
27357 vector<string> excess_values;
27358 for (auto &val : excess_set) {
27359 excess_values.push_back(val);
27360 }
27361 return StringUtil::Format("Parameter argument/count mismatch, identifiers of the excess parameters: %s",
27362 StringUtil::Join(excess_values, ", "));
27363 }
static DUCKDB_API string Join(const vector< string > &input, const string &separator)
Join multiple strings into one string. Components are concatenated by the given separator.
static string Format(const string fmt_str, ARGS... params)
Format a string using printf semantics.
Definition duckdb.hpp:4002

◆ MissingValuesException()

template<class PAYLOAD >
static string duckdb::PreparedStatement::MissingValuesException ( const case_insensitive_map_t< idx_t > &  parameters,
const case_insensitive_map_t< PAYLOAD > &  values 
)
inlinestatic
27367 {
27368 // Missing values
27369 set<string> missing_set;
27370 for (auto &pair : parameters) {
27371 auto &name = pair.first;
27372 if (!values.count(name)) {
27373 missing_set.insert(name);
27374 }
27375 }
27376 vector<string> missing_values;
27377 for (auto &val : missing_set) {
27378 missing_values.push_back(val);
27379 }
27380 return StringUtil::Format("Values were not provided for the following prepared statement parameters: %s",
27381 StringUtil::Join(missing_values, ", "));
27382 }

◆ VerifyParameters()

template<class PAYLOAD >
static void duckdb::PreparedStatement::VerifyParameters ( const case_insensitive_map_t< PAYLOAD > &  provided,
const case_insensitive_map_t< idx_t > &  expected 
)
inlinestatic
27386 {
27387 if (expected.size() == provided.size()) {
27388 // Same amount of identifiers, if
27389 for (auto &pair : expected) {
27390 auto &identifier = pair.first;
27391 if (!provided.count(identifier)) {
27392 throw InvalidInputException(MissingValuesException(expected, provided));
27393 }
27394 }
27395 return;
27396 }
27397 // Mismatch in expected and provided parameters/values
27398 if (expected.size() > provided.size()) {
27399 throw InvalidInputException(MissingValuesException(expected, provided));
27400 } else {
27401 D_ASSERT(provided.size() > expected.size());
27402 throw InvalidInputException(ExcessValuesException(expected, provided));
27403 }
27404 }

◆ PendingQueryRecursive() [1/2]

unique_ptr< PendingQueryResult > duckdb::PreparedStatement::PendingQueryRecursive ( vector< Value > &  values)
inlineprivate
27410 {
27411 return PendingQuery(values);
27412 }
unique_ptr< PendingQueryResult > PendingQuery(ARGS... args)
Create a pending query result of the prepared statement with the given set of arguments.
Definition duckdb.hpp:27320

◆ PendingQueryRecursive() [2/2]

template<typename T , typename... ARGS>
unique_ptr< PendingQueryResult > duckdb::PreparedStatement::PendingQueryRecursive ( vector< Value > &  values,
value,
ARGS...  args 
)
inlineprivate
27415 {
27416 values.push_back(Value::CreateValue<T>(value));
27417 return PendingQueryRecursive(values, args...);
27418 }

◆ ExecuteRecursive() [1/2]

unique_ptr< QueryResult > duckdb::PreparedStatement::ExecuteRecursive ( vector< Value > &  values)
inlineprivate
27420 {
27421 return Execute(values);
27422 }
DUCKDB_API unique_ptr< QueryResult > Execute(vector< Value > &values, bool allow_stream_result=true)
Execute the prepared statement with the given set of values.

◆ ExecuteRecursive() [2/2]

template<typename T , typename... ARGS>
unique_ptr< QueryResult > duckdb::PreparedStatement::ExecuteRecursive ( vector< Value > &  values,
value,
ARGS...  args 
)
inlineprivate
27425 {
27426 values.push_back(Value::CreateValue<T>(value));
27427 return ExecuteRecursive(values, args...);
27428 }

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