mirror of
https://github.com/PyMySQL/mysqlclient.git
synced 2025-08-15 19:31:54 +08:00
Always MYSQL_VERSION_ID >= 50007
This commit is contained in:
30
_mysql.c
30
_mysql.c
@ -251,7 +251,6 @@ static PyObject *_mysql_server_init(
|
|||||||
&cmd_args, &groups))
|
&cmd_args, &groups))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
#if MYSQL_VERSION_ID >= 40000
|
|
||||||
if (cmd_args) {
|
if (cmd_args) {
|
||||||
if (!PySequence_Check(cmd_args)) {
|
if (!PySequence_Check(cmd_args)) {
|
||||||
PyErr_SetString(PyExc_TypeError,
|
PyErr_SetString(PyExc_TypeError,
|
||||||
@ -318,7 +317,6 @@ static PyObject *_mysql_server_init(
|
|||||||
_mysql_Exception(NULL);
|
_mysql_Exception(NULL);
|
||||||
goto finish;
|
goto finish;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
ret = Py_None;
|
ret = Py_None;
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
_mysql_server_init_done = 1;
|
_mysql_server_init_done = 1;
|
||||||
@ -336,9 +334,7 @@ static PyObject *_mysql_server_end(
|
|||||||
PyObject *self,
|
PyObject *self,
|
||||||
PyObject *args) {
|
PyObject *args) {
|
||||||
if (_mysql_server_init_done) {
|
if (_mysql_server_init_done) {
|
||||||
#if MYSQL_VERSION_ID >= 40000
|
|
||||||
mysql_server_end();
|
mysql_server_end();
|
||||||
#endif
|
|
||||||
_mysql_server_init_done = 0;
|
_mysql_server_init_done = 0;
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
@ -1063,9 +1059,6 @@ _mysql_escape_string(
|
|||||||
str = PyBytes_FromStringAndSize((char *) NULL, size*2+1);
|
str = PyBytes_FromStringAndSize((char *) NULL, size*2+1);
|
||||||
if (!str) return PyErr_NoMemory();
|
if (!str) return PyErr_NoMemory();
|
||||||
out = PyBytes_AS_STRING(str);
|
out = PyBytes_AS_STRING(str);
|
||||||
#if MYSQL_VERSION_ID < 32321
|
|
||||||
len = mysql_escape_string(out, in, size);
|
|
||||||
#else
|
|
||||||
check_server_init(NULL);
|
check_server_init(NULL);
|
||||||
|
|
||||||
if (self && PyModule_Check((PyObject*)self))
|
if (self && PyModule_Check((PyObject*)self))
|
||||||
@ -1074,7 +1067,6 @@ _mysql_escape_string(
|
|||||||
len = mysql_real_escape_string(&(self->connection), out, in, size);
|
len = mysql_real_escape_string(&(self->connection), out, in, size);
|
||||||
else
|
else
|
||||||
len = mysql_escape_string(out, in, size);
|
len = mysql_escape_string(out, in, size);
|
||||||
#endif
|
|
||||||
if (_PyBytes_Resize(&str, len) < 0) return NULL;
|
if (_PyBytes_Resize(&str, len) < 0) return NULL;
|
||||||
return (str);
|
return (str);
|
||||||
}
|
}
|
||||||
@ -1123,15 +1115,12 @@ _mysql_string_literal(
|
|||||||
return PyErr_NoMemory();
|
return PyErr_NoMemory();
|
||||||
}
|
}
|
||||||
out = PyBytes_AS_STRING(str);
|
out = PyBytes_AS_STRING(str);
|
||||||
#if MYSQL_VERSION_ID < 32321
|
|
||||||
len = mysql_escape_string(out+1, in, size);
|
|
||||||
#else
|
|
||||||
check_server_init(NULL);
|
check_server_init(NULL);
|
||||||
if (self && self->open)
|
if (self && self->open) {
|
||||||
len = mysql_real_escape_string(&(self->connection), out+1, in, size);
|
len = mysql_real_escape_string(&(self->connection), out+1, in, size);
|
||||||
else
|
} else {
|
||||||
len = mysql_escape_string(out+1, in, size);
|
len = mysql_escape_string(out+1, in, size);
|
||||||
#endif
|
}
|
||||||
*out = *(out+len+1) = '\'';
|
*out = *(out+len+1) = '\'';
|
||||||
if (_PyBytes_Resize(&str, len+2) < 0) return NULL;
|
if (_PyBytes_Resize(&str, len+2) < 0) return NULL;
|
||||||
Py_DECREF(s);
|
Py_DECREF(s);
|
||||||
@ -1593,8 +1582,6 @@ _mysql_ResultObject_fetch_row(
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MYSQL_VERSION_ID >= 32303
|
|
||||||
|
|
||||||
static char _mysql_ConnectionObject_change_user__doc__[] =
|
static char _mysql_ConnectionObject_change_user__doc__[] =
|
||||||
"Changes the user and causes the database specified by db to\n\
|
"Changes the user and causes the database specified by db to\n\
|
||||||
become the default (current) database on the connection\n\
|
become the default (current) database on the connection\n\
|
||||||
@ -1633,7 +1620,6 @@ _mysql_ConnectionObject_change_user(
|
|||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static char _mysql_ConnectionObject_character_set_name__doc__[] =
|
static char _mysql_ConnectionObject_character_set_name__doc__[] =
|
||||||
"Returns the default character set for the current connection.\n\
|
"Returns the default character set for the current connection.\n\
|
||||||
@ -1651,7 +1637,6 @@ _mysql_ConnectionObject_character_set_name(
|
|||||||
return PyString_FromString(s);
|
return PyString_FromString(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MYSQL_VERSION_ID >= 50007
|
|
||||||
static char _mysql_ConnectionObject_set_character_set__doc__[] =
|
static char _mysql_ConnectionObject_set_character_set__doc__[] =
|
||||||
"Sets the default character set for the current connection.\n\
|
"Sets the default character set for the current connection.\n\
|
||||||
Non-standard.\n\
|
Non-standard.\n\
|
||||||
@ -1673,7 +1658,6 @@ _mysql_ConnectionObject_set_character_set(
|
|||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return Py_None;
|
return Py_None;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if MYSQL_VERSION_ID >= 50010
|
#if MYSQL_VERSION_ID >= 50010
|
||||||
static char _mysql_ConnectionObject_get_character_set_info__doc__[] =
|
static char _mysql_ConnectionObject_get_character_set_info__doc__[] =
|
||||||
@ -2039,11 +2023,7 @@ _mysql_ConnectionObject_shutdown(
|
|||||||
int r;
|
int r;
|
||||||
check_connection(self);
|
check_connection(self);
|
||||||
Py_BEGIN_ALLOW_THREADS
|
Py_BEGIN_ALLOW_THREADS
|
||||||
r = mysql_shutdown(&(self->connection)
|
r = mysql_shutdown(&(self->connection), SHUTDOWN_DEFAULT);
|
||||||
#if MYSQL_VERSION_ID >= 40103
|
|
||||||
, SHUTDOWN_DEFAULT
|
|
||||||
#endif
|
|
||||||
);
|
|
||||||
Py_END_ALLOW_THREADS
|
Py_END_ALLOW_THREADS
|
||||||
if (r) return _mysql_Exception(self);
|
if (r) return _mysql_Exception(self);
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
@ -2333,14 +2313,12 @@ static PyMethodDef _mysql_ConnectionObject_methods[] = {
|
|||||||
METH_NOARGS,
|
METH_NOARGS,
|
||||||
_mysql_ConnectionObject_character_set_name__doc__
|
_mysql_ConnectionObject_character_set_name__doc__
|
||||||
},
|
},
|
||||||
#if MYSQL_VERSION_ID >= 50007
|
|
||||||
{
|
{
|
||||||
"set_character_set",
|
"set_character_set",
|
||||||
(PyCFunction)_mysql_ConnectionObject_set_character_set,
|
(PyCFunction)_mysql_ConnectionObject_set_character_set,
|
||||||
METH_VARARGS,
|
METH_VARARGS,
|
||||||
_mysql_ConnectionObject_set_character_set__doc__
|
_mysql_ConnectionObject_set_character_set__doc__
|
||||||
},
|
},
|
||||||
#endif
|
|
||||||
#if MYSQL_VERSION_ID >= 50010
|
#if MYSQL_VERSION_ID >= 50010
|
||||||
{
|
{
|
||||||
"get_character_set_info",
|
"get_character_set_info",
|
||||||
|
Reference in New Issue
Block a user