trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbirds...@apache.org
Subject [2/3] incubator-trafodion git commit: change insert short to byte when boolean
Date Tue, 30 May 2017 16:35:28 GMT
change insert short to byte when boolean


Project: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/commit/fee5a941
Tree: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/tree/fee5a941
Diff: http://git-wip-us.apache.org/repos/asf/incubator-trafodion/diff/fee5a941

Branch: refs/heads/master
Commit: fee5a941bb486a3b500666e9de040fb5a3b541e6
Parents: e32f6b9
Author: mashengchen <mashengchen@gmail.com>
Authored: Thu May 25 06:30:52 2017 +0000
Committer: mashengchen <mashengchen@gmail.com>
Committed: Thu May 25 06:30:52 2017 +0000

----------------------------------------------------------------------
 .../src/main/java/org/trafodion/jdbc/t4/Bytes.java |  5 +++++
 .../org/trafodion/jdbc/t4/InterfaceStatement.java  |  2 +-
 .../trafodion/jdbc/t4/TrafT4PreparedStatement.java | 17 ++++++++++++++---
 .../org/trafodion/jdbc/t4/TrafT4ResultSet.java     |  3 +++
 4 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fee5a941/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Bytes.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Bytes.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Bytes.java
index 625bdff..a289bb3 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Bytes.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/Bytes.java
@@ -122,6 +122,11 @@ class Bytes {
 		return value;
 	}
 
+	static int insertByte(byte[] array, int offset, byte value) {
+		array[offset] = value;
+		return offset + 1;
+	}
+
 	static int insertShort(byte[] array, int offset, short value, boolean swap) {
 		if (swap) {
 			array[offset + 1] = (byte) ((value >>> 8) & 0xff);

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fee5a941/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceStatement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceStatement.java
b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceStatement.java
index 120f084..6ee93bf 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceStatement.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/InterfaceStatement.java
@@ -686,7 +686,7 @@ class InterfaceStatement {
 		case InterfaceResultSet.SQLTYPECODE_BOOLEAN:
 			tmpbd = Utility.getBigDecimalValue(locale, paramValue);
 
-			Bytes.insertShort(values, noNullValue, tmpbd.shortValue(), this.ic_.getByteSwap());
+			Bytes.insertByte(values, noNullValue, tmpbd.byteValue());
 			break;
 		// You will not get this type, since server internally converts it
 		// SMALLINT, INTERGER or LARGEINT

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fee5a941/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
index 04fa6aa..66323dc 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4PreparedStatement.java
@@ -720,11 +720,22 @@ public class TrafT4PreparedStatement extends TrafT4Statement implements
java.sql
 		}
 		validateSetInvocation(parameterIndex);
 		inputDesc_[parameterIndex - 1].checkValidNumericConversion(connection_.getLocale());
-		if (x) {
-			addParamValue(parameterIndex, "1"); // true
+		int sqltype = inputDesc_[parameterIndex - 1].sqlDataType_;
+		Object valueObj = null;
+		if (sqltype == InterfaceResultSet.SQLTYPECODE_BOOLEAN) {
+			if (x) {
+				valueObj = 1;
+			} else {
+				valueObj = 0;
+			}
 		} else {
-			addParamValue(parameterIndex, "0"); // false
+			if (x) {
+				valueObj = "1";
+			} else {
+				valueObj = "0";
+			}
 		}
+		addParamValue(parameterIndex, valueObj);
 	}
 
 	public void setByte(int parameterIndex, byte x) throws SQLException {

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/fee5a941/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
----------------------------------------------------------------------
diff --git a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
index a3d1826..e5864c9 100644
--- a/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
+++ b/core/conn/jdbcT4/src/main/java/org/trafodion/jdbc/t4/TrafT4ResultSet.java
@@ -1832,6 +1832,9 @@ public class TrafT4ResultSet extends TrafT4Handle implements java.sql.ResultSet
 
 
 		case Types.CHAR:
+			if (sqltype == InterfaceResultSet.SQLTYPECODE_BOOLEAN) {
+				return String.valueOf(getBoolean(columnIndex));
+			}
 		case Types.VARCHAR:
 		case Types.LONGVARCHAR:
 		case Types.BLOB:


Mime
View raw message