duckdb 0.7.2-dev2233.0 → 0.7.2-dev2320.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 +1 -0
- package/package.json +1 -1
- package/src/duckdb/src/catalog/catalog.cpp +18 -17
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +0 -4
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +0 -4
- package/src/duckdb/src/catalog/catalog_set.cpp +3 -3
- package/src/duckdb/src/common/adbc/adbc.cpp +441 -0
- package/src/duckdb/src/common/adbc/driver_manager.cpp +749 -0
- package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +1 -1
- package/src/duckdb/src/common/tree_renderer.cpp +3 -3
- package/src/duckdb/src/common/types/conflict_manager.cpp +2 -1
- package/src/duckdb/src/execution/column_binding_resolver.cpp +1 -1
- package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +1 -1
- package/src/duckdb/src/execution/operator/filter/physical_filter.cpp +2 -2
- package/src/duckdb/src/execution/operator/helper/physical_execute.cpp +2 -2
- package/src/duckdb/src/execution/operator/helper/physical_result_collector.cpp +5 -5
- package/src/duckdb/src/execution/operator/join/physical_cross_product.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +11 -10
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +3 -3
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +9 -9
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +4 -4
- package/src/duckdb/src/execution/operator/join/physical_join.cpp +7 -7
- package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +3 -3
- package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +3 -3
- package/src/duckdb/src/execution/operator/join/physical_positional_join.cpp +2 -2
- package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +8 -9
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +20 -19
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +3 -3
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +25 -24
- package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +1 -1
- package/src/duckdb/src/execution/operator/projection/physical_projection.cpp +2 -2
- package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +12 -6
- package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +10 -11
- package/src/duckdb/src/execution/operator/set/physical_union.cpp +2 -2
- package/src/duckdb/src/execution/physical_operator.cpp +13 -13
- package/src/duckdb/src/execution/physical_plan/plan_column_data_get.cpp +2 -4
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +5 -5
- package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +3 -3
- package/src/duckdb/src/execution/physical_plan/plan_delim_join.cpp +6 -7
- package/src/duckdb/src/execution/physical_plan/plan_explain.cpp +2 -4
- package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_show_select.cpp +2 -4
- package/src/duckdb/src/execution/physical_plan/plan_update.cpp +3 -3
- package/src/duckdb/src/function/compression_config.cpp +9 -9
- package/src/duckdb/src/function/scalar/date/strftime.cpp +1 -1
- package/src/duckdb/src/function/table/copy_csv.cpp +5 -0
- package/src/duckdb/src/function/table/pragma_detailed_profiling_output.cpp +6 -5
- package/src/duckdb/src/function/table/pragma_last_profiling_output.cpp +7 -5
- package/src/duckdb/src/function/table/system/duckdb_databases.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_dependencies.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_keywords.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_settings.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_tables.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_temporary_files.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_types.cpp +1 -1
- package/src/duckdb/src/function/table/system/pragma_collations.cpp +1 -1
- package/src/duckdb/src/function/table/system/pragma_database_size.cpp +1 -1
- package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +5 -5
- package/src/duckdb/src/function/table/system/pragma_table_info.cpp +1 -1
- package/src/duckdb/src/function/table/system/test_all_types.cpp +1 -1
- package/src/duckdb/src/function/table/table_scan.cpp +3 -4
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +1 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +1 -2
- package/src/duckdb/src/include/duckdb/common/adbc/adbc-init.hpp +37 -0
- package/src/duckdb/src/include/duckdb/common/adbc/adbc.h +1088 -0
- package/src/duckdb/src/include/duckdb/common/adbc/adbc.hpp +85 -0
- package/src/duckdb/src/include/duckdb/common/adbc/driver_manager.h +84 -0
- package/src/duckdb/src/include/duckdb/common/helper.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/types/conflict_manager.hpp +3 -2
- package/src/duckdb/src/include/duckdb/common/types.hpp +0 -1
- package/src/duckdb/src/include/duckdb/execution/executor.hpp +7 -7
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_execute.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_result_collector.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_cross_product.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +3 -3
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_index_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_positional_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_export.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +3 -4
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_union.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +3 -3
- package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/cast/cast_function_set.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/config.hpp +2 -2
- package/src/duckdb/src/include/duckdb/main/query_profiler.hpp +10 -9
- package/src/duckdb/src/include/duckdb/parallel/meta_pipeline.hpp +4 -4
- package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +18 -17
- package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +14 -17
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +6 -6
- package/src/duckdb/src/include/duckdb/planner/expression_binder/index_binder.hpp +4 -4
- package/src/duckdb/src/include/duckdb/planner/expression_binder/where_binder.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_create.hpp +3 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_create_table.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/parsed_data/bound_create_function_info.hpp +3 -2
- package/src/duckdb/src/include/duckdb/planner/parsed_data/bound_create_table_info.hpp +3 -2
- package/src/duckdb/src/include/duckdb/planner/table_binding.hpp +6 -5
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_basetableref.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_compress.hpp +3 -7
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_compress.hpp +3 -7
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/column_data_checkpointer.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +4 -4
- package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +3 -3
- package/src/duckdb/src/include/duckdb/transaction/cleanup_state.hpp +3 -3
- package/src/duckdb/src/include/duckdb/transaction/commit_state.hpp +5 -5
- package/src/duckdb/src/include/duckdb/transaction/duck_transaction.hpp +3 -3
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +31 -30
- package/src/duckdb/src/include/duckdb/transaction/transaction_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/transaction/undo_buffer.hpp +1 -1
- package/src/duckdb/src/main/client_context.cpp +1 -1
- package/src/duckdb/src/main/query_profiler.cpp +24 -22
- package/src/duckdb/src/parallel/executor.cpp +55 -49
- package/src/duckdb/src/parallel/meta_pipeline.cpp +5 -5
- package/src/duckdb/src/parallel/pipeline.cpp +43 -26
- package/src/duckdb/src/parallel/pipeline_executor.cpp +22 -22
- package/src/duckdb/src/planner/bind_context.cpp +67 -71
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +6 -7
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +6 -8
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +3 -4
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +17 -18
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +16 -17
- package/src/duckdb/src/planner/binder/statement/bind_vacuum.cpp +6 -5
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +9 -9
- package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +20 -18
- package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +1 -1
- package/src/duckdb/src/planner/binder.cpp +4 -4
- package/src/duckdb/src/planner/expression_binder/index_binder.cpp +2 -1
- package/src/duckdb/src/planner/expression_binder/where_binder.cpp +3 -2
- package/src/duckdb/src/planner/operator/logical_create_table.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_delete.cpp +5 -5
- package/src/duckdb/src/planner/operator/logical_insert.cpp +6 -7
- package/src/duckdb/src/planner/operator/logical_update.cpp +6 -7
- package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +4 -5
- package/src/duckdb/src/planner/table_binding.cpp +6 -5
- package/src/duckdb/src/storage/compression/bitpacking.cpp +5 -6
- package/src/duckdb/src/storage/compression/dictionary_compression.cpp +5 -6
- package/src/duckdb/src/storage/compression/fsst.cpp +3 -5
- package/src/duckdb/src/storage/compression/rle.cpp +4 -6
- package/src/duckdb/src/storage/data_table.cpp +27 -28
- package/src/duckdb/src/storage/local_storage.cpp +70 -68
- package/src/duckdb/src/storage/storage_manager.cpp +12 -13
- package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +2 -2
- package/src/duckdb/src/storage/table/column_data.cpp +2 -2
- package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +18 -6
- package/src/duckdb/src/storage/table/column_segment.cpp +23 -24
- package/src/duckdb/src/storage/table/row_group.cpp +3 -3
- package/src/duckdb/src/storage/table/row_group_collection.cpp +1 -1
- package/src/duckdb/src/storage/table/update_segment.cpp +15 -15
- package/src/duckdb/src/storage/wal_replay.cpp +1 -1
- package/src/duckdb/src/transaction/cleanup_state.cpp +10 -10
- package/src/duckdb/src/transaction/commit_state.cpp +19 -19
- package/src/duckdb/src/transaction/duck_transaction.cpp +7 -7
- package/src/duckdb/src/transaction/rollback_state.cpp +1 -1
- package/src/duckdb/src/transaction/undo_buffer.cpp +2 -1
- package/src/duckdb/ub_src_common_adbc.cpp +4 -0
- package/src/duckdb/src/include/duckdb/common/single_thread_ptr.hpp +0 -185
package/binding.gyp
CHANGED
@@ -12,6 +12,7 @@
|
|
12
12
|
"src/duckdb/ub_src_catalog.cpp",
|
13
13
|
"src/duckdb/ub_src_catalog_catalog_entry.cpp",
|
14
14
|
"src/duckdb/ub_src_catalog_default.cpp",
|
15
|
+
"src/duckdb/ub_src_common_adbc.cpp",
|
15
16
|
"src/duckdb/ub_src_common.cpp",
|
16
17
|
"src/duckdb/ub_src_common_arrow.cpp",
|
17
18
|
"src/duckdb/ub_src_common_crypto.cpp",
|
package/package.json
CHANGED
@@ -287,8 +287,8 @@ struct CatalogLookup {
|
|
287
287
|
|
288
288
|
//! Return value of Catalog::LookupEntry
|
289
289
|
struct CatalogEntryLookup {
|
290
|
-
SchemaCatalogEntry
|
291
|
-
CatalogEntry
|
290
|
+
optional_ptr<SchemaCatalogEntry> schema;
|
291
|
+
optional_ptr<CatalogEntry> entry;
|
292
292
|
|
293
293
|
DUCKDB_API bool Found() const {
|
294
294
|
return entry;
|
@@ -323,18 +323,19 @@ SchemaCatalogEntry *Catalog::GetSchema(ClientContext &context, const string &sch
|
|
323
323
|
// Lookup
|
324
324
|
//===--------------------------------------------------------------------===//
|
325
325
|
SimilarCatalogEntry Catalog::SimilarEntryInSchemas(ClientContext &context, const string &entry_name, CatalogType type,
|
326
|
-
const
|
326
|
+
const reference_set_t<SchemaCatalogEntry> &schemas) {
|
327
327
|
SimilarCatalogEntry result;
|
328
|
-
for (auto
|
329
|
-
auto
|
330
|
-
auto
|
328
|
+
for (auto schema_ref : schemas) {
|
329
|
+
auto &schema = schema_ref.get();
|
330
|
+
auto transaction = schema.catalog->GetCatalogTransaction(context);
|
331
|
+
auto entry = schema.GetSimilarEntry(transaction, type, entry_name);
|
331
332
|
if (!entry.Found()) {
|
332
333
|
// no similar entry found
|
333
334
|
continue;
|
334
335
|
}
|
335
336
|
if (!result.Found() || result.distance > entry.distance) {
|
336
337
|
result = entry;
|
337
|
-
result.schema = schema;
|
338
|
+
result.schema = &schema;
|
338
339
|
}
|
339
340
|
}
|
340
341
|
return result;
|
@@ -446,18 +447,18 @@ CatalogException Catalog::UnrecognizedConfigurationError(ClientContext &context,
|
|
446
447
|
|
447
448
|
CatalogException Catalog::CreateMissingEntryException(ClientContext &context, const string &entry_name,
|
448
449
|
CatalogType type,
|
449
|
-
const
|
450
|
+
const reference_set_t<SchemaCatalogEntry> &schemas,
|
450
451
|
QueryErrorContext error_context) {
|
451
452
|
auto entry = SimilarEntryInSchemas(context, entry_name, type, schemas);
|
452
453
|
|
453
|
-
|
454
|
+
reference_set_t<SchemaCatalogEntry> unseen_schemas;
|
454
455
|
auto &db_manager = DatabaseManager::Get(context);
|
455
456
|
auto databases = db_manager.GetDatabases(context);
|
456
457
|
for (auto database : databases) {
|
457
458
|
auto &catalog = database->GetCatalog();
|
458
459
|
auto current_schemas = catalog.GetAllSchemas(context);
|
459
460
|
for (auto ¤t_schema : current_schemas) {
|
460
|
-
unseen_schemas.insert(current_schema);
|
461
|
+
unseen_schemas.insert(*current_schema);
|
461
462
|
}
|
462
463
|
}
|
463
464
|
// check if the entry exists in any extension
|
@@ -506,7 +507,7 @@ CatalogEntryLookup Catalog::LookupEntryInternal(CatalogTransaction transaction,
|
|
506
507
|
|
507
508
|
CatalogEntryLookup Catalog::LookupEntry(ClientContext &context, CatalogType type, const string &schema,
|
508
509
|
const string &name, bool if_exists, QueryErrorContext error_context) {
|
509
|
-
|
510
|
+
reference_set_t<SchemaCatalogEntry> schemas;
|
510
511
|
if (IsInvalidSchema(schema)) {
|
511
512
|
// try all schemas for this catalog
|
512
513
|
auto catalog_name = GetName();
|
@@ -522,7 +523,7 @@ CatalogEntryLookup Catalog::LookupEntry(ClientContext &context, CatalogType type
|
|
522
523
|
return result;
|
523
524
|
}
|
524
525
|
if (result.schema) {
|
525
|
-
schemas.insert(result.schema);
|
526
|
+
schemas.insert(*result.schema);
|
526
527
|
}
|
527
528
|
}
|
528
529
|
} else {
|
@@ -532,7 +533,7 @@ CatalogEntryLookup Catalog::LookupEntry(ClientContext &context, CatalogType type
|
|
532
533
|
return result;
|
533
534
|
}
|
534
535
|
if (result.schema) {
|
535
|
-
schemas.insert(result.schema);
|
536
|
+
schemas.insert(*result.schema);
|
536
537
|
}
|
537
538
|
}
|
538
539
|
if (if_exists) {
|
@@ -543,7 +544,7 @@ CatalogEntryLookup Catalog::LookupEntry(ClientContext &context, CatalogType type
|
|
543
544
|
|
544
545
|
CatalogEntryLookup Catalog::LookupEntry(ClientContext &context, vector<CatalogLookup> &lookups, CatalogType type,
|
545
546
|
const string &name, bool if_exists, QueryErrorContext error_context) {
|
546
|
-
|
547
|
+
reference_set_t<SchemaCatalogEntry> schemas;
|
547
548
|
for (auto &lookup : lookups) {
|
548
549
|
auto transaction = lookup.catalog.GetCatalogTransaction(context);
|
549
550
|
auto result = lookup.catalog.LookupEntryInternal(transaction, type, lookup.schema, name);
|
@@ -551,7 +552,7 @@ CatalogEntryLookup Catalog::LookupEntry(ClientContext &context, vector<CatalogLo
|
|
551
552
|
return result;
|
552
553
|
}
|
553
554
|
if (result.schema) {
|
554
|
-
schemas.insert(result.schema);
|
555
|
+
schemas.insert(*result.schema);
|
555
556
|
}
|
556
557
|
}
|
557
558
|
if (if_exists) {
|
@@ -575,7 +576,7 @@ CatalogEntry *Catalog::GetEntry(ClientContext &context, const string &schema, co
|
|
575
576
|
|
576
577
|
CatalogEntry *Catalog::GetEntry(ClientContext &context, CatalogType type, const string &schema_name, const string &name,
|
577
578
|
bool if_exists, QueryErrorContext error_context) {
|
578
|
-
return LookupEntry(context, type, schema_name, name, if_exists, error_context).entry;
|
579
|
+
return LookupEntry(context, type, schema_name, name, if_exists, error_context).entry.get();
|
579
580
|
}
|
580
581
|
|
581
582
|
CatalogEntry *Catalog::GetEntry(ClientContext &context, CatalogType type, const string &catalog, const string &schema,
|
@@ -599,7 +600,7 @@ CatalogEntry *Catalog::GetEntry(ClientContext &context, CatalogType type, const
|
|
599
600
|
D_ASSERT(if_exists_p);
|
600
601
|
return nullptr;
|
601
602
|
}
|
602
|
-
return result.entry;
|
603
|
+
return result.entry.get();
|
603
604
|
}
|
604
605
|
|
605
606
|
SchemaCatalogEntry *Catalog::GetSchema(ClientContext &context, const string &catalog_name, const string &schema_name,
|
@@ -707,10 +707,6 @@ DataTable &DuckTableEntry::GetStorage() {
|
|
707
707
|
return *storage;
|
708
708
|
}
|
709
709
|
|
710
|
-
DataTable *DuckTableEntry::GetStoragePtr() {
|
711
|
-
return storage.get();
|
712
|
-
}
|
713
|
-
|
714
710
|
const vector<unique_ptr<BoundConstraint>> &DuckTableEntry::GetBoundConstraints() {
|
715
711
|
return bound_constraints;
|
716
712
|
}
|
@@ -196,10 +196,6 @@ DataTable &TableCatalogEntry::GetStorage() {
|
|
196
196
|
throw InternalException("Calling GetStorage on a TableCatalogEntry that is not a DuckTableEntry");
|
197
197
|
}
|
198
198
|
|
199
|
-
DataTable *TableCatalogEntry::GetStoragePtr() {
|
200
|
-
throw InternalException("Calling GetStoragePtr on a TableCatalogEntry that is not a DuckTableEntry");
|
201
|
-
}
|
202
|
-
|
203
199
|
const vector<unique_ptr<BoundConstraint>> &TableCatalogEntry::GetBoundConstraints() {
|
204
200
|
throw InternalException("Calling GetBoundConstraints on a TableCatalogEntry that is not a DuckTableEntry");
|
205
201
|
}
|
@@ -144,7 +144,7 @@ bool CatalogSet::CreateEntry(CatalogTransaction transaction, const string &name,
|
|
144
144
|
// push the old entry in the undo buffer for this transaction
|
145
145
|
if (transaction.transaction) {
|
146
146
|
auto &dtransaction = (DuckTransaction &)*transaction.transaction;
|
147
|
-
dtransaction.PushCatalogEntry(value_ptr->child
|
147
|
+
dtransaction.PushCatalogEntry(*value_ptr->child);
|
148
148
|
}
|
149
149
|
return true;
|
150
150
|
}
|
@@ -265,7 +265,7 @@ bool CatalogSet::AlterEntry(CatalogTransaction transaction, const string &name,
|
|
265
265
|
// push the old entry in the undo buffer for this transaction
|
266
266
|
if (transaction.transaction) {
|
267
267
|
auto &dtransaction = (DuckTransaction &)*transaction.transaction;
|
268
|
-
dtransaction.PushCatalogEntry(new_entry->child
|
268
|
+
dtransaction.PushCatalogEntry(*new_entry->child, serialized_alter.data.get(), serialized_alter.size);
|
269
269
|
}
|
270
270
|
|
271
271
|
// Check the dependency manager to verify that there are no conflicting dependencies with this alter
|
@@ -311,7 +311,7 @@ void CatalogSet::DropEntryInternal(CatalogTransaction transaction, EntryIndex en
|
|
311
311
|
// push the old entry in the undo buffer for this transaction
|
312
312
|
if (transaction.transaction) {
|
313
313
|
auto &dtransaction = (DuckTransaction &)*transaction.transaction;
|
314
|
-
dtransaction.PushCatalogEntry(value_ptr->child
|
314
|
+
dtransaction.PushCatalogEntry(*value_ptr->child);
|
315
315
|
}
|
316
316
|
}
|
317
317
|
|
@@ -0,0 +1,441 @@
|
|
1
|
+
#include "duckdb/common/adbc/adbc.hpp"
|
2
|
+
#include "duckdb/common/adbc/adbc-init.hpp"
|
3
|
+
|
4
|
+
#include "duckdb/common/string.hpp"
|
5
|
+
#include "duckdb/common/string_util.hpp"
|
6
|
+
|
7
|
+
#include "duckdb.h"
|
8
|
+
#include "duckdb/main/connection.hpp"
|
9
|
+
#include "duckdb/common/arrow/arrow_wrapper.hpp"
|
10
|
+
#include "duckdb/common/arrow/arrow.hpp"
|
11
|
+
|
12
|
+
#include <string.h>
|
13
|
+
#include <stdlib.h>
|
14
|
+
|
15
|
+
// We gotta leak the symbols of the init function
|
16
|
+
duckdb_adbc::AdbcStatusCode duckdb_adbc_init(size_t count, struct duckdb_adbc::AdbcDriver *driver,
|
17
|
+
struct duckdb_adbc::AdbcError *error) {
|
18
|
+
if (!driver) {
|
19
|
+
return ADBC_STATUS_INVALID_ARGUMENT;
|
20
|
+
}
|
21
|
+
|
22
|
+
driver->DatabaseNew = duckdb_adbc::DatabaseNew;
|
23
|
+
driver->DatabaseSetOption = duckdb_adbc::DatabaseSetOption;
|
24
|
+
driver->DatabaseInit = duckdb_adbc::DatabaseInit;
|
25
|
+
driver->DatabaseRelease = duckdb_adbc::DatabaseRelease;
|
26
|
+
driver->ConnectionNew = duckdb_adbc::ConnectionNew;
|
27
|
+
driver->ConnectionSetOption = duckdb_adbc::ConnectionSetOption;
|
28
|
+
driver->ConnectionInit = duckdb_adbc::ConnectionInit;
|
29
|
+
driver->ConnectionRelease = duckdb_adbc::ConnectionRelease;
|
30
|
+
driver->ConnectionGetTableTypes = duckdb_adbc::ConnectionGetTableTypes;
|
31
|
+
driver->StatementNew = duckdb_adbc::StatementNew;
|
32
|
+
driver->StatementRelease = duckdb_adbc::StatementRelease;
|
33
|
+
// driver->StatementBind = duckdb::adbc::StatementBind;
|
34
|
+
driver->StatementBindStream = duckdb_adbc::StatementBindStream;
|
35
|
+
driver->StatementExecuteQuery = duckdb_adbc::StatementExecuteQuery;
|
36
|
+
driver->StatementPrepare = duckdb_adbc::StatementPrepare;
|
37
|
+
driver->StatementSetOption = duckdb_adbc::StatementSetOption;
|
38
|
+
driver->StatementSetSqlQuery = duckdb_adbc::StatementSetSqlQuery;
|
39
|
+
driver->ConnectionGetObjects = duckdb_adbc::ConnectionGetObjects;
|
40
|
+
return ADBC_STATUS_OK;
|
41
|
+
}
|
42
|
+
|
43
|
+
namespace duckdb_adbc {
|
44
|
+
#define CHECK_TRUE(p, e, m) \
|
45
|
+
if (!(p)) { \
|
46
|
+
if (e) { \
|
47
|
+
e->message = strdup(m); /* TODO Set cleanup callback */ \
|
48
|
+
} \
|
49
|
+
return ADBC_STATUS_INVALID_ARGUMENT; \
|
50
|
+
}
|
51
|
+
|
52
|
+
#define CHECK_RES(res, e, m) \
|
53
|
+
if (res != DuckDBSuccess) { \
|
54
|
+
if (e) { \
|
55
|
+
e->message = strdup(m); \
|
56
|
+
} \
|
57
|
+
return ADBC_STATUS_INTERNAL; \
|
58
|
+
} else { \
|
59
|
+
return ADBC_STATUS_OK; \
|
60
|
+
}
|
61
|
+
|
62
|
+
struct DuckDBAdbcDatabaseWrapper {
|
63
|
+
//! The DuckDB Database Configuration
|
64
|
+
::duckdb_config config;
|
65
|
+
//! The DuckDB Database
|
66
|
+
::duckdb_database database;
|
67
|
+
//! Path of Disk-Based Database or :memory: database
|
68
|
+
std::string path;
|
69
|
+
};
|
70
|
+
|
71
|
+
AdbcStatusCode DatabaseNew(struct AdbcDatabase *database, struct AdbcError *error) {
|
72
|
+
CHECK_TRUE(database, error, "Missing database object");
|
73
|
+
|
74
|
+
database->private_data = nullptr;
|
75
|
+
auto wrapper = (DuckDBAdbcDatabaseWrapper *)malloc(sizeof(DuckDBAdbcDatabaseWrapper));
|
76
|
+
CHECK_TRUE(wrapper, error, "Allocation error");
|
77
|
+
|
78
|
+
database->private_data = wrapper;
|
79
|
+
auto res = duckdb_create_config(&wrapper->config);
|
80
|
+
CHECK_RES(res, error, "Failed to allocate");
|
81
|
+
}
|
82
|
+
|
83
|
+
AdbcStatusCode DatabaseSetOption(struct AdbcDatabase *database, const char *key, const char *value,
|
84
|
+
struct AdbcError *error) {
|
85
|
+
CHECK_TRUE(database, error, "Missing database object");
|
86
|
+
CHECK_TRUE(key, error, "Missing key");
|
87
|
+
|
88
|
+
auto wrapper = (DuckDBAdbcDatabaseWrapper *)database->private_data;
|
89
|
+
if (strcmp(key, "path") == 0) {
|
90
|
+
wrapper->path = value;
|
91
|
+
return ADBC_STATUS_OK;
|
92
|
+
}
|
93
|
+
auto res = duckdb_set_config(wrapper->config, key, value);
|
94
|
+
|
95
|
+
CHECK_RES(res, error, "Failed to set configuration option");
|
96
|
+
}
|
97
|
+
|
98
|
+
AdbcStatusCode DatabaseInit(struct AdbcDatabase *database, struct AdbcError *error) {
|
99
|
+
char *errormsg;
|
100
|
+
// TODO can we set the database path via option, too? Does not look like it...
|
101
|
+
auto wrapper = (DuckDBAdbcDatabaseWrapper *)database->private_data;
|
102
|
+
auto res = duckdb_open_ext(wrapper->path.c_str(), &wrapper->database, wrapper->config, &errormsg);
|
103
|
+
|
104
|
+
// TODO this leaks memory because errormsg is malloc-ed
|
105
|
+
CHECK_RES(res, error, errormsg);
|
106
|
+
}
|
107
|
+
|
108
|
+
AdbcStatusCode DatabaseRelease(struct AdbcDatabase *database, struct AdbcError *error) {
|
109
|
+
|
110
|
+
if (database && database->private_data) {
|
111
|
+
auto wrapper = (DuckDBAdbcDatabaseWrapper *)database->private_data;
|
112
|
+
|
113
|
+
duckdb_close(&wrapper->database);
|
114
|
+
duckdb_destroy_config(&wrapper->config);
|
115
|
+
free(database->private_data);
|
116
|
+
database->private_data = nullptr;
|
117
|
+
}
|
118
|
+
return ADBC_STATUS_OK;
|
119
|
+
}
|
120
|
+
|
121
|
+
AdbcStatusCode ConnectionNew(struct AdbcConnection *connection, struct AdbcError *error) {
|
122
|
+
|
123
|
+
CHECK_TRUE(connection, error, "Missing connection object");
|
124
|
+
connection->private_data = nullptr;
|
125
|
+
return ADBC_STATUS_OK;
|
126
|
+
}
|
127
|
+
|
128
|
+
AdbcStatusCode ConnectionSetOption(struct AdbcConnection *connection, const char *key, const char *value,
|
129
|
+
struct AdbcError *error) {
|
130
|
+
// there are no connection-level options that need to be set before connecting
|
131
|
+
return ADBC_STATUS_OK;
|
132
|
+
}
|
133
|
+
|
134
|
+
AdbcStatusCode ConnectionInit(struct AdbcConnection *connection, struct AdbcDatabase *database,
|
135
|
+
struct AdbcError *error) {
|
136
|
+
CHECK_TRUE(database, error, "Missing database");
|
137
|
+
CHECK_TRUE(database->private_data, error, "Invalid database");
|
138
|
+
CHECK_TRUE(connection, error, "Missing connection");
|
139
|
+
auto database_wrapper = (DuckDBAdbcDatabaseWrapper *)database->private_data;
|
140
|
+
|
141
|
+
connection->private_data = nullptr;
|
142
|
+
auto res = duckdb_connect(database_wrapper->database, (duckdb_connection *)&connection->private_data);
|
143
|
+
CHECK_RES(res, error, "Failed to connect to Database");
|
144
|
+
}
|
145
|
+
|
146
|
+
AdbcStatusCode ConnectionRelease(struct AdbcConnection *connection, struct AdbcError *error) {
|
147
|
+
if (connection && connection->private_data) {
|
148
|
+
duckdb_disconnect((duckdb_connection *)&connection->private_data);
|
149
|
+
connection->private_data = nullptr;
|
150
|
+
}
|
151
|
+
return ADBC_STATUS_OK;
|
152
|
+
}
|
153
|
+
|
154
|
+
// some stream callbacks
|
155
|
+
|
156
|
+
static int get_schema(struct ArrowArrayStream *stream, struct ArrowSchema *out) {
|
157
|
+
if (!stream || !stream->private_data || !out) {
|
158
|
+
return DuckDBError;
|
159
|
+
}
|
160
|
+
return duckdb_query_arrow_schema((duckdb_arrow)stream->private_data, (duckdb_arrow_schema *)&out);
|
161
|
+
}
|
162
|
+
|
163
|
+
static int get_next(struct ArrowArrayStream *stream, struct ArrowArray *out) {
|
164
|
+
if (!stream || !stream->private_data || !out) {
|
165
|
+
return DuckDBError;
|
166
|
+
}
|
167
|
+
out->release = nullptr;
|
168
|
+
|
169
|
+
return duckdb_query_arrow_array((duckdb_arrow)stream->private_data, (duckdb_arrow_array *)&out);
|
170
|
+
}
|
171
|
+
|
172
|
+
void release(struct ArrowArrayStream *stream) {
|
173
|
+
if (!stream || !stream->release) {
|
174
|
+
return;
|
175
|
+
}
|
176
|
+
stream->release = nullptr;
|
177
|
+
if (stream->private_data) {
|
178
|
+
duckdb_destroy_arrow((duckdb_arrow *)&stream->private_data);
|
179
|
+
stream->private_data = nullptr;
|
180
|
+
}
|
181
|
+
}
|
182
|
+
|
183
|
+
const char *get_last_error(struct ArrowArrayStream *stream) {
|
184
|
+
if (!stream) {
|
185
|
+
return nullptr;
|
186
|
+
}
|
187
|
+
return nullptr;
|
188
|
+
// return duckdb_query_arrow_error(stream);
|
189
|
+
}
|
190
|
+
|
191
|
+
// this is an evil hack, normally we would need a stream factory here, but its probably much easier if the adbc clients
|
192
|
+
// just hand over a stream
|
193
|
+
|
194
|
+
duckdb::unique_ptr<duckdb::ArrowArrayStreamWrapper>
|
195
|
+
stream_produce(uintptr_t factory_ptr,
|
196
|
+
std::pair<std::unordered_map<idx_t, std::string>, std::vector<std::string>> &project_columns,
|
197
|
+
duckdb::TableFilterSet *filters) {
|
198
|
+
|
199
|
+
// TODO this will ignore any projections or filters but since we don't expose the scan it should be sort of fine
|
200
|
+
auto res = duckdb::make_uniq<duckdb::ArrowArrayStreamWrapper>();
|
201
|
+
res->arrow_array_stream = *(ArrowArrayStream *)factory_ptr;
|
202
|
+
return res;
|
203
|
+
}
|
204
|
+
|
205
|
+
void stream_schema(uintptr_t factory_ptr, duckdb::ArrowSchemaWrapper &schema) {
|
206
|
+
auto stream = (ArrowArrayStream *)factory_ptr;
|
207
|
+
get_schema(stream, &schema.arrow_schema);
|
208
|
+
}
|
209
|
+
|
210
|
+
AdbcStatusCode Ingest(duckdb_connection connection, const char *table_name, struct ArrowArrayStream *input,
|
211
|
+
struct AdbcError *error) {
|
212
|
+
|
213
|
+
CHECK_TRUE(connection, error, "Invalid connection");
|
214
|
+
CHECK_TRUE(input, error, "Missing input arrow stream pointer");
|
215
|
+
CHECK_TRUE(table_name, error, "Missing database object name");
|
216
|
+
|
217
|
+
try {
|
218
|
+
// TODO evil cast, do we need a way to do this from the C api?
|
219
|
+
auto cconn = (duckdb::Connection *)connection;
|
220
|
+
cconn
|
221
|
+
->TableFunction("arrow_scan",
|
222
|
+
{duckdb::Value::POINTER((uintptr_t)input),
|
223
|
+
duckdb::Value::POINTER((uintptr_t)stream_produce),
|
224
|
+
duckdb::Value::POINTER((uintptr_t)get_schema)}) // TODO make this a parameter somewhere
|
225
|
+
->Create(table_name); // TODO this should probably be a temp table
|
226
|
+
// After creating a table, the arrow array stream is released. Hence we must set it as released to avoid
|
227
|
+
// double-releasing it
|
228
|
+
input->release = nullptr;
|
229
|
+
} catch (std::exception &ex) {
|
230
|
+
if (error) {
|
231
|
+
error->message = strdup(ex.what());
|
232
|
+
}
|
233
|
+
return ADBC_STATUS_INTERNAL;
|
234
|
+
} catch (...) {
|
235
|
+
return ADBC_STATUS_INTERNAL;
|
236
|
+
}
|
237
|
+
return ADBC_STATUS_OK;
|
238
|
+
}
|
239
|
+
|
240
|
+
struct DuckDBAdbcStatementWrapper {
|
241
|
+
::duckdb_connection connection;
|
242
|
+
::duckdb_arrow result;
|
243
|
+
::duckdb_prepared_statement statement;
|
244
|
+
char *ingestion_table_name;
|
245
|
+
ArrowArrayStream *ingestion_stream;
|
246
|
+
};
|
247
|
+
|
248
|
+
AdbcStatusCode StatementNew(struct AdbcConnection *connection, struct AdbcStatement *statement,
|
249
|
+
struct AdbcError *error) {
|
250
|
+
|
251
|
+
CHECK_TRUE(connection, error, "Missing connection object");
|
252
|
+
CHECK_TRUE(connection->private_data, error, "Invalid connection object");
|
253
|
+
CHECK_TRUE(statement, error, "Missing statement object");
|
254
|
+
|
255
|
+
statement->private_data = nullptr;
|
256
|
+
|
257
|
+
auto statement_wrapper = (DuckDBAdbcStatementWrapper *)malloc(sizeof(DuckDBAdbcStatementWrapper));
|
258
|
+
CHECK_TRUE(statement_wrapper, error, "Allocation error");
|
259
|
+
|
260
|
+
statement->private_data = statement_wrapper;
|
261
|
+
statement_wrapper->connection = (duckdb_connection)connection->private_data;
|
262
|
+
statement_wrapper->statement = nullptr;
|
263
|
+
statement_wrapper->result = nullptr;
|
264
|
+
statement_wrapper->ingestion_stream = nullptr;
|
265
|
+
statement_wrapper->ingestion_table_name = nullptr;
|
266
|
+
return ADBC_STATUS_OK;
|
267
|
+
}
|
268
|
+
|
269
|
+
AdbcStatusCode StatementRelease(struct AdbcStatement *statement, struct AdbcError *error) {
|
270
|
+
|
271
|
+
if (statement && statement->private_data) {
|
272
|
+
auto wrapper = (DuckDBAdbcStatementWrapper *)statement->private_data;
|
273
|
+
if (wrapper->statement) {
|
274
|
+
duckdb_destroy_prepare(&wrapper->statement);
|
275
|
+
wrapper->statement = nullptr;
|
276
|
+
}
|
277
|
+
if (wrapper->result) {
|
278
|
+
duckdb_destroy_arrow(&wrapper->result);
|
279
|
+
wrapper->result = nullptr;
|
280
|
+
}
|
281
|
+
if (wrapper->ingestion_stream) {
|
282
|
+
wrapper->ingestion_stream->release(wrapper->ingestion_stream);
|
283
|
+
wrapper->ingestion_stream->release = nullptr;
|
284
|
+
wrapper->ingestion_stream = nullptr;
|
285
|
+
}
|
286
|
+
if (wrapper->ingestion_table_name) {
|
287
|
+
free(wrapper->ingestion_table_name);
|
288
|
+
wrapper->ingestion_table_name = nullptr;
|
289
|
+
}
|
290
|
+
free(statement->private_data);
|
291
|
+
statement->private_data = nullptr;
|
292
|
+
}
|
293
|
+
return ADBC_STATUS_OK;
|
294
|
+
}
|
295
|
+
|
296
|
+
AdbcStatusCode StatementExecuteQuery(struct AdbcStatement *statement, struct ArrowArrayStream *out,
|
297
|
+
int64_t *rows_affected, struct AdbcError *error) {
|
298
|
+
CHECK_TRUE(statement, error, "Missing statement object");
|
299
|
+
CHECK_TRUE(statement->private_data, error, "Invalid statement object");
|
300
|
+
auto wrapper = (DuckDBAdbcStatementWrapper *)statement->private_data;
|
301
|
+
|
302
|
+
// TODO: Set affected rows, careful with early return
|
303
|
+
if (rows_affected) {
|
304
|
+
*rows_affected = 0;
|
305
|
+
}
|
306
|
+
|
307
|
+
if (wrapper->ingestion_stream && wrapper->ingestion_table_name) {
|
308
|
+
auto stream = wrapper->ingestion_stream;
|
309
|
+
wrapper->ingestion_stream = nullptr;
|
310
|
+
return Ingest(wrapper->connection, wrapper->ingestion_table_name, stream, error);
|
311
|
+
}
|
312
|
+
|
313
|
+
auto res = duckdb_execute_prepared_arrow(wrapper->statement, &wrapper->result);
|
314
|
+
CHECK_TRUE(res == DuckDBSuccess, error, duckdb_query_arrow_error(wrapper->result));
|
315
|
+
|
316
|
+
if (out) {
|
317
|
+
out->private_data = wrapper->result;
|
318
|
+
out->get_schema = get_schema;
|
319
|
+
out->get_next = get_next;
|
320
|
+
out->release = release;
|
321
|
+
out->get_last_error = get_last_error;
|
322
|
+
|
323
|
+
// because we handed out the stream pointer its no longer our responsibility to destroy it in
|
324
|
+
// AdbcStatementRelease, this is now done in release()
|
325
|
+
wrapper->result = nullptr;
|
326
|
+
}
|
327
|
+
|
328
|
+
return ADBC_STATUS_OK;
|
329
|
+
}
|
330
|
+
|
331
|
+
// this is a nop for us
|
332
|
+
AdbcStatusCode StatementPrepare(struct AdbcStatement *statement, struct AdbcError *error) {
|
333
|
+
CHECK_TRUE(statement, error, "Missing statement object");
|
334
|
+
CHECK_TRUE(statement->private_data, error, "Invalid statement object");
|
335
|
+
return ADBC_STATUS_OK;
|
336
|
+
}
|
337
|
+
|
338
|
+
AdbcStatusCode StatementSetSqlQuery(struct AdbcStatement *statement, const char *query, struct AdbcError *error) {
|
339
|
+
CHECK_TRUE(statement, error, "Missing statement object");
|
340
|
+
CHECK_TRUE(query, error, "Missing query");
|
341
|
+
|
342
|
+
auto wrapper = (DuckDBAdbcStatementWrapper *)statement->private_data;
|
343
|
+
auto res = duckdb_prepare(wrapper->connection, query, &wrapper->statement);
|
344
|
+
|
345
|
+
CHECK_RES(res, error, duckdb_prepare_error(wrapper->statement));
|
346
|
+
}
|
347
|
+
|
348
|
+
AdbcStatusCode StatementBindStream(struct AdbcStatement *statement, struct ArrowArrayStream *values,
|
349
|
+
struct AdbcError *error) {
|
350
|
+
CHECK_TRUE(statement, error, "Missing statement object");
|
351
|
+
CHECK_TRUE(values, error, "Missing stream object");
|
352
|
+
auto wrapper = (DuckDBAdbcStatementWrapper *)statement->private_data;
|
353
|
+
wrapper->ingestion_stream = values;
|
354
|
+
return ADBC_STATUS_OK;
|
355
|
+
}
|
356
|
+
|
357
|
+
AdbcStatusCode StatementSetOption(struct AdbcStatement *statement, const char *key, const char *value,
|
358
|
+
struct AdbcError *error) {
|
359
|
+
CHECK_TRUE(statement, error, "Missing statement object");
|
360
|
+
CHECK_TRUE(key, error, "Missing key object");
|
361
|
+
auto wrapper = (DuckDBAdbcStatementWrapper *)statement->private_data;
|
362
|
+
|
363
|
+
if (strcmp(key, ADBC_INGEST_OPTION_TARGET_TABLE) == 0) {
|
364
|
+
wrapper->ingestion_table_name = strdup(value);
|
365
|
+
return ADBC_STATUS_OK;
|
366
|
+
}
|
367
|
+
return ADBC_STATUS_INVALID_ARGUMENT;
|
368
|
+
}
|
369
|
+
|
370
|
+
static AdbcStatusCode QueryInternal(struct AdbcConnection *connection, struct ArrowArrayStream *out, const char *query,
|
371
|
+
struct AdbcError *error) {
|
372
|
+
AdbcStatusCode res;
|
373
|
+
AdbcStatement statement;
|
374
|
+
|
375
|
+
res = StatementNew(connection, &statement, error);
|
376
|
+
CHECK_TRUE(!res, error, "unable to initialize statement");
|
377
|
+
|
378
|
+
res = StatementSetSqlQuery(&statement, query, error);
|
379
|
+
CHECK_TRUE(!res, error, "unable to initialize statement");
|
380
|
+
|
381
|
+
res = StatementExecuteQuery(&statement, out, NULL, error);
|
382
|
+
CHECK_TRUE(!res, error, "unable to execute statement");
|
383
|
+
|
384
|
+
return ADBC_STATUS_OK;
|
385
|
+
}
|
386
|
+
|
387
|
+
AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth, const char *catalog,
|
388
|
+
const char *db_schema, const char *table_name, const char **table_type,
|
389
|
+
const char *column_name, struct ArrowArrayStream *out, struct AdbcError *error) {
|
390
|
+
CHECK_TRUE(catalog == nullptr || strcmp(catalog, "duckdb") == 0, error, "catalog must be NULL or 'duckdb'");
|
391
|
+
CHECK_TRUE(table_type == nullptr, error, "table types parameter not yet supported");
|
392
|
+
|
393
|
+
auto q = duckdb::StringUtil::Format(R"(
|
394
|
+
SELECT table_schema db_schema_name, LIST(table_schema_list) db_schema_tables FROM (
|
395
|
+
SELECT table_schema, { table_name : table_name, table_columns : LIST({column_name : column_name, ordinal_position : ordinal_position + 1, remarks : ''})} table_schema_list FROM information_schema.columns WHERE table_schema LIKE '%s' AND table_name LIKE '%s' AND column_name LIKE '%s' GROUP BY table_schema, table_name
|
396
|
+
) GROUP BY table_schema;
|
397
|
+
)",
|
398
|
+
db_schema ? db_schema : "%", table_name ? table_name : "%",
|
399
|
+
column_name ? column_name : "%");
|
400
|
+
|
401
|
+
return QueryInternal(connection, out, q.c_str(), error);
|
402
|
+
}
|
403
|
+
|
404
|
+
//
|
405
|
+
// AdbcStatusCode ConnectionGetCatalogs(struct AdbcConnection *connection, struct AdbcStatement *statement,
|
406
|
+
// struct AdbcError *error) {
|
407
|
+
// const char *q = "SELECT 'duckdb' catalog_name";
|
408
|
+
//
|
409
|
+
// return QueryInternal(connection, statement, q, error);
|
410
|
+
//}
|
411
|
+
//
|
412
|
+
// AdbcStatusCode ConnectionGetDbSchemas(struct AdbcConnection *connection, struct AdbcStatement *statement,
|
413
|
+
// struct AdbcError *error) {
|
414
|
+
// const char *q = "SELECT 'duckdb' catalog_name, schema_name db_schema_name FROM information_schema.schemata ORDER "
|
415
|
+
// "BY schema_name";
|
416
|
+
// return QueryInternal(connection, statement, q, error);
|
417
|
+
//}
|
418
|
+
AdbcStatusCode ConnectionGetTableTypes(struct AdbcConnection *connection, struct ArrowArrayStream *out,
|
419
|
+
struct AdbcError *error) {
|
420
|
+
const char *q = "SELECT DISTINCT table_type FROM information_schema.tables ORDER BY table_type";
|
421
|
+
return QueryInternal(connection, out, q, error);
|
422
|
+
}
|
423
|
+
//
|
424
|
+
// AdbcStatusCode ConnectionGetTables(struct AdbcConnection *connection, const char *catalog, const char *db_schema,
|
425
|
+
// const char *table_name, const char **table_types,
|
426
|
+
// struct AdbcStatement *statement, struct AdbcError *error) {
|
427
|
+
//
|
428
|
+
// CHECK_TRUE(catalog == nullptr || strcmp(catalog, "duckdb") == 0, error, "catalog must be NULL or 'duckdb'");
|
429
|
+
//
|
430
|
+
// // let's wait for https://github.com/lidavidm/arrow/issues/6
|
431
|
+
// CHECK_TRUE(table_types == nullptr, error, "table types parameter not yet supported");
|
432
|
+
// auto q = duckdb::StringUtil::Format(
|
433
|
+
// "SELECT 'duckdb' catalog_name, table_schema db_schema_name, table_name, table_type FROM "
|
434
|
+
// "information_schema.tables WHERE table_schema LIKE '%s' AND table_name LIKE '%s' ORDER BY table_schema, "
|
435
|
+
// "table_name",
|
436
|
+
// db_schema ? db_schema : "%", table_name ? table_name : "%");
|
437
|
+
//
|
438
|
+
// return QueryInternal(connection, statement, q.c_str(), error);
|
439
|
+
//}
|
440
|
+
|
441
|
+
} // namespace duckdb_adbc
|