mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-45243: Add support for setting/getting sqlite3
connection limits (GH-28463)
This commit is contained in:
parent
e2063d6a1e
commit
b6b38a8226
7 changed files with 228 additions and 1 deletions
|
@ -750,6 +750,83 @@ exit:
|
|||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(setlimit__doc__,
|
||||
"setlimit($self, category, limit, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Set connection run-time limits.\n"
|
||||
"\n"
|
||||
" category\n"
|
||||
" The limit category to be set.\n"
|
||||
" limit\n"
|
||||
" The new limit. If the new limit is a negative number, the limit is\n"
|
||||
" unchanged.\n"
|
||||
"\n"
|
||||
"Attempts to increase a limit above its hard upper bound are silently truncated\n"
|
||||
"to the hard upper bound. Regardless of whether or not the limit was changed,\n"
|
||||
"the prior value of the limit is returned.");
|
||||
|
||||
#define SETLIMIT_METHODDEF \
|
||||
{"setlimit", (PyCFunction)(void(*)(void))setlimit, METH_FASTCALL, setlimit__doc__},
|
||||
|
||||
static PyObject *
|
||||
setlimit_impl(pysqlite_Connection *self, int category, int limit);
|
||||
|
||||
static PyObject *
|
||||
setlimit(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
int category;
|
||||
int limit;
|
||||
|
||||
if (!_PyArg_CheckPositional("setlimit", nargs, 2, 2)) {
|
||||
goto exit;
|
||||
}
|
||||
category = _PyLong_AsInt(args[0]);
|
||||
if (category == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
limit = _PyLong_AsInt(args[1]);
|
||||
if (limit == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = setlimit_impl(self, category, limit);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(getlimit__doc__,
|
||||
"getlimit($self, category, /)\n"
|
||||
"--\n"
|
||||
"\n"
|
||||
"Get connection run-time limits.\n"
|
||||
"\n"
|
||||
" category\n"
|
||||
" The limit category to be queried.");
|
||||
|
||||
#define GETLIMIT_METHODDEF \
|
||||
{"getlimit", (PyCFunction)getlimit, METH_O, getlimit__doc__},
|
||||
|
||||
static PyObject *
|
||||
getlimit_impl(pysqlite_Connection *self, int category);
|
||||
|
||||
static PyObject *
|
||||
getlimit(pysqlite_Connection *self, PyObject *arg)
|
||||
{
|
||||
PyObject *return_value = NULL;
|
||||
int category;
|
||||
|
||||
category = _PyLong_AsInt(arg);
|
||||
if (category == -1 && PyErr_Occurred()) {
|
||||
goto exit;
|
||||
}
|
||||
return_value = getlimit_impl(self, category);
|
||||
|
||||
exit:
|
||||
return return_value;
|
||||
}
|
||||
|
||||
#ifndef PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF
|
||||
#define PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF
|
||||
#endif /* !defined(PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF) */
|
||||
|
@ -757,4 +834,4 @@ exit:
|
|||
#ifndef PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
|
||||
#define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
|
||||
#endif /* !defined(PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF) */
|
||||
/*[clinic end generated code: output=7567e5d716309258 input=a9049054013a1b77]*/
|
||||
/*[clinic end generated code: output=0c3901153a3837a5 input=a9049054013a1b77]*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue