fixed ast

This commit is contained in:
yariks5s 2023-08-01 19:14:11 +00:00
parent 2227945529
commit 6db7eaf4d8

View File

@ -18,7 +18,7 @@ static void createInformationSchemaView(ContextMutablePtr context, IDatabase & d
database.getDatabaseName() == DatabaseCatalog::INFORMATION_SCHEMA_UPPERCASE); database.getDatabaseName() == DatabaseCatalog::INFORMATION_SCHEMA_UPPERCASE);
if (database.getEngineName() != "Memory") if (database.getEngineName() != "Memory")
return; return;
bool is_uppercase = database.getDatabaseName() == DatabaseCatalog::INFORMATION_SCHEMA_UPPERCASE; // bool is_uppercase = database.getDatabaseName() == DatabaseCatalog::INFORMATION_SCHEMA_UPPERCASE;
String metadata_resource_name = view_name + ".sql"; String metadata_resource_name = view_name + ".sql";
auto attach_query = getResource(metadata_resource_name); auto attach_query = getResource(metadata_resource_name);
@ -34,14 +34,20 @@ static void createInformationSchemaView(ContextMutablePtr context, IDatabase & d
assert(view_name == ast_create.getTable()); assert(view_name == ast_create.getTable());
ast_create.attach = false; ast_create.attach = false;
ast_create.setDatabase(database.getDatabaseName()); ast_create.setDatabase(database.getDatabaseName());
if (is_uppercase) // if (is_uppercase)
ast_create.setTable(Poco::toUpper(view_name)); // ast_create.setTable(Poco::toUpper(view_name));
StoragePtr view = createTableFromAST(ast_create, database.getDatabaseName(), StoragePtr view = createTableFromAST(ast_create, database.getDatabaseName(),
database.getTableDataPath(ast_create), context, true).second; database.getTableDataPath(ast_create), context, true).second;
database.createTable(context, ast_create.getTable(), view, ast);
ASTPtr ast_upper = ast_create.clone();
auto & ast_create_upper = ast_upper->as<ASTCreateQuery &>();
ast_create.setTable(Poco::toUpper(view_name));
StoragePtr view_upper = createTableFromAST(ast_create_upper, database.getDatabaseName(),
database.getTableDataPath(ast_create_upper), context, true).second;
database.createTable(context, ast_create_upper.getTable(), view_upper, ast_upper);
database.createTable(context, Poco::toUpper(ast_create.getTable()), view, ast);
database.createTable(context, Poco::toLower(ast_create.getTable()), view, ast);
} }
catch (...) catch (...)