From 158e5dfcbf8b084024d587313de190defa5329b9 Mon Sep 17 00:00:00 2001 From: xiyang Date: Wed, 29 Nov 2023 13:52:59 +0800 Subject: [PATCH] X --- src/main/connection.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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