Bit Type and Postgresql v8.0.0beta5

Bit Type and Postgresql v8.0.0beta5

Postby Aaron » Thu 31 Mar 2005 15:57

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.
Aaron
 

Bit Type and Postgresql v8.0.0beta5

Postby Yuri » Fri 01 Apr 2005 15:20

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.
Yuri
 
Posts: 140
Joined: Mon 08 Nov 2004 12:07

Postby Guest » Sat 09 Apr 2005 13:49

Has this version been released??
Guest
 

Postby Guest » Tue 12 Apr 2005 13:36

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.
Guest
 

Bit Type and Postgresql v8.0.0beta5

Postby Yuri » Tue 12 Apr 2005 14:56

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.
Yuri
 
Posts: 140
Joined: Mon 08 Nov 2004 12:07

Postby Guest » Wed 13 Apr 2005 08:21

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
Guest
 

Bit Type and Postgresql v8.0.0beta5

Postby Yuri » Wed 13 Apr 2005 11:37

Send us please small demo project to demonstrate the problem and include script to create server objects.
Yuri
 
Posts: 140
Joined: Mon 08 Nov 2004 12:07

Bit Type and Postgresql v8.0.0beta5 - workaround

Postby darius » Mon 25 Apr 2005 17:57

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
darius
 
Posts: 1
Joined: Mon 25 Apr 2005 17:53

Bit Type and Postgresql v8.0.0beta5 - workaround

Postby Yuri » Thu 28 Apr 2005 14:44

Thank you for your sample. We reproduced your problem and fixed it. This fix will be included in the next PostgreSQLDirect .NET build.
Yuri
 
Posts: 140
Joined: Mon 08 Nov 2004 12:07

Bit Type and Postgresql v8.0.0beta5

Postby simon » Fri 29 Apr 2005 05:09

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
simon
 
Posts: 2
Joined: Fri 29 Apr 2005 04:51

Bit Type and Postgresql v8.0.0beta5

Postby Yuri » Fri 29 Apr 2005 14:01

New build was released and you can download it now from Core Lab server.
Yuri
 
Posts: 140
Joined: Mon 08 Nov 2004 12:07

Postby Guest » Sat 30 Apr 2005 14:19

This time it's fixed :D

Aaron
Guest
 


Return to dotConnect for PostgreSQL