Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 354b601

Browse filesBrowse files
committed
Remove threadsafe and embedded build options
1 parent 40b8809 commit 354b601
Copy full SHA for 354b601

File tree

Expand file treeCollapse file tree

6 files changed

+15
-221
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+15
-221
lines changed

‎INSTALL.rst

Copy file name to clipboardExpand all lines: INSTALL.rst
+6-17Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,10 @@ Depending on which version of MySQL you have, you may have the option
4242
of using three different client libraries. To select the client library,
4343
edit the [options] section of site.cfg:
4444

45-
embedded
46-
use embedded server library (libmysqld) if True; otherwise use
47-
one of the client libraries (default).
48-
49-
threadsafe
50-
thread-safe client library (libmysqlclient_r) if True (default);
51-
otherwise use non-thread-safe (libmysqlclient). You should
52-
always use the thread-safe library if you have the option;
53-
otherwise you *may* have problems.
54-
5545
static
5646
if True, try to link against a static library; otherwise link
57-
against dynamic libraries (default). You may need static linking
58-
to use the embedded server.
47+
against dynamic libraries (default). You may need static linking
48+
to use the embedded server.
5949
This option doesn't work for MySQL>5.6 since libmysqlclient
6050
requires libstdc++. If you want to use, add `-lstdc++` to
6151
mysql_config manually.
@@ -130,7 +120,7 @@ Debian GNU/Linux
130120

131121
Packaged as `python-mysqldb`_::
132122

133-
# apt-get install python-mysqldb
123+
# apt-get install python-mysqldb
134124

135125
Or use Synaptic.
136126

@@ -148,9 +138,9 @@ Gentoo Linux
148138

149139
Packaged as `mysql-python`_. ::
150140

151-
# emerge sync
152-
# emerge mysql-python
153-
# emerge zmysqlda # if you use Zope
141+
# emerge sync
142+
# emerge mysql-python
143+
# emerge zmysqlda # if you use Zope
154144

155145
.. _`mysql-python`: https://packages.gentoo.org/packages/search?q=mysql-python
156146

@@ -169,4 +159,3 @@ GPL or the original license based on Python 1.5.2's license.
169159

170160

171161
:Author: Andy Dustman <andy@dustman.net>
172-
:Revision: $Id$

‎_mysql.c

