Skip site navigation (1) Skip section navigation (2)

BUG #3611: The first INSERT return -1 with prepare() before

From: "" <Philippe(dot)Errard(at)Wanadoo(dot)fr>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #3611: The first INSERT return -1 with prepare() before
Date: 2007-09-16 12:51:32
Message-ID: 200709161251.l8GCpWqm096863@wwwmaster.postgresql.org (view raw or flat)
Thread:
Lists: pgsql-bugs
The following bug has been logged online:

Bug reference:      3611
Logged by:          
Email address:      Philippe(dot)Errard(at)Wanadoo(dot)fr
PostgreSQL version: 8.2.4
Operating system:   Windows XP
Description:        The first INSERT return -1 with prepare() before
Details: 

DbProviderFactory          dbpf  =
DbProviderFactories.GetFactory("Npgsql");
      ..... 
      dbConnect = dbpf.CreateConnection();
      dbConnect.ConnectionString   =  dbCsb.ConnectionString;   
      dbConnect.Open();    ----> OK

      dbCmd_Select = dbConnect.CreateCommand();
      dbCmd_Insert = dbConnect.CreateCommand();

      dbCmd_Select.CommandText = "SELECT col_1, col_2....FROM mytable Where
...."
      dbCmd_Select.Prepare();   ---> OK

      dbCmd_Insert.CommandText = "INSERT ...."    this INSERT only add one
row 
      dbCmd_Insert.Prepare();    ----> OK

      ....
      int RowAdded;
      RowAdded = dbCmd_Insert.ExecuteNonQuery();   ---> KO  return -1 		
      RowAdded = dbCmd_Insert.ExecuteNonQuery();   ---> OK  return  1
      RowAdded = dbCmd_Insert.ExecuteNonQuery();   ---> OK  return  1
      RowAdded = dbCmd_Insert.ExecuteNonQuery();   ---> OK  return  1
      ......
		
	
//------  NOTE  File NpgsqlMLediator.cs-------

        public void AddCompletedResponse(String response)
        {
            if (_rd != null)

The first INSERT executes this code

            // Finished receiving the resultset. Add it to the buffer.
                _resultSets.Add(new NpgsqlResultSet(_rd, _rows));

                // Add a placeholder response.
                _responses.Add(null);

                // Discard the RowDescription.
                _rd = null;
            }
            else
            {
The other INSERT uses this code

                // Add a placeholder resultset.
                _resultSets.Add(null);
                // It was just a non query string. Just add the response.
                _responses.Add(response);
            }

        }

//--------------

if I delete the line dbCmd_Select.Prepare(), the first INSERT is OK

Best Regards

pgsql-bugs by date

Next:From: Martin PittDate: 2007-09-16 18:34:21
Subject: psql CLI: warn about ongoing transaction on exit
Previous:From: BorisDate: 2007-09-16 01:08:57
Subject: BUG #3610: Vaccum stop and can not continue

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group