@@ -141,6 +141,11 @@ void QuerySession::analyzeQuery(std::string const& sql, std::shared_ptr<query::S
141141 LOGS (_log, LOG_LVL_TRACE, " Query Plugins applied: " << *this );
142142 LOGS (_log, LOG_LVL_TRACE, " ORDER BY clause for result query: " << getResultOrderBy ());
143143
144+ // Besides analysing an explicit result of the operation, allow catching CSS exceptions
145+ // that may be thrown by the method.
146+ if (!_validateDominantDbs ()) {
147+ _error = " Dominant databases validation failed" ;
148+ }
144149 } catch (QueryProcessingBug& b) {
145150 _error = std::string (" QuerySession bug:" ) + b.what ();
146151 } catch (qana::AnalysisError& e) {
@@ -216,7 +221,13 @@ bool QuerySession::containsTable(std::string const& dbName, std::string const& t
216221 return _context->containsTable (dbName, tableName);
217222}
218223
219- bool QuerySession::validateDominantDbs () const {
224+ bool QuerySession::_validateDominantDbs () const {
225+ if (_skipDominatDbsValidation) {
226+ LOGS (_log, LOG_LVL_DEBUG,
227+ " QuerySession::" << __func__ << " : Skipping dominant DB validation in unit test" );
228+ return true ;
229+ }
230+
220231 if (_context->dominantDbs .empty ()) {
221232 LOGS (_log, LOG_LVL_WARN, " QuerySession::" << __func__ << " : no dominant dbs specified" );
222233 return false ;
@@ -245,21 +256,13 @@ bool QuerySession::validateDominantDbs() const {
245256 return true ;
246257}
247258
248- css::StripingParams QuerySession::getDbStriping () const {
249- if (!validateDominantDbs ()) {
250- throw std::logic_error (" QuerySession::" + std::string (__func__) + " : Invalid dominant databases" );
251- }
252- return _context->getDbStriping ();
253- }
259+ css::StripingParams QuerySession::getDbStriping () const { return _context->getDbStriping (); }
254260
255261std::shared_ptr<IntSet const > QuerySession::getEmptyChunks () {
256262 if (_css == nullptr ) {
257263 LOGS (_log, LOG_LVL_WARN, " QuerySession::" << __func__ << " no _css" );
258264 return nullptr ;
259265 }
260- if (!validateDominantDbs ()) {
261- throw std::logic_error (" QuerySession::" + std::string (__func__) + " : Invalid dominant databases" );
262- }
263266 std::shared_ptr<IntSet> result = std::make_shared<IntSet>();
264267 for (auto const & dbName : _context->dominantDbs ) {
265268 LOGS (_log, LOG_LVL_TRACE, " QuerySession::" << __func__ << " " << dbName);
@@ -298,7 +301,7 @@ void QuerySession::finalize() {
298301 }
299302}
300303
301- QuerySession::QuerySession (Test& t) : _css(t.css), _defaultDb(t.defaultDb) {
304+ QuerySession::QuerySession (Test& t) : _css(t.css), _defaultDb(t.defaultDb), _skipDominatDbsValidation( true ) {
302305 sql::SqlConfig sqlConfig (t.sqlConfig );
303306 _databaseModels = DatabaseModels::create (sqlConfig, sqlConfig);
304307 _initContext ();
@@ -442,10 +445,6 @@ std::ostream& operator<<(std::ostream& out, QuerySession const& querySession) {
442445ChunkQuerySpec::Ptr QuerySession::buildChunkQuerySpec (query::QueryTemplate::Vect const & queryTemplates,
443446 ChunkSpec const & chunkSpec,
444447 bool fillInChunkIdTag) const {
445- if (!validateDominantDbs ()) {
446- throw std::logic_error (" QuerySession::" + std::string (__func__) + " : Invalid dominant databases" );
447- }
448-
449448 // Any dominant database (if there is more than one) works here. Note that after the previously made
450449 // validation step, there should be at least one such database, and if there are more than one, then
451450 // all databases ara guaranteeded to have the same striping parameters. The only role if the database
0 commit comments