diff --git a/src/main/connection.cpp b/src/main/connection.cpp index 28d28643444..5fe82952e22 100644 --- a/src/main/connection.cpp +++ b/src/main/connection.cpp @@ -100,9 +100,6 @@ std::unique_ptr Connection::prepareNoLock( auto statement = Parser::parseQuery(query); preparedStatement->preparedSummary.statementType = statement->getStatementType(); preparedStatement->readOnly = parser::StatementReadWriteAnalyzer().isReadOnly(*statement); - if (database->systemConfig.readOnly && !preparedStatement->isReadOnly()) { - throw ConnectionException("Cannot execute write operations in a read-only database!"); - } if (statement->getStatementType() != StatementType::TRANSACTION) { auto txContext = clientContext->transactionContext.get(); if (txContext->isAutoTransaction()) { @@ -114,6 +111,9 @@ std::unique_ptr Connection::prepareNoLock( if (!clientContext->getTx()->isReadOnly()) { database->catalog->initCatalogContentForWriteTrxIfNecessary(); database->storageManager->initStatistics(); + if (database->systemConfig.readOnly) { + throw ConnectionException("Cannot execute write operations in a read-only database!"); + } } } // binding