Bug 47931 - It is not possible to use CALL MySQL method with apr_dbd_mysql
Summary: It is not possible to use CALL MySQL method with apr_dbd_mysql
Status: NEW
Alias: None
Product: APR
Classification: Unclassified
Component: APR-util (show other bugs)
Version: HEAD
Hardware: PC Linux
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Apache Portable Runtime bugs mailinglist
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-10-01 23:46 UTC by Marko Kevac
Modified: 2011-08-03 16:47 UTC (History)
0 users



Attachments
allow few additional flags to be passed to mysql_real_connect (961 bytes, patch)
2009-10-01 23:46 UTC, Marko Kevac
Details | Diff
allow few additional flags to be passed to mysql_real_connect (951 bytes, patch)
2009-10-09 23:36 UTC, Marko Kevac
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marko Kevac 2009-10-01 23:46:31 UTC
Created attachment 24334 [details]
allow few additional flags to be passed to mysql_real_connect

It is not possible to use CALL MySQL method with apr_dbd_mysql, because
libmysqlclient requires CLIENT_MULTI_STATEMENTS and 
CLIENT_MULTI_RESULTS to be passed, but apr_dbd_mysql accepts only 
CLIENT_FOUND_ROWS flag.

This patch slightly changes apr_dbd_mysql in order to accept these two
additional flags.
Comment 1 Marko Kevac 2009-10-09 23:36:47 UTC
Created attachment 24372 [details]
allow few additional flags to be passed to mysql_real_connect

Flags are not exclusive, so we must use if's, not else if's
Comment 2 Firat Sarlar 2011-08-03 16:47:29 UTC
(In reply to comment #0)
> Created attachment 24334 [details]
> allow few additional flags to be passed to mysql_real_connect
> 
> It is not possible to use CALL MySQL method with apr_dbd_mysql, because
> libmysqlclient requires CLIENT_MULTI_STATEMENTS and 
> CLIENT_MULTI_RESULTS to be passed, but apr_dbd_mysql accepts only 
> CLIENT_FOUND_ROWS flag.
> 
> This patch slightly changes apr_dbd_mysql in order to accept these two
> additional flags.

This patch may solve use problem, but then another problem appearing,
"Commands out of synch" as declared in mysql ref. as common error 
http://dev.mysql.com/doc/refman/5.1/en/commands-out-of-sync.html

There is a solution.
http://dev.mysql.com/doc/refman/5.1/en/c-api-multiple-queries.html

But applying the solution described above to current design of apr_mysql_dbd_driver does not seem easy to me. 

Also I've tested and succeed to use underlaying MYSQL connection like

MYSQL *mysql = ((apr_dbd_t*)db->handle)->conn;
status = mysql_query(mysql,"CALL xgetposts;");
do {
/* did current statement return data? */
	//MYSQL_RES *result = mysql_store_result(mysql);
	MYSQL_RES *result = mysql_use_result(mysql);
if (result)
{
	MYSQL_ROW row;
	while ((row = mysql_fetch_row(result)))
	{


		ap_rprintf(r, "<h2> %s</h2>%s\n%s</br><hr>\n", row[2], row[1], ap_escape_html(r->pool, row[3]));
	//	ap_rprintf(r, "<h2>%s</h2>%s\n%s</br><hr>\n", row[2], row[1], (r->pool, row[3]));
	}
	mysql_free_result(result);
}

/* more results? -1 = no, >0 = error, 0 = yes (keep looping) */
if ((status = mysql_next_result(mysql)) > 0)
printf("Could not execute statement\n");
} while (status == 0);