21class ExpressionBinder;
31struct ExtensionOptions;
42class AttachedKuzuDatabase;
43struct SpillToDiskSetting;
59 friend class binder::Binder;
60 friend class binder::ExpressionBinder;
61 friend class processor::ImportDB;
62 friend struct main::SpillToDiskSetting;
76 void interrupt() { activeQuery.interrupted =
true; }
78 bool hasTimeout()
const {
return clientConfig.timeoutInMS != 0; }
98 std::unique_ptr<function::ScanReplacementData>
tryReplace(
const std::string& objectName)
const;
121 std::unique_ptr<PreparedStatement>
prepare(std::string_view query);
123 std::unordered_map<std::string, std::unique_ptr<common::Value>> inputParams,
124 std::optional<uint64_t> queryID = std::nullopt);
125 std::unique_ptr<QueryResult>
query(std::string_view queryStatement,
126 std::optional<uint64_t> queryID = std::nullopt);
129 std::vector<std::shared_ptr<parser::Statement>>
parseQuery(std::string_view query);
143 std::unique_ptr<QueryResult> queryInternal(std::string_view query, std::string_view encodedJoin,
144 bool enumerateAllPlans =
true, std::optional<uint64_t> queryID = std::nullopt);
146 std::unique_ptr<QueryResult> queryResultWithError(std::string_view errMsg);
148 std::unique_ptr<PreparedStatement> preparedStatementWithError(std::string_view errMsg);
154 std::unique_ptr<PreparedStatement> prepareNoLock(
155 std::shared_ptr<parser::Statement> parsedStatement,
bool enumerateAllPlans =
false,
156 std::string_view joinOrder = std::string_view(),
bool requireNewTx =
true,
157 std::optional<std::unordered_map<std::string, std::shared_ptr<common::Value>>> inputParams =
160 template<
typename T,
typename... Args>
161 std::unique_ptr<QueryResult> executeWithParams(
PreparedStatement* preparedStatement,
162 std::unordered_map<std::string, std::unique_ptr<common::Value>> params,
163 std::pair<std::string, T> arg, std::pair<std::string, Args>... args) {
164 auto name = arg.first;
165 auto val = std::make_unique<common::Value>((T)arg.second);
166 params.insert({name, std::move(val)});
167 return executeWithParams(preparedStatement, std::move(params), args...);
170 void bindParametersNoLock(PreparedStatement* preparedStatement,
171 const std::unordered_map<std::string, std::unique_ptr<common::Value>>& inputParams);
173 std::unique_ptr<QueryResult> executeNoLock(PreparedStatement* preparedStatement,
174 uint32_t planIdx = 0u, std::optional<uint64_t> queryID = std::nullopt);
176 bool canExecuteWriteQuery();
178 void runFuncInTransaction(
const std::function<
void(
void)>& fun);
181 ClientConfig clientConfig;
185 ActiveQuery activeQuery;
187 std::unique_ptr<transaction::TransactionContext> transactionContext;
189 std::vector<function::ScanReplacement> scanReplacements;
191 std::unordered_map<std::string, common::Value> extensionOptionValues;
193 std::unique_ptr<common::RandomEngine> randomEngine;
195 Database* localDatabase;
197 AttachedKuzuDatabase* remoteDatabase;
199 std::unique_ptr<common::ProgressBar> progressBar;
#define KUZU_API
Definition api.h:25
Contain client side configuration. We make profiler associated per query, so profiler is not maintain...
Definition client_context.h:57
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:109
ClientConfig * getClientConfigUnsafe()
Definition client_context.h:70
processor::WarningContext & getWarningContextUnsafe()
common::RandomEngine * getRandomEngine()
storage::StorageManager * getStorageManager() const
common::ProgressBar * getProgressBar() const
common::Value getCurrentSetting(const std::string &optionName)
std::unique_ptr< PreparedStatement > prepare(std::string_view query)
common::TaskScheduler * getTaskScheduler() const
const ClientConfig * getClientConfig() const
Definition client_context.h:69
uint64_t getMaxNumThreadForExec() const
void setMaxNumThreadForExec(uint64_t numThreads)
uint64_t getTimeoutRemainingInMS() const
std::string getEnvVariable(const std::string &name)
catalog::Catalog * getCatalog() const
extension::ExtensionOptions * getExtensionOptions() const
uint64_t getQueryTimeOut() const
DBConfig * getDBConfigUnsafe()
Definition client_context.h:72
void addScalarFunction(std::string name, function::function_set definitions)
std::string getDatabasePath() const
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:77
void removeScalarFunction(std::string name)
void addScanReplace(function::ScanReplacement scanReplacement)
void interrupt()
Definition client_context.h:76
const DBConfig * getDBConfig() const
Definition client_context.h:71
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)
const processor::WarningContext & getWarningContext() const
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:83
ClientContext(Database *database)
void setExtensionOption(std::string name, common::Value value)
bool hasTimeout() const
Definition client_context.h:78
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 warning_context.h:35
Definition transaction_context.h:32
Definition transaction.h:30
std::vector< std::unique_ptr< Function > > function_set
Definition function.h:43
Definition array_utils.h:7
Definition scan_replacement.h:16
Definition client_context.h:45
std::atomic< bool > interrupted
Definition client_context.h:47
common::Timer timer
Definition client_context.h:48
Definition client_config.h:26
Definition db_config.h:53