From: Mike Bayer Date: Fri, 28 Jul 2017 19:05:25 +0000 (-0400) Subject: Revert cx_Oracle WITH_UNICODE change under > 5.0 X-Git-Tag: origin~89^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7997d7fdc3634e7dba9fd0113b8b85ef311bfeaa;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Revert cx_Oracle WITH_UNICODE change under > 5.0 Fixed performance regression caused by the fix for :ticket:`3937` where cx_Oracle as of version 5.3 dropped the ``.UNICODE`` symbol from its namespace, which was interpreted as cx_Oracle's "WITH_UNICODE" mode being turned on unconditionally, which invokes functions on the SQLAlchemy side which convert all strings to unicode unconditionally and causing a performance impact. In fact, per cx_Oracle's author the "WITH_UNICODE" mode has been removed entirely as of 5.1, so the expensive unicode conversion functions are no longer necessary and are disabled if cx_Oracle 5.1 or greater is detected under Python 2. The warning against "WITH_UNICODE" mode that was removed under :ticket:`3937` is also restored. Change-Id: Iddd38d81a5adb27c953a5ee2eae5529a21da16e1 Fixes: #4035 --- diff --git a/doc/build/changelog/unreleased_10/4035.rst b/doc/build/changelog/unreleased_10/4035.rst new file mode 100644 index 0000000000..74acdfe710 --- /dev/null +++ b/doc/build/changelog/unreleased_10/4035.rst @@ -0,0 +1,15 @@ +.. change:: + :tags: bug, oracle, performance, py2k + :tickets: 4035 + :versions: 1.0.19, 1.1.13, 1.2.0b3 + + Fixed performance regression caused by the fix for :ticket:`3937` where + cx_Oracle as of version 5.3 dropped the ``.UNICODE`` symbol from its + namespace, which was interpreted as cx_Oracle's "WITH_UNICODE" mode being + turned on unconditionally, which invokes functions on the SQLAlchemy + side which convert all strings to unicode unconditionally and causing + a performance impact. In fact, per cx_Oracle's author the + "WITH_UNICODE" mode has been removed entirely as of 5.1, so the expensive unicode + conversion functions are no longer necessary and are disabled if + cx_Oracle 5.1 or greater is detected under Python 2. The warning against + "WITH_UNICODE" mode that was removed under :ticket:`3937` is also restored. diff --git a/lib/sqlalchemy/dialects/oracle/cx_oracle.py b/lib/sqlalchemy/dialects/oracle/cx_oracle.py index f6c3c97b76..4e9f6314b4 100644 --- a/lib/sqlalchemy/dialects/oracle/cx_oracle.py +++ b/lib/sqlalchemy/dialects/oracle/cx_oracle.py @@ -723,19 +723,28 @@ class OracleDialect_cx_oracle(OracleDialect): self._cx_oracle_string_types = set() self._cx_oracle_with_unicode = False elif util.py3k or ( - self.cx_oracle_ver >= (5,) and not \ + self.cx_oracle_ver >= (5,) and + self.cx_oracle_ver < (5, 1) and not hasattr(self.dbapi, 'UNICODE') ): # cx_Oracle WITH_UNICODE mode. *only* python - # unicode objects accepted for anything + # unicode objects accepted for anything. This + # mode of operation is implicit for Python 3, + # however under Python 2 it existed as a never-used build-time + # option for cx_Oracle 5.0 only and was removed in 5.1. self.supports_unicode_statements = True self.supports_unicode_binds = True self._cx_oracle_with_unicode = True if util.py2k: # There's really no reason to run with WITH_UNICODE under - # Python 2.x. However as of cx_oracle 5.3 it seems to be - # set to ON for default builds + # Python 2.x. Give the user a hint. + util.warn( + "cx_Oracle is compiled under Python 2.xx using the " + "WITH_UNICODE flag. Consider recompiling cx_Oracle " + "without this flag, which is in no way necessary for " + "full support of Unicode and causes significant " + "performance issues.") self.execution_ctx_cls = \ OracleExecutionContext_cx_oracle_with_unicode else: