[Mono-devel-list] Npgsql

Daniel Morgan danielmorgan at verizon.net
Sun Dec 26 21:51:01 EST 2004


Hey fxjr, 
Thanks for responding!

Here is a test case:

// mcs pgtest.cs /r:System.Data.dll /r:Npgsql.dll
using System;
using System.Data;
using Npgsql;

namespace TestNpgsqlStuff
{
	public class TestNpgsql 
	{
		NpgsqlConnection con;

		public void ReadData (string selectSql) 
		{
			NpgsqlCommand cmd = null;
			NpgsqlDataReader reader = null;
		
			cmd = con.CreateCommand();
			cmd.CommandText = selectSql;
			reader = cmd.ExecuteReader();
		
			Console.WriteLine("Results...");
			Console.WriteLine("Schema");
			DataTable table;
			table = reader.GetSchemaTable();
			for(int c = 0; c < reader.FieldCount; c++) {
				Console.WriteLine("  Column " +
c.ToString());
				DataRow row = table.Rows[c];
			
				string strColumnName =
row["ColumnName"].ToString();
				string strColumnSize =
row["ColumnSize"].ToString();
				string strNumericScale =
row["NumericScale"].ToString();
				string strNumericPrecision =
row["NumericPrecision"].ToString();
				string strDataType =
row["DataType"].ToString();

				Console.WriteLine("    ColumnName: " +
strColumnName);
				Console.WriteLine("    ColumnSize: " +
strColumnSize);
				Console.WriteLine("    NumericScale: " +
strNumericScale);
				Console.WriteLine("    NumericPrecision: " +
strNumericPrecision);
				Console.WriteLine("    DataType: " +
strDataType);
			}
		}

		public void DoTest () 
		{
			con = new
NpgsqlConnection("SERVER=localhost;DATABASE=test;USER
ID=daniel;PASSWORD=asdf1234");
			con.Open ();

			ReadData ("SELECT numeric_value, char_value,
varchar_value FROM mono_postgres_test");

			con.Close ();
			con.Dispose ();
			con = null;
		}

		public static void Main (string[] args) {
			TestNpgsql test = new TestNpgsql ();
			test.DoTest ();
		}
	}
}


Here is the results:

$ mono pgtest.exe
Results...
Schema
  Column 0
    ColumnName: numeric_value
    ColumnSize: -1
    NumericScale: 0
    NumericPrecision: 0
    DataType: System.Decimal
  Column 1
    ColumnName: char_value
    ColumnSize: -1
    NumericScale: 0
    NumericPrecision: 0
    DataType: System.String
  Column 2
    ColumnName: varchar_value
    ColumnSize: -1
    NumericScale: 0
    NumericPrecision: 0
    DataType: System.String

Notice the ColumnSize is -1 for char_value and varchar_value and the scale
and precision is 0 for numeric_value.

You can see the program that created this table at
mcs/class/System.Data/Test/PostgresTest.cs

-----Original Message-----
From: mono-devel-list-admin at lists.ximian.com
[mailto:mono-devel-list-admin at lists.ximian.com] On Behalf Of Francisco
Figueiredo Jr.
Sent: Sunday, December 26, 2004 9:45 PM
To: Daniel Morgan
Cc: 'Mono Development List'
Subject: Re: [Mono-devel-list] Npgsql


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Daniel Morgan wrote:
| I don't know if this has been reported or not.  Or if it has been 
| fixed or not.
|
| However, I am using the Npgsql provider with Mono 1.0.5 on Windows XP 
| Pro with SP2. I am using an alpha version of PostgreSQL 8.0 Win32.
|
| I am getting the wrong column size of character types of -1.
|

Hi Daniel,

Could you send a simple test case??

|
|
| Also, the postmaster log shows "unexpected EOF on client connection".
  Here
| is a test program.
|

Yeap, this is a side effect of connection pool. When you open the connection
and close it, it is sent back to pool. But if your application exits, I
didn't find a way of catching this event and clear the pool and so when
socket is finalized by runtime, the socket is closed unexpectedly by Npgsql
and server reports that.

But you can ignore that.

Thanks for feedback.


- --
Regards,

Francisco Figueiredo Jr.
Membro Fundador do Projeto MonoBrasil - MonoBrasil Project Founder Member
http://monobrasil.softwarelivre.org



- -------------
"Science without religion is lame;
religion without science is blind."

~                  ~ Albert Einstein
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iQEVAwUBQc93Ff7iFmsNzeXfAQKGlQgAoFPXC49ZcaS8NlJQyQh1Kpdx7+iixVp0
nvAiYAOtbECX+9MfriZPOb06PL4+qYZt98aGAG/YOvxB5gsABucLasgRxRwxymXF
GT7LHsAU6nV3oq47W1YnMx/tHmasqAqCewCaIzTXy5nRo4V01twUV5XUs4YMVlDN
WGNMNmVB2/CmbsAO+2B1LnLo+UGHx+DKIcRcgvVMEWQKz1GlPj+olki8jZN8RWZ5
3gpYgeGyNBJLqqlnKFjWh8n4vx4bnqn3NxAShZV32BduX4EbFJRJxJCmzsNeALed
XkYJePJG/x8JYX7MC25yXhO1BgxwQ8I/610qADpU5FvniR4gtdb3ew==
=d1+5
-----END PGP SIGNATURE----- _______________________________________________
Mono-devel-list mailing list
Mono-devel-list at lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list




More information about the Mono-devel-list mailing list