| 258 | } |
| 259 | |
| 260 | static inline BlockOutputStreamPtr |
| 261 | getTableOutput(const String & database_name, const String & table_name, ContextMutablePtr query_context, bool insert_delete_flag_column = false) |
| 262 | { |
| 263 | const StoragePtr & storage = DatabaseCatalog::instance().getTable(StorageID(database_name, table_name), query_context); |
| 264 | |
| 265 | WriteBufferFromOwnString insert_columns_str; |
| 266 | const StorageInMemoryMetadata & storage_metadata = storage->getInMemoryMetadata(); |
| 267 | const ColumnsDescription & storage_columns = storage_metadata.getColumns(); |
| 268 | const NamesAndTypesList & insert_columns_names = storage_columns.getOrdinary(); |
| 269 | |
| 270 | |
| 271 | for (auto iterator = insert_columns_names.begin(); iterator != insert_columns_names.end(); ++iterator) |
| 272 | { |
| 273 | if (iterator != insert_columns_names.begin()) |
| 274 | insert_columns_str << ", "; |
| 275 | |
| 276 | insert_columns_str << backQuoteIfNeed(iterator->name); |
| 277 | } |
| 278 | if (insert_delete_flag_column) |
| 279 | { |
| 280 | insert_columns_str << ", " << backQuoteIfNeed(StorageInMemoryMetadata::DELETE_FLAG_COLUMN_NAME); |
| 281 | } |
| 282 | |
| 283 | String comment = "Materialize MySQL step 1: execute dump data"; |
| 284 | BlockIO res = tryToExecuteQuery("INSERT INTO " + backQuoteIfNeed(table_name) + "(" + insert_columns_str.str() + ")" + " VALUES", |
| 285 | query_context, database_name, comment); |
| 286 | |
| 287 | if (!res.out) |
| 288 | throw Exception("LOGICAL ERROR: It is a bug.", ErrorCodes::LOGICAL_ERROR); |
| 289 | |
| 290 | return res.out; |
| 291 | } |
| 292 | |
| 293 | static inline UInt32 randomNumber() |
| 294 | { |
no test coverage detected