Re: [Sqlrelay-discussion] MySQL 5.0+ and stored procedures
Brought to you by:
mused
|
From: David M. <dav...@fi...> - 2006-06-22 03:38:47
|
Cool, thanks!
I'll roll this into 0.38 as well and it'll be in CVS tonight or
tomorrow.
Dave
On Mon, 2006-06-19 at 12:53 -0700, Devananda wrote:
> I've made a minor change to the mysql connector -- more of a hack really
> -- to allow a result set to be returned by stored procedures. I'm sure
> there is a better way to do it, since this "quick-fix" only handles the
> first result set returned, and procedures can return many result sets.
> However, this covers all my needs (for now)... Hope it helps someone else!
>
> The two changes as follows, to the connections/mysql/mysql.C file:
>
> First, tell MySQL that we can process multi_result sets...
>
> lines 73-85, reordered to set CLIENT_MULTI_RESULT if MYSQL_VERSION_ID > 5000
> > #if MYSQL_VERSION_ID < 32200
> > if (!mysql_real_connect(&mysql,hostval,user,password,
> > portval,socketval,0)) {
> > #else
> > // initialize database connection structure
> > if (!mysql_init(&mysql)) {
> > fprintf(stderr,"mysql_init failed\n");
> > return false;
> > }
> > #if MYSQL_VERSION_ID < 50000
> > if (!mysql_real_connect(&mysql,hostval,user,password,dbval,
> > portval,socketval,0)) {
> > #else
> > if (!mysql_real_connect(&mysql,hostval,user,password,dbval,
> > portval,socketval,CLIENT_MULTI_RESULTS)) {
> > #endif
> > #endif
> Second, make sure we do NOT leave any result sets trailing around.
>
> function def. on line 855, inserted "#if MYSQL_VERSION_ID..." block:
> > void mysqlcursor::cleanUpData(bool freeresult, bool freebinds) {
> > #ifdef HAVE_MYSQL_STMT_PREPARE
> > if (!mysqlconn->fakebinds) {
> > if (freebinds) {
> > bindcounter=0;
> > rawbuffer::zero(&bind,sizeof(bind));
> > mysql_stmt_reset(stmt);
> > }
> > if (freeresult) {
> > mysql_stmt_free_result(stmt);
> > if (mysqlresult) {
> > mysql_free_result(mysqlresult);
> > mysqlresult=NULL;
> > }
> > }
> > } else {
> > #endif
> > if (freeresult && mysqlresult!=(MYSQL_RES *)NULL) {
> > mysql_free_result(mysqlresult);
> > mysqlresult=NULL;
> > }
> > #if MYSQL_VERSION_ID > 50000
> > whlie(!mysql_next_result(&mysqlconn->mysql)) {
> > mysqlresult=mysql_store_result($mysqlconn->mysql);
> > mysql_free_result(mysqlresult);
> > mysqlresult=NULL;
> > }
> > #endif
> > #ifdef HAVE_MYSQL_STMT_PREPARE
> > }
> > #endif
> > delete[] columnnames;
> > columnnames=NULL;
> > }
>
>
> _______________________________________________
> Sqlrelay-discussion mailing list
> Sql...@li...
> https://lists.sourceforge.net/lists/listinfo/sqlrelay-discussion
>
|