func (stmt *Statement) UnmarshalBson(buf *bytes.Buffer) { bson.Next(buf, 4) kind := bson.NextByte(buf) for kind != bson.EOO { key := bson.ReadCString(buf) switch key { case "Category": stmt.Category = int(bson.DecodeInt64(buf, kind)) case "Sql": stmt.Sql = bson.DecodeBytes(buf, kind) default: panic(bson.NewBsonError("Unrecognized tag %s", key)) } kind = bson.NextByte(buf) } }
func DecodeRowBson(buf *bytes.Buffer, kind byte) []sqltypes.Value { switch kind { case bson.Array: // valid case bson.Null: return nil default: panic(bson.NewBsonError("Unexpected data type %v for Query.Row", kind)) } bson.Next(buf, 4) row := make([]sqltypes.Value, 0, 8) kind = bson.NextByte(buf) for i := 0; kind != bson.EOO; i++ { bson.ExpectIndex(buf, i) if kind != bson.Null { row = append(row, sqltypes.MakeString(bson.DecodeBytes(buf, kind))) } else { row = append(row, sqltypes.Value{}) } kind = bson.NextByte(buf) } return row }