Bug #89095 32bit ODBC driver truncates SP parameter names
Submitted: 2 Jan 2018 16:28 Modified: 1 Jun 2018 11:35
Reporter: Gary Brookman Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / ODBC Severity:S2 (Serious)
Version:5.3.9 OS:Windows (tested on 7)
Assigned to: CPU Architecture:Any
Tags: 32bit, ODBC

[2 Jan 2018 16:28] Gary Brookman
Description:
Code below is for getting the parameters for a stored procedure.
This works in the 64 bit ODBC driver, but the 32 bit driver returns InP and Outm as the parameter names, not InParm and OutParm.

// =========================================================================
// Get all stored procedure columns
if (SQL_SUCCEEDED (SQLProcedureColumns (hstmt1, NULL, 0, NULL, 0, (SQLTCHAR*)L"TestParm", SQL_NTS, NULL, 0)))
	{
	SQLTCHAR szParameterName[256];
	SQLSMALLINT nParameterType = 0;
	SQLSMALLINT nParameterDataType = 0;
	SQLLEN  nLen = 0;

	// Bind data for fetch (parameter name, type (input, input/output, output), data type)
	if ((SQL_SUCCEEDED (SQLBindCol (hstmt1, COLUMN_NAME, SQL_C_TCHAR, szParameterName, _countof (szParameterName), &nLen))) &&
	(SQL_SUCCEEDED (SQLBindCol (hstmt1, COLUMN_TYPE, SQL_SMALLINT, &nParameterType, sizeof (nParameterType), &nLen))) &&
	(SQL_SUCCEEDED (SQLBindCol (hstmt1, DATA_TYPE, SQL_SMALLINT, &nParameterDataType, sizeof (nParameterDataType), &nLen))))
	{
		while (true)
			{
			memset (szParameterName, 0, _countof(szParameterName));
			// Fetch data
			if (!SQL_SUCCEEDED (SQLFetch (hstmt1)))
				{
				break;
				}

			std::wcout << "column: " << szParameterName << "\n";
			}
		}
	}

// *** stored procedure 
CREATE DEFINER=`root`@`localhost` PROCEDURE `TestParm`(IN InParm nvarchar (15), 
								OUT OutParm nvarchar (20))
BEGIN
SELECT LName INTO OutParm FROM sys.es 
WHERE FName = InParm; 
END

// *** es table
CREATE TABLE `es` (
  `FName` varchar(15) NOT NULL,
  `LName` varchar(20) NOT NULL,
  `EID` int(11) DEFAULT NULL,
  PRIMARY KEY (`FName`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

How to repeat:
Configure a System DSN for both 32 and 64 bit ODBC data sources.

run the code in a 64bit Windows console app, output is:
column: InParm
column: OutParm

run the code in a 32bit Windows console app, the output is:
column: InP
column: Outm
[12 Jan 2018 9:48] Chiranjeevi Battula
Hello Gary Brookman,

Thank you for the bug report.
I tried with latest version of MySQL Connector / ODBC 5.3.9 as well and it worked without any issues.
Probably this is fixed, please feel free to reopen this bug report if you encounter this issue again.

Thanks,
Chiranjeevi.
[18 Jan 2018 13:52] Gary Brookman
Sorry, didn't realize I wasn't on the latest version, that's what my customer was using. You're correct, that is fixed in the 5.3 Unicode driver but the same behavior persists in the 5.3 ANSI driver.
Using version 5.03.09.00

Maybe this part deserves a separate forum question, but why doesn't SQLGetDiagRec do anything for the MySQL drivers? For MS SQL drivers I get meaningful diagnostic information.
[23 Jan 2018 13:08] Chiranjeevi Battula
http://bugs.mysql.com/bug.php?id=89358 marked as duplicate of this one.
[1 Jun 2018 11:35] Chiranjeevi Battula
Hello Gary Brookman,

Thank you for your feedback.
I could not repeat the issue at our end using Connector / ODBC 8.0.11 64 bit, MySQL 8.0.11  with Windows 10 and it worked without any issues.
If you can provide more information, feel free to add it to this bug and change the status back to 'Open'.

Thank you for your interest in MySQL.

Thanks,
Chiranjeevi.