Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update fork to version 2.1.5 #13

Merged
merged 1 commit into from Mar 6, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGES.txt
Expand Up @@ -8,6 +8,16 @@ Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
Full release notes:
http://dev.mysql.com/doc/relnotes/connector-python/en/

v2.1.5
======

- BUG#25111218: Fix duplicate logic for reading EOF packet
- BUG#21656282: Connection fails using unicode passwords with C extension
- BUG#21530841: Select statement fails for results with more than 4096 columns
- BUG#21530100: Fix reading option files
- BUG#21477493: Fix RE_SQL_INSERT_STMT to correctly match Insert Statement
- BUG#21476495: Fix set_charset_collation() for an invalid charset provided

v2.1.4
======

Expand Down
2 changes: 1 addition & 1 deletion PKG-INFO
@@ -1,6 +1,6 @@
Metadata-Version: 1.0
Name: mysql-connector-python
Version: 2.1.4
Version: 2.1.5
Summary: MySQL driver written in Python
Home-page: http://dev.mysql.com/doc/connector-python/en/index.html
Author: Oracle and/or its affiliates
Expand Down
1 change: 0 additions & 1 deletion lib/mysql/connector/abstracts.py
Expand Up @@ -634,7 +634,6 @@ def set_charset_collation(self, charset=None, collation=None):
"""
if charset:
if isinstance(charset, int):
self._charset_id = charset
(self._charset_id, charset_name, collation_name) = \
CharacterSet.get_charset_info(charset)
elif isinstance(charset, str):
Expand Down
3 changes: 2 additions & 1 deletion lib/mysql/connector/cursor.py
Expand Up @@ -40,7 +40,8 @@
r'''\s*ON\s+DUPLICATE\s+KEY(?:[^"'`]*["'`][^"'`]*["'`])*[^"'`]*$''',
re.I | re.M | re.S)
RE_SQL_INSERT_STMT = re.compile(
r"({0}|\s)*INSERT({0}|\s)*INTO.+VALUES.*".format(SQL_COMMENT),
r"({0}|\s)*INSERT({0}|\s)*INTO\s+[`'\"]?.+[`'\"]?(?:\.[`'\"]?.+[`'\"]?)"
"{{0,2}}\s+VALUES\s*\(.+(?:\s*,.+)*\)".format(SQL_COMMENT),
re.I | re.M | re.S)
RE_SQL_INSERT_VALUES = re.compile(r'.*VALUES\s*(\(.*\)).*', re.I | re.M | re.S)
RE_PY_PARAM = re.compile(b'(%s)')
Expand Down
36 changes: 16 additions & 20 deletions lib/mysql/connector/optionfiles.py
Expand Up @@ -286,19 +286,19 @@ def get_groups(self, *args):
args = self._options_dict.keys()

options = {}
priority = {}
for group in args:
try:
for option, value in self._options_dict[group].items():
if option not in options or options[option][1] <= value[1]:
options[option] = value
for option, value in [(key, value,) for key, value in
self._options_dict[group].items() if
key != "__name__" and
not key.startswith("!")]:
if option not in options or priority[option] <= value[1]:
priority[option] = value[1]
options[option] = value[0]
except KeyError:
pass

for key in options.keys():
if key == '__name__' or key.startswith('!'):
del options[key]
else:
options[key] = options[key][0]
return options

def get_groups_as_dict_with_priority(self, *args): # pylint: disable=C0103
Expand All @@ -321,14 +321,13 @@ def get_groups_as_dict_with_priority(self, *args): # pylint: disable=C0103
options = dict()
for group in args:
try:
options[group] = dict(self._options_dict[group])
options[group] = dict((key, value,) for key, value in
self._options_dict[group].items() if
key != "__name__" and
not key.startswith("!"))
except KeyError:
pass

for group in options.keys():
for key in options[group].keys():
if key == '__name__' or key.startswith('!'):
del options[group][key]
return options

def get_groups_as_dict(self, *args):
Expand All @@ -347,14 +346,11 @@ def get_groups_as_dict(self, *args):
options = dict()
for group in args:
try:
options[group] = dict(self._options_dict[group])
options[group] = dict((key, value[0],) for key, value in
self._options_dict[group].items() if
key != "__name__" and
not key.startswith("!"))
except KeyError:
pass

for group in options.keys():
for key in options[group].keys():
if key == '__name__' or key.startswith('!'):
del options[group][key]
else:
options[group][key] = options[group][key][0]
return options
7 changes: 0 additions & 7 deletions lib/mysql/connector/protocol.py
Expand Up @@ -227,8 +227,6 @@ def parse_column_count(self, packet):
"""Parse a MySQL packet with the number of columns in result set"""
try:
count = utils.read_lc_int(packet[4:])[1]
if count > MAX_MYSQL_TABLE_COLUMNS:
return None
return count
except (struct.error, ValueError):
raise errors.InterfaceError("Failed parsing column count")
Expand Down Expand Up @@ -318,7 +316,6 @@ def read_text_result(self, sock, version, count=1):
eof = None
rowdata = None
i = 0
eof57 = version >= (5, 7, 5)
while True:
if eof or i == count:
break
Expand All @@ -334,10 +331,6 @@ def read_text_result(self, sock, version, count=1):
elif (packet[4] == 254 and packet[0] < 7):
eof = self.parse_eof(packet)
rowdata = None
elif eof57 and (packet[4] == 0 and packet[0] > 9):
# EOF deprecation: make sure we catch it whether flag is set or not
eof = self.parse_ok(packet)
rowdata = None
else:
eof = None
rowdata = utils.read_lc_string_list(packet[4:])
Expand Down
2 changes: 1 addition & 1 deletion lib/mysql/connector/version.py
Expand Up @@ -26,7 +26,7 @@
as mysql.connector.version.
"""

