예제 #1
0
        public BinaryResultSet Execute(int statementId, params object[] parameters) // how to avoid boxing?
        {
            var stream = client.GetStream();

            var readWriteBuffer = InternalMemoryPool.GetBuffer();
            var writer          = PacketWriter.Create(readWriteBuffer);

            ProtocolWriter.WriteExecuteStatement(ref writer, statementId, parameters);

            var reader = SyncWriteAndRead(ref writer, 0, stream);

            // COM_STMT_PREPARE_OK on success, ERR_Packet otherwise
            if (reader.IsErrorPacket())
            {
                throw ErrorPacket.Parse(ref reader).ToMySqlException();
            }

            // TODO: Ok or ResultSet?
            var set = ProtocolReader.ReadBinaryResultSet(ref reader);

            return(set);
        }