duckdb 0.8.1-dev125.0 → 0.8.1-dev180.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.
Files changed (32) hide show
  1. package/package.json +1 -1
  2. package/src/duckdb/src/catalog/catalog.cpp +0 -13
  3. package/src/duckdb/src/catalog/catalog_search_path.cpp +17 -0
  4. package/src/duckdb/src/common/adbc/adbc.cpp +118 -12
  5. package/src/duckdb/src/common/adbc/driver_manager.cpp +0 -20
  6. package/src/duckdb/src/common/types/value.cpp +1 -0
  7. package/src/duckdb/src/core_functions/aggregate/holistic/quantile.cpp +14 -2
  8. package/src/duckdb/src/core_functions/function_list.cpp +1 -0
  9. package/src/duckdb/src/core_functions/scalar/generic/system_functions.cpp +14 -0
  10. package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +5 -2
  11. package/src/duckdb/src/execution/operator/helper/physical_set.cpp +5 -1
  12. package/src/duckdb/src/function/pragma/pragma_queries.cpp +33 -23
  13. package/src/duckdb/src/function/table/arrow.cpp +2 -2
  14. package/src/duckdb/src/function/table/read_csv.cpp +11 -16
  15. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  16. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +0 -3
  17. package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +2 -0
  18. package/src/duckdb/src/include/duckdb/core_functions/scalar/generic_functions.hpp +9 -0
  19. package/src/duckdb/src/include/duckdb/core_functions/scalar/map_functions.hpp +2 -6
  20. package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +16 -36
  21. package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +3 -1
  22. package/src/duckdb/src/include/duckdb/main/config.hpp +2 -0
  23. package/src/duckdb/src/include/duckdb/main/settings.hpp +9 -0
  24. package/src/duckdb/src/include/duckdb/parser/parser.hpp +2 -0
  25. package/src/duckdb/src/include/duckdb/parser/tableref/emptytableref.hpp +1 -1
  26. package/src/duckdb/src/main/config.cpp +1 -0
  27. package/src/duckdb/src/main/settings/settings.cpp +20 -4
  28. package/src/duckdb/src/parser/column_definition.cpp +5 -8
  29. package/src/duckdb/src/parser/parser.cpp +1 -1
  30. package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +3 -0
  31. package/src/duckdb/src/storage/data_table.cpp +6 -5
  32. package/src/duckdb/src/storage/wal_replay.cpp +4 -5
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.8.1-dev125.0",
5
+ "version": "0.8.1-dev180.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -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
@@ -5,10 +5,13 @@
5
5
  #include "duckdb/common/string_util.hpp"
6
6
 
7
7
  #include "duckdb.h"
8
- #include "duckdb/main/connection.hpp"
9
8
  #include "duckdb/common/arrow/arrow_wrapper.hpp"
10
9
  #include "duckdb/common/arrow/arrow.hpp"
11
10
 
11
+ #ifndef DUCKDB_AMALGAMATION
12
+ #include "duckdb/main/connection.hpp"
13
+ #endif
14
+
12
15
  #include <string.h>
13
16
  #include <stdlib.h>
14
17
 
@@ -37,6 +40,10 @@ duckdb_adbc::AdbcStatusCode duckdb_adbc_init(size_t count, struct duckdb_adbc::A
37
40
  driver->StatementSetOption = duckdb_adbc::StatementSetOption;
38
41
  driver->StatementSetSqlQuery = duckdb_adbc::StatementSetSqlQuery;
39
42
  driver->ConnectionGetObjects = duckdb_adbc::ConnectionGetObjects;
43
+ driver->ConnectionCommit = duckdb_adbc::ConnectionCommit;
44
+ driver->ConnectionRollback = duckdb_adbc::ConnectionRollback;
45
+ driver->ConnectionReadPartition = duckdb_adbc::ConnectionReadPartition;
46
+ driver->StatementExecutePartitions = duckdb_adbc::StatementExecutePartitions;
40
47
  return ADBC_STATUS_OK;
41
48
  }
42
49
 
@@ -162,10 +169,104 @@ AdbcStatusCode ConnectionNew(struct AdbcConnection *connection, struct AdbcError
162
169
  return ADBC_STATUS_OK;
163
170
  }
164
171
 
