(root)/
Python-3.11.7/
Modules/
_sqlite/
clinic/
connection.c.h
       1  /*[clinic input]
       2  preserve
       3  [clinic start generated code]*/
       4  
       5  static int
       6  pysqlite_connection_init_impl(pysqlite_Connection *self, PyObject *database,
       7                                double timeout, int detect_types,
       8                                const char *isolation_level,
       9                                int check_same_thread, PyObject *factory,
      10                                int cache_size, int uri);
      11  
      12  static int
      13  pysqlite_connection_init(PyObject *self, PyObject *args, PyObject *kwargs)
      14  {
      15      int return_value = -1;
      16      static const char * const _keywords[] = {"database", "timeout", "detect_types", "isolation_level", "check_same_thread", "factory", "cached_statements", "uri", NULL};
      17      static _PyArg_Parser _parser = {NULL, _keywords, "Connection", 0};
      18      PyObject *argsbuf[8];
      19      PyObject * const *fastargs;
      20      Py_ssize_t nargs = PyTuple_GET_SIZE(args);
      21      Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
      22      PyObject *database;
      23      double timeout = 5.0;
      24      int detect_types = 0;
      25      const char *isolation_level = "";
      26      int check_same_thread = 1;
      27      PyObject *factory = (PyObject*)clinic_state()->ConnectionType;
      28      int cache_size = 128;
      29      int uri = 0;
      30  
      31      fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 8, 0, argsbuf);
      32      if (!fastargs) {
      33          goto exit;
      34      }
      35      database = fastargs[0];
      36      if (!noptargs) {
      37          goto skip_optional_pos;
      38      }
      39      if (fastargs[1]) {
      40          if (PyFloat_CheckExact(fastargs[1])) {
      41              timeout = PyFloat_AS_DOUBLE(fastargs[1]);
      42          }
      43          else
      44          {
      45              timeout = PyFloat_AsDouble(fastargs[1]);
      46              if (timeout == -1.0 && PyErr_Occurred()) {
      47                  goto exit;
      48              }
      49          }
      50          if (!--noptargs) {
      51              goto skip_optional_pos;
      52          }
      53      }
      54      if (fastargs[2]) {
      55          detect_types = _PyLong_AsInt(fastargs[2]);
      56          if (detect_types == -1 && PyErr_Occurred()) {
      57              goto exit;
      58          }
      59          if (!--noptargs) {
      60              goto skip_optional_pos;
      61          }
      62      }
      63      if (fastargs[3]) {
      64          if (!isolation_level_converter(fastargs[3], &isolation_level)) {
      65              goto exit;
      66          }
      67          if (!--noptargs) {
      68              goto skip_optional_pos;
      69          }
      70      }
      71      if (fastargs[4]) {
      72          check_same_thread = _PyLong_AsInt(fastargs[4]);
      73          if (check_same_thread == -1 && PyErr_Occurred()) {
      74              goto exit;
      75          }
      76          if (!--noptargs) {
      77              goto skip_optional_pos;
      78          }
      79      }
      80      if (fastargs[5]) {
      81          factory = fastargs[5];
      82          if (!--noptargs) {
      83              goto skip_optional_pos;
      84          }
      85      }
      86      if (fastargs[6]) {
      87          cache_size = _PyLong_AsInt(fastargs[6]);
      88          if (cache_size == -1 && PyErr_Occurred()) {
      89              goto exit;
      90          }
      91          if (!--noptargs) {
      92              goto skip_optional_pos;
      93          }
      94      }
      95      uri = PyObject_IsTrue(fastargs[7]);
      96      if (uri < 0) {
      97          goto exit;
      98      }
      99  skip_optional_pos:
     100      return_value = pysqlite_connection_init_impl((pysqlite_Connection *)self, database, timeout, detect_types, isolation_level, check_same_thread, factory, cache_size, uri);
     101  
     102  exit:
     103      return return_value;
     104  }
     105  
     106  PyDoc_STRVAR(pysqlite_connection_cursor__doc__,
     107  "cursor($self, /, factory=<unrepresentable>)\n"
     108  "--\n"
     109  "\n"
     110  "Return a cursor for the connection.");
     111  
     112  #define PYSQLITE_CONNECTION_CURSOR_METHODDEF    \
     113      {"cursor", _PyCFunction_CAST(pysqlite_connection_cursor), METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_cursor__doc__},
     114  
     115  static PyObject *
     116  pysqlite_connection_cursor_impl(pysqlite_Connection *self, PyObject *factory);
     117  
     118  static PyObject *
     119  pysqlite_connection_cursor(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     120  {
     121      PyObject *return_value = NULL;
     122      static const char * const _keywords[] = {"factory", NULL};
     123      static _PyArg_Parser _parser = {NULL, _keywords, "cursor", 0};
     124      PyObject *argsbuf[1];
     125      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     126      PyObject *factory = NULL;
     127  
     128      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
     129      if (!args) {
     130          goto exit;
     131      }
     132      if (!noptargs) {
     133          goto skip_optional_pos;
     134      }
     135      factory = args[0];
     136  skip_optional_pos:
     137      return_value = pysqlite_connection_cursor_impl(self, factory);
     138  
     139  exit:
     140      return return_value;
     141  }
     142  
     143  PyDoc_STRVAR(blobopen__doc__,
     144  "blobopen($self, table, column, row, /, *, readonly=False, name=\'main\')\n"
     145  "--\n"
     146  "\n"
     147  "Open and return a BLOB object.\n"
     148  "\n"
     149  "  table\n"
     150  "    Table name.\n"
     151  "  column\n"
     152  "    Column name.\n"
     153  "  row\n"
     154  "    Row index.\n"
     155  "  readonly\n"
     156  "    Open the BLOB without write permissions.\n"
     157  "  name\n"
     158  "    Database name.");
     159  
     160  #define BLOBOPEN_METHODDEF    \
     161      {"blobopen", _PyCFunction_CAST(blobopen), METH_FASTCALL|METH_KEYWORDS, blobopen__doc__},
     162  
     163  static PyObject *
     164  blobopen_impl(pysqlite_Connection *self, const char *table, const char *col,
     165                sqlite3_int64 row, int readonly, const char *name);
     166  
     167  static PyObject *
     168  blobopen(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     169  {
     170      PyObject *return_value = NULL;
     171      static const char * const _keywords[] = {"", "", "", "readonly", "name", NULL};
     172      static _PyArg_Parser _parser = {NULL, _keywords, "blobopen", 0};
     173      PyObject *argsbuf[5];
     174      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;
     175      const char *table;
     176      const char *col;
     177      sqlite3_int64 row;
     178      int readonly = 0;
     179      const char *name = "main";
     180  
     181      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
     182      if (!args) {
     183          goto exit;
     184      }
     185      if (!PyUnicode_Check(args[0])) {
     186          _PyArg_BadArgument("blobopen", "argument 1", "str", args[0]);
     187          goto exit;
     188      }
     189      Py_ssize_t table_length;
     190      table = PyUnicode_AsUTF8AndSize(args[0], &table_length);
     191      if (table == NULL) {
     192          goto exit;
     193      }
     194      if (strlen(table) != (size_t)table_length) {
     195          PyErr_SetString(PyExc_ValueError, "embedded null character");
     196          goto exit;
     197      }
     198      if (!PyUnicode_Check(args[1])) {
     199          _PyArg_BadArgument("blobopen", "argument 2", "str", args[1]);
     200          goto exit;
     201      }
     202      Py_ssize_t col_length;
     203      col = PyUnicode_AsUTF8AndSize(args[1], &col_length);
     204      if (col == NULL) {
     205          goto exit;
     206      }
     207      if (strlen(col) != (size_t)col_length) {
     208          PyErr_SetString(PyExc_ValueError, "embedded null character");
     209          goto exit;
     210      }
     211      if (!sqlite3_int64_converter(args[2], &row)) {
     212          goto exit;
     213      }
     214      if (!noptargs) {
     215          goto skip_optional_kwonly;
     216      }
     217      if (args[3]) {
     218          readonly = _PyLong_AsInt(args[3]);
     219          if (readonly == -1 && PyErr_Occurred()) {
     220              goto exit;
     221          }
     222          if (!--noptargs) {
     223              goto skip_optional_kwonly;
     224          }
     225      }
     226      if (!PyUnicode_Check(args[4])) {
     227          _PyArg_BadArgument("blobopen", "argument 'name'", "str", args[4]);
     228          goto exit;
     229      }
     230      Py_ssize_t name_length;
     231      name = PyUnicode_AsUTF8AndSize(args[4], &name_length);
     232      if (name == NULL) {
     233          goto exit;
     234      }
     235      if (strlen(name) != (size_t)name_length) {
     236          PyErr_SetString(PyExc_ValueError, "embedded null character");
     237          goto exit;
     238      }
     239  skip_optional_kwonly:
     240      return_value = blobopen_impl(self, table, col, row, readonly, name);
     241  
     242  exit:
     243      return return_value;
     244  }
     245  
     246  PyDoc_STRVAR(pysqlite_connection_close__doc__,
     247  "close($self, /)\n"
     248  "--\n"
     249  "\n"
     250  "Close the database connection.\n"
     251  "\n"
     252  "Any pending transaction is not committed implicitly.");
     253  
     254  #define PYSQLITE_CONNECTION_CLOSE_METHODDEF    \
     255      {"close", (PyCFunction)pysqlite_connection_close, METH_NOARGS, pysqlite_connection_close__doc__},
     256  
     257  static PyObject *
     258  pysqlite_connection_close_impl(pysqlite_Connection *self);
     259  
     260  static PyObject *
     261  pysqlite_connection_close(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
     262  {
     263      return pysqlite_connection_close_impl(self);
     264  }
     265  
     266  PyDoc_STRVAR(pysqlite_connection_commit__doc__,
     267  "commit($self, /)\n"
     268  "--\n"
     269  "\n"
     270  "Commit any pending transaction to the database.\n"
     271  "\n"
     272  "If there is no open transaction, this method is a no-op.");
     273  
     274  #define PYSQLITE_CONNECTION_COMMIT_METHODDEF    \
     275      {"commit", (PyCFunction)pysqlite_connection_commit, METH_NOARGS, pysqlite_connection_commit__doc__},
     276  
     277  static PyObject *
     278  pysqlite_connection_commit_impl(pysqlite_Connection *self);
     279  
     280  static PyObject *
     281  pysqlite_connection_commit(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
     282  {
     283      return pysqlite_connection_commit_impl(self);
     284  }
     285  
     286  PyDoc_STRVAR(pysqlite_connection_rollback__doc__,
     287  "rollback($self, /)\n"
     288  "--\n"
     289  "\n"
     290  "Roll back to the start of any pending transaction.\n"
     291  "\n"
     292  "If there is no open transaction, this method is a no-op.");
     293  
     294  #define PYSQLITE_CONNECTION_ROLLBACK_METHODDEF    \
     295      {"rollback", (PyCFunction)pysqlite_connection_rollback, METH_NOARGS, pysqlite_connection_rollback__doc__},
     296  
     297  static PyObject *
     298  pysqlite_connection_rollback_impl(pysqlite_Connection *self);
     299  
     300  static PyObject *
     301  pysqlite_connection_rollback(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
     302  {
     303      return pysqlite_connection_rollback_impl(self);
     304  }
     305  
     306  PyDoc_STRVAR(pysqlite_connection_create_function__doc__,
     307  "create_function($self, /, name, narg, func, *, deterministic=False)\n"
     308  "--\n"
     309  "\n"
     310  "Creates a new function.");
     311  
     312  #define PYSQLITE_CONNECTION_CREATE_FUNCTION_METHODDEF    \
     313      {"create_function", _PyCFunction_CAST(pysqlite_connection_create_function), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_function__doc__},
     314  
     315  static PyObject *
     316  pysqlite_connection_create_function_impl(pysqlite_Connection *self,
     317                                           PyTypeObject *cls, const char *name,
     318                                           int narg, PyObject *func,
     319                                           int deterministic);
     320  
     321  static PyObject *
     322  pysqlite_connection_create_function(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     323  {
     324      PyObject *return_value = NULL;
     325      static const char * const _keywords[] = {"name", "narg", "func", "deterministic", NULL};
     326      static _PyArg_Parser _parser = {NULL, _keywords, "create_function", 0};
     327      PyObject *argsbuf[4];
     328      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;
     329      const char *name;
     330      int narg;
     331      PyObject *func;
     332      int deterministic = 0;
     333  
     334      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
     335      if (!args) {
     336          goto exit;
     337      }
     338      if (!PyUnicode_Check(args[0])) {
     339          _PyArg_BadArgument("create_function", "argument 'name'", "str", args[0]);
     340          goto exit;
     341      }
     342      Py_ssize_t name_length;
     343      name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
     344      if (name == NULL) {
     345          goto exit;
     346      }
     347      if (strlen(name) != (size_t)name_length) {
     348          PyErr_SetString(PyExc_ValueError, "embedded null character");
     349          goto exit;
     350      }
     351      narg = _PyLong_AsInt(args[1]);
     352      if (narg == -1 && PyErr_Occurred()) {
     353          goto exit;
     354      }
     355      func = args[2];
     356      if (!noptargs) {
     357          goto skip_optional_kwonly;
     358      }
     359      deterministic = PyObject_IsTrue(args[3]);
     360      if (deterministic < 0) {
     361          goto exit;
     362      }
     363  skip_optional_kwonly:
     364      return_value = pysqlite_connection_create_function_impl(self, cls, name, narg, func, deterministic);
     365  
     366  exit:
     367      return return_value;
     368  }
     369  
     370  #if defined(HAVE_WINDOW_FUNCTIONS)
     371  
     372  PyDoc_STRVAR(create_window_function__doc__,
     373  "create_window_function($self, name, num_params, aggregate_class, /)\n"
     374  "--\n"
     375  "\n"
     376  "Creates or redefines an aggregate window function. Non-standard.\n"
     377  "\n"
     378  "  name\n"
     379  "    The name of the SQL aggregate window function to be created or\n"
     380  "    redefined.\n"
     381  "  num_params\n"
     382  "    The number of arguments the step and inverse methods takes.\n"
     383  "  aggregate_class\n"
     384  "    A class with step(), finalize(), value(), and inverse() methods.\n"
     385  "    Set to None to clear the window function.");
     386  
     387  #define CREATE_WINDOW_FUNCTION_METHODDEF    \
     388      {"create_window_function", _PyCFunction_CAST(create_window_function), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, create_window_function__doc__},
     389  
     390  static PyObject *
     391  create_window_function_impl(pysqlite_Connection *self, PyTypeObject *cls,
     392                              const char *name, int num_params,
     393                              PyObject *aggregate_class);
     394  
     395  static PyObject *
     396  create_window_function(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     397  {
     398      PyObject *return_value = NULL;
     399      static const char * const _keywords[] = {"", "", "", NULL};
     400      static _PyArg_Parser _parser = {NULL, _keywords, "create_window_function", 0};
     401      PyObject *argsbuf[3];
     402      const char *name;
     403      int num_params;
     404      PyObject *aggregate_class;
     405  
     406      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
     407      if (!args) {
     408          goto exit;
     409      }
     410      if (!PyUnicode_Check(args[0])) {
     411          _PyArg_BadArgument("create_window_function", "argument 1", "str", args[0]);
     412          goto exit;
     413      }
     414      Py_ssize_t name_length;
     415      name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
     416      if (name == NULL) {
     417          goto exit;
     418      }
     419      if (strlen(name) != (size_t)name_length) {
     420          PyErr_SetString(PyExc_ValueError, "embedded null character");
     421          goto exit;
     422      }
     423      num_params = _PyLong_AsInt(args[1]);
     424      if (num_params == -1 && PyErr_Occurred()) {
     425          goto exit;
     426      }
     427      aggregate_class = args[2];
     428      return_value = create_window_function_impl(self, cls, name, num_params, aggregate_class);
     429  
     430  exit:
     431      return return_value;
     432  }
     433  
     434  #endif /* defined(HAVE_WINDOW_FUNCTIONS) */
     435  
     436  PyDoc_STRVAR(pysqlite_connection_create_aggregate__doc__,
     437  "create_aggregate($self, /, name, n_arg, aggregate_class)\n"
     438  "--\n"
     439  "\n"
     440  "Creates a new aggregate.");
     441  
     442  #define PYSQLITE_CONNECTION_CREATE_AGGREGATE_METHODDEF    \
     443      {"create_aggregate", _PyCFunction_CAST(pysqlite_connection_create_aggregate), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_aggregate__doc__},
     444  
     445  static PyObject *
     446  pysqlite_connection_create_aggregate_impl(pysqlite_Connection *self,
     447                                            PyTypeObject *cls,
     448                                            const char *name, int n_arg,
     449                                            PyObject *aggregate_class);
     450  
     451  static PyObject *
     452  pysqlite_connection_create_aggregate(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     453  {
     454      PyObject *return_value = NULL;
     455      static const char * const _keywords[] = {"name", "n_arg", "aggregate_class", NULL};
     456      static _PyArg_Parser _parser = {NULL, _keywords, "create_aggregate", 0};
     457      PyObject *argsbuf[3];
     458      const char *name;
     459      int n_arg;
     460      PyObject *aggregate_class;
     461  
     462      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
     463      if (!args) {
     464          goto exit;
     465      }
     466      if (!PyUnicode_Check(args[0])) {
     467          _PyArg_BadArgument("create_aggregate", "argument 'name'", "str", args[0]);
     468          goto exit;
     469      }
     470      Py_ssize_t name_length;
     471      name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
     472      if (name == NULL) {
     473          goto exit;
     474      }
     475      if (strlen(name) != (size_t)name_length) {
     476          PyErr_SetString(PyExc_ValueError, "embedded null character");
     477          goto exit;
     478      }
     479      n_arg = _PyLong_AsInt(args[1]);
     480      if (n_arg == -1 && PyErr_Occurred()) {
     481          goto exit;
     482      }
     483      aggregate_class = args[2];
     484      return_value = pysqlite_connection_create_aggregate_impl(self, cls, name, n_arg, aggregate_class);
     485  
     486  exit:
     487      return return_value;
     488  }
     489  
     490  PyDoc_STRVAR(pysqlite_connection_set_authorizer__doc__,
     491  "set_authorizer($self, /, authorizer_callback)\n"
     492  "--\n"
     493  "\n"
     494  "Sets authorizer callback.");
     495  
     496  #define PYSQLITE_CONNECTION_SET_AUTHORIZER_METHODDEF    \
     497      {"set_authorizer", _PyCFunction_CAST(pysqlite_connection_set_authorizer), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_authorizer__doc__},
     498  
     499  static PyObject *
     500  pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self,
     501                                          PyTypeObject *cls,
     502                                          PyObject *callable);
     503  
     504  static PyObject *
     505  pysqlite_connection_set_authorizer(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     506  {
     507      PyObject *return_value = NULL;
     508      static const char * const _keywords[] = {"authorizer_callback", NULL};
     509      static _PyArg_Parser _parser = {NULL, _keywords, "set_authorizer", 0};
     510      PyObject *argsbuf[1];
     511      PyObject *callable;
     512  
     513      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
     514      if (!args) {
     515          goto exit;
     516      }
     517      callable = args[0];
     518      return_value = pysqlite_connection_set_authorizer_impl(self, cls, callable);
     519  
     520  exit:
     521      return return_value;
     522  }
     523  
     524  PyDoc_STRVAR(pysqlite_connection_set_progress_handler__doc__,
     525  "set_progress_handler($self, /, progress_handler, n)\n"
     526  "--\n"
     527  "\n"
     528  "Sets progress handler callback.");
     529  
     530  #define PYSQLITE_CONNECTION_SET_PROGRESS_HANDLER_METHODDEF    \
     531      {"set_progress_handler", _PyCFunction_CAST(pysqlite_connection_set_progress_handler), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_progress_handler__doc__},
     532  
     533  static PyObject *
     534  pysqlite_connection_set_progress_handler_impl(pysqlite_Connection *self,
     535                                                PyTypeObject *cls,
     536                                                PyObject *callable, int n);
     537  
     538  static PyObject *
     539  pysqlite_connection_set_progress_handler(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     540  {
     541      PyObject *return_value = NULL;
     542      static const char * const _keywords[] = {"progress_handler", "n", NULL};
     543      static _PyArg_Parser _parser = {NULL, _keywords, "set_progress_handler", 0};
     544      PyObject *argsbuf[2];
     545      PyObject *callable;
     546      int n;
     547  
     548      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
     549      if (!args) {
     550          goto exit;
     551      }
     552      callable = args[0];
     553      n = _PyLong_AsInt(args[1]);
     554      if (n == -1 && PyErr_Occurred()) {
     555          goto exit;
     556      }
     557      return_value = pysqlite_connection_set_progress_handler_impl(self, cls, callable, n);
     558  
     559  exit:
     560      return return_value;
     561  }
     562  
     563  PyDoc_STRVAR(pysqlite_connection_set_trace_callback__doc__,
     564  "set_trace_callback($self, /, trace_callback)\n"
     565  "--\n"
     566  "\n"
     567  "Sets a trace callback called for each SQL statement (passed as unicode).");
     568  
     569  #define PYSQLITE_CONNECTION_SET_TRACE_CALLBACK_METHODDEF    \
     570      {"set_trace_callback", _PyCFunction_CAST(pysqlite_connection_set_trace_callback), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_trace_callback__doc__},
     571  
     572  static PyObject *
     573  pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
     574                                              PyTypeObject *cls,
     575                                              PyObject *callable);
     576  
     577  static PyObject *
     578  pysqlite_connection_set_trace_callback(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     579  {
     580      PyObject *return_value = NULL;
     581      static const char * const _keywords[] = {"trace_callback", NULL};
     582      static _PyArg_Parser _parser = {NULL, _keywords, "set_trace_callback", 0};
     583      PyObject *argsbuf[1];
     584      PyObject *callable;
     585  
     586      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
     587      if (!args) {
     588          goto exit;
     589      }
     590      callable = args[0];
     591      return_value = pysqlite_connection_set_trace_callback_impl(self, cls, callable);
     592  
     593  exit:
     594      return return_value;
     595  }
     596  
     597  #if defined(PY_SQLITE_ENABLE_LOAD_EXTENSION)
     598  
     599  PyDoc_STRVAR(pysqlite_connection_enable_load_extension__doc__,
     600  "enable_load_extension($self, enable, /)\n"
     601  "--\n"
     602  "\n"
     603  "Enable dynamic loading of SQLite extension modules.");
     604  
     605  #define PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF    \
     606      {"enable_load_extension", (PyCFunction)pysqlite_connection_enable_load_extension, METH_O, pysqlite_connection_enable_load_extension__doc__},
     607  
     608  static PyObject *
     609  pysqlite_connection_enable_load_extension_impl(pysqlite_Connection *self,
     610                                                 int onoff);
     611  
     612  static PyObject *
     613  pysqlite_connection_enable_load_extension(pysqlite_Connection *self, PyObject *arg)
     614  {
     615      PyObject *return_value = NULL;
     616      int onoff;
     617  
     618      onoff = _PyLong_AsInt(arg);
     619      if (onoff == -1 && PyErr_Occurred()) {
     620          goto exit;
     621      }
     622      return_value = pysqlite_connection_enable_load_extension_impl(self, onoff);
     623  
     624  exit:
     625      return return_value;
     626  }
     627  
     628  #endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */
     629  
     630  #if defined(PY_SQLITE_ENABLE_LOAD_EXTENSION)
     631  
     632  PyDoc_STRVAR(pysqlite_connection_load_extension__doc__,
     633  "load_extension($self, name, /)\n"
     634  "--\n"
     635  "\n"
     636  "Load SQLite extension module.");
     637  
     638  #define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF    \
     639      {"load_extension", (PyCFunction)pysqlite_connection_load_extension, METH_O, pysqlite_connection_load_extension__doc__},
     640  
     641  static PyObject *
     642  pysqlite_connection_load_extension_impl(pysqlite_Connection *self,
     643                                          const char *extension_name);
     644  
     645  static PyObject *
     646  pysqlite_connection_load_extension(pysqlite_Connection *self, PyObject *arg)
     647  {
     648      PyObject *return_value = NULL;
     649      const char *extension_name;
     650  
     651      if (!PyUnicode_Check(arg)) {
     652          _PyArg_BadArgument("load_extension", "argument", "str", arg);
     653          goto exit;
     654      }
     655      Py_ssize_t extension_name_length;
     656      extension_name = PyUnicode_AsUTF8AndSize(arg, &extension_name_length);
     657      if (extension_name == NULL) {
     658          goto exit;
     659      }
     660      if (strlen(extension_name) != (size_t)extension_name_length) {
     661          PyErr_SetString(PyExc_ValueError, "embedded null character");
     662          goto exit;
     663      }
     664      return_value = pysqlite_connection_load_extension_impl(self, extension_name);
     665  
     666  exit:
     667      return return_value;
     668  }
     669  
     670  #endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */
     671  
     672  PyDoc_STRVAR(pysqlite_connection_execute__doc__,
     673  "execute($self, sql, parameters=<unrepresentable>, /)\n"
     674  "--\n"
     675  "\n"
     676  "Executes an SQL statement.");
     677  
     678  #define PYSQLITE_CONNECTION_EXECUTE_METHODDEF    \
     679      {"execute", _PyCFunction_CAST(pysqlite_connection_execute), METH_FASTCALL, pysqlite_connection_execute__doc__},
     680  
     681  static PyObject *
     682  pysqlite_connection_execute_impl(pysqlite_Connection *self, PyObject *sql,
     683                                   PyObject *parameters);
     684  
     685  static PyObject *
     686  pysqlite_connection_execute(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
     687  {
     688      PyObject *return_value = NULL;
     689      PyObject *sql;
     690      PyObject *parameters = NULL;
     691  
     692      if (!_PyArg_CheckPositional("execute", nargs, 1, 2)) {
     693          goto exit;
     694      }
     695      if (!PyUnicode_Check(args[0])) {
     696          _PyArg_BadArgument("execute", "argument 1", "str", args[0]);
     697          goto exit;
     698      }
     699      if (PyUnicode_READY(args[0]) == -1) {
     700          goto exit;
     701      }
     702      sql = args[0];
     703      if (nargs < 2) {
     704          goto skip_optional;
     705      }
     706      parameters = args[1];
     707  skip_optional:
     708      return_value = pysqlite_connection_execute_impl(self, sql, parameters);
     709  
     710  exit:
     711      return return_value;
     712  }
     713  
     714  PyDoc_STRVAR(pysqlite_connection_executemany__doc__,
     715  "executemany($self, sql, parameters, /)\n"
     716  "--\n"
     717  "\n"
     718  "Repeatedly executes an SQL statement.");
     719  
     720  #define PYSQLITE_CONNECTION_EXECUTEMANY_METHODDEF    \
     721      {"executemany", _PyCFunction_CAST(pysqlite_connection_executemany), METH_FASTCALL, pysqlite_connection_executemany__doc__},
     722  
     723  static PyObject *
     724  pysqlite_connection_executemany_impl(pysqlite_Connection *self,
     725                                       PyObject *sql, PyObject *parameters);
     726  
     727  static PyObject *
     728  pysqlite_connection_executemany(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
     729  {
     730      PyObject *return_value = NULL;
     731      PyObject *sql;
     732      PyObject *parameters;
     733  
     734      if (!_PyArg_CheckPositional("executemany", nargs, 2, 2)) {
     735          goto exit;
     736      }
     737      if (!PyUnicode_Check(args[0])) {
     738          _PyArg_BadArgument("executemany", "argument 1", "str", args[0]);
     739          goto exit;
     740      }
     741      if (PyUnicode_READY(args[0]) == -1) {
     742          goto exit;
     743      }
     744      sql = args[0];
     745      parameters = args[1];
     746      return_value = pysqlite_connection_executemany_impl(self, sql, parameters);
     747  
     748  exit:
     749      return return_value;
     750  }
     751  
     752  PyDoc_STRVAR(pysqlite_connection_executescript__doc__,
     753  "executescript($self, sql_script, /)\n"
     754  "--\n"
     755  "\n"
     756  "Executes multiple SQL statements at once.");
     757  
     758  #define PYSQLITE_CONNECTION_EXECUTESCRIPT_METHODDEF    \
     759      {"executescript", (PyCFunction)pysqlite_connection_executescript, METH_O, pysqlite_connection_executescript__doc__},
     760  
     761  PyDoc_STRVAR(pysqlite_connection_interrupt__doc__,
     762  "interrupt($self, /)\n"
     763  "--\n"
     764  "\n"
     765  "Abort any pending database operation.");
     766  
     767  #define PYSQLITE_CONNECTION_INTERRUPT_METHODDEF    \
     768      {"interrupt", (PyCFunction)pysqlite_connection_interrupt, METH_NOARGS, pysqlite_connection_interrupt__doc__},
     769  
     770  static PyObject *
     771  pysqlite_connection_interrupt_impl(pysqlite_Connection *self);
     772  
     773  static PyObject *
     774  pysqlite_connection_interrupt(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
     775  {
     776      return pysqlite_connection_interrupt_impl(self);
     777  }
     778  
     779  PyDoc_STRVAR(pysqlite_connection_iterdump__doc__,
     780  "iterdump($self, /)\n"
     781  "--\n"
     782  "\n"
     783  "Returns iterator to the dump of the database in an SQL text format.");
     784  
     785  #define PYSQLITE_CONNECTION_ITERDUMP_METHODDEF    \
     786      {"iterdump", (PyCFunction)pysqlite_connection_iterdump, METH_NOARGS, pysqlite_connection_iterdump__doc__},
     787  
     788  static PyObject *
     789  pysqlite_connection_iterdump_impl(pysqlite_Connection *self);
     790  
     791  static PyObject *
     792  pysqlite_connection_iterdump(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
     793  {
     794      return pysqlite_connection_iterdump_impl(self);
     795  }
     796  
     797  PyDoc_STRVAR(pysqlite_connection_backup__doc__,
     798  "backup($self, /, target, *, pages=-1, progress=None, name=\'main\',\n"
     799  "       sleep=0.25)\n"
     800  "--\n"
     801  "\n"
     802  "Makes a backup of the database.");
     803  
     804  #define PYSQLITE_CONNECTION_BACKUP_METHODDEF    \
     805      {"backup", _PyCFunction_CAST(pysqlite_connection_backup), METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_backup__doc__},
     806  
     807  static PyObject *
     808  pysqlite_connection_backup_impl(pysqlite_Connection *self,
     809                                  pysqlite_Connection *target, int pages,
     810                                  PyObject *progress, const char *name,
     811                                  double sleep);
     812  
     813  static PyObject *
     814  pysqlite_connection_backup(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     815  {
     816      PyObject *return_value = NULL;
     817      static const char * const _keywords[] = {"target", "pages", "progress", "name", "sleep", NULL};
     818      static _PyArg_Parser _parser = {NULL, _keywords, "backup", 0};
     819      PyObject *argsbuf[5];
     820      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
     821      pysqlite_Connection *target;
     822      int pages = -1;
     823      PyObject *progress = Py_None;
     824      const char *name = "main";
     825      double sleep = 0.25;
     826  
     827      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
     828      if (!args) {
     829          goto exit;
     830      }
     831      if (!PyObject_TypeCheck(args[0], clinic_state()->ConnectionType)) {
     832          _PyArg_BadArgument("backup", "argument 'target'", (clinic_state()->ConnectionType)->tp_name, args[0]);
     833          goto exit;
     834      }
     835      target = (pysqlite_Connection *)args[0];
     836      if (!noptargs) {
     837          goto skip_optional_kwonly;
     838      }
     839      if (args[1]) {
     840          pages = _PyLong_AsInt(args[1]);
     841          if (pages == -1 && PyErr_Occurred()) {
     842              goto exit;
     843          }
     844          if (!--noptargs) {
     845              goto skip_optional_kwonly;
     846          }
     847      }
     848      if (args[2]) {
     849          progress = args[2];
     850          if (!--noptargs) {
     851              goto skip_optional_kwonly;
     852          }
     853      }
     854      if (args[3]) {
     855          if (!PyUnicode_Check(args[3])) {
     856              _PyArg_BadArgument("backup", "argument 'name'", "str", args[3]);
     857              goto exit;
     858          }
     859          Py_ssize_t name_length;
     860          name = PyUnicode_AsUTF8AndSize(args[3], &name_length);
     861          if (name == NULL) {
     862              goto exit;
     863          }
     864          if (strlen(name) != (size_t)name_length) {
     865              PyErr_SetString(PyExc_ValueError, "embedded null character");
     866              goto exit;
     867          }
     868          if (!--noptargs) {
     869              goto skip_optional_kwonly;
     870          }
     871      }
     872      if (PyFloat_CheckExact(args[4])) {
     873          sleep = PyFloat_AS_DOUBLE(args[4]);
     874      }
     875      else
     876      {
     877          sleep = PyFloat_AsDouble(args[4]);
     878          if (sleep == -1.0 && PyErr_Occurred()) {
     879              goto exit;
     880          }
     881      }
     882  skip_optional_kwonly:
     883      return_value = pysqlite_connection_backup_impl(self, target, pages, progress, name, sleep);
     884  
     885  exit:
     886      return return_value;
     887  }
     888  
     889  PyDoc_STRVAR(pysqlite_connection_create_collation__doc__,
     890  "create_collation($self, name, callback, /)\n"
     891  "--\n"
     892  "\n"
     893  "Creates a collation function.");
     894  
     895  #define PYSQLITE_CONNECTION_CREATE_COLLATION_METHODDEF    \
     896      {"create_collation", _PyCFunction_CAST(pysqlite_connection_create_collation), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_collation__doc__},
     897  
     898  static PyObject *
     899  pysqlite_connection_create_collation_impl(pysqlite_Connection *self,
     900                                            PyTypeObject *cls,
     901                                            const char *name,
     902                                            PyObject *callable);
     903  
     904  static PyObject *
     905  pysqlite_connection_create_collation(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     906  {
     907      PyObject *return_value = NULL;
     908      static const char * const _keywords[] = {"", "", NULL};
     909      static _PyArg_Parser _parser = {NULL, _keywords, "create_collation", 0};
     910      PyObject *argsbuf[2];
     911      const char *name;
     912      PyObject *callable;
     913  
     914      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
     915      if (!args) {
     916          goto exit;
     917      }
     918      if (!PyUnicode_Check(args[0])) {
     919          _PyArg_BadArgument("create_collation", "argument 1", "str", args[0]);
     920          goto exit;
     921      }
     922      Py_ssize_t name_length;
     923      name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
     924      if (name == NULL) {
     925          goto exit;
     926      }
     927      if (strlen(name) != (size_t)name_length) {
     928          PyErr_SetString(PyExc_ValueError, "embedded null character");
     929          goto exit;
     930      }
     931      callable = args[1];
     932      return_value = pysqlite_connection_create_collation_impl(self, cls, name, callable);
     933  
     934  exit:
     935      return return_value;
     936  }
     937  
     938  #if defined(PY_SQLITE_HAVE_SERIALIZE)
     939  
     940  PyDoc_STRVAR(serialize__doc__,
     941  "serialize($self, /, *, name=\'main\')\n"
     942  "--\n"
     943  "\n"
     944  "Serialize a database into a byte string.\n"
     945  "\n"
     946  "  name\n"
     947  "    Which database to serialize.\n"
     948  "\n"
     949  "For an ordinary on-disk database file, the serialization is just a copy of the\n"
     950  "disk file. For an in-memory database or a \"temp\" database, the serialization is\n"
     951  "the same sequence of bytes which would be written to disk if that database\n"
     952  "were backed up to disk.");
     953  
     954  #define SERIALIZE_METHODDEF    \
     955      {"serialize", _PyCFunction_CAST(serialize), METH_FASTCALL|METH_KEYWORDS, serialize__doc__},
     956  
     957  static PyObject *
     958  serialize_impl(pysqlite_Connection *self, const char *name);
     959  
     960  static PyObject *
     961  serialize(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
     962  {
     963      PyObject *return_value = NULL;
     964      static const char * const _keywords[] = {"name", NULL};
     965      static _PyArg_Parser _parser = {NULL, _keywords, "serialize", 0};
     966      PyObject *argsbuf[1];
     967      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
     968      const char *name = "main";
     969  
     970      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);
     971      if (!args) {
     972          goto exit;
     973      }
     974      if (!noptargs) {
     975          goto skip_optional_kwonly;
     976      }
     977      if (!PyUnicode_Check(args[0])) {
     978          _PyArg_BadArgument("serialize", "argument 'name'", "str", args[0]);
     979          goto exit;
     980      }
     981      Py_ssize_t name_length;
     982      name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
     983      if (name == NULL) {
     984          goto exit;
     985      }
     986      if (strlen(name) != (size_t)name_length) {
     987          PyErr_SetString(PyExc_ValueError, "embedded null character");
     988          goto exit;
     989      }
     990  skip_optional_kwonly:
     991      return_value = serialize_impl(self, name);
     992  
     993  exit:
     994      return return_value;
     995  }
     996  
     997  #endif /* defined(PY_SQLITE_HAVE_SERIALIZE) */
     998  
     999  #if defined(PY_SQLITE_HAVE_SERIALIZE)
    1000  
    1001  PyDoc_STRVAR(deserialize__doc__,
    1002  "deserialize($self, data, /, *, name=\'main\')\n"
    1003  "--\n"
    1004  "\n"
    1005  "Load a serialized database.\n"
    1006  "\n"
    1007  "  data\n"
    1008  "    The serialized database content.\n"
    1009  "  name\n"
    1010  "    Which database to reopen with the deserialization.\n"
    1011  "\n"
    1012  "The deserialize interface causes the database connection to disconnect from the\n"
    1013  "target database, and then reopen it as an in-memory database based on the given\n"
    1014  "serialized data.\n"
    1015  "\n"
    1016  "The deserialize interface will fail with SQLITE_BUSY if the database is\n"
    1017  "currently in a read transaction or is involved in a backup operation.");
    1018  
    1019  #define DESERIALIZE_METHODDEF    \
    1020      {"deserialize", _PyCFunction_CAST(deserialize), METH_FASTCALL|METH_KEYWORDS, deserialize__doc__},
    1021  
    1022  static PyObject *
    1023  deserialize_impl(pysqlite_Connection *self, Py_buffer *data,
    1024                   const char *name);
    1025  
    1026  static PyObject *
    1027  deserialize(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
    1028  {
    1029      PyObject *return_value = NULL;
    1030      static const char * const _keywords[] = {"", "name", NULL};
    1031      static _PyArg_Parser _parser = {NULL, _keywords, "deserialize", 0};
    1032      PyObject *argsbuf[2];
    1033      Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
    1034      Py_buffer data = {NULL, NULL};
    1035      const char *name = "main";
    1036  
    1037      args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
    1038      if (!args) {
    1039          goto exit;
    1040      }
    1041      if (PyUnicode_Check(args[0])) {
    1042          Py_ssize_t len;
    1043          const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len);
    1044          if (ptr == NULL) {
    1045              goto exit;
    1046          }
    1047          PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
    1048      }
    1049      else { /* any bytes-like object */
    1050          if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
    1051              goto exit;
    1052          }
    1053          if (!PyBuffer_IsContiguous(&data, 'C')) {
    1054              _PyArg_BadArgument("deserialize", "argument 1", "contiguous buffer", args[0]);
    1055              goto exit;
    1056          }
    1057      }
    1058      if (!noptargs) {
    1059          goto skip_optional_kwonly;
    1060      }
    1061      if (!PyUnicode_Check(args[1])) {
    1062          _PyArg_BadArgument("deserialize", "argument 'name'", "str", args[1]);
    1063          goto exit;
    1064      }
    1065      Py_ssize_t name_length;
    1066      name = PyUnicode_AsUTF8AndSize(args[1], &name_length);
    1067      if (name == NULL) {
    1068          goto exit;
    1069      }
    1070      if (strlen(name) != (size_t)name_length) {
    1071          PyErr_SetString(PyExc_ValueError, "embedded null character");
    1072          goto exit;
    1073      }
    1074  skip_optional_kwonly:
    1075      return_value = deserialize_impl(self, &data, name);
    1076  
    1077  exit:
    1078      /* Cleanup for data */
    1079      if (data.obj) {
    1080         PyBuffer_Release(&data);
    1081      }
    1082  
    1083      return return_value;
    1084  }
    1085  
    1086  #endif /* defined(PY_SQLITE_HAVE_SERIALIZE) */
    1087  
    1088  PyDoc_STRVAR(pysqlite_connection_enter__doc__,
    1089  "__enter__($self, /)\n"
    1090  "--\n"
    1091  "\n"
    1092  "Called when the connection is used as a context manager.\n"
    1093  "\n"
    1094  "Returns itself as a convenience to the caller.");
    1095  
    1096  #define PYSQLITE_CONNECTION_ENTER_METHODDEF    \
    1097      {"__enter__", (PyCFunction)pysqlite_connection_enter, METH_NOARGS, pysqlite_connection_enter__doc__},
    1098  
    1099  static PyObject *
    1100  pysqlite_connection_enter_impl(pysqlite_Connection *self);
    1101  
    1102  static PyObject *
    1103  pysqlite_connection_enter(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
    1104  {
    1105      return pysqlite_connection_enter_impl(self);
    1106  }
    1107  
    1108  PyDoc_STRVAR(pysqlite_connection_exit__doc__,
    1109  "__exit__($self, type, value, traceback, /)\n"
    1110  "--\n"
    1111  "\n"
    1112  "Called when the connection is used as a context manager.\n"
    1113  "\n"
    1114  "If there was any exception, a rollback takes place; otherwise we commit.");
    1115  
    1116  #define PYSQLITE_CONNECTION_EXIT_METHODDEF    \
    1117      {"__exit__", _PyCFunction_CAST(pysqlite_connection_exit), METH_FASTCALL, pysqlite_connection_exit__doc__},
    1118  
    1119  static PyObject *
    1120  pysqlite_connection_exit_impl(pysqlite_Connection *self, PyObject *exc_type,
    1121                                PyObject *exc_value, PyObject *exc_tb);
    1122  
    1123  static PyObject *
    1124  pysqlite_connection_exit(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
    1125  {
    1126      PyObject *return_value = NULL;
    1127      PyObject *exc_type;
    1128      PyObject *exc_value;
    1129      PyObject *exc_tb;
    1130  
    1131      if (!_PyArg_CheckPositional("__exit__", nargs, 3, 3)) {
    1132          goto exit;
    1133      }
    1134      exc_type = args[0];
    1135      exc_value = args[1];
    1136      exc_tb = args[2];
    1137      return_value = pysqlite_connection_exit_impl(self, exc_type, exc_value, exc_tb);
    1138  
    1139  exit:
    1140      return return_value;
    1141  }
    1142  
    1143  PyDoc_STRVAR(setlimit__doc__,
    1144  "setlimit($self, category, limit, /)\n"
    1145  "--\n"
    1146  "\n"
    1147  "Set connection run-time limits.\n"
    1148  "\n"
    1149  "  category\n"
    1150  "    The limit category to be set.\n"
    1151  "  limit\n"
    1152  "    The new limit. If the new limit is a negative number, the limit is\n"
    1153  "    unchanged.\n"
    1154  "\n"
    1155  "Attempts to increase a limit above its hard upper bound are silently truncated\n"
    1156  "to the hard upper bound. Regardless of whether or not the limit was changed,\n"
    1157  "the prior value of the limit is returned.");
    1158  
    1159  #define SETLIMIT_METHODDEF    \
    1160      {"setlimit", _PyCFunction_CAST(setlimit), METH_FASTCALL, setlimit__doc__},
    1161  
    1162  static PyObject *
    1163  setlimit_impl(pysqlite_Connection *self, int category, int limit);
    1164  
    1165  static PyObject *
    1166  setlimit(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
    1167  {
    1168      PyObject *return_value = NULL;
    1169      int category;
    1170      int limit;
    1171  
    1172      if (!_PyArg_CheckPositional("setlimit", nargs, 2, 2)) {
    1173          goto exit;
    1174      }
    1175      category = _PyLong_AsInt(args[0]);
    1176      if (category == -1 && PyErr_Occurred()) {
    1177          goto exit;
    1178      }
    1179      limit = _PyLong_AsInt(args[1]);
    1180      if (limit == -1 && PyErr_Occurred()) {
    1181          goto exit;
    1182      }
    1183      return_value = setlimit_impl(self, category, limit);
    1184  
    1185  exit:
    1186      return return_value;
    1187  }
    1188  
    1189  PyDoc_STRVAR(getlimit__doc__,
    1190  "getlimit($self, category, /)\n"
    1191  "--\n"
    1192  "\n"
    1193  "Get connection run-time limits.\n"
    1194  "\n"
    1195  "  category\n"
    1196  "    The limit category to be queried.");
    1197  
    1198  #define GETLIMIT_METHODDEF    \
    1199      {"getlimit", (PyCFunction)getlimit, METH_O, getlimit__doc__},
    1200  
    1201  static PyObject *
    1202  getlimit_impl(pysqlite_Connection *self, int category);
    1203  
    1204  static PyObject *
    1205  getlimit(pysqlite_Connection *self, PyObject *arg)
    1206  {
    1207      PyObject *return_value = NULL;
    1208      int category;
    1209  
    1210      category = _PyLong_AsInt(arg);
    1211      if (category == -1 && PyErr_Occurred()) {
    1212          goto exit;
    1213      }
    1214      return_value = getlimit_impl(self, category);
    1215  
    1216  exit:
    1217      return return_value;
    1218  }
    1219  
    1220  #ifndef CREATE_WINDOW_FUNCTION_METHODDEF
    1221      #define CREATE_WINDOW_FUNCTION_METHODDEF
    1222  #endif /* !defined(CREATE_WINDOW_FUNCTION_METHODDEF) */
    1223  
    1224  #ifndef PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF
    1225      #define PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF
    1226  #endif /* !defined(PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF) */
    1227  
    1228  #ifndef PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
    1229      #define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
    1230  #endif /* !defined(PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF) */
    1231  
    1232  #ifndef SERIALIZE_METHODDEF
    1233      #define SERIALIZE_METHODDEF
    1234  #endif /* !defined(SERIALIZE_METHODDEF) */
    1235  
    1236  #ifndef DESERIALIZE_METHODDEF
    1237      #define DESERIALIZE_METHODDEF
    1238  #endif /* !defined(DESERIALIZE_METHODDEF) */
    1239  /*[clinic end generated code: output=67e5b3dbade4a15b input=a9049054013a1b77]*/