| 56 | } |
| 57 | |
| 58 | StorageMySQL::StorageMySQL( |
| 59 | const StorageID & table_id_, |
| 60 | mysqlxx::PoolWithFailover && pool_, |
| 61 | const std::string & remote_database_name_, |
| 62 | const std::string & remote_table_name_, |
| 63 | const bool replace_query_, |
| 64 | const std::string & on_duplicate_clause_, |
| 65 | const ColumnsDescription & columns_, |
| 66 | const ConstraintsDescription & constraints_, |
| 67 | const String & comment, |
| 68 | ContextPtr context_, |
| 69 | const MySQLSettings & mysql_settings_) |
| 70 | : StorageWithCommonVirtualColumns(table_id_) |
| 71 | , WithContext(context_->getGlobalContext()) |
| 72 | , remote_database_name(remote_database_name_) |
| 73 | , remote_table_name(remote_table_name_) |
| 74 | , replace_query{replace_query_} |
| 75 | , on_duplicate_clause{on_duplicate_clause_} |
| 76 | , mysql_settings(std::make_unique<MySQLSettings>(mysql_settings_)) |
| 77 | , pool(std::make_shared<mysqlxx::PoolWithFailover>(pool_)) |
| 78 | , log(getLogger("StorageMySQL (" + table_id_.getFullTableName() + ")")) |
| 79 | { |
| 80 | StorageInMemoryMetadata storage_metadata; |
| 81 | |
| 82 | if (columns_.empty()) |
| 83 | { |
| 84 | auto columns = getTableStructureFromData(*pool, remote_database_name, remote_table_name, context_); |
| 85 | storage_metadata.setColumns(columns); |
| 86 | } |
| 87 | else |
| 88 | storage_metadata.setColumns(columns_); |
| 89 | |
| 90 | storage_metadata.setConstraints(constraints_); |
| 91 | storage_metadata.setComment(comment); |
| 92 | storage_metadata.setVirtuals(createVirtuals()); |
| 93 | setInMemoryMetadata(storage_metadata); |
| 94 | } |
| 95 | |
| 96 | VirtualColumnsDescription StorageMySQL::createVirtuals() |
| 97 | { |
nothing calls this directly
no test coverage detected