From 201c8d34975165405d7ba014f05656e586d882f0 Mon Sep 17 00:00:00 2001 From: Roan Kattouw Date: Wed, 12 Jun 2019 16:29:50 -0700 Subject: [PATCH] Database: Recognize USE queries as non-write queries This should unbreak Ie7341a0e6c41, which switched DatabaseMysql::doSelectDomain() from using doQuery() to using executeQuery() for its USE query, which means it no longer bypasses the isWriteQuery() check. This caused every USE query on a replica DB to fail, because it was considered a write query. Bug: T225682 Bug: T212284 Change-Id: Iecb8b9f6e64d08df8c64b3133078b5324e654ed1 Follows-Up: Ie7341a0e6c4149fc375cc357877486efe9e56eb9 --- includes/libs/rdbms/database/Database.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index ab718ec267..a2caa96a96 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -1120,11 +1120,11 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware // for all queries within a request. Use cases: // - Treating these as writes would trigger ChronologyProtector (see method doc). // - We use this method to reject writes to replicas, but we need to allow - // use of transactions on replicas for read snapshots. This fine given + // use of transactions on replicas for read snapshots. This is fine given // that transactions by themselves don't make changes, only actual writes // within the transaction matter, which we still detect. return !preg_match( - '/^(?:SELECT|BEGIN|ROLLBACK|COMMIT|SAVEPOINT|RELEASE|SET|SHOW|EXPLAIN|\(SELECT)\b/i', + '/^(?:SELECT|BEGIN|ROLLBACK|COMMIT|SAVEPOINT|RELEASE|SET|SHOW|EXPLAIN|USE|\(SELECT)\b/i', $sql ); } -- 2.20.1