Exemplo n.º 1
0
        public static ResultSet Parse(ref PacketReader reader, bool isTextResultSet)
        {
            var resultSet = (isTextResultSet)
                ? (ResultSet) new TextResultSet()
                : (ResultSet) new BinaryResultSet();

            resultSet.ColumnCount       = (int)reader.ReadLengthEncodedInteger();
            resultSet.ColumnDefinitions = new ColumnDefinition41[resultSet.ColumnCount];

            PacketReader columnReader = reader; // struct copy

            for (int i = 0; i < resultSet.ColumnDefinitions.Length; i++)
            {
                columnReader = columnReader.CreateNextReader();

                var column = ColumnDefinition41.Parse(ref columnReader);
                resultSet.ColumnDefinitions[i] = column;
            }
            resultSet.rowData = new ArraySegment <byte> [resultSet.ColumnCount];

            // if the CLIENT_DEPRECATE_EOF EOF_PACKET
            // RESULTSETROW


            var lastReader = columnReader.CreateNextReader();
            var eof        = ProtocolReader.ReadResponsePacket(ref lastReader);

            resultSet.rowReader = lastReader;

            return(resultSet);
        }
Exemplo n.º 2
0
        public static ColumnDefinition41 Parse(ref PacketReader reader)
        {
            var def = new ColumnDefinition41();

            // TODO:Array lifetime?
            def.catalog        = reader.ReadLengthEncodedStringSegment(); // always "def"
            def.schema         = reader.ReadLengthEncodedStringSegment();
            def.table          = reader.ReadLengthEncodedStringSegment();
            def.originalTable  = reader.ReadLengthEncodedStringSegment();
            def.column         = reader.ReadLengthEncodedStringSegment();
            def.originalColumn = reader.ReadLengthEncodedStringSegment();

            reader.ReadByte(); // 0x

            def.CharacterSet = (CharacterSet)(byte)reader.ReadUInt16();
            def.ColumnLength = reader.ReadInt32();
            def.ColumnType   = (ColumnType)reader.ReadByte();
            def.ColumnFlags  = (ColumnFlags)reader.ReadUInt16();
            var decimals = reader.ReadByte(); // 0x00 for intergers and static string, 0x1f for dynamic strings, double, float, 0x00 to 0x51 for decimals

            reader.ReadNext(2);               // filter

            // TODO:and others

            return(def);
        }