Sunday, November 12, 2006

Initial Npgsql2 provider factory support added to cvs

UPDATE: Thomas Burkhart sent me a mail telling me that this configuration syntax doesn't work on ms.net 2.0. This is the version which works:

<?xml version="1.0" encoding="iso-8859-1" ?>
<configuration>

<system.data>
<DbProviderFactories>

<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7" />

</DbProviderFactories>
</system.data>

</configuration>


Thomas said that "the tags are case sensitive and the must be outside any <applicationSettings>"


Thank you Thomas for your feedback which, for sure will help others to get their configuration up and running. I will check with Mono guys to see why my original configuration worked.




Hi all!

Today I committed an initial support for provider factory to Npgsql2.

This will allow ado.net 2.0 users to work with Npgsql using ado.net generic coding.

In order to use it, you have to add the following xml config in your machine.config or yourapp.exe.config file:


<?xml version="1.0" encoding="ISO-8859-1" ?>
<configuration>
<appsettings>

<system.data>
<dbproviderfactories>

<add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory, Npgsql, Version=1.0.0.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7">
</add>
</dbproviderfactories>
</system.data>
</appsettings>
</configuration>


P.S.: Sorry for indentation lacking. I don't know how to add it on blogger :(

Note that this is the full contents of a yourapp.exe.config file. If you are changing the machine.config file, just add the "add name=..." section.

The key elements here are the invariant name which will be used in your application when returning the provider factory. In this case it is defined as "Npgsql". But you can specify whatever you want.


That's it! If everything is ok, you will be able to write some code like that, to connect to postgresql:


using System;
using System.Data;
using System.Data.Common;


public class c
{
public static void Main(String[] args)
{

DbProviderFactory factory = DbProviderFactories.GetFactory("Npgsql");

DbConnection conn = factory.CreateConnection();

conn.ConnectionString = "Server=127.0.0.1;User id=npgsql_tests;password=npgsql_tests;";

conn.Open();

conn.Close();


}
}


Enjoy!


P.S.: Npgsql2 code is found in Npgsql2 cvs module. See here for more info about how to get it.

Warning: This is a very early code, so bugs still exist and there are things missing. Basic functionality should work ok.



Friday, October 27, 2006

Started works on Npgsql2

Hi all,

We already started to work on Npgsql2 with support for .net 2.0 and ado.net 2.0. Josh Cooley already refactored all Npgsql classes to extend from .net 2.0 classes, like DbCommand, DbConnection and others. We hope to have a preview release soon with some long awaited features like Provider Factory support, design time in vs.net 2005 and others.

Stay tuned!

Tuesday, October 17, 2006

Npgsql 1.0 Released!! A little bit of its history

Hi all!

I'm really happy to announce that Npgsql Team has released Npgsql 1.0 final!

I started to work on Npgsql 4 years ago, just after I finished my CS graduation course. What motivated me was the possibility to implement a network communication protocol and to have something done to community. I'm a big fan of OpenSource philosophy, better, I'm passionate about OpenSource and community, and realized I didn't return anything to it up to now. Besides that, I wanted to make part of it.

So, I started sending a message to postgresql mailling list asking if there was something about that being worked on. I received some replies about nothing being done yet and one saying that a p/invoke based proof of concept was tested. I wanted to implement postgresql communication protocol so I started to work on it. Some time later, I sent another message talking about project launch. At that time, Dave Page, from pgAdmin, jumped the wagon and started to help me get project going. I couldn't believe it! Dave Page, who later I discovered didn't play only with pgAdmin but also with postgresql installer and postgresql itself and others, was helping me with my just-started project! Thank you, Dave!

Since then, we have been working on a lot of features to make Npgsql work as best as possible. We have made a lot of progress and today Npgsql is a big success. One thing which make me think we were in the right direction was an invitation from Daniel Morgan, of Mono Project, to make Npgsql available in Mono sources. This made Npgsql become part of a bigger project and I'm very happy this happened. You guys, rock! Thanks for believing in the project.

I learned a lot about opensource on all those years working with Npgsql. I also knew a lot of very nice people, here in my country, Brazil, and throughout the world. I think this is the biggest reward I received for all this work. It is an experience I will carry with me for the rest of my life.

I would like to thank, firstly, God for allowing all this to happen and all people who helped me and the project to become what it is today! Without your help this won't be possible. I'd like to give special thanks to Josh Cooley, who have been doing a great job helping me to organize and give Npgsql the right direction and Hiroshi Saito who is helping us to spread the word of Npgsql in Japan! Dave Page for all his guidance and support. Guys and gals at gborg and pgfoundry who hosted Npgsql. Thank you!

(Note: I will edit this post later to add the name of all developers who helped Npgsql. I will search my mail archives to get your names and make sure I don't forget anyone)


For the future, we will be working on new ado.net 2.0 features and integration with visual studio.net. We will work on better performance and feature completeness. There is a lot of work to do and we will count on community feedback to make it even better! Stay tuned!


Thank you all

Francisco Figueiredo Jr.
Npgsql Lead Developer

Sunday, August 20, 2006

Npgsql 1.0RC3 released!

Hi all,

Npgsql 1.0 RC3 is released!

Download it here

This release fixes some critical bugs with concurrent connection stablishment and "This stream does not support seek operation" error when sending a query. Please, have a look at release notes here for more information about there errors.

We are almost finished with 1.0. We hope to have a 1.0 final really soon so we can get 100% concentration on ado.net 2.0 features.

Thursday, August 10, 2006

Critical bugs fixed. RC3 is on the way...

Hi all,

These past 10 days, Josh Cooley fixed and helped to fix a lot of critical bugs on Npgsql! Here are they:

Josh Cooley fixed a bug when dealing with concurrent connection establishment using Npgsql RC2. When I implemented ConnectionTimeout support for connection establishment, I was incorrectly using an instance variable with a singleton object :(
This was leading to some nasty problems like this.

Here is the relevant stack trace:

Npgsql.NpgsqlException:
Operation not allowed on non-connected sockets.
at Npgsql.NpgsqlClosedState.Open(NpgsqlConnector context)
at Npgsql.NpgsqlConnector.Open()
at Npgsql.NpgsqlConnectorPool.GetNonPooledConnector(NpgsqlConnection Connection)
at Npgsql.NpgsqlConnectorPool.RequestConnector(NpgsqlConnection Connection)
at Npgsql.NpgsqlConnection.Open()


Another problem, this time with async notification support, was that Npgsql wasn't handling correctly the notification message sent from server when async notification was off. This was leading to nasty exceptions from Npgsql about "this stream doesn't not support seek operation". More information about this bug can be found here. Josh Cooley had a critical role here as his observations about some details on code while struggling to fix this bug lead us to find the culpirit. Thank you, Josh! This is the root stack trace:

System.NotSupportedException: This stream does not
support seek operations.
at System.Net.Sockets.NetworkStream.Seek(Int64 offset, SeekOrigin origin)
at System.IO.BufferedStream.FlushRead()
at System.IO.BufferedStream.WriteByte(Byte value)
at Npgsql.NpgsqlQuery.WriteToStream(Stream outputStream, Encoding encoding)
at Npgsql.NpgsqlReadyState.Query(NpgsqlConnector context, NpgsqlCommand command)
at Npgsql.NpgsqlConnector.Query(NpgsqlCommand queryCommand)
at Npgsql.NpgsqlCommand.ExecuteCommand()
at Npgsql.NpgsqlCommand.ExecuteNonQuery()


One thing worth noting here is that if you look closer, this exception is caused because BufferedStream, when flusing the stream, calls Seek method! It seems FlushRead() doesn't check if the stream passed can seek or not. This error only happens on ms.net, 1.1 and 2.0.
Mono correctly checks if stream can seek when flushing the stream and doesn't throw the exception.

So, if you are being affected by some of these bugs ( or all of them :) ) and need an urgent fix, please grab a copy of cvs and give it a try. Otherwise, RC3 release is on the way with those fixes.

Sorry for any problem this may have caused to you.

Tuesday, July 11, 2006

Npgsql 1.0RC2 released!

Hi all,

after a lot of time, I'm finally writing here again! I had to reinstall my development box. But here are some good news: Npgsql 1.0RC2 is released!! :)

There were a lot of bug fixes and some nice features added this time. Please, have a look at release notes and download it here.

Please, give it a try and let me know of any problems you may have.

Sunday, April 23, 2006

I'm back from 7th Forum Internacional de Software Livre

Hi all,

I'm back from 7th Fórum Internacional de Software Livre em Porto Alegre. It was very good! I attended to a lot of presentations. I also could meet some Mono Brasil friends. I also met Miguel de Icaza there! He took a lot of pictures :)

I'd like to thank all the organization crew for this great event and all people who went there.

Thursday, April 13, 2006

Synchronous notification explained

Hi all,

it seems that my coined feature name "synchronous notification" is confusing everybody. I hope to explain it better now.

Synchronous notification is the name I gave to Npgsql implementation of Listen/Notify support where you (the Npgsql client) receive a notification message "synchronously" or "almost" at same time the notification is sent from server. This contrasts to what Npgsql had before: the client would just receive any notification on next iteration with server as this was when we processed the notification server sent us.

One possible solution for this problem before was the client to keep "polling" the server with empty commands in order to force an interation with server and receive the notification. Now, behind the scenes, Npgsql creates a new thread which keeps polling server for you with Socket.Poll() method while client is idle. This way, as soon as notification arrives in Npgsql socket, it can promptly process notification and deliver it to client with no intervention of client as before. This will help very much client applications which just stays there and wants to receive notifications from server without any modification.

It is disabled by default. You can enable it by specifying SyncNotification=true in your connection string.

I hope this explanation helps clear what is this feature of Npgsql :)


Please, share what you think about this feature and if it is working for you like it should.

Sunday, April 09, 2006

Npgsql 1.0RC1 released!

Hi all,

Npgsql Development Team has just released Npgsql 1.0RC1.

Please, check release notes at usual place: http://pgfoundry.org/frs/shownotes.php?release_id=529

Thanks God for making this possible.
Thanks all who contributed with bug reports and feedback.

You can download binaries and sources from here

Friday, March 24, 2006

Synchronous notification landed in cvs.

Hi all,

I finally could get synchronous notification done. It is in cvs now.

What is synchronous notification?
Up to now, in order to get notifications from postgresql, Npgsql clients would need to call empty commands. If application didn't do that, only on next NpgsqlCommand.Execute* call notification would be delivered.
Now with synchronous notification, client applications are notified as soon as message arrives, hence the name synchronous notification.

On current code, it is disabled by default. To enable it, you have to put syncnotification=true in your connection string.

How it works?

When you enable synchronous notification, Npgsql will create another thread to check is data arrived in socket. To do that, it uses Socket.Poll method. When Npgsql is idle, this thread is running. It is stopped as soon as any NpgsqlCommand.Execute* method is called and resumed when this call returns.

Side effects:

Because of synchronization of threads, there is performance drop when using synchronous notification. So, if you want max performance, don't use it. Synchronous notification is more valuable on desktop applications where they have more idle cycles and need more "real time" notifications.

Please, give it a try and let me know if you find any problems.

This blog is now subscribed in PlanetPostgresql.org

Hi all,

Magnus Hagander added this blog to the list of blogs in PlanetPostgresql.org! Thank you very much, Magnus. As I said before, this is a honor to me :)

Monday, March 20, 2006

Synchronous notification is working!!

Hi all,

I finally got the synchronization problems fixed and now Npgsql supports synchronous notification!

Right now the code is only on my devel machine. I will commit the code to cvs this week. I'm still doing more tests. All tests I did up to now passed ok!

Thursday, March 16, 2006

Npgsql synchronous notification status...

Hi all,

After recovering from my myopia surgery, I started to play with the long ago requested synchronous notification support in Npgsql. With it, you will be able to receive notifications from Postgresql server as soon as they are posted.

Right now it can handle correctly the notifications, but I'm having some problems when sync'ing the notification thread. This notification thread will be checking for notifications from server with Socket.Poll calls.

As soon as I got this sync problem done, I will commit it to cvs. Stay tunned.

Saturday, March 11, 2006

Music genoma really exists...

Well, I think it is around for some time, but just today I had a look at Pandora site.

I have to admit that I started to really believe in music genoma!! It really exists! Each new music Pandora presented to my ears was 90% close to what I like. :) I don't say 100% because there were some bad choices. But for sure this is just a matter of time and fine tunning. I just listened to 8 songs.

Pandora is really an excellent way of getting personal playlists.

If you don't know it yet, give it a try: www.pandora.com

Thursday, March 09, 2006

Eu também falo Português do Brasil :)

Olá pessoal,

Alguns colegas meus me perguntaram porque o meu blog estava todo em inglês. Eu falei para eles que era apenas uma questão de audiência. No entanto o fato de eu escrever em Inglês não impede que os meus amigos deixem comentários em Português. Podem escrever à vontade! :)

Valeu pelo apoio e por me chamar a atenção para esse fato.

Até a próxima!

Monday, February 06, 2006

I see "almost crystal clear" people!

Hi all,

Today I'm getting back to work. Finally! Myopia surgery seems to went ok. But I'm still seeing some blur and I hope it goes away on next weeks :) Now I will, little by little, start to answer emails and keep updates to Npgsql project which has some bugs and patches pending :)

I'd like to thank God, in first place, for allowing me to be back.
Also, I'd like to thank Dr. Antônio Márcio who did the surgery. And thank you to all my friends and co-workers who gave me a big support on all this.

Sunday, January 22, 2006

Myopia surgery

Hi all,

Tomorrow (2006-01-23) I'll be submitted to a myopia surgery. This means I won't be able to work for a couple of days. I hope to be back online soon :)

Monday, January 09, 2006

Npgsql 1.0beta2 released!

Hi all,

after some delay, finally I could release Npgsql 1.0beta2.

This release has a lot of bug fixes and features a huge performance improvement, thanks Hubert Fongarnand and Bryan Mayland who sent a lot of optimizations to Npgsql.

Also, on this release, for the first time we release assemblies for .net 2.0, mono and ms implementations.

You can download it from Npgsql homepage

Please, give it a try and let me know if you have any problems with it.

Thanks God for allowing me to make this happen.

Thanks all who helped with patches and feedbacks.