github.com/dolthub/go-mysql-server@v0.18.0/sql/plan/show_replica_status.go (about) 1 // Copyright 2022 Dolthub, Inc. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package plan 16 17 import ( 18 "github.com/dolthub/go-mysql-server/sql" 19 "github.com/dolthub/go-mysql-server/sql/binlogreplication" 20 "github.com/dolthub/go-mysql-server/sql/types" 21 22 "github.com/dolthub/vitess/go/sqltypes" 23 ) 24 25 // ShowReplicaStatus is the plan node for the "SHOW REPLICA STATUS" statement. 26 // https://dev.mysql.com/doc/refman/8.0/en/show-replica-status.html 27 type ShowReplicaStatus struct { 28 ReplicaController binlogreplication.BinlogReplicaController 29 } 30 31 var _ sql.Node = (*ShowReplicaStatus)(nil) 32 var _ sql.CollationCoercible = (*ShowReplicaStatus)(nil) 33 var _ BinlogReplicaControllerCommand = (*ShowReplicaStatus)(nil) 34 35 func NewShowReplicaStatus() *ShowReplicaStatus { 36 return &ShowReplicaStatus{} 37 } 38 39 // WithBinlogReplicaController implements the BinlogReplicaControllerCommand interface. 40 func (s *ShowReplicaStatus) WithBinlogReplicaController(controller binlogreplication.BinlogReplicaController) sql.Node { 41 nc := *s 42 nc.ReplicaController = controller 43 return &nc 44 } 45 46 func (s *ShowReplicaStatus) Resolved() bool { 47 return true 48 } 49 50 func (s *ShowReplicaStatus) String() string { 51 return "SHOW REPLICA STATUS" 52 } 53 54 func (s *ShowReplicaStatus) Schema() sql.Schema { 55 return sql.Schema{ 56 {Name: "Replica_IO_State", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 57 {Name: "Source_Host", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 255), Default: nil, Nullable: false}, 58 {Name: "Source_User", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 59 {Name: "Source_Port", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 60 {Name: "Connect_Retry", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 61 {Name: "Source_Log_File", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 62 {Name: "Read_Source_Log_Pos", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 63 {Name: "Relay_Log_File", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 64 {Name: "Relay_Log_Pos", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 65 {Name: "Relay_Source_Log_File", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 66 {Name: "Replica_IO_Running", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 128), Default: nil, Nullable: false}, 67 {Name: "Replica_SQL_Running", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 128), Default: nil, Nullable: false}, 68 {Name: "Replicate_Do_DB", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 128), Default: nil, Nullable: false}, 69 {Name: "Replicate_Ignore_DB", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 128), Default: nil, Nullable: false}, 70 {Name: "Replicate_Do_Table", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 256), Default: nil, Nullable: false}, 71 {Name: "Replicate_Ignore_Table", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 256), Default: nil, Nullable: false}, 72 {Name: "Replicate_Wild_Do_Table", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 128), Default: nil, Nullable: false}, 73 {Name: "Replicate_Wild_Ignore_Table", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 128), Default: nil, Nullable: false}, 74 {Name: "Last_Errno", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 75 {Name: "Last_Error", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 256), Default: nil, Nullable: false}, 76 {Name: "Skip_Counter", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 77 {Name: "Exec_Source_Log_Pos", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 78 {Name: "Relay_Log_Space", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 79 {Name: "Until_Condition", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 80 {Name: "Until_Log_File", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 81 {Name: "Until_Log_Pos", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 82 {Name: "Source_SSL_Allowed", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 83 {Name: "Source_SSL_CA_File", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 84 {Name: "Source_SSL_CA_Path", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 85 {Name: "Source_SSL_Cert", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 86 {Name: "Source_SSL_Cipher", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 87 {Name: "Source_SSL_CRL_File", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 88 {Name: "Source_SSL_CRL_Path", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 89 {Name: "Source_SSL_Key", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 90 {Name: "Source_SSL_Verify_Server_Cert", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 91 {Name: "Seconds_Behind_Source", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 92 {Name: "Last_IO_Errno", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 93 {Name: "Last_IO_Error", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 256), Default: nil, Nullable: false}, 94 {Name: "Last_SQL_Errno", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 95 {Name: "Last_SQL_Error", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 256), Default: nil, Nullable: false}, 96 {Name: "Replicate_Ignore_Server_Ids", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 97 {Name: "Source_Server_Id", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 98 {Name: "Source_UUID", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 99 {Name: "Source_Info_File", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 100 {Name: "SQL_Delay", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 101 {Name: "SQL_Remaining_Delay", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 102 {Name: "Replica_SQL_Running_State", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 103 {Name: "Source_Retry_Count", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 104 {Name: "Source_Bind", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 105 {Name: "Last_IO_Error_Timestamp", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 106 {Name: "Last_SQL_Error_Timestamp", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 107 {Name: "Retrieved_Gtid_Set", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 128), Default: nil, Nullable: false}, 108 {Name: "Executed_Gtid_Set", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 128), Default: nil, Nullable: false}, 109 {Name: "Auto_Position", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 110 {Name: "Replicate_Rewrite_DB", Type: types.MustCreateStringWithDefaults(sqltypes.VarChar, 64), Default: nil, Nullable: false}, 111 } 112 } 113 114 func (s *ShowReplicaStatus) Children() []sql.Node { 115 return nil 116 } 117 118 func (s *ShowReplicaStatus) IsReadOnly() bool { 119 return true 120 } 121 122 func (s *ShowReplicaStatus) WithChildren(children ...sql.Node) (sql.Node, error) { 123 if len(children) != 0 { 124 return nil, sql.ErrInvalidChildrenNumber.New(s, len(children), 0) 125 } 126 127 newNode := *s 128 return &newNode, nil 129 } 130 131 func (s *ShowReplicaStatus) CheckPrivileges(ctx *sql.Context, opChecker sql.PrivilegedOperationChecker) bool { 132 return opChecker.UserHasPrivileges(ctx, sql.NewPrivilegedOperation(sql.PrivilegeCheckSubject{}, sql.PrivilegeType_ReplicationClient)) 133 } 134 135 // CollationCoercibility implements the interface sql.CollationCoercible. 136 func (*ShowReplicaStatus) CollationCoercibility(ctx *sql.Context) (collation sql.CollationID, coercibility byte) { 137 return sql.Collation_binary, 7 138 }