Skip to content

Commit

Permalink
db_mysql: Fix regression in PS handling
Browse files Browse the repository at this point in the history
Commit 87f2416 introduced a regression in db_mysql where modules using
prepared statements on top of it would run into errors.

Example behavior of auth_db on a basic user auth query:

    ERROR:db_mysql:db_mysql_store_result: driver error:
        Commands out of sync; you can't run this command now
    ERROR:auth_db:get_ha1: failed to query database

Credits to @masudmuborakshohi for the accurate report and logs!
Fixes #2593

(cherry picked from commit 4ef6bab)
  • Loading branch information
liviuchircu committed Aug 16, 2021
1 parent 8f4c24a commit c871d9e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion modules/db_mysql/dbase.c
Expand Up @@ -976,14 +976,15 @@ int db_mysql_query(const db_con_t* _h, const db_key_t* _k, const db_op_t* _op,
}

ret = db_mysql_do_prepared_query(_h, &query_holder, _v, _n, NULL, 0);
CON_RESET_CURR_PS(_h);
if (ret != 0) {
CON_RESET_CURR_PS(_h);
if (_r)
*_r = NULL;
return ret;
}

ret = db_mysql_store_result(_h, _r);
CON_RESET_CURR_PS(_h);
return ret;
}
return db_do_query(_h, _k, _op, _v, _c, _n, _nc, _o, _r,
Expand Down

1 comment on commit c871d9e

@bogdan-iancu
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch @liviuchircu !!

Please sign in to comment.