trafodion-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lium...@apache.org
Subject [4/5] incubator-trafodion git commit: [TRAFODION-2385] windows SQLTYPECODE_BOOLEAN using
Date Thu, 22 Jun 2017 12:25:57 GMT
[TRAFODION-2385] windows SQLTYPECODE_BOOLEAN using


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

Branch: refs/heads/master
Commit: 3bb2941bea13e64dfed9d9b5507a4a8cb4a730b5
Parents: 2b98720
Author: Weixin-Xu <weixin.xu@esgyn.cn>
Authored: Tue Jun 13 10:34:58 2017 +0800
Committer: Weixin-Xu <weixin.xu@esgyn.cn>
Committed: Tue Jun 13 10:34:58 2017 +0800

----------------------------------------------------------------------
 win-odbc64/odbcclient/drvr35/ctosqlconv.cpp | 125 ++++++++++++++++-------
 win-odbc64/odbcclient/drvr35/sqltocconv.cpp |  68 ++++++------
 win-odbc64/sql/cli/sqlcli.h                 |   2 -
 3 files changed, 123 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3bb2941b/win-odbc64/odbcclient/drvr35/ctosqlconv.cpp
----------------------------------------------------------------------
diff --git a/win-odbc64/odbcclient/drvr35/ctosqlconv.cpp b/win-odbc64/odbcclient/drvr35/ctosqlconv.cpp
index 5b0037a..fe1c58e 100644
--- a/win-odbc64/odbcclient/drvr35/ctosqlconv.cpp
+++ b/win-odbc64/odbcclient/drvr35/ctosqlconv.cpp
@@ -248,12 +248,6 @@ unsigned long ODBC::ConvertCToSQL(SQLINTEGER	ODBCAppVersion,
 		targetUnsigned = true;
 	}
 
