Skip to content

Commit 695e6a5

Browse files
committed
2 parents 1958841 + d40a8b0 commit 695e6a5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+23553
-276
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,5 @@ cpy_server*/
1212
*_output.txt
1313
tests_*.log
1414
dev*.py
15+
/lib/mysqlx/expr_backup.py
16+
/lib/test.py

CHANGES.txt

Lines changed: 18 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,29 @@
11
====================================================
2-
MySQL Connector/Python 2.1 - Release Notes & Changes
2+
MySQL Connector/Python 2.2 - Release Notes & Changes
33
====================================================
44

55
MySQL Connector/Python
6-
Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
6+
Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
77

88
Full release notes:
99
http://dev.mysql.com/doc/relnotes/connector-python/en/
1010

11-
v2.1.3
11+
v2.2.1
1212
======
1313

14-
- BUG#21782246: Fix Install check of bitness of libmysql c client fails
15-
- BUG#21505096: MySQL Connector python 2.1.2 does not ship with required __init.py__ files
16-
- BUG#21499127: Fix copyright year in README.txt
17-
- BUG#21420633: Fix CExtension crashing while fetching large number of NULL value
18-
- BUG#21420906: Fix connect using SHA256 user with blank password
19-
- BUG#21090014: Fix handshake with MySQL server 5.5.8
20-
- BUG#21054559: Using a binary field in Django raises an exception
21-
- BUG#21054556: Attribute error raised with Django
22-
- BUG#20638660: The account_locked needs value for MySQL 5.7.6
23-
- BUG#20653441: C/Py hangs if a query is killed
24-
- BUG#20987205: C/Py Django backend doesn't work with Django 1.8
25-
- BUG#21492815: Fix callproc when consuming results turned on
26-
- BUG#21529781: Fix usage of auth_plugin option with CExtension
27-
- BUG#21535573: Fix character decoding of identifiers using CExtension
28-
- BUG#21536507: Fix raising warnings as exceptions
29-
- BUG#21490865: Fix compiling CExtension with relocated libmysqlclient
30-
- BUG#21492428: Fix using passwords with leading/trailing whitespaces
31-
- BUG#21541244: Fix running unit tests for MySQL server 5.5
32-
- BUG#21782246: Fix Install check of bitness of libmysql c client fails
33-
34-
v2.1.2b1
35-
========
36-
37-
- WL7956: Support MySQL Protocol connecting to MySQL Fabric
38-
- BUG20462427: Fix receiving large field data from server
39-
- BUG20365619: Fix MySQL version detection for C Extension
40-
- BUG20301989: Fix conversion of empty set
41-
- BUG20407036: Fix incorrect arguments to mysld_stmt_execute error
42-
- BUG20106629: Support Django Safetext and SafeBytes type
43-
- BUG20324089: Fix HASH baesd sharding with MySQL Fabric
44-
- BUG20217174: Fix install command honouring --install-lib when given
45-
- BUG19777815: Add support for warnings with MySQLCursor.callproc()
46-
- BUG19331658: Fix connection pooling with fabric
47-
- BUG19972427: Fix creating of redundant connections in Django
48-
- BUG20022533: Fix failing Django inspectdb command with C/Python
49-
- BUG19703022: Fix using passwords with integers only in option files
50-
- BUG19803702: Fix reporting errors with non-ascii characters
51-
- BUG20834643: Attribute Error while promoting servers using MySQL Fabric
52-
- BUG20811802: Fix buffered named tuple cursor with CExtension
53-
54-
v2.1.1a1
55-
========
56-
57-
- WL7643: Add Python C Extension using Connector/C
14+
- Add support for Protocol Buffers 3
15+
- Add View support (without DDL)
16+
- Implement get_default_schema() method in BaseSchema
17+
- DevAPI: Per ReplicaSet SQL execution
18+
- DevAPI: XSession accepts a list of routers
19+
- DevAPI: Define action on adding empty list of documents
20+
- BUG23729357: Fix fetching BIT datatype
21+
- BUG23583381: Add who_am_i and am_i_real methods to DatabaseObject
22+
- BUG23568257: Add fetch_one method to mysqlx.result
23+
- BUG23550743: Add close method to XSession and NodeSession
24+
- BUG23550057: Add support for URI as connection data
25+
26+
v2.2.0
27+
======
5828

