123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668 |
- /*[clinic input]
- preserve
- [clinic start generated code]*/
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- # include "pycore_gc.h" // PyGC_Head
- # include "pycore_runtime.h" // _Py_ID()
- #endif
- static int
- pysqlite_connection_init_impl(pysqlite_Connection *self, PyObject *database,
- double timeout, int detect_types,
- const char *isolation_level,
- int check_same_thread, PyObject *factory,
- int cache_size, int uri,
- enum autocommit_mode autocommit);
- static int
- pysqlite_connection_init(PyObject *self, PyObject *args, PyObject *kwargs)
- {
- int return_value = -1;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 9
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .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), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"database", "timeout", "detect_types", "isolation_level", "check_same_thread", "factory", "cached_statements", "uri", "autocommit", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "Connection",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[9];
- PyObject * const *fastargs;
- Py_ssize_t nargs = PyTuple_GET_SIZE(args);
- Py_ssize_t noptargs = nargs + (kwargs ? PyDict_GET_SIZE(kwargs) : 0) - 1;
- PyObject *database;
- double timeout = 5.0;
- int detect_types = 0;
- const char *isolation_level = "";
- int check_same_thread = 1;
- PyObject *factory = (PyObject*)clinic_state()->ConnectionType;
- int cache_size = 128;
- int uri = 0;
- enum autocommit_mode autocommit = LEGACY_TRANSACTION_CONTROL;
- fastargs = _PyArg_UnpackKeywords(_PyTuple_CAST(args)->ob_item, nargs, kwargs, NULL, &_parser, 1, 8, 0, argsbuf);
- if (!fastargs) {
- goto exit;
- }
- database = fastargs[0];
- if (!noptargs) {
- goto skip_optional_pos;
- }
- if (fastargs[1]) {
- if (PyFloat_CheckExact(fastargs[1])) {
- timeout = PyFloat_AS_DOUBLE(fastargs[1]);
- }
- else
- {
- timeout = PyFloat_AsDouble(fastargs[1]);
- if (timeout == -1.0 && PyErr_Occurred()) {
- goto exit;
- }
- }
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- if (fastargs[2]) {
- detect_types = _PyLong_AsInt(fastargs[2]);
- if (detect_types == -1 && PyErr_Occurred()) {
- goto exit;
- }
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- if (fastargs[3]) {
- if (!isolation_level_converter(fastargs[3], &isolation_level)) {
- goto exit;
- }
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- if (fastargs[4]) {
- check_same_thread = PyObject_IsTrue(fastargs[4]);
- if (check_same_thread < 0) {
- goto exit;
- }
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- if (fastargs[5]) {
- factory = fastargs[5];
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- if (fastargs[6]) {
- cache_size = _PyLong_AsInt(fastargs[6]);
- if (cache_size == -1 && PyErr_Occurred()) {
- goto exit;
- }
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- if (fastargs[7]) {
- uri = PyObject_IsTrue(fastargs[7]);
- if (uri < 0) {
- goto exit;
- }
- if (!--noptargs) {
- goto skip_optional_pos;
- }
- }
- skip_optional_pos:
- if (!noptargs) {
- goto skip_optional_kwonly;
- }
- if (!autocommit_converter(fastargs[8], &autocommit)) {
- goto exit;
- }
- skip_optional_kwonly:
- return_value = pysqlite_connection_init_impl((pysqlite_Connection *)self, database, timeout, detect_types, isolation_level, check_same_thread, factory, cache_size, uri, autocommit);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(pysqlite_connection_cursor__doc__,
- "cursor($self, /, factory=<unrepresentable>)\n"
- "--\n"
- "\n"
- "Return a cursor for the connection.");
- #define PYSQLITE_CONNECTION_CURSOR_METHODDEF \
- {"cursor", _PyCFunction_CAST(pysqlite_connection_cursor), METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_cursor__doc__},
- static PyObject *
- pysqlite_connection_cursor_impl(pysqlite_Connection *self, PyObject *factory);
- static PyObject *
- pysqlite_connection_cursor(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 1
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(factory), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"factory", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "cursor",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[1];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
- PyObject *factory = NULL;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 1, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!noptargs) {
- goto skip_optional_pos;
- }
- factory = args[0];
- skip_optional_pos:
- return_value = pysqlite_connection_cursor_impl(self, factory);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(blobopen__doc__,
- "blobopen($self, table, column, row, /, *, readonly=False, name=\'main\')\n"
- "--\n"
- "\n"
- "Open and return a BLOB object.\n"
- "\n"
- " table\n"
- " Table name.\n"
- " column\n"
- " Column name.\n"
- " row\n"
- " Row index.\n"
- " readonly\n"
- " Open the BLOB without write permissions.\n"
- " name\n"
- " Database name.");
- #define BLOBOPEN_METHODDEF \
- {"blobopen", _PyCFunction_CAST(blobopen), METH_FASTCALL|METH_KEYWORDS, blobopen__doc__},
- static PyObject *
- blobopen_impl(pysqlite_Connection *self, const char *table, const char *col,
- sqlite3_int64 row, int readonly, const char *name);
- static PyObject *
- blobopen(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 2
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(readonly), &_Py_ID(name), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"", "", "", "readonly", "name", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "blobopen",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[5];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;
- const char *table;
- const char *col;
- sqlite3_int64 row;
- int readonly = 0;
- const char *name = "main";
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!PyUnicode_Check(args[0])) {
- _PyArg_BadArgument("blobopen", "argument 1", "str", args[0]);
- goto exit;
- }
- Py_ssize_t table_length;
- table = PyUnicode_AsUTF8AndSize(args[0], &table_length);
- if (table == NULL) {
- goto exit;
- }
- if (strlen(table) != (size_t)table_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- if (!PyUnicode_Check(args[1])) {
- _PyArg_BadArgument("blobopen", "argument 2", "str", args[1]);
- goto exit;
- }
- Py_ssize_t col_length;
- col = PyUnicode_AsUTF8AndSize(args[1], &col_length);
- if (col == NULL) {
- goto exit;
- }
- if (strlen(col) != (size_t)col_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- if (!sqlite3_int64_converter(args[2], &row)) {
- goto exit;
- }
- if (!noptargs) {
- goto skip_optional_kwonly;
- }
- if (args[3]) {
- readonly = PyObject_IsTrue(args[3]);
- if (readonly < 0) {
- goto exit;
- }
- if (!--noptargs) {
- goto skip_optional_kwonly;
- }
- }
- if (!PyUnicode_Check(args[4])) {
- _PyArg_BadArgument("blobopen", "argument 'name'", "str", args[4]);
- goto exit;
- }
- Py_ssize_t name_length;
- name = PyUnicode_AsUTF8AndSize(args[4], &name_length);
- if (name == NULL) {
- goto exit;
- }
- if (strlen(name) != (size_t)name_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- skip_optional_kwonly:
- return_value = blobopen_impl(self, table, col, row, readonly, name);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(pysqlite_connection_close__doc__,
- "close($self, /)\n"
- "--\n"
- "\n"
- "Close the database connection.\n"
- "\n"
- "Any pending transaction is not committed implicitly.");
- #define PYSQLITE_CONNECTION_CLOSE_METHODDEF \
- {"close", (PyCFunction)pysqlite_connection_close, METH_NOARGS, pysqlite_connection_close__doc__},
- static PyObject *
- pysqlite_connection_close_impl(pysqlite_Connection *self);
- static PyObject *
- pysqlite_connection_close(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
- {
- return pysqlite_connection_close_impl(self);
- }
- PyDoc_STRVAR(pysqlite_connection_commit__doc__,
- "commit($self, /)\n"
- "--\n"
- "\n"
- "Commit any pending transaction to the database.\n"
- "\n"
- "If there is no open transaction, this method is a no-op.");
- #define PYSQLITE_CONNECTION_COMMIT_METHODDEF \
- {"commit", (PyCFunction)pysqlite_connection_commit, METH_NOARGS, pysqlite_connection_commit__doc__},
- static PyObject *
- pysqlite_connection_commit_impl(pysqlite_Connection *self);
- static PyObject *
- pysqlite_connection_commit(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
- {
- return pysqlite_connection_commit_impl(self);
- }
- PyDoc_STRVAR(pysqlite_connection_rollback__doc__,
- "rollback($self, /)\n"
- "--\n"
- "\n"
- "Roll back to the start of any pending transaction.\n"
- "\n"
- "If there is no open transaction, this method is a no-op.");
- #define PYSQLITE_CONNECTION_ROLLBACK_METHODDEF \
- {"rollback", (PyCFunction)pysqlite_connection_rollback, METH_NOARGS, pysqlite_connection_rollback__doc__},
- static PyObject *
- pysqlite_connection_rollback_impl(pysqlite_Connection *self);
- static PyObject *
- pysqlite_connection_rollback(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
- {
- return pysqlite_connection_rollback_impl(self);
- }
- PyDoc_STRVAR(pysqlite_connection_create_function__doc__,
- "create_function($self, /, name, narg, func, *, deterministic=False)\n"
- "--\n"
- "\n"
- "Creates a new function.");
- #define PYSQLITE_CONNECTION_CREATE_FUNCTION_METHODDEF \
- {"create_function", _PyCFunction_CAST(pysqlite_connection_create_function), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_function__doc__},
- static PyObject *
- pysqlite_connection_create_function_impl(pysqlite_Connection *self,
- PyTypeObject *cls, const char *name,
- int narg, PyObject *func,
- int deterministic);
- static PyObject *
- pysqlite_connection_create_function(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 4
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(name), &_Py_ID(narg), &_Py_ID(func), &_Py_ID(deterministic), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"name", "narg", "func", "deterministic", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "create_function",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[4];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 3;
- const char *name;
- int narg;
- PyObject *func;
- int deterministic = 0;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!PyUnicode_Check(args[0])) {
- _PyArg_BadArgument("create_function", "argument 'name'", "str", args[0]);
- goto exit;
- }
- Py_ssize_t name_length;
- name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
- if (name == NULL) {
- goto exit;
- }
- if (strlen(name) != (size_t)name_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- narg = _PyLong_AsInt(args[1]);
- if (narg == -1 && PyErr_Occurred()) {
- goto exit;
- }
- func = args[2];
- if (!noptargs) {
- goto skip_optional_kwonly;
- }
- deterministic = PyObject_IsTrue(args[3]);
- if (deterministic < 0) {
- goto exit;
- }
- skip_optional_kwonly:
- return_value = pysqlite_connection_create_function_impl(self, cls, name, narg, func, deterministic);
- exit:
- return return_value;
- }
- #if defined(HAVE_WINDOW_FUNCTIONS)
- PyDoc_STRVAR(create_window_function__doc__,
- "create_window_function($self, name, num_params, aggregate_class, /)\n"
- "--\n"
- "\n"
- "Creates or redefines an aggregate window function. Non-standard.\n"
- "\n"
- " name\n"
- " The name of the SQL aggregate window function to be created or\n"
- " redefined.\n"
- " num_params\n"
- " The number of arguments the step and inverse methods takes.\n"
- " aggregate_class\n"
- " A class with step(), finalize(), value(), and inverse() methods.\n"
- " Set to None to clear the window function.");
- #define CREATE_WINDOW_FUNCTION_METHODDEF \
- {"create_window_function", _PyCFunction_CAST(create_window_function), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, create_window_function__doc__},
- static PyObject *
- create_window_function_impl(pysqlite_Connection *self, PyTypeObject *cls,
- const char *name, int num_params,
- PyObject *aggregate_class);
- static PyObject *
- create_window_function(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
- #else
- # define KWTUPLE NULL
- #endif
- static const char * const _keywords[] = {"", "", "", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "create_window_function",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[3];
- const char *name;
- int num_params;
- PyObject *aggregate_class;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!PyUnicode_Check(args[0])) {
- _PyArg_BadArgument("create_window_function", "argument 1", "str", args[0]);
- goto exit;
- }
- Py_ssize_t name_length;
- name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
- if (name == NULL) {
- goto exit;
- }
- if (strlen(name) != (size_t)name_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- num_params = _PyLong_AsInt(args[1]);
- if (num_params == -1 && PyErr_Occurred()) {
- goto exit;
- }
- aggregate_class = args[2];
- return_value = create_window_function_impl(self, cls, name, num_params, aggregate_class);
- exit:
- return return_value;
- }
- #endif /* defined(HAVE_WINDOW_FUNCTIONS) */
- PyDoc_STRVAR(pysqlite_connection_create_aggregate__doc__,
- "create_aggregate($self, /, name, n_arg, aggregate_class)\n"
- "--\n"
- "\n"
- "Creates a new aggregate.");
- #define PYSQLITE_CONNECTION_CREATE_AGGREGATE_METHODDEF \
- {"create_aggregate", _PyCFunction_CAST(pysqlite_connection_create_aggregate), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_aggregate__doc__},
- static PyObject *
- pysqlite_connection_create_aggregate_impl(pysqlite_Connection *self,
- PyTypeObject *cls,
- const char *name, int n_arg,
- PyObject *aggregate_class);
- static PyObject *
- pysqlite_connection_create_aggregate(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 3
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(name), &_Py_ID(n_arg), &_Py_ID(aggregate_class), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"name", "n_arg", "aggregate_class", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "create_aggregate",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[3];
- const char *name;
- int n_arg;
- PyObject *aggregate_class;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 3, 3, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!PyUnicode_Check(args[0])) {
- _PyArg_BadArgument("create_aggregate", "argument 'name'", "str", args[0]);
- goto exit;
- }
- Py_ssize_t name_length;
- name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
- if (name == NULL) {
- goto exit;
- }
- if (strlen(name) != (size_t)name_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- n_arg = _PyLong_AsInt(args[1]);
- if (n_arg == -1 && PyErr_Occurred()) {
- goto exit;
- }
- aggregate_class = args[2];
- return_value = pysqlite_connection_create_aggregate_impl(self, cls, name, n_arg, aggregate_class);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(pysqlite_connection_set_authorizer__doc__,
- "set_authorizer($self, /, authorizer_callback)\n"
- "--\n"
- "\n"
- "Sets authorizer callback.");
- #define PYSQLITE_CONNECTION_SET_AUTHORIZER_METHODDEF \
- {"set_authorizer", _PyCFunction_CAST(pysqlite_connection_set_authorizer), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_authorizer__doc__},
- static PyObject *
- pysqlite_connection_set_authorizer_impl(pysqlite_Connection *self,
- PyTypeObject *cls,
- PyObject *callable);
- static PyObject *
- pysqlite_connection_set_authorizer(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 1
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(authorizer_callback), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"authorizer_callback", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "set_authorizer",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[1];
- PyObject *callable;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- callable = args[0];
- return_value = pysqlite_connection_set_authorizer_impl(self, cls, callable);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(pysqlite_connection_set_progress_handler__doc__,
- "set_progress_handler($self, /, progress_handler, n)\n"
- "--\n"
- "\n"
- "Sets progress handler callback.");
- #define PYSQLITE_CONNECTION_SET_PROGRESS_HANDLER_METHODDEF \
- {"set_progress_handler", _PyCFunction_CAST(pysqlite_connection_set_progress_handler), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_progress_handler__doc__},
- static PyObject *
- pysqlite_connection_set_progress_handler_impl(pysqlite_Connection *self,
- PyTypeObject *cls,
- PyObject *callable, int n);
- static PyObject *
- pysqlite_connection_set_progress_handler(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 2
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(progress_handler), _Py_LATIN1_CHR('n'), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"progress_handler", "n", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "set_progress_handler",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[2];
- PyObject *callable;
- int n;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- callable = args[0];
- n = _PyLong_AsInt(args[1]);
- if (n == -1 && PyErr_Occurred()) {
- goto exit;
- }
- return_value = pysqlite_connection_set_progress_handler_impl(self, cls, callable, n);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(pysqlite_connection_set_trace_callback__doc__,
- "set_trace_callback($self, /, trace_callback)\n"
- "--\n"
- "\n"
- "Sets a trace callback called for each SQL statement (passed as unicode).");
- #define PYSQLITE_CONNECTION_SET_TRACE_CALLBACK_METHODDEF \
- {"set_trace_callback", _PyCFunction_CAST(pysqlite_connection_set_trace_callback), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_set_trace_callback__doc__},
- static PyObject *
- pysqlite_connection_set_trace_callback_impl(pysqlite_Connection *self,
- PyTypeObject *cls,
- PyObject *callable);
- static PyObject *
- pysqlite_connection_set_trace_callback(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 1
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(trace_callback), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"trace_callback", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "set_trace_callback",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[1];
- PyObject *callable;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- callable = args[0];
- return_value = pysqlite_connection_set_trace_callback_impl(self, cls, callable);
- exit:
- return return_value;
- }
- #if defined(PY_SQLITE_ENABLE_LOAD_EXTENSION)
- PyDoc_STRVAR(pysqlite_connection_enable_load_extension__doc__,
- "enable_load_extension($self, enable, /)\n"
- "--\n"
- "\n"
- "Enable dynamic loading of SQLite extension modules.");
- #define PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF \
- {"enable_load_extension", (PyCFunction)pysqlite_connection_enable_load_extension, METH_O, pysqlite_connection_enable_load_extension__doc__},
- static PyObject *
- pysqlite_connection_enable_load_extension_impl(pysqlite_Connection *self,
- int onoff);
- static PyObject *
- pysqlite_connection_enable_load_extension(pysqlite_Connection *self, PyObject *arg)
- {
- PyObject *return_value = NULL;
- int onoff;
- onoff = PyObject_IsTrue(arg);
- if (onoff < 0) {
- goto exit;
- }
- return_value = pysqlite_connection_enable_load_extension_impl(self, onoff);
- exit:
- return return_value;
- }
- #endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */
- #if defined(PY_SQLITE_ENABLE_LOAD_EXTENSION)
- PyDoc_STRVAR(pysqlite_connection_load_extension__doc__,
- "load_extension($self, name, /, *, entrypoint=None)\n"
- "--\n"
- "\n"
- "Load SQLite extension module.");
- #define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF \
- {"load_extension", _PyCFunction_CAST(pysqlite_connection_load_extension), METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_load_extension__doc__},
- static PyObject *
- pysqlite_connection_load_extension_impl(pysqlite_Connection *self,
- const char *extension_name,
- const char *entrypoint);
- static PyObject *
- pysqlite_connection_load_extension(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 1
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(entrypoint), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"", "entrypoint", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "load_extension",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[2];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
- const char *extension_name;
- const char *entrypoint = NULL;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!PyUnicode_Check(args[0])) {
- _PyArg_BadArgument("load_extension", "argument 1", "str", args[0]);
- goto exit;
- }
- Py_ssize_t extension_name_length;
- extension_name = PyUnicode_AsUTF8AndSize(args[0], &extension_name_length);
- if (extension_name == NULL) {
- goto exit;
- }
- if (strlen(extension_name) != (size_t)extension_name_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- if (!noptargs) {
- goto skip_optional_kwonly;
- }
- if (args[1] == Py_None) {
- entrypoint = NULL;
- }
- else if (PyUnicode_Check(args[1])) {
- Py_ssize_t entrypoint_length;
- entrypoint = PyUnicode_AsUTF8AndSize(args[1], &entrypoint_length);
- if (entrypoint == NULL) {
- goto exit;
- }
- if (strlen(entrypoint) != (size_t)entrypoint_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- }
- else {
- _PyArg_BadArgument("load_extension", "argument 'entrypoint'", "str or None", args[1]);
- goto exit;
- }
- skip_optional_kwonly:
- return_value = pysqlite_connection_load_extension_impl(self, extension_name, entrypoint);
- exit:
- return return_value;
- }
- #endif /* defined(PY_SQLITE_ENABLE_LOAD_EXTENSION) */
- PyDoc_STRVAR(pysqlite_connection_execute__doc__,
- "execute($self, sql, parameters=<unrepresentable>, /)\n"
- "--\n"
- "\n"
- "Executes an SQL statement.");
- #define PYSQLITE_CONNECTION_EXECUTE_METHODDEF \
- {"execute", _PyCFunction_CAST(pysqlite_connection_execute), METH_FASTCALL, pysqlite_connection_execute__doc__},
- static PyObject *
- pysqlite_connection_execute_impl(pysqlite_Connection *self, PyObject *sql,
- PyObject *parameters);
- static PyObject *
- pysqlite_connection_execute(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
- {
- PyObject *return_value = NULL;
- PyObject *sql;
- PyObject *parameters = NULL;
- if (!_PyArg_CheckPositional("execute", nargs, 1, 2)) {
- goto exit;
- }
- if (!PyUnicode_Check(args[0])) {
- _PyArg_BadArgument("execute", "argument 1", "str", args[0]);
- goto exit;
- }
- if (PyUnicode_READY(args[0]) == -1) {
- goto exit;
- }
- sql = args[0];
- if (nargs < 2) {
- goto skip_optional;
- }
- parameters = args[1];
- skip_optional:
- return_value = pysqlite_connection_execute_impl(self, sql, parameters);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(pysqlite_connection_executemany__doc__,
- "executemany($self, sql, parameters, /)\n"
- "--\n"
- "\n"
- "Repeatedly executes an SQL statement.");
- #define PYSQLITE_CONNECTION_EXECUTEMANY_METHODDEF \
- {"executemany", _PyCFunction_CAST(pysqlite_connection_executemany), METH_FASTCALL, pysqlite_connection_executemany__doc__},
- static PyObject *
- pysqlite_connection_executemany_impl(pysqlite_Connection *self,
- PyObject *sql, PyObject *parameters);
- static PyObject *
- pysqlite_connection_executemany(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
- {
- PyObject *return_value = NULL;
- PyObject *sql;
- PyObject *parameters;
- if (!_PyArg_CheckPositional("executemany", nargs, 2, 2)) {
- goto exit;
- }
- if (!PyUnicode_Check(args[0])) {
- _PyArg_BadArgument("executemany", "argument 1", "str", args[0]);
- goto exit;
- }
- if (PyUnicode_READY(args[0]) == -1) {
- goto exit;
- }
- sql = args[0];
- parameters = args[1];
- return_value = pysqlite_connection_executemany_impl(self, sql, parameters);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(pysqlite_connection_executescript__doc__,
- "executescript($self, sql_script, /)\n"
- "--\n"
- "\n"
- "Executes multiple SQL statements at once.");
- #define PYSQLITE_CONNECTION_EXECUTESCRIPT_METHODDEF \
- {"executescript", (PyCFunction)pysqlite_connection_executescript, METH_O, pysqlite_connection_executescript__doc__},
- PyDoc_STRVAR(pysqlite_connection_interrupt__doc__,
- "interrupt($self, /)\n"
- "--\n"
- "\n"
- "Abort any pending database operation.");
- #define PYSQLITE_CONNECTION_INTERRUPT_METHODDEF \
- {"interrupt", (PyCFunction)pysqlite_connection_interrupt, METH_NOARGS, pysqlite_connection_interrupt__doc__},
- static PyObject *
- pysqlite_connection_interrupt_impl(pysqlite_Connection *self);
- static PyObject *
- pysqlite_connection_interrupt(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
- {
- return pysqlite_connection_interrupt_impl(self);
- }
- PyDoc_STRVAR(pysqlite_connection_iterdump__doc__,
- "iterdump($self, /)\n"
- "--\n"
- "\n"
- "Returns iterator to the dump of the database in an SQL text format.");
- #define PYSQLITE_CONNECTION_ITERDUMP_METHODDEF \
- {"iterdump", (PyCFunction)pysqlite_connection_iterdump, METH_NOARGS, pysqlite_connection_iterdump__doc__},
- static PyObject *
- pysqlite_connection_iterdump_impl(pysqlite_Connection *self);
- static PyObject *
- pysqlite_connection_iterdump(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
- {
- return pysqlite_connection_iterdump_impl(self);
- }
- PyDoc_STRVAR(pysqlite_connection_backup__doc__,
- "backup($self, /, target, *, pages=-1, progress=None, name=\'main\',\n"
- " sleep=0.25)\n"
- "--\n"
- "\n"
- "Makes a backup of the database.");
- #define PYSQLITE_CONNECTION_BACKUP_METHODDEF \
- {"backup", _PyCFunction_CAST(pysqlite_connection_backup), METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_backup__doc__},
- static PyObject *
- pysqlite_connection_backup_impl(pysqlite_Connection *self,
- pysqlite_Connection *target, int pages,
- PyObject *progress, const char *name,
- double sleep);
- static PyObject *
- pysqlite_connection_backup(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 5
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(target), &_Py_ID(pages), &_Py_ID(progress), &_Py_ID(name), &_Py_ID(sleep), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"target", "pages", "progress", "name", "sleep", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "backup",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[5];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
- pysqlite_Connection *target;
- int pages = -1;
- PyObject *progress = Py_None;
- const char *name = "main";
- double sleep = 0.25;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!PyObject_TypeCheck(args[0], clinic_state()->ConnectionType)) {
- _PyArg_BadArgument("backup", "argument 'target'", (clinic_state()->ConnectionType)->tp_name, args[0]);
- goto exit;
- }
- target = (pysqlite_Connection *)args[0];
- if (!noptargs) {
- goto skip_optional_kwonly;
- }
- if (args[1]) {
- pages = _PyLong_AsInt(args[1]);
- if (pages == -1 && PyErr_Occurred()) {
- goto exit;
- }
- if (!--noptargs) {
- goto skip_optional_kwonly;
- }
- }
- if (args[2]) {
- progress = args[2];
- if (!--noptargs) {
- goto skip_optional_kwonly;
- }
- }
- if (args[3]) {
- if (!PyUnicode_Check(args[3])) {
- _PyArg_BadArgument("backup", "argument 'name'", "str", args[3]);
- goto exit;
- }
- Py_ssize_t name_length;
- name = PyUnicode_AsUTF8AndSize(args[3], &name_length);
- if (name == NULL) {
- goto exit;
- }
- if (strlen(name) != (size_t)name_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- if (!--noptargs) {
- goto skip_optional_kwonly;
- }
- }
- if (PyFloat_CheckExact(args[4])) {
- sleep = PyFloat_AS_DOUBLE(args[4]);
- }
- else
- {
- sleep = PyFloat_AsDouble(args[4]);
- if (sleep == -1.0 && PyErr_Occurred()) {
- goto exit;
- }
- }
- skip_optional_kwonly:
- return_value = pysqlite_connection_backup_impl(self, target, pages, progress, name, sleep);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(pysqlite_connection_create_collation__doc__,
- "create_collation($self, name, callback, /)\n"
- "--\n"
- "\n"
- "Creates a collation function.");
- #define PYSQLITE_CONNECTION_CREATE_COLLATION_METHODDEF \
- {"create_collation", _PyCFunction_CAST(pysqlite_connection_create_collation), METH_METHOD|METH_FASTCALL|METH_KEYWORDS, pysqlite_connection_create_collation__doc__},
- static PyObject *
- pysqlite_connection_create_collation_impl(pysqlite_Connection *self,
- PyTypeObject *cls,
- const char *name,
- PyObject *callable);
- static PyObject *
- pysqlite_connection_create_collation(pysqlite_Connection *self, PyTypeObject *cls, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- # define KWTUPLE (PyObject *)&_Py_SINGLETON(tuple_empty)
- #else
- # define KWTUPLE NULL
- #endif
- static const char * const _keywords[] = {"", "", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "create_collation",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[2];
- const char *name;
- PyObject *callable;
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 2, 2, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!PyUnicode_Check(args[0])) {
- _PyArg_BadArgument("create_collation", "argument 1", "str", args[0]);
- goto exit;
- }
- Py_ssize_t name_length;
- name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
- if (name == NULL) {
- goto exit;
- }
- if (strlen(name) != (size_t)name_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- callable = args[1];
- return_value = pysqlite_connection_create_collation_impl(self, cls, name, callable);
- exit:
- return return_value;
- }
- #if defined(PY_SQLITE_HAVE_SERIALIZE)
- PyDoc_STRVAR(serialize__doc__,
- "serialize($self, /, *, name=\'main\')\n"
- "--\n"
- "\n"
- "Serialize a database into a byte string.\n"
- "\n"
- " name\n"
- " Which database to serialize.\n"
- "\n"
- "For an ordinary on-disk database file, the serialization is just a copy of the\n"
- "disk file. For an in-memory database or a \"temp\" database, the serialization is\n"
- "the same sequence of bytes which would be written to disk if that database\n"
- "were backed up to disk.");
- #define SERIALIZE_METHODDEF \
- {"serialize", _PyCFunction_CAST(serialize), METH_FASTCALL|METH_KEYWORDS, serialize__doc__},
- static PyObject *
- serialize_impl(pysqlite_Connection *self, const char *name);
- static PyObject *
- serialize(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 1
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(name), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"name", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "serialize",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[1];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 0;
- const char *name = "main";
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 0, 0, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (!noptargs) {
- goto skip_optional_kwonly;
- }
- if (!PyUnicode_Check(args[0])) {
- _PyArg_BadArgument("serialize", "argument 'name'", "str", args[0]);
- goto exit;
- }
- Py_ssize_t name_length;
- name = PyUnicode_AsUTF8AndSize(args[0], &name_length);
- if (name == NULL) {
- goto exit;
- }
- if (strlen(name) != (size_t)name_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- skip_optional_kwonly:
- return_value = serialize_impl(self, name);
- exit:
- return return_value;
- }
- #endif /* defined(PY_SQLITE_HAVE_SERIALIZE) */
- #if defined(PY_SQLITE_HAVE_SERIALIZE)
- PyDoc_STRVAR(deserialize__doc__,
- "deserialize($self, data, /, *, name=\'main\')\n"
- "--\n"
- "\n"
- "Load a serialized database.\n"
- "\n"
- " data\n"
- " The serialized database content.\n"
- " name\n"
- " Which database to reopen with the deserialization.\n"
- "\n"
- "The deserialize interface causes the database connection to disconnect from the\n"
- "target database, and then reopen it as an in-memory database based on the given\n"
- "serialized data.\n"
- "\n"
- "The deserialize interface will fail with SQLITE_BUSY if the database is\n"
- "currently in a read transaction or is involved in a backup operation.");
- #define DESERIALIZE_METHODDEF \
- {"deserialize", _PyCFunction_CAST(deserialize), METH_FASTCALL|METH_KEYWORDS, deserialize__doc__},
- static PyObject *
- deserialize_impl(pysqlite_Connection *self, Py_buffer *data,
- const char *name);
- static PyObject *
- deserialize(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
- {
- PyObject *return_value = NULL;
- #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
- #define NUM_KEYWORDS 1
- static struct {
- PyGC_Head _this_is_not_used;
- PyObject_VAR_HEAD
- PyObject *ob_item[NUM_KEYWORDS];
- } _kwtuple = {
- .ob_base = PyVarObject_HEAD_INIT(&PyTuple_Type, NUM_KEYWORDS)
- .ob_item = { &_Py_ID(name), },
- };
- #undef NUM_KEYWORDS
- #define KWTUPLE (&_kwtuple.ob_base.ob_base)
- #else // !Py_BUILD_CORE
- # define KWTUPLE NULL
- #endif // !Py_BUILD_CORE
- static const char * const _keywords[] = {"", "name", NULL};
- static _PyArg_Parser _parser = {
- .keywords = _keywords,
- .fname = "deserialize",
- .kwtuple = KWTUPLE,
- };
- #undef KWTUPLE
- PyObject *argsbuf[2];
- Py_ssize_t noptargs = nargs + (kwnames ? PyTuple_GET_SIZE(kwnames) : 0) - 1;
- Py_buffer data = {NULL, NULL};
- const char *name = "main";
- args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
- if (!args) {
- goto exit;
- }
- if (PyUnicode_Check(args[0])) {
- Py_ssize_t len;
- const char *ptr = PyUnicode_AsUTF8AndSize(args[0], &len);
- if (ptr == NULL) {
- goto exit;
- }
- PyBuffer_FillInfo(&data, args[0], (void *)ptr, len, 1, 0);
- }
- else { /* any bytes-like object */
- if (PyObject_GetBuffer(args[0], &data, PyBUF_SIMPLE) != 0) {
- goto exit;
- }
- if (!PyBuffer_IsContiguous(&data, 'C')) {
- _PyArg_BadArgument("deserialize", "argument 1", "contiguous buffer", args[0]);
- goto exit;
- }
- }
- if (!noptargs) {
- goto skip_optional_kwonly;
- }
- if (!PyUnicode_Check(args[1])) {
- _PyArg_BadArgument("deserialize", "argument 'name'", "str", args[1]);
- goto exit;
- }
- Py_ssize_t name_length;
- name = PyUnicode_AsUTF8AndSize(args[1], &name_length);
- if (name == NULL) {
- goto exit;
- }
- if (strlen(name) != (size_t)name_length) {
- PyErr_SetString(PyExc_ValueError, "embedded null character");
- goto exit;
- }
- skip_optional_kwonly:
- return_value = deserialize_impl(self, &data, name);
- exit:
- /* Cleanup for data */
- if (data.obj) {
- PyBuffer_Release(&data);
- }
- return return_value;
- }
- #endif /* defined(PY_SQLITE_HAVE_SERIALIZE) */
- PyDoc_STRVAR(pysqlite_connection_enter__doc__,
- "__enter__($self, /)\n"
- "--\n"
- "\n"
- "Called when the connection is used as a context manager.\n"
- "\n"
- "Returns itself as a convenience to the caller.");
- #define PYSQLITE_CONNECTION_ENTER_METHODDEF \
- {"__enter__", (PyCFunction)pysqlite_connection_enter, METH_NOARGS, pysqlite_connection_enter__doc__},
- static PyObject *
- pysqlite_connection_enter_impl(pysqlite_Connection *self);
- static PyObject *
- pysqlite_connection_enter(pysqlite_Connection *self, PyObject *Py_UNUSED(ignored))
- {
- return pysqlite_connection_enter_impl(self);
- }
- PyDoc_STRVAR(pysqlite_connection_exit__doc__,
- "__exit__($self, type, value, traceback, /)\n"
- "--\n"
- "\n"
- "Called when the connection is used as a context manager.\n"
- "\n"
- "If there was any exception, a rollback takes place; otherwise we commit.");
- #define PYSQLITE_CONNECTION_EXIT_METHODDEF \
- {"__exit__", _PyCFunction_CAST(pysqlite_connection_exit), METH_FASTCALL, pysqlite_connection_exit__doc__},
- static PyObject *
- pysqlite_connection_exit_impl(pysqlite_Connection *self, PyObject *exc_type,
- PyObject *exc_value, PyObject *exc_tb);
- static PyObject *
- pysqlite_connection_exit(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
- {
- PyObject *return_value = NULL;
- PyObject *exc_type;
- PyObject *exc_value;
- PyObject *exc_tb;
- if (!_PyArg_CheckPositional("__exit__", nargs, 3, 3)) {
- goto exit;
- }
- exc_type = args[0];
- exc_value = args[1];
- exc_tb = args[2];
- return_value = pysqlite_connection_exit_impl(self, exc_type, exc_value, exc_tb);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(setlimit__doc__,
- "setlimit($self, category, limit, /)\n"
- "--\n"
- "\n"
- "Set connection run-time limits.\n"
- "\n"
- " category\n"
- " The limit category to be set.\n"
- " limit\n"
- " The new limit. If the new limit is a negative number, the limit is\n"
- " unchanged.\n"
- "\n"
- "Attempts to increase a limit above its hard upper bound are silently truncated\n"
- "to the hard upper bound. Regardless of whether or not the limit was changed,\n"
- "the prior value of the limit is returned.");
- #define SETLIMIT_METHODDEF \
- {"setlimit", _PyCFunction_CAST(setlimit), METH_FASTCALL, setlimit__doc__},
- static PyObject *
- setlimit_impl(pysqlite_Connection *self, int category, int limit);
- static PyObject *
- setlimit(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
- {
- PyObject *return_value = NULL;
- int category;
- int limit;
- if (!_PyArg_CheckPositional("setlimit", nargs, 2, 2)) {
- goto exit;
- }
- category = _PyLong_AsInt(args[0]);
- if (category == -1 && PyErr_Occurred()) {
- goto exit;
- }
- limit = _PyLong_AsInt(args[1]);
- if (limit == -1 && PyErr_Occurred()) {
- goto exit;
- }
- return_value = setlimit_impl(self, category, limit);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(getlimit__doc__,
- "getlimit($self, category, /)\n"
- "--\n"
- "\n"
- "Get connection run-time limits.\n"
- "\n"
- " category\n"
- " The limit category to be queried.");
- #define GETLIMIT_METHODDEF \
- {"getlimit", (PyCFunction)getlimit, METH_O, getlimit__doc__},
- static PyObject *
- getlimit_impl(pysqlite_Connection *self, int category);
- static PyObject *
- getlimit(pysqlite_Connection *self, PyObject *arg)
- {
- PyObject *return_value = NULL;
- int category;
- category = _PyLong_AsInt(arg);
- if (category == -1 && PyErr_Occurred()) {
- goto exit;
- }
- return_value = getlimit_impl(self, category);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(setconfig__doc__,
- "setconfig($self, op, enable=True, /)\n"
- "--\n"
- "\n"
- "Set a boolean connection configuration option.\n"
- "\n"
- " op\n"
- " The configuration verb; one of the sqlite3.SQLITE_DBCONFIG codes.");
- #define SETCONFIG_METHODDEF \
- {"setconfig", _PyCFunction_CAST(setconfig), METH_FASTCALL, setconfig__doc__},
- static PyObject *
- setconfig_impl(pysqlite_Connection *self, int op, int enable);
- static PyObject *
- setconfig(pysqlite_Connection *self, PyObject *const *args, Py_ssize_t nargs)
- {
- PyObject *return_value = NULL;
- int op;
- int enable = 1;
- if (!_PyArg_CheckPositional("setconfig", nargs, 1, 2)) {
- goto exit;
- }
- op = _PyLong_AsInt(args[0]);
- if (op == -1 && PyErr_Occurred()) {
- goto exit;
- }
- if (nargs < 2) {
- goto skip_optional;
- }
- enable = PyObject_IsTrue(args[1]);
- if (enable < 0) {
- goto exit;
- }
- skip_optional:
- return_value = setconfig_impl(self, op, enable);
- exit:
- return return_value;
- }
- PyDoc_STRVAR(getconfig__doc__,
- "getconfig($self, op, /)\n"
- "--\n"
- "\n"
- "Query a boolean connection configuration option.\n"
- "\n"
- " op\n"
- " The configuration verb; one of the sqlite3.SQLITE_DBCONFIG codes.");
- #define GETCONFIG_METHODDEF \
- {"getconfig", (PyCFunction)getconfig, METH_O, getconfig__doc__},
- static int
- getconfig_impl(pysqlite_Connection *self, int op);
- static PyObject *
- getconfig(pysqlite_Connection *self, PyObject *arg)
- {
- PyObject *return_value = NULL;
- int op;
- int _return_value;
- op = _PyLong_AsInt(arg);
- if (op == -1 && PyErr_Occurred()) {
- goto exit;
- }
- _return_value = getconfig_impl(self, op);
- if ((_return_value == -1) && PyErr_Occurred()) {
- goto exit;
- }
- return_value = PyBool_FromLong((long)_return_value);
- exit:
- return return_value;
- }
- #ifndef CREATE_WINDOW_FUNCTION_METHODDEF
- #define CREATE_WINDOW_FUNCTION_METHODDEF
- #endif /* !defined(CREATE_WINDOW_FUNCTION_METHODDEF) */
- #ifndef PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF
- #define PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF
- #endif /* !defined(PYSQLITE_CONNECTION_ENABLE_LOAD_EXTENSION_METHODDEF) */
- #ifndef PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
- #define PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF
- #endif /* !defined(PYSQLITE_CONNECTION_LOAD_EXTENSION_METHODDEF) */
- #ifndef SERIALIZE_METHODDEF
- #define SERIALIZE_METHODDEF
- #endif /* !defined(SERIALIZE_METHODDEF) */
- #ifndef DESERIALIZE_METHODDEF
- #define DESERIALIZE_METHODDEF
- #endif /* !defined(DESERIALIZE_METHODDEF) */
- /*[clinic end generated code: output=305d580e3eaa622d input=a9049054013a1b77]*/
|