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
// 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
);
}