{"id":"3cb380721afa74e1","repo":"go-sql-driver/mysql","slug":"unknown-field-type-d","errorCode":null,"errorMessage":"unknown field type %d","messagePattern":"unknown field type (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packets.go","lineNumber":1446,"sourceCode":"\t\t\t\t\t\treturn fmt.Errorf(\n\t\t\t\t\t\t\t\"protocol error, illegal decimals value %d\",\n\t\t\t\t\t\t\trows.rs.columns[i].decimals,\n\t\t\t\t\t\t)\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tdest[i], err = formatBinaryDateTime(data[pos:pos+int(num)], dstlen)\n\t\t\t}\n\n\t\t\tif err == nil {\n\t\t\t\tpos += int(num)\n\t\t\t\tcontinue\n\t\t\t} else {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t// Please report if this happens!\n\t\tdefault:\n\t\t\treturn fmt.Errorf(\"unknown field type %d\", rows.rs.columns[i].fieldType)\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":1428,"sourceCodeEnd":1452,"githubUrl":"https://github.com/go-sql-driver/mysql/blob/c426bd93799de0f0e094c8f0582872c529d0ed0a/packets.go#L1428-L1452","documentation":"While decoding a binary-protocol result row (packets.go:1446), a column's fieldType byte does not match any type the driver knows how to decode. The surrounding code comment 'Please report if this happens!' signals a column type the driver version has not implemented, typically from a newer server feature (e.g. a vector type) or a non-MySQL-compatible server, or corrupted packet data.","triggerScenarios":"Selecting a column whose type code predates support in the installed driver version (e.g. HeatWave/vector columns on an older driver); a non-MySQL server returning an unrecognized type code; packet corruption altering the field type byte.","commonSituations":"Old driver version against a newer MySQL with novel column types; selecting VECTOR or another exotic type directly; a MariaDB-fork-specific type not in the map.","solutions":["Upgrade the go-sql-driver/mysql package to the latest release.","Cast the unknown column to a supported type in SQL: SELECT CAST(col AS CHAR) AS col.","Exclude the unsupported column from the query.","If the type is genuinely unsupported, report it upstream with the server version."],"exampleFix":"// before — 'embedding' uses a type the driver cannot decode\nrows, _ := db.Query(\"SELECT embedding FROM docs\")\n\n// after\nrows, _ := db.Query(\"SELECT CAST(embedding AS CHAR) AS embedding FROM docs\")","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := rows.Scan(dest...); err != nil {\n    if strings.Contains(err.Error(), \"unknown field type\") {\n        // driver cannot decode this column; upgrade the driver or CAST the column in SQL\n    }\n}","preventionTips":["Keep the driver version current with your MySQL server.","Avoid selecting exotic/new column types directly; CAST to CHAR.","Report unsupported field types upstream with the server version."],"tags":["protocol","binary-protocol","field-type","resultset","version-skew"],"analyzedSha":"c426bd93799de0f0e094c8f0582872c529d0ed0a","analyzedAt":"2026-08-04T21:52:59.219Z","schemaVersion":2}