diff --git a/src/Processors/Transforms/PostgreSQLSource.cpp b/src/Processors/Transforms/PostgreSQLSource.cpp index 6926ac26bbc..77c2fc41aa1 100644 --- a/src/Processors/Transforms/PostgreSQLSource.cpp +++ b/src/Processors/Transforms/PostgreSQLSource.cpp @@ -1,4 +1,5 @@ #include "PostgreSQLSource.h" +#include "Common/Exception.h" #if USE_LIBPQXX #include @@ -22,6 +23,10 @@ namespace DB { +namespace ErrorCodes +{ + extern const int TOO_MANY_COLUMNS; +} template PostgreSQLSource::PostgreSQLSource( @@ -123,6 +128,11 @@ Chunk PostgreSQLSource::generate() if (!row) break; + if (row->size() > description.sample_block.columns()) + throw Exception(ErrorCodes::TOO_MANY_COLUMNS, + "Row has too many columns: {}, expected structure: {}", + row->size(), description.sample_block.dumpStructure()); + for (const auto idx : collections::range(0, row->size())) { const auto & sample = description.sample_block.getByPosition(idx);