Commit Graph

307 Commits

Author SHA1 Message Date
Erlend Egeberg Aasland 890e22957d
bpo-42064: Migrate to `sqlite3_create_collation_v2` (GH-27156)
This implies that SQLite now takes care of destroying the callback
context (the PyObject callable it has been passed), so we can strip the
collation dict from the connection object.
2021-07-27 15:54:20 +02:00
Erlend Egeberg Aasland 4c0deb25ac
bpo-42064: Finalise establishing sqlite3 global state (GH-27155)
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
2021-07-20 12:59:18 +02:00
Erlend Egeberg Aasland 5007a4f23c
bpo-44641: Use vectorcall in sqlite3 collation callback (GH-27158) 2021-07-15 16:49:14 +01:00
Erlend Egeberg Aasland 81b8c0a385
Fix docstring typo in sqlite3.Connection.executescript/sqlite3.Cursor.executescript (GH-27147)
Both `executescript` methods contain the same docstring typo:
_"Executes a multiple SQL statements at once."_ => _"Executes multiple SQL statements at once."_

Automerge-Triggered-By: GH:pablogsal
2021-07-14 14:54:37 -07:00
Erlend Egeberg Aasland 05162993fe
bpo-42064: Move `sqlite3` exceptions to global state, part 2 of 2 (GH-26884)
Automerge-Triggered-By: GH:encukou
2021-07-14 04:26:44 -07:00
Erlend Egeberg Aasland b19f455339
bpo-44491: Allow clearing the sqlite3 authoriser callback (GH-26863) 2021-06-24 15:35:57 +01:00
Erlend Egeberg Aasland a50e28377b
bpo-42064: Move `sqlite3` exceptions to global state, part 1 of 2 (GH-26745)
Also adds a test to verify the (borrowed) exceptions in `sqlite3.Connection`.
2021-06-23 05:56:40 -07:00
Erlend Egeberg Aasland 019ad62afd
bpo-42064: Remove stale extern declarations in `sqlite3` headers (GH-26840) 2021-06-23 21:06:53 +09:00
Erlend Egeberg Aasland 7d0a47e1af
bpo-44087: Disallow instantiation of sqlite3.Statement (GH-26567) 2021-06-20 20:24:32 +01:00
Erlend Egeberg Aasland 185ecdc146
bpo-40956: Convert sqlite3.connect and sqlite3.Connection.__init__ to AC (GH-24421) 2021-06-20 20:24:00 +01:00
Erlend Egeberg Aasland 00710e6346
bpo-43908: Make heap types converted during 3.10 alpha immutable (GH-26351)
* Make functools types immutable

* Multibyte codec types are now immutable

* pyexpat.xmlparser is now immutable

* array.arrayiterator is now immutable

* _thread types are now immutable

* _csv types are now immutable

* _queue.SimpleQueue is now immutable

* mmap.mmap is now immutable

* unicodedata.UCD is now immutable

* sqlite3 types are now immutable

* _lsprof.Profiler is now immutable

* _overlapped.Overlapped is now immutable

* _operator types are now immutable

* winapi__overlapped.Overlapped is now immutable

* _lzma types are now immutable

* _bz2 types are now immutable

* _dbm.dbm and _gdbm.gdbm are now immutable
2021-06-17 11:06:09 +01:00
Erlend Egeberg Aasland 10a5c806d4
bpo-42064: Move sqlite3 types to global state (GH-26537)
* Move connection type to global state
* Move cursor type to global state
* Move prepare protocol type to global state
* Move row type to global state
* Move statement type to global state
* ADD_TYPE takes a pointer
* pysqlite_get_state is now static inline
2021-06-15 14:47:34 +02:00
Erlend Egeberg Aasland 1c02655fb0
bpo-44329: Refactor sqlite3 statement creation (GH-26566)
Call SQLite API's first, and return early in case of error. At the end,
allocate the object and initialise members. We now avoid unneeded
alloc/dealloc's in case the statement creation fails.
2021-06-08 16:00:56 +01:00
Pablo Galindo 781dc76577
Fix compiler errors for unused variables (GH-26601) 2021-06-08 13:16:24 +01:00
Erlend Egeberg Aasland 0d12f24552
bpo-44326: Remove unused members from pysqlite_Statement (GH-26564)
* Remove unused db member of pysqlite_Statement

