[libpostgresql-jdbc-java] 19/22: 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 toString method on statement.

Emmanuel Bourg ebourg-guest at moszumanska.debian.org
Mon Jan 9 10:19:04 UTC 2017


This is an automated email from the git hooks/post-receive script.

ebourg-guest pushed a commit to tag REL7_3_4
in repository libpostgresql-jdbc-java.

commit 6186c9a3e355fa708a07bf3d2b5307479d47d7a3
Author: Barry Lind <barry at xythos.com>
Date:   Thu Apr 17 04:19:55 2003 +0000

    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 toString
    method on statement.
    
     Modified Files:
      Tag: REL7_3_STABLE
     	jdbc/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
     	jdbc/org/postgresql/jdbc1/AbstractJdbc1Statement.java
---
 .../jdbc1/AbstractJdbc1DatabaseMetaData.java       | 52 +++++++++++++++-------
 org/postgresql/jdbc1/AbstractJdbc1Statement.java   | 34 +++-----------
 2 files changed, 42 insertions(+), 44 deletions(-)

diff --git a/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java b/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
index 305b88e..03ce99a 100644
--- a/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
+++ b/org/postgresql/jdbc1/AbstractJdbc1DatabaseMetaData.java
@@ -3136,20 +3136,17 @@ public abstract class AbstractJdbc1DatabaseMetaData
 			//<unnamed>\000ww\000vv\000UNSPECIFIED\000m\000a\000n\000b\000
 			// we are primarily interested in the column names which are the last items in the string
 
-			StringTokenizer st = new StringTokenizer(targs, "\\000");
-
-			int advance = 4 + (keySequence - 1) * 2;
-			for ( int i = 0; st.hasMoreTokens() && i < advance ; i++ )
-				st.nextToken(); // advance to the key column of interest
-
-			if ( st.hasMoreTokens() )
-			{
-				fkeyColumn = st.nextToken();
-			}
-			if ( st.hasMoreTokens() )
-			{
-				pkeyColumn = st.nextToken();
-			}
+ 			Vector tokens = tokenize(targs, "\\000");
+
+ 			int element = 4 + (keySequence - 1) * 2;
+ 			if (tokens.size() > element) {
+ 				fkeyColumn = (String)tokens.elementAt(element);
+  			}
+ 
+ 			element++;
+ 			if (tokens.size() > element) {
+ 				pkeyColumn = (String)tokens.elementAt(element);
+  			}
 
 			tuple[3] = pkeyColumn.getBytes(); //PKCOLUMN_NAME
 			tuple[7] = fkeyColumn.getBytes(); //FKCOLUMN_NAME
@@ -3553,8 +3550,33 @@ public abstract class AbstractJdbc1DatabaseMetaData
 		if (unique) {
 			sql += " AND i.indisunique ";
 		}
-		sql += " ORDER BY NON_UNIQUE, TYPE, INDEX_NAME ";
+		sql += " ORDER BY NON_UNIQUE, TYPE, INDEX_NAME, ORDINAL_POSITION ";
 		return connection.createStatement().executeQuery(sql);
 	}
 
+	/**
+	 * Tokenize based on words not on single characters.
+	 */
+	private static Vector tokenize(String input, String delimiter) {
+		Vector result = new Vector();
+		int start = 0;
+		int end = input.length();
+		int delimiterSize = delimiter.length();
+
+		while (start < end) {
+			int delimiterIndex = input.indexOf(delimiter,start);
+			if (delimiterIndex < 0) {
+				result.addElement(input.substring(start));
+				break;
+			} else {
+				String token = input.substring(start,delimiterIndex);
+				result.addElement(token);
+				start = delimiterIndex + delimiterSize;
+			}
+		}
+		return result;
+	}
+
+		
+
 }
diff --git a/org/postgresql/jdbc1/AbstractJdbc1Statement.java b/org/postgresql/jdbc1/AbstractJdbc1Statement.java
index 151d5d4..5f076d0 100644
--- a/org/postgresql/jdbc1/AbstractJdbc1Statement.java
+++ b/org/postgresql/jdbc1/AbstractJdbc1Statement.java
@@ -1408,35 +1408,7 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
 	{
 		if (x == null)
 		{
-			int l_sqlType;
-			if (x instanceof String)
-				l_sqlType = Types.VARCHAR;
-			else if (x instanceof BigDecimal)
-				l_sqlType = Types.DECIMAL;
-			else if (x instanceof Short)
-				l_sqlType = Types.SMALLINT;
-			else if (x instanceof Integer)
-				l_sqlType = Types.INTEGER;
-			else if (x instanceof Long)
-				l_sqlType = Types.BIGINT;
-			else if (x instanceof Float)
-				l_sqlType = Types.FLOAT;
-			else if (x instanceof Double)
-				l_sqlType = Types.DOUBLE;
-			else if (x instanceof byte[])
-				l_sqlType = Types.BINARY;
-			else if (x instanceof java.sql.Date)
-				l_sqlType = Types.DATE;
-			else if (x instanceof Time)
-				l_sqlType = Types.TIME;
-			else if (x instanceof Timestamp)
-				l_sqlType = Types.TIMESTAMP;
-			else if (x instanceof Boolean)
-				l_sqlType = Types.OTHER;
-			else 
-				l_sqlType = Types.OTHER;
-
-			setNull(parameterIndex, l_sqlType);
+			setNull(parameterIndex, Types.OTHER);
 			return ;
 		}
 		if (x instanceof String)
@@ -1768,6 +1740,10 @@ public abstract class AbstractJdbc1Statement implements org.postgresql.PGStateme
 	 */
 	public String toString()
 	{
+		//if no sql yet set, return default toString()
+		if (m_sqlFragments == null)
+			return super.toString();
+
 		synchronized (sbuf)
 		{
 			sbuf.setLength(0);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-java/libpostgresql-jdbc-java.git



More information about the pkg-java-commits mailing list