public override void Execute(NpgsqlConnector context, NpgsqlExecute execute)
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Execute");
            NpgsqlDescribe describe = new NpgsqlDescribe('P', execute.PortalName);
            Stream         stream   = context.Stream;

            describe.WriteToStream(stream);
            execute.WriteToStream(stream);
            //stream.Flush();
            Sync(context);
        }
        public override IEnumerable <IServerResponseObject> ExecuteEnum(NpgsqlConnector context, NpgsqlExecute execute)
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Execute");
            NpgsqlDescribe describe = new NpgsqlDescribe('P', execute.PortalName);
            Stream         stream   = context.Stream;

            describe.WriteToStream(stream);
            execute.WriteToStream(stream);
            //stream.Flush();
            return(SyncEnum(context));
        }
Exemple #3
0
        public override void Describe(NpgsqlConnector context, NpgsqlDescribe describe)
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Describe");

            describe.WriteToStream(context.Stream);
        }
 internal void Describe(NpgsqlDescribe describe)
 {
     CurrentState.Describe(this, describe);
 }
Exemple #5
0
 public virtual void Describe(NpgsqlConnector context, NpgsqlDescribe describe)
 {
     throw new InvalidOperationException("Internal Error! " + this);
 }
Exemple #6
0
        /// <summary>
        /// Creates a prepared version of the command on a PostgreSQL server.
        /// </summary>
        public override void Prepare()
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Prepare");

            // Check the connection state.
            CheckConnectionState();

            // reset any responses just before getting new ones
            Connector.Mediator.ResetResponses();

            // Set command timeout.
            m_Connector.Mediator.CommandTimeout = CommandTimeout;

            if (!m_Connector.SupportsPrepare)
            {
                return; // Do nothing.
            }

            if (m_Connector.BackendProtocolVersion == ProtocolVersion.Version2)
            {
                using (NpgsqlCommand command = new NpgsqlCommand(GetPrepareCommandText(), m_Connector))
                {
                    command.ExecuteBlind();
                }
            }
            else
            {
                using (m_Connector.BlockNotificationThread())
                {
                    try
                    {
                        // Use the extended query parsing...
                        planName = m_Connector.NextPlanName();
                        String portalName = m_Connector.NextPortalName();

                        parse = new NpgsqlParse(planName, GetParseCommandText(), new Int32[] { });

                        m_Connector.Parse(parse);

                        // We need that because Flush() doesn't cause backend to send
                        // ReadyForQuery on error. Without ReadyForQuery, we don't return 
                        // from query extended processing.

                        // We could have used Connector.Flush() which sends us back a
                        // ReadyForQuery, but on postgresql server below 8.1 there is an error
                        // with extended query processing which hinders us from using it.
                        m_Connector.RequireReadyForQuery = false;
                        m_Connector.Flush();


                        // Description...
                        NpgsqlDescribe describe = new NpgsqlDescribe('S', planName);


                        m_Connector.Describe(describe);

                        NpgsqlRowDescription returnRowDesc = m_Connector.Sync();

                        Int16[] resultFormatCodes;


                        if (returnRowDesc != null)
                        {
                            resultFormatCodes = new Int16[returnRowDesc.NumFields];

                            for (int i = 0; i < returnRowDesc.NumFields; i++)
                            {
                                NpgsqlRowDescription.FieldData returnRowDescData = returnRowDesc[i];


                                if (returnRowDescData.TypeInfo != null && returnRowDescData.TypeInfo.NpgsqlDbType == NpgsqlDbType.Bytea)
                                {
                                    // Binary format
                                    resultFormatCodes[i] = (Int16)FormatCode.Binary;
                                }
                                else
                                {
                                    // Text Format
                                    resultFormatCodes[i] = (Int16)FormatCode.Text;
                                }
                            }
                        }
                        else
                        {
                            resultFormatCodes = new Int16[] { 0 };
                        }

                        bind = new NpgsqlBind("", planName, new Int16[Parameters.Count], null, resultFormatCodes);
                    }
                    catch (IOException e)
                    {
                        throw ClearPoolAndCreateException(e);
                    }
                    catch
                    {

                        // As per documentation:

                        // "[...] When an error is detected while processing any extended-query message,

                        // the backend issues ErrorResponse, then reads and discards messages until a

                        // Sync is reached, then issues ReadyForQuery and returns to normal message processing.[...]"

                        // So, send a sync command if we get any problems.



                        m_Connector.Sync();

                        throw;
                    }
                }
            }
        }
 public override void Describe(NpgsqlConnector context, NpgsqlDescribe describe)
 {
     NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Describe");
     describe.WriteToStream(context.Stream);
     //context.Stream.Flush();
 }
