From ccfc41bce5f3d3280f802be3310707a1ce6411b0 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Sat, 12 Feb 2022 13:50:05 +0300 Subject: [PATCH] Allow constraints for ODBC and JDBC tables --- src/Storages/StorageXDBC.cpp | 9 +++++---- src/Storages/StorageXDBC.h | 3 ++- src/TableFunctions/ITableFunctionXDBC.cpp | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Storages/StorageXDBC.cpp b/src/Storages/StorageXDBC.cpp index 90ac04ed250..79f99227aca 100644 --- a/src/Storages/StorageXDBC.cpp +++ b/src/Storages/StorageXDBC.cpp @@ -27,19 +27,19 @@ StorageXDBC::StorageXDBC( const StorageID & table_id_, const std::string & remote_database_name_, const std::string & remote_table_name_, - const ColumnsDescription & columns_, + ColumnsDescription columns_, + ConstraintsDescription constraints_, const String & comment, ContextPtr context_, const BridgeHelperPtr bridge_helper_) - /// Please add support for constraints as soon as StorageODBC or JDBC will support insertion. : IStorageURLBase( "", context_, table_id_, IXDBCBridgeHelper::DEFAULT_FORMAT, getFormatSettings(context_), - columns_, - ConstraintsDescription{}, + std::move(columns_), + std::move(constraints_), comment, "" /* CompressionMethod */) , bridge_helper(bridge_helper_) @@ -174,6 +174,7 @@ namespace engine_args[1]->as().value.safeGet(), engine_args[2]->as().value.safeGet(), args.columns, + args.constraints, args.comment, args.getContext(), bridge_helper); diff --git a/src/Storages/StorageXDBC.h b/src/Storages/StorageXDBC.h index 4438e1c4737..483f28d410e 100644 --- a/src/Storages/StorageXDBC.h +++ b/src/Storages/StorageXDBC.h @@ -32,7 +32,8 @@ public: const StorageID & table_id_, const std::string & remote_database_name, const std::string & remote_table_name, - const ColumnsDescription & columns_, + ColumnsDescription columns_, + ConstraintsDescription constraints_, const String & comment, ContextPtr context_, BridgeHelperPtr bridge_helper_); diff --git a/src/TableFunctions/ITableFunctionXDBC.cpp b/src/TableFunctions/ITableFunctionXDBC.cpp index e9d33acc6de..6d2b508aaa3 100644 --- a/src/TableFunctions/ITableFunctionXDBC.cpp +++ b/src/TableFunctions/ITableFunctionXDBC.cpp @@ -97,7 +97,7 @@ StoragePtr ITableFunctionXDBC::executeImpl(const ASTPtr & /*ast_function*/, Cont startBridgeIfNot(context); auto columns = getActualTableStructure(context); auto result = std::make_shared( - StorageID(getDatabaseName(), table_name), schema_name, remote_table_name, columns, String{}, context, helper); + StorageID(getDatabaseName(), table_name), schema_name, remote_table_name, columns, ConstraintsDescription{}, String{}, context, helper); result->startup(); return result; }