From 0488d1dd0870b99308a26c86cea0b57fdbaf2898 Mon Sep 17 00:00:00 2001 From: Mark Schisler Date: Wed, 30 Dec 2015 15:14:44 -0500 Subject: [PATCH] fixing error codes for msql 5.7 see: https://dev.mysql.com/worklog/task/?id=8206 --- .gitignore | 2 ++ README | 2 +- oursqlx/_exceptions.c | 21 +++++++++++++++++---- setup.py | 2 +- 4 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index ba74660..d1abbf4 100644 --- a/.gitignore +++ b/.gitignore @@ -55,3 +55,5 @@ docs/_build/ # PyBuilder target/ + +PKG-INFO diff --git a/README b/README index 3fb44bd..213b955 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -oursql v0.9.2! +oursql v0.9.3.2! Comprehensive documentation for oursql is available online: http://packages.python.org/oursql/ diff --git a/oursqlx/_exceptions.c b/oursqlx/_exceptions.c index 8e76bed..0d76ff0 100644 --- a/oursqlx/_exceptions.c +++ b/oursqlx/_exceptions.c @@ -617,10 +617,23 @@ enum _oursqlx_exception_type _oursqlx_exc_from_errno(int err) { return _oursqlx_PermissionsError; default: - if (err >= ER_ERROR_FIRST && err <= ER_ERROR_LAST) - return _oursqlx_ProgrammingError; - else if (err > CR_MIN_ERROR && err < CR_MAX_ERROR) - return _oursqlx_InterfaceError; + #if MYSQL_VERSION_ID >= 50700 + for(unsigned int i = 0; i < sizeof(errmsg_section_start)/sizeof(int); ++i) { + int min = errmsg_section_start[i]; + int max = errmsg_section_start[i] + errmsg_section_size[i] - 1; + if ( err >= min && err <= max ) { + return _oursqlx_ProgrammingError; + } + } + if ( err > CR_MIN_ERROR && err < CR_MAX_ERROR) { + return _oursqlx_InterfaceError; + } + #else + if (err >= ER_ERROR_FIRST && err <= ER_ERROR_LAST) + return _oursqlx_ProgrammingError; + else if (err > CR_MIN_ERROR && err < CR_MAX_ERROR) + return _oursqlx_InterfaceError; + #endif } return _oursqlx_UnknownError; } diff --git a/setup.py b/setup.py index 0614822..180d697 100644 --- a/setup.py +++ b/setup.py @@ -205,7 +205,7 @@ def run(self): setup( name='oursql', - version='0.9.3', + version='0.9.3.2', author='Aaron Gallagher', author_email='habnabit@gmail.com', url='http://launchpad.net/oursql',