public StatementPrepareOk Prepare(string query) { var stream = client.GetStream(); var readWriteBuffer = InternalMemoryPool.GetBuffer(); var writer = PacketWriter.Create(readWriteBuffer); ProtocolWriter.WritePrepareStatement(ref writer, query); 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(); } return(ProtocolReader.ReadStatementPrepareOk(ref reader)); }