Page 1 of 1

Bit Type and Postgresql v8.0.0beta5

Posted: Thu 31 Mar 2005 15:57
by Aaron
There seems to be a problem correctly retrieving the bit type from Postgresql v8.0.0beta5 using the latest version of the driver (2.10.3.0). It works fine for the bit type with Postgresql v7.3.

I had the same problem with the old version of the CoreLab driver and was hoping the new one would fix it but no such luck.

I retrieve rows into a DataSet using adpater.Fill() and then attempt to retrieve the bit fields with the following cast:

string bitStr = ((System.Collections.BitArray)dataRow["bitfield"])[0].ToString();

but it's always false regardless of whether the bit is 0 or 1 in the database.

Bit Type and Postgresql v8.0.0beta5

Posted: Fri 01 Apr 2005 15:20
by Yuri
We reproduced your problem and fixed it. This fix will be included in the next PostgreSQLDirect NET build. It will be available in a week.

Posted: Sat 09 Apr 2005 13:49
by Guest
Has this version been released??

Posted: Tue 12 Apr 2005 13:36
by Guest
This does not appear to be fixed in version 2.10.4.

Once again:

string strResult = ((System.Collections.BitArray)column)[0].ToString();
if(strResult == "0" || Regex.Match(strResult, "false", RegexOptions.IgnoreCase).Success)
{
return false;
}
else
{
return true;
}

always returns false irrespective of whether the bit is 0 or 1 in the database.

Is there a reason why a BitArray is being returned for a bit field in the database? Npgsql returns bit fields as strings which makes more sense since there will only ever be one element in the array and also makes it a lot easier to work with.

Thanks.

Bit Type and Postgresql v8.0.0beta5

Posted: Tue 12 Apr 2005 14:56
by Yuri
We couldn't reproduce the problem. The sample you have provided works fine. Please check the version of assembly you load.
Guest wrote:Is there a reason why a BitArray is being returned for a bit field in the database?
Fields BIT and VARBIT are not always of length 1, thus BitArray type is used.

Posted: Wed 13 Apr 2005 08:21
by Guest
Hi,

I've double checked the version of the CoreLab dll I'm using and it's defintelty 2.10.4. I don't have it installed in the GAC so there is no chance of a conflict there.

I'm still getting the memory leak and the incorrect serialisation of the bit field. Is it possible that the version for download on your web site is incorrect?

Thanks,

Aaron

Bit Type and Postgresql v8.0.0beta5

Posted: Wed 13 Apr 2005 11:37
by Yuri
Send us please small demo project to demonstrate the problem and include script to create server objects.

Bit Type and Postgresql v8.0.0beta5 - workaround

Posted: Mon 25 Apr 2005 17:57
by darius
Hi Yuri,

Just tried 2.10.4 with postgresql 8.01 on linux with same symptoms. The pgsql and C# code below reproduces the symptoms for me;

Workaround is to put the bit field in the first or last position in the query; eg.
string qry = "SELECT bitn, chars1, chars2 from bits";
string qry = "SELECT chars1, chars2, bitn from bits";

If the bit field is not in the first or last position then it comes comes back as False.
----------------------------------------------

using System;
using System.Data;
using System.Collections;
using CoreLab.PostgreSql;
namespace ConsoleApplication1 {
class Class1
{

// CREATE TABLE bits
// (
// chars1 char(2) NOT NULL,
// bitn bit NOT NULL,
// chars2 char(2) NOT NULL
// )
//
// insert into bits values( 'B1', '1', 'XX' )
// insert into bits values( 'B2', '0', 'XX' )
// insert into bits values( 'B3', '1', 'XX' )

[STAThread]
static void Main(string[] args) {
string connStr "host=pghost;database=mydb;user=postgres;";
string qry = "SELECT chars1, bitn, chars2 from bits";
pgSqlConnection conn = new PgSqlConnection(connStr);
conn.Open();
PgSqlDataAdapter adapter = new PgSqlDataAdapter();
adapter.SelectCommand = new PgSqlCommand(qry, conn);
DataSet ds = new DataSet();
adapter.Fill(ds, "bits");
Console.WriteLine( "CoreLab.PostgreSql 2.10.4.0" );
Console.WriteLine( "B1 and B3 should be true ..." );
foreach (DataRow r in ds.Tables["bits"].Rows)
{
BitArray bits = (BitArray)r[ "bitn" ];
Console.WriteLine( "char2(" + r[ "chars1" ] + ") bitn(" + bits[0].ToString() + ")" );
}
Console.WriteLine( "Done." );
} // end of main
} // end of class Class1
} // end of namespace ConsoleApplication1

Bit Type and Postgresql v8.0.0beta5 - workaround

Posted: Thu 28 Apr 2005 14:44
by Yuri
Thank you for your sample. We reproduced your problem and fixed it. This fix will be included in the next PostgreSQLDirect .NET build.

Bit Type and Postgresql v8.0.0beta5

Posted: Fri 29 Apr 2005 05:09
by simon
Greetings Yuri,

> Thank you for your sample. We reproduced your problem and fixed it. This fix will be included in the next PostgreSQLDirect .NET build

That's been fixed a bit more quickly than I was expecting :) :!:

Do you have an approximate date for the next build/release of PostgreSQLDirect?

Thanks

Bit Type and Postgresql v8.0.0beta5

Posted: Fri 29 Apr 2005 14:01
by Yuri
New build was released and you can download it now from Core Lab server.

Posted: Sat 30 Apr 2005 14:19
by Guest
This time it's fixed :D

Aaron