-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
errors.go
336 lines (269 loc) · 9.4 KB
/
errors.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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
package schemadiff
import (
"errors"
"fmt"
"vitess.io/vitess/go/sqlescape"
)
var (
ErrEntityTypeMismatch = errors.New("mismatched entity type")
ErrStrictIndexOrderingUnsupported = errors.New("strict index ordering is unsupported")
ErrUnexpectedDiffAction = errors.New("unexpected diff action")
ErrUnexpectedTableSpec = errors.New("unexpected table spec")
ErrExpectedCreateTable = errors.New("expected a CREATE TABLE statement")
ErrExpectedCreateView = errors.New("expected a CREATE VIEW statement")
)
type UnsupportedEntityError struct {
Entity string
Statement string
}
func (e *UnsupportedEntityError) Error() string {
return fmt.Sprintf("entity %s is not supported: %s", sqlescape.EscapeID(e.Entity), e.Statement)
}
type NotFullyParsedError struct {
Entity string
Statement string
}
func (e *NotFullyParsedError) Error() string {
return fmt.Sprintf("entity %s is not fully parsed: %s", sqlescape.EscapeID(e.Entity), e.Statement)
}
type UnsupportedTableOptionError struct {
Table string
Option string
}
func (e *UnsupportedTableOptionError) Error() string {
return fmt.Sprintf("unsupported option %s on table %s", e.Option, sqlescape.EscapeID(e.Table))
}
type UnsupportedStatementError struct {
Statement string
}
func (e *UnsupportedStatementError) Error() string {
return fmt.Sprintf("unsupported statement: %s", e.Statement)
}
type UnsupportedApplyOperationError struct {
Statement string
}
func (e *UnsupportedApplyOperationError) Error() string {
return fmt.Sprintf("unsupported operation: %s", e.Statement)
}
type ApplyTableNotFoundError struct {
Table string
}
func (e *ApplyTableNotFoundError) Error() string {
return fmt.Sprintf("table %s not found", sqlescape.EscapeID(e.Table))
}
type ApplyViewNotFoundError struct {
View string
}
func (e *ApplyViewNotFoundError) Error() string {
return fmt.Sprintf("view %s not found", sqlescape.EscapeID(e.View))
}
type ApplyKeyNotFoundError struct {
Table string
Key string
}
func (e *ApplyKeyNotFoundError) Error() string {
return fmt.Sprintf("key %s not found in table %s", sqlescape.EscapeID(e.Key), sqlescape.EscapeID(e.Table))
}
type ApplyColumnNotFoundError struct {
Table string
Column string
}
func (e *ApplyColumnNotFoundError) Error() string {
return fmt.Sprintf("column %s not found in table %s", sqlescape.EscapeID(e.Column), sqlescape.EscapeID(e.Table))
}
type ApplyColumnAfterNotFoundError struct {
Table string
Column string
AfterColumn string
}
func (e *ApplyColumnAfterNotFoundError) Error() string {
return fmt.Sprintf("column %s can't be after non-existing column %s in table %s",
sqlescape.EscapeID(e.Column), sqlescape.EscapeID(e.AfterColumn), sqlescape.EscapeID(e.Table))
}
type ApplyDuplicateEntityError struct {
Entity string
}
func (e *ApplyDuplicateEntityError) Error() string {
return fmt.Sprintf("duplicate entity %s", sqlescape.EscapeID(e.Entity))
}
type ApplyDuplicateKeyError struct {
Table string
Key string
}
func (e *ApplyDuplicateKeyError) Error() string {
return fmt.Sprintf("duplicate key %s in table %s", sqlescape.EscapeID(e.Key), sqlescape.EscapeID(e.Table))
}
type ApplyDuplicateColumnError struct {
Table string
Column string
}
func (e *ApplyDuplicateColumnError) Error() string {
return fmt.Sprintf("duplicate column %s in table %s", sqlescape.EscapeID(e.Column), sqlescape.EscapeID(e.Table))
}
type ApplyConstraintNotFoundError struct {
Table string
Constraint string
}
func (e *ApplyConstraintNotFoundError) Error() string {
return fmt.Sprintf("constraint %s not found in table %s", sqlescape.EscapeID(e.Constraint), sqlescape.EscapeID(e.Table))
}
type ApplyDuplicateConstraintError struct {
Table string
Constraint string
}
func (e *ApplyDuplicateConstraintError) Error() string {
return fmt.Sprintf("duplicate constraint %s in table %s", sqlescape.EscapeID(e.Constraint), sqlescape.EscapeID(e.Table))
}
type ApplyPartitionNotFoundError struct {
Table string
Partition string
}
func (e *ApplyPartitionNotFoundError) Error() string {
return fmt.Sprintf("partition %s not found in table %s", sqlescape.EscapeID(e.Partition), sqlescape.EscapeID(e.Table))
}
type ApplyDuplicatePartitionError struct {
Table string
Partition string
}
func (e *ApplyDuplicatePartitionError) Error() string {
return fmt.Sprintf("duplicate partition %s in table %s", sqlescape.EscapeID(e.Partition), sqlescape.EscapeID(e.Table))
}
type ApplyNoPartitionsError struct {
Table string
}
func (e *ApplyNoPartitionsError) Error() string {
return fmt.Sprintf("no partitions in table %s", sqlescape.EscapeID(e.Table))
}
type InvalidColumnInKeyError struct {
Table string
Column string
Key string
}
type DuplicateKeyNameError struct {
Table string
Key string
}
func (e *DuplicateKeyNameError) Error() string {
return fmt.Sprintf("duplicate key %s in table %s", sqlescape.EscapeID(e.Key), sqlescape.EscapeID(e.Table))
}
func (e *InvalidColumnInKeyError) Error() string {
return fmt.Sprintf("invalid column %s referenced by key %s in table %s",
sqlescape.EscapeID(e.Column), sqlescape.EscapeID(e.Key), sqlescape.EscapeID(e.Table))
}
type InvalidColumnInGeneratedColumnError struct {
Table string
Column string
GeneratedColumn string
}
func (e *InvalidColumnInGeneratedColumnError) Error() string {
return fmt.Sprintf("invalid column %s referenced by generated column %s in table %s",
sqlescape.EscapeID(e.Column), sqlescape.EscapeID(e.GeneratedColumn), sqlescape.EscapeID(e.Table))
}
type InvalidColumnInPartitionError struct {
Table string
Column string
}
func (e *InvalidColumnInPartitionError) Error() string {
return fmt.Sprintf("invalid column %s referenced by partition in table %s",
sqlescape.EscapeID(e.Column), sqlescape.EscapeID(e.Table))
}
type MissingPartitionColumnInUniqueKeyError struct {
Table string
Column string
UniqueKey string
}
func (e *MissingPartitionColumnInUniqueKeyError) Error() string {
return fmt.Sprintf("invalid column %s referenced by unique key %s in table %s",
sqlescape.EscapeID(e.Column), sqlescape.EscapeID(e.UniqueKey), sqlescape.EscapeID(e.Table))
}
type InvalidColumnInCheckConstraintError struct {
Table string
Constraint string
Column string
}
func (e *InvalidColumnInCheckConstraintError) Error() string {
return fmt.Sprintf("invalid column %s referenced by check constraint %s in table %s",
sqlescape.EscapeID(e.Column), sqlescape.EscapeID(e.Constraint), sqlescape.EscapeID(e.Table))
}
type ForeignKeyDependencyUnresolvedError struct {
Table string
}
func (e *ForeignKeyDependencyUnresolvedError) Error() string {
return fmt.Sprintf("table %s has unresolved/loop foreign key dependencies",
sqlescape.EscapeID(e.Table))
}
type InvalidColumnInForeignKeyConstraintError struct {
Table string
Constraint string
Column string
}
func (e *InvalidColumnInForeignKeyConstraintError) Error() string {
return fmt.Sprintf("invalid column %s covered by foreign key constraint %s in table %s",
sqlescape.EscapeID(e.Column), sqlescape.EscapeID(e.Constraint), sqlescape.EscapeID(e.Table))
}
type InvalidReferencedColumnInForeignKeyConstraintError struct {
Table string
Constraint string
ReferencedTable string
ReferencedColumn string
}
func (e *InvalidReferencedColumnInForeignKeyConstraintError) Error() string {
return fmt.Sprintf("invalid column %s.%s referenced by foreign key constraint %s in table %s",
sqlescape.EscapeID(e.ReferencedTable), sqlescape.EscapeID(e.ReferencedColumn), sqlescape.EscapeID(e.Constraint), sqlescape.EscapeID(e.Table))
}
type ForeignKeyColumnCountMismatchError struct {
Table string
Constraint string
ColumnCount int
ReferencedTable string
ReferencedColumnCount int
}
func (e *ForeignKeyColumnCountMismatchError) Error() string {
return fmt.Sprintf("mismatching column count %d referenced by foreign key constraint %s in table %s. Expected %d",
e.ReferencedColumnCount, sqlescape.EscapeID(e.Constraint), sqlescape.EscapeID(e.Table), e.ColumnCount)
}
type ForeignKeyColumnTypeMismatchError struct {
Table string
Constraint string
Column string
ReferencedTable string
ReferencedColumn string
}
func (e *ForeignKeyColumnTypeMismatchError) Error() string {
return fmt.Sprintf("mismatching column type %s.%s and %s.%s referenced by foreign key constraint %s in table %s",
sqlescape.EscapeID(e.ReferencedTable),
sqlescape.EscapeID(e.ReferencedColumn),
sqlescape.EscapeID(e.Table),
sqlescape.EscapeID(e.Column),
sqlescape.EscapeID(e.Constraint),
sqlescape.EscapeID(e.Table),
)
}
type MissingForeignKeyReferencedIndexError struct {
Table string
Constraint string
ReferencedTable string
}
func (e *MissingForeignKeyReferencedIndexError) Error() string {
return fmt.Sprintf("missing index in referenced table %s for foreign key constraint %s in table %s",
sqlescape.EscapeID(e.ReferencedTable),
sqlescape.EscapeID(e.Constraint),
sqlescape.EscapeID(e.Table),
)
}
type IndexNeededByForeignKeyError struct {
Table string
Key string
}
func (e *IndexNeededByForeignKeyError) Error() string {
return fmt.Sprintf("key %s needed by a foreign key constraint in table %s",
sqlescape.EscapeID(e.Key),
sqlescape.EscapeID(e.Table),
)
}
type ViewDependencyUnresolvedError struct {
View string
}
func (e *ViewDependencyUnresolvedError) Error() string {
return fmt.Sprintf("view %s has unresolved/loop dependencies", sqlescape.EscapeID(e.View))
}