diff --git a/src/proxy/admin_cleanup_test.go b/src/proxy/admin_cleanup_test.go index 1ab97a6f..69d8e602 100644 --- a/src/proxy/admin_cleanup_test.go +++ b/src/proxy/admin_cleanup_test.go @@ -349,3 +349,22 @@ func TestCleanupDropErr(t *testing.T) { assert.NotNil(t, err) } } + +func TestCleanupReadOnly(t *testing.T) { + log := xlog.NewStdLog(xlog.Level(xlog.PANIC)) + fakedbs, proxy, cleanup := MockProxy(log) + defer cleanup() + + address := proxy.Address() + client, err := driver.NewConn("mock", "mock", address, "", "utf8") + assert.Nil(t, err) + + // set radon readonly. + proxy.SetReadOnly(true) + query := "radon cleanup" + fakedbs.AddQuery(query, &sqltypes.Result{}) + _, err = client.FetchAll(query, -1) + want := "The MySQL server is running with the --read-only option so it cannot execute this statement (errno 1290) (sqlstate 42000)" + got := err.Error() + assert.Equal(t, want, got) +} diff --git a/src/proxy/query.go b/src/proxy/query.go index cdce161c..9fdb0fc2 100644 --- a/src/proxy/query.go +++ b/src/proxy/query.go @@ -377,7 +377,7 @@ func (spanner *Spanner) IsDDL(node sqlparser.Statement) bool { func (spanner *Spanner) IsAdminCmd(node sqlparser.Statement) bool { if node, ok := node.(*sqlparser.Radon); ok { switch node.Action { - case sqlparser.AttachStr, sqlparser.DetachStr, sqlparser.ReshardStr: + case sqlparser.AttachStr, sqlparser.DetachStr, sqlparser.ReshardStr, sqlparser.CleanupStr: return true } }