Copy file name to clipboardExpand all lines: _mysql.c
+1-148Lines changed: 1 addition & 148 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,6 @@ typedef struct {
9191

9292
extern PyTypeObject _mysql_ResultObject_Type;
9393

94-
static int _mysql_server_init_done = 0;
95-
#define check_server_init(x) if (!_mysql_server_init_done) { if (mysql_server_init(0, NULL, NULL)) { _mysql_Exception(NULL); return x; } else { _mysql_server_init_done = 1;} }
9694

9795
/* According to https://dev.mysql.com/doc/refman/5.1/en/mysql-options.html
9896
The MYSQL_OPT_READ_TIMEOUT appear in the version 5.1.12 */
@@ -107,14 +105,6 @@ _mysql_Exception(_mysql_ConnectionObject *c)
107105
int merr;
108106

109107
if (!(t = PyTuple_New(2))) return NULL;
110-
if (!_mysql_server_init_done) {
111-
e = _mysql_InternalError;
112-
PyTuple_SET_ITEM(t, 0, PyInt_FromLong(-1L));
113-
PyTuple_SET_ITEM(t, 1, PyString_FromString("server not initialized"));
114-
PyErr_SetObject(e, t);
115-
Py_DECREF(t);
116-
return NULL;
117-
}
118108
if (!(c->open)) {
119109
/* GH-270: When connection is closed, accessing the c->connection
120110
* object may cause SEGV.
@@ -219,135 +209,14 @@ _mysql_Exception(_mysql_ConnectionObject *c)
219209
return NULL;
220210
}
221211

222-
static char _mysql_server_init__doc__[] =
223-
"Initialize embedded server. If this client is not linked against\n\
224-
the embedded server library, this function does nothing.\n\
225-
\n\
226-
args -- sequence of command-line arguments\n\
227-
groups -- sequence of groups to use in defaults files\n\
228-
";
229-
230-
static PyObject *_mysql_server_init(
231-
PyObject *self,
232-
PyObject *args,
233-
PyObject *kwargs) {
234-
static char *kwlist[] = {"args", "groups", NULL};
235-
char **cmd_args_c=NULL, **groups_c=NULL, *s;
236-
int cmd_argc=0, i, groupc;
237-
PyObject *cmd_args=NULL, *groups=NULL, *ret=NULL, *item;
238-
239-
if (_mysql_server_init_done) {
240-
PyErr_SetString(_mysql_ProgrammingError,
241-
"already initialized");
242-
return NULL;
243-
}
244-
245-
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO", kwlist,
246-
&cmd_args, &groups))
247-
return NULL;
248-
249-
if (cmd_args) {
250-
if (!PySequence_Check(cmd_args)) {
251-
PyErr_SetString(PyExc_TypeError,
252-
"args must be a sequence");
253-
goto finish;
254-
}
255-
cmd_argc = PySequence_Size(cmd_args);
256-
if (cmd_argc == -1) {
257-
PyErr_SetString(PyExc_TypeError,
258-
"args could not be sized");
259-
goto finish;
260-
}
261-
cmd_args_c = (char **) PyMem_Malloc(cmd_argc*sizeof(char *));
262-
for (i=0; i< cmd_argc; i++) {
263-
item = PySequence_GetItem(cmd_args, i);
264-
#ifdef IS_PY3K
265-
s = PyUnicode_AsUTF8(item);
266-
#else
267-
s = PyString_AsString(item);
268-
#endif
269-
270-
Py_DECREF(item);
271-
if (!s) {
272-
PyErr_SetString(PyExc_TypeError,
273-
"args must contain strings");
274-
goto finish;
275-
}
276-
cmd_args_c[i] = s;
277-
}
278-
}
279-
if (groups) {
280-
if (!PySequence_Check(groups)) {
281-
PyErr_SetString(PyExc_TypeError,
282-
"groups must be a sequence");
283-
goto finish;
284-
}
285-
groupc = PySequence_Size(groups);
286-
if (groupc == -1) {
287-
PyErr_SetString(PyExc_TypeError,
288-
"groups could not be sized");
289-
goto finish;
290-
}
291-
groups_c = (char **) PyMem_Malloc((1+groupc)*sizeof(char *));
292-
for (i=0; i< groupc; i++) {
293-
item = PySequence_GetItem(groups, i);
294-
#ifdef IS_PY3K
295-
s = PyUnicode_AsUTF8(item);
296-
#else
297-
s = PyString_AsString(item);
298-
#endif
299-
Py_DECREF(item);
300-
if (!s) {
301-
PyErr_SetString(PyExc_TypeError,
302-
"groups must contain strings");
303-
goto finish;
304-
}
305-
groups_c[i] = s;
306-
}
307-
groups_c[groupc] = (char *)NULL;
308-
}
309-
/* even though this may block, don't give up the interpreter lock
310-
so that the server can't be initialized multiple times. */
311-
if (mysql_server_init(cmd_argc, cmd_args_c, groups_c)) {
312-
_mysql_Exception(NULL);
313-
goto finish;
314-
}
315-
ret = Py_None;
316-
Py_INCREF(Py_None);
317-
_mysql_server_init_done = 1;
318-
finish:
319-
PyMem_Free(groups_c);
320-
PyMem_Free(cmd_args_c);
321-
return ret;
322-
}
323-
324-
static char _mysql_server_end__doc__[] =
325-
"Shut down embedded server. If not using an embedded server, this\n\
326-
does nothing.";
327-
328-
static PyObject *_mysql_server_end(
329-
PyObject *self,
330-
PyObject *args) {
331-
if (_mysql_server_init_done) {
332-
mysql_server_end();
333-
_mysql_server_init_done = 0;
334-
Py_INCREF(Py_None);
335-
return Py_None;
336-
}
337-
return _mysql_Exception(NULL);
338-
}
339-
340212
static char _mysql_thread_safe__doc__[] =
341213
"Indicates whether the client is compiled as thread-safe.";
342214

343215
static PyObject *_mysql_thread_safe(
344216
PyObject *self,
345217
PyObject *noargs)
346218
{
347-
PyObject *flag;
348-
check_server_init(NULL);
349-
if (!(flag=PyInt_FromLong((long)mysql_thread_safe()))) return NULL;
350-
return flag;
219+
return PyInt_FromLong((long)mysql_thread_safe());
351220
}
352221

353222
static char _mysql_ResultObject__doc__[] =
@@ -530,7 +399,6 @@ _mysql_ConnectionObject_Initialize(
530399

531400
self->converter = NULL;
532401
self->open = 0;
533-
check_server_init(-1);
534402

535403
if (!PyArg_ParseTupleAndKeywords(args, kwargs,
536404
#ifdef HAVE_MYSQL_OPT_TIMEOUTS
@@ -1029,7 +897,6 @@ _mysql_escape_string(
1029897
str = PyBytes_FromStringAndSize((char *) NULL, size*2+1);
1030898
if (!str) return PyErr_NoMemory();
1031899
out = PyBytes_AS_STRING(str);
1032-
check_server_init(NULL);
1033900

1034901
if (self && PyModule_Check((PyObject*)self))
1035902
self = NULL;
@@ -1090,7 +957,6 @@ _mysql_string_literal(
1090957
return PyErr_NoMemory();
1091958
}
1092959
out = PyBytes_AS_STRING(str);
1093-
check_server_init(NULL);
1094960
if (self && self->open) {
1095961
#if MYSQL_VERSION_ID >= 50707 && !defined(MARIADB_BASE_VERSION) && !defined(MARIADB_VERSION_ID)
1096962
len = mysql_real_escape_string_quote(&(self->connection), out+1, in, size, '\'');
@@ -1715,7 +1581,6 @@ _mysql_get_client_info(
17151581
PyObject *self,
17161582
PyObject *noargs)
17171583
{
1718-
check_server_init(NULL);
17191584
return PyString_FromString(mysql_get_client_info());
17201585
}
17211586

@@ -2785,18 +2650,6 @@ _mysql_methods[] = {
27852650
METH_NOARGS,
27862651
_mysql_thread_safe__doc__
27872652
},
2788-
{
2789-
"server_init",
2790-
(PyCFunction)_mysql_server_init,
2791-
METH_VARARGS | METH_KEYWORDS,
2792-
_mysql_server_init__doc__
2793-
},
2794-
{
2795-
"server_end",
2796-
(PyCFunction)_mysql_server_end,
2797-
METH_VARARGS,
2798-
_mysql_server_end__doc__
2799-
},
28002653
{NULL, NULL} /* sentinel */
28012654
};
28022655

‎doc/FAQ.rst

Copy file name to clipboardExpand all lines: doc/FAQ.rst
-7Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@
99
Build Errors
1010
------------
1111

12-
ld: fatal: library -lmysqlclient_r: not found
13-
14-
mysqlclient_r is the thread-safe library. It's not available on
15-
all platforms, or all installations, apparently. You'll need to
16-
reconfigure site.cfg (in MySQLdb-1.2.1 and newer) to have
17-
threadsafe = False.
18-
1912
mysql.h: No such file or directory
2013

2114
This almost always mean you don't have development packages

‎doc/user_guide.rst

Copy file name to clipboardExpand all lines: doc/user_guide.rst
-27Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -680,33 +680,6 @@ SSDictCursor
680680
Like ``SSCursor`` except it returns rows as dictionaries.
681681

682682

683-
Embedded Server
684-
---------------
685-
686-
Instead of connecting to a stand-alone server over the network,
687-
the embedded server support lets you run a full server right in
688-
your Python code or application server.
689-
690-
If you have built MySQLdb with embedded server support, there
691-
are two additional functions you will need to make use of:
692-
693-
server_init(args, groups)
694-
Initialize embedded server. If this client is not linked against
695-
the embedded server library, this function does nothing.
696-
697-
args
698-
sequence of command-line arguments
699-
groups
700-
sequence of groups to use in defaults files
701-
702-
server_end()
703-
Shut down embedded server. If not using an embedded server, this
704-
does nothing.
705-
706-
See the MySQL documentation for more information on the embedded
707-
server.
708-
709-
710683

711684
:Title: MySQLdb: a Python interface for MySQL
712685
:Author: Andy Dustman

‎setup_posix.py

Copy file name to clipboardExpand all lines: setup_posix.py
+7-16Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
try:
33
from ConfigParser import SafeConfigParser
44
except ImportError:
5-
# Probably running Python 3.x
65
from configparser import ConfigParser as SafeConfigParser
76

87
# This dequote() business is required for some older versions
@@ -15,27 +14,29 @@ def dequote(s):
1514
s = s[1:-1]
1615
return s
1716

17+
_mysql_config_path = "mysql_config"
18+
1819
def mysql_config(what):
1920
from os import popen
2021

21-
f = popen("%s --%s" % (mysql_config.path, what))
22+
f = popen("%s --%s" % (_mysql_config_path, what))
2223
data = f.read().strip().split()
2324
ret = f.close()
2425
if ret:
2526
if ret/256:
2627
data = []
2728
if ret/256 > 1:
28-
raise EnvironmentError("%s not found" % (mysql_config.path,))
29+
raise EnvironmentError("%s not found" % (_mysql_config_path,))
2930
return data
30-
mysql_config.path = "mysql_config"
3131

3232
def get_config():
3333
from setup_common import get_metadata_and_options, enabled, create_release_file
34+
global _mysql_config_path
3435

3536
metadata, options = get_metadata_and_options()
3637

3738
if 'mysql_config' in options:
38-
mysql_config.path = options['mysql_config']
39+
_mysql_config_path = options['mysql_config']
3940

4041
extra_objects = []
4142
static = enabled(options, 'static')
@@ -47,15 +48,7 @@ def get_config():
4748
static = True
4849
sys.argv.remove('--static')
4950

50-
if enabled(options, 'embedded'):
51-
libs = mysql_config("libmysqld-libs")
52-
elif enabled(options, 'threadsafe'):
53-
libs = mysql_config("libs_r")
54-
if not libs:
55-
libs = mysql_config("libs")
56-
else:
57-
libs = mysql_config("libs")
58-
51+
libs = mysql_config("libs")
5952
library_dirs = [dequote(i[2:]) for i in libs if i.startswith('-L')]
6053
libraries = [dequote(i[2:]) for i in libs if i.startswith('-l')]
6154
extra_link_args = [x for x in libs if not x.startswith(('-l', '-L'))]
@@ -92,8 +85,6 @@ def get_config():
9285
libraries.remove(client)
9386

9487
name = "mysqlclient"
95-
if enabled(options, 'embedded'):
96-
name = name + "-embedded"
9788
metadata['name'] = name
9889

9990
define_macros = [

‎site.cfg

Copy file name to clipboardExpand all lines: site.cfg
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
[options]
2-
# embedded: link against the embedded server library
3-
# threadsafe: use the threadsafe client
4-
# static: link against a static library (probably required for embedded)
5-
6-
embedded = False
7-
threadsafe = True
2+
# static: link against a static library
83
static = False
94

105
# The path to mysql_config.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.