* Remove unused sql method from statement object
2021-06-06 23:12:07 +01:00
Erlend Egeberg Aasland 505624e917
bpo-44327: Remove unused members from pysqlite_Connection (GH-26565)
* Remove timeout_started

* Remove timeout member
2021-06-06 23:11:44 +01:00
Pablo Galindo 6e3b7cf3af
bpo-44304: Ensure the sqlite3 destructor callback is always called with the GIL held (GH-26551) 2021-06-05 23:41:11 +01:00
Pablo Galindo fa106a685c
bpo-44304: Fix crash in the sqlite3 module when the GC clears Statement objects (GH-26545) 2021-06-05 03:50:39 +01:00
Erlend Egeberg Aasland 7459208de1
bpo-44315: Remove unused connection argument from pysqlite_step() (GH-26535) 2021-06-04 21:42:20 +01:00
Erlend Egeberg Aasland 006fd869e4
bpo-43853: Handle sqlite3_value_text() errors (GH-25422) 2021-06-04 19:34:00 +01:00
Erlend Egeberg Aasland 3446516ffa
bpo-44042: Optimize sqlite3 begin transaction (GH-25908) 2021-06-03 22:24:25 +01:00
Erlend Egeberg Aasland f461a7fc3f
bpo-42862: Use functools.lru_cache iso. _sqlite.Cache in sqlite3 module (GH-24203)
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
2021-06-03 20:59:26 +01:00
Erlend Egeberg Aasland d88b47b5a3
bpo-42213: Remove redundant cyclic GC hack in sqlite3 (GH-26517)
The sqlite3 module now fully implements the GC protocol, so there's no
need for this workaround anymore.

- Add and use managed resource helper for connections using TESTFN
- Sort test imports
- Split open-tests into their own test case

Automerge-Triggered-By: GH:vstinner
2021-06-03 09:38:19 -07:00
Erlend Egeberg Aasland 82ad22a97d
bpo-42213: Check connection in sqlite3.Connection.__enter__ (GH-26512)
Try to harden connection close:

- add tests that exercise stuff against a closed database
- add wrapper for sqlite3_close_v2()
- check connection on __enter__
- explicitly free pending statements before close()
- sqlite3_close_v2() always returns SQLITE_OK
2021-06-03 17:53:47 +02:00
Erlend Egeberg Aasland fbf25b8c0d
bpo-44165: pysqlite_statement_create now returns a Py object, not an int (GH-26484)
GH-26206 was broken by GH-26475.
2021-06-02 14:22:15 +01:00
Erlend Egeberg Aasland a384b6c040
bpo-44165: Optimise sqlite3 statement preparation by passing string size (GH-26206) 2021-06-02 13:26:06 +01:00
Erlend Egeberg Aasland fffa0f92ad
bpo-42972: Track sqlite3 statement objects (GH-26475)
Allocate and track statement objects in pysqlite_statement_create.

By allocating and tracking creation of statement object in
pysqlite_statement_create(), the caller does not need to worry about GC
syncronization, and eliminates the possibility of getting a badly
created object. All related fault handling is moved to
pysqlite_statement_create().

