Merge pull request #53832 from kssenii/mat-pg-fix-get-create-table

Materialized postgres: fix uncaught exception in getCreateTableQueryImpl
This commit is contained in:
Kseniia Sumarokova 2023-08-25 18:24:07 +02:00 committed by GitHub
commit 8633b8fbc9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -35,6 +35,7 @@ namespace ErrorCodes
extern const int UNKNOWN_TABLE;
extern const int BAD_ARGUMENTS;
extern const int NOT_IMPLEMENTED;
extern const int CANNOT_GET_CREATE_TABLE_QUERY;
}
DatabaseMaterializedPostgreSQL::DatabaseMaterializedPostgreSQL(
@ -221,10 +222,25 @@ ASTPtr DatabaseMaterializedPostgreSQL::getCreateTableQueryImpl(const String & ta
std::lock_guard lock(handler_mutex);
/// FIXME TSA
ASTPtr ast_storage;
try
{
auto storage = std::make_shared<StorageMaterializedPostgreSQL>(StorageID(TSA_SUPPRESS_WARNING_FOR_READ(database_name), table_name), getContext(), remote_database_name, table_name);
auto ast_storage = replication_handler->getCreateNestedTableQuery(storage.get(), table_name);
ast_storage = replication_handler->getCreateNestedTableQuery(storage.get(), table_name);
assert_cast<ASTCreateQuery *>(ast_storage.get())->uuid = UUIDHelpers::generateV4();
}
catch (...)
{
if (throw_on_error)
{
throw Exception(ErrorCodes::CANNOT_GET_CREATE_TABLE_QUERY,
"Received error while fetching table structure for table {} from PostgreSQL: {}",
backQuote(table_name), getCurrentExceptionMessage(true));
}
tryLogCurrentException(__PRETTY_FUNCTION__);
}
return ast_storage;
}