Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix for CONC-139:
When using binary protocol, convert data to binary object only if the
character set is BINARY (63), not if the flag was set.
  • Loading branch information
9EOR9 committed Feb 14, 2021
1 parent 5f03209 commit f633103
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
3 changes: 1 addition & 2 deletions mariadb/mariadb_codecs.c
Expand Up @@ -785,8 +785,7 @@ field_fetch_callback(void *data, unsigned int column, unsigned char **row)
unsigned long utf8len;
length= mysql_net_field_length(row);

if ((self->fields[column].flags & BINARY_FLAG ||
self->fields[column].charsetnr == CHARSET_BINARY))
if (self->fields[column].charsetnr == CHARSET_BINARY)
{
self->values[column]=
PyBytes_FromStringAndSize((const char *)*row,
Expand Down
3 changes: 2 additions & 1 deletion mariadb/mariadb_connection.c
Expand Up @@ -612,7 +612,8 @@ void MrdbConnection_dealloc(MrdbConnection *self)
mysql_close(self->mysql);
Py_END_ALLOW_THREADS
}
Py_DECREF(self->server_version_info);
if (self->server_version_info)
Py_DECREF(self->server_version_info);
Py_TYPE(self)->tp_free((PyObject*)self);
}
}
Expand Down
17 changes: 17 additions & 0 deletions testing/test/integration/test_cursor.py
Expand Up @@ -1135,6 +1135,23 @@ def test_conpy133(self):
pass
del cursor

def test_conpy139(self):
connection= create_connection()
cursor= connection.cursor()
cursor.execute("create temporary table t1 (a varchar(254) character set utf8mb4 collate utf8mb4_bin)")
cursor.execute("insert into t1 values ('foo')")
del cursor
c1= connection.cursor()
c2= connection.cursor(prepared=True)
c1.execute("select a from t1")
r1= c1.fetchall()
c2.execute("select a from t1")
r2= c2.fetchall()
self.assertEqual(r1, r2)

del c1, c2
connection.close()

def test_conpy91(self):
with create_connection() as connection:
with connection.cursor() as cursor:
Expand Down

0 comments on commit f633103

Please sign in to comment.