29+
- Provide initial implementation of new DevAPI

README.txt

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
==========================
2-
MySQL Connector/Python 2.1
2+
MySQL Connector/Python 2.2
33
==========================
44

55
MySQL Connector/Python
6-
Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
6+
Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
77

88
License information can be found in the LICENSE.txt file.
99

1010

11+
Requirements
12+
============
13+
14+
Python Protobuf (version >= 3.0.0)
15+
https://developers.google.com/protocol-buffers/docs/downloads
16+
17+
1118
Documentation & Examples
1219
========================
1320

@@ -28,7 +35,7 @@ doubt, this particular copy of the software is released
2835
under the version 2 of the GNU General Public License.
2936
MySQL Connector/Python is brought to you by Oracle.
3037

31-
Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
38+
Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
3239

3340
License information can be found in the LICENSE.txt file.
3441

cpyint

examples/dates.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ def main(config):
8282
except (mysql.connector.errors.Error, TypeError) as exc:
8383
output.append("Failed inserting {0}\nError: {1}\n".format(
8484
data, exc))
85+
cursor.execute(stmt_drop)
8586
raise
8687

8788
# Read the names again and print them

examples/microseconds.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ def main(config):
9595
except:
9696
# Ignoring the fact that it was not there
9797
pass
98-
98+
99+
cursor.execute("DROP TABLE IF EXISTS relay_laps")
99100
cursor.close()
100101
cnx.close()
101102

lib/cpy_distutils.py

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# MySQL Connector/Python - MySQL driver written in Python.
2-
# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
33

44
# MySQL Connector/Python is licensed under the terms of the GPLv2
55
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -125,7 +125,11 @@ def unix_lib_is64bit(lib_file):
125125
lib_file = mysqlclient_libs[-1]
126126

