Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit521017c

Browse files
author
Dave Cramer
committed
patch from Vicktor to fix Numeric decimal digits in getColumns
1 parentfef790c commit521017c

File tree

2 files changed

+21
-15
lines changed

2 files changed

+21
-15
lines changed

‎src/interfaces/jdbc/org/postgresql/jdbc1/DatabaseMetaData.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/*
1414
* This class provides information about the database as a whole.
1515
*
16-
* $Id: DatabaseMetaData.java,v 1.42 2002/02/22 02:40:09 davec Exp $
16+
* $Id: DatabaseMetaData.java,v 1.43 2002/03/05 02:14:06 davec Exp $
1717
*
1818
* <p>Many of the methods here return lists of information in ResultSets. You
1919
* can use the normal ResultSet methods such as getString and getInt to
@@ -2017,14 +2017,17 @@ public java.sql.ResultSet getColumns(String catalog, String schemaPattern, Strin
20172017
// from the typmod value.
20182018
if (typname.equals("numeric") ||typname.equals("decimal"))
20192019
{
2020-
intattypmod =r.getInt(8);
2020+
intattypmod =r.getInt(8) -VARHDRSZ;
20212021
tuple[8] =
2022-
Integer.toString((attypmod -VARHDRSZ) &0xffff).getBytes();
2022+
Integer.toString(attypmod &0xffff).getBytes();
2023+
tuple[9] =
2024+
Integer.toString( (attypmod >>16 ) &0xffff ).getBytes();
20232025
}
20242026
else
2027+
{
20252028
tuple[8] ="0".getBytes();
2026-
2027-
tuple[9] ="10".getBytes();// Num Prec Radix - assume decimal
2029+
tuple[9] ="10".getBytes();// Num Prec Radix - assume decimal
2030+
}
20282031
tuple[10] =Integer.toString(nullFlag.equals("f") ?
20292032
java.sql.DatabaseMetaData.columnNullable :
20302033
java.sql.DatabaseMetaData.columnNoNulls).getBytes();// Nullable

‎src/interfaces/jdbc/org/postgresql/jdbc2/DatabaseMetaData.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
/*
1616
* This class provides information about the database as a whole.
1717
*
18-
* $Id: DatabaseMetaData.java,v 1.49 2002/02/22 02:17:13 davec Exp $
18+
* $Id: DatabaseMetaData.java,v 1.50 2002/03/05 02:14:08 davec Exp $
1919
*
2020
* <p>Many of the methods here return lists of information in ResultSets. You
2121
* can use the normal ResultSet methods such as getString and getInt to
@@ -2046,17 +2046,17 @@ public java.sql.ResultSet getColumns(String catalog, String schemaPattern, Strin
20462046

20472047
if ((tableNamePattern !=null) && !tableNamePattern.equals("%"))
20482048
{
2049-
sql.append("and c.relname like\'" +tableNamePattern +"\'");
2049+
sql.append(" and c.relname like\'" +tableNamePattern +"\'");
20502050
}
20512051

20522052
if ((columnNamePattern !=null) && !columnNamePattern.equals("%"))
20532053
{
2054-
sql.append("and a.attname like\'" +columnNamePattern +"\'");
2054+
sql.append(" and a.attname like\'" +columnNamePattern +"\'");
20552055
}
20562056

20572057
sql.append(
2058-
"and a.attnum > 0" +
2059-
")" +
2058+
" and a.attnum > 0" +
2059+
" )" +
20602060
" ) inner join pg_type t on" +
20612061
" (" +
20622062
" t.oid = a.atttypid" +
@@ -2112,18 +2112,22 @@ public java.sql.ResultSet getColumns(String catalog, String schemaPattern, Strin
21122112

21132113
tuple[7] =null;// Buffer length
21142114
// Decimal digits = scale
2115-
// From the source (see e.g. backend/utils/adt/numeric.c,
2115+
// From the source (see e.g. backend/utils/adt/format_type.c,
21162116
// function numeric()) the scale and precision can be calculated
21172117
// from the typmod value.
21182118
if (typname.equals("numeric") ||typname.equals("decimal"))
21192119
{
2120-
intattypmod =r.getInt(8);
2120+
intattypmod =r.getInt(8) -VARHDRSZ;
21212121
tuple[8] =
2122-
Integer.toString((attypmod -VARHDRSZ) &0xffff).getBytes();
2122+
Integer.toString(attypmod &0xffff ).getBytes();
2123+
tuple[9] =
2124+
Integer.toString( (attypmod >>16 ) &0xffff ).getBytes();
21232125
}
21242126
else
2127+
{
21252128
tuple[8] ="0".getBytes();
2126-
tuple[9] ="10".getBytes();// Num Prec Radix - assume decimal
2129+
tuple[9] ="10".getBytes();// Num Prec Radix - assume decimal
2130+
}
21272131
tuple[10] =Integer.toString(nullFlag.equals("f") ?
21282132
java.sql.DatabaseMetaData.columnNullable :
21292133
java.sql.DatabaseMetaData.columnNoNulls).getBytes();// Nullable
@@ -2135,7 +2139,6 @@ public java.sql.ResultSet getColumns(String catalog, String schemaPattern, Strin
21352139
tuple[16] =r.getBytes(5);// ordinal position
21362140
tuple[17] = (nullFlag.equals("f") ?"YES" :"NO").getBytes();// Is nullable
21372141

2138-
v.addElement(tuple);
21392142
}
21402143
r.close();
21412144

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp