Bug #4211 Unhandled exception in main.exe (LIBMYSQL.DLL): 0xC0000005: Access Violation
Submitted: 18 Jun 2004 20:48 Modified: 20 Jul 2004 11:03
Reporter: [ name withheld ] Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL++ Severity:S1 (Critical)
Version:1.7.9 OS:Windows (WinXp)
Assigned to: CPU Architecture:Any

[18 Jun 2004 20:48] [ name withheld ]
Description:
When you compile a program and enter a query that cannot be matched in the database, the result is that... or a message saying that main.exe needs to close.

I have included a cut back version of the source code which still has the same problem.

#include <sqlplus.hh>
#include <iostream>

using namespace std;

#define user "user"
#define pass "pass"
#define host "192.0.0.1"
#define dbname "sample_db"

main() {
	MYSQL *conn;
	conn = mysql_init(NULL);
	mysql_real_connect(conn,host,user,pass,dbname,0,NULL,0);
	MYSQL_RES *res_set;
	MYSQL_ROW row;
	unsigned int i;
	char query[128]="";
	cin >> query;
	mysql_query(conn, query);
	
	res_set = mysql_store_result(conn);
	unsigned int numrows = mysql_num_rows(res_set);
	while ((row=mysql_fetch_row(res_set)) != NULL)
	{
		for (i=0; i<mysql_num_fields(res_set); i++) 
		{
			printf("%s\n",row[i] != NULL ? row[i] : "NULL"); 
		} 
	} 

	mysql_close(conn); 
	return 0; 
	} 		

	

How to repeat:
Compile program (console) above and try enter a query that doesnt exist...

Suggested fix:
Error handling.
[20 Jun 2004 6:47] MySQL Verification Team
I assume here that the category should be MySQL Client Library
(the C API) according the Synopsis: ..(LIBMYSQL.DLL): 0xC0000005.

What compiler are you using ?.
[14 Feb 2005 22:54] 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".