21class ExpressionBinder;
30struct ExtensionOptions;
37class AttachedKuzuDatabase;
53 friend class binder::Binder;
54 friend class binder::ExpressionBinder;
68 void interrupt() { activeQuery.interrupted =
true; }
70 bool hasTimeout()
const {
return clientConfig.timeoutInMS != 0; }
90 std::unique_ptr<function::ScanReplacementData>
tryReplace(
const std::string& objectName)
const;
113 std::unique_ptr<PreparedStatement>
prepare(std::string_view query);
115 std::unordered_map<std::string, std::unique_ptr<common::Value>> inputParams,
116 std::optional<uint64_t> queryID = std::nullopt);
117 std::unique_ptr<QueryResult>
query(std::string_view queryStatement,
118 std::optional<uint64_t> queryID = std::nullopt);
122 std::unique_ptr<PreparedStatement>
prepareTest(std::string_view query);
124 std::vector<std::shared_ptr<parser::Statement>>
parseQuery(std::string_view query);
136 std::unique_ptr<QueryResult> query(std::string_view query, std::string_view encodedJoin,
137 bool enumerateAllPlans =
true, std::optional<uint64_t> queryID = std::nullopt);
139 std::unique_ptr<QueryResult> queryResultWithError(std::string_view errMsg);
141 std::unique_ptr<PreparedStatement> preparedStatementWithError(std::string_view errMsg);
147 std::unique_ptr<PreparedStatement> prepareNoLock(
148 std::shared_ptr<parser::Statement> parsedStatement,
bool enumerateAllPlans =
false,
149 std::string_view joinOrder = std::string_view(),
bool requireNewTx =
true,
150 std::optional<std::unordered_map<std::string, std::shared_ptr<common::Value>>> inputParams =
153 template<
typename T,
typename... Args>
154 std::unique_ptr<QueryResult> executeWithParams(
PreparedStatement* preparedStatement,
155 std::unordered_map<std::string, std::unique_ptr<common::Value>> params,
156 std::pair<std::string, T> arg, std::pair<std::string, Args>... args) {
157 auto name = arg.first;
158 auto val = std::make_unique<common::Value>((T)arg.second);
159 params.insert({name, std::move(val)});
160 return executeWithParams(preparedStatement, std::move(params), args...);
163 void bindParametersNoLock(PreparedStatement* preparedStatement,
164 const std::unordered_map<std::string, std::unique_ptr<common::Value>>& inputParams);
166 std::unique_ptr<QueryResult> executeAndAutoCommitIfNecessaryNoLock(
167 PreparedStatement* preparedStatement, uint32_t planIdx = 0u,
168 std::optional<uint64_t> queryID = std::nullopt);
170 bool canExecuteWriteQuery();
173 ClientConfig clientConfig;
177 ActiveQuery activeQuery;
179 std::unique_ptr<transaction::TransactionContext> transactionContext;
181 std::vector<function::ScanReplacement> scanReplacements;
183 std::unordered_map<std::string, common::Value> extensionOptionValues;
185 std::unique_ptr<common::RandomEngine> randomEngine;
187 Database* localDatabase;
189 AttachedKuzuDatabase* remoteDatabase;
191 std::unique_ptr<common::ProgressBar> progressBar;
#define KUZU_API
Definition api.h:25
Progress bar for tracking the progress of a pipeline. Prints the progress of each query pipeline and ...
Definition progress_bar.h:18
Contain client side configuration. We make profiler associated per query, so profiler is not maintain...
Definition client_context.h:51
std::unique_ptr< QueryResult > query(std::string_view queryStatement, std::optional< uint64_t > queryID=std::nullopt)
common::VirtualFileSystem * getVFSUnsafe() const
Database * getDatabase() const
Definition client_context.h:101
ClientConfig * getClientConfigUnsafe()
Definition client_context.h:62
common::RandomEngine * getRandomEngine()
storage::StorageManager * getStorageManager() const
common::ProgressBar * getProgressBar() const
common::Value getCurrentSetting(const std::string &optionName)
void runQuery(std::string query)
std::unique_ptr< PreparedStatement > prepare(std::string_view query)
common::TaskScheduler * getTaskScheduler() const
const ClientConfig * getClientConfig() const
Definition client_context.h:61
uint64_t getMaxNumThreadForExec() const
void setMaxNumThreadForExec(uint64_t numThreads)
uint64_t getTimeoutRemainingInMS() const
std::string getEnvVariable(const std::string &name)
std::unique_ptr< PreparedStatement > prepareTest(std::string_view query)
catalog::Catalog * getCatalog() const
extension::ExtensionOptions * getExtensionOptions() const
uint64_t getQueryTimeOut() const
DBConfig * getDBConfigUnsafe()
Definition client_context.h:64
void addScalarFunction(std::string name, function::function_set definitions)
std::string getDatabasePath() const
void runFuncInTransaction(const std::function< void(void)> &fun)
std::vector< std::shared_ptr< parser::Statement > > parseQuery(std::string_view query)
bool isOptionSet(const std::string &optionName) const
bool interrupted() const
Definition client_context.h:69
void removeScalarFunction(std::string name)
void addScanReplace(function::ScanReplacement scanReplacement)
void interrupt()
Definition client_context.h:68
const DBConfig * getDBConfig() const
Definition client_context.h:63
std::unique_ptr< function::ScanReplacementData > tryReplace(const std::string &objectName) const
std::unique_ptr< QueryResult > executeWithParams(PreparedStatement *preparedStatement, std::unordered_map< std::string, std::unique_ptr< common::Value > > inputParams, std::optional< uint64_t > queryID=std::nullopt)
void setDefaultDatabase(AttachedKuzuDatabase *defaultDatabase_)
void setQueryTimeOut(uint64_t timeoutInMS)
transaction::TransactionContext * getTransactionContext() const
storage::MemoryManager * getMemoryManager()
DatabaseManager * getDatabaseManager() const
bool hasDefaultDatabase()
transaction::Transaction * getTx() const
storage::WAL * getWAL() const
std::string getExtensionDir() const
transaction::TransactionManager * getTransactionManagerUnsafe() const
void resetActiveQuery()
Definition client_context.h:75
ClientContext(Database *database)
void setExtensionOption(std::string name, common::Value value)
bool hasTimeout() const
Definition client_context.h:70
Connection is used to interact with a Database instance. Each Connection is thread-safe....
Definition connection.h:14
Database class is the main class of KùzuDB. It manages all database components.
Definition database.h:81
A prepared statement is a parameterized query which can avoid planning the same query for repeated ex...
Definition prepared_statement.h:20
Definition transaction_context.h:32
Definition transaction.h:28
std::vector< std::unique_ptr< Function > > function_set
Definition function.h:43
Definition alter_type.h:5
Definition scan_replacement.h:16
Definition client_context.h:39
std::atomic< bool > interrupted
Definition client_context.h:41
common::Timer timer
Definition client_context.h:42
Definition client_config.h:11
Definition db_config.h:53