{"record":{"id":"996d030a09278471","repo":"vitessio/vitess","slug":"internal-value-v-get-mysql-value-length-error-v","errorCode":null,"errorMessage":"internal value %v get MySQL value length error: %v","messagePattern":"internal value (.+?) get MySQL value length error: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/mysql/query.go","lineNumber":1192,"sourceCode":"\t\tif c.Capabilities&CapabilityClientDeprecateEOF == 0 {\n\t\t\t// With CapabilityClientDeprecateEOF, we do not send this EOF.\n\t\t\tif err := c.writeEOFPacket(c.StatusFlags, 0); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc (c *Conn) writeBinaryRow(fields []*querypb.Field, row []sqltypes.Value) error {\n\tlength := 0\n\tnullBitMapLen := (len(fields) + 7 + 2) / 8\n\tfor _, val := range row {\n\t\tif !val.IsNull() {\n\t\t\tl, err := val2MySQLLen(val)\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"internal value %v get MySQL value length error: %v\", val, err)\n\t\t\t}\n\t\t\tlength += l\n\t\t}\n\t}\n\n\tlength += nullBitMapLen + 1\n\n\tdata, pos := c.startEphemeralPacketWithHeader(length)\n\n\tpos = writeByte(data, pos, 0x00)\n\n\tfor range nullBitMapLen {\n\t\tpos = writeByte(data, pos, 0x00)\n\t}\n\n\tfor i, val := range row {\n\t\tif val.IsNull() {\n\t\t\tbytePos := (i+2)/8 + 1 + PacketHeaderSize","sourceCodeStart":1174,"sourceCodeEnd":1210,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/mysql/query.go#L1174-L1210","documentation":"writeBinaryRow computes the encoded length of each row value with val2MySQLLen before building the binary protocol packet; if a value's type cannot be sized, the packet write aborts with this wrapped error. It indicates an internal value the MySQL wire encoder does not know how to serialize.","triggerScenarios":"A query result row contains a Value whose type has no binary-protocol length mapping (val2MySQLLen returns an error) while writing binary rows for a prepared-statement result.","commonSituations":"Vitess serving a result set containing an unsupported/internal column type over the MySQL protocol; mismatches between field type metadata and actual values after a version change or unsupported type passthrough.","solutions":["Check the column type in the fields metadata and ensure it is a supported wire type","Cast/convert the offending column to a supported type in the query (e.g. CAST(col AS CHAR))","Report/investigate if an internal vitess Value type is reaching writeBinaryRow unencoded"],"exampleFix":"// before\nSELECT weird_col FROM t\n// after\nSELECT CAST(weird_col AS CHAR) AS weird_col FROM t","handlingStrategy":"try-catch","validationCode":"// pre-check supported types before executing the query\nfor _, f := range fields {\n\tswitch f.Type {\n\tcase query.Type_INT8, query.Type_UINT8, query.Type_INT16, query.Type_UINT16,\n\t\tquery.Type_INT24, query.Type_UINT24, query.Type_INT32, query.Type_UINT32,\n\t\tquery.Type_INT64, query.Type_UINT64, query.Type_FLOAT32, query.Type_FLOAT64,\n\t\tquery.Type_VARCHAR, query.Type_VARBINARY, query.Type_DATETIME, query.Type_DATE,\n\t\tquery.Type_TIME, query.Type_TIMESTAMP, query.Type_YEAR, query.Type_BIT,\n\t\tquery.Type_ENUM, query.Type_SET, query.Type_NEWDECIMAL:\n\t\t// supported\n\tdefault:\n\t\treturn fmt.Errorf(\"unsupported column type %v for binary protocol\", f.Type)\n\t}\n}","typeGuard":null,"tryCatchPattern":"if err := conn.WriteBinaryRows(fields, rows); err != nil {\n\tif strings.Contains(err.Error(), \"get MySQL value length error\") {\n\t\t// fall back to text protocol or cast columns to supported types\n\t}\n\treturn err\n}","preventionTips":["Cast exotic column types to CHAR/standard types in queries served over prepared statements","Keep field metadata in sync with actual returned value types","Add type coverage tests when introducing new vitess value types"],"tags":["mysql-protocol","serialization","wire-protocol"],"backgroundTag":"unsupported-column-type","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}