Co-authored-by: Victor Stinner <vstinner@python.org>
2021-06-01 12:47:37 +02:00
Erlend Egeberg Aasland d1124b09e8
bpo-42972: Fix sqlite3 traverse/clear functions (GH-26452) 2021-05-31 10:24:56 +02:00
Erlend Egeberg Aasland d3c277a59c
bpo-42972: Fully implement GC protocol for sqlite3 heap types (GH-26104) 2021-05-25 18:43:56 +01:00
Erlend Egeberg Aasland 0988ed09b4
bpo-44047: Remove unused argument to _pysqlite_seterror (GH-25915) 2021-05-07 16:15:01 +03:00
Erlend Egeberg Aasland cbb7b9ed4a
bpo-43434: Clean up sqlite3.connect() after GH-25818 (GH-25823) 2021-05-02 23:10:51 +01:00
Erlend Egeberg Aasland c96cc089f6
bpo-43434: Move sqlite3.connect audit events to sqlite3.Connection.__init__ (GH-25818) 2021-05-02 22:25:17 +01:00
Erlend Egeberg Aasland 7244c0060d
bpo-43762: Add audit events for loading of sqlite3 extensions (GH-25246) 2021-04-27 00:16:46 +01:00
Erlend Egeberg Aasland e9194ea6ea
bpo-43852: Improve tuple creation in sqlite3 (GH-25421) 2021-04-23 14:21:08 +03:00
Erlend Egeberg Aasland 5cb601f956
bpo-43296: Handle sqlite3_value_blob() errors (GH-24674) 2021-04-15 00:09:11 +03:00
Erlend Egeberg Aasland def919342f
bpo-43505: Explicitly initialize and shutdown sqlite3 (GH-25404) 2021-04-14 17:50:16 +03:00
Erlend Egeberg Aasland c1ae741997
bpo-43265: Improve sqlite3.Connection.backup error handling (GH-24586) 2021-04-14 14:45:49 +03:00
Erlend Egeberg Aasland 6f1e8ccffa
bpo-43752: Fix sqlite3 regression for zero-sized blobs with converters (GH-25228) 2021-04-14 14:18:49 +03:00
Erlend Egeberg Aasland 2256a2876b
bpo-43444: Move sqlite3 MODULE_NAME from setup.py to module.h (GH-24801) 2021-03-13 17:33:39 +02:00
Erlend Egeberg Aasland e161ec5dd7
bpo-43369: sqlite3_column_{text,blob} failures now raise MemoryError (GH-24723) 2021-03-04 11:50:25 +02:00
Mariusz Felisiak 3b4b2cf418
bpo-43368: Fix fetching empty bytes in sqlite3 (GH-24706)
Regression introduced in 47feb1feb2.
2021-03-03 16:16:24 +02:00
Alex Henrie 25e244c925
bpo-39523: Use do-while loop pysqlite_cursor_executescript() (GH-18305) 2021-03-02 09:40:34 +02:00
Erlend Egeberg Aasland 2183d06bc8
bpo-43251: sqlite3_column_name() failures now raise MemoryError (GH-24609) 2021-02-28 19:01:06 +02:00
Erlend Egeberg Aasland 5e48e83688
bpo-43294: Remove unused variables in pysqlite_connection_*() (GH-24658) 2021-02-26 16:30:22 +02:00
Erlend Egeberg Aasland 3150754f91
bpo-43314: Remove SQLITE_OPEN_URI ifdef (GH-24637)
SQLite 3.7.15 is required as by GH-24106. SQLITE_OPEN_URI was added in
SQLite 3.7.7.
2021-02-26 02:48:19 +02:00
Erlend Egeberg Aasland 91ea37c84a
bpo-43290: Remove workaround from pysqlite_step() (GH-24638)
From the SQLite 3.5.3 changelog:

sqlite3_step() returns SQLITE_MISUSE instead of crashing when called
with a NULL parameter.

The workaround no longer needed because we no longer support
SQLite releases older than 3.7.15.
2021-02-26 01:39:34 +02:00
Erlend Egeberg Aasland 38b6c2acd4
bpo-43269: Remove redundant extern keywords (GH-24605) 2021-02-21 12:07:49 +02:00
Erlend Egeberg Aasland bf838a6e7e
bpo-43269: Clean up sqlite3 file scope (GH-24578) 2021-02-21 02:29:19 +02:00
Erlend Egeberg Aasland 2bb0bf4dd8
bpo-43258: Make sqlite3 callback functions static (GH-24574) 2021-02-19 13:59:24 +02:00
Erlend Egeberg Aasland 979b23cbe4
bpo-43258: Don't allocate sqlite3 aggregate context for empty queries (GH-24569) 2021-02-19 13:20:32 +02:00