Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
amend err consts
  • Loading branch information
elianddb committed Nov 3, 2025
commit 435170529e66d68d20b895989b1c45c20d845a1c
3 changes: 3 additions & 0 deletions go/mysql/binlog_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ type BinlogEvent interface {

// Bytes returns the binary representation of the event
Bytes() []byte

// TypeName returns a human-readable name for the event type.
TypeName() string
}

// BinlogFormat contains relevant data from the FORMAT_DESCRIPTION_EVENT.
Expand Down
35 changes: 35 additions & 0 deletions go/mysql/binlog_event_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package mysql
import (
"bytes"
"encoding/binary"
"fmt"

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

// TypeName returns a human-readable name for the event type.
// This matches MariaDB's Log_event::get_type_str() function for consistency.
func (ev binlogEvent) TypeName() string {
eventType := ev.Type()
switch eventType {
case eQueryEvent:
return "Query"
case eRotateEvent:
return "Rotate"
case eFormatDescriptionEvent:
return "Format_desc"
case eXIDEvent:
return "Xid"
case eTableMapEvent:
return "Table_map"
case eWriteRowsEventV1:
return "Write_rows_v1"
case eUpdateRowsEventV1:
return "Update_rows_v1"
case eDeleteRowsEventV1:
return "Delete_rows_v1"
case eWriteRowsEventV2:
return "Write_rows"
case eUpdateRowsEventV2:
return "Update_rows"
case eDeleteRowsEventV2:
return "Delete_rows"
case eMariaGTIDEvent:
return "Gtid"
default:
return fmt.Sprintf("Unknown (type %d)", eventType)
}
}

// Flags returns the flags field from the header.
func (ev binlogEvent) Flags() uint16 {
return binary.LittleEndian.Uint16(ev.Bytes()[17 : 17+2])
Expand Down
8 changes: 8 additions & 0 deletions go/mysql/binlog_event_filepos.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,10 @@ func (ev filePosQueryEvent) StripChecksum(f BinlogFormat) (BinlogEvent, []byte,
return ev, nil, nil
}

func (ev filePosQueryEvent) TypeName() string {
return "Query"
}

//----------------------------------------------------------------------------

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

func (ev filePosGTIDEvent) TypeName() string {
return "Gtid"
}

func (ev filePosGTIDEvent) GTID(BinlogFormat) (GTID, bool, error) {
return ev.gtid, false, nil
}
238 changes: 119 additions & 119 deletions go/mysql/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,15 +417,12 @@ const (
EROptionPreventsStatement = 1290
ERDuplicatedValueInType = 1291
ERSPDoesNotExist = 1305
ERNoDefaultForField = 1364
ERBase64DecodeError = 1373
ErSPNotVarArg = 1414
ERNoFormatDescriptionEventBeforeBinlogStatement = 1403
ERRowIsReferenced2 = 1451
ErNoReferencedRow2 = 1452
EROnlyFDAndRBREventsAllowedInBinlogStatement = 1512
ERDupIndex = 1831
ERInnodbReadOnly = 1874
ERNoDefaultForField = 1364
ErSPNotVarArg = 1414
ERRowIsReferenced2 = 1451
ErNoReferencedRow2 = 1452
ERDupIndex = 1831
ERInnodbReadOnly = 1874

// already exists
ERDbCreateExists = 1007
Expand All @@ -441,116 +438,119 @@ const (
ERLockDeadlock = 1213

// invalid arg
ERUnknownComError = 1047
ERBadNullError = 1048
ERBadDb = 1049
ERBadTable = 1051
ERNonUniq = 1052
ERWrongFieldWithGroup = 1055
ERWrongGroupField = 1056
ERWrongSumSelect = 1057
ERWrongValueCount = 1058
ERTooLongIdent = 1059
ERDupFieldName = 1060
ERDupKeyName = 1061
ERWrongFieldSpec = 1063
ERParseError = 1064
EREmptyQuery = 1065
ERNonUniqTable = 1066
ERInvalidDefault = 1067
ERMultiplePriKey = 1068
ERTooManyKeys = 1069
ERTooManyKeyParts = 1070
ERTooLongKey = 1071
ERKeyColumnDoesNotExist = 1072
ERBlobUsedAsKey = 1073
ERTooBigFieldLength = 1074
ERWrongAutoKey = 1075
ERWrongFieldTerminators = 1083
ERBlobsAndNoTerminated = 1084
ERTextFileNotReadable = 1085
ERWrongSubKey = 1089
ERCantRemoveAllFields = 1090
ERUpdateTableUsed = 1093
ERNoTablesUsed = 1096
ERTooBigSet = 1097
ERBlobCantHaveDefault = 1101
ERWrongDbName = 1102
ERWrongTableName = 1103
ERUnknownProcedure = 1106
ERWrongParamCountToProcedure = 1107
ERWrongParametersToProcedure = 1108
ERFieldSpecifiedTwice = 1110
ERInvalidGroupFuncUse = 1111
ERTableMustHaveColumns = 1113
ERUnknownCharacterSet = 1115
ERTooManyTables = 1116
ERTooManyFields = 1117
ERTooBigRowSize = 1118
ERWrongOuterJoin = 1120
ERNullColumnInIndex = 1121
ERFunctionNotDefined = 1128
ERWrongValueCountOnRow = 1136
ERInvalidUseOfNull = 1138
ERRegexpError = 1139
ERMixOfGroupFuncAndFields = 1140
ERIllegalGrantForTable = 1144
ERSyntaxError = 1149
ERWrongColumnName = 1166
ERWrongKeyColumn = 1167
ERBlobKeyWithoutLength = 1170
ERPrimaryCantHaveNull = 1171
ERTooManyRows = 1172
ERLockOrActiveTransaction = 1192
ERUnknownSystemVariable = 1193
ERSetConstantsOnly = 1204
ERWrongArguments = 1210
ERWrongUsage = 1221
ERWrongNumberOfColumnsInSelect = 1222
ERDupArgument = 1225
ERLocalVariable = 1228
ERGlobalVariable = 1229
ERWrongValueForVar = 1231
ERWrongTypeForVar = 1232
ERVarCantBeRead = 1233
ERCantUseOptionHere = 1234
ERIncorrectGlobalLocalVar = 1238
ERWrongFKDef = 1239
ERKeyRefDoNotMatchTableRef = 1240
ERCyclicReference = 1245
ERIllegalReference = 1247
ERDerivedMustHaveAlias = 1248
ERTableNameNotAllowedHere = 1250
ERCollationCharsetMismatch = 1253
ERWarnDataTruncated = 1265
ERCantAggregate2Collations = 1267
ERCantAggregate3Collations = 1270
ERCantAggregateNCollations = 1271
ERVariableIsNotStruct = 1272
ERUnknownCollation = 1273
ERWrongNameForIndex = 1280
ERWrongNameForCatalog = 1281
ERBadFTColumn = 1283
ERTruncatedWrongValue = 1292
ERTooMuchAutoTimestampCols = 1293
ERInvalidOnUpdate = 1294
ERUnknownTimeZone = 1298
ERInvalidCharacterString = 1300
ERQueryInterrupted = 1317
ERTruncatedWrongValueForField = 1366
ERIllegalValueForType = 1367
ERDataTooLong = 1406
ErrWrongValueForType = 1411
ERForbidSchemaChange = 1450
ERWrongValue = 1525
ERDataOutOfRange = 1690
ERInvalidJSONText = 3140
ERInvalidJSONTextInParams = 3141
ERInvalidJSONBinaryData = 3142
ERInvalidJSONCharset = 3144
ERInvalidCastToJSON = 3147
ERJSONValueTooBig = 3150
ERJSONDocumentTooDeep = 3157
ERUnknownComError = 1047
ERBadNullError = 1048
ERBadDb = 1049
ERBadTable = 1051
ERNonUniq = 1052
ERWrongFieldWithGroup = 1055
ERWrongGroupField = 1056
ERWrongSumSelect = 1057
ERWrongValueCount = 1058
ERTooLongIdent = 1059
ERDupFieldName = 1060
ERDupKeyName = 1061
ERWrongFieldSpec = 1063
ERParseError = 1064
EREmptyQuery = 1065
ERNonUniqTable = 1066
ERInvalidDefault = 1067
ERMultiplePriKey = 1068
ERTooManyKeys = 1069
ERTooManyKeyParts = 1070
ERTooLongKey = 1071
ERKeyColumnDoesNotExist = 1072
ERBlobUsedAsKey = 1073
ERTooBigFieldLength = 1074
ERWrongAutoKey = 1075
ERWrongFieldTerminators = 1083
ERBlobsAndNoTerminated = 1084
ERTextFileNotReadable = 1085
ERWrongSubKey = 1089
ERCantRemoveAllFields = 1090
ERUpdateTableUsed = 1093
ERNoTablesUsed = 1096
ERTooBigSet = 1097
ERBlobCantHaveDefault = 1101
ERWrongDbName = 1102
ERWrongTableName = 1103
ERUnknownProcedure = 1106
ERWrongParamCountToProcedure = 1107
ERWrongParametersToProcedure = 1108
ERFieldSpecifiedTwice = 1110
ERInvalidGroupFuncUse = 1111
ERTableMustHaveColumns = 1113
ERUnknownCharacterSet = 1115
ERTooManyTables = 1116
ERTooManyFields = 1117
ERTooBigRowSize = 1118
ERWrongOuterJoin = 1120
ERNullColumnInIndex = 1121
ERFunctionNotDefined = 1128
ERWrongValueCountOnRow = 1136
ERInvalidUseOfNull = 1138
ERRegexpError = 1139
ERMixOfGroupFuncAndFields = 1140
ERIllegalGrantForTable = 1144
ERSyntaxError = 1149
ERWrongColumnName = 1166
ERWrongKeyColumn = 1167
ERBlobKeyWithoutLength = 1170
ERPrimaryCantHaveNull = 1171
ERTooManyRows = 1172
ERLockOrActiveTransaction = 1192
ERUnknownSystemVariable = 1193
ERSetConstantsOnly = 1204
ERWrongArguments = 1210
ERWrongUsage = 1221
ERWrongNumberOfColumnsInSelect = 1222
ERDupArgument = 1225
ERLocalVariable = 1228
ERGlobalVariable = 1229
ERWrongValueForVar = 1231
ERWrongTypeForVar = 1232
ERVarCantBeRead = 1233
ERCantUseOptionHere = 1234
ERIncorrectGlobalLocalVar = 1238
ERWrongFKDef = 1239
ERKeyRefDoNotMatchTableRef = 1240
ERCyclicReference = 1245
ERIllegalReference = 1247
ERDerivedMustHaveAlias = 1248
ERTableNameNotAllowedHere = 1250
ERCollationCharsetMismatch = 1253
ERWarnDataTruncated = 1265
ERCantAggregate2Collations = 1267
ERCantAggregate3Collations = 1270
ERCantAggregateNCollations = 1271
ERVariableIsNotStruct = 1272
ERUnknownCollation = 1273
ERWrongNameForIndex = 1280
ERWrongNameForCatalog = 1281
ERBadFTColumn = 1283
ERTruncatedWrongValue = 1292
ERTooMuchAutoTimestampCols = 1293
ERInvalidOnUpdate = 1294
ERUnknownTimeZone = 1298
ERInvalidCharacterString = 1300
ERQueryInterrupted = 1317
ERTruncatedWrongValueForField = 1366
ERIllegalValueForType = 1367
ERDataTooLong = 1406
ErrWrongValueForType = 1411
ERForbidSchemaChange = 1450
ERWrongValue = 1525
ERBase64DecodeError = 1575
ERNoFormatDescriptionEventBeforeBinlogStatement = 1609
ERDataOutOfRange = 1690
EROnlyFDAndRBREventsAllowedInBinlogStatement = 1730
ERInvalidJSONText = 3140
ERInvalidJSONTextInParams = 3141
ERInvalidJSONBinaryData = 3142
ERInvalidJSONCharset = 3144
ERInvalidCastToJSON = 3147
ERJSONValueTooBig = 3150
ERJSONDocumentTooDeep = 3157

// max execution time exceeded
ERQueryTimeout = 3024
Expand Down
7 changes: 6 additions & 1 deletion go/vt/sqlparser/sql.y
Original file line number Diff line number Diff line change
Expand Up @@ -10862,8 +10862,13 @@ kill_statement:
binlog_statement:
BINLOG STRING
{
base64Str := string($2)
if base64Str == "" {
yylex.Error("You have an error in your SQL syntax")
return 1
}
$$ = &Binlog{
Base64Str: string($2),
Base64Str: base64Str,
Auth: AuthInformation{
AuthType: AuthType_BINLOG,
TargetType: AuthTargetType_Global,
Expand Down
Loading