MCPcopy Create free account
hub / github.com/ByConity/ByConity / fetchTablesCreateQuery

Function fetchTablesCreateQuery

src/Databases/MySQL/MaterializeMetadata.cpp:28–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26}
27
28static std::unordered_map<String, String> fetchTablesCreateQuery(
29 const mysqlxx::PoolWithFailover::Entry & connection, const String & database_name,
30 const std::vector<String> & fetch_tables, std::unordered_set<String> & materialized_tables_list,
31 const Settings & global_settings)
32{
33 std::unordered_map<String, String> tables_create_query;
34 for (const auto & fetch_table_name : fetch_tables)
35 {
36 if (!materialized_tables_list.contains(fetch_table_name))
37 {
38 LOG_INFO(&Poco::Logger::get("fetchTablesCreateQuery"), "Skip table " + fetch_table_name + " as it is not in materialized_table_list");
39 continue;
40 }
41
42 Block show_create_table_header{
43 {std::make_shared<DataTypeString>(), "Table"},
44 {std::make_shared<DataTypeString>(), "Create Table"},
45 };
46
47 StreamSettings mysql_input_stream_settings(global_settings, false, true);
48 MySQLBlockInputStream show_create_table(
49 connection, "SHOW CREATE TABLE " + backQuoteIfNeed(database_name) + "." + backQuoteIfNeed(fetch_table_name),
50 show_create_table_header, mysql_input_stream_settings);
51
52 Block create_query_block = show_create_table.read();
53 if (!create_query_block || create_query_block.rows() != 1)
54 throw Exception("LOGICAL ERROR mysql show create return more rows.", ErrorCodes::LOGICAL_ERROR);
55
56 tables_create_query[fetch_table_name] = create_query_block.getByName("Create Table").column->getDataAt(0).toString();
57 }
58
59 return tables_create_query;
60}
61
62std::vector<String> MaterializeMetadata::fetchTablesInDB(const mysqlxx::PoolWithFailover::Entry & connection, const std::string & database, const Settings & global_settings)
63{

Callers 1

Calls 9

backQuoteIfNeedFunction · 0.85
getByNameMethod · 0.80
getFunction · 0.50
ExceptionClass · 0.50
containsMethod · 0.45
readMethod · 0.45
rowsMethod · 0.45
toStringMethod · 0.45
getDataAtMethod · 0.45

Tested by

no test coverage detected