172
+ AdbcStatusCode ExecuteQuery(duckdb::Connection *conn, const char *query, struct AdbcError *error) {
173
+ auto res = conn->Query(query);
174
+ if (res->HasError()) {
175
+ auto error_message = "Failed to execute query \"" + std::string(query) + "\": " + res->GetError();
176
+ SetError(error, error_message);
177
+ return ADBC_STATUS_INTERNAL;
178
+ }
179
+ return ADBC_STATUS_OK;
180
+ }
181
+
165
182
  AdbcStatusCode ConnectionSetOption(struct AdbcConnection *connection, const char *key, const char *value,
166
183
  struct AdbcError *error) {
167
- // there are no connection-level options that need to be set before connecting
168
- return ADBC_STATUS_OK;
184
+ if (!connection) {
185
+ SetError(error, "Connection is not set");
186
+ return ADBC_STATUS_INVALID_ARGUMENT;
187
+ }
188
+ auto conn = (duckdb::Connection *)connection->private_data;
189
+ if (strcmp(key, ADBC_CONNECTION_OPTION_AUTOCOMMIT) == 0) {
190
+ if (strcmp(value, ADBC_OPTION_VALUE_ENABLED) == 0) {
191
+ if (conn->HasActiveTransaction()) {
192
+ AdbcStatusCode status = ExecuteQuery(conn, "COMMIT", error);
193
+ if (status != ADBC_STATUS_OK) {
194
+ return status;
195
+ }
196
+ } else {
197
+ // no-op
198
+ }
199
+ } else if (strcmp(value, ADBC_OPTION_VALUE_DISABLED) == 0) {
200
+ if (conn->HasActiveTransaction()) {
201
+ // no-op
202
+ } else {
203
+ // begin
204
+ AdbcStatusCode status = ExecuteQuery(conn, "START TRANSACTION", error);
205
+ if (status != ADBC_STATUS_OK) {
206
+ return status;
207
+ }
208
+ }
209
+ } else {
210
+ auto error_message = "Invalid connection option value " + std::string(key) + "=" + std::string(value);
211
+ SetError(error, error_message);
212
+ return ADBC_STATUS_INVALID_ARGUMENT;
213
+ }
214
+ return ADBC_STATUS_OK;
215
+ }
216
+ auto error_message =
217
+ "Unknown connection option " + std::string(key) + "=" + (value ? std::string(value) : "(NULL)");
218
+ SetError(error, error_message);
219
+ return ADBC_STATUS_NOT_IMPLEMENTED;
220
+ }
221
+
222
+ AdbcStatusCode ConnectionReadPartition(struct AdbcConnection *connection, const uint8_t *serialized_partition,
223
+ size_t serialized_length, struct ArrowArrayStream *out,
224
+ struct AdbcError *error) {
225
+ SetError(error, "Read Partitions are not supported in DuckDB");
226
+ return ADBC_STATUS_NOT_IMPLEMENTED;
227
+ }
228
+
229
+ AdbcStatusCode StatementExecutePartitions(struct AdbcStatement *statement, struct ArrowSchema *schema,
230
+ struct AdbcPartitions *partitions, int64_t *rows_affected,
231
+ struct AdbcError *error) {
232
+ SetError(error, "Execute Partitions are not supported in DuckDB");
233
+ return ADBC_STATUS_NOT_IMPLEMENTED;
234
+ }
235
+
236
+ AdbcStatusCode ConnectionCommit(struct AdbcConnection *connection, struct AdbcError *error) {
237
+ if (!connection) {
238
+ SetError(error, "Connection is not set");
239
+ return ADBC_STATUS_INVALID_ARGUMENT;
240
+ }
241
+ auto conn = (duckdb::Connection *)connection->private_data;
242
+ if (!conn->HasActiveTransaction()) {
243
+ SetError(error, "No active transaction, cannot commit");
244
+ return ADBC_STATUS_INVALID_STATE;
245
+ }
246
+
247
+ AdbcStatusCode status = ExecuteQuery(conn, "COMMIT", error);
248
+ if (status != ADBC_STATUS_OK) {
249
+ return status;
250
+ }
251
+ return ExecuteQuery(conn, "START TRANSACTION", error);
252
+ }
253
+
254
+ AdbcStatusCode ConnectionRollback(struct AdbcConnection *connection, struct AdbcError *error) {
255
+ if (!connection) {
256
+ SetError(error, "Connection is not set");
257
+ return ADBC_STATUS_INVALID_ARGUMENT;
258
+ }
259
+ auto conn = (duckdb::Connection *)connection->private_data;
260
+ if (!conn->HasActiveTransaction()) {
261
+ SetError(error, "No active transaction, cannot rollback");
262
+ return ADBC_STATUS_INVALID_STATE;
263
+ }
264
+
265
+ AdbcStatusCode status = ExecuteQuery(conn, "ROLLBACK", error);
266
+ if (status != ADBC_STATUS_OK) {
267
+ return status;
268
+ }
269
+ return ExecuteQuery(conn, "START TRANSACTION", error);
169
270
  }
