BUG #3611: The first INSERT return -1 with prepare() before - Mailing list pgsql-bugs

From
Subject BUG #3611: The first INSERT return -1 with prepare() before
Date
Msg-id 200709161251.l8GCpWqm096863@wwwmaster.postgresql.org
Whole thread Raw
List pgsql-bugs
The following bug has been logged online:

Bug reference:      3611
Logged by:
Email address:      Philippe.Errard@Wanadoo.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:

Previous
From: "Boris"
Date:
Subject: BUG #3610: Vaccum stop and can not continue
Next
From: Martin Pitt
Date:
Subject: psql CLI: warn about ongoing transaction on exit