forked from dolthub/go-mysql-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
replica_source_info_table.go
225 lines (212 loc) · 7.95 KB
/
replica_source_info_table.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
// Copyright 2023 Dolthub, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package mysql_db
import (
"github.com/dolthub/vitess/go/sqltypes"
"github.com/gabereiser/go-mysql-server/sql/types"
"github.com/gabereiser/go-mysql-server/sql"
"github.com/gabereiser/go-mysql-server/sql/expression"
"github.com/gabereiser/go-mysql-server/sql/in_mem_table"
)
// replicaSourceInfoTblName stores the name of the mysql table for persistent storage
// of replication data.
// For more details, see: https://dev.mysql.com/doc/refman/8.0/en/replica-logs-status.html
// Note: MySQL hasn't updated this table name yet to move to the newer, inclusive
//
// naming terms, so for compatibility, we match the current name.
const replicaSourceInfoTblName = "slave_master_info"
var replicaSourceInfoTblSchema sql.Schema
type ReplicaSourceInfoPrimaryKey struct {
Channel string
}
var _ in_mem_table.Key = ReplicaSourceInfoPrimaryKey{}
// KeyFromEntry implements the interface in_mem_table.Key.
func (r ReplicaSourceInfoPrimaryKey) KeyFromEntry(_ *sql.Context, entry in_mem_table.Entry) (in_mem_table.Key, error) {
_, ok := entry.(*ReplicaSourceInfo)
if !ok {
return nil, errPrimaryKeyUnknownEntry.New(replicaSourceInfoTblName)
}
return ReplicaSourceInfoPrimaryKey{
Channel: "",
}, nil
}
// KeyFromRow implements the interface in_mem_table.Key.
func (r ReplicaSourceInfoPrimaryKey) KeyFromRow(_ *sql.Context, row sql.Row) (in_mem_table.Key, error) {
if len(row) != len(replicaSourceInfoTblSchema) {
return r, errPrimaryKeyUnknownSchema.New(replicaSourceInfoTblName)
}
return ReplicaSourceInfoPrimaryKey{
Channel: "",
}, nil
}
func init() {
char255_ascii_general_ci := types.MustCreateString(sqltypes.Char, 255, sql.Collation_ascii_general_ci)
char64_utf8mb3_bin := types.MustCreateString(sqltypes.Char, 64, sql.Collation_utf8mb3_bin)
char64_utf8mb3_general_ci := types.MustCreateString(sqltypes.Char, 64, sql.Collation_utf8mb3_general_ci)
replicaSourceInfoTblSchema = sql.Schema{
columnTemplate("Number_of_lines", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Uint32,
}),
columnTemplate("Master_log_name", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
}),
columnTemplate("Master_log_pos", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Uint64,
}),
columnTemplate("Host", replicaSourceInfoTblName, false, &sql.Column{
Type: char255_ascii_general_ci,
Nullable: true,
}),
columnTemplate("User_name", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("User_password", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Port", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Uint32,
}),
columnTemplate("Connect_retry", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Uint32,
}),
columnTemplate("Enabled_ssl", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Int8,
}),
columnTemplate("Ssl_ca", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Ssl_capath", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Ssl_cert", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Ssl_cipher", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Ssl_key", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Ssl_verify_server_cert", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Int8,
}),
columnTemplate("Heartbeat", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Float32,
}),
columnTemplate("Bind", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Ignored_server_ids", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Uuid", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Retry_count", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Uint64,
}),
columnTemplate("Ssl_crl", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Ssl_crlpath", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Enabled_auto_position", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Int8,
}),
columnTemplate("Channel_name", replicaSourceInfoTblName, true, &sql.Column{
Type: char64_utf8mb3_general_ci,
}),
columnTemplate("Tls_version", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Public_key_path", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Get_public_key", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Int8,
}),
columnTemplate("Network_namespace", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Master_compression_algorithm", replicaSourceInfoTblName, false, &sql.Column{
Type: char64_utf8mb3_bin,
}),
columnTemplate("Master_zstd_compression_level", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Uint32,
}),
columnTemplate("Tls_ciphersuites", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Text,
Nullable: true,
}),
columnTemplate("Source_connection_auto_failover", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Int8,
Default: mustDefault(expression.NewLiteral(0, types.Int8), types.Int8, true, false),
}),
columnTemplate("Gtid_only", replicaSourceInfoTblName, false, &sql.Column{
Type: types.Int8,
Default: mustDefault(expression.NewLiteral(0, types.Int8), types.Int8, true, false),
}),
}
}
const (
replicaSourceInfoTblColIndex_Number_of_lines int = iota
replicaSourceInfoTblColIndex_Master_log_name
replicaSourceInfoTblColIndex_Master_log_pos
replicaSourceInfoTblColIndex_Host
replicaSourceInfoTblColIndex_User_name
replicaSourceInfoTblColIndex_User_password
replicaSourceInfoTblColIndex_Port
replicaSourceInfoTblColIndex_Connect_retry
replicaSourceInfoTblColIndex_Enabled_ssl
replicaSourceInfoTblColIndex_Ssl_ca
replicaSourceInfoTblColIndex_Ssl_capath
replicaSourceInfoTblColIndex_Ssl_cert
replicaSourceInfoTblColIndex_Ssl_cipher
replicaSourceInfoTblColIndex_Ssl_key
replicaSourceInfoTblColIndex_Ssl_verify_server_cert
replicaSourceInfoTblColIndex_Heartbeat
replicaSourceInfoTblColIndex_Bind
replicaSourceInfoTblColIndex_Ignored_server_ids
replicaSourceInfoTblColIndex_Uuid
replicaSourceInfoTblColIndex_Retry_count
replicaSourceInfoTblColIndex_Ssl_crl
replicaSourceInfoTblColIndex_Ssl_crlpath
replicaSourceInfoTblColIndex_Enabled_auto_position
replicaSourceInfoTblColIndex_Channel_name
replicaSourceInfoTblColIndex_Tls_version
replicaSourceInfoTblColIndex_Public_key_path
replicaSourceInfoTblColIndex_Get_public_key
replicaSourceInfoTblColIndex_Network_namespace
replicaSourceInfoTblColIndex_Master_compression_algorithm
replicaSourceInfoTblColIndex_Master_zstd_compression_level
replicaSourceInfoTblColIndex_Tls_ciphersuites
replicaSourceInfoTblColIndex_Source_connection_auto_failover
replicaSourceInfoTblColIndex_Gtid_only
)