170
271
 
171
272
  AdbcStatusCode ConnectionInit(struct AdbcConnection *connection, struct AdbcDatabase *database,
@@ -219,11 +320,11 @@ void release(struct ArrowArrayStream *stream) {
219
320
  if (!stream || !stream->release) {
220
321
  return;
221
322
  }
222
- stream->release = nullptr;
223
323
  if (stream->private_data) {
224
324
  duckdb_destroy_arrow((duckdb_arrow *)&stream->private_data);
225
325
  stream->private_data = nullptr;
226
326
  }
327
+ stream->release = nullptr;
227
328
  }
228
329
 
229
330
  const char *get_last_error(struct ArrowArrayStream *stream) {
@@ -270,16 +371,21 @@ AdbcStatusCode Ingest(duckdb_connection connection, const char *table_name, stru
270
371
  if (status != ADBC_STATUS_OK) {
271
372
  return status;
272
373
  }
374
+ auto cconn = (duckdb::Connection *)connection;
273
375
 
376
+ auto has_table = cconn->TableInfo(table_name);
377
+ auto arrow_scan = cconn->TableFunction("arrow_scan", {duckdb::Value::POINTER((uintptr_t)input),
378
+ duckdb::Value::POINTER((uintptr_t)stream_produce),
379
+ duckdb::Value::POINTER((uintptr_t)get_schema)});
274
380
  try {
275
- // TODO evil cast, do we need a way to do this from the C api?
276
- auto cconn = (duckdb::Connection *)connection;
277
- cconn
278
- ->TableFunction("arrow_scan",
279
- {duckdb::Value::POINTER((uintptr_t)input),
280
- duckdb::Value::POINTER((uintptr_t)stream_produce),
281
- duckdb::Value::POINTER((uintptr_t)get_schema)}) // TODO make this a parameter somewhere
282
- ->Create(table_name); // TODO this should probably be a temp table
381
+ if (!has_table) {
382
+ // We create the table based on an Arrow Scanner
383
+ arrow_scan->Create(table_name);
384
+ } else {
385
+ arrow_scan->CreateView("temp_adbc_view", true, true);
386
+ auto query = "insert into " + std::string(table_name) + " select * from temp_adbc_view";
387
+ auto result = cconn->Query(query);
388
+ }
283
389
  // After creating a table, the arrow array stream is released. Hence we must set it as released to avoid
284
390
  // double-releasing it
285
391
  input->release = nullptr;
@@ -133,10 +133,6 @@ static AdbcStatusCode ReleaseDriver(struct AdbcDriver *driver, struct AdbcError
133
133
 
134
134
  // Default stubs
135
135
 
136
- AdbcStatusCode ConnectionCommit(struct AdbcConnection *, struct AdbcError *error) {
137
- return ADBC_STATUS_NOT_IMPLEMENTED;
138
- }
139
-
140
136
  AdbcStatusCode ConnectionGetInfo(struct AdbcConnection *connection, uint32_t *info_codes, size_t info_codes_length,
141
137
  struct ArrowArrayStream *out, struct AdbcError *error) {
142
138
  return ADBC_STATUS_NOT_IMPLEMENTED;
@@ -147,27 +143,11 @@ AdbcStatusCode ConnectionGetTableSchema(struct AdbcConnection *, const char *, c
147
143
  return ADBC_STATUS_NOT_IMPLEMENTED;
148
144
  }
149
145
 
150
- AdbcStatusCode ConnectionReadPartition(struct AdbcConnection *connection, const uint8_t *serialized_partition,
151
- size_t serialized_length, struct ArrowArrayStream *out,
152
- struct AdbcError *error) {
153
- return ADBC_STATUS_NOT_IMPLEMENTED;
154
- }
155
-
156
- AdbcStatusCode ConnectionRollback(struct AdbcConnection *, struct AdbcError *error) {
157
- return ADBC_STATUS_NOT_IMPLEMENTED;
158
- }
159
-
160
146
  AdbcStatusCode StatementBind(struct AdbcStatement *, struct ArrowArray *, struct ArrowSchema *,
161
147
  struct AdbcError *error) {
162
148
  return ADBC_STATUS_NOT_IMPLEMENTED;
163
149
  }
164
150
 
165
- AdbcStatusCode StatementExecutePartitions(struct AdbcStatement *statement, struct ArrowSchema *schema,
166
- struct AdbcPartitions *partitions, int64_t *rows_affected,
167
- struct AdbcError *error) {
168
- return ADBC_STATUS_NOT_IMPLEMENTED;
169
- }
170
-
171
151
  AdbcStatusCode StatementGetParameterSchema(struct AdbcStatement *statement, struct ArrowSchema *schema,
172
152
  struct AdbcError *error) {
173
153
  return ADBC_STATUS_NOT_IMPLEMENTED;
@@ -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 operator*(const hugeint_t &h, const double &d) {
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 operator*(const interval_t &i, const double &d) { // NOLINT
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 &paramet
18
18
  }
19
19
 
20
20
  string PragmaShowTables(ClientContext &context, const FunctionParameters &parameters) {
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
- auto pragma_query = StringUtil::Format(R"EOF(
22
+ return R"EOF(
28
23
  with "tables" as
29
24
  (
30
25
  SELECT table_name as "name"
31
- FROM duckdb_tables %s
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 %s
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 &parame
41
38
  )
42
39
  SELECT "name"
43
40
  FROM db_objects
44
- ORDER BY "name";)EOF", where_clause, where_clause);
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 &parameters) {
51
46
  return R"(
52
- SELECT
53
- t.database_name AS database,
54
- t.schema_name AS schema,
55
- t.table_name,
56
- LIST(c.column_name order by c.column_index) AS column_names,
57
- LIST(c.data_type order by c.column_index) AS column_types,
58
- FIRST(t.temporary) AS temporary,
59
- FROM duckdb_tables t
60
- JOIN duckdb_columns c
61
- USING (table_oid)
62
- GROUP BY t.database_name, t.schema_name, t.table_name
63
- ORDER BY t.database_name, t.schema_name, t.table_name;
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
 
@@ -206,8 +206,8 @@ unique_ptr<FunctionData> ArrowTableFunction::ArrowScanBind(ClientContext &contex
206
206
  throw InvalidInputException("arrow_scan: released schema passed");
207
207
  }
208
208
  if (schema.dictionary) {
209
- res->arrow_convert_data[col_idx] =
210
- make_uniq<ArrowConvertData>(GetArrowLogicalType(schema, res->arrow_convert_data, col_idx));
209
+ auto logical_type = GetArrowLogicalType(schema, res->arrow_convert_data, col_idx);
210
+ res->arrow_convert_data[col_idx] = make_uniq<ArrowConvertData>(std::move(logical_type));
211
211
  return_types.emplace_back(GetArrowLogicalType(*schema.dictionary, res->arrow_convert_data, col_idx));
212
212
  } else {
213
213
  return_types.emplace_back(GetArrowLogicalType(schema, res->arrow_convert_data, col_idx));
@@ -378,8 +378,8 @@ private:
378
378
  //! Current File Number
379
379
  idx_t file_number = 0;
380
380
  idx_t max_tuple_end = 0;
381
- //! the vector stores positions where threads ended the last line they read in the CSV File, and the set stores
382
- //! positions where they started reading the first line.
381
+ //! The vector stores positions where threads ended the last line they read in the CSV File, and the set stores
382
+ //! Positions where they started reading the first line.
383
383
  vector<vector<idx_t>> tuple_end;
384
384
  vector<set<idx_t>> tuple_start;
385
385
  //! Tuple end to batch
@@ -559,15 +559,13 @@ bool ParallelCSVGlobalState::Next(ClientContext &context, const ReadCSVData &bin
559
559
  }
560
560
  void ParallelCSVGlobalState::UpdateVerification(VerificationPositions positions, idx_t file_number_p, idx_t batch_idx) {
561
561
  lock_guard<mutex> parallel_lock(main_mutex);
562
- if (positions.beginning_of_first_line < positions.end_of_last_line) {
563
- if (positions.end_of_last_line > max_tuple_end) {
564
- max_tuple_end = positions.end_of_last_line;
565
- }
566
- tuple_end_to_batch[file_number_p][positions.end_of_last_line] = batch_idx;
567
- batch_to_tuple_end[file_number_p][batch_idx] = tuple_end[file_number_p].size();
568
- tuple_start[file_number_p].insert(positions.beginning_of_first_line);
569
- tuple_end[file_number_p].push_back(positions.end_of_last_line);
562
+ if (positions.end_of_last_line > max_tuple_end) {
563
+ max_tuple_end = positions.end_of_last_line;
570
564
  }
565
+ tuple_end_to_batch[file_number_p][positions.end_of_last_line] = batch_idx;
566
+ batch_to_tuple_end[file_number_p][batch_idx] = tuple_end[file_number_p].size();
567
+ tuple_start[file_number_p].insert(positions.beginning_of_first_line);
568
+ tuple_end[file_number_p].push_back(positions.end_of_last_line);
571
569
  }
572
570
 
573
571
  void ParallelCSVGlobalState::UpdateLinesRead(CSVBufferRead &buffer_read, idx_t file_idx) {
@@ -690,17 +688,14 @@ static void ParallelReadCSVFunction(ClientContext &context, TableFunctionInput &
690
688
  }
691
689
  if (csv_local_state.csv_reader->finished) {
692
690
  auto verification_updates = csv_local_state.csv_reader->GetVerificationPositions();
693
- if (verification_updates.beginning_of_first_line != verification_updates.end_of_last_line) {
694
- csv_global_state.UpdateVerification(verification_updates,
695
- csv_local_state.csv_reader->buffer->buffer->GetFileNumber(),
696
- csv_local_state.csv_reader->buffer->local_batch_index);
697
- }
691
+ csv_global_state.UpdateVerification(verification_updates,
692
+ csv_local_state.csv_reader->buffer->buffer->GetFileNumber(),
693
+ csv_local_state.csv_reader->buffer->local_batch_index);
698
694
  csv_global_state.UpdateLinesRead(*csv_local_state.csv_reader->buffer, csv_local_state.csv_reader->file_idx);
699
695
  auto has_next = csv_global_state.Next(context, bind_data, csv_local_state.csv_reader);
700
696
  if (csv_local_state.csv_reader) {
701
697
  csv_local_state.csv_reader->linenr = 0;
702
698
  }
703
-
704
699
  if (!has_next) {
705
700
  csv_global_state.DecrementThread();
706
701
  break;
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.8.1-dev125"
2
+ #define DUCKDB_VERSION "0.8.1-dev180"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "09486d2b9d"
5
+ #define DUCKDB_SOURCE_ID "e9f6ba553a"
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();
@@ -25,8 +25,10 @@ public:
25
25
  bool serialize = function.serialize;
26
26
  writer.WriteField(serialize);
27
27
  if (serialize) {
28
- D_ASSERT(function.deserialize);
29
28
  function.serialize(writer, bind_info, function);
29
+ // First check if serialize throws a NotImplementedException, in which case it doesn't require a deserialize
30
+ // function
31
+ D_ASSERT(function.deserialize);
30
32
  }
31
33
  }
32
34
 
@@ -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 &parameter);
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
  };
@@ -11,7 +11,7 @@
11
11
  #include "duckdb/parser/tableref.hpp"
12
12
 
13
13
  namespace duckdb {
14
- //! Represents a cross product
14
+
15
15
  class EmptyTableRef : public TableRef {
16
16
  public:
17
17
  static constexpr const TableReferenceType TYPE = TableReferenceType::EMPTY;
@@ -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 (!param) {
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).force_no_cross_product = ClientConfig().force_asof_iejoin;
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
- switch (category) {
65
- case TableColumnType::STANDARD:
66
- return ColumnDefinition(column_name, column_type, std::move(expression), TableColumnType::STANDARD);
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
- static bool StripUnicodeSpaces(const string &query_str, string &new_query) {
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
- auto column_ids = index->column_ids;
1205
- column_ids.push_back(COLUMN_IDENTIFIER_ROW_ID);
1206
- for (auto &id : index->column_ids) {
1207
- auto &col = column_definitions[id];
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 bound_info = binder->BindCreateTableInfo(std::move(info));
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
- if (Catalog::TypeExists(context, info->catalog, info->schema, info->name)) {
286
- return;
287
- }
286
+ info->on_conflict = OnCreateConflict::IGNORE_ON_CONFLICT;
288
287
  catalog.CreateType(context, *info);
289
288
  }
290
289