@@ -251,7 +251,6 @@ static PyObject *_mysql_server_init(
251
251
& cmd_args , & groups ))
252
252
return NULL ;
253
253
254
- #if MYSQL_VERSION_ID >= 40000
255
254
if (cmd_args ) {
256
255
if (!PySequence_Check (cmd_args )) {
257
256
PyErr_SetString (PyExc_TypeError ,
@@ -318,7 +317,6 @@ static PyObject *_mysql_server_init(
318
317
_mysql_Exception (NULL );
319
318
goto finish ;
320
319
}
321
- #endif
322
320
ret = Py_None ;
323
321
Py_INCREF (Py_None );
324
322
_mysql_server_init_done = 1 ;
@@ -336,9 +334,7 @@ static PyObject *_mysql_server_end(
336
334
PyObject * self ,
337
335
PyObject * args ) {
338
336
if (_mysql_server_init_done ) {
339
- #if MYSQL_VERSION_ID >= 40000
340
337
mysql_server_end ();
341
- #endif
342
338
_mysql_server_init_done = 0 ;
343
339
Py_INCREF (Py_None );
344
340
return Py_None ;
@@ -1063,18 +1059,19 @@ _mysql_escape_string(
1063
1059
str = PyBytes_FromStringAndSize ((char * ) NULL , size * 2 + 1 );
1064
1060
if (!str ) return PyErr_NoMemory ();
1065
1061
out = PyBytes_AS_STRING (str );
1066
- #if MYSQL_VERSION_ID < 32321
1067
- len = mysql_escape_string (out , in , size );
1068
- #else
1069
1062
check_server_init (NULL );
1070
1063
1071
1064
if (self && PyModule_Check ((PyObject * )self ))
1072
1065
self = NULL ;
1073
- if (self && self -> open )
1066
+ if (self && self -> open ) {
1067
+ #if MYSQL_VERSION_ID >= 50706
1068
+ len = mysql_real_escape_string_quote (& (self -> connection ), out , in , size , '\'' );
1069
+ #else
1074
1070
len = mysql_real_escape_string (& (self -> connection ), out , in , size );
1075
- else
1076
- len = mysql_escape_string (out , in , size );
1077
1071
#endif
1072
+ } else {
1073
+ len = mysql_escape_string (out , in , size );
1074
+ }
1078
1075
if (_PyBytes_Resize (& str , len ) < 0 ) return NULL ;
1079
1076
return (str );
1080
1077
}
@@ -1123,15 +1120,16 @@ _mysql_string_literal(
1123
1120
return PyErr_NoMemory ();
1124
1121
}
1125
1122
out = PyBytes_AS_STRING (str );
1126
- #if MYSQL_VERSION_ID < 32321
1127
- len = mysql_escape_string (out + 1 , in , size );
1128
- #else
1129
1123
check_server_init (NULL );
1130
- if (self && self -> open )
1124
+ if (self && self -> open ) {
1125
+ #if MYSQL_VERSION_ID >= 50706
1126
+ len = mysql_real_escape_string_quote (& (self -> connection ), out + 1 , in , size , '\'' );
1127
+ #else
1131
1128
len = mysql_real_escape_string (& (self -> connection ), out + 1 , in , size );
1132
- else
1133
- len = mysql_escape_string (out + 1 , in , size );
1134
1129
#endif
1130
+ } else {
1131
+ len = mysql_escape_string (out + 1 , in , size );
1132
+ }
1135
1133
* out = * (out + len + 1 ) = '\'' ;
1136
1134
if (_PyBytes_Resize (& str , len + 2 ) < 0 ) return NULL ;
1137
1135
Py_DECREF (s );
@@ -1593,8 +1591,6 @@ _mysql_ResultObject_fetch_row(
1593
1591
return NULL ;
1594
1592
}
1595
1593
1596
- #if MYSQL_VERSION_ID >= 32303
1597
-
1598
1594
static char _mysql_ConnectionObject_change_user__doc__ [] =
1599
1595
"Changes the user and causes the database specified by db to\n\
1600
1596
become the default (current) database on the connection\n\
@@ -1633,7 +1629,6 @@ _mysql_ConnectionObject_change_user(
1633
1629
Py_INCREF (Py_None );
1634
1630
return Py_None ;
1635
1631
}
1636
- #endif
1637
1632
1638
1633
static char _mysql_ConnectionObject_character_set_name__doc__ [] =
1639
1634
"Returns the default character set for the current connection.\n\
@@ -1651,7 +1646,6 @@ _mysql_ConnectionObject_character_set_name(
1651
1646
return PyString_FromString (s );
1652
1647
}
1653
1648
1654
- #if MYSQL_VERSION_ID >= 50007
1655
1649
static char _mysql_ConnectionObject_set_character_set__doc__ [] =
1656
1650
"Sets the default character set for the current connection.\n\
1657
1651
Non-standard.\n\
@@ -1673,7 +1667,6 @@ _mysql_ConnectionObject_set_character_set(
1673
1667
Py_INCREF (Py_None );
1674
1668
return Py_None ;
1675
1669
}
1676
- #endif
1677
1670
1678
1671
#if MYSQL_VERSION_ID >= 50010
1679
1672
static char _mysql_ConnectionObject_get_character_set_info__doc__ [] =
@@ -2039,11 +2032,7 @@ _mysql_ConnectionObject_shutdown(
2039
2032
int r ;
2040
2033
check_connection (self );
2041
2034
Py_BEGIN_ALLOW_THREADS
2042
- r = mysql_shutdown (& (self -> connection )
2043
- #if MYSQL_VERSION_ID >= 40103
2044
- , SHUTDOWN_DEFAULT
2045
- #endif
2046
- );
2035
+ r = mysql_shutdown (& (self -> connection ), SHUTDOWN_DEFAULT );
2047
2036
Py_END_ALLOW_THREADS
2048
2037
if (r ) return _mysql_Exception (self );
2049
2038
Py_INCREF (Py_None );
@@ -2333,14 +2322,12 @@ static PyMethodDef _mysql_ConnectionObject_methods[] = {
2333
2322
METH_NOARGS ,
2334
2323
_mysql_ConnectionObject_character_set_name__doc__
2335
2324
},
2336
- #if MYSQL_VERSION_ID >= 50007
2337
2325
{
2338
2326
"set_character_set" ,
2339
2327
(PyCFunction )_mysql_ConnectionObject_set_character_set ,
2340
2328
METH_VARARGS ,
2341
2329
_mysql_ConnectionObject_set_character_set__doc__
2342
2330
},
2343
- #endif
2344
2331
#if MYSQL_VERSION_ID >= 50010
2345
2332
{
2346
2333
"get_character_set_info" ,
0 commit comments