Bug #87433 Parse Query MySql Result With Method getString() Cause Process Broken
Submitted: 16 Aug 2017 9:44 Modified: 25 Jun 2018 9:44
Reporter: alen smith alen Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / C++ Severity:S2 (Serious)
Version:mysql-community-5.7.19.0 OS:Windows
Assigned to: Assigned Account CPU Architecture:Any
Tags: getstring, Process Broken

[16 Aug 2017 9:44] alen smith alen
Description:
When i query all table datas then use resultset to parse the result which cause process broken,the source code is below(the broken function point is res->getString("label") ):

#include "stdafx.h"
#include<iostream>
#include<mysql_connection.h>
#include <cppconn/statement.h>
#include<mysql_driver.h>
#include<cppconn/exception.h>

int _tmain(int argc, _TCHAR* argv[])
{
	sql::mysql::MySQL_Driver *driver = 0;
	sql::Connection *con = 0;
	sql::Statement *stmt = 0;
	sql::ResultSet  *res = 0;
	sql::ResultSetMetaData *resmeta = 0;

	driver = sql::mysql::get_mysql_driver_instance();
	con = driver->connect("tcp://127.0.0.1:3306", "root", "123456");

	stmt = con->createStatement();
	stmt->execute("CREATE DATABASE IF NOT EXISTS EXAMPLE_DB");
	stmt->execute("USE EXAMPLE_DB");
	stmt->execute("DROP TABLE IF EXISTS test");
	stmt->execute("CREATE TABLE test(id INT, label VARCHAR(10),func VARCHAR(5))");
	stmt->execute("INSERT INTO test(id, label,func) VALUES (1, 'aaaaa','bbbb')");
	//query the mysql
	res = stmt->executeQuery("SELECT * from test");

	while (res->next()) {

		if (res->isNull("label")){
			std::cout << "label is null" << std::endl;
			continue;

		}
		try
		{
			std::cout << "label = " << res->getString("label") << std::endl;
		}
		catch (sql::SQLException test)
		{
			std::cout << "exception :" << test.what() << std::endl;
		}
		catch (...)
		{
			std::cout << "unrecognise exception" << std::endl;
		}
	}

	delete stmt;
	delete con;
	delete res;

	return 0;
}

How to repeat:
you can recompile the program in windows and excute it,this is encountered every time when i executed
[25 May 2018 9:43] Luis Silva
Hi Alen,

You probably are mixing Release/Debug runtime binaries, so the issue.

Connector package is built as Release, so using VS release runtime, so your code has to be built the same way.

If you want to debug your program, you can have Release with debug information build option.

Luís
[26 Jun 2018 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".