127127
log.debug("# Using file command to test lib_file {0}".format(lib_file))
128-
prc = Popen(['file', '-L', lib_file], stdin=PIPE, stderr=STDOUT,
128+
if platform.uname() == 'SunOS':
129+
cmd_list = ['file', '-L', lib_file]
130+
else:
131+
cmd_list = ['file', '-L', lib_file]
132+
prc = Popen(cmd_list, stdin=PIPE, stderr=STDOUT,
129133
stdout=PIPE)
130134
stdout = prc.communicate()[0]
131135
stdout = stdout.split(':')[1]
@@ -166,10 +170,12 @@ def get_mysql_config_info(mysql_config):
166170
libs = shlex.split(info['libs'])
167171
info['lib_dir'] = libs[0].replace('-L', '')
168172
info['libs'] = [ lib.replace('-l', '') for lib in libs[1:] ]
173+
if platform.uname()[0] == 'SunOS':
174+
info['lib_dir'] = info['lib_dir'].replace('-R', '')
175+
info['libs'] = [lib.replace('-R', '') for lib in info['libs']]
169176
log.debug("# info['libs']: ")
170177
for lib in info['libs']:
171178
log.debug("# {0}".format(lib))
172-
log.error("# info['libs']: {0}".format(info['libs']))
173179
libs = shlex.split(info['libs_r'])
174180
info['lib_r_dir'] = libs[0].replace('-L', '')
175181
info['libs_r'] = [ lib.replace('-l', '') for lib in libs[1:] ]
@@ -179,11 +185,18 @@ def get_mysql_config_info(mysql_config):
179185
# Try to figure out the architecture
180186
info['arch'] = None
181187
if os.name == 'posix':
182-
pathname = os.path.join(info['lib_dir'], 'lib' + info['libs'][0]) + '*'
188+
if platform.uname()[0] == 'SunOS':
189+
print("info['lib_dir']: {0}".format(info['lib_dir']))
190+
print("info['libs'][0]: {0}".format(info['libs'][0]))
191+
pathname = os.path.abspath(os.path.join(info['lib_dir'],
192+
'lib',
193+
info['libs'][0])) + '/*'
194+
else:
195+
pathname = os.path.join(info['lib_dir'],
196+
'lib' + info['libs'][0]) + '*'
197+
print("# Looking mysqlclient_lib at path: {0}".format(pathname))
198+
log.debug("# searching mysqlclient_lib at: %s", pathname)
183199
libs = glob(pathname)
184-
log.debug("# libs: {0}".format(libs))
185-
for lib in libs:
186-
log.debug("#- {0}".format(lib))
187200
mysqlclient_libs = []
188201
for filepath in libs:
189202
_, filename = os.path.split(filepath)
@@ -202,7 +215,12 @@ def get_mysql_config_info(mysql_config):
202215
log.debug("#+ {0}".format(mysqlclient_lib))
203216
log.debug("# tested mysqlclient_lib[-1]: "
204217
"{0}".format(mysqlclient_libs[-1]))
205-
proc = Popen(['file', '-L', mysqlclient_libs[-1]], stdout=PIPE,
218+
if platform.uname()[0] == 'SunOS':
219+
print("mysqlclient_lib: {0}".format(mysqlclient_libs[-1]))
220+
cmd_list = ['file', mysqlclient_libs[-1]]
221+
else:
222+
cmd_list = ['file', '-L', mysqlclient_libs[-1]]
223+
proc = Popen(cmd_list, stdout=PIPE,
206224
universal_newlines=True)
207225
stdout, _ = proc.communicate()
208226
stdout = stdout.split(':')[1]
@@ -364,9 +382,9 @@ def _finalize_connector_c(self, connc_loc):
364382
# We try to offer a nice message when the architecture of Python
365383
# is not the same as MySQL Connector/C binaries.
366384
py_arch = '64-bit' if ARCH_64BIT else '32-bit'
367-
log.debug("# Python architecture: {0}".format(py_arch))
368-
log.debug("# Python ARCH_64BIT: {0}".format(ARCH_64BIT))
369-
log.debug("# self.arch: {0}".format(self.arch))
385+
print("# Python architecture: {0}".format(py_arch))
386+
print("# Python ARCH_64BIT: {0}".format(ARCH_64BIT))
387+
print("# self.arch: {0}".format(self.arch))
370388
if ARCH_64BIT != connc_64bit:
371389
log.error("Python is {0}, but does not "
372390
"match MySQL C API {1} architecture, "
@@ -472,13 +490,19 @@ def _finalize_connector_c(self, connc_loc):
472490
log.error("MySQL C API should be a directory")
473491
sys.exit(1)
474492

493+
log.info("Copying MySQL libraries")
475494
copy_tree(os.path.join(connc_loc, 'lib'), self.connc_lib)
495+
log.info("Copying MySQL header files")
476496
copy_tree(os.path.join(connc_loc, 'include'), self.connc_include)
477497

478498
# Remove all but static libraries to force static linking
479-
for lib_file in os.listdir(self.connc_lib):
480-
if os.name == 'posix' and not lib_file.endswith('.a'):
481-
os.unlink(os.path.join(self.connc_lib, lib_file))
499+
if os.name == 'posix':
500+
log.info("Removing non-static MySQL libraries from %s" % self.connc_lib)
501+
for lib_file in os.listdir(self.connc_lib):
502+
lib_file_path = os.path.join(self.connc_lib, lib_file)
503+
if os.path.isfile(lib_file_path) and not lib_file.endswith('.a'):
504+
os.unlink(os.path.join(self.connc_lib, lib_file))
505+
482506

483507
def fix_compiler(self):
484508
BuildExtDynamic.fix_compiler(self)
@@ -556,6 +580,7 @@ def initialize_options(self):
556580

557581
def finalize_options(self):
558582
if self.static:
583+
log.info("Linking CExtension statically with MySQL libraries")
559584
self.distribution.cmdclass['build_ext'] = BuildExtStatic
560585

561586
if self.byte_code_only is None:

lib/mysql/connector/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# MySQL Connector/Python - MySQL driver written in Python.
2-
# Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
33

44
# MySQL Connector/Python is licensed under the terms of the GPLv2
55
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -42,7 +42,7 @@
4242
from .constants import FieldFlag, FieldType, CharacterSet, \
4343
RefreshOption, ClientFlag
4444
from .dbapi import (
45-
Date, Time, Timestamp, Binary, DateFromTicks, DateFromTicks,
45+
Date, Time, Timestamp, Binary, DateFromTicks,
4646
TimestampFromTicks, TimeFromTicks,
4747
STRING, BINARY, NUMBER, DATETIME, ROWID,
4848
apilevel, threadsafety, paramstyle)

lib/mysql/connector/abstracts.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# MySQL Connector/Python - MySQL driver written in Python.
2-
# Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
33

44
# MySQL Connector/Python is licensed under the terms of the GPLv2
55
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -23,9 +23,6 @@
2323

2424
"""Module gathering all abstract base classes"""
2525

26-
# Issue with pylint and NotImplementedError
27-
# pylint: disable=R0921
28-
2926
from abc import ABCMeta, abstractmethod, abstractproperty
3027
import re
3128
import time

lib/mysql/connector/connection.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# MySQL Connector/Python - MySQL driver written in Python.
2-
# Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
33

44
# MySQL Connector/Python is licensed under the terms of the GPLv2
55
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most
@@ -237,7 +237,7 @@ def close(self):
237237
disconnect = close
238238

239239
def _send_cmd(self, command, argument=None, packet_number=0, packet=None,
240-
expect_response=True):
240+
expect_response=True, compressed_packet_number=0):
241241
"""Send a command to the MySQL server
242242
243243
This method sends a command with an optional argument.
@@ -258,7 +258,7 @@ def _send_cmd(self, command, argument=None, packet_number=0, packet=None,
258258
try:
259259
self._socket.send(
260260
self._protocol.make_command(command, packet or argument),
261-
packet_number)
261+
packet_number, compressed_packet_number)
262262
except AttributeError:
263263
raise errors.OperationalError("MySQL Connection not available.")
264264

@@ -325,7 +325,7 @@ def _handle_ok(self, packet):
325325
"""
326326
if packet[4] == 0:
327327
ok_pkt = self._protocol.parse_ok(packet)
328-
self._handle_server_status(ok_pkt['server_status'])
328+
self._handle_server_status(ok_pkt['status_flag'])
329329
return ok_pkt
330330
elif packet[4] == 255:
331331
raise errors.get_exception(packet)
@@ -440,12 +440,14 @@ def get_rows(self, count=None, binary=False, columns=None):
440440
rows = self._protocol.read_binary_result(
441441
self._socket, columns, count)
442442
else:
443-
rows = self._protocol.read_text_result(self._socket, count)
443+
rows = self._protocol.read_text_result(self._socket, self._server_version, count=count)
444444
except errors.Error as err:
445445
self.unread_result = False
446446
raise err
447+
447448
if rows[-1] is not None:
448-
self._handle_server_status(rows[-1]['status_flag'])
449+
ek = rows[-1] # OK or EOF
450+
self._handle_server_status(ek['status_flag'] if 'status_flag' in ek else ek['server_status'])
449451
self.unread_result = False
450452

451453
return rows
@@ -553,7 +555,7 @@ def cmd_quit(self):
553555
self.handle_unread_result()
554556

555557
packet = self._protocol.make_command(ServerCmd.QUIT)
556-
self._socket.send(packet, 0)
558+
self._socket.send(packet, 0, 0)
557559
return packet
558560

559561
def cmd_shutdown(self, shutdown_type=None):
@@ -587,7 +589,7 @@ def cmd_statistics(self):
587589
self.handle_unread_result()
588590

589591
packet = self._protocol.make_command(ServerCmd.STATISTICS)
590-
self._socket.send(packet, 0)
592+
self._socket.send(packet, 0, 0)
591593
return self._protocol.parse_statistics(self._socket.recv())
592594

593595
def cmd_process_kill(self, mysql_pid):
@@ -646,7 +648,7 @@ def cmd_change_user(self, username='', password='', database='',
646648
charset=charset, client_flags=self._client_flags,
647649
ssl_enabled=self._ssl_active,
648650
auth_plugin=self._auth_plugin)
649-
self._socket.send(packet, 0)
651+
self._socket.send(packet, 0, 0)
650652

651653
ok_packet = self._auth_switch_request(username, password)
652654

0 commit comments

Comments
 (0)