-	if (SQLDataType == SQLTYPECODE_BOOLEAN)
-	{
-		ODBCDataType = SQL_BOOLEAN;
-	}
-
-
 	if (CDataType == SQL_C_DEFAULT)
 	{
 		getCDefault(tODBCDataType, ODBCAppVersion, CDataType);
@@ -299,6 +293,92 @@ unsigned long ODBC::ConvertCToSQL(SQLINTEGER	ODBCAppVersion,
 			Offset = sizeof(USHORT);
 		}
 	case SQL_CHAR:
+		if (SQLDataType == SQLTYPECODE_BOOLEAN)
+		{
+			switch (CDataType)
+			{
+			case SQL_C_WCHAR:
+				if (srcLength != SQL_NTS)
+					srcLength = srcLength / 2;
+				if (WCharToUTF8((wchar_t*)srcDataPtr, srcLength, srcDataLocale, sizeof(srcDataLocale),
(int*)&translateLength, (char*)errorMsg) != SQL_SUCCESS)
+					return IDS_193_DRVTODS_ERROR;
+				srcDataPtr = srcDataLocale;
+				srcLength = translateLength;
+			case SQL_C_CHAR:
+			{
+				retCode = ConvertCharToNumeric(srcDataPtr, srcLength, dTmp);
+				if (retCode != SQL_SUCCESS)
+					return retCode;
+			}
+			break;
+			case SQL_C_SHORT:
+			case SQL_C_SSHORT:
+				dTmp = *(SSHORT *)srcDataPtr;
+				break;
+			case SQL_C_USHORT:
+				dTmp = *(USHORT *)srcDataPtr;
+				break;
+			case SQL_C_TINYINT:
+			case SQL_C_STINYINT:
+				dTmp = *(SCHAR *)srcDataPtr;
+				break;
+			case SQL_C_UTINYINT:
+			case SQL_C_BIT:
+				dTmp = *(UCHAR *)srcDataPtr;
+				break;
+			case SQL_C_SLONG:
+			case SQL_C_LONG:
+				dTmp = *(SLONG *)srcDataPtr;
+				break;
+			case SQL_C_ULONG:
+				dTmp = *(ULONG *)srcDataPtr;
+				break;
+			case SQL_C_FLOAT:
+				dTmp = *(SFLOAT *)srcDataPtr;
+				break;
+			case SQL_C_DOUBLE:
+				dTmp = *(DOUBLE *)srcDataPtr;
+				break;
+			case SQL_C_BINARY:
+				DataPtr = srcDataPtr;
+				break;
+			case SQL_C_DEFAULT:
+				if (ODBCAppVersion >= SQL_OV_ODBC3)
+					DataPtr = srcDataPtr;
+				else
+				{
+					retCode = ConvertCharToNumeric(srcDataPtr, srcLength, dTmp);
+					if (retCode != SQL_SUCCESS)
+						return retCode;
+				}
+				break;
+			case SQL_C_SBIGINT:
+				dTmp = *(__int64 *)srcDataPtr;
+				break;
+			case SQL_C_NUMERIC:
+				ConvertCNumericToChar((SQL_NUMERIC_STRUCT*)srcDataPtr, cTmpBuf);
+				srcLength = strlen(cTmpBuf);
+				retCode = ConvertCharToNumeric((char*)cTmpBuf, srcLength, dTmp);
+				if (retCode != SQL_SUCCESS)
+					return retCode;
+				break;
+			default:
+				return IDS_07_006;
+			}
+			if (DataPtr == NULL)
+			{
+				if (dTmp < 0)
+					return IDS_22_003_02;  //negValue in unsigned column
+				if (dTmp > 1)
+					return IDS_22_003;
+				tTmp = (SCHAR)dTmp;
+				if (dTmp != tTmp)
+					retCode = IDS_01_S07;
+				DataPtr = &tTmp;
+				DataLen = sizeof(SCHAR);
+			}
+			break;
+		}
 	case SQL_WCHAR:
 		switch (CDataType)
 		{
@@ -597,7 +677,6 @@ unsigned long ODBC::ConvertCToSQL(SQLINTEGER	ODBCAppVersion,
 			DataLen = sizeof(fltTmp);
 			break;
 		}
-	case SQL_BOOLEAN:
 	case SQL_TINYINT:
 	case SQL_SMALLINT:
 	case SQL_INTEGER:
@@ -824,17 +903,6 @@ unsigned long ODBC::ConvertCToSQL(SQLINTEGER	ODBCAppVersion,
 
 				switch (ODBCDataType)
 				{
-				case SQL_BOOLEAN:
-					if (dTmp < 0)
-						return IDS_22_003_02;  //negValue in unsigned column
-					if (dTmp > 1)
-						return IDS_22_003;
-					tTmp = (SCHAR)dTmp;
-					if (dTmp != tTmp)
-						retCode = IDS_01_S07;
-					DataPtr = &tTmp;
-					DataLen = sizeof(SCHAR);
-					break;
 				case SQL_TINYINT:
 					if (targetUnsigned)
 					{
@@ -1026,15 +1094,6 @@ unsigned long ODBC::ConvertCToSQL(SQLINTEGER	ODBCAppVersion,
 
 				switch( SQLDataType )
 				{
-				case SQLTYPECODE_BOOLEAN:
-					if (tempVal64 < 0 || tempVal64 > 1)
-						return IDS_22_003_02;
-					tTmp = (SCHAR)tempVal64;
-					if (tempVal64 != tTmp)
-						retCode = IDS_01_S07;
-					DataPtr = &tTmp;
-					DataLen = sizeof(SCHAR);
-					break;
 				case SQLTYPECODE_TINYINT_UNSIGNED:
 					if (tempVal64 < 0)
 						return IDS_22_003_02;
@@ -1142,9 +1201,6 @@ unsigned long ODBC::ConvertCToSQL(SQLINTEGER	ODBCAppVersion,
 		{
 			switch (ODBCDataType)
 			{
-			case SQL_BOOLEAN:
-				DataLen = sizeof(SCHAR);
-				break;
 			case SQL_TINYINT:
 				DataLen = sizeof(SCHAR);
 				break;
@@ -1596,11 +1652,6 @@ unsigned long ODBC::ConvertCToSQL(SQLINTEGER	ODBCAppVersion,
 				dTmp *= scaleOffset;
 				switch (SQLDataType)
 				{
-				case SQLTYPECODE_BOOLEAN:
-					tTmp = (SCHAR)dTmp;
-					DataPtr = &tTmp;
-					DataLen = sizeof(SCHAR);
-					break;
 				case SQLTYPECODE_TINYINT_UNSIGNED:
 					utTmp = (UCHAR)dTmp;
 					DataPtr = &utTmp;
@@ -3098,7 +3149,7 @@ unsigned long ODBC::ConvertCToSQL(SQLINTEGER	ODBCAppVersion,
 
 		if (DataPtr != NULL && DataLen > 0 && 
 			(ODBCDataType == SQL_CHAR || ODBCDataType == SQL_VARCHAR || ODBCDataType == SQL_LONGVARCHAR
|| 
-			ODBCDataType == SQL_WCHAR || ODBCDataType == SQL_WVARCHAR) && CDataType != SQL_C_BINARY)
+			ODBCDataType == SQL_WCHAR || ODBCDataType == SQL_WVARCHAR) && CDataType != SQL_C_BINARY
&& SQLDataType != SQLTYPECODE_BOOLEAN)
 		{
 			SQLRETURN rc = SQL_SUCCESS;
 			if (targetCharSet == SQLCHARSETCODE_UCS2)
@@ -3188,7 +3239,7 @@ unsigned long ODBC::ConvertCToSQL(SQLINTEGER	ODBCAppVersion,
 
 			}
 
-			if (ODBCDataType == SQL_CHAR)
+			if (ODBCDataType == SQL_CHAR && SQLDataType != SQLTYPECODE_BOOLEAN)
 				memset((unsigned char *)outDataPtr+DataLen, ' ', targetLength-DataLen-Offset-1);
 			else if (ODBCDataType == SQL_WCHAR)
 			{

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3bb2941b/win-odbc64/odbcclient/drvr35/sqltocconv.cpp
----------------------------------------------------------------------
diff --git a/win-odbc64/odbcclient/drvr35/sqltocconv.cpp b/win-odbc64/odbcclient/drvr35/sqltocconv.cpp
index 486cc63..37922c0 100644
--- a/win-odbc64/odbcclient/drvr35/sqltocconv.cpp
+++ b/win-odbc64/odbcclient/drvr35/sqltocconv.cpp
@@ -310,12 +310,6 @@ unsigned long ODBC::ConvertSQLToC(SQLINTEGER	ODBCAppVersion,
 		srcUnsigned = true;
 	}
 
-	if (SQLDataType == SQLTYPECODE_BOOLEAN)
-	{
-		ODBCDataType = SQL_BOOLEAN;
-	}
-
-
 	if (CDataType == SQL_C_DEFAULT)
 	{
 		getCDefault(tODBCDataType, ODBCAppVersion, CDataType);
@@ -369,6 +363,16 @@ unsigned long ODBC::ConvertSQLToC(SQLINTEGER	ODBCAppVersion,
 		switch (ODBCDataType)
 		{
 		case SQL_CHAR:
+			if (SQLDataType == SQLTYPECODE_BOOLEAN)
+			{
+				tTmp = *((SCHAR *)srcDataPtr);
+				_ltoa(tTmp, cTmpBuf, 10);
+				DataLen = strlen(cTmpBuf);
+				if (DataLen > targetLength)
+					return IDS_22_003;
+				DataPtr = cTmpBuf;
+				break;
+			}
 		case SQL_WCHAR:
 			charlength = srcLength-1;
 			if (charlength == 0)
@@ -487,14 +491,6 @@ unsigned long ODBC::ConvertSQLToC(SQLINTEGER	ODBCAppVersion,
 //			if (totalReturnedLength != NULL)
 //				*totalReturnedLength = DataLen + Offset;
 			break;
-		case SQL_BOOLEAN:
-			tTmp = *((SCHAR *) srcDataPtr);
-			_ltoa(tTmp, cTmpBuf, 10);
-			DataLen = strlen(cTmpBuf);
-			if (DataLen > targetLength)
-				return IDS_22_003;
-			DataPtr = cTmpBuf;
-			break;
 		case SQL_TINYINT:
 			if (srcUnsigned)
 			{
@@ -543,7 +539,7 @@ unsigned long ODBC::ConvertSQLToC(SQLINTEGER	ODBCAppVersion,
 			break;
 		case SQL_BIGINT:
 			if (srcUnsigned)
-				_snprintf(cTmpBuf, sizeof(__int64), "%I64u", *((__int64 *)srcDataPtr));
+				_snprintf(cTmpBuf, sizeof(__int64), "%I64u", *((unsigned __int64 *)srcDataPtr));
 			else
 				_snprintf(cTmpBuf, sizeof(__int64), "%I64d", *((__int64 *)srcDataPtr));
 			DataLen = strlen(cTmpBuf);
@@ -719,6 +715,16 @@ unsigned long ODBC::ConvertSQLToC(SQLINTEGER	ODBCAppVersion,
 		switch (ODBCDataType)
 		{
 		 case SQL_CHAR:
+			 if (SQLDataType == SQLTYPECODE_BOOLEAN)
+			 {
+				 tTmp = *((SCHAR *)srcDataPtr);
+				 _ltoa(tTmp, cTmpBuf, 10);
+				 DataLen = strlen(cTmpBuf);
+				 if (DataLen > targetLength)
+					 return IDS_22_003;
+				 DataPtr = cTmpBuf;
+				 break;
+			 }
 		 case SQL_WCHAR:
 			charlength = srcLength-1;
 			if (charlength == 0)
@@ -840,14 +846,6 @@ unsigned long ODBC::ConvertSQLToC(SQLINTEGER	ODBCAppVersion,
 //			if (totalReturnedLength != NULL)
 //				*totalReturnedLength = DataLen + Offset;
 			break;
-		case SQL_BOOLEAN:
-			tTmp = *((SCHAR *) srcDataPtr);
-			_ltoa(tTmp, cTmpBuf, 10);
-			DataLen = strlen(cTmpBuf);
-			if (DataLen > targetLength)
-				return IDS_22_003;
-			DataPtr = cTmpBuf;
-			break;
 		case SQL_TINYINT:
 			if (srcUnsigned)
 			{
@@ -1081,6 +1079,11 @@ unsigned long ODBC::ConvertSQLToC(SQLINTEGER	ODBCAppVersion,
 		switch (ODBCDataType)
 		{
 		case SQL_CHAR:
+			if (SQLDataType == SQLTYPECODE_BOOLEAN)
+			{
+				dTmp = *((SCHAR *)srcDataPtr);
+				break;
+			}
 		case SQL_VARCHAR:
 		case SQL_LONGVARCHAR:
 		case SQL_WCHAR:
@@ -1208,9 +1211,6 @@ unsigned long ODBC::ConvertSQLToC(SQLINTEGER	ODBCAppVersion,
 			if ((retCode = ConvertSQLCharToNumeric(srcDataPtr, srcLength, ODBCDataType, dTmp)) !=
SQL_SUCCESS)
 				return retCode;
 			break;
-		case SQL_BOOLEAN:
-			dTmp = *((SCHAR *) srcDataPtr);
-			break;
 		case SQL_TINYINT:
 			if (srcUnsigned)
 			{
@@ -1457,7 +1457,8 @@ unsigned long ODBC::ConvertSQLToC(SQLINTEGER	ODBCAppVersion,
 				ODBCDataType != SQL_LONGVARCHAR && 
 				ODBCDataType != SQL_WCHAR &&
 				ODBCDataType != SQL_WVARCHAR &&
-				ODBCDataType != SQL_WLONGVARCHAR)
+				ODBCDataType != SQL_WLONGVARCHAR ||
+				SQLDataType == SQLTYPECODE_BOOLEAN)
 				tempVal64 = dTmp;
 			DataPtr = &tempVal64;
 			DataLen = sizeof(tempVal64);
@@ -2401,7 +2402,6 @@ unsigned long ODBC::ConvertSQLToC(SQLINTEGER	ODBCAppVersion,
 //			if (totalReturnedLength != NULL)
 //				*totalReturnedLength = DataLen + Offset;
 			break;
-		case SQL_BOOLEAN:
 		case SQL_TINYINT:
 		case SQL_SMALLINT:
 		case SQL_INTEGER:
@@ -2431,6 +2431,13 @@ unsigned long ODBC::ConvertSQLToC(SQLINTEGER	ODBCAppVersion,
 		switch (ODBCDataType)
 		{
 		case SQL_CHAR:
+			if (SQLDataType == SQLTYPECODE_BOOLEAN)
+			{
+				tTmp = *((SCHAR *)srcDataPtr);
+				DataPtr = &tTmp;
+				DataLen = sizeof(SCHAR);
+				break;
+			}
 		case SQL_WCHAR:
 			charlength = srcLength-1;
 			if (charlength == 0)
@@ -2520,11 +2527,6 @@ unsigned long ODBC::ConvertSQLToC(SQLINTEGER	ODBCAppVersion,
 			DataPtr = &intervalTmp;
 			DataLen = sizeof(SQL_INTERVAL_STRUCT);
 			break;
-		case SQL_BOOLEAN:
-			tTmp = *((SCHAR *) srcDataPtr);
-			DataPtr = &tTmp;
-			DataLen = sizeof(SCHAR);
-			break;
 		case SQL_TINYINT:
 			if (srcUnsigned)
 			{

http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/3bb2941b/win-odbc64/sql/cli/sqlcli.h
----------------------------------------------------------------------
diff --git a/win-odbc64/sql/cli/sqlcli.h b/win-odbc64/sql/cli/sqlcli.h
index 982f609..fc964fb 100644
--- a/win-odbc64/sql/cli/sqlcli.h
+++ b/win-odbc64/sql/cli/sqlcli.h
@@ -433,8 +433,6 @@ enum SQLTYPE_CODE {
     SQLTYPECODE_BITVAR   = 15   /* not supported */
 };
 
-#define SQL_BOOLEAN			13
-
 /* #ifndef SQLDTCODE_DATE */
 /* specifies the type of datetime data type */
 enum SQLDATETIME_CODE {


Mime
View raw message