Exemple #8
0
 internal void Describe(NpgsqlDescribe describe)
 {
     CurrentState.Describe(this, describe);
 }
Exemple #9
0
 public virtual void Describe(NpgsqlConnector context, NpgsqlDescribe describe)
 {
     throw new InvalidOperationException("Internal Error! " + this);
 }
		public override IEnumerable<IServerResponseObject> ExecuteEnum(NpgsqlConnector context, NpgsqlExecute execute)
		{
			NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Execute");
			NpgsqlDescribe describe = new NpgsqlDescribe('P', execute.PortalName);
			Stream stream = context.Stream;
			describe.WriteToStream(stream);
			execute.WriteToStream(stream);
			//stream.Flush();
			return SyncEnum(context);
		}
		public override void Execute(NpgsqlConnector context, NpgsqlExecute execute)
		{
			NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Execute");
			NpgsqlDescribe describe = new NpgsqlDescribe('P', execute.PortalName);
			Stream stream = context.Stream;
			describe.WriteToStream(stream);
			execute.WriteToStream(stream);
			//stream.Flush();
			Sync(context);
		}
Exemple #12
0
 public virtual void Describe(NpgsqlConnector context, NpgsqlDescribe describe)
 {
     throw new InvalidOperationException("¬нутренн¤¤ ќшибка! " + this);
 }
Exemple #13
0
 internal void Describe(NpgsqlDescribe describe)
 {
     _log.Debug("Sending describe message");
     describe.WriteToStream(Stream);
 }
Exemple #14
0
        /// <summary>
        /// Creates a prepared version of the command on a PostgreSQL server.
        /// </summary>
        public void Prepare()
        {
            NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "Prepare");

            // Check the connection state.
            CheckConnectionState();
            
            // reset any responses just before getting new ones
            Connector.Mediator.ResetResponses();
            
            // Set command timeout.
            connector.Mediator.CommandTimeout = CommandTimeout;

            if (! connector.SupportsPrepare)
            {
                return;	// Do nothing.
            }

            if (connector.BackendProtocolVersion == ProtocolVersion.Version2)
            {
                NpgsqlCommand command = new NpgsqlCommand(GetPrepareCommandText(), connector );
                command.ExecuteNonQuery();
            }
            else
            {
                try
                {
                    
                    connector.StopNotificationThread();
                    
                    // Use the extended query parsing...
                    planName = connector.NextPlanName();
                    String portalName = connector.NextPortalName();
    
                    parse = new NpgsqlParse(planName, GetParseCommandText(), new Int32[] {});
    
                    connector.Parse(parse);
                    
                    // We need that because Flush() doesn't cause backend to send
                    // ReadyForQuery on error. Without ReadyForQuery, we don't return 
                    // from query extended processing.
                    
                    // We could have used Connector.Flush() which sends us back a
                    // ReadyForQuery, but on postgresql server below 8.1 there is an error
                    // with extended query processing which hinders us from using it.
                    connector.Mediator.RequireReadyForQuery = false;
                    connector.Flush();
                    
                    // Check for errors and/or notifications and do the Right Thing.
                    connector.CheckErrorsAndNotifications();
    
                    
                    // Description...
                    NpgsqlDescribe describe = new NpgsqlDescribe('S', planName);
                
                
                    connector.Describe(describe);
                    
                    connector.Sync();
                    
                    Npgsql.NpgsqlRowDescription returnRowDesc = connector.Mediator.LastRowDescription;
                
                    Int16[] resultFormatCodes;
                    
                    
                    if (returnRowDesc != null)
                    {
                        resultFormatCodes = new Int16[returnRowDesc.NumFields];
                        
                        for (int i=0; i < returnRowDesc.NumFields; i++)
                        {
                            Npgsql.NpgsqlRowDescriptionFieldData returnRowDescData = returnRowDesc[i];
                            
                            
                            if (returnRowDescData.type_info != null && returnRowDescData.type_info.NpgsqlDbType == NpgsqlTypes.NpgsqlDbType.Bytea)
                            {
                            // Binary format
                                resultFormatCodes[i] = (Int16)FormatCode.Binary;
                            }
                            else 
                            // Text Format
                                resultFormatCodes[i] = (Int16)FormatCode.Text;
                        }
                    
                        
                    }
                    else
                        resultFormatCodes = new Int16[]{0};
                    
                    bind = new NpgsqlBind("", planName, new Int16[Parameters.Count], null, resultFormatCodes);
                }    
                catch (IOException e)
                {
                    ClearPoolAndThrowException(e);
                }
                catch
                {
                    // See ExecuteCommand method for a discussion of this.
                    connector.Sync();
                    
                    throw;
                }
                finally
                {
                    connector.ResumeNotificationThread();
                }
                
                
                
            }
        }