(t *TableMapEvent)
| 195 | } |
| 196 | |
| 197 | func (p *TableMapEventParser) parseColumns(t *TableMapEvent) error { |
| 198 | numCols := len(t.columnTypesBytes) |
| 199 | t.columnDescriptors = make([]ColumnDescriptor, numCols, numCols) |
| 200 | |
| 201 | metadata := t.metadataBytes |
| 202 | |
| 203 | nullVector, _, err := readBitArray(t.nullColumnsBytes, numCols) |
| 204 | if err != nil { |
| 205 | return err |
| 206 | } |
| 207 | |
| 208 | for idx, colTypeByte := range t.columnTypesBytes { |
| 209 | colType := mysql_proto.FieldType_Type(colTypeByte) |
| 210 | realType := colType |
| 211 | metaLength := 0 |
| 212 | if colType == mysql_proto.FieldType_STRING || |
| 213 | colType == mysql_proto.FieldType_VAR_STRING { |
| 214 | |
| 215 | realType, metaLength, metadata, err = parseTypeAndLength(metadata) |
| 216 | if err != nil { |
| 217 | return err |
| 218 | } |
| 219 | |
| 220 | // mysql_proto.FieldType_VAR_STRING is not type polymorphic. |
| 221 | if colType == mysql_proto.FieldType_VAR_STRING && |
| 222 | colType != realType { |
| 223 | |
| 224 | return errors.Newf("Invalid real type: %s (%d)", |
| 225 | realType.String(), |
| 226 | realType) |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | var fd FieldDescriptor |
| 231 | |
| 232 | nullable := NullableColumn(nullVector[idx]) |
| 233 | |
| 234 | switch realType { |
| 235 | case mysql_proto.FieldType_DECIMAL: |
| 236 | fd = NewDecimalFieldDescriptor(nullable) |
| 237 | case mysql_proto.FieldType_TINY: |
| 238 | fd = NewTinyFieldDescriptor(nullable) |
| 239 | case mysql_proto.FieldType_SHORT: |
| 240 | fd = NewShortFieldDescriptor(nullable) |
| 241 | case mysql_proto.FieldType_LONG: |
| 242 | fd = NewLongFieldDescriptor(nullable) |
| 243 | case mysql_proto.FieldType_FLOAT: |
| 244 | fd, metadata, err = NewFloatFieldDescriptor(nullable, metadata) |
| 245 | case mysql_proto.FieldType_DOUBLE: |
| 246 | fd, metadata, err = NewDoubleFieldDescriptor(nullable, metadata) |
| 247 | case mysql_proto.FieldType_NULL: |
| 248 | fd = NewNullFieldDescriptor(nullable) |
| 249 | case mysql_proto.FieldType_TIMESTAMP: |
| 250 | fd = NewTimestampFieldDescriptor(nullable) |
| 251 | case mysql_proto.FieldType_LONGLONG: |
| 252 | fd = NewLongLongFieldDescriptor(nullable) |
| 253 | case mysql_proto.FieldType_INT24: |
| 254 | fd = NewInt24FieldDescriptor(nullable) |
no test coverage detected