duckdb 0.7.1-dev2.0 → 0.7.1-dev240.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +7 -7
- package/package.json +1 -1
- package/src/duckdb/extension/json/buffered_json_reader.cpp +50 -9
- package/src/duckdb/extension/json/include/buffered_json_reader.hpp +7 -2
- package/src/duckdb/extension/json/include/json_common.hpp +2 -2
- package/src/duckdb/extension/json/include/json_scan.hpp +29 -10
- package/src/duckdb/extension/json/json_functions/copy_json.cpp +35 -22
- package/src/duckdb/extension/json/json_functions/json_create.cpp +8 -8
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +47 -8
- package/src/duckdb/extension/json/json_functions/read_json.cpp +104 -49
- package/src/duckdb/extension/json/json_functions/read_json_objects.cpp +5 -3
- package/src/duckdb/extension/json/json_functions.cpp +6 -0
- package/src/duckdb/extension/json/json_scan.cpp +144 -34
- package/src/duckdb/extension/parquet/parquet-extension.cpp +3 -2
- package/src/duckdb/src/common/enums/logical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/statement_type.cpp +2 -0
- package/src/duckdb/src/common/file_system.cpp +14 -0
- package/src/duckdb/src/common/hive_partitioning.cpp +1 -0
- package/src/duckdb/src/common/operator/cast_operators.cpp +14 -8
- package/src/duckdb/src/common/printer.cpp +1 -1
- package/src/duckdb/src/common/types/time.cpp +1 -1
- package/src/duckdb/src/common/types/timestamp.cpp +35 -4
- package/src/duckdb/src/common/types.cpp +36 -10
- package/src/duckdb/src/execution/column_binding_resolver.cpp +5 -2
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +7 -9
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +6 -11
- package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +13 -13
- package/src/duckdb/src/execution/operator/persistent/parallel_csv_reader.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +37 -0
- package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +0 -5
- package/src/duckdb/src/execution/physical_plan/plan_simple.cpp +4 -0
- package/src/duckdb/src/execution/physical_plan_generator.cpp +1 -0
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +36 -9
- package/src/duckdb/src/function/table/read_csv.cpp +15 -4
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +3 -2
- package/src/duckdb/src/include/duckdb/common/exception.hpp +10 -0
- package/src/duckdb/src/include/duckdb/common/file_system.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/hive_partitioning.hpp +9 -1
- package/src/duckdb/src/include/duckdb/common/radix_partitioning.hpp +4 -4
- package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +5 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/base_csv_reader.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +0 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_detach.hpp +32 -0
- package/src/duckdb/src/include/duckdb/main/client_data.hpp +2 -2
- package/src/duckdb/src/include/duckdb/main/config.hpp +0 -3
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_database_info.hpp +0 -4
- package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +32 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/select_node.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/sql_statement.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/statement/copy_statement.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/statement/detach_statement.hpp +29 -0
- package/src/duckdb/src/include/duckdb/parser/statement/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/statement/select_statement.hpp +3 -3
- package/src/duckdb/src/include/duckdb/parser/tableref/subqueryref.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_execute.hpp +1 -5
- package/src/duckdb/src/include/duckdb/planner/operator/logical_show.hpp +1 -2
- package/src/duckdb/src/include/duckdb/storage/storage_extension.hpp +7 -0
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +2 -0
- package/src/duckdb/src/main/client_context.cpp +2 -0
- package/src/duckdb/src/main/extension/extension_alias.cpp +2 -1
- package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +2 -6
- package/src/duckdb/src/parser/statement/copy_statement.cpp +2 -13
- package/src/duckdb/src/parser/statement/delete_statement.cpp +3 -0
- package/src/duckdb/src/parser/statement/detach_statement.cpp +15 -0
- package/src/duckdb/src/parser/statement/insert_statement.cpp +9 -0
- package/src/duckdb/src/parser/statement/update_statement.cpp +3 -0
- package/src/duckdb/src/parser/transform/expression/transform_case.cpp +3 -3
- package/src/duckdb/src/parser/transform/statement/transform_create_database.cpp +0 -1
- package/src/duckdb/src/parser/transform/statement/transform_detach.cpp +19 -0
- package/src/duckdb/src/parser/transformer.cpp +2 -0
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +3 -0
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +6 -3
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +16 -14
- package/src/duckdb/src/planner/binder/statement/bind_detach.cpp +19 -0
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +29 -4
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +22 -1
- package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +2 -1
- package/src/duckdb/src/planner/binder.cpp +2 -0
- package/src/duckdb/src/planner/expression_binder/lateral_binder.cpp +21 -5
- package/src/duckdb/src/planner/logical_operator.cpp +4 -0
- package/src/duckdb/src/planner/planner.cpp +1 -0
- package/src/duckdb/src/storage/storage_info.cpp +2 -1
- package/src/duckdb/src/storage/table/column_data.cpp +4 -2
- package/src/duckdb/src/storage/table/update_segment.cpp +15 -0
- package/src/duckdb/third_party/fmt/include/fmt/core.h +1 -2
- package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +1 -0
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +14 -0
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +530 -1006
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +17659 -17626
- package/src/duckdb/third_party/thrift/thrift/Thrift.h +8 -2
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +4 -4
- package/src/duckdb/ub_src_execution_operator_schema.cpp +2 -0
- package/src/duckdb/ub_src_parser_statement.cpp +2 -0
- package/src/duckdb/ub_src_parser_transform_statement.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_statement.cpp +2 -0
- package/src/duckdb/src/include/duckdb/function/create_database_extension.hpp +0 -37
|
@@ -43,11 +43,12 @@ enum class StatementType : uint8_t {
|
|
|
43
43
|
RELATION_STATEMENT,
|
|
44
44
|
EXTENSION_STATEMENT,
|
|
45
45
|
LOGICAL_PLAN_STATEMENT,
|
|
46
|
-
ATTACH_STATEMENT
|
|
46
|
+
ATTACH_STATEMENT,
|
|
47
|
+
DETACH_STATEMENT
|
|
47
48
|
|
|
48
49
|
};
|
|
49
50
|
|
|
50
|
-
string StatementTypeToString(StatementType type);
|
|
51
|
+
DUCKDB_API string StatementTypeToString(StatementType type);
|
|
51
52
|
|
|
52
53
|
enum class StatementReturnType : uint8_t {
|
|
53
54
|
QUERY_RESULT, // the statement returns a query result (e.g. for display to the user)
|
|
@@ -262,6 +262,16 @@ public:
|
|
|
262
262
|
}
|
|
263
263
|
};
|
|
264
264
|
|
|
265
|
+
class MissingExtensionException : public IOException {
|
|
266
|
+
public:
|
|
267
|
+
DUCKDB_API explicit MissingExtensionException(const string &msg);
|
|
268
|
+
|
|
269
|
+
template <typename... Args>
|
|
270
|
+
explicit MissingExtensionException(const string &msg, Args... params)
|
|
271
|
+
: IOException(ConstructMessage(msg, params...)) {
|
|
272
|
+
}
|
|
273
|
+
};
|
|
274
|
+
|
|
265
275
|
class SerializationException : public Exception {
|
|
266
276
|
public:
|
|
267
277
|
DUCKDB_API explicit SerializationException(const string &msg);
|
|
@@ -201,6 +201,7 @@ public:
|
|
|
201
201
|
|
|
202
202
|
//! Whether or not a sub-system can handle a specific file path
|
|
203
203
|
DUCKDB_API virtual bool CanHandleFile(const string &fpath);
|
|
204
|
+
DUCKDB_API static IOException MissingFileException(const string &file_path, ClientContext &context);
|
|
204
205
|
|
|
205
206
|
//! Set the file pointer of a file handle to a specified location. Reads and writes will happen from this location
|
|
206
207
|
DUCKDB_API virtual void Seek(FileHandle &handle, idx_t location);
|
|
@@ -52,7 +52,15 @@ struct HivePartitionKey {
|
|
|
52
52
|
|
|
53
53
|
struct Equality {
|
|
54
54
|
bool operator()(const HivePartitionKey &a, const HivePartitionKey &b) const {
|
|
55
|
-
|
|
55
|
+
if (a.values.size() != b.values.size()) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
for (idx_t i = 0; i < a.values.size(); i++) {
|
|
59
|
+
if (!Value::NotDistinctFrom(a.values[i], b.values[i])) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
56
64
|
}
|
|
57
65
|
};
|
|
58
66
|
};
|
|
@@ -78,13 +78,13 @@ protected:
|
|
|
78
78
|
case 2:
|
|
79
79
|
case 3:
|
|
80
80
|
case 4:
|
|
81
|
-
return GetBufferSize(1);
|
|
81
|
+
return GetBufferSize(1 << 1);
|
|
82
82
|
case 5:
|
|
83
|
-
return GetBufferSize(2);
|
|
83
|
+
return GetBufferSize(1 << 2);
|
|
84
84
|
case 6:
|
|
85
|
-
return GetBufferSize(3);
|
|
85
|
+
return GetBufferSize(1 << 3);
|
|
86
86
|
default:
|
|
87
|
-
return GetBufferSize(4);
|
|
87
|
+
return GetBufferSize(1 << 4);
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
void InitializeAppendStateInternal(PartitionedColumnDataAppendState &state) const override;
|
|
@@ -93,6 +93,8 @@ struct timestamp_ns_t : public timestamp_t {}; // NOLINT
|
|
|
93
93
|
struct timestamp_ms_t : public timestamp_t {}; // NOLINT
|
|
94
94
|
struct timestamp_sec_t : public timestamp_t {}; // NOLINT
|
|
95
95
|
|
|
96
|
+
enum class TimestampCastResult : uint8_t { SUCCESS, ERROR_INCORRECT_FORMAT, ERROR_NON_UTC_TIMEZONE };
|
|
97
|
+
|
|
96
98
|
//! The Timestamp class is a static class that holds helper functions for the Timestamp
|
|
97
99
|
//! type.
|
|
98
100
|
class Timestamp {
|
|
@@ -110,7 +112,7 @@ public:
|
|
|
110
112
|
//! If the tz is not empty, the result is still an instant, but the parts can be extracted and applied to the TZ
|
|
111
113
|
DUCKDB_API static bool TryConvertTimestampTZ(const char *str, idx_t len, timestamp_t &result, bool &has_offset,
|
|
112
114
|
string_t &tz);
|
|
113
|
-
DUCKDB_API static
|
|
115
|
+
DUCKDB_API static TimestampCastResult TryConvertTimestamp(const char *str, idx_t len, timestamp_t &result);
|
|
114
116
|
DUCKDB_API static timestamp_t FromCString(const char *str, idx_t len);
|
|
115
117
|
//! Convert a date object to a string in the format "YYYY-MM-DD hh:mm:ss"
|
|
116
118
|
DUCKDB_API static string ToString(timestamp_t timestamp);
|
|
@@ -161,6 +163,8 @@ public:
|
|
|
161
163
|
|
|
162
164
|
DUCKDB_API static string ConversionError(const string &str);
|
|
163
165
|
DUCKDB_API static string ConversionError(string_t str);
|
|
166
|
+
DUCKDB_API static string UnsupportedTimezoneError(const string &str);
|
|
167
|
+
DUCKDB_API static string UnsupportedTimezoneError(string_t str);
|
|
164
168
|
};
|
|
165
169
|
|
|
166
170
|
} // namespace duckdb
|
|
@@ -35,11 +35,9 @@ class BaseCSVReader {
|
|
|
35
35
|
public:
|
|
36
36
|
BaseCSVReader(ClientContext &context, BufferedCSVReaderOptions options,
|
|
37
37
|
const vector<LogicalType> &requested_types = vector<LogicalType>());
|
|
38
|
-
|
|
39
|
-
BaseCSVReader(FileSystem &fs, Allocator &allocator, FileOpener *opener, BufferedCSVReaderOptions options,
|
|
40
|
-
const vector<LogicalType> &requested_types = vector<LogicalType>());
|
|
41
38
|
~BaseCSVReader();
|
|
42
39
|
|
|
40
|
+
ClientContext &context;
|
|
43
41
|
FileSystem &fs;
|
|
44
42
|
Allocator &allocator;
|
|
45
43
|
FileOpener *opener;
|
|
@@ -55,8 +55,6 @@ class BufferedCSVReader : public BaseCSVReader {
|
|
|
55
55
|
public:
|
|
56
56
|
BufferedCSVReader(ClientContext &context, BufferedCSVReaderOptions options,
|
|
57
57
|
const vector<LogicalType> &requested_types = vector<LogicalType>());
|
|
58
|
-
BufferedCSVReader(FileSystem &fs, Allocator &allocator, FileOpener *opener, BufferedCSVReaderOptions options,
|
|
59
|
-
const vector<LogicalType> &requested_types = vector<LogicalType>());
|
|
60
58
|
BufferedCSVReader(ClientContext &context, string filename, BufferedCSVReaderOptions options,
|
|
61
59
|
const vector<LogicalType> &requested_types = vector<LogicalType>());
|
|
62
60
|
~BufferedCSVReader();
|
|
@@ -75,6 +75,8 @@ struct BufferedCSVReaderOptions {
|
|
|
75
75
|
case_insensitive_map_t<idx_t> sql_types_per_column;
|
|
76
76
|
//! User-defined SQL type list
|
|
77
77
|
vector<LogicalType> sql_type_list;
|
|
78
|
+
//! User-defined name list
|
|
79
|
+
vector<string> name_list;
|
|
78
80
|
//===--------------------------------------------------------------------===//
|
|
79
81
|
// ReadCSVOptions
|
|
80
82
|
//===--------------------------------------------------------------------===//
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
|
2
|
+
// DuckDB
|
|
3
|
+
//
|
|
4
|
+
// duckdb/execution/operator/schema/physical_detach.hpp
|
|
5
|
+
//
|
|
6
|
+
//
|
|
7
|
+
//===----------------------------------------------------------------------===//
|
|
8
|
+
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#include "duckdb/execution/physical_operator.hpp"
|
|
12
|
+
#include "duckdb/parser/parsed_data/detach_info.hpp"
|
|
13
|
+
|
|
14
|
+
namespace duckdb {
|
|
15
|
+
|
|
16
|
+
class PhysicalDetach : public PhysicalOperator {
|
|
17
|
+
public:
|
|
18
|
+
explicit PhysicalDetach(unique_ptr<DetachInfo> info, idx_t estimated_cardinality)
|
|
19
|
+
: PhysicalOperator(PhysicalOperatorType::DETACH, {LogicalType::BOOLEAN}, estimated_cardinality),
|
|
20
|
+
info(std::move(info)) {
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
unique_ptr<DetachInfo> info;
|
|
24
|
+
|
|
25
|
+
public:
|
|
26
|
+
// Source interface
|
|
27
|
+
unique_ptr<GlobalSourceState> GetGlobalSourceState(ClientContext &context) const override;
|
|
28
|
+
void GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate,
|
|
29
|
+
LocalSourceState &lstate) const override;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
} // namespace duckdb
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
#include "duckdb/common/common.hpp"
|
|
12
12
|
#include "duckdb/common/enums/output_type.hpp"
|
|
13
13
|
#include "duckdb/common/types/value.hpp"
|
|
14
|
-
#include "duckdb/common/
|
|
14
|
+
#include "duckdb/common/case_insensitive_map.hpp"
|
|
15
15
|
#include "duckdb/common/atomic.hpp"
|
|
16
16
|
|
|
17
17
|
namespace duckdb {
|
|
@@ -39,7 +39,7 @@ struct ClientData {
|
|
|
39
39
|
//! The set of temporary objects that belong to this client
|
|
40
40
|
shared_ptr<AttachedDatabase> temporary_objects;
|
|
41
41
|
//! The set of bound prepared statements that belong to this client
|
|
42
|
-
|
|
42
|
+
case_insensitive_map_t<shared_ptr<PreparedStatementData>> prepared_statements;
|
|
43
43
|
|
|
44
44
|
//! The writer used to log queries (if logging is enabled)
|
|
45
45
|
unique_ptr<BufferedFileWriter> log_query_writer;
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
#include "duckdb/storage/compression/bitpacking.hpp"
|
|
26
26
|
#include "duckdb/function/cast/default_casts.hpp"
|
|
27
27
|
#include "duckdb/function/replacement_scan.hpp"
|
|
28
|
-
#include "duckdb/function/create_database_extension.hpp"
|
|
29
28
|
#include "duckdb/optimizer/optimizer_extension.hpp"
|
|
30
29
|
#include "duckdb/parser/parser_extension.hpp"
|
|
31
30
|
#include "duckdb/planner/operator_extension.hpp"
|
|
@@ -185,8 +184,6 @@ public:
|
|
|
185
184
|
vector<std::unique_ptr<OperatorExtension>> operator_extensions;
|
|
186
185
|
//! Extensions made to storage
|
|
187
186
|
case_insensitive_map_t<std::unique_ptr<StorageExtension>> storage_extensions;
|
|
188
|
-
//! Extensions made to binder to implement the create_database functionality
|
|
189
|
-
vector<CreateDatabaseExtension> create_database_extensions;
|
|
190
187
|
|
|
191
188
|
public:
|
|
192
189
|
DUCKDB_API static DBConfig &GetConfig(ClientContext &context);
|
|
@@ -16,9 +16,6 @@ struct CreateDatabaseInfo : public CreateInfo {
|
|
|
16
16
|
CreateDatabaseInfo() : CreateInfo(CatalogType::DATABASE_ENTRY) {
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
//! Extension name which creates databases
|
|
20
|
-
string extension_name;
|
|
21
|
-
|
|
22
19
|
//! Name of the database
|
|
23
20
|
string name;
|
|
24
21
|
|
|
@@ -29,7 +26,6 @@ public:
|
|
|
29
26
|
unique_ptr<CreateInfo> Copy() const override {
|
|
30
27
|
auto result = make_unique<CreateDatabaseInfo>();
|
|
31
28
|
CopyProperties(*result);
|
|
32
|
-
result->extension_name = extension_name;
|
|
33
29
|
result->name = name;
|
|
34
30
|
result->path = path;
|
|
35
31
|
return unique_ptr<CreateInfo>(result.release());
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
|
2
|
+
// DuckDB
|
|
3
|
+
//
|
|
4
|
+
// duckdb/parser/parsed_data/detach_info.hpp
|
|
5
|
+
//
|
|
6
|
+
//
|
|
7
|
+
//===----------------------------------------------------------------------===//
|
|
8
|
+
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#include "duckdb/parser/parsed_data/parse_info.hpp"
|
|
12
|
+
|
|
13
|
+
namespace duckdb {
|
|
14
|
+
|
|
15
|
+
struct DetachInfo : public ParseInfo {
|
|
16
|
+
DetachInfo() {
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
//! The alias of the attached database
|
|
20
|
+
string name;
|
|
21
|
+
//! Whether to throw an exception if alias is not found
|
|
22
|
+
bool if_exists;
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
unique_ptr<DetachInfo> Copy() const {
|
|
26
|
+
auto result = make_unique<DetachInfo>();
|
|
27
|
+
result->name = name;
|
|
28
|
+
result->if_exists = if_exists;
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
} // namespace duckdb
|
|
@@ -40,11 +40,11 @@ protected:
|
|
|
40
40
|
SQLStatement(const SQLStatement &other) = default;
|
|
41
41
|
|
|
42
42
|
public:
|
|
43
|
-
virtual string ToString() const {
|
|
43
|
+
DUCKDB_API virtual string ToString() const {
|
|
44
44
|
throw InternalException("ToString not supported for this type of SQLStatement: '%s'",
|
|
45
45
|
StatementTypeToString(type));
|
|
46
46
|
}
|
|
47
47
|
//! Create a copy of this SelectStatement
|
|
48
|
-
virtual unique_ptr<SQLStatement> Copy() const = 0;
|
|
48
|
+
DUCKDB_API virtual unique_ptr<SQLStatement> Copy() const = 0;
|
|
49
49
|
};
|
|
50
50
|
} // namespace duckdb
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
//===----------------------------------------------------------------------===//
|
|
2
|
+
// DuckDB
|
|
3
|
+
//
|
|
4
|
+
// duckdb/parser/statement/detach_statement.hpp
|
|
5
|
+
//
|
|
6
|
+
//
|
|
7
|
+
//===----------------------------------------------------------------------===//
|
|
8
|
+
|
|
9
|
+
#pragma once
|
|
10
|
+
|
|
11
|
+
#include "duckdb/parser/parsed_data/detach_info.hpp"
|
|
12
|
+
#include "duckdb/parser/sql_statement.hpp"
|
|
13
|
+
|
|
14
|
+
namespace duckdb {
|
|
15
|
+
|
|
16
|
+
class DetachStatement : public SQLStatement {
|
|
17
|
+
public:
|
|
18
|
+
DetachStatement();
|
|
19
|
+
|
|
20
|
+
unique_ptr<DetachInfo> info;
|
|
21
|
+
|
|
22
|
+
protected:
|
|
23
|
+
DetachStatement(const DetachStatement &other);
|
|
24
|
+
|
|
25
|
+
public:
|
|
26
|
+
unique_ptr<SQLStatement> Copy() const override;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
} // namespace duckdb
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#include "duckdb/parser/statement/copy_statement.hpp"
|
|
5
5
|
#include "duckdb/parser/statement/create_statement.hpp"
|
|
6
6
|
#include "duckdb/parser/statement/delete_statement.hpp"
|
|
7
|
+
#include "duckdb/parser/statement/detach_statement.hpp"
|
|
7
8
|
#include "duckdb/parser/statement/drop_statement.hpp"
|
|
8
9
|
#include "duckdb/parser/statement/execute_statement.hpp"
|
|
9
10
|
#include "duckdb/parser/statement/explain_statement.hpp"
|
|
@@ -21,7 +21,7 @@ class QueryNode;
|
|
|
21
21
|
//! SelectStatement is a typical SELECT clause
|
|
22
22
|
class SelectStatement : public SQLStatement {
|
|
23
23
|
public:
|
|
24
|
-
SelectStatement() : SQLStatement(StatementType::SELECT_STATEMENT) {
|
|
24
|
+
DUCKDB_API SelectStatement() : SQLStatement(StatementType::SELECT_STATEMENT) {
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
//! The main query node
|
|
@@ -32,9 +32,9 @@ protected:
|
|
|
32
32
|
|
|
33
33
|
public:
|
|
34
34
|
//! Convert the SELECT statement to a string
|
|
35
|
-
string ToString() const override;
|
|
35
|
+
DUCKDB_API string ToString() const override;
|
|
36
36
|
//! Create a copy of this SelectStatement
|
|
37
|
-
unique_ptr<SQLStatement> Copy() const override;
|
|
37
|
+
DUCKDB_API unique_ptr<SQLStatement> Copy() const override;
|
|
38
38
|
//! Serializes a SelectStatement to a stand-alone binary blob
|
|
39
39
|
void Serialize(Serializer &serializer) const;
|
|
40
40
|
//! Deserializes a blob back into a SelectStatement, returns nullptr if
|
|
@@ -15,7 +15,7 @@ namespace duckdb {
|
|
|
15
15
|
//! Represents a subquery
|
|
16
16
|
class SubqueryRef : public TableRef {
|
|
17
17
|
public:
|
|
18
|
-
explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
|
|
18
|
+
DUCKDB_API explicit SubqueryRef(unique_ptr<SelectStatement> subquery, string alias = string());
|
|
19
19
|
|
|
20
20
|
//! The subquery
|
|
21
21
|
unique_ptr<SelectStatement> subquery;
|
|
@@ -156,6 +156,7 @@ private:
|
|
|
156
156
|
unique_ptr<SQLStatement> TransformShow(duckdb_libpgquery::PGNode *node);
|
|
157
157
|
unique_ptr<ShowStatement> TransformShowSelect(duckdb_libpgquery::PGNode *node);
|
|
158
158
|
unique_ptr<AttachStatement> TransformAttach(duckdb_libpgquery::PGNode *node);
|
|
159
|
+
unique_ptr<DetachStatement> TransformDetach(duckdb_libpgquery::PGNode *node);
|
|
159
160
|
unique_ptr<SetStatement> TransformUse(duckdb_libpgquery::PGNode *node);
|
|
160
161
|
|
|
161
162
|
unique_ptr<PrepareStatement> TransformPrepare(duckdb_libpgquery::PGNode *node);
|
|
@@ -247,6 +247,7 @@ private:
|
|
|
247
247
|
BoundStatement Bind(LoadStatement &stmt);
|
|
248
248
|
BoundStatement Bind(LogicalPlanStatement &stmt);
|
|
249
249
|
BoundStatement Bind(AttachStatement &stmt);
|
|
250
|
+
BoundStatement Bind(DetachStatement &stmt);
|
|
250
251
|
|
|
251
252
|
BoundStatement BindReturning(vector<unique_ptr<ParsedExpression>> returning_list, TableCatalogEntry *table,
|
|
252
253
|
idx_t update_table_index, unique_ptr<LogicalOperator> child_operator,
|
|
@@ -32,11 +32,7 @@ protected:
|
|
|
32
32
|
// already resolved
|
|
33
33
|
}
|
|
34
34
|
vector<ColumnBinding> GetColumnBindings() override {
|
|
35
|
-
|
|
36
|
-
for (idx_t i = 0; i < types.size(); i++) {
|
|
37
|
-
bindings.push_back(ColumnBinding(0, i));
|
|
38
|
-
}
|
|
39
|
-
return bindings;
|
|
35
|
+
return GenerateColumnBindings(0, types.size());
|
|
40
36
|
}
|
|
41
37
|
};
|
|
42
38
|
} // namespace duckdb
|
|
@@ -33,8 +33,7 @@ protected:
|
|
|
33
33
|
LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR};
|
|
34
34
|
}
|
|
35
35
|
vector<ColumnBinding> GetColumnBindings() override {
|
|
36
|
-
return
|
|
37
|
-
ColumnBinding(0, 3), ColumnBinding(0, 4), ColumnBinding(0, 5)};
|
|
36
|
+
return GenerateColumnBindings(0, types.size());
|
|
38
37
|
}
|
|
39
38
|
};
|
|
40
39
|
} // namespace duckdb
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
#include "duckdb/common/common.hpp"
|
|
12
12
|
#include "duckdb/common/enums/access_mode.hpp"
|
|
13
|
+
#include "duckdb/parser/tableref/table_function_ref.hpp"
|
|
13
14
|
|
|
14
15
|
namespace duckdb {
|
|
15
16
|
class AttachedDatabase;
|
|
@@ -27,11 +28,17 @@ typedef unique_ptr<Catalog> (*attach_function_t)(StorageExtensionInfo *storage_i
|
|
|
27
28
|
const string &name, AttachInfo &info, AccessMode access_mode);
|
|
28
29
|
typedef unique_ptr<TransactionManager> (*create_transaction_manager_t)(StorageExtensionInfo *storage_info,
|
|
29
30
|
AttachedDatabase &db, Catalog &catalog);
|
|
31
|
+
typedef unique_ptr<TableFunctionRef> (*create_database_t)(StorageExtensionInfo *info, ClientContext &context,
|
|
32
|
+
const string &database_name, const string &source_path);
|
|
33
|
+
typedef unique_ptr<TableFunctionRef> (*drop_database_t)(StorageExtensionInfo *storage_info, ClientContext &context,
|
|
34
|
+
const string &database_name);
|
|
30
35
|
|
|
31
36
|
class StorageExtension {
|
|
32
37
|
public:
|
|
33
38
|
attach_function_t attach;
|
|
34
39
|
create_transaction_manager_t create_transaction_manager;
|
|
40
|
+
create_database_t create_database;
|
|
41
|
+
drop_database_t drop_database;
|
|
35
42
|
|
|
36
43
|
//! Additional info passed to the various storage functions
|
|
37
44
|
shared_ptr<StorageExtensionInfo> storage_info;
|
|
@@ -23,6 +23,8 @@ struct UpdateNode;
|
|
|
23
23
|
class UpdateSegment {
|
|
24
24
|
public:
|
|
25
25
|
UpdateSegment(ColumnData &column_data);
|
|
26
|
+
// Construct a duplicate of 'other' with 'new_owner' as it's column data
|
|
27
|
+
UpdateSegment(UpdateSegment &other, ColumnData &new_owner);
|
|
26
28
|
~UpdateSegment();
|
|
27
29
|
|
|
28
30
|
ColumnData &column_data;
|
|
@@ -665,6 +665,7 @@ unique_ptr<PendingQueryResult> ClientContext::PendingStatementOrPreparedStatemen
|
|
|
665
665
|
statement = std::move(copied_statement);
|
|
666
666
|
break;
|
|
667
667
|
}
|
|
668
|
+
#ifndef DUCKDB_ALTERNATIVE_VERIFY
|
|
668
669
|
case StatementType::COPY_STATEMENT:
|
|
669
670
|
case StatementType::INSERT_STATEMENT:
|
|
670
671
|
case StatementType::DELETE_STATEMENT:
|
|
@@ -685,6 +686,7 @@ unique_ptr<PendingQueryResult> ClientContext::PendingStatementOrPreparedStatemen
|
|
|
685
686
|
statement = std::move(parser.statements[0]);
|
|
686
687
|
break;
|
|
687
688
|
}
|
|
689
|
+
#endif
|
|
688
690
|
default:
|
|
689
691
|
statement = std::move(copied_statement);
|
|
690
692
|
break;
|
|
@@ -24,8 +24,9 @@ ExtensionAlias ExtensionHelper::GetExtensionAlias(idx_t index) {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
string ExtensionHelper::ApplyExtensionAlias(string extension_name) {
|
|
27
|
+
auto lname = StringUtil::Lower(extension_name);
|
|
27
28
|
for (idx_t index = 0; internal_aliases[index].alias; index++) {
|
|
28
|
-
if (
|
|
29
|
+
if (lname == internal_aliases[index].alias) {
|
|
29
30
|
return internal_aliases[index].extension;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -83,12 +83,8 @@ void StatisticsPropagator::PropagateStatistics(LogicalComparisonJoin &join, uniq
|
|
|
83
83
|
*node_ptr = std::move(cross_product);
|
|
84
84
|
return;
|
|
85
85
|
}
|
|
86
|
-
case JoinType::INNER:
|
|
87
|
-
|
|
88
|
-
case JoinType::RIGHT:
|
|
89
|
-
case JoinType::OUTER: {
|
|
90
|
-
// inner/left/right/full outer join, replace with cross product
|
|
91
|
-
// since the condition is always true, left/right/outer join are equivalent to inner join here
|
|
86
|
+
case JoinType::INNER: {
|
|
87
|
+
// inner, replace with cross product
|
|
92
88
|
auto cross_product =
|
|
93
89
|
LogicalCrossProduct::Create(std::move(join.children[0]), std::move(join.children[1]));
|
|
94
90
|
*node_ptr = std::move(cross_product);
|
|
@@ -11,16 +11,6 @@ CopyStatement::CopyStatement(const CopyStatement &other) : SQLStatement(other),
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
string ConvertOptionValueToString(const Value &val) {
|
|
15
|
-
auto type = val.type().id();
|
|
16
|
-
switch (type) {
|
|
17
|
-
case LogicalTypeId::VARCHAR:
|
|
18
|
-
return KeywordHelper::WriteOptionallyQuoted(val.ToString());
|
|
19
|
-
default:
|
|
20
|
-
return val.ToString();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
14
|
string CopyStatement::CopyOptionsToString(const string &format,
|
|
25
15
|
const case_insensitive_map_t<vector<Value>> &options) const {
|
|
26
16
|
if (format.empty() && options.empty()) {
|
|
@@ -45,15 +35,14 @@ string CopyStatement::CopyOptionsToString(const string &format,
|
|
|
45
35
|
// Options like HEADER don't need an explicit value
|
|
46
36
|
// just providing the name already sets it to true
|
|
47
37
|
} else if (values.size() == 1) {
|
|
48
|
-
result +=
|
|
38
|
+
result += values[0].ToSQLString();
|
|
49
39
|
} else {
|
|
50
40
|
result += "( ";
|
|
51
41
|
for (idx_t i = 0; i < values.size(); i++) {
|
|
52
|
-
auto &value = values[i];
|
|
53
42
|
if (i) {
|
|
54
43
|
result += ", ";
|
|
55
44
|
}
|
|
56
|
-
result +=
|
|
45
|
+
result += values[i].ToSQLString();
|
|
57
46
|
}
|
|
58
47
|
result += " )";
|
|
59
48
|
}
|
|
@@ -13,6 +13,9 @@ DeleteStatement::DeleteStatement(const DeleteStatement &other) : SQLStatement(ot
|
|
|
13
13
|
for (const auto &using_clause : other.using_clauses) {
|
|
14
14
|
using_clauses.push_back(using_clause->Copy());
|
|
15
15
|
}
|
|
16
|
+
for (auto &expr : other.returning_list) {
|
|
17
|
+
returning_list.emplace_back(expr->Copy());
|
|
18
|
+
}
|
|
16
19
|
cte_map = other.cte_map.Copy();
|
|
17
20
|
}
|
|
18
21
|
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#include "duckdb/parser/statement/detach_statement.hpp"
|
|
2
|
+
|
|
3
|
+
namespace duckdb {
|
|
4
|
+
|
|
5
|
+
DetachStatement::DetachStatement() : SQLStatement(StatementType::DETACH_STATEMENT) {
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
DetachStatement::DetachStatement(const DetachStatement &other) : SQLStatement(other), info(other.info->Copy()) {
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
unique_ptr<SQLStatement> DetachStatement::Copy() const {
|
|
12
|
+
return unique_ptr<DetachStatement>(new DetachStatement(*this));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
} // namespace duckdb
|
|
@@ -13,6 +13,9 @@ OnConflictInfo::OnConflictInfo(const OnConflictInfo &other)
|
|
|
13
13
|
if (other.set_info) {
|
|
14
14
|
set_info = other.set_info->Copy();
|
|
15
15
|
}
|
|
16
|
+
if (other.condition) {
|
|
17
|
+
condition = other.condition->Copy();
|
|
18
|
+
}
|
|
16
19
|
}
|
|
17
20
|
|
|
18
21
|
unique_ptr<OnConflictInfo> OnConflictInfo::Copy() const {
|
|
@@ -28,6 +31,12 @@ InsertStatement::InsertStatement(const InsertStatement &other)
|
|
|
28
31
|
select_statement(unique_ptr_cast<SQLStatement, SelectStatement>(other.select_statement->Copy())),
|
|
29
32
|
columns(other.columns), table(other.table), schema(other.schema), catalog(other.catalog) {
|
|
30
33
|
cte_map = other.cte_map.Copy();
|
|
34
|
+
for (auto &expr : other.returning_list) {
|
|
35
|
+
returning_list.emplace_back(expr->Copy());
|
|
36
|
+
}
|
|
37
|
+
if (other.table_ref) {
|
|
38
|
+
table_ref = other.table_ref->Copy();
|
|
39
|
+
}
|
|
31
40
|
if (other.on_conflict_info) {
|
|
32
41
|
on_conflict_info = other.on_conflict_info->Copy();
|
|
33
42
|
}
|
|
@@ -27,6 +27,9 @@ UpdateStatement::UpdateStatement(const UpdateStatement &other)
|
|
|
27
27
|
if (other.from_table) {
|
|
28
28
|
from_table = other.from_table->Copy();
|
|
29
29
|
}
|
|
30
|
+
for (auto &expr : other.returning_list) {
|
|
31
|
+
returning_list.emplace_back(expr->Copy());
|
|
32
|
+
}
|
|
30
33
|
cte_map = other.cte_map.Copy();
|
|
31
34
|
}
|
|
32
35
|
|
|
@@ -9,16 +9,16 @@ unique_ptr<ParsedExpression> Transformer::TransformCase(duckdb_libpgquery::PGCas
|
|
|
9
9
|
D_ASSERT(root);
|
|
10
10
|
|
|
11
11
|
auto case_node = make_unique<CaseExpression>();
|
|
12
|
+
auto root_arg = TransformExpression(reinterpret_cast<duckdb_libpgquery::PGNode *>(root->arg));
|
|
12
13
|
for (auto cell = root->args->head; cell != nullptr; cell = cell->next) {
|
|
13
14
|
CaseCheck case_check;
|
|
14
15
|
|
|
15
16
|
auto w = reinterpret_cast<duckdb_libpgquery::PGCaseWhen *>(cell->data.ptr_value);
|
|
16
17
|
auto test_raw = TransformExpression(reinterpret_cast<duckdb_libpgquery::PGNode *>(w->expr));
|
|
17
18
|
unique_ptr<ParsedExpression> test;
|
|
18
|
-
|
|
19
|
-
if (arg) {
|
|
19
|
+
if (root_arg) {
|
|
20
20
|
case_check.when_expr =
|
|
21
|
-
make_unique<ComparisonExpression>(ExpressionType::COMPARE_EQUAL,
|
|
21
|
+
make_unique<ComparisonExpression>(ExpressionType::COMPARE_EQUAL, root_arg->Copy(), std::move(test_raw));
|
|
22
22
|
} else {
|
|
23
23
|
case_check.when_expr = std::move(test_raw);
|
|
24
24
|
}
|
|
@@ -11,7 +11,6 @@ unique_ptr<CreateStatement> Transformer::TransformCreateDatabase(duckdb_libpgque
|
|
|
11
11
|
auto result = make_unique<CreateStatement>();
|
|
12
12
|
auto info = make_unique<CreateDatabaseInfo>();
|
|
13
13
|
|
|
14
|
-
info->extension_name = stmt->extension ? stmt->extension : string();
|
|
15
14
|
info->path = stmt->path ? stmt->path : string();
|
|
16
15
|
|
|
17
16
|
auto qualified_name = TransformQualifiedName(stmt->name);
|