Skip to content

Commit

Permalink
Test if the MySQL client version is 5.6.6+
Browse files Browse the repository at this point in the history
In 5.6.6 the connection attributes feature was introduced according to the docs.

Pair programming with Eric Herman <eric@freesa.org>
  • Loading branch information
Daniël van Eeden committed Apr 23, 2015
1 parent f0dd694 commit 37bb434
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions dbdimp.c
Expand Up @@ -1747,17 +1747,19 @@ MYSQL *mysql_dr_connect(

mysql_options(sock, MYSQL_READ_DEFAULT_GROUP, gr);
}
if ((svp = hv_fetch(hv, "mysql_conn_attrs", 16, FALSE)) && *svp) {
HV* attrs = (HV*) SvRV(*svp);
HE* entry = NULL;
hv_iterinit(attrs);
while ((entry = hv_iternext(attrs))) {
I32 *retlen;
char *attr_name = hv_iterkey(entry, retlen);
SV *sv_attr_val = hv_iterval(attrs, entry);
char *attr_val = SvPV(sv_attr_val, lna);
mysql_options4(sock, MYSQL_OPT_CONNECT_ATTR_ADD, attr_name, attr_val);
}
if (mysql_get_client_version() >= 50606) {
if ((svp = hv_fetch(hv, "mysql_conn_attrs", 16, FALSE)) && *svp) {
HV* attrs = (HV*) SvRV(*svp);
HE* entry = NULL;
hv_iterinit(attrs);
while ((entry = hv_iternext(attrs))) {
I32 *retlen;
char *attr_name = hv_iterkey(entry, retlen);
SV *sv_attr_val = hv_iterval(attrs, entry);
char *attr_val = SvPV(sv_attr_val, lna);
mysql_options4(sock, MYSQL_OPT_CONNECT_ATTR_ADD, attr_name, attr_val);
}
}
}
if ((svp = hv_fetch(hv, "mysql_client_found_rows", 23, FALSE)) && *svp)
{
Expand Down

0 comments on commit 37bb434

Please sign in to comment.