Re: NpgsqlCopySerializer blows up if no rows are saved

From: "Francisco Figueiredo Jr(dot)" <francisco(at)npgsql(dot)org>
To: AK <alkuzo(at)gmail(dot)com>
Cc: PgSql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: NpgsqlCopySerializer blows up if no rows are saved
Date: 2013-12-02 22:16:55
Message-ID: CACUQdMYbQew1sodPC60yUuDccBiFuDd+9J+A-ZX4Gj7yxek9aw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi!

You should post Npgsql questions to our user's forums :
http://forums.npgsql.org

In this case I think it is a bug in Npgsql. Please add this test program to
your post when talking about this problem.

Thanks in advance.
Em 02/12/2013 19:29, "AK" <alkuzo(at)gmail(dot)com> escreveu:

> I am not sure if this is the correct place to post my question to. If this
> is
> a wrong list, can you tell me the right one.
>
> I am bulk loading rows using the following code:
>
> const string connString =
> "myConnString";
> using(var conn = new NpgsqlConnection(connString))
> {
> conn.Open();
> var command = conn.CreateCommand();
> var copyStr = string.Format("COPY staging.test(col1,col2) FROM STDIN");
> command.CommandText = copyStr;
> command.CommandType = CommandType.Text;
> var serializer = new NpgsqlCopySerializer(conn);
> var copyIn = new NpgsqlCopyIn(command, conn, serializer.ToStream);
> copyIn.Start();
> foreach (var row in incomingRows)
> {
> //feed the values here
> }
> copyIn.End();
> serializer.Flush();
> serializer.Close();
> command.Dispose();
> }
> If incomingRows has one or more items, this works. However, if no rows are
> saved, serializer.Close() blows up:
>
> System.NullReferenceException : Object reference not set to an instance of
> an object.
> at Npgsql.NpgsqlCopySerializer.Close()
>
> What am I doing wrong?
>
>
>
>
>
> --
> View this message in context:
> http://postgresql.1045698.n5.nabble.com/NpgsqlCopySerializer-blows-up-if-no-rows-are-saved-tp5781300.html
> Sent from the PostgreSQL - general mailing list archive at Nabble.com.
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message AK 2013-12-02 22:20:29 Re: NpgsqlCopySerializer blows up if no rows are saved
Previous Message Stephen Frost 2013-12-02 21:56:56 Re: Trust intermediate CA for client certificates