1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/main/stream_query_result.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/common/winapi.hpp"
12#include "duckdb/main/query_result.hpp"
13
14namespace duckdb {
15
16class ClientContext;
17class ClientContextLock;
18class Executor;
19class MaterializedQueryResult;
20class PreparedStatementData;
21
22class StreamQueryResult : public QueryResult {
23 friend class ClientContext;
24
25public:
26 static constexpr const QueryResultType TYPE = QueryResultType::STREAM_RESULT;
27
28public:
29 //! Create a successful StreamQueryResult. StreamQueryResults should always be successful initially (it makes no
30 //! sense to stream an error).
31 DUCKDB_API StreamQueryResult(StatementType statement_type, StatementProperties properties,
32 shared_ptr<ClientContext> context, vector<LogicalType> types, vector<string> names);
33 DUCKDB_API ~StreamQueryResult() override;
34
35public:
36 //! Fetches a DataChunk from the query result.
37 DUCKDB_API unique_ptr<DataChunk> FetchRaw() override;
38 //! Converts the QueryResult to a string
39 DUCKDB_API string ToString() override;
40 //! Materializes the query result and turns it into a materialized query result
41 DUCKDB_API unique_ptr<MaterializedQueryResult> Materialize();
42
43 DUCKDB_API bool IsOpen();
44
45 //! Closes the StreamQueryResult
46 DUCKDB_API void Close();
47
48 //! The client context this StreamQueryResult belongs to
49 shared_ptr<ClientContext> context;
50
51private:
52 unique_ptr<ClientContextLock> LockContext();
53 void CheckExecutableInternal(ClientContextLock &lock);
54 bool IsOpenInternal(ClientContextLock &lock);
55};
56
57} // namespace duckdb
58