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

Commit0b88b63

Browse files
author
Barry Lind
committed
Applied patches from Kris Jurka fixing a string tokenizing problem and
fixing an order by problem for index metadata results.Also includes removing some unused code as well as a fix to the toStringmethod on statement. Modified Files: jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
1 parent26b237f commit0b88b63

File tree

2 files changed

+39
-45
lines changed

2 files changed

+39
-45
lines changed

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

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3143,26 +3143,23 @@ else if ("setdefault".equals(rule))
31433143
//<unnamed>\000ww\000vv\000UNSPECIFIED\000m\000a\000n\000b\000
31443144
// we are primarily interested in the column names which are the last items in the string
31453145

3146-
StringTokenizerst =newStringTokenizer(targs,"\\000");
3147-
if (st.hasMoreTokens()) {
3148-
fkName =st.nextToken();
3146+
Vectortokens =tokenize(targs,"\\000");
3147+
if (tokens.size() >0) {
3148+
fkName =(String)tokens.elementAt(0);
31493149
}
31503150

31513151
if (fkName.startsWith("<unnamed>")) {
31523152
fkName =targs;
31533153
}
31543154

3155-
intadvance =4 + (keySequence -1) *2;
3156-
for (inti =1;st.hasMoreTokens() &&i <advance ;i++ )
3157-
st.nextToken();// advance to the key column of interest
3158-
3159-
if (st.hasMoreTokens() )
3160-
{
3161-
fkeyColumn =st.nextToken();
3155+
intelement =4 + (keySequence -1) *2;
3156+
if (tokens.size() >element) {
3157+
fkeyColumn = (String)tokens.elementAt(element);
31623158
}
3163-
if (st.hasMoreTokens() )
3164-
{
3165-
pkeyColumn =st.nextToken();
3159+
3160+
element++;
3161+
if (tokens.size() >element) {
3162+
pkeyColumn = (String)tokens.elementAt(element);
31663163
}
31673164

31683165
tuple[3] =pkeyColumn.getBytes();//PKCOLUMN_NAME
@@ -3568,8 +3565,33 @@ public java.sql.ResultSet getIndexInfo(String catalog, String schema, String tab
35683565
if (unique) {
35693566
sql +=" AND i.indisunique ";
35703567
}
3571-
sql +=" ORDER BY NON_UNIQUE, TYPE, INDEX_NAME ";
3568+
sql +=" ORDER BY NON_UNIQUE, TYPE, INDEX_NAME, ORDINAL_POSITION ";
35723569
returnconnection.createStatement().executeQuery(sql);
35733570
}
35743571

3572+
/**
3573+
* Tokenize based on words not on single characters.
3574+
*/
3575+
privatestaticVectortokenize(Stringinput,Stringdelimiter) {
3576+
Vectorresult =newVector();
3577+
intstart =0;
3578+
intend =input.length();
3579+
intdelimiterSize =delimiter.length();
3580+
3581+
while (start <end) {
3582+
intdelimiterIndex =input.indexOf(delimiter,start);
3583+
if (delimiterIndex <0) {
3584+
result.addElement(input.substring(start));
3585+
break;
3586+
}else {
3587+
Stringtoken =input.substring(start,delimiterIndex);
3588+
result.addElement(token);
3589+
start =delimiterIndex +delimiterSize;
3590+
}
3591+
}
3592+
returnresult;
3593+
}
3594+
3595+
3596+
35753597
}

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

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
importorg.postgresql.largeobject.*;
1414
importorg.postgresql.util.*;
1515

16-
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.19 2003/04/13 04:10:07 barry Exp $
16+
/* $Header: /cvsroot/pgsql/src/interfaces/jdbc/org/postgresql/jdbc1/Attic/AbstractJdbc1Statement.java,v 1.20 2003/04/17 04:37:07 barry Exp $
1717
* This class defines methods of the jdbc1 specification. This class is
1818
* extended by org.postgresql.jdbc2.AbstractJdbc2Statement which adds the jdbc2
1919
* methods. The real Statement class (for jdbc1) is org.postgresql.jdbc1.Jdbc1Statement
@@ -1512,35 +1512,7 @@ public void setObject(int parameterIndex, Object x) throws SQLException
15121512
{
15131513
if (x ==null)
15141514
{
1515-
intl_sqlType;
1516-
if (xinstanceofString)
1517-
l_sqlType =Types.VARCHAR;
1518-
elseif (xinstanceofBigDecimal)
1519-
l_sqlType =Types.DECIMAL;
1520-
elseif (xinstanceofShort)
1521-
l_sqlType =Types.SMALLINT;
1522-
elseif (xinstanceofInteger)
1523-
l_sqlType =Types.INTEGER;
1524-
elseif (xinstanceofLong)
1525-
l_sqlType =Types.BIGINT;
1526-
elseif (xinstanceofFloat)
1527-
l_sqlType =Types.FLOAT;
1528-
elseif (xinstanceofDouble)
1529-
l_sqlType =Types.DOUBLE;
1530-
elseif (xinstanceofbyte[])
1531-
l_sqlType =Types.BINARY;
1532-
elseif (xinstanceofjava.sql.Date)
1533-
l_sqlType =Types.DATE;
1534-
elseif (xinstanceofTime)
1535-
l_sqlType =Types.TIME;
1536-
elseif (xinstanceofTimestamp)
1537-
l_sqlType =Types.TIMESTAMP;
1538-
elseif (xinstanceofBoolean)
1539-
l_sqlType =Types.OTHER;
1540-
else
1541-
l_sqlType =Types.OTHER;
1542-
1543-
setNull(parameterIndex,l_sqlType);
1515+
setNull(parameterIndex,Types.OTHER);
15441516
return ;
15451517
}
15461518
if (xinstanceofString)
@@ -1879,7 +1851,7 @@ public int getResultSetConcurrency() throws SQLException
18791851
publicStringtoString()
18801852
{
18811853
if (m_sqlFragments ==null)
1882-
return"";
1854+
returnsuper.toString();
18831855

18841856
synchronized (sbuf)
18851857
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp