A simple query message. Note that since this is only used to send some specific control messages (e.g. start transaction) and never arbitrary-length user-provided queries, this message is treated as simple and not chunking, and only ASCII is supported.
Inheritance: SimpleFrontendMessage
コード例 #1
0
ファイル: PregeneratedMessage.cs プロジェクト: Emill/Npgsql
        static PregeneratedMessage BuildQuery(string query)
        {
            Contract.Requires(query != null && query.All(c => c < 128));

            var totalLen = 5 + query.Length;
            var ms = new MemoryStream(totalLen);
            _tempBuf.Underlying = ms;
            var simpleQuery = new QueryMessage(query);
            simpleQuery.Write(_tempBuf);
            _tempBuf.Flush();
            return new PregeneratedMessage(ms.ToArray(), simpleQuery.ToString());
        }
コード例 #2
0
ファイル: PregeneratedMessage.cs プロジェクト: npgsql/npgsql
        static PregeneratedMessage()
        {
            _tempBuf = new WriteBuffer(null, new MemoryStream(), WriteBuffer.MinimumBufferSize, Encoding.ASCII);
            _tempQuery = new QueryMessage(PGUtil.UTF8Encoding);

            BeginTrans                = BuildQuery("BEGIN;");
            SetTransRepeatableRead    = BuildQuery("SET TRANSACTION ISOLATION LEVEL REPEATABLE READ;");
            SetTransSerializable      = BuildQuery("SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;");
            SetTransReadCommitted     = BuildQuery("SET TRANSACTION ISOLATION LEVEL READ COMMITTED;");
            SetTransReadUncommitted   = BuildQuery("SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;");
            CommitTransaction         = BuildQuery("COMMIT");
            RollbackTransaction       = BuildQuery("ROLLBACK");
            DiscardAll                = BuildQuery("DISCARD ALL");
            UnlistenAll               = BuildQuery("UNLISTEN *");
            KeepAlive                 = BuildQuery("SELECT NULL");

            _tempBuf = null;
            _tempQuery = null;
        }