Skip to content

Commit 4351705

Browse files
committed
amend err consts
1 parent 3191c97 commit 4351705

File tree

5 files changed

+171
-120
lines changed

5 files changed

+171
-120
lines changed

go/mysql/binlog_event.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ type BinlogEvent interface {
127127

128128
// Bytes returns the binary representation of the event
129129
Bytes() []byte
130+
131+
// TypeName returns a human-readable name for the event type.
132+
TypeName() string
130133
}
131134

132135
// BinlogFormat contains relevant data from the FORMAT_DESCRIPTION_EVENT.

go/mysql/binlog_event_common.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package mysql
1919
import (
2020
"bytes"
2121
"encoding/binary"
22+
"fmt"
2223

2324
binlogdatapb "github.com/dolthub/vitess/go/vt/proto/binlogdata"
2425
"github.com/dolthub/vitess/go/vt/proto/vtrpc"
@@ -81,6 +82,40 @@ func (ev binlogEvent) Type() byte {
8182
return ev.Bytes()[4]
8283
}
8384

85+
// TypeName returns a human-readable name for the event type.
86+
// This matches MariaDB's Log_event::get_type_str() function for consistency.
87+
func (ev binlogEvent) TypeName() string {
88+
eventType := ev.Type()
89+
switch eventType {
90+
case eQueryEvent:
91+
return "Query"
92+
case eRotateEvent:
93+
return "Rotate"
94+
case eFormatDescriptionEvent:
95+
return "Format_desc"
96+
case eXIDEvent:
97+
return "Xid"
98+
case eTableMapEvent:
99+
return "Table_map"
100+
case eWriteRowsEventV1:
101+
return "Write_rows_v1"
102+
case eUpdateRowsEventV1:
103+
return "Update_rows_v1"
104+
case eDeleteRowsEventV1:
105+
return "Delete_rows_v1"
106+
case eWriteRowsEventV2:
107+
return "Write_rows"
108+
case eUpdateRowsEventV2:
109+
return "Update_rows"
110+
case eDeleteRowsEventV2:
111+
return "Delete_rows"
112+
case eMariaGTIDEvent:
113+
return "Gtid"
114+
default:
115+
return fmt.Sprintf("Unknown (type %d)", eventType)
116+
}
117+
}
118+
84119
// Flags returns the flags field from the header.
85120
func (ev binlogEvent) Flags() uint16 {
86121
return binary.LittleEndian.Uint16(ev.Bytes()[17 : 17+2])

go/mysql/binlog_event_filepos.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,10 @@ func (ev filePosQueryEvent) StripChecksum(f BinlogFormat) (BinlogEvent, []byte,
114114
return ev, nil, nil
115115
}
116116

117+
func (ev filePosQueryEvent) TypeName() string {
118+
return "Query"
119+
}
120+
117121
//----------------------------------------------------------------------------
118122

119123
// filePosFakeEvent is the base class for fake events.
@@ -253,6 +257,10 @@ func (ev filePosGTIDEvent) StripChecksum(f BinlogFormat) (BinlogEvent, []byte, e
253257
return ev, nil, nil
254258
}
255259

260+
func (ev filePosGTIDEvent) TypeName() string {
261+
return "Gtid"
262+
}
263+
256264
func (ev filePosGTIDEvent) GTID(BinlogFormat) (GTID, bool, error) {
257265
return ev.gtid, false, nil
258266
}

go/mysql/constants.go

Lines changed: 119 additions & 119 deletions
Original file line numberDiff line numberDiff line change
@@ -417,15 +417,12 @@ const (
417417
EROptionPreventsStatement = 1290
418418
ERDuplicatedValueInType = 1291
419419
ERSPDoesNotExist = 1305
420-
ERNoDefaultForField = 1364
421-
ERBase64DecodeError = 1373
422-
ErSPNotVarArg = 1414
423-
ERNoFormatDescriptionEventBeforeBinlogStatement = 1403
424-
ERRowIsReferenced2 = 1451
425-
ErNoReferencedRow2 = 1452
426-
EROnlyFDAndRBREventsAllowedInBinlogStatement = 1512
427-
ERDupIndex = 1831
428-
ERInnodbReadOnly = 1874
420+
ERNoDefaultForField = 1364
421+
ErSPNotVarArg = 1414
422+
ERRowIsReferenced2 = 1451
423+
ErNoReferencedRow2 = 1452
424+
ERDupIndex = 1831
425+
ERInnodbReadOnly = 1874
429426

430427
// already exists
431428
ERDbCreateExists = 1007
@@ -441,116 +438,119 @@ const (
441438
ERLockDeadlock = 1213
442439

443440
// invalid arg
444-
ERUnknownComError = 1047
445-
ERBadNullError = 1048
446-
ERBadDb = 1049
447-
ERBadTable = 1051
448-
ERNonUniq = 1052
449-
ERWrongFieldWithGroup = 1055
450-
ERWrongGroupField = 1056
451-
ERWrongSumSelect = 1057
452-
ERWrongValueCount = 1058
453-
ERTooLongIdent = 1059
454-
ERDupFieldName = 1060
455-
ERDupKeyName = 1061
456-
ERWrongFieldSpec = 1063
457-
ERParseError = 1064
458-
EREmptyQuery = 1065
459-
ERNonUniqTable = 1066
460-
ERInvalidDefault = 1067
461-
ERMultiplePriKey = 1068
462-
ERTooManyKeys = 1069
463-
ERTooManyKeyParts = 1070
464-
ERTooLongKey = 1071
465-
ERKeyColumnDoesNotExist = 1072
466-
ERBlobUsedAsKey = 1073
467-
ERTooBigFieldLength = 1074
468-
ERWrongAutoKey = 1075
469-
ERWrongFieldTerminators = 1083
470-
ERBlobsAndNoTerminated = 1084
471-
ERTextFileNotReadable = 1085
472-
ERWrongSubKey = 1089
473-
ERCantRemoveAllFields = 1090
474-
ERUpdateTableUsed = 1093
475-
ERNoTablesUsed = 1096
476-
ERTooBigSet = 1097
477-
ERBlobCantHaveDefault = 1101
478-
ERWrongDbName = 1102
479-
ERWrongTableName = 1103
480-
ERUnknownProcedure = 1106
481-
ERWrongParamCountToProcedure = 1107
482-
ERWrongParametersToProcedure = 1108
483-
ERFieldSpecifiedTwice = 1110
484-
ERInvalidGroupFuncUse = 1111
485-
ERTableMustHaveColumns = 1113
486-
ERUnknownCharacterSet = 1115
487-
ERTooManyTables = 1116
488-
ERTooManyFields = 1117
489-
ERTooBigRowSize = 1118
490-
ERWrongOuterJoin = 1120
491-
ERNullColumnInIndex = 1121
492-
ERFunctionNotDefined = 1128
493-
ERWrongValueCountOnRow = 1136
494-
ERInvalidUseOfNull = 1138
495-
ERRegexpError = 1139
496-
ERMixOfGroupFuncAndFields = 1140
497-
ERIllegalGrantForTable = 1144
498-
ERSyntaxError = 1149
499-
ERWrongColumnName = 1166
500-
ERWrongKeyColumn = 1167
501-
ERBlobKeyWithoutLength = 1170
502-
ERPrimaryCantHaveNull = 1171
503-
ERTooManyRows = 1172
504-
ERLockOrActiveTransaction = 1192
505-
ERUnknownSystemVariable = 1193
506-
ERSetConstantsOnly = 1204
507-
ERWrongArguments = 1210
508-
ERWrongUsage = 1221
509-
ERWrongNumberOfColumnsInSelect = 1222
510-
ERDupArgument = 1225
511-
ERLocalVariable = 1228
512-
ERGlobalVariable = 1229
513-
ERWrongValueForVar = 1231
514-
ERWrongTypeForVar = 1232
515-
ERVarCantBeRead = 1233
516-
ERCantUseOptionHere = 1234
517-
ERIncorrectGlobalLocalVar = 1238
518-
ERWrongFKDef = 1239
519-
ERKeyRefDoNotMatchTableRef = 1240
520-
ERCyclicReference = 1245
521-
ERIllegalReference = 1247
522-
ERDerivedMustHaveAlias = 1248
523-
ERTableNameNotAllowedHere = 1250
524-
ERCollationCharsetMismatch = 1253
525-
ERWarnDataTruncated = 1265
526-
ERCantAggregate2Collations = 1267
527-
ERCantAggregate3Collations = 1270
528-
ERCantAggregateNCollations = 1271
529-
ERVariableIsNotStruct = 1272
530-
ERUnknownCollation = 1273
531-
ERWrongNameForIndex = 1280
532-
ERWrongNameForCatalog = 1281
533-
ERBadFTColumn = 1283
534-
ERTruncatedWrongValue = 1292
535-
ERTooMuchAutoTimestampCols = 1293
536-
ERInvalidOnUpdate = 1294
537-
ERUnknownTimeZone = 1298
538-
ERInvalidCharacterString = 1300
539-
ERQueryInterrupted = 1317
540-
ERTruncatedWrongValueForField = 1366
541-
ERIllegalValueForType = 1367
542-
ERDataTooLong = 1406
543-
ErrWrongValueForType = 1411
544-
ERForbidSchemaChange = 1450
545-
ERWrongValue = 1525
546-
ERDataOutOfRange = 1690
547-
ERInvalidJSONText = 3140
548-
ERInvalidJSONTextInParams = 3141
549-
ERInvalidJSONBinaryData = 3142
550-
ERInvalidJSONCharset = 3144
551-
ERInvalidCastToJSON = 3147
552-
ERJSONValueTooBig = 3150
553-
ERJSONDocumentTooDeep = 3157
441+
ERUnknownComError = 1047
442+
ERBadNullError = 1048
443+
ERBadDb = 1049
444+
ERBadTable = 1051
445+
ERNonUniq = 1052
446+
ERWrongFieldWithGroup = 1055
447+
ERWrongGroupField = 1056
448+
ERWrongSumSelect = 1057
449+
ERWrongValueCount = 1058
450+
ERTooLongIdent = 1059
451+
ERDupFieldName = 1060
452+
ERDupKeyName = 1061
453+
ERWrongFieldSpec = 1063
454+
ERParseError = 1064
455+
EREmptyQuery = 1065
456+
ERNonUniqTable = 1066
457+
ERInvalidDefault = 1067
458+
ERMultiplePriKey = 1068
459+
ERTooManyKeys = 1069
460+
ERTooManyKeyParts = 1070
461+
ERTooLongKey = 1071
462+
ERKeyColumnDoesNotExist = 1072
463+
ERBlobUsedAsKey = 1073
464+
ERTooBigFieldLength = 1074
465+
ERWrongAutoKey = 1075
466+
ERWrongFieldTerminators = 1083
467+
ERBlobsAndNoTerminated = 1084
468+
ERTextFileNotReadable = 1085
469+
ERWrongSubKey = 1089
470+
ERCantRemoveAllFields = 1090
471+
ERUpdateTableUsed = 1093
472+
ERNoTablesUsed = 1096
473+
ERTooBigSet = 1097
474+
ERBlobCantHaveDefault = 1101
475+
ERWrongDbName = 1102
476+
ERWrongTableName = 1103
477+
ERUnknownProcedure = 1106
478+
ERWrongParamCountToProcedure = 1107
479+
ERWrongParametersToProcedure = 1108
480+
ERFieldSpecifiedTwice = 1110
481+
ERInvalidGroupFuncUse = 1111
482+
ERTableMustHaveColumns = 1113
483+
ERUnknownCharacterSet = 1115
484+
ERTooManyTables = 1116
485+
ERTooManyFields = 1117
486+
ERTooBigRowSize = 1118
487+
ERWrongOuterJoin = 1120
488+
ERNullColumnInIndex = 1121
489+
ERFunctionNotDefined = 1128
490+
ERWrongValueCountOnRow = 1136
491+
ERInvalidUseOfNull = 1138
492+
ERRegexpError = 1139
493+
ERMixOfGroupFuncAndFields = 1140
494+
ERIllegalGrantForTable = 1144
495+
ERSyntaxError = 1149
496+
ERWrongColumnName = 1166
497+
ERWrongKeyColumn = 1167
498+
ERBlobKeyWithoutLength = 1170
499+
ERPrimaryCantHaveNull = 1171
500+
ERTooManyRows = 1172
501+
ERLockOrActiveTransaction = 1192
502+
ERUnknownSystemVariable = 1193
503+
ERSetConstantsOnly = 1204
504+
ERWrongArguments = 1210
505+
ERWrongUsage = 1221
506+
ERWrongNumberOfColumnsInSelect = 1222
507+
ERDupArgument = 1225
508+
ERLocalVariable = 1228
509+
ERGlobalVariable = 1229
510+
ERWrongValueForVar = 1231
511+
ERWrongTypeForVar = 1232
512+
ERVarCantBeRead = 1233
513+
ERCantUseOptionHere = 1234
514+
ERIncorrectGlobalLocalVar = 1238
515+
ERWrongFKDef = 1239
516+
ERKeyRefDoNotMatchTableRef = 1240
517+
ERCyclicReference = 1245
518+
ERIllegalReference = 1247
519+
ERDerivedMustHaveAlias = 1248
520+
ERTableNameNotAllowedHere = 1250
521+
ERCollationCharsetMismatch = 1253
522+
ERWarnDataTruncated = 1265
523+
ERCantAggregate2Collations = 1267
524+
ERCantAggregate3Collations = 1270
525+
ERCantAggregateNCollations = 1271
526+
ERVariableIsNotStruct = 1272
527+
ERUnknownCollation = 1273
528+
ERWrongNameForIndex = 1280
529+
ERWrongNameForCatalog = 1281
530+
ERBadFTColumn = 1283
531+
ERTruncatedWrongValue = 1292
532+
ERTooMuchAutoTimestampCols = 1293
533+
ERInvalidOnUpdate = 1294
534+
ERUnknownTimeZone = 1298
535+
ERInvalidCharacterString = 1300
536+
ERQueryInterrupted = 1317
537+
ERTruncatedWrongValueForField = 1366
538+
ERIllegalValueForType = 1367
539+
ERDataTooLong = 1406
540+
ErrWrongValueForType = 1411
541+
ERForbidSchemaChange = 1450
542+
ERWrongValue = 1525
543+
ERBase64DecodeError = 1575
544+
ERNoFormatDescriptionEventBeforeBinlogStatement = 1609
545+
ERDataOutOfRange = 1690
546+
EROnlyFDAndRBREventsAllowedInBinlogStatement = 1730
547+
ERInvalidJSONText = 3140
548+
ERInvalidJSONTextInParams = 3141
549+
ERInvalidJSONBinaryData = 3142
550+
ERInvalidJSONCharset = 3144
551+
ERInvalidCastToJSON = 3147
552+
ERJSONValueTooBig = 3150
553+
ERJSONDocumentTooDeep = 3157
554554

555555
// max execution time exceeded
556556
ERQueryTimeout = 3024

go/vt/sqlparser/sql.y

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10862,8 +10862,13 @@ kill_statement:
1086210862
binlog_statement:
1086310863
BINLOG STRING
1086410864
{
10865+
base64Str := string($2)
10866+
if base64Str == "" {
10867+
yylex.Error("You have an error in your SQL syntax")
10868+
return 1
10869+
}
1086510870
$$ = &Binlog{
10866-
Base64Str: string($2),
10871+
Base64Str: base64Str,
1086710872
Auth: AuthInformation{
1086810873
AuthType: AuthType_BINLOG,
1086910874
TargetType: AuthTargetType_Global,

0 commit comments

Comments
 (0)