• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*[clinic input]
2 preserve
3 [clinic start generated code]*/
4 
5 PyDoc_STRVAR(pysqlite_complete_statement__doc__,
6 "complete_statement($module, /, statement)\n"
7 "--\n"
8 "\n"
9 "Checks if a string contains a complete SQL statement. Non-standard.");
10 
11 #define PYSQLITE_COMPLETE_STATEMENT_METHODDEF    \
12     {"complete_statement", (PyCFunction)(void(*)(void))pysqlite_complete_statement, METH_FASTCALL|METH_KEYWORDS, pysqlite_complete_statement__doc__},
13 
14 static PyObject *
15 pysqlite_complete_statement_impl(PyObject *module, const char *statement);
16 
17 static PyObject *
pysqlite_complete_statement(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)18 pysqlite_complete_statement(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
19 {
20     PyObject *return_value = NULL;
21     static const char * const _keywords[] = {"statement", NULL};
22     static _PyArg_Parser _parser = {NULL, _keywords, "complete_statement", 0};
23     PyObject *argsbuf[1];
24     const char *statement;
25 
26     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
27     if (!args) {
28         goto exit;
29     }
30     if (!PyUnicode_Check(args[0])) {
31         _PyArg_BadArgument("complete_statement", "argument 'statement'", "str", args[0]);
32         goto exit;
33     }
34     Py_ssize_t statement_length;
35     statement = PyUnicode_AsUTF8AndSize(args[0], &statement_length);
36     if (statement == NULL) {
37         goto exit;
38     }
39     if (strlen(statement) != (size_t)statement_length) {
40         PyErr_SetString(PyExc_ValueError, "embedded null character");
41         goto exit;
42     }
43     return_value = pysqlite_complete_statement_impl(module, statement);
44 
45 exit:
46     return return_value;
47 }
48 
49 PyDoc_STRVAR(pysqlite_enable_shared_cache__doc__,
50 "enable_shared_cache($module, /, do_enable)\n"
51 "--\n"
52 "\n"
53 "Enable or disable shared cache mode for the calling thread.\n"
54 "\n"
55 "Experimental/Non-standard.");
56 
57 #define PYSQLITE_ENABLE_SHARED_CACHE_METHODDEF    \
58     {"enable_shared_cache", (PyCFunction)(void(*)(void))pysqlite_enable_shared_cache, METH_FASTCALL|METH_KEYWORDS, pysqlite_enable_shared_cache__doc__},
59 
60 static PyObject *
61 pysqlite_enable_shared_cache_impl(PyObject *module, int do_enable);
62 
63 static PyObject *
pysqlite_enable_shared_cache(PyObject * module,PyObject * const * args,Py_ssize_t nargs,PyObject * kwnames)64 pysqlite_enable_shared_cache(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
65 {
66     PyObject *return_value = NULL;
67     static const char * const _keywords[] = {"do_enable", NULL};
68     static _PyArg_Parser _parser = {NULL, _keywords, "enable_shared_cache", 0};
69     PyObject *argsbuf[1];
70     int do_enable;
71 
72     args = _PyArg_UnpackKeywords(args, nargs, NULL, kwnames, &_parser, 1, 1, 0, argsbuf);
73     if (!args) {
74         goto exit;
75     }
76     do_enable = _PyLong_AsInt(args[0]);
77     if (do_enable == -1 && PyErr_Occurred()) {
78         goto exit;
79     }
80     return_value = pysqlite_enable_shared_cache_impl(module, do_enable);
81 
82 exit:
83     return return_value;
84 }
85 
86 PyDoc_STRVAR(pysqlite_register_adapter__doc__,
87 "register_adapter($module, type, caster, /)\n"
88 "--\n"
89 "\n"
90 "Registers an adapter with pysqlite\'s adapter registry. Non-standard.");
91 
92 #define PYSQLITE_REGISTER_ADAPTER_METHODDEF    \
93     {"register_adapter", (PyCFunction)(void(*)(void))pysqlite_register_adapter, METH_FASTCALL, pysqlite_register_adapter__doc__},
94 
95 static PyObject *
96 pysqlite_register_adapter_impl(PyObject *module, PyTypeObject *type,
97                                PyObject *caster);
98 
99 static PyObject *
pysqlite_register_adapter(PyObject * module,PyObject * const * args,Py_ssize_t nargs)100 pysqlite_register_adapter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
101 {
102     PyObject *return_value = NULL;
103     PyTypeObject *type;
104     PyObject *caster;
105 
106     if (!_PyArg_CheckPositional("register_adapter", nargs, 2, 2)) {
107         goto exit;
108     }
109     type = (PyTypeObject *)args[0];
110     caster = args[1];
111     return_value = pysqlite_register_adapter_impl(module, type, caster);
112 
113 exit:
114     return return_value;
115 }
116 
117 PyDoc_STRVAR(pysqlite_register_converter__doc__,
118 "register_converter($module, name, converter, /)\n"
119 "--\n"
120 "\n"
121 "Registers a converter with pysqlite. Non-standard.");
122 
123 #define PYSQLITE_REGISTER_CONVERTER_METHODDEF    \
124     {"register_converter", (PyCFunction)(void(*)(void))pysqlite_register_converter, METH_FASTCALL, pysqlite_register_converter__doc__},
125 
126 static PyObject *
127 pysqlite_register_converter_impl(PyObject *module, PyObject *orig_name,
128                                  PyObject *callable);
129 
130 static PyObject *
pysqlite_register_converter(PyObject * module,PyObject * const * args,Py_ssize_t nargs)131 pysqlite_register_converter(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
132 {
133     PyObject *return_value = NULL;
134     PyObject *orig_name;
135     PyObject *callable;
136 
137     if (!_PyArg_CheckPositional("register_converter", nargs, 2, 2)) {
138         goto exit;
139     }
140     if (!PyUnicode_Check(args[0])) {
141         _PyArg_BadArgument("register_converter", "argument 1", "str", args[0]);
142         goto exit;
143     }
144     if (PyUnicode_READY(args[0]) == -1) {
145         goto exit;
146     }
147     orig_name = args[0];
148     callable = args[1];
149     return_value = pysqlite_register_converter_impl(module, orig_name, callable);
150 
151 exit:
152     return return_value;
153 }
154 
155 PyDoc_STRVAR(pysqlite_enable_callback_trace__doc__,
156 "enable_callback_tracebacks($module, enable, /)\n"
157 "--\n"
158 "\n"
159 "Enable or disable callback functions throwing errors to stderr.");
160 
161 #define PYSQLITE_ENABLE_CALLBACK_TRACE_METHODDEF    \
162     {"enable_callback_tracebacks", (PyCFunction)pysqlite_enable_callback_trace, METH_O, pysqlite_enable_callback_trace__doc__},
163 
164 static PyObject *
165 pysqlite_enable_callback_trace_impl(PyObject *module, int enable);
166 
167 static PyObject *
pysqlite_enable_callback_trace(PyObject * module,PyObject * arg)168 pysqlite_enable_callback_trace(PyObject *module, PyObject *arg)
169 {
170     PyObject *return_value = NULL;
171     int enable;
172 
173     enable = _PyLong_AsInt(arg);
174     if (enable == -1 && PyErr_Occurred()) {
175         goto exit;
176     }
177     return_value = pysqlite_enable_callback_trace_impl(module, enable);
178 
179 exit:
180     return return_value;
181 }
182 
183 PyDoc_STRVAR(pysqlite_adapt__doc__,
184 "adapt($module, obj, proto=PrepareProtocolType, alt=<unrepresentable>, /)\n"
185 "--\n"
186 "\n"
187 "Adapt given object to given protocol. Non-standard.");
188 
189 #define PYSQLITE_ADAPT_METHODDEF    \
190     {"adapt", (PyCFunction)(void(*)(void))pysqlite_adapt, METH_FASTCALL, pysqlite_adapt__doc__},
191 
192 static PyObject *
193 pysqlite_adapt_impl(PyObject *module, PyObject *obj, PyObject *proto,
194                     PyObject *alt);
195 
196 static PyObject *
pysqlite_adapt(PyObject * module,PyObject * const * args,Py_ssize_t nargs)197 pysqlite_adapt(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
198 {
199     PyObject *return_value = NULL;
200     PyObject *obj;
201     PyObject *proto = (PyObject*)pysqlite_PrepareProtocolType;
202     PyObject *alt = NULL;
203 
204     if (!_PyArg_CheckPositional("adapt", nargs, 1, 3)) {
205         goto exit;
206     }
207     obj = args[0];
208     if (nargs < 2) {
209         goto skip_optional;
210     }
211     proto = args[1];
212     if (nargs < 3) {
213         goto skip_optional;
214     }
215     alt = args[2];
216 skip_optional:
217     return_value = pysqlite_adapt_impl(module, obj, proto, alt);
218 
219 exit:
220     return return_value;
221 }
222 /*[clinic end generated code: output=d87990f941c209fa input=a9049054013a1b77]*/
223