
With these changes SET @saved_cs_client= @@character_set_client; will be classified as QUERY_TYPE_USERVAR_WRITE and SELECT 1 AS c1 FROM t1 ORDER BY ( SELECT 1 AS c2 FROM t1 GROUP BY GREATEST(LAST_INSERT_ID(), t1.a) ORDER BY GREATEST(LAST_INSERT_ID(), t1.a) LIMIT 1); will be classified as QUERY_TYPE_READ|QUERY_TYPE_MASTER_READ