Наследование: ChunkingFrontendMessage
Пример #1
0
        void CreateMessagesPrepared(CommandBehavior behavior)
        {
            for (var i = 0; i < _queries.Count; i++)
            {
                BindMessage bindMessage;
                ExecuteMessage executeMessage;
                if (i == 0)
                {
                    bindMessage = _connector.BindMessage;
                    executeMessage = _connector.ExecuteMessage;
                }
                else
                {
                    bindMessage = new BindMessage();
                    executeMessage = new ExecuteMessage();
                }

                var query = _queries[i];
                bindMessage.Populate(_connector.TypeHandlerRegistry, query.InputParameters, "", query.PreparedStatementName);
                if (AllResultTypesAreUnknown) {
                    bindMessage.AllResultTypesAreUnknown = AllResultTypesAreUnknown;
                } else if (i == 0 && UnknownResultTypeList != null) {
                    bindMessage.UnknownResultTypeList = UnknownResultTypeList;
                }
                _connector.AddMessage(bindMessage);
                _connector.AddMessage(executeMessage.Populate("", (behavior & CommandBehavior.SingleRow) != 0 ? 1 : 0));
            }
            _connector.AddMessage(SyncMessage.Instance);
        }
Пример #2
0
        void CreateMessagesNonPrepared(CommandBehavior behavior)
        {
            Contract.Requires((behavior & CommandBehavior.SchemaOnly) == 0);

            ProcessRawQuery();

            var portalNames = _queries.Count > 1
                ? Enumerable.Range(0, _queries.Count).Select(i => "MQ" + i).ToArray()
                : null;

            for (var i = 0; i < _queries.Count; i++)
            {
                var query = _queries[i];

                ParseMessage parseMessage;
                DescribeMessage describeMessage;
                BindMessage bindMessage;
                if (i == 0)
                {
                    parseMessage = _connector.ParseMessage;
                    describeMessage = _connector.DescribeMessage;
                    bindMessage = _connector.BindMessage;
                }
                else
                {
                    parseMessage = new ParseMessage();
                    describeMessage = new DescribeMessage();
                    bindMessage = new BindMessage();
                }

                _connector.AddMessage(parseMessage.Populate(query, _connector.TypeHandlerRegistry));
                _connector.AddMessage(describeMessage.Populate(StatementOrPortal.Statement));

                bindMessage.Populate(
                    _connector.TypeHandlerRegistry,
                    query.InputParameters,
                    _queries.Count == 1 ? "" : portalNames[i]
                );
                if (AllResultTypesAreUnknown) {
                    bindMessage.AllResultTypesAreUnknown = AllResultTypesAreUnknown;
                } else if (i == 0 && UnknownResultTypeList != null) {
                    bindMessage.UnknownResultTypeList = UnknownResultTypeList;
                }
                _connector.AddMessage(bindMessage);
            }

            if (_queries.Count == 1) {
                _connector.AddMessage(_connector.ExecuteMessage.Populate("", (behavior & CommandBehavior.SingleRow) != 0 ? 1 : 0));
            } else
                for (var i = 0; i < _queries.Count; i++) {
                    // TODO: Verify SingleRow behavior for multiqueries
                    _connector.AddMessage(new ExecuteMessage(portalNames[i], (behavior & CommandBehavior.SingleRow) != 0 ? 1 : 0));
                    _connector.AddMessage(new CloseMessage(StatementOrPortal.Portal, portalNames[i]));
                }
            _connector.AddMessage(SyncMessage.Instance);
        }