Commit Graph
7 Commits
Author SHA1 Message Date
Jiseok CHOI e19b622174 sqlite3: pass None for NULL authorizer args instead of crashing (#8534)
* sqlite3: pass None for NULL authorizer args instead of crashing

CPython's authorizer callback receives NULL for arg1/arg2/db_name/access
when not applicable (e.g. SQLITE_READ on a table gives NULL for the
database name in some versions). Previously RustPython passed these
pointers to ptr_to_str which would crash or produce an error.

Now ptr_to_str_or_none is used: NULL pointers become Python None, which
matches CPython behavior and allows test_table_access and
test_column_access to pass.

Assisted-by: GitHub Copilot:claude-sonnet-4-6

* fix(sqlite3): avoid reentrant deadlock in Statement::new

sqlite3_prepare_v2 can synchronously invoke the authorizer callback,
which may call back into Connection methods (e.g. set_authorizer)
that require the same db lock. Holding db_lock across the prepare()
call caused a self-deadlock when a callback re-entered the connection.

Release the lock after sql_limit check and copy the raw handle before
calling prepare(), so FFI calls that can trigger Python re-entrancy
happen outside the lock scope.

Fixes hang in test_authorizer_concurrent_mutation_in_call
2026-08-15 21:05:33 +09:00
Jiseok CHOI 7cda53b946 sqlite3: validate narg before creating functions/aggregates (#8532)
CPython 3.14 added check_num_params() which raises ProgrammingError when
narg/n_arg/num_params is out of range (-1..=SQLITE_LIMIT_FUNCTION_ARG).
RustPython passed invalid values directly to SQLite, resulting in an
OperationalError instead.

Add check_num_params() helper and call it in create_function(),
create_aggregate(), and create_window_function().

Assisted-by: GitHub Copilot:claude-sonnet-4-6
2026-08-15 21:04:45 +09:00
Shahar Naveh d93dd2a781 Update test_sqlite3 to 3.14.6 (#8172) 2026-06-30 23:49:27 +09:00
Jiseok CHOI 00440b179a Update sqlite3 and the tests to CPython 3.14.2 (#6787)
* Update sqlite3, dbm.sqlite3 and tests to CPython 3.14.2

* Add skip decorators for failing sqlite3 tests

Skip tests that fail due to unimplemented features or behavior differences:
- _iterdump not implemented (test_dump.py)
- Unraisable exception handling not implemented (test_hooks.py, test_userfunctions.py)
- Keyword-only arguments not supported for various methods
- Autocommit behavior differences (test_transactions.py)
- TransactionTests skipped due to timeout parameter type issue
- Various error message differences (test_dbapi.py)
- SQLITE_DBCONFIG constants not implemented
- Row and Connection signature inspection issues

All tests now pass with 95 skipped out of 493 total tests.

* Change @unittest.skip to @unittest.expectedFailure per code review

- Convert @unittest.skip decorators to @unittest.expectedFailure for tests that fail without panic/hang
- Keep @unittest.skip only for TransactionTests class (setUp fails with timeout=0 int type)

* fixup
2026-01-19 02:45:47 +09:00
Jiseok CHOI d42e8f0042 fix(sqlite): produce correct error for surrogate characters (#5962) 2025-07-14 14:21:36 +09:00
Jiseok CHOI 341341520e Fix SQLite large integer overflow error handling (#5916) 2025-07-09 17:14:45 +09:00
Steve Shi 765933136c Implement Sqlite3 Module (#4260)
* add supporting for PyAtomic<PyObject>

* create sqlite module

* add dependency sqlite3-sys

* add module constants

* import sqlite3 from cpython

* adjust lib

* add module structure

* impl Connection.cursor

* add module exceptions

* impl lstrip_sql

* impl statement new

* wip cursor.execute

* wip cursor

* wip error to exception

* add SqliteRaw and SqliteStatementRaw

* impl statement parameters binding

* wip cursor.execute

* add test_sqlite

* impl closeable connection

* impl closeable cursor

* impl cursor.executemany

* impl cursor.executescript

* impl cursor.fetch*

* impl connection.backup

* stage 1

* add support connection.backup with progress

* fix backup deadlock

* support changable isolation_level

* impl converter

* impl adapter

* impl text_factory and blob

* impl create_function

* impl create_function 2

* fix empty statement

* impl blob support

* impl create_aggregate

* impl create_aggregate 2

* refactor create_*

* impl enable_callback_traceback

* impl create_collation

* refactor create_* with CallbackData

* fix text and blob use SQLITE_TRANSIENT

* fix str to SQLITE_TEXT

* impl thread check

* impl Connection Factory

* impl busy timeout

* shift sqlite3-sys -> libsqlite3-sys

* refactor CallbackData

* impl create_window_function

* refactor callback functions

* add module attr converters

* fix nullable isolation_level

* add module attr adapters

* fix nullable adapt proto

* impl set_authorizer

* impl trace_callback

* impl set_progress_handler

* impl cancellable sqlite function*

* impl attributes for Connection

* fix some failed tests

* impl Row

* impl Blob methods

* impl Blob subscript & ass_subscript

* pass tests

* rebase

* no sqlite for wasm

* use ThreadId instead u64

* no libsqlite3-sys for wasm

* fix into_cstring for all platform

* fixup

* rebase

* fix windows into_bytes

* disable sqlite for android

* fixup
2023-01-07 22:03:24 +02:00