duckdb 0.8.1-dev125.0 → 0.8.1-dev152.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/package.json +1 -1
- package/src/duckdb/src/catalog/catalog.cpp +0 -13
- package/src/duckdb/src/catalog/catalog_search_path.cpp +17 -0
- package/src/duckdb/src/common/types/value.cpp +1 -0
- package/src/duckdb/src/core_functions/aggregate/holistic/quantile.cpp +14 -2
- package/src/duckdb/src/core_functions/function_list.cpp +1 -0
- package/src/duckdb/src/core_functions/scalar/generic/system_functions.cpp +14 -0
- package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +5 -2
- package/src/duckdb/src/execution/operator/helper/physical_set.cpp +5 -1
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +33 -23
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +0 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +2 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/generic_functions.hpp +9 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/map_functions.hpp +2 -6
- package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +16 -36
- package/src/duckdb/src/include/duckdb/main/config.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/settings.hpp +9 -0
- package/src/duckdb/src/include/duckdb/parser/parser.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/emptytableref.hpp +1 -1
- package/src/duckdb/src/main/config.cpp +1 -0
- package/src/duckdb/src/main/settings/settings.cpp +20 -4
- package/src/duckdb/src/parser/column_definition.cpp +5 -8
- package/src/duckdb/src/parser/parser.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +3 -0
- package/src/duckdb/src/storage/data_table.cpp +6 -5
- package/src/duckdb/src/storage/wal_replay.cpp +4 -5
package/package.json
CHANGED
@@ -674,19 +674,6 @@ vector<reference<SchemaCatalogEntry>> Catalog::GetSchemas(ClientContext &context
|
|
674
674
|
return schemas;
|
675
675
|
}
|
676
676
|
|
677
|
-
bool Catalog::TypeExists(ClientContext &context, const string &catalog_name, const string &schema, const string &name) {
|
678
|
-
optional_ptr<CatalogEntry> entry;
|
679
|
-
entry = GetEntry(context, CatalogType::TYPE_ENTRY, catalog_name, schema, name, OnEntryNotFound::RETURN_NULL);
|
680
|
-
if (!entry) {
|
681
|
-
// look in the system catalog
|
682
|
-
entry = GetEntry(context, CatalogType::TYPE_ENTRY, SYSTEM_CATALOG, schema, name, OnEntryNotFound::RETURN_NULL);
|
683
|
-
if (!entry) {
|
684
|
-
return false;
|
685
|
-
}
|
686
|
-
}
|
687
|
-
return true;
|
688
|
-
}
|
689
|
-
|
690
677
|
vector<reference<SchemaCatalogEntry>> Catalog::GetSchemas(ClientContext &context, const string &catalog_name) {
|
691
678
|
vector<reference<Catalog>> catalogs;
|
692
679
|
if (IsInvalidCatalog(catalog_name)) {
|
@@ -5,6 +5,7 @@
|
|
5
5
|
#include "duckdb/common/string_util.hpp"
|
6
6
|
#include "duckdb/main/client_context.hpp"
|
7
7
|
#include "duckdb/catalog/catalog.hpp"
|
8
|
+
#include "duckdb/main/database_manager.hpp"
|
8
9
|
|
9
10
|
namespace duckdb {
|
10
11
|
|
@@ -245,4 +246,20 @@ void CatalogSearchPath::SetPaths(vector<CatalogSearchEntry> new_paths) {
|
|
245
246
|
paths.emplace_back(SYSTEM_CATALOG, "pg_catalog");
|
246
247
|
}
|
247
248
|
|
249
|
+
bool CatalogSearchPath::SchemaInSearchPath(ClientContext &context, const string &catalog_name,
|
250
|
+
const string &schema_name) {
|
251
|
+
for (auto &path : paths) {
|
252
|
+
if (path.schema != schema_name) {
|
253
|
+
continue;
|
254
|
+
}
|
255
|
+
if (path.catalog == catalog_name) {
|
256
|
+
return true;
|
257
|
+
}
|
258
|
+
if (IsInvalidCatalog(path.catalog) && catalog_name == DatabaseManager::GetDefaultDatabase(context)) {
|
259
|
+
return true;
|
260
|
+
}
|
261
|
+
}
|
262
|
+
return false;
|
263
|
+
}
|
264
|
+
|
248
265
|
} // namespace duckdb
|
@@ -1319,6 +1319,7 @@ string Value::ToSQLString() const {
|
|
1319
1319
|
case LogicalTypeId::BLOB:
|
1320
1320
|
return "'" + ToString() + "'::" + type_.ToString();
|
1321
1321
|
case LogicalTypeId::VARCHAR:
|
1322
|
+
case LogicalTypeId::ENUM:
|
1322
1323
|
return "'" + StringUtil::Replace(ToString(), "'", "''") + "'";
|
1323
1324
|
case LogicalTypeId::STRUCT: {
|
1324
1325
|
string ret = "{";
|
@@ -16,13 +16,13 @@
|
|
16
16
|
namespace duckdb {
|
17
17
|
|
18
18
|
// Hugeint arithmetic
|
19
|
-
static hugeint_t
|
19
|
+
static hugeint_t MultiplyByDouble(const hugeint_t &h, const double &d) {
|
20
20
|
D_ASSERT(d >= 0 && d <= 1);
|
21
21
|
return Hugeint::Convert(Hugeint::Cast<double>(h) * d);
|
22
22
|
}
|
23
23
|
|
24
24
|
// Interval arithmetic
|
25
|
-
static interval_t
|
25
|
+
static interval_t MultiplyByDouble(const interval_t &i, const double &d) { // NOLINT
|
26
26
|
D_ASSERT(d >= 0 && d <= 1);
|
27
27
|
return Interval::FromMicro(std::llround(Interval::GetMicro(i) * d));
|
28
28
|
}
|
@@ -207,6 +207,18 @@ timestamp_t CastInterpolation::Interpolate(const timestamp_t &lo, const double d
|
|
207
207
|
return timestamp_t(std::llround(lo.value * (1.0 - d) + hi.value * d));
|
208
208
|
}
|
209
209
|
|
210
|
+
template <>
|
211
|
+
hugeint_t CastInterpolation::Interpolate(const hugeint_t &lo, const double d, const hugeint_t &hi) {
|
212
|
+
const hugeint_t delta = hi - lo;
|
213
|
+
return lo + MultiplyByDouble(delta, d);
|
214
|
+
}
|
215
|
+
|
216
|
+
template <>
|
217
|
+
interval_t CastInterpolation::Interpolate(const interval_t &lo, const double d, const interval_t &hi) {
|
218
|
+
const interval_t delta = hi - lo;
|
219
|
+
return lo + MultiplyByDouble(delta, d);
|
220
|
+
}
|
221
|
+
|
210
222
|
template <>
|
211
223
|
string_t CastInterpolation::Cast(const std::string &src, Vector &result) {
|
212
224
|
return StringVector::AddString(result, src);
|
@@ -169,6 +169,7 @@ static StaticFunctionDefinition internal_functions[] = {
|
|
169
169
|
DUCKDB_SCALAR_FUNCTION_SET(HexFun),
|
170
170
|
DUCKDB_AGGREGATE_FUNCTION_SET(HistogramFun),
|
171
171
|
DUCKDB_SCALAR_FUNCTION_SET(HoursFun),
|
172
|
+
DUCKDB_SCALAR_FUNCTION(InSearchPathFun),
|
172
173
|
DUCKDB_SCALAR_FUNCTION(InstrFun),
|
173
174
|
DUCKDB_SCALAR_FUNCTION_SET(IsFiniteFun),
|
174
175
|
DUCKDB_SCALAR_FUNCTION_SET(IsInfiniteFun),
|
@@ -49,6 +49,16 @@ static void CurrentSchemasFunction(DataChunk &input, ExpressionState &state, Vec
|
|
49
49
|
result.Reference(val);
|
50
50
|
}
|
51
51
|
|
52
|
+
// in_search_path
|
53
|
+
static void InSearchPathFunction(DataChunk &input, ExpressionState &state, Vector &result) {
|
54
|
+
auto &context = state.GetContext();
|
55
|
+
auto &search_path = ClientData::Get(context).catalog_search_path;
|
56
|
+
BinaryExecutor::Execute<string_t, string_t, bool>(
|
57
|
+
input.data[0], input.data[1], result, input.size(), [&](string_t db_name, string_t schema_name) {
|
58
|
+
return search_path->SchemaInSearchPath(context, db_name.GetString(), schema_name.GetString());
|
59
|
+
});
|
60
|
+
}
|
61
|
+
|
52
62
|
// txid_current
|
53
63
|
static void TransactionIdCurrent(DataChunk &input, ExpressionState &state, Vector &result) {
|
54
64
|
auto &context = state.GetContext();
|
@@ -83,6 +93,10 @@ ScalarFunction CurrentSchemasFun::GetFunction() {
|
|
83
93
|
return ScalarFunction({LogicalType::BOOLEAN}, varchar_list_type, CurrentSchemasFunction);
|
84
94
|
}
|
85
95
|
|
96
|
+
ScalarFunction InSearchPathFun::GetFunction() {
|
97
|
+
return ScalarFunction({LogicalType::VARCHAR, LogicalType::VARCHAR}, LogicalType::BOOLEAN, InSearchPathFunction);
|
98
|
+
}
|
99
|
+
|
86
100
|
ScalarFunction CurrentTransactionIdFun::GetFunction() {
|
87
101
|
return ScalarFunction({}, LogicalType::BIGINT, TransactionIdCurrent);
|
88
102
|
}
|
@@ -20,10 +20,14 @@ void PhysicalReset::ResetExtensionVariable(ExecutionContext &context, DBConfig &
|
|
20
20
|
}
|
21
21
|
|
22
22
|
SourceResultType PhysicalReset::GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const {
|
23
|
+
auto &config = DBConfig::GetConfig(context.client);
|
24
|
+
if (config.options.lock_configuration) {
|
25
|
+
throw InvalidInputException("Cannot reset configuration option \"%s\" - the configuration has been locked",
|
26
|
+
name);
|
27
|
+
}
|
23
28
|
auto option = DBConfig::GetOptionByName(name);
|
24
29
|
if (!option) {
|
25
30
|
// check if this is an extra extension variable
|
26
|
-
auto &config = DBConfig::GetConfig(context.client);
|
27
31
|
auto entry = config.extension_parameters.find(name);
|
28
32
|
if (entry == config.extension_parameters.end()) {
|
29
33
|
throw Catalog::UnrecognizedConfigurationError(context.client, name);
|
@@ -49,7 +53,6 @@ SourceResultType PhysicalReset::GetData(ExecutionContext &context, DataChunk &ch
|
|
49
53
|
throw CatalogException("option \"%s\" cannot be reset globally", name);
|
50
54
|
}
|
51
55
|
auto &db = DatabaseInstance::GetDatabase(context.client);
|
52
|
-
auto &config = DBConfig::GetConfig(context.client);
|
53
56
|
config.ResetOption(&db, *option);
|
54
57
|
break;
|
55
58
|
}
|
@@ -23,10 +23,14 @@ void PhysicalSet::SetExtensionVariable(ClientContext &context, ExtensionOption &
|
|
23
23
|
}
|
24
24
|
|
25
25
|
SourceResultType PhysicalSet::GetData(ExecutionContext &context, DataChunk &chunk, OperatorSourceInput &input) const {
|
26
|
+
auto &config = DBConfig::GetConfig(context.client);
|
27
|
+
if (config.options.lock_configuration) {
|
28
|
+
throw InvalidInputException("Cannot change configuration option \"%s\" - the configuration has been locked",
|
29
|
+
name);
|
30
|
+
}
|
26
31
|
auto option = DBConfig::GetOptionByName(name);
|
27
32
|
if (!option) {
|
28
33
|
// check if this is an extra extension variable
|
29
|
-
auto &config = DBConfig::GetConfig(context.client);
|
30
34
|
auto entry = config.extension_parameters.find(name);
|
31
35
|
if (entry == config.extension_parameters.end()) {
|
32
36
|
throw Catalog::UnrecognizedConfigurationError(context.client, name);
|
@@ -18,21 +18,18 @@ string PragmaTableInfo(ClientContext &context, const FunctionParameters ¶met
|
|
18
18
|
}
|
19
19
|
|
20
20
|
string PragmaShowTables(ClientContext &context, const FunctionParameters ¶meters) {
|
21
|
-
auto catalog = DatabaseManager::GetDefaultDatabase(context);
|
22
|
-
auto schema = ClientData::Get(context).catalog_search_path->GetDefault().schema;
|
23
|
-
schema = (schema == INVALID_SCHEMA) ? DEFAULT_SCHEMA : schema; // NOLINT
|
24
|
-
|
25
|
-
auto where_clause = StringUtil::Format("where ((database_name = '%s') and (schema_name = '%s'))", catalog, schema);
|
26
21
|
// clang-format off
|
27
|
-
|
22
|
+
return R"EOF(
|
28
23
|
with "tables" as
|
29
24
|
(
|
30
25
|
SELECT table_name as "name"
|
31
|
-
FROM duckdb_tables
|
26
|
+
FROM duckdb_tables
|
27
|
+
where in_search_path(database_name, schema_name)
|
32
28
|
), "views" as
|
33
29
|
(
|
34
30
|
SELECT view_name as "name"
|
35
|
-
FROM duckdb_views
|
31
|
+
FROM duckdb_views
|
32
|
+
where in_search_path(database_name, schema_name)
|
36
33
|
), db_objects as
|
37
34
|
(
|
38
35
|
SELECT "name" FROM "tables"
|
@@ -41,26 +38,39 @@ string PragmaShowTables(ClientContext &context, const FunctionParameters ¶me
|
|
41
38
|
)
|
42
39
|
SELECT "name"
|
43
40
|
FROM db_objects
|
44
|
-
ORDER BY "name";)EOF"
|
41
|
+
ORDER BY "name";)EOF";
|
45
42
|
// clang-format on
|
46
|
-
|
47
|
-
return pragma_query;
|
48
43
|
}
|
49
44
|
|
50
45
|
string PragmaShowTablesExpanded(ClientContext &context, const FunctionParameters ¶meters) {
|
51
46
|
return R"(
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
47
|
+
SELECT
|
48
|
+
t.database_name AS database,
|
49
|
+
t.schema_name AS schema,
|
50
|
+
t.table_name AS name,
|
51
|
+
LIST(c.column_name order by c.column_index) AS column_names,
|
52
|
+
LIST(c.data_type order by c.column_index) AS column_types,
|
53
|
+
FIRST(t.temporary) AS temporary,
|
54
|
+
FROM duckdb_tables t
|
55
|
+
JOIN duckdb_columns c
|
56
|
+
USING (table_oid)
|
57
|
+
GROUP BY database, schema, name
|
58
|
+
|
59
|
+
UNION ALL
|
60
|
+
|
61
|
+
SELECT
|
62
|
+
v.database_name AS database,
|
63
|
+
v.schema_name AS schema,
|
64
|
+
v.view_name AS name,
|
65
|
+
LIST(c.column_name order by c.column_index) AS column_names,
|
66
|
+
LIST(c.data_type order by c.column_index) AS column_types,
|
67
|
+
FIRST(v.temporary) AS temporary,
|
68
|
+
FROM duckdb_views v
|
69
|
+
JOIN duckdb_columns c
|
70
|
+
ON (v.view_oid=c.table_oid)
|
71
|
+
GROUP BY database, schema, name
|
72
|
+
|
73
|
+
ORDER BY database, schema, name
|
64
74
|
)";
|
65
75
|
}
|
66
76
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
2
|
-
#define DUCKDB_VERSION "0.8.1-
|
2
|
+
#define DUCKDB_VERSION "0.8.1-dev152"
|
3
3
|
#endif
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
5
|
+
#define DUCKDB_SOURCE_ID "d636ce2d59"
|
6
6
|
#endif
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
8
8
|
#include "duckdb/main/database.hpp"
|
@@ -229,9 +229,6 @@ public:
|
|
229
229
|
DUCKDB_API static LogicalType GetType(ClientContext &context, const string &catalog_name, const string &schema,
|
230
230
|
const string &name);
|
231
231
|
|
232
|
-
static bool TypeExists(ClientContext &context, const string &catalog_name, const string &schema,
|
233
|
-
const string &name);
|
234
|
-
|
235
232
|
template <class T>
|
236
233
|
optional_ptr<T> GetEntry(ClientContext &context, const string &schema_name, const string &name,
|
237
234
|
OnEntryNotFound if_not_found, QueryErrorContext error_context = QueryErrorContext()) {
|
@@ -58,6 +58,8 @@ public:
|
|
58
58
|
DUCKDB_API vector<string> GetSchemasForCatalog(const string &catalog);
|
59
59
|
DUCKDB_API vector<string> GetCatalogsForSchema(const string &schema);
|
60
60
|
|
61
|
+
DUCKDB_API bool SchemaInSearchPath(ClientContext &context, const string &catalog_name, const string &schema_name);
|
62
|
+
|
61
63
|
private:
|
62
64
|
void SetPaths(vector<CatalogSearchEntry> new_paths);
|
63
65
|
|
@@ -121,6 +121,15 @@ struct CurrentDatabaseFun {
|
|
121
121
|
static ScalarFunction GetFunction();
|
122
122
|
};
|
123
123
|
|
124
|
+
struct InSearchPathFun {
|
125
|
+
static constexpr const char *Name = "in_search_path";
|
126
|
+
static constexpr const char *Parameters = "database_name,schema_name";
|
127
|
+
static constexpr const char *Description = "Returns whether or not the database/schema are in the search path.";
|
128
|
+
static constexpr const char *Example = "in_search_path('memory', 'main')";
|
129
|
+
|
130
|
+
static ScalarFunction GetFunction();
|
131
|
+
};
|
132
|
+
|
124
133
|
struct CurrentTransactionIdFun {
|
125
134
|
static constexpr const char *Name = "txid_current";
|
126
135
|
static constexpr const char *Parameters = "";
|
@@ -43,10 +43,7 @@ struct MapEntriesFun {
|
|
43
43
|
struct MapExtractFun {
|
44
44
|
static constexpr const char *Name = "map_extract";
|
45
45
|
static constexpr const char *Parameters = "map,key";
|
46
|
-
static constexpr const char *Description =
|
47
|
-
"Return a list containing the value for a given key or an empty list if the key is not contained in the map. "
|
48
|
-
"The type of the key provided in the second parameter must match the type of the map’s keys else an error is "
|
49
|
-
"returned.";
|
46
|
+
static constexpr const char *Description = "Return a list containing the value for a given key or an empty list if the key is not contained in the map. The type of the key provided in the second parameter must match the type of the map’s keys else an error is returned.";
|
50
47
|
static constexpr const char *Example = "map_extract(map(['key'], ['val']), 'key')";
|
51
48
|
|
52
49
|
static ScalarFunction GetFunction();
|
@@ -70,8 +67,7 @@ struct MapFromEntriesFun {
|
|
70
67
|
struct MapConcatFun {
|
71
68
|
static constexpr const char *Name = "map_concat";
|
72
69
|
static constexpr const char *Parameters = "any,...";
|
73
|
-
static constexpr const char *Description = "Returns a map created from merging the input maps, on key collision "
|
74
|
-
"the value is taken from the last map with that key";
|
70
|
+
static constexpr const char *Description = "Returns a map created from merging the input maps, on key collision the value is taken from the last map with that key";
|
75
71
|
static constexpr const char *Example = "map_concat(map([1,2], ['a', 'b']), map([2,3], ['c', 'd']));";
|
76
72
|
|
77
73
|
static ScalarFunction GetFunction();
|
@@ -31,8 +31,7 @@ struct StartsWithFun {
|
|
31
31
|
struct ASCIIFun {
|
32
32
|
static constexpr const char *Name = "ascii";
|
33
33
|
static constexpr const char *Parameters = "string";
|
34
|
-
static constexpr const char *Description =
|
35
|
-
"Returns an integer that represents the Unicode code point of the first character of the string.";
|
34
|
+
static constexpr const char *Description = "Returns an integer that represents the Unicode code point of the first character of the string.";
|
36
35
|
static constexpr const char *Example = "ascii('Ω')";
|
37
36
|
|
38
37
|
static ScalarFunction GetFunction();
|
@@ -41,8 +40,7 @@ struct ASCIIFun {
|
|
41
40
|
struct BarFun {
|
42
41
|
static constexpr const char *Name = "bar";
|
43
42
|
static constexpr const char *Parameters = "x,min,max,width";
|
44
|
-
static constexpr const char *Description = "Draw a band whose width is proportional to (x - min) and equal to "
|
45
|
-
"width characters when x = max. width defaults to 80.";
|
43
|
+
static constexpr const char *Description = "Draw a band whose width is proportional to (x - min) and equal to width characters when x = max. width defaults to 80.";
|
46
44
|
static constexpr const char *Example = "bar(5, 0, 20, 10)";
|
47
45
|
|
48
46
|
static ScalarFunctionSet GetFunctions();
|
@@ -66,8 +64,7 @@ struct ToBinaryFun {
|
|
66
64
|
struct ChrFun {
|
67
65
|
static constexpr const char *Name = "chr";
|
68
66
|
static constexpr const char *Parameters = "code_point";
|
69
|
-
static constexpr const char *Description =
|
70
|
-
"returns a character which is corresponding the ASCII code value or Unicode code point";
|
67
|
+
static constexpr const char *Description = "returns a character which is corresponding the ASCII code value or Unicode code point";
|
71
68
|
static constexpr const char *Example = "chr(65)";
|
72
69
|
|
73
70
|
static ScalarFunction GetFunction();
|
@@ -76,10 +73,7 @@ struct ChrFun {
|
|
76
73
|
struct DamerauLevenshteinFun {
|
77
74
|
static constexpr const char *Name = "damerau_levenshtein";
|
78
75
|
static constexpr const char *Parameters = "str1,str2";
|
79
|
-
static constexpr const char *Description =
|
80
|
-
"Extension of Levenshtein distance to also include transposition of adjacent characters as an allowed edit "
|
81
|
-
"operation. In other words, the minimum number of edit operations (insertions, deletions, substitutions or "
|
82
|
-
"transpositions) required to change one string to another. Different case is considered different.";
|
76
|
+
static constexpr const char *Description = "Extension of Levenshtein distance to also include transposition of adjacent characters as an allowed edit operation. In other words, the minimum number of edit operations (insertions, deletions, substitutions or transpositions) required to change one string to another. Different case is considered different.";
|
83
77
|
static constexpr const char *Example = "damerau_levenshtein('hello', 'world')";
|
84
78
|
|
85
79
|
static ScalarFunction GetFunction();
|
@@ -112,8 +106,7 @@ struct FormatreadabledecimalsizeFun {
|
|
112
106
|
struct HammingFun {
|
113
107
|
static constexpr const char *Name = "hamming";
|
114
108
|
static constexpr const char *Parameters = "str1,str2";
|
115
|
-
static constexpr const char *Description = "The number of positions with different characters for 2 strings of "
|
116
|
-
"equal length. Different case is considered different.";
|
109
|
+
static constexpr const char *Description = "The number of positions with different characters for 2 strings of equal length. Different case is considered different.";
|
117
110
|
static constexpr const char *Example = "hamming('duck','luck')";
|
118
111
|
|
119
112
|
static ScalarFunction GetFunction();
|
@@ -143,8 +136,7 @@ struct ToHexFun {
|
|
143
136
|
struct InstrFun {
|
144
137
|
static constexpr const char *Name = "instr";
|
145
138
|
static constexpr const char *Parameters = "haystack,needle";
|
146
|
-
static constexpr const char *Description =
|
147
|
-
"Return location of first occurrence of needle in haystack, counting from 1. Returns 0 if no match found.";
|
139
|
+
static constexpr const char *Description = "Return location of first occurrence of needle in haystack, counting from 1. Returns 0 if no match found.";
|
148
140
|
static constexpr const char *Example = "instr('test test','es')";
|
149
141
|
|
150
142
|
static ScalarFunction GetFunction();
|
@@ -165,8 +157,7 @@ struct PositionFun {
|
|
165
157
|
struct JaccardFun {
|
166
158
|
static constexpr const char *Name = "jaccard";
|
167
159
|
static constexpr const char *Parameters = "str1,str2";
|
168
|
-
static constexpr const char *Description = "The Jaccard similarity between two strings. Different case is "
|
169
|
-
"considered different. Returns a number between 0 and 1.";
|
160
|
+
static constexpr const char *Description = "The Jaccard similarity between two strings. Different case is considered different. Returns a number between 0 and 1.";
|
170
161
|
static constexpr const char *Example = "jaccard('duck','luck')";
|
171
162
|
|
172
163
|
static ScalarFunction GetFunction();
|
@@ -175,8 +166,7 @@ struct JaccardFun {
|
|
175
166
|
struct JaroSimilarityFun {
|
176
167
|
static constexpr const char *Name = "jaro_similarity";
|
177
168
|
static constexpr const char *Parameters = "str1,str2";
|
178
|
-
static constexpr const char *Description = "The Jaro similarity between two strings. Different case is considered "
|
179
|
-
"different. Returns a number between 0 and 1.";
|
169
|
+
static constexpr const char *Description = "The Jaro similarity between two strings. Different case is considered different. Returns a number between 0 and 1.";
|
180
170
|
static constexpr const char *Example = "jaro_similarity('duck','duckdb')";
|
181
171
|
|
182
172
|
static ScalarFunction GetFunction();
|
@@ -185,8 +175,7 @@ struct JaroSimilarityFun {
|
|
185
175
|
struct JaroWinklerSimilarityFun {
|
186
176
|
static constexpr const char *Name = "jaro_winkler_similarity";
|
187
177
|
static constexpr const char *Parameters = "str1,str2";
|
188
|
-
static constexpr const char *Description = "The Jaro-Winkler similarity between two strings. Different case is "
|
189
|
-
"considered different. Returns a number between 0 and 1.";
|
178
|
+
static constexpr const char *Description = "The Jaro-Winkler similarity between two strings. Different case is considered different. Returns a number between 0 and 1.";
|
190
179
|
static constexpr const char *Example = "jaro_winkler_similarity('duck','duckdb')";
|
191
180
|
|
192
181
|
static ScalarFunction GetFunction();
|
@@ -213,9 +202,7 @@ struct LeftGraphemeFun {
|
|
213
202
|
struct LevenshteinFun {
|
214
203
|
static constexpr const char *Name = "levenshtein";
|
215
204
|
static constexpr const char *Parameters = "str1,str2";
|
216
|
-
static constexpr const char *Description =
|
217
|
-
"The minimum number of single-character edits (insertions, deletions or substitutions) required to change one "
|
218
|
-
"string to the other. Different case is considered different.";
|
205
|
+
static constexpr const char *Description = "The minimum number of single-character edits (insertions, deletions or substitutions) required to change one string to the other. Different case is considered different.";
|
219
206
|
static constexpr const char *Example = "levenshtein('duck','db')";
|
220
207
|
|
221
208
|
static ScalarFunction GetFunction();
|
@@ -230,8 +217,7 @@ struct Editdist3Fun {
|
|
230
217
|
struct LpadFun {
|
231
218
|
static constexpr const char *Name = "lpad";
|
232
219
|
static constexpr const char *Parameters = "string,count,character";
|
233
|
-
static constexpr const char *Description =
|
234
|
-
"Pads the string with the character from the left until it has count characters";
|
220
|
+
static constexpr const char *Description = "Pads the string with the character from the left until it has count characters";
|
235
221
|
static constexpr const char *Example = "lpad('hello', 10, '>')";
|
236
222
|
|
237
223
|
static ScalarFunction GetFunction();
|
@@ -240,8 +226,7 @@ struct LpadFun {
|
|
240
226
|
struct LtrimFun {
|
241
227
|
static constexpr const char *Name = "ltrim";
|
242
228
|
static constexpr const char *Parameters = "string,characters";
|
243
|
-
static constexpr const char *Description =
|
244
|
-
"Removes any occurrences of any of the characters from the left side of the string";
|
229
|
+
static constexpr const char *Description = "Removes any occurrences of any of the characters from the left side of the string";
|
245
230
|
static constexpr const char *Example = "ltrim('>>>>test<<', '><')";
|
246
231
|
|
247
232
|
static ScalarFunctionSet GetFunctions();
|
@@ -340,8 +325,7 @@ struct RightGraphemeFun {
|
|
340
325
|
struct RpadFun {
|
341
326
|
static constexpr const char *Name = "rpad";
|
342
327
|
static constexpr const char *Parameters = "string,count,character";
|
343
|
-
static constexpr const char *Description =
|
344
|
-
"Pads the string with the character from the right until it has count characters";
|
328
|
+
static constexpr const char *Description = "Pads the string with the character from the right until it has count characters";
|
345
329
|
static constexpr const char *Example = "rpad('hello', 10, '<')";
|
346
330
|
|
347
331
|
static ScalarFunction GetFunction();
|
@@ -350,8 +334,7 @@ struct RpadFun {
|
|
350
334
|
struct RtrimFun {
|
351
335
|
static constexpr const char *Name = "rtrim";
|
352
336
|
static constexpr const char *Parameters = "string,characters";
|
353
|
-
static constexpr const char *Description =
|
354
|
-
"Removes any occurrences of any of the characters from the right side of the string";
|
337
|
+
static constexpr const char *Description = "Removes any occurrences of any of the characters from the right side of the string";
|
355
338
|
static constexpr const char *Example = "rtrim('>>>>test<<', '><')";
|
356
339
|
|
357
340
|
static ScalarFunctionSet GetFunctions();
|
@@ -408,9 +391,7 @@ struct RegexpSplitToArrayFun {
|
|
408
391
|
struct TranslateFun {
|
409
392
|
static constexpr const char *Name = "translate";
|
410
393
|
static constexpr const char *Parameters = "string,from,to";
|
411
|
-
static constexpr const char *Description =
|
412
|
-
"Replaces each character in string that matches a character in the from set with the corresponding character "
|
413
|
-
"in the to set. If from is longer than to, occurrences of the extra characters in from are deleted.";
|
394
|
+
static constexpr const char *Description = "Replaces each character in string that matches a character in the from set with the corresponding character in the to set. If from is longer than to, occurrences of the extra characters in from are deleted.";
|
414
395
|
static constexpr const char *Example = "translate('12345', '143', 'ax')";
|
415
396
|
|
416
397
|
static ScalarFunction GetFunction();
|
@@ -419,8 +400,7 @@ struct TranslateFun {
|
|
419
400
|
struct TrimFun {
|
420
401
|
static constexpr const char *Name = "trim";
|
421
402
|
static constexpr const char *Parameters = "string,characters";
|
422
|
-
static constexpr const char *Description =
|
423
|
-
"Removes any occurrences of any of the characters from either side of the string";
|
403
|
+
static constexpr const char *Description = "Removes any occurrences of any of the characters from either side of the string";
|
424
404
|
static constexpr const char *Example = "trim('>>>>test<<', '><')";
|
425
405
|
|
426
406
|
static ScalarFunctionSet GetFunctions();
|
@@ -151,6 +151,8 @@ struct DBConfigOptions {
|
|
151
151
|
DebugInitialize debug_initialize = DebugInitialize::NO_INITIALIZE;
|
152
152
|
//! The set of unrecognized (other) options
|
153
153
|
unordered_map<string, Value> unrecognized_options;
|
154
|
+
//! Whether or not the configuration settings can be altered
|
155
|
+
bool lock_configuration = false;
|
154
156
|
//! Whether to print bindings when printing the plan (debug mode only)
|
155
157
|
static bool debug_print_bindings;
|
156
158
|
|
@@ -309,6 +309,15 @@ struct LogQueryPathSetting {
|
|
309
309
|
static Value GetSetting(ClientContext &context);
|
310
310
|
};
|
311
311
|
|
312
|
+
struct LockConfigurationSetting {
|
313
|
+
static constexpr const char *Name = "lock_configuration";
|
314
|
+
static constexpr const char *Description = "Whether or not the configuration can be altered";
|
315
|
+
static constexpr const LogicalTypeId InputType = LogicalTypeId::BOOLEAN;
|
316
|
+
static void SetGlobal(DatabaseInstance *db, DBConfig &config, const Value ¶meter);
|
317
|
+
static void ResetGlobal(DatabaseInstance *db, DBConfig &config);
|
318
|
+
static Value GetSetting(ClientContext &context);
|
319
|
+
};
|
320
|
+
|
312
321
|
struct ImmediateTransactionModeSetting {
|
313
322
|
static constexpr const char *Name = "immediate_transaction_mode";
|
314
323
|
static constexpr const char *Description =
|
@@ -62,6 +62,8 @@ public:
|
|
62
62
|
//! Parses a column list (i.e. as found in a CREATE TABLE statement)
|
63
63
|
static ColumnList ParseColumnList(const string &column_list, ParserOptions options = ParserOptions());
|
64
64
|
|
65
|
+
static bool StripUnicodeSpaces(const string &query_str, string &new_query);
|
66
|
+
|
65
67
|
private:
|
66
68
|
ParserOptions options;
|
67
69
|
};
|
@@ -82,6 +82,7 @@ static ConfigurationOption internal_options[] = {DUCKDB_GLOBAL(AccessModeSetting
|
|
82
82
|
DUCKDB_GLOBAL(ForceBitpackingModeSetting),
|
83
83
|
DUCKDB_LOCAL(HomeDirectorySetting),
|
84
84
|
DUCKDB_LOCAL(LogQueryPathSetting),
|
85
|
+
DUCKDB_GLOBAL(LockConfigurationSetting),
|
85
86
|
DUCKDB_GLOBAL(ImmediateTransactionModeSetting),
|
86
87
|
DUCKDB_LOCAL(IntegerDivisionSetting),
|
87
88
|
DUCKDB_LOCAL(MaximumExpressionDepthSetting),
|
@@ -151,7 +151,7 @@ void OrderedAggregateThreshold::ResetLocal(ClientContext &context) {
|
|
151
151
|
|
152
152
|
void OrderedAggregateThreshold::SetLocal(ClientContext &context, const Value &input) {
|
153
153
|
const auto param = input.GetValue<uint64_t>();
|
154
|
-
if (
|
154
|
+
if (param <= 0) {
|
155
155
|
throw ParserException("Invalid option for PRAGMA ordered_aggregate_threshold, value must be positive");
|
156
156
|
}
|
157
157
|
ClientConfig::GetConfig(context).ordered_aggregate_threshold = param;
|
@@ -189,7 +189,7 @@ Value DebugWindowMode::GetSetting(ClientContext &context) {
|
|
189
189
|
// Debug AsOf Join
|
190
190
|
//===--------------------------------------------------------------------===//
|
191
191
|
void DebugAsOfIEJoin::ResetLocal(ClientContext &context) {
|
192
|
-
ClientConfig::GetConfig(context).
|
192
|
+
ClientConfig::GetConfig(context).force_asof_iejoin = ClientConfig().force_asof_iejoin;
|
193
193
|
}
|
194
194
|
|
195
195
|
void DebugAsOfIEJoin::SetLocal(ClientContext &context, const Value &input) {
|
@@ -433,7 +433,6 @@ Value EnableHTTPMetadataCacheSetting::GetSetting(ClientContext &context) {
|
|
433
433
|
//===--------------------------------------------------------------------===//
|
434
434
|
// Enable Profiling
|
435
435
|
//===--------------------------------------------------------------------===//
|
436
|
-
|
437
436
|
void EnableProfilingSetting::ResetLocal(ClientContext &context) {
|
438
437
|
auto &config = ClientConfig::GetConfig(context);
|
439
438
|
config.profiler_print_format = ClientConfig().profiler_print_format;
|
@@ -718,10 +717,10 @@ Value IntegerDivisionSetting::GetSetting(ClientContext &context) {
|
|
718
717
|
auto &config = ClientConfig::GetConfig(context);
|
719
718
|
return Value(config.integer_division);
|
720
719
|
}
|
720
|
+
|
721
721
|
//===--------------------------------------------------------------------===//
|
722
722
|
// Log Query Path
|
723
723
|
//===--------------------------------------------------------------------===//
|
724
|
-
|
725
724
|
void LogQueryPathSetting::ResetLocal(ClientContext &context) {
|
726
725
|
auto &client_data = ClientData::Get(context);
|
727
726
|
// TODO: verify that this does the right thing
|
@@ -745,6 +744,23 @@ Value LogQueryPathSetting::GetSetting(ClientContext &context) {
|
|
745
744
|
return client_data.log_query_writer ? Value(client_data.log_query_writer->path) : Value();
|
746
745
|
}
|
747
746
|
|
747
|
+
//===--------------------------------------------------------------------===//
|
748
|
+
// Lock Configuration
|
749
|
+
//===--------------------------------------------------------------------===//
|
750
|
+
void LockConfigurationSetting::SetGlobal(DatabaseInstance *db, DBConfig &config, const Value &input) {
|
751
|
+
auto new_value = input.GetValue<bool>();
|
752
|
+
config.options.lock_configuration = new_value;
|
753
|
+
}
|
754
|
+
|
755
|
+
void LockConfigurationSetting::ResetGlobal(DatabaseInstance *db, DBConfig &config) {
|
756
|
+
config.options.lock_configuration = DBConfig().options.lock_configuration;
|
757
|
+
}
|
758
|
+
|
759
|
+
Value LockConfigurationSetting::GetSetting(ClientContext &context) {
|
760
|
+
auto &config = DBConfig::GetConfig(context);
|
761
|
+
return Value::BOOLEAN(config.options.lock_configuration);
|
762
|
+
}
|
763
|
+
|
748
764
|
//===--------------------------------------------------------------------===//
|
749
765
|
// Immediate Transaction Mode
|
750
766
|
//===--------------------------------------------------------------------===//
|
@@ -50,6 +50,7 @@ void ColumnDefinition::Serialize(Serializer &serializer) const {
|
|
50
50
|
writer.WriteOptional(default_value);
|
51
51
|
}
|
52
52
|
writer.WriteField<TableColumnType>(category);
|
53
|
+
writer.WriteField<duckdb::CompressionType>(compression_type);
|
53
54
|
writer.Finalize();
|
54
55
|
}
|
55
56
|
|
@@ -59,16 +60,12 @@ ColumnDefinition ColumnDefinition::Deserialize(Deserializer &source) {
|
|
59
60
|
auto column_type = reader.ReadRequiredSerializable<LogicalType, LogicalType>();
|
60
61
|
auto expression = reader.ReadOptional<ParsedExpression>(nullptr);
|
61
62
|
auto category = reader.ReadField<TableColumnType>(TableColumnType::STANDARD);
|
63
|
+
auto compression_type = reader.ReadField<duckdb::CompressionType>(duckdb::CompressionType::COMPRESSION_AUTO);
|
62
64
|
reader.Finalize();
|
63
65
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
case TableColumnType::GENERATED:
|
68
|
-
return ColumnDefinition(column_name, column_type, std::move(expression), TableColumnType::GENERATED);
|
69
|
-
default:
|
70
|
-
throw NotImplementedException("Type not implemented for TableColumnType");
|
71
|
-
}
|
66
|
+
ColumnDefinition result(column_name, column_type, std::move(expression), category);
|
67
|
+
result.compression_type = compression_type;
|
68
|
+
return result;
|
72
69
|
}
|
73
70
|
|
74
71
|
const unique_ptr<ParsedExpression> &ColumnDefinition::DefaultValue() const {
|
@@ -45,7 +45,7 @@ static bool ReplaceUnicodeSpaces(const string &query, string &new_query, vector<
|
|
45
45
|
// This function strips unicode space characters from the query and replaces them with regular spaces
|
46
46
|
// It returns true if any unicode space characters were found and stripped
|
47
47
|
// See here for a list of unicode space characters - https://jkorpela.fi/chars/spaces.html
|
48
|
-
|
48
|
+
bool Parser::StripUnicodeSpaces(const string &query_str, string &new_query) {
|
49
49
|
const idx_t NBSP_LEN = 2;
|
50
50
|
const idx_t USP_LEN = 3;
|
51
51
|
idx_t pos = 0;
|
@@ -161,6 +161,9 @@ Binder::BindTableFunctionInternal(TableFunction &table_function, const string &f
|
|
161
161
|
table_function.extra_info = "(Multi-Threaded)";
|
162
162
|
}
|
163
163
|
}
|
164
|
+
} else {
|
165
|
+
throw InvalidInputException("Cannot call function \"%s\" directly - it has no bind function",
|
166
|
+
table_function.name);
|
164
167
|
}
|
165
168
|
if (return_types.size() != return_names.size()) {
|
166
169
|
throw InternalException("Failed to bind \"%s\": return_types/names must have same size", table_function.name);
|
@@ -1201,13 +1201,14 @@ void DataTable::WALAddIndex(ClientContext &context, unique_ptr<Index> index,
|
|
1201
1201
|
// intermediate holds scanned chunks of the underlying data to create the index
|
1202
1202
|
DataChunk intermediate;
|
1203
1203
|
vector<LogicalType> intermediate_types;
|
1204
|
-
|
1205
|
-
|
1206
|
-
|
1207
|
-
|
1208
|
-
intermediate_types.push_back(col.Type());
|
1204
|
+
vector<column_t> column_ids;
|
1205
|
+
for (auto &it : column_definitions) {
|
1206
|
+
intermediate_types.push_back(it.Type());
|
1207
|
+
column_ids.push_back(it.Oid());
|
1209
1208
|
}
|
1209
|
+
column_ids.push_back(COLUMN_IDENTIFIER_ROW_ID);
|
1210
1210
|
intermediate_types.emplace_back(LogicalType::ROW_TYPE);
|
1211
|
+
|
1211
1212
|
intermediate.Initialize(allocator, intermediate_types);
|
1212
1213
|
|
1213
1214
|
// holds the result of executing the index expression on the intermediate chunks
|
@@ -195,15 +195,16 @@ void ReplayState::ReplayEntry(WALType entry_type) {
|
|
195
195
|
// Replay Table
|
196
196
|
//===--------------------------------------------------------------------===//
|
197
197
|
void ReplayState::ReplayCreateTable() {
|
198
|
-
|
199
198
|
auto info = TableCatalogEntry::Deserialize(source, context);
|
200
199
|
if (deserialize_only) {
|
201
200
|
return;
|
202
201
|
}
|
203
202
|
|
204
203
|
// bind the constraints to the table again
|
204
|
+
|
205
205
|
auto binder = Binder::CreateBinder(context);
|
206
|
-
auto
|
206
|
+
auto &schema = catalog.GetSchema(context, info->schema);
|
207
|
+
auto bound_info = binder->BindCreateTableInfo(std::move(info), schema);
|
207
208
|
|
208
209
|
catalog.CreateTable(context, *bound_info);
|
209
210
|
}
|
@@ -282,9 +283,7 @@ void ReplayState::ReplayDropSchema() {
|
|
282
283
|
//===--------------------------------------------------------------------===//
|
283
284
|
void ReplayState::ReplayCreateType() {
|
284
285
|
auto info = TypeCatalogEntry::Deserialize(source);
|
285
|
-
|
286
|
-
return;
|
287
|
-
}
|
286
|
+
info->on_conflict = OnCreateConflict::IGNORE_ON_CONFLICT;
|
288
287
|
catalog.CreateType(context, *info);
|
289
288
|
}
|
290
289
|
|