21class ExpressionBinder;
31struct ExtensionOptions;
46class AttachedKuzuDatabase;
47struct SpillToDiskSetting;
63 friend class binder::Binder;
64 friend class binder::ExpressionBinder;
65 friend class processor::ImportDB;
66 friend struct main::SpillToDiskSetting;
80 void interrupt() { activeQuery.interrupted =
true; }
82 bool hasTimeout()
const {
return clientConfig.timeoutInMS != 0; }
102 std::unique_ptr<function::ScanReplacementData>
tryReplace(
const std::string& objectName)
const;
125 std::unique_ptr<PreparedStatement>
prepare(std::string_view query);
127 std::unordered_map<std::string, std::unique_ptr<common::Value>> inputParams,
128 std::optional<uint64_t> queryID = std::nullopt);
129 std::unique_ptr<QueryResult>
query(std::string_view queryStatement,
130 std::optional<uint64_t> queryID = std::nullopt);
133 std::vector<std::shared_ptr<parser::Statement>>
parseQuery(std::string_view query);
148 std::unique_ptr<QueryResult>
queryInternal(std::string_view query, std::string_view encodedJoin,
149 bool enumerateAllPlans =
true, std::optional<uint64_t> queryID = std::nullopt);
152 std::unique_ptr<QueryResult> queryResultWithError(std::string_view errMsg);
154 std::unique_ptr<PreparedStatement> preparedStatementWithError(std::string_view errMsg);
160 std::unique_ptr<PreparedStatement> prepareNoLock(
161 std::shared_ptr<parser::Statement> parsedStatement,
bool enumerateAllPlans =
false,
162 std::string_view joinOrder = std::string_view(),
bool requireNewTx =
true,
163 std::optional<std::unordered_map<std::string, std::shared_ptr<common::Value>>> inputParams =
166 template<
typename T,
typename... Args>
167 std::unique_ptr<QueryResult> executeWithParams(
PreparedStatement* preparedStatement,
168 std::unordered_map<std::string, std::unique_ptr<common::Value>> params,
169 std::pair<std::string, T> arg, std::pair<std::string, Args>... args) {
170 auto name = arg.first;
171 auto val = std::make_unique<common::Value>((T)arg.second);
172 params.insert({name, std::move(val)});
173 return executeWithParams(preparedStatement, std::move(params), args...);
176 void bindParametersNoLock(PreparedStatement* preparedStatement,
177 const std::unordered_map<std::string, std::unique_ptr<common::Value>>& inputParams);
179 std::unique_ptr<QueryResult> executeNoLock(PreparedStatement* preparedStatement,
180 uint32_t planIdx = 0u, std::optional<uint64_t> queryID = std::nullopt);
182 bool canExecuteWriteQuery();
184 void runFuncInTransaction(
const std::function<
void(
void)>& fun);
187 ClientConfig clientConfig;
191 ActiveQuery activeQuery;
193 std::unique_ptr<transaction::TransactionContext> transactionContext;
195 std::vector<function::ScanReplacement> scanReplacements;
197 std::unordered_map<std::string, common::Value> extensionOptionValues;
199 std::unique_ptr<common::RandomEngine> randomEngine;
201 Database* localDatabase;
203 AttachedKuzuDatabase* remoteDatabase;
205 std::unique_ptr<common::ProgressBar> progressBar;
209 std::unique_ptr<graph::GraphEntrySet> graphEntrySet;
#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:61
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:113
ClientConfig * getClientConfigUnsafe()
Definition client_context.h:74
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:73
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:76
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:81
void removeScalarFunction(std::string name)
void addScanReplace(function::ScanReplacement scanReplacement)
void interrupt()
Definition client_context.h:80
const DBConfig * getDBConfig() const
Definition client_context.h:75
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)
std::unique_ptr< QueryResult > queryInternal(std::string_view query, std::string_view encodedJoin, bool enumerateAllPlans=true, 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:87
ClientContext(Database *database)
graph::GraphEntrySet & getGraphEntrySetUnsafe()
void setExtensionOption(std::string name, common::Value value)
bool hasTimeout() const
Definition client_context.h:82
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:31
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:49
std::atomic< bool > interrupted
Definition client_context.h:51
common::Timer timer
Definition client_context.h:52
Definition client_config.h:26
Definition db_config.h:53