VERSION = (2, 1, 4, '', 0)
VERSION = (2, 1, 5, '', 0)

if VERSION[3] and VERSION[4]:
VERSION_TEXT = '{0}.{1}.{2}{3}{4}'.format(*VERSION)
Expand Down
47 changes: 38 additions & 9 deletions src/mysql_capi.c
Expand Up @@ -1025,14 +1025,16 @@ MySQL_commit(MySQL *self)
PyObject*
MySQL_connect(MySQL *self, PyObject *args, PyObject *kwds)
{
char *host= NULL, *user= NULL, *password= NULL, *database= NULL,
*unix_socket= NULL;
char *host= NULL, *user= NULL, *database= NULL, *unix_socket= NULL;
char *ssl_ca= NULL, *ssl_cert= NULL, *ssl_key= NULL;
PyObject *charset_name, *compress, *ssl_verify_cert;
PyObject *charset_name, *compress, *ssl_verify_cert, *password;
const char* auth_plugin;
unsigned long client_flags= 0;
unsigned int port= 3306, tmp_uint;
unsigned int protocol= 0;
#if MYSQL_VERSION_ID >= 50711
unsigned int ssl_mode;
#endif
my_bool abool;
MYSQL *res;

Expand All @@ -1045,7 +1047,11 @@ MySQL_connect(MySQL *self, PyObject *args, PyObject *kwds)
NULL
};

#ifdef PY3
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzzzkzkzzzO!O!", kwlist,
#else
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|zzOzkzkzzzO!O!", kwlist,
#endif
&host, &user, &password, &database,
&port, &unix_socket,
&client_flags,
Expand Down Expand Up @@ -1115,15 +1121,17 @@ MySQL_connect(MySQL *self, PyObject *args, PyObject *kwds)
#endif
#if MYSQL_VERSION_ID >= 50711
{
mysql_options(&self->session, MYSQL_OPT_SSL_MODE, SSL_MODE_REQUIRED);
ssl_mode= SSL_MODE_REQUIRED;
mysql_options(&self->session, MYSQL_OPT_SSL_MODE, &ssl_mode);
}
#endif

if (ssl_verify_cert && ssl_verify_cert == Py_True)
{
#if MYSQL_VERSION_ID >= 50711
{
mysql_options(&self->session, MYSQL_OPT_SSL_MODE, SSL_MODE_VERIFY_IDENTITY);
ssl_mode= SSL_MODE_VERIFY_IDENTITY;
mysql_options(&self->session, MYSQL_OPT_SSL_MODE, &ssl_mode);
}
#else
{
Expand All @@ -1144,7 +1152,8 @@ MySQL_connect(MySQL *self, PyObject *args, PyObject *kwds)
#endif
#if MYSQL_VERSION_ID >= 50711
{
mysql_options(&self->session, MYSQL_OPT_SSL_ENFORCE, SSL_MODE_DISABLED);
ssl_mode= SSL_MODE_DISABLED;
mysql_options(&self->session, MYSQL_OPT_SSL_MODE, &ssl_mode);
}
#endif
}
Expand All @@ -1170,9 +1179,29 @@ MySQL_connect(MySQL *self, PyObject *args, PyObject *kwds)
client_flags= client_flags & ~CLIENT_CONNECT_WITH_DB;
}

res= mysql_real_connect(&self->session,
host, user, password, database,
port, unix_socket, client_flags);
if (client_flags & CLIENT_LOCAL_FILES) {
abool= 1;
mysql_options(&self->session, MYSQL_OPT_LOCAL_INFILE, (unsigned int*)&abool);
}

#ifdef PY3
res= mysql_real_connect(&self->session, host, user, password, database,
port, unix_socket, client_flags);
#else
char* c_password;
if (PyUnicode_Check(password))
{
PyObject* u_password= PyUnicode_AsUTF8String(password);
c_password= PyString_AsString(u_password);
Py_DECREF(u_password);
}
else
{
c_password= PyString_AsString(password);
}
res= mysql_real_connect(&self->session, host, user, c_password, database,
port, unix_socket, client_flags);
#endif

Py_END_ALLOW_THREADS

Expand Down