Re: [PATCHES] DatabaseMetadata patch
Re: [PATCHES] DatabaseMetadata patch
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Here is a patch for DatabaseMetaData to show precision properly. It is
from Mark Lillywhite. I am adding to the patch queue.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Index: org/postgresql/jdbc2/DatabaseMetaData.java
===================================================================
RCS file: /cvs/pgjdbc71/org/postgresql/jdbc2/DatabaseMetaData.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- org/postgresql/jdbc2/DatabaseMetaData.java 2001/10/04 05:01:32 1.1
+++ org/postgresql/jdbc2/DatabaseMetaData.java 2001/10/23 09:44:30 1.2
@@ -1932,7 +1932,19 @@
tuple[7] = null; // Buffer length
- tuple[8] = "0".getBytes(); // Decimal Digits - how to get this?
+ // Decimal digits = scale
+ // From the source (see e.g. backend/utils/adt/numeric.c,
+ // function numeric()) the scale and precision can be calculated
+ // from the typmod value. mark@plasticsoftware.com.au
+ if (typname.equals("numeric") || typname.equals("decimal"))
+ {
+ int attypmod = r.getInt(8);
+ tuple[8] =
+ Integer.toString((attypmod & 0xffff) - VARHDRSZ).getBytes();
+ }
+ else
+ tuple[8] = "0".getBytes();
+
tuple[9] = "10".getBytes(); // Num Prec Radix - assume decimal
// tuple[10] is below
Re: [PATCHES] DatabaseMetadata patch
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Bruce Momjian writes: > + tuple[8] = > + Integer.toString((attypmod & 0xffff) - VARHDRSZ).getBytes(); In the backend sources, we subtract VARHDRSZ *first* and then AND with FFFF. Not sure if this will ever yield a different result, but I'd say it should be kept consistent ... regards, tom lane
Re: [PATCHES] DatabaseMetadata patch
От:
Barry Lind <barry@xythos.com>
Дата:
The patch is missing the corresponding fix for
jdbc1/DatabaseMetaData.java. Can you resubmit the patch with a fix for
both occurances of the problem? Otherwise the fix looks fine.
thanks,
--Barry
Bruce Momjian wrote:
> Here is a patch for DatabaseMetaData to show precision properly. It is
> from Mark Lillywhite. I am adding to the patch queue.
>
>
>
> ------------------------------------------------------------------------
>
> Index: org/postgresql/jdbc2/DatabaseMetaData.java
> ===================================================================
> RCS file: /cvs/pgjdbc71/org/postgresql/jdbc2/DatabaseMetaData.java,v
> retrieving revision 1.1
> retrieving revision 1.2
> diff -u -r1.1 -r1.2
> --- org/postgresql/jdbc2/DatabaseMetaData.java 2001/10/04 05:01:32 1.1
> +++ org/postgresql/jdbc2/DatabaseMetaData.java 2001/10/23 09:44:30 1.2
> @@ -1932,7 +1932,19 @@
>
> tuple[7] = null; // Buffer length
>
> - tuple[8] = "0".getBytes(); // Decimal Digits - how to get this?
> + // Decimal digits = scale
> + // From the source (see e.g. backend/utils/adt/numeric.c,
> + // function numeric()) the scale and precision can be calculated
> + // from the typmod value. mark@plasticsoftware.com.au
> + if (typname.equals("numeric") || typname.equals("decimal"))
> + {
> + int attypmod = r.getInt(8);
> + tuple[8] =
> + Integer.toString((attypmod & 0xffff) - VARHDRSZ).getBytes();
> + }
> + else
> + tuple[8] = "0".getBytes();
> +
> tuple[9] = "10".getBytes(); // Num Prec Radix - assume decimal
>
> // tuple[10] is below
>
>
> ------------------------------------------------------------------------
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
>
Re: [PATCHES] DatabaseMetadata patch
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
> The patch is missing the corresponding fix for > jdbc1/DatabaseMetaData.java. Can you resubmit the patch with a fix for > both occurances of the problem? Otherwise the fix looks fine. I have applied the jdbc2 version. It would be nice to have a jdbc1 version too. Thanks. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Re: [PATCHES] DatabaseMetadata patch
JDBC1 patch attached. I don't have a JDBC1 environment (that I know of) so I haven't even compiled this... sorry :( I also attach a very small patch to correct my email address in the JDBC 2 patch. Apply it or not, it's not important, I just noticed it. Thanks again Cheers Mark > I have applied the jdbc2 version. It would be nice to have a jdbc1 > version too. Thanks.
Re: [PATCHES] DatabaseMetadata patch
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
This was applied a while ago. Thanks. --------------------------------------------------------------------------- -- Start of PGP signed section. > JDBC1 patch attached. I don't have a JDBC1 environment (that I know of) > so I haven't even compiled this... sorry :( > > I also attach a very small patch to correct my email address in the JDBC > 2 patch. Apply it or not, it's not important, I just noticed it. > > Thanks again > Cheers > Mark > > > I have applied the jdbc2 version. It would be nice to have a jdbc1 > > version too. Thanks. > [ Attachment, skipping... ] [ Attachment, skipping... ] -- End of PGP section. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026