public void PqsqlCopyFromTest2() { PqsqlTransaction tran = mConnection.BeginTransaction(); mCmd.Transaction = tran; mCmd.CommandText = "CREATE TEMP TABLE temp (id int4, val int4, txt text)"; mCmd.CommandTimeout = 200; mCmd.CommandType = CommandType.Text; const int upperbound = 2000000; const string text = "text value with ü and ä "; int q = mCmd.ExecuteNonQuery(); Assert.AreEqual(0, q); PqsqlCopyFrom copy = new PqsqlCopyFrom(mConnection) { Table = "temp", CopyTimeout = 30 }; copy.Start(); for (int i = 0; i < upperbound; i++) { int j = copy.WriteInt4(i); Assert.AreEqual(4, j); j = copy.WriteInt4(i); Assert.AreEqual(4, j); j = copy.WriteText(text + i); Assert.AreEqual(Encoding.UTF8.GetByteCount(text + i), j); // length without nul byte } copy.WriteNull(); // id copy.WriteNull(); // val copy.WriteNull(); // txt copy.End(); copy.Close(); mCmd.CommandText = "select * from temp"; mCmd.CommandTimeout = 30; mCmd.CommandType = CommandType.Text; PqsqlDataReader r = mCmd.ExecuteReader(); int n = 0; int k = 0; while (r.Read()) { if (n++ == upperbound) { Assert.IsTrue(r.IsDBNull(0)); Assert.IsTrue(r.IsDBNull(1)); Assert.IsTrue(r.IsDBNull(2)); } else { Assert.AreEqual(k, r.GetInt32(0)); Assert.AreEqual(k, r.GetInt32(1)); Assert.AreEqual(text + k, r.GetString(2)); k++; } } Assert.AreEqual(upperbound + 1, n); r.Close(); tran.Rollback(); }