Kuzu C++ API
Loading...
Searching...
No Matches
prepared_statement.h
Go to the documentation of this file.
1#pragma once
2
3#include <memory>
4#include <string>
5#include <unordered_map>
6#include <vector>
7
8#include "api.h"
9#include "query_summary.h"
10
11namespace kuzu {
12namespace common {
13class LogicalType;
14}
15namespace parser {
16class Statement;
17}
18
19namespace main {
20
21// Prepared statement cached in client context and NEVER serialized to client side.
24 std::shared_ptr<parser::Statement> parsedStatement;
25 std::unique_ptr<planner::LogicalPlan> logicalPlan;
26 std::vector<std::shared_ptr<binder::Expression>> columns;
27
30
31 std::vector<std::string> getColumnNames() const;
32 std::vector<common::LogicalType> getColumnTypes() const;
33};
34
40 friend class Connection;
41 friend class ClientContext;
42 friend class testing::TestHelper;
43 friend class testing::TestRunner;
44
45public:
50 KUZU_API bool isSuccess() const;
54 KUZU_API std::string getErrorMessage() const;
58 KUZU_API bool isReadOnly() const;
59
60 std::unordered_map<std::string, std::shared_ptr<common::Value>>& getParameterMapUnsafe() {
61 return parameterMap;
62 }
63
64 std::string getName() const { return cachedPreparedStatementName; }
65
67
68 void validateExecuteParam(const std::string& paramName, common::Value* param) const;
69
70 static std::unique_ptr<PreparedStatement> getPreparedStatementWithError(
71 const std::string& errorMessage);
72
73private:
74 bool success = true;
75 bool readOnly = true;
76 std::string errMsg;
77 PreparedSummary preparedSummary;
78 std::string cachedPreparedStatementName;
79 std::unordered_map<std::string, std::shared_ptr<common::Value>> parameterMap;
80};
81
82} // namespace main
83} // namespace kuzu
#define KUZU_API
Definition api.h:25
Definition types.h:256
Definition value.h:26
A prepared statement is a parameterized query which can avoid planning the same query for repeated ex...
Definition prepared_statement.h:39
void validateExecuteParam(const std::string &paramName, common::Value *param) const
KUZU_API bool isReadOnly() const
friend class testing::TestRunner
Definition prepared_statement.h:43
friend class Connection
Definition prepared_statement.h:40
friend class testing::TestHelper
Definition prepared_statement.h:42
KUZU_API bool isSuccess() const
std::unordered_map< std::string, std::shared_ptr< common::Value > > & getParameterMapUnsafe()
Definition prepared_statement.h:60
KUZU_API std::string getErrorMessage() const
common::StatementType getStatementType() const
static std::unique_ptr< PreparedStatement > getPreparedStatementWithError(const std::string &errorMessage)
std::string getName() const
Definition prepared_statement.h:64
friend class ClientContext
Definition prepared_statement.h:41
Definition statement.h:9
Definition array_utils.h:7
StatementType
Definition statement_type.h:8
Definition bind_input.h:16
Definition client_context.h:20
Definition array_utils.h:7
std::unique_ptr< planner::LogicalPlan > logicalPlan
Definition prepared_statement.h:25
std::shared_ptr< parser::Statement > parsedStatement
Definition prepared_statement.h:24
bool useInternalCatalogEntry
Definition prepared_statement.h:23
std::vector< std::string > getColumnNames() const
std::vector< common::LogicalType > getColumnTypes() const
std::vector< std::shared_ptr< binder::Expression > > columns
Definition prepared_statement.h:26
PreparedSummary stores the compiling time and query options of a query.
Definition query_summary.h:12