Path: blob/main/Modules/_sqlite/clinic/connection.c.h
12 views
/*[clinic input]1preserve2[clinic start generated code]*/34#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)5# include "pycore_gc.h" // PyGC_Head6# include "pycore_runtime.h" // _Py_ID()7#endif8910static int11pysqlite_connection_init_impl(pysqlite_Connection *self, PyObject *database,12double timeout, int detect_types,13const char *isolation_level,14int check_same_thread, PyObject *factory,15int cache_size, int uri,16enum autocommit_mode autocommit);1718static int19pysqlite_connection_init(PyObject *self, PyObject *args, PyObject *kwargs)20{21int return_value = -1;22#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)2324#define NUM_KEYWORDS 925static struct {26PyGC_Head _this_is_not_used;27PyObject_VAR_HEAD28PyObject *ob_item[NUM_KEYWORDS];29} _kwtuple = {30.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)31.ob_item = { &_Py_ID(database), &_Py_ID(timeout), &_Py_ID(detect_types), &_Py_ID(isolation_level), &_Py_ID(check_same_thread), &_Py_ID(factory), &_Py_ID(cached_statements), &_Py_ID(uri), &_Py_ID(autocommit), },32};33#undef NUM_KEYWORDS34#define KWTUPLE (&_kwtuple.ob_base.ob_base)3536#else // !Py_BUILD_CORE37# define KWTUPLE NULL38#endif // !Py_BUILD_CORE3940static const char * const _keywords[] = {"database", "timeout", "detect_types", "isolation_level", "check_same_thread", "factory", "cached_statements", "uri", "autocommit", NULL};41static _PyArg_Parser _parser = {42.keywords = _keywords,43.fname = "Connection",44.kwtuple = KWTUPLE,45};46#undef KWTUPLE47PyObject *argsbuf[9];48PyObject * const *fastargs;49Py_ssize_t nargs = PyTuple_GET_SIZE(args);50Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;51PyObject *database;52double timeout = 5.0;53int detect_types = 0;54const char *isolation_level = "";55int check_same_thread = 1;56PyObject *factory = (PyObject*)clinic_state()->ConnectionType;57int cache_size = 128;58int uri = 0;59enum autocommit_mode autocommit = LEGACY_TRANSACTION_CONTROL;6061fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 8, 0, argsbuf);62if (!fastargs) {63goto exit;64}65database = fastargs[0];66if (!noptargs) {67goto skip_optional_pos;68}69if (fastargs[1]) {70if (PyFloat_CheckExact(fastargs[1])) {71timeout = PyFloat_AS_DOUBLE(fastargs[1]);72}73else74{75timeout = PyFloat_AsDouble(fastargs[1]);76if (timeout == -1.0 && PyErr_Occurred()) {77goto exit;78}79}80if (!--noptargs) {81goto skip_optional_pos;82}83}84if (fastargs[2]) {85detect_types = _PyLong_AsInt(fastargs[2]);86if (detect_types == -1 && PyErr_Occurred()) {87goto exit;88}89if (!--noptargs) {90goto skip_optional_pos;91}92}93if (fastargs[3]) {94if (!isolation_level_converter(fastargs[3], &isolation_level)) {95goto exit;96}97if (!--noptargs) {98goto skip_optional_pos;99}100}101if (fastargs[4]) {102check_same_thread = PyObject_IsTrue(fastargs[4]);103if (check_same_thread < 0) {104goto exit;105}106if (!--noptargs) {107goto skip_optional_pos;108}109}110if (fastargs[5]) {111factory = fastargs[5];112if (!--noptargs) {113goto skip_optional_pos;114}115}116if (fastargs[6]) {117cache_size = _PyLong_AsInt(fastargs[6]);118if (cache_size == -1 && PyErr_Occurred()) {119goto exit;120}121if (!--noptargs) {122goto skip_optional_pos;123}124}125if (fastargs[7]) {126uri = PyObject_IsTrue(fastargs[7]);127if (uri < 0) {128goto exit;129}130if (!--noptargs) {131goto skip_optional_pos;132}133}134skip_optional_pos:135if (!noptargs) {136goto skip_optional_kwonly;137}138if (!autocommit_converter(fastargs[8], &autocommit)) {139goto exit;140}141skip_optional_kwonly:142return_value = pysqlite_connection_init_impl((pysqlite_Connection *)self, database, timeout, detect_types, isolation_level, check_same_thread, factory, cache_size, uri, autocommit);143144exit:145return return_value;146}147148PyDoc_STRVAR(pysqlite_connection_cursor__doc__,149"cursor($self, /, factory=<unrepresentable>)\n"150"--\n"151"\n"152"Return a cursor for the connection.");153154#define PYSQLITE_CONNECTION_CURSOR_METHODDEF \155{"cursor", _PyCFunction_CAST(pysqlite_connection_cursor), METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_cursor__doc__},156157static PyObject *158pysqlite_connection_cursor_impl(pysqlite_Connection *self, PyObject *factory);159160static PyObject *161pysqlite_connection_cursor(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)162{163PyObject *return_value = NULL;164#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)165166#define NUM_KEYWORDS 1167static struct {168PyGC_Head _this_is_not_used;169PyObject_VAR_HEAD170PyObject *ob_item[NUM_KEYWORDS];171} _kwtuple = {172.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)173.ob_item = { &_Py_ID(factory), },174};175#undef NUM_KEYWORDS176#define KWTUPLE (&_kwtuple.ob_base.ob_base)177178#else // !Py_BUILD_CORE179# define KWTUPLE NULL180#endif // !Py_BUILD_CORE181182static const char * const _keywords[] = {"factory", NULL};183static _PyArg_Parser _parser = {184.keywords = _keywords,185.fname = "cursor",186.kwtuple = KWTUPLE,187};188#undef KWTUPLE189PyObject *argsbuf[1];190Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;191PyObject *factory = NULL;192193args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);194if (!args) {195goto exit;196}197if (!noptargs) {198goto skip_optional_pos;199}200factory = args[0];201skip_optional_pos:202return_value = pysqlite_connection_cursor_impl(self, factory);203204exit:205return return_value;206}207208PyDoc_STRVAR(blobopen__doc__,209"blobopen($self, table, column, row, /, *, readonly=False, name=\'main\')\n"210"--\n"211"\n"212"Open and return a BLOB object.\n"213"\n"214" table\n"215" Table name.\n"216" column\n"217" Column name.\n"218" row\n"219" Row index.\n"220" readonly\n"221" Open the BLOB without write permissions.\n"222" name\n"223" Database name.");224225#define BLOBOPEN_METHODDEF \226{"blobopen", _PyCFunction_CAST(blobopen), METH_FASTCALL|METH_KEYWORDS, blobopen__doc__},227228static PyObject *229blobopen_impl(pysqlite_Connection *self, const char *table, const char *col,230sqlite3_int64 row, int readonly, const char *name);231232static PyObject *233blobopen(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)234{235PyObject *return_value = NULL;236#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)237238#define NUM_KEYWORDS 2239static struct {240PyGC_Head _this_is_not_used;241PyObject_VAR_HEAD242PyObject *ob_item[NUM_KEYWORDS];243} _kwtuple = {244.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)245.ob_item = { &_Py_ID(readonly), &_Py_ID(name), },246};247#undef NUM_KEYWORDS248#define KWTUPLE (&_kwtuple.ob_base.ob_base)249250#else // !Py_BUILD_CORE251# define KWTUPLE NULL252#endif // !Py_BUILD_CORE253254static const char * const _keywords[] = {"", "", "", "readonly", "name", NULL};255static _PyArg_Parser _parser = {256.keywords = _keywords,257.fname = "blobopen",258.kwtuple = KWTUPLE,259};260#undef KWTUPLE261PyObject *argsbuf[5];262Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;263const char *table;264const char *col;265sqlite3_int64 row;266int readonly = 0;267const char *name = "main";268269args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);270if (!args) {271goto exit;272}273if (!PyUnicode_Check(args[0])) {274_PyArg_BadArgument("blobopen", "argument 1", "str", args[0]);275goto exit;276}277Py_ssize_t table_length;278table = PyUnicode_AsUTF8AndSize(args[0], &table_length);279if (table == NULL) {280goto exit;281}282if (strlen(table) != (size_t)table_length) {283PyErr_SetString(PyExc_ValueError, "embedded null character");284goto exit;285}286if (!PyUnicode_Check(args[1])) {287_PyArg_BadArgument("blobopen", "argument 2", "str", args[1]);288goto exit;289}290Py_ssize_t col_length;291col = PyUnicode_AsUTF8AndSize(args[1], &col_length);292if (col == NULL) {293goto exit;294}295if (strlen(col) != (size_t)col_length) {296PyErr_SetString(PyExc_ValueError, "embedded null character");297goto exit;298}299if (!sqlite3_int64_converter(args[2], &row)) {300goto exit;301}302if (!noptargs) {303goto skip_optional_kwonly;304}305if (args[3]) {306readonly = PyObject_IsTrue(args[3]);307if (readonly < 0) {308goto exit;309}310if (!--noptargs) {311goto skip_optional_kwonly;312}313}314if (!PyUnicode_Check(args[4])) {315_PyArg_BadArgument("blobopen", "argument 'name'", "str", args[4]);316goto exit;317}318Py_ssize_t name_length;319name = PyUnicode_AsUTF8AndSize(args[4], &name_length);320if (name == NULL) {321goto exit;322}323if (strlen(name) != (size_t)name_length) {324PyErr_SetString(PyExc_ValueError, "embedded null character");325goto exit;326}327skip_optional_kwonly:328return_value = blobopen_impl(self, table, col, row, readonly, name);329330exit:331return return_value;332}333334PyDoc_STRVAR(pysqlite_connection_close__doc__,335"close($self, /)\n"336"--\n"337"\n"338"Close the database connection.\n"339"\n"340"Any pending transaction is not committed implicitly.");341342#define PYSQLITE_CONNECTION_CLOSE_METHODDEF \343{"close", (PyCFunction)pysqlite_connection_close, METH_NOARGS, pysqlite_connection_close__doc__},344345static PyObject *346pysqlite_connection_close_impl(pysqlite_Connection *self);347348static PyObject *349pysqlite_connection_close(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))350{351return pysqlite_connection_close_impl(self);352}353354PyDoc_STRVAR(pysqlite_connection_commit__doc__,355"commit($self, /)\n"356"--\n"357"\n"358"Commit any pending transaction to the database.\n"359"\n"360"If there is no open transaction, this method is a no-op.");361362#define PYSQLITE_CONNECTION_COMMIT_METHODDEF \363{"commit", (PyCFunction)pysqlite_connection_commit, METH_NOARGS, pysqlite_connection_commit__doc__},364365static PyObject *366pysqlite_connection_commit_impl(pysqlite_Connection *self);367368static PyObject *369pysqlite_connection_commit(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))370{371return pysqlite_connection_commit_impl(self);372}373374PyDoc_STRVAR(pysqlite_connection_rollback__doc__,375"rollback($self, /)\n"376"--\n"377"\n"378"Roll back to the start of any pending transaction.\n"379"\n"380"If there is no open transaction, this method is a no-op.");381382#define PYSQLITE_CONNECTION_ROLLBACK_METHODDEF \383{"rollback", (PyCFunction)pysqlite_connection_rollback, METH_NOARGS, pysqlite_connection_rollback__doc__},384385static PyObject *386pysqlite_connection_rollback_impl(pysqlite_Connection *self);387388static PyObject *389pysqlite_connection_rollback(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))390{391return pysqlite_connection_rollback_impl(self);392}393394PyDoc_STRVAR(pysqlite_connection_create_function__doc__,395"create_function($self, /, name, narg, func, *, deterministic=False)\n"396"--\n"397"\n"398"Creates a new function.");399400#define PYSQLITE_CONNECTION_CREATE_FUNCTION_METHODDEF \401{"create_function", _PyCFunction_CAST(pysqlite_connection_create_function), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_function__doc__},402403static PyObject *404pysqlite_connection_create_function_impl(pysqlite_Connection *self,405PyTypeObject *cls, const char *name,406int narg, PyObject *func,407int deterministic);408409static PyObject *410pysqlite_connection_create_function(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)411{412PyObject *return_value = NULL;413#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)414415#define NUM_KEYWORDS 4416static struct {417PyGC_Head _this_is_not_used;418PyObject_VAR_HEAD419PyObject *ob_item[NUM_KEYWORDS];420} _kwtuple = {421.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)422.ob_item = { &_Py_ID(name), &_Py_ID(narg), &_Py_ID(func), &_Py_ID(deterministic), },423};424#undef NUM_KEYWORDS425#define KWTUPLE (&_kwtuple.ob_base.ob_base)426427#else // !Py_BUILD_CORE428# define KWTUPLE NULL429#endif // !Py_BUILD_CORE430431static const char * const _keywords[] = {"name", "narg", "func", "deterministic", NULL};432static _PyArg_Parser _parser = {433.keywords = _keywords,434.fname = "create_function",435.kwtuple = KWTUPLE,436};437#undef KWTUPLE438PyObject *argsbuf[4];439Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;440const char *name;441int narg;442PyObject *func;443int deterministic = 0;444445args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);446if (!args) {447goto exit;448}449if (!PyUnicode_Check(args[0])) {450_PyArg_BadArgument("create_function", "argument 'name'", "str", args[0]);451goto exit;452}453Py_ssize_t name_length;454name = PyUnicode_AsUTF8AndSize(args[0], &name_length);455if (name == NULL) {456goto exit;457}458if (strlen(name) != (size_t)name_length) {459PyErr_SetString(PyExc_ValueError, "embedded null character");460goto exit;461}462narg = _PyLong_AsInt(args[1]);463if (narg == -1 && PyErr_Occurred()) {464goto exit;465}466func = args[2];467if (!noptargs) {468goto skip_optional_kwonly;469}470deterministic = PyObject_IsTrue(args[3]);471if (deterministic < 0) {472goto exit;473}474skip_optional_kwonly:475return_value = pysqlite_connection_create_function_impl(self, cls, name, narg, func, deterministic);476477exit:478return return_value;479}480481#if defined(HAVE_WINDOW_FUNCTIONS)482483PyDoc_STRVAR(create_window_function__doc__,484"create_window_function($self, name, num_params, aggregate_class, /)\n"485"--\n"486"\n"487"Creates or redefines an aggregate window function. Non-standard.\n"488"\n"489" name\n"490" The name of the SQL aggregate window function to be created or\n"491" redefined.\n"492" num_params\n"493" The number of arguments the step and inverse methods takes.\n"494" aggregate_class\n"495" A class with step(), finalize(), value(), and inverse() methods.\n"496" Set to None to clear the window function.");497498#define CREATE_WINDOW_FUNCTION_METHODDEF \499{"create_window_function", _PyCFunction_CAST(create_window_function), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, create_window_function__doc__},500501static PyObject *502create_window_function_impl(pysqlite_Connection *self, PyTypeObject *cls,503const char *name, int num_params,504PyObject *aggregate_class);505506static PyObject *507create_window_function(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)508{509PyObject *return_value = NULL;510#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)511# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)512#else513# define KWTUPLE NULL514#endif515516static const char * const _keywords[] = {"", "", "", NULL};517static _PyArg_Parser _parser = {518.keywords = _keywords,519.fname = "create_window_function",520.kwtuple = KWTUPLE,521};522#undef KWTUPLE523PyObject *argsbuf[3];524const char *name;525int num_params;526PyObject *aggregate_class;527528args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);529if (!args) {530goto exit;531}532if (!PyUnicode_Check(args[0])) {533_PyArg_BadArgument("create_window_function", "argument 1", "str", args[0]);534goto exit;535}536Py_ssize_t name_length;537name = PyUnicode_AsUTF8AndSize(args[0], &name_length);538if (name == NULL) {539goto exit;540}541if (strlen(name) != (size_t)name_length) {542PyErr_SetString(PyExc_ValueError, "embedded null character");543goto exit;544}545num_params = _PyLong_AsInt(args[1]);546if (num_params == -1 && PyErr_Occurred()) {547goto exit;548}549aggregate_class = args[2];550return_value = create_window_function_impl(self, cls, name, num_params, aggregate_class);551552exit:553return return_value;554}555556#endif /* defined(HAVE_WINDOW_FUNCTIONS) */557558PyDoc_STRVAR(pysqlite_connection_create_aggregate__doc__,559"create_aggregate($self, /, name, n_arg, aggregate_class)\n"560"--\n"561"\n"562"Creates a new aggregate.");563564#define PYSQLITE_CONNECTION_CREATE_AGGREGATE_METHODDEF \565{"create_aggregate", _PyCFunction_CAST(pysqlite_connection_create_aggregate), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_aggregate__doc__},566567static PyObject *568pysqlite_connection_create_aggregate_impl(pysqlite_Connection *self,569PyTypeObject *cls,570const char *name, int n_arg,571PyObject *aggregate_class);572573static PyObject *574pysqlite_connection_create_aggregate(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)575{576PyObject *return_value = NULL;577#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)578579#define NUM_KEYWORDS 3580static struct {581PyGC_Head _this_is_not_used;582PyObject_VAR_HEAD583PyObject *ob_item[NUM_KEYWORDS];584} _kwtuple = {585.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)586.ob_item = { &_Py_ID(name), &_Py_ID(n_arg), &_Py_ID(aggregate_class), },587};588#undef NUM_KEYWORDS589#define KWTUPLE (&_kwtuple.ob_base.ob_base)590591#else // !Py_BUILD_CORE592# define KWTUPLE NULL593#endif // !Py_BUILD_CORE594595static const char * const _keywords[] = {"name", "n_arg", "aggregate_class", NULL};596static _PyArg_Parser _parser = {597.keywords = _keywords,598.fname = "create_aggregate",599.kwtuple = KWTUPLE,600};601#undef KWTUPLE602PyObject *argsbuf[3];603const char *name;604int n_arg;605PyObject *aggregate_class;606607args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);608if (!args) {609goto exit;610}611if (!PyUnicode_Check(args[0])) {612_PyArg_BadArgument("create_aggregate", "argument 'name'", "str", args[0]);613goto exit;614}615Py_ssize_t name_length;616name = PyUnicode_AsUTF8AndSize(args[0], &name_length);617if (name == NULL) {618goto exit;619}620if (strlen(name) != (size_t)name_length) {621PyErr_SetString(PyExc_ValueError, "embedded null character");622goto exit;623}624n_arg = _PyLong_AsInt(args[1]);625if (n_arg == -1 && PyErr_Occurred()) {626goto exit;627}628aggregate_class = args[2];629return_value = pysqlite_connection_create_aggregate_impl(self, cls, name, n_arg, aggregate_class);630631exit:632return return_value;633}634635PyDoc_STRVAR(pysqlite_connection_set_authorizer__doc__,636"set_authorizer($self, /, authorizer_callback)\n"637"--\n"638"\n"639"Sets authorizer callback.");640641#define PYSQLITE_CONNECTION_SET_AUTHORIZER_METHODDEF \642{"set_authorizer", _PyCFunction_CAST(pysqlite_connection_set_authorizer), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_authorizer__doc__},643644static PyObject *645pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self,646PyTypeObject *cls,647PyObject *callable);648649static PyObject *650pysqlite_connection_set_authorizer(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)651{652PyObject *return_value = NULL;653#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)654655#define NUM_KEYWORDS 1656static struct {657PyGC_Head _this_is_not_used;658PyObject_VAR_HEAD659PyObject *ob_item[NUM_KEYWORDS];660} _kwtuple = {661.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)662.ob_item = { &_Py_ID(authorizer_callback), },663};664#undef NUM_KEYWORDS665#define KWTUPLE (&_kwtuple.ob_base.ob_base)666667#else // !Py_BUILD_CORE668# define KWTUPLE NULL669#endif // !Py_BUILD_CORE670671static const char * const _keywords[] = {"authorizer_callback", NULL};672static _PyArg_Parser _parser = {673.keywords = _keywords,674.fname = "set_authorizer",675.kwtuple = KWTUPLE,676};677#undef KWTUPLE678PyObject *argsbuf[1];679PyObject *callable;680681args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);682if (!args) {683goto exit;684}685callable = args[0];686return_value = pysqlite_connection_set_authorizer_impl(self, cls, callable);687688exit:689return return_value;690}691692PyDoc_STRVAR(pysqlite_connection_set_progress_handler__doc__,693"set_progress_handler($self, /, progress_handler, n)\n"694"--\n"695"\n"696"Sets progress handler callback.");697698#define PYSQLITE_CONNECTION_SET_PROGRESS_HANDLER_METHODDEF \699{"set_progress_handler", _PyCFunction_CAST(pysqlite_connection_set_progress_handler), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_progress_handler__doc__},700701static PyObject *702pysqlite_connection_set_progress_handler_impl(pysqlite_Connection *self,703PyTypeObject *cls,704PyObject *callable, int n);705706static PyObject *707pysqlite_connection_set_progress_handler(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)708{709PyObject *return_value = NULL;710#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)711712#define NUM_KEYWORDS 2713static struct {714PyGC_Head _this_is_not_used;715PyObject_VAR_HEAD716PyObject *ob_item[NUM_KEYWORDS];717} _kwtuple = {718.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)719.ob_item = { &_Py_ID(progress_handler), &_Py_ID(n), },720};721#undef NUM_KEYWORDS722#define KWTUPLE (&_kwtuple.ob_base.ob_base)723724#else // !Py_BUILD_CORE725# define KWTUPLE NULL726#endif // !Py_BUILD_CORE727728static const char * const _keywords[] = {"progress_handler", "n", NULL};729static _PyArg_Parser _parser = {730.keywords = _keywords,731.fname = "set_progress_handler",732.kwtuple = KWTUPLE,733};734#undef KWTUPLE735PyObject *argsbuf[2];736PyObject *callable;737int n;738739args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);740if (!args) {741goto exit;742}743callable = args[0];744n = _PyLong_AsInt(args[1]);745if (n == -1 && PyErr_Occurred()) {746goto exit;747}748return_value = pysqlite_connection_set_progress_handler_impl(self, cls, callable, n);749750exit:751return return_value;752}753754PyDoc_STRVAR(pysqlite_connection_set_trace_callback__doc__,755"set_trace_callback($self, /, trace_callback)\n"756"--\n"757"\n"758"Sets a trace callback called for each SQL statement (passed as unicode).");759760#define PYSQLITE_CONNECTION_SET_TRACE_CALLBACK_METHODDEF \761{"set_trace_callback", _PyCFunction_CAST(pysqlite_connection_set_trace_callback), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_trace_callback__doc__},762763static PyObject *764pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,765PyTypeObject *cls,766PyObject *callable);767768static PyObject *769pysqlite_connection_set_trace_callback(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)770{771PyObject *return_value = NULL;772#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)773774#define NUM_KEYWORDS 1775static struct {776PyGC_Head _this_is_not_used;777PyObject_VAR_HEAD778PyObject *ob_item[NUM_KEYWORDS];779} _kwtuple = {780.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)781.ob_item = { &_Py_ID(trace_callback), },782};783#undef NUM_KEYWORDS784#define KWTUPLE (&_kwtuple.ob_base.ob_base)785786#else // !Py_BUILD_CORE787# define KWTUPLE NULL788#endif // !Py_BUILD_CORE789790static const char * const _keywords[] = {"trace_callback", NULL};791static _PyArg_Parser _parser = {792.keywords = _keywords,793.fname = "set_trace_callback",794.kwtuple = KWTUPLE,795};796#undef KWTUPLE797PyObject *argsbuf[1];798PyObject *callable;799800args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);801if (!args) {802goto exit;803}804callable = args[0];805return_value = pysqlite_connection_set_trace_callback_impl(self, cls, callable);806807exit:808return return_value;809}810811#if defined(PY_SQLITE_ENABLE_LOAD_EXTENSION)812813PyDoc_STRVAR(pysqlite_connection_enable_load_extension__doc__,814"enable_load_extension($self, enable, /)\n"815"--\n"816"\n"817"Enable dynamic loading of SQLite extension modules.");818819#define PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF \820{"enable_load_extension", (PyCFunction)pysqlite_connection_enable_load_extension, METH_O, pysqlite_connection_enable_load_extension__doc__},821822static PyObject *823pysqlite_connection_enable_load_extension_impl(pysqlite_Connection *self,824int onoff);825826static PyObject *827pysqlite_connection_enable_load_extension(pysqlite_Connection *self, PyObject *arg)828{829PyObject *return_value = NULL;830int onoff;831832onoff = PyObject_IsTrue(arg);833if (onoff < 0) {834goto exit;835}836return_value = pysqlite_connection_enable_load_extension_impl(self, onoff);837838exit:839return return_value;840}841842#endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */843844#if defined(PY_SQLITE_ENABLE_LOAD_EXTENSION)845846PyDoc_STRVAR(pysqlite_connection_load_extension__doc__,847"load_extension($self, name, /, *, entrypoint=None)\n"848"--\n"849"\n"850"Load SQLite extension module.");851852#define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF \853{"load_extension", _PyCFunction_CAST(pysqlite_connection_load_extension), METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_load_extension__doc__},854855static PyObject *856pysqlite_connection_load_extension_impl(pysqlite_Connection *self,857const char *extension_name,858const char *entrypoint);859860static PyObject *861pysqlite_connection_load_extension(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)862{863PyObject *return_value = NULL;864#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)865866#define NUM_KEYWORDS 1867static struct {868PyGC_Head _this_is_not_used;869PyObject_VAR_HEAD870PyObject *ob_item[NUM_KEYWORDS];871} _kwtuple = {872.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)873.ob_item = { &_Py_ID(entrypoint), },874};875#undef NUM_KEYWORDS876#define KWTUPLE (&_kwtuple.ob_base.ob_base)877878#else // !Py_BUILD_CORE879# define KWTUPLE NULL880#endif // !Py_BUILD_CORE881882static const char * const _keywords[] = {"", "entrypoint", NULL};883static _PyArg_Parser _parser = {884.keywords = _keywords,885.fname = "load_extension",886.kwtuple = KWTUPLE,887};888#undef KWTUPLE889PyObject *argsbuf[2];890Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;891const char *extension_name;892const char *entrypoint = NULL;893894args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);895if (!args) {896goto exit;897}898if (!PyUnicode_Check(args[0])) {899_PyArg_BadArgument("load_extension", "argument 1", "str", args[0]);900goto exit;901}902Py_ssize_t extension_name_length;903extension_name = PyUnicode_AsUTF8AndSize(args[0], &extension_name_length);904if (extension_name == NULL) {905goto exit;906}907if (strlen(extension_name) != (size_t)extension_name_length) {908PyErr_SetString(PyExc_ValueError, "embedded null character");909goto exit;910}911if (!noptargs) {912goto skip_optional_kwonly;913}914if (args[1] == Py_None) {915entrypoint = NULL;916}917else if (PyUnicode_Check(args[1])) {918Py_ssize_t entrypoint_length;919entrypoint = PyUnicode_AsUTF8AndSize(args[1], &entrypoint_length);920if (entrypoint == NULL) {921goto exit;922}923if (strlen(entrypoint) != (size_t)entrypoint_length) {924PyErr_SetString(PyExc_ValueError, "embedded null character");925goto exit;926}927}928else {929_PyArg_BadArgument("load_extension", "argument 'entrypoint'", "str or None", args[1]);930goto exit;931}932skip_optional_kwonly:933return_value = pysqlite_connection_load_extension_impl(self, extension_name, entrypoint);934935exit:936return return_value;937}938939#endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */940941PyDoc_STRVAR(pysqlite_connection_execute__doc__,942"execute($self, sql, parameters=<unrepresentable>, /)\n"943"--\n"944"\n"945"Executes an SQL statement.");946947#define PYSQLITE_CONNECTION_EXECUTE_METHODDEF \948{"execute", _PyCFunction_CAST(pysqlite_connection_execute), METH_FASTCALL, pysqlite_connection_execute__doc__},949950static PyObject *951pysqlite_connection_execute_impl(pysqlite_Connection *self, PyObject *sql,952PyObject *parameters);953954static PyObject *955pysqlite_connection_execute(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)956{957PyObject *return_value = NULL;958PyObject *sql;959PyObject *parameters = NULL;960961if (!_PyArg_CheckPositional("execute", nargs, 1, 2)) {962goto exit;963}964if (!PyUnicode_Check(args[0])) {965_PyArg_BadArgument("execute", "argument 1", "str", args[0]);966goto exit;967}968sql = args[0];969if (nargs < 2) {970goto skip_optional;971}972parameters = args[1];973skip_optional:974return_value = pysqlite_connection_execute_impl(self, sql, parameters);975976exit:977return return_value;978}979980PyDoc_STRVAR(pysqlite_connection_executemany__doc__,981"executemany($self, sql, parameters, /)\n"982"--\n"983"\n"984"Repeatedly executes an SQL statement.");985986#define PYSQLITE_CONNECTION_EXECUTEMANY_METHODDEF \987{"executemany", _PyCFunction_CAST(pysqlite_connection_executemany), METH_FASTCALL, pysqlite_connection_executemany__doc__},988989static PyObject *990pysqlite_connection_executemany_impl(pysqlite_Connection *self,991PyObject *sql, PyObject *parameters);992993static PyObject *994pysqlite_connection_executemany(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)995{996PyObject *return_value = NULL;997PyObject *sql;998PyObject *parameters;9991000if (!_PyArg_CheckPositional("executemany", nargs, 2, 2)) {1001goto exit;1002}1003if (!PyUnicode_Check(args[0])) {1004_PyArg_BadArgument("executemany", "argument 1", "str", args[0]);1005goto exit;1006}1007sql = args[0];1008parameters = args[1];1009return_value = pysqlite_connection_executemany_impl(self, sql, parameters);10101011exit:1012return return_value;1013}10141015PyDoc_STRVAR(pysqlite_connection_executescript__doc__,1016"executescript($self, sql_script, /)\n"1017"--\n"1018"\n"1019"Executes multiple SQL statements at once.");10201021#define PYSQLITE_CONNECTION_EXECUTESCRIPT_METHODDEF \1022{"executescript", (PyCFunction)pysqlite_connection_executescript, METH_O, pysqlite_connection_executescript__doc__},10231024PyDoc_STRVAR(pysqlite_connection_interrupt__doc__,1025"interrupt($self, /)\n"1026"--\n"1027"\n"1028"Abort any pending database operation.");10291030#define PYSQLITE_CONNECTION_INTERRUPT_METHODDEF \1031{"interrupt", (PyCFunction)pysqlite_connection_interrupt, METH_NOARGS, pysqlite_connection_interrupt__doc__},10321033static PyObject *1034pysqlite_connection_interrupt_impl(pysqlite_Connection *self);10351036static PyObject *1037pysqlite_connection_interrupt(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))1038{1039return pysqlite_connection_interrupt_impl(self);1040}10411042PyDoc_STRVAR(pysqlite_connection_iterdump__doc__,1043"iterdump($self, /)\n"1044"--\n"1045"\n"1046"Returns iterator to the dump of the database in an SQL text format.");10471048#define PYSQLITE_CONNECTION_ITERDUMP_METHODDEF \1049{"iterdump", (PyCFunction)pysqlite_connection_iterdump, METH_NOARGS, pysqlite_connection_iterdump__doc__},10501051static PyObject *1052pysqlite_connection_iterdump_impl(pysqlite_Connection *self);10531054static PyObject *1055pysqlite_connection_iterdump(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))1056{1057return pysqlite_connection_iterdump_impl(self);1058}10591060PyDoc_STRVAR(pysqlite_connection_backup__doc__,1061"backup($self, /, target, *, pages=-1, progress=None, name=\'main\',\n"1062" sleep=0.25)\n"1063"--\n"1064"\n"1065"Makes a backup of the database.");10661067#define PYSQLITE_CONNECTION_BACKUP_METHODDEF \1068{"backup", _PyCFunction_CAST(pysqlite_connection_backup), METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_backup__doc__},10691070static PyObject *1071pysqlite_connection_backup_impl(pysqlite_Connection *self,1072pysqlite_Connection *target, int pages,1073PyObject *progress, const char *name,1074double sleep);10751076static PyObject *1077pysqlite_connection_backup(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)1078{1079PyObject *return_value = NULL;1080#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)10811082#define NUM_KEYWORDS 51083static struct {1084PyGC_Head _this_is_not_used;1085PyObject_VAR_HEAD1086PyObject *ob_item[NUM_KEYWORDS];1087} _kwtuple = {1088.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)1089.ob_item = { &_Py_ID(target), &_Py_ID(pages), &_Py_ID(progress), &_Py_ID(name), &_Py_ID(sleep), },1090};1091#undef NUM_KEYWORDS1092#define KWTUPLE (&_kwtuple.ob_base.ob_base)10931094#else // !Py_BUILD_CORE1095# define KWTUPLE NULL1096#endif // !Py_BUILD_CORE10971098static const char * const _keywords[] = {"target", "pages", "progress", "name", "sleep", NULL};1099static _PyArg_Parser _parser = {1100.keywords = _keywords,1101.fname = "backup",1102.kwtuple = KWTUPLE,1103};1104#undef KWTUPLE1105PyObject *argsbuf[5];1106Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;1107pysqlite_Connection *target;1108int pages = -1;1109PyObject *progress = Py_None;1110const char *name = "main";1111double sleep = 0.25;11121113args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);1114if (!args) {1115goto exit;1116}1117if (!PyObject_TypeCheck(args[0], clinic_state()->ConnectionType)) {1118_PyArg_BadArgument("backup", "argument 'target'", (clinic_state()->ConnectionType)->tp_name, args[0]);1119goto exit;1120}1121target = (pysqlite_Connection *)args[0];1122if (!noptargs) {1123goto skip_optional_kwonly;1124}1125if (args[1]) {1126pages = _PyLong_AsInt(args[1]);1127if (pages == -1 && PyErr_Occurred()) {1128goto exit;1129}1130if (!--noptargs) {1131goto skip_optional_kwonly;1132}1133}1134if (args[2]) {1135progress = args[2];1136if (!--noptargs) {1137goto skip_optional_kwonly;1138}1139}1140if (args[3]) {1141if (!PyUnicode_Check(args[3])) {1142_PyArg_BadArgument("backup", "argument 'name'", "str", args[3]);1143goto exit;1144}1145Py_ssize_t name_length;1146name = PyUnicode_AsUTF8AndSize(args[3], &name_length);1147if (name == NULL) {1148goto exit;1149}1150if (strlen(name) != (size_t)name_length) {1151PyErr_SetString(PyExc_ValueError, "embedded null character");1152goto exit;1153}1154if (!--noptargs) {1155goto skip_optional_kwonly;1156}1157}1158if (PyFloat_CheckExact(args[4])) {1159sleep = PyFloat_AS_DOUBLE(args[4]);1160}1161else1162{1163sleep = PyFloat_AsDouble(args[4]);1164if (sleep == -1.0 && PyErr_Occurred()) {1165goto exit;1166}1167}1168skip_optional_kwonly:1169return_value = pysqlite_connection_backup_impl(self, target, pages, progress, name, sleep);11701171exit:1172return return_value;1173}11741175PyDoc_STRVAR(pysqlite_connection_create_collation__doc__,1176"create_collation($self, name, callback, /)\n"1177"--\n"1178"\n"1179"Creates a collation function.");11801181#define PYSQLITE_CONNECTION_CREATE_COLLATION_METHODDEF \1182{"create_collation", _PyCFunction_CAST(pysqlite_connection_create_collation), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_collation__doc__},11831184static PyObject *1185pysqlite_connection_create_collation_impl(pysqlite_Connection *self,1186PyTypeObject *cls,1187const char *name,1188PyObject *callable);11891190static PyObject *1191pysqlite_connection_create_collation(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)1192{1193PyObject *return_value = NULL;1194#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)1195# define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)1196#else1197# define KWTUPLE NULL1198#endif11991200static const char * const _keywords[] = {"", "", NULL};1201static _PyArg_Parser _parser = {1202.keywords = _keywords,1203.fname = "create_collation",1204.kwtuple = KWTUPLE,1205};1206#undef KWTUPLE1207PyObject *argsbuf[2];1208const char *name;1209PyObject *callable;12101211args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);1212if (!args) {1213goto exit;1214}1215if (!PyUnicode_Check(args[0])) {1216_PyArg_BadArgument("create_collation", "argument 1", "str", args[0]);1217goto exit;1218}1219Py_ssize_t name_length;1220name = PyUnicode_AsUTF8AndSize(args[0], &name_length);1221if (name == NULL) {1222goto exit;1223}1224if (strlen(name) != (size_t)name_length) {1225PyErr_SetString(PyExc_ValueError, "embedded null character");1226goto exit;1227}1228callable = args[1];1229return_value = pysqlite_connection_create_collation_impl(self, cls, name, callable);12301231exit:1232return return_value;1233}12341235#if defined(PY_SQLITE_HAVE_SERIALIZE)12361237PyDoc_STRVAR(serialize__doc__,1238"serialize($self, /, *, name=\'main\')\n"1239"--\n"1240"\n"1241"Serialize a database into a byte string.\n"1242"\n"1243" name\n"1244" Which database to serialize.\n"1245"\n"1246"For an ordinary on-disk database file, the serialization is just a copy of the\n"1247"disk file. For an in-memory database or a \"temp\" database, the serialization is\n"1248"the same sequence of bytes which would be written to disk if that database\n"1249"were backed up to disk.");12501251#define SERIALIZE_METHODDEF \1252{"serialize", _PyCFunction_CAST(serialize), METH_FASTCALL|METH_KEYWORDS, serialize__doc__},12531254static PyObject *1255serialize_impl(pysqlite_Connection *self, const char *name);12561257static PyObject *1258serialize(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)1259{1260PyObject *return_value = NULL;1261#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)12621263#define NUM_KEYWORDS 11264static struct {1265PyGC_Head _this_is_not_used;1266PyObject_VAR_HEAD1267PyObject *ob_item[NUM_KEYWORDS];1268} _kwtuple = {1269.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)1270.ob_item = { &_Py_ID(name), },1271};1272#undef NUM_KEYWORDS1273#define KWTUPLE (&_kwtuple.ob_base.ob_base)12741275#else // !Py_BUILD_CORE1276# define KWTUPLE NULL1277#endif // !Py_BUILD_CORE12781279static const char * const _keywords[] = {"name", NULL};1280static _PyArg_Parser _parser = {1281.keywords = _keywords,1282.fname = "serialize",1283.kwtuple = KWTUPLE,1284};1285#undef KWTUPLE1286PyObject *argsbuf[1];1287Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;1288const char *name = "main";12891290args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);1291if (!args) {1292goto exit;1293}1294if (!noptargs) {1295goto skip_optional_kwonly;1296}1297if (!PyUnicode_Check(args[0])) {1298_PyArg_BadArgument("serialize", "argument 'name'", "str", args[0]);1299goto exit;1300}1301Py_ssize_t name_length;1302name = PyUnicode_AsUTF8AndSize(args[0], &name_length);1303if (name == NULL) {1304goto exit;1305}1306if (strlen(name) != (size_t)name_length) {1307PyErr_SetString(PyExc_ValueError, "embedded null character");1308goto exit;1309}1310skip_optional_kwonly:1311return_value = serialize_impl(self, name);13121313exit:1314return return_value;1315}13161317#endif /* defined(PY_SQLITE_HAVE_SERIALIZE) */13181319#if defined(PY_SQLITE_HAVE_SERIALIZE)13201321PyDoc_STRVAR(deserialize__doc__,1322"deserialize($self, data, /, *, name=\'main\')\n"1323"--\n"1324"\n"1325"Load a serialized database.\n"1326"\n"1327" data\n"1328" The serialized database content.\n"1329" name\n"1330" Which database to reopen with the deserialization.\n"1331"\n"1332"The deserialize interface causes the database connection to disconnect from the\n"1333"target database, and then reopen it as an in-memory database based on the given\n"1334"serialized data.\n"1335"\n"1336"The deserialize interface will fail with SQLITE_BUSY if the database is\n"1337"currently in a read transaction or is involved in a backup operation.");13381339#define DESERIALIZE_METHODDEF \1340{"deserialize", _PyCFunction_CAST(deserialize), METH_FASTCALL|METH_KEYWORDS, deserialize__doc__},13411342static PyObject *1343deserialize_impl(pysqlite_Connection *self, Py_buffer *data,1344const char *name);13451346static PyObject *1347deserialize(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)1348{1349PyObject *return_value = NULL;1350#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)13511352#define NUM_KEYWORDS 11353static struct {1354PyGC_Head _this_is_not_used;1355PyObject_VAR_HEAD1356PyObject *ob_item[NUM_KEYWORDS];1357} _kwtuple = {1358.ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)1359.ob_item = { &_Py_ID(name), },1360};1361#undef NUM_KEYWORDS1362#define KWTUPLE (&_kwtuple.ob_base.ob_base)13631364#else // !Py_BUILD_CORE1365# define KWTUPLE NULL1366#endif // !Py_BUILD_CORE13671368static const char * const _keywords[] = {"", "name", NULL};1369static _PyArg_Parser _parser = {1370.keywords = _keywords,1371.fname = "deserialize",1372.kwtuple = KWTUPLE,1373};1374#undef KWTUPLE1375PyObject *argsbuf[2];1376Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;1377Py_buffer data = {NULL, NULL};1378const char *name = "main";13791380args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);1381if (!args) {1382goto exit;1383}1384if (PyUnicode_Check(args[0])) {1385Py_ssize_t len;1386const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len);1387if (ptr == NULL) {1388goto exit;1389}1390PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);1391}1392else { /* any bytes-like object */1393if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {1394goto exit;1395}1396if (!PyBuffer_IsContiguous(&data, 'C')) {1397_PyArg_BadArgument("deserialize", "argument 1", "contiguous buffer", args[0]);1398goto exit;1399}1400}1401if (!noptargs) {1402goto skip_optional_kwonly;1403}1404if (!PyUnicode_Check(args[1])) {1405_PyArg_BadArgument("deserialize", "argument 'name'", "str", args[1]);1406goto exit;1407}1408Py_ssize_t name_length;1409name = PyUnicode_AsUTF8AndSize(args[1], &name_length);1410if (name == NULL) {1411goto exit;1412}1413if (strlen(name) != (size_t)name_length) {1414PyErr_SetString(PyExc_ValueError, "embedded null character");1415goto exit;1416}1417skip_optional_kwonly:1418return_value = deserialize_impl(self, &data, name);14191420exit:1421/* Cleanup for data */1422if (data.obj) {1423PyBuffer_Release(&data);1424}14251426return return_value;1427}14281429#endif /* defined(PY_SQLITE_HAVE_SERIALIZE) */14301431PyDoc_STRVAR(pysqlite_connection_enter__doc__,1432"__enter__($self, /)\n"1433"--\n"1434"\n"1435"Called when the connection is used as a context manager.\n"1436"\n"1437"Returns itself as a convenience to the caller.");14381439#define PYSQLITE_CONNECTION_ENTER_METHODDEF \1440{"__enter__", (PyCFunction)pysqlite_connection_enter, METH_NOARGS, pysqlite_connection_enter__doc__},14411442static PyObject *1443pysqlite_connection_enter_impl(pysqlite_Connection *self);14441445static PyObject *1446pysqlite_connection_enter(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))1447{1448return pysqlite_connection_enter_impl(self);1449}14501451PyDoc_STRVAR(pysqlite_connection_exit__doc__,1452"__exit__($self, type, value, traceback, /)\n"1453"--\n"1454"\n"1455"Called when the connection is used as a context manager.\n"1456"\n"1457"If there was any exception, a rollback takes place; otherwise we commit.");14581459#define PYSQLITE_CONNECTION_EXIT_METHODDEF \1460{"__exit__", _PyCFunction_CAST(pysqlite_connection_exit), METH_FASTCALL, pysqlite_connection_exit__doc__},14611462static PyObject *1463pysqlite_connection_exit_impl(pysqlite_Connection *self, PyObject *exc_type,1464PyObject *exc_value, PyObject *exc_tb);14651466static PyObject *1467pysqlite_connection_exit(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)1468{1469PyObject *return_value = NULL;1470PyObject *exc_type;1471PyObject *exc_value;1472PyObject *exc_tb;14731474if (!_PyArg_CheckPositional("__exit__", nargs, 3, 3)) {1475goto exit;1476}1477exc_type = args[0];1478exc_value = args[1];1479exc_tb = args[2];1480return_value = pysqlite_connection_exit_impl(self, exc_type, exc_value, exc_tb);14811482exit:1483return return_value;1484}14851486PyDoc_STRVAR(setlimit__doc__,1487"setlimit($self, category, limit, /)\n"1488"--\n"1489"\n"1490"Set connection run-time limits.\n"1491"\n"1492" category\n"1493" The limit category to be set.\n"1494" limit\n"1495" The new limit. If the new limit is a negative number, the limit is\n"1496" unchanged.\n"1497"\n"1498"Attempts to increase a limit above its hard upper bound are silently truncated\n"1499"to the hard upper bound. Regardless of whether or not the limit was changed,\n"1500"the prior value of the limit is returned.");15011502#define SETLIMIT_METHODDEF \1503{"setlimit", _PyCFunction_CAST(setlimit), METH_FASTCALL, setlimit__doc__},15041505static PyObject *1506setlimit_impl(pysqlite_Connection *self, int category, int limit);15071508static PyObject *1509setlimit(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)1510{1511PyObject *return_value = NULL;1512int category;1513int limit;15141515if (!_PyArg_CheckPositional("setlimit", nargs, 2, 2)) {1516goto exit;1517}1518category = _PyLong_AsInt(args[0]);1519if (category == -1 && PyErr_Occurred()) {1520goto exit;1521}1522limit = _PyLong_AsInt(args[1]);1523if (limit == -1 && PyErr_Occurred()) {1524goto exit;1525}1526return_value = setlimit_impl(self, category, limit);15271528exit:1529return return_value;1530}15311532PyDoc_STRVAR(getlimit__doc__,1533"getlimit($self, category, /)\n"1534"--\n"1535"\n"1536"Get connection run-time limits.\n"1537"\n"1538" category\n"1539" The limit category to be queried.");15401541#define GETLIMIT_METHODDEF \1542{"getlimit", (PyCFunction)getlimit, METH_O, getlimit__doc__},15431544static PyObject *1545getlimit_impl(pysqlite_Connection *self, int category);15461547static PyObject *1548getlimit(pysqlite_Connection *self, PyObject *arg)1549{1550PyObject *return_value = NULL;1551int category;15521553category = _PyLong_AsInt(arg);1554if (category == -1 && PyErr_Occurred()) {1555goto exit;1556}1557return_value = getlimit_impl(self, category);15581559exit:1560return return_value;1561}15621563PyDoc_STRVAR(setconfig__doc__,1564"setconfig($self, op, enable=True, /)\n"1565"--\n"1566"\n"1567"Set a boolean connection configuration option.\n"1568"\n"1569" op\n"1570" The configuration verb; one of the sqlite3.SQLITE_DBCONFIG codes.");15711572#define SETCONFIG_METHODDEF \1573{"setconfig", _PyCFunction_CAST(setconfig), METH_FASTCALL, setconfig__doc__},15741575static PyObject *1576setconfig_impl(pysqlite_Connection *self, int op, int enable);15771578static PyObject *1579setconfig(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)1580{1581PyObject *return_value = NULL;1582int op;1583int enable = 1;15841585if (!_PyArg_CheckPositional("setconfig", nargs, 1, 2)) {1586goto exit;1587}1588op = _PyLong_AsInt(args[0]);1589if (op == -1 && PyErr_Occurred()) {1590goto exit;1591}1592if (nargs < 2) {1593goto skip_optional;1594}1595enable = PyObject_IsTrue(args[1]);1596if (enable < 0) {1597goto exit;1598}1599skip_optional:1600return_value = setconfig_impl(self, op, enable);16011602exit:1603return return_value;1604}16051606PyDoc_STRVAR(getconfig__doc__,1607"getconfig($self, op, /)\n"1608"--\n"1609"\n"1610"Query a boolean connection configuration option.\n"1611"\n"1612" op\n"1613" The configuration verb; one of the sqlite3.SQLITE_DBCONFIG codes.");16141615#define GETCONFIG_METHODDEF \1616{"getconfig", (PyCFunction)getconfig, METH_O, getconfig__doc__},16171618static int1619getconfig_impl(pysqlite_Connection *self, int op);16201621static PyObject *1622getconfig(pysqlite_Connection *self, PyObject *arg)1623{1624PyObject *return_value = NULL;1625int op;1626int _return_value;16271628op = _PyLong_AsInt(arg);1629if (op == -1 && PyErr_Occurred()) {1630goto exit;1631}1632_return_value = getconfig_impl(self, op);1633if ((_return_value == -1) && PyErr_Occurred()) {1634goto exit;1635}1636return_value = PyBool_FromLong((long)_return_value);16371638exit:1639return return_value;1640}16411642#ifndef CREATE_WINDOW_FUNCTION_METHODDEF1643#define CREATE_WINDOW_FUNCTION_METHODDEF1644#endif /* !defined(CREATE_WINDOW_FUNCTION_METHODDEF) */16451646#ifndef PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF1647#define PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF1648#endif /* !defined(PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF) */16491650#ifndef PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF1651#define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF1652#endif /* !defined(PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF) */16531654#ifndef SERIALIZE_METHODDEF1655#define SERIALIZE_METHODDEF1656#endif /* !defined(SERIALIZE_METHODDEF) */16571658#ifndef DESERIALIZE_METHODDEF1659#define DESERIALIZE_METHODDEF1660#endif /* !defined(DESERIALIZE_METHODDEF) */1661/*[clinic end generated code: output=d3c6cb9326736ea5 input=a9049054013a1b77]*/166216631664