[Mono-list] [ANN] Initial strong datatype support is in cvs

Francisco Figueiredo Jr. fxjrlists@yahoo.com.br
Tue, 8 Apr 2003 23:31:56 -0300 (ART)

Hi all,

    Strong datatype support has been checked out into CVS. Now, you can work
with seven strong types: 

numeric and 

Both DataReader as well as parameters are fully strong type supported and not
just integer, bigint and text types as before.

In earlier versions, the data read from backend was stored as a string and
later converted to the expected type in DataReader and Command functions. Now,
the data is parsed and converted to its strong type as soon as it is read from
backend. Any types not yet support are still stored as string, but now they are
NpgsqlString types.

A new namespace called NpgsqlTypes were added. It contains all the strong types
classes as well as a helper class used to do the conversions.

As Daniel Morgan, from Mono ADO.NET team said, oids could change from one
version to other of the backend, so, instead of relaying in hardcoded oids to
do the conversion, we load the types with a select oid, typname from pg_type
and work with the relationship oid<->typename and we relay in the typename
itself as this would have a much lower probability of change (I think it is
about 0 percent probability). (i.e.: a int4 would be called int4 for a long

Another issue would be the cost of this type mapping load which should be done
in each connection open. To lower this cost, a "cache" of type mappings is hold
key'ed in the string version returned by select version(). This means that each
new connections to the same server will load types exactly only once, in the
first time connection is done. I could see an improved performance with this
approach in the tests I did.

I think new types can be easily added as all the support for it can be added in
just one place, the NpgsqlTypesHelper class. It has responsabilities as get the
data as soon as they are read from backend and translate it to the strong
datatype and the support to convert the strong type to a string to be sent to
the backend. 

Note that now, strings are handled correctly. They are added the single quotes
automatically so strings with spaces are correctly sent to server.

timestamp is supported by setting the datestyle to ISO in server. So it can be
sent/received from server in a cultural-neutral way.

numerics are parsed using also a cultural-neutral way of representing the
decimal point, as it can change from '.' to ',' in some countries.

I'd like to thank Victor Vatamanescu for his implementation of strong datatypes
classes and Ben Clewett for tests. And of course all of you who helped us
improve Npgsql with comments, bug reports and fixes. Thank you very much :)

Please, get the latest cvs code and post your comments, bug reports and fixes
so we can improve Npgsql even more. :)

Francisco Figueiredo Jr.

Yahoo! Mail
O melhor e-mail gratuito da internet: 6MB de espašo, antivÝrus, acesso POP3, filtro contra spam.