From 53b4ab43b669eb8d6991b2b9c13146d94bd8e7ec Mon Sep 17 00:00:00 2001 From: Matt Lord Date: Wed, 24 Apr 2024 14:46:51 -0400 Subject: [PATCH] Revert "Properly calculate field length for SET columns in unit tests" This reverts commit 6435392b87f80d8d3ed2ed95cca5d232ed33b6ad. Signed-off-by: Matt Lord --- .../tabletserver/vstreamer/helper_event_test.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/go/vt/vttablet/tabletserver/vstreamer/helper_event_test.go b/go/vt/vttablet/tabletserver/vstreamer/helper_event_test.go index dc5c0088332..bc7bd5cfc7e 100644 --- a/go/vt/vttablet/tabletserver/vstreamer/helper_event_test.go +++ b/go/vt/vttablet/tabletserver/vstreamer/helper_event_test.go @@ -59,6 +59,14 @@ const ( lengthInt = 11 lengthBlob = 65535 lengthText = 262140 + + // We have to hardcode the set lengths as we don't yet have an encoded way + // to calculate the length for the TableMap event, + // This is the expected length of the only SET column in the test schema. + lengthSet = 204 + // This is the expected length of the only SET column using a binary collation + // in the test schema. + lengthSetBinary = 428 ) var ( @@ -502,9 +510,11 @@ func (ts *TestSpec) getFieldEvent(table *schemadiff.CreateTableEntity) *TestFiel tc.len = lengthText tc.colType = "text" case "set": - tc.len = int64((len(col.Type.EnumValues) + 1) * (strings.Count(col.Type.EnumValues[0], ",") + 1)) if collation.IsBinary() { + tc.len = lengthSetBinary tc.dataType = "BINARY" + } else { + tc.len = lengthSet } tc.colType = fmt.Sprintf("%s(%s)", tc.dataTypeLowered, strings.Join(col.Type.EnumValues, ",")) ts.metadata[getMetadataKey(table.Name(), tc.name)] = col.Type.EnumValues