Exemple #1
0
        public override void WriteToStream(Stream outputStream)
        {
            //NpgsqlEventLog.LogMsg( this.ToString() + _commandText, LogLevel.Debug  );

            byte[] commandText = _command.GetCommandText();

            if (NpgsqlEventLog.Level >= LogLevel.Debug)
            {
                // Log the string being sent.
                PGUtil.LogStringWritten(BackendEncoding.UTF8Encoding.GetString(commandText));
            }

            // Tell to mediator what command is being sent.
            _command.Connector.Mediator.SetSqlSent(commandText);

            // Workaround for seek exceptions when running under ms.net. TODO: Check why Npgsql may be letting behind data in the stream.
            // Whatever issue there was here seems to be rectified.  Leaving it active, per Francisco.
            // The problem is not well understood.  Needs more checking.
            // [email protected]       09/20/2013
            outputStream.Flush();

            // Send the query to server.
            // Write the byte 'Q' to identify a query message.
            outputStream.WriteByte((byte)FrontEndMessageCode.Query);

            if (_protocolVersion == ProtocolVersion.Version3)
            {
                // Write message length. Int32 + string length + null terminator.
                PGUtil.WriteInt32(outputStream, 4 + commandText.Length + 1);
            }

            outputStream.WriteBytesNullTerminated(commandText);
        }
Exemple #2
0
        public override void WriteToStream(Stream outputStream)
        {
            //NpgsqlEventLog.LogMsg( this.ToString() + _commandText, LogLevel.Debug  );


            StringBuilder commandText = _command.GetCommandText();



            // Log the string being sent.



            if (NpgsqlEventLog.Level >= LogLevel.Debug)
            {
                PGUtil.LogStringWritten(commandText.ToString());
            }



            // This method needs refactory.

            // The code below which deals with writing string to stream needs to be redone to use

            // PGUtil.WriteString() as before. The problem is that WriteString is using too much strings (concatenation).

            // Find a way to optimize that.



            // Tell to mediator what command is being sent.

            _command.Connector.Mediator.SetSqlSent(commandText);

            // Workaround for seek exceptions when running under ms.net. TODO: Check why Npgsql may be letting behind data in the stream.
            outputStream.Flush();

            // Send the query to server.
            // Write the byte 'Q' to identify a query message.
            outputStream.WriteByte((byte)FrontEndMessageCode.Query);

            //Work out the encoding of the string (null-terminated) once and take the length from having done so
            //rather than doing so repeatedly.
            byte[] bytes = UTF8Encoding.GetBytes(commandText.Append('\x00').ToString());

            if (_protocolVersion == ProtocolVersion.Version3)
            {
                // Write message length. Int32 + string length + null terminator.
                PGUtil.WriteInt32(outputStream, 4 + bytes.Length);
            }

            outputStream.Write(bytes, 0, bytes.Length);
        }
Exemple #3
0
        public override void WriteToStream(Stream outputStream)
        {
            if (NpgsqlEventLog.Level >= LogLevel.Debug)
            {
                // Log the string being sent.
                PGUtil.LogStringWritten(BackendEncoding.UTF8Encoding.GetString(commandText));
            }

            // Send the query to server.
            // Write the byte 'Q' to identify a query message.
            outputStream.WriteByte((byte)FrontEndMessageCode.Query);

            outputStream.WriteBytesNullTerminated(commandText);
        }
Exemple #4
0
        public override void WriteToStream(Stream outputStream)
        {
            if (NpgsqlEventLog.Level >= LogLevel.Debug)
            {
                // Log the string being sent.
                // If (this) was constructed with a byte[], then commandText has to be
                // initialized before the first Log call.
                if (commandText == null)
                {
                    commandText  = BackendEncoding.UTF8Encoding.GetString(commandBytes);
                    commandBytes = null;
                }

                PGUtil.LogStringWritten(commandText);
            }

            outputStream.WriteBytes(pgCommandBytes);
        }
Exemple #5
0
        public override void WriteToStream(Stream outputStream)
        {
            if (NpgsqlEventLog.Level >= LogLevel.Debug)
            {
                // Log the string being sent.
                PGUtil.LogStringWritten(BackendEncoding.UTF8Encoding.GetString(commandText));
            }

            // Tell to mediator what command is being sent.
            _connector.Mediator.SetSqlSent(commandText);

            // Send the query to server.
            // Write the byte 'Q' to identify a query message.
            outputStream.WriteByte((byte)FrontEndMessageCode.Query);

            if (_connector.BackendProtocolVersion == ProtocolVersion.Version3)
            {
                // Write message length. Int32 + string length + null terminator.
                PGUtil.WriteInt32(outputStream, 4 + commandText.Length + 1);
            }

            outputStream.WriteBytesNullTerminated(commandText);
        }