NUMERIC/DECIMAL handling in JDBC fixed
NUMERIC/DECIMAL handling in JDBC fixed
От:
Mark Lillywhite <mark@plasticsoftware.com.au>
Дата:
Hi folks In my continuing quest to actually contribute something to the world (not to mention get my application running) I have found and fixed a few problems with the JDBC driver's handing of Numeric/Decimal data types. It seems to me that these types were never really implemented in JDBC when the types were added to Postgresql, so I hope this small amount of work is helpful. This is the driver shipped with 6.5.1 since I don't have the bandwidth for 6.5.2 at this moment. Firstly, in postgresql.Field, getSQLType() didn't recognise these types and returned SQL_OTHER, which is wrong. I've made a very little fix to make it return SQL_DECIMAL or SQL_NUMERIC (see questions below). Next, in DatabaseMetaData.getColumns(), this method did not return the DECIMAL_DIGITS column of the attribute; this is pretty important for working out what to put into a getBigDecimal() call, so I worked out how to work it out (hm) and I added it in. It seems to work fine. I hope that noone (e.g. the maintainer!) minds that I did this, I was really interested in fixing it as an excersise as much as because I needed it fixed :) ... also, if this is generally considered useful then what do I do to submit a patch? And, what do people here use for patches anyway? diff -Naur? I am going to quickly look at getObject since that has some issues with Numeric types too, it tries to set the scale but throws an exception when it needs rounding (since it assumes the scale is zero). I'm not sure if I can do anything about this and if not I think I will ignore it for now as my application has to be running, more or less, this evening (sigh). Also, can someone smarter than me tell me what difference there is (if any) between DECIMAL and NUMERIC, either in the PG type names (does Postgres distinguish these?) or in the SQL spec? I looked at the parser's yacc file but I wasn't really able to see how it distinguishes between them, or if they are just synonyms. (but it has been many years since I used yacc). I presume that the same changes will be needed to the JDBC2 driver and I'm happy to make them and submit them too, but at this stage I can't test them. Kind regards Mark -- Mark Lillywhite - Plastic Software http://www.plasticsoftware.com.au/ ------------------------------------------------------------------------------- Plastic Software provides fully integrated, easy to use products and support for Internet Service Providers, such as authentication and accounts receivable. "The great thing about free mail is that you don't have to pay for it." -- Scott McNealy
Re: [INTERFACES] NUMERIC/DECIMAL handling in JDBC fixed
От:
Jens Glaser <jens@helena.jens.de>
Дата:
Hi, On Sun, 19 Sep 1999, Mark Lillywhite wrote: > In my continuing quest to actually contribute something to the world (not to > mention get my application running) I have found and fixed a few problems > with the JDBC driver's handing of Numeric/Decimal data types. It seems to me This is superb! But you are too late :-) Check out the recent 6.5.2. driver, it should include the NUMERIC type fix. Best regards, Jens BTW: AFAIK it is *not* included in the 6.5.2 tarball (don't know why), so try the version in the CVS. -- Jens Glaser Am Holderstrauch 13, 36041 Fulda, 0661/9429507 jens@jens.de
Re: [INTERFACES] NUMERIC/DECIMAL handling in JDBC fixed
От:
Peter Mount <peter@retep.org.uk>
Дата:
On Sun, 19 Sep 1999, Jens Glaser wrote: > Hi, > > On Sun, 19 Sep 1999, Mark Lillywhite wrote: > > In my continuing quest to actually contribute something to the world (not to > > mention get my application running) I have found and fixed a few problems > > with the JDBC driver's handing of Numeric/Decimal data types. It seems to me > > This is superb! But you are too late :-) Check out the recent 6.5.2. > driver, it should include the NUMERIC type fix. > > Best regards, Jens > > BTW: AFAIK it is *not* included in the 6.5.2 tarball (don't know why), so > try the version in the CVS. It possibly missed the deadline when Mark built the tar ball (although it's more likely that when I committed it, it went into the 6.6 tree rather than the 6.5.2 one). -- Peter T Mount peter@retep.org.uk Main Homepage: http://www.retep.org.uk PostgreSQL JDBC Faq: http://www.retep.org.uk/postgresJava PDF Generator: http://www.retep.org.uk/pdf