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

Public Member Functions

DUCKDB_API PreparedStatementData (StatementType type)
void CheckParameterCount (idx_t parameter_count)
bool RequireRebind (ClientContext &context, optional_ptr< case_insensitive_map_t< BoundParameterData > > values)
 Whether or not the prepared statement data requires the query to rebound for the given parameters.
DUCKDB_API void Bind (case_insensitive_map_t< BoundParameterData > values)
 Bind a set of values to the prepared statement data.
DUCKDB_API LogicalType GetType (const string &identifier)
 Get the expected SQL Type of the bound parameter.
DUCKDB_API bool TryGetType (const string &identifier, LogicalType &result)
 Try to get the expected SQL Type of the bound parameter.

Public Attributes

StatementType statement_type
unique_ptr< SQLStatement > unbound_statement
 The unbound SQL statement that was prepared.
unique_ptr< PhysicalPlan > physical_plan
 The physical plan.
vector< string > names
 The result names of the transaction.
vector< LogicalType > types
 The result types of the transaction.
StatementProperties properties
 The statement properties.
bound_parameter_map_t value_map
 The map of parameter index to the actual value entry.
QueryResultOutputType output_type
 Whether we are creating a streaming result or not.
QueryResultMemoryType memory_type
 Whether we are creating a buffer-managed result or not.

Constructor & Destructor Documentation

◆ PreparedStatementData()

duckdb::PreparedStatementData::PreparedStatementData ( StatementType type)
explicit
294521 : statement_type(type) {
294522}

◆ ~PreparedStatementData()

duckdb::PreparedStatementData::~PreparedStatementData ( )
294524 {
294525}

Member Function Documentation

◆ CheckParameterCount()

void duckdb::PreparedStatementData::CheckParameterCount ( idx_t parameter_count)
294527 {
294528 const auto required = properties.parameter_count;
294529 if (parameter_count != required) {
294530 throw BinderException("Parameter/argument count mismatch for prepared statement. Expected %llu, got %llu",
294531 required, parameter_count);
294532 }
294533}
StatementProperties properties
The statement properties.
Definition duckdb.cpp:27588

◆ RequireRebind()

bool duckdb::PreparedStatementData::RequireRebind ( ClientContext & context,
optional_ptr< case_insensitive_map_t< BoundParameterData > > values )

Whether or not the prepared statement data requires the query to rebound for the given parameters.

294553 {
294554 idx_t count = values ? values->size() : 0;
294555 CheckParameterCount(count);
294556 if (!unbound_statement) {
294557 throw InternalException("Prepared statement without unbound statement");
294558 }
294559 if (properties.always_require_rebind) {
294560 // this statement must always be re-bound
294561 return true;
294562 }
294563 if (!properties.bound_all_parameters) {
294564 // parameters not yet bound: query always requires a rebind
294565 return true;
294566 }
294567 for (auto &it : value_map) {
294568 auto &identifier = it.first;
294569 auto lookup = values->find(identifier);
294570 if (lookup == values->end()) {
294571 break;
294572 }
294573 if (lookup->second.GetValue().type() != it.second->return_type) {
294574 return true;
294575 }
294576 }
294577 // Check the catalog versions to ensure all catalog entries we rely on are current
294578 for (auto &it : properties.read_databases) {
294579 if (!CheckCatalogIdentity(context, it.first, it.second)) {
294580 return true;
294581 }
294582 }
294583 for (auto &it : properties.modified_databases) {
294584 if (!CheckCatalogIdentity(context, it.first, it.second.identity)) {
294585 return true;
294586 }
294587 }
294588 return false;
294589}
bound_parameter_map_t value_map
The map of parameter index to the actual value entry.
Definition duckdb.cpp:27591
unique_ptr< SQLStatement > unbound_statement
The unbound SQL statement that was prepared.
Definition duckdb.cpp:27577
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ Bind()

void duckdb::PreparedStatementData::Bind ( case_insensitive_map_t< BoundParameterData > values)

Bind a set of values to the prepared statement data.

294591 {
294592 // set parameters
294593 D_ASSERT(!unbound_statement || unbound_statement->named_param_map.size() == properties.parameter_count);
294594 CheckParameterCount(values.size());
294595
294596 // bind the required values
294597 for (auto &it : value_map) {
294598 const string &identifier = it.first;
294599 auto lookup = values.find(identifier);
294600 if (lookup == values.end()) {
294601 throw BinderException("Could not find parameter with identifier %s", identifier);
294602 }
294603 D_ASSERT(it.second);
294604 auto value = lookup->second.GetValue();
294605 if (!value.DefaultTryCastAs(it.second->return_type)) {
294606 throw BinderException(
294607 "Type mismatch for binding parameter with identifier %s, expected type %s but got type %s", identifier,
294608 it.second->return_type.ToString().c_str(), value.type().ToString().c_str());
294609 }
294610 it.second->SetValue(std::move(value));
294611 }
294612}

◆ GetType()

LogicalType duckdb::PreparedStatementData::GetType ( const string & identifier)

Get the expected SQL Type of the bound parameter.

294627 {
294628 LogicalType result;
294629 if (!TryGetType(identifier, result)) {
294630 throw BinderException("Could not find parameter identified with: %s", identifier);
294631 }
294632 return result;
294633}
DUCKDB_API bool TryGetType(const string &identifier, LogicalType &result)
Try to get the expected SQL Type of the bound parameter.
Definition duckdb.cpp:294614
Here is the call graph for this function:

◆ TryGetType()

bool duckdb::PreparedStatementData::TryGetType ( const string & identifier,
LogicalType & result )

Try to get the expected SQL Type of the bound parameter.

294614 {
294615 auto it = value_map.find(identifier);
294616 if (it == value_map.end()) {
294617 return false;
294618 }
294619 if (it->second->return_type.id() != LogicalTypeId::INVALID) {
294620 result = it->second->return_type;
294621 } else {
294622 result = it->second->GetValue().type();
294623 }
294624 return true;
294625}
Here is the caller graph for this function:

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