summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/cursor.c
Commit message (Collapse)AuthorAgeFilesLines
* gh-139327: consolidate `sqlite3_finalize` and `sqlite3_reset` usages (GH-139329)Bénédikt Tran2025-10-151-9/+92
|
* gh-139327: fix some reference leaks in `sqlite3` error branches (#139328)Bénédikt Tran2025-10-011-24/+27
|
* gh-139283: correctly handle `size` limit in `cursor.fetchmany()` (#139296)Bénédikt Tran2025-09-301-12/+37
| | | | | | | | Passing a negative or zero size to `cursor.fetchmany()` made it fetch all rows instead of none. While this could be considered a security vulnerability, it was decided to treat this issue as a regular bug as passing a non-sanitized *size* value in the first place is not recommended.
* gh-135607: remove null checking of weakref list in dealloc of extension ↵Xuanteng Huang2025-06-301-3/+2
| | | | | | modules and objects (#135614) Co-authored-by: Kumar Aditya <kumaraditya@python.org> Co-authored-by: Victor Stinner <vstinner@python.org>
* gh-111178: Change Argument Clinic signature for METH_O (#130682)Victor Stinner2025-03-111-2/+2
| | | Use "PyObject*" for METH_O functions to fix an undefined behavior.
* gh-129928: Rework sqlite3 error helpers (#129929)Erlend E. Aasland2025-02-111-7/+6
| | | | | | | | | Add a helper for raising DB-API compatible exceptions based on the result code of SQLite C APIs. Some APIs do not store the error indicator on the database pointer, so we need to be able to deduce the DB-API compatible exception directly from the error code. - rename _pysqlite_seterror() as set_error_from_db() - introduce set_error_from_code()
* gh-111178: fix UBSan failures in `Modules/_sqlite` (GH-129087)Bénédikt Tran2025-01-311-10/+16
| | | | | | | | | | | * fix UBSan failures for `pysqlite_Blob` * fix UBSan failures for `pysqlite_Connection` * fix UBSan failures for `pysqlite_Cursor` * fix UBSan failures for `pysqlite_PrepareProtocol` * fix UBSan failures for `pysqlite_Row` * fix UBSan failures for `pysqlite_Statement` * suppress unused return values
* gh-111178: Generate correct signature for most self converters (#128447)Erlend E. Aasland2025-01-201-2/+2
|
* gh-118928: sqlite3: correctly bail if sequences of params are used with ↵Erlend E. Aasland2024-05-201-0/+1
| | | | named placeholders (#119197)
* gh-118928: sqlite3: disallow sequences of params with named placeholders ↵Erlend E. Aasland2024-05-141-6/+2
| | | | | | | | (#118929) Follow-up of gh-101693. The previous DeprecationWarning is replaced with raising sqlite3.ProgrammingError. Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
* gh-117995: Don't raise DeprecationWarnings for indexed nameless params (#118001)Erlend E. Aasland2024-04-221-1/+1
| | | | | Filter out '?NNN' placeholders when looking for named params. Co-authored-by: AN Long <aisk@users.noreply.github.com>
* gh-111789: Simplify the sqlite code (GH-111829)Serhiy Storchaka2023-11-101-12/+2
| | | | Use new C API functions PyDict_GetItemRef() and PyMapping_GetOptionalItemString().
* gh-106869: Use new PyMemberDef constant names (#106871)Victor Stinner2023-07-251-7/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove '#include "structmember.h"'. * If needed, add <stddef.h> to get offsetof() function. * Update Parser/asdl_c.py to regenerate Python/Python-ast.c. * Replace: * T_SHORT => Py_T_SHORT * T_INT => Py_T_INT * T_LONG => Py_T_LONG * T_FLOAT => Py_T_FLOAT * T_DOUBLE => Py_T_DOUBLE * T_STRING => Py_T_STRING * T_OBJECT => _Py_T_OBJECT * T_CHAR => Py_T_CHAR * T_BYTE => Py_T_BYTE * T_UBYTE => Py_T_UBYTE * T_USHORT => Py_T_USHORT * T_UINT => Py_T_UINT * T_ULONG => Py_T_ULONG * T_STRING_INPLACE => Py_T_STRING_INPLACE * T_BOOL => Py_T_BOOL * T_OBJECT_EX => Py_T_OBJECT_EX * T_LONGLONG => Py_T_LONGLONG * T_ULONGLONG => Py_T_ULONGLONG * T_PYSSIZET => Py_T_PYSSIZET * T_NONE => _Py_T_NONE * READONLY => Py_READONLY * PY_AUDIT_READ => Py_AUDIT_READ * READ_RESTRICTED => Py_AUDIT_READ * PY_WRITE_RESTRICTED => _Py_WRITE_RESTRICTED * RESTRICTED => (READ_RESTRICTED | _Py_WRITE_RESTRICTED)
* gh-106320: Remove private _PyErr C API functions (#106356)Victor Stinner2023-07-031-0/+6
| | | | Remove private _PyErr C API functions: move them to the internal C API (pycore_pyerrors.h).
* gh-102192: Replace PyErr_Fetch/Restore etc by more efficient alternatives ↵Irit Katriel2023-02-241-6/+4
| | | | (in Modules/) (#102196)
* gh-101693: In sqlite3, deprecate using named placeholders with parameters ↵Erlend E. Aasland2023-02-151-0/+13
| | | | supplied as a sequence (#101698)
* gh-99537: Use Py_SETREF() function in C code (#99656)Victor Stinner2022-11-221-2/+1
| | | | | | | | | | | | | | | Fix potential race condition in code patterns: * Replace "Py_DECREF(var); var = new;" with "Py_SETREF(var, new);" * Replace "Py_XDECREF(var); var = new;" with "Py_XSETREF(var, new);" * Replace "Py_CLEAR(var); var = new;" with "Py_XSETREF(var, new);" Other changes: * Replace "old = var; var = new; Py_DECREF(var)" with "Py_SETREF(var, new);" * Replace "old = var; var = new; Py_XDECREF(var)" with "Py_XSETREF(var, new);" * And remove the "old" variable.
* gh-83638: Add sqlite3.Connection.autocommit for PEP 249 compliant behaviour ↵Erlend E. Aasland2022-11-121-2/+5
| | | | | | | | | | (#93823) Introduce the autocommit attribute to Connection and the autocommit parameter to connect() for PEP 249-compliant transaction handling. Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM> Co-authored-by: Géry Ogam <gery.ogam@gmail.com>
* gh-88239: Use sqlite3_stmt_busy() to determine if statements are in use (#25984)Erlend Egeberg Aasland2022-06-271-16/+3
|
* gh-89121: Keep the number of pending SQLite statements to a minimum (#30379)Erlend Egeberg Aasland2022-06-231-22/+12
| | | | | Make sure statements that have run to completion or errored are reset and cleared off the cursor for all paths in execute() and executemany().
* gh-94028: Clear and reset sqlite3 statements properly in cursor iternext ↵Erlend Egeberg Aasland2022-06-211-0/+3
| | | | (GH-94042)
* gh-93421: Update sqlite3 cursor.rowcount only after SQLITE_DONE (#93526)Erlend Egeberg Aasland2022-06-081-8/+11
|
* gh-89022: Improve sqlite3 exceptions related to binding params and API ↵Erlend Egeberg Aasland2022-05-041-14/+19
| | | | | | | | | | | | | misuse (#91572) * Map SQLITE_MISUSE to sqlite3.InterfaceError SQLITE_MISUSE implies misuse of the SQLite C API, which, if it happens, is _not_ a user error; it is an sqlite3 extension module error. * Raise better errors when binding parameters fail. Instead of always raising InterfaceError, guessing what went wrong, raise accurate exceptions with more accurate error messages.
* gh-80254: Disallow recursive usage of cursors in `sqlite3` converters (#29054)Erlend Egeberg Aasland2022-05-031-7/+24
| | | | Co-authored-by: Sergey Fedoseev <fedoseev.sergey@gmail.com> Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
* gh-92206: Improve scoping of sqlite3 statement helper (#92260)Erlend Egeberg Aasland2022-05-031-2/+8
|
* gh-92206: Improve scoping of sqlite3 bind param functions (#92250)Erlend Egeberg Aasland2022-05-031-1/+249
|
* gh-92206: Improve scoping of sqlite3 reset statement helper (#92241)Erlend Egeberg Aasland2022-05-031-10/+28
|
* gh-92206: Improve scoping of sqlite3 register cursor helper (#92212)Erlend Egeberg Aasland2022-05-031-1/+23
|
* gh-92206: Move pysqlite_step() to Modules/_sqlite/cursor.c (#92207)Erlend Egeberg Aasland2022-05-031-2/+14
|
* sqlite3: normalise pre-acronym determiners (GH-31772)Erlend Egeberg Aasland2022-03-111-4/+4
| | | For consistency, replace "a SQL" with "an SQL".
* Docstring: replace pysqlite with sqlite3 (GH-31758)Erlend Egeberg Aasland2022-03-091-4/+4
| | | | Replace two instances of "pysqlite" with "sqlite3" in sqlite3 docstrings. Also reword "is a no-op" to "does nothing" for clarity.
* bpo-46878: Purge 'non-standard' from sqlite3 docstrings (GH-31612)Erlend Egeberg Aasland2022-03-081-2/+2
|
* bpo-46541: Replace _Py_IDENTIFIER with _Py_ID in sqlite3 (GH-31351)Erlend Egeberg Aasland2022-02-161-5/+2
|
* bpo-46541: Replace core use of _Py_IDENTIFIER() with statically initialized ↵Eric Snow2022-02-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | global objects. (gh-30928) We're no longer using _Py_IDENTIFIER() (or _Py_static_string()) in any core CPython code. It is still used in a number of non-builtin stdlib modules. The replacement is: PyUnicodeObject (not pointer) fields under _PyRuntimeState, statically initialized as part of _PyRuntime. A new _Py_GET_GLOBAL_IDENTIFIER() macro facilitates lookup of the fields (along with _Py_GET_GLOBAL_STRING() for non-identifier strings). https://bugs.python.org/issue46541#msg411799 explains the rationale for this change. The core of the change is in: * (new) Include/internal/pycore_global_strings.h - the declarations for the global strings, along with the macros * Include/internal/pycore_runtime_init.h - added the static initializers for the global strings * Include/internal/pycore_global_objects.h - where the struct in pycore_global_strings.h is hooked into _PyRuntimeState * Tools/scripts/generate_global_objects.py - added generation of the global string declarations and static initializers I've also added a --check flag to generate_global_objects.py (along with make check-global-objects) to check for unused global strings. That check is added to the PR CI config. The remainder of this change updates the core code to use _Py_GET_GLOBAL_IDENTIFIER() instead of _Py_IDENTIFIER() and the related _Py*Id functions (likewise for _Py_GET_GLOBAL_STRING() instead of _Py_static_string()). This includes adding a few functions where there wasn't already an alternative to _Py*Id(), replacing the _Py_Identifier * parameter with PyObject *. The following are not changed (yet): * stop using _Py_IDENTIFIER() in the stdlib modules * (maybe) get rid of _Py_IDENTIFIER(), etc. entirely -- this may not be doable as at least one package on PyPI using this (private) API * (maybe) intern the strings during runtime init https://bugs.python.org/issue46541
* bpo-46249: Move set lastrowid out of the sqlite3 query loop (GH-30489)Erlend Egeberg Aasland2022-01-221-11/+11
|
* bpo-44092: Remove unused member `reset` from `sqlite3.Cursor` (GH-30377)Erlend Egeberg Aasland2022-01-031-19/+0
| | | Automerge-Triggered-By: GH:pablogsal
* bpo-45512: Simplify manage isolation level (GH-29562)Dong-hee Na2021-11-171-3/+9
|
* bpo-45754: Use correct SQLite limit when checking statement length (GH-29489)Erlend Egeberg Aasland2021-11-101-2/+2
|
* bpo-42064: Convert `sqlite3` global state to module state (GH-29073)Erlend Egeberg Aasland2021-10-271-6/+5
|
* bpo-45041: Restore `sqlite3` executescript behaviour for `SELECT` queries ↵Erlend Egeberg Aasland2021-10-071-1/+1
| | | | | | | (GH-28509) * bpo-45041: Restore sqlite3 executescript behaviour for select queries * Add regression test
* bpo-44958: Revert GH-27844 (GH-28574)Erlend Egeberg Aasland2021-09-261-19/+26
| | | | This reverts commit 050d1035957379d70e8601e6f5636637716a264b, but keeps the tests.
* bpo-44958: Only reset `sqlite3` statements when needed (GH-27844)Erlend Egeberg Aasland2021-09-211-26/+19
|
* bpo-45041: Simplify `sqlite3.Cursor.executescript()` (GH-28020)Erlend Egeberg Aasland2021-09-191-42/+25
|
* bpo-45040: Simplify sqlite3 transaction control functions (GH-28019)Erlend Egeberg Aasland2021-09-191-16/+7
|
* bpo-42064: Offset arguments for PyObject_Vectorcall in the _sqlite module ↵Petr Viktorin2021-08-311-2/+3
| | | | | | | (GH-27931) This allows e.g. methods to be called efficiently by providing space for a "self" argument; see PY_VECTORCALL_ARGUMENTS_OFFSET docs.
* bpo-44976: Lazy creation of sqlite3 result rows (GH-27884)Erlend Egeberg Aasland2021-08-251-55/+29
|
* bpo-44965: Early exit for non-DML statements in sqlite3.Cursor.executemany() ↵Erlend Egeberg Aasland2021-08-211-8/+7
| | | | (GH-27865)
* bpo-44859: Improve error handling in sqlite3 and and raise more accurate ↵Serhiy Storchaka2021-08-081-23/+14
| | | | | | | | | | | | | | | | | | | | exceptions. (GH-27654) * MemoryError is now raised instead of sqlite3.Warning when memory is not enough for encoding a statement to UTF-8 in Connection.__call__() and Cursor.execute(). * UnicodEncodeError is now raised instead of sqlite3.Warning when the statement contains surrogate characters in Connection.__call__() and Cursor.execute(). * TypeError is now raised instead of ValueError for non-string script argument in Cursor.executescript(). * ValueError is now raised for script containing the null character instead of truncating it in Cursor.executescript(). * Correctly handle exceptions raised when getting boolean value of the result of the progress handler. * Add many tests covering different corner cases. Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no>
* bpo-42064: Optimise `sqlite3` state access, part 1 (GH-27273)Erlend Egeberg Aasland2021-07-291-22/+28
| | | | | | | | | | Prepare for module state: - Add "get state by defining class" and "get state by module def" stubs - Add AC defining class when needed - Add state pointer to connection context - Pass state as argument to utility functions Automerge-Triggered-By: GH:encukou
* bpo-42064: Finalise establishing sqlite3 global state (GH-27155)Erlend Egeberg Aasland2021-07-201-2/+4
| | | | | | With this, all sqlite3 static globals have been moved to the global state. There are a couple of global static strings left, but there should be no need for adding them to the state. https://bugs.python.org/issue42064