[New-bugs-announce] [issue45243] [sqlite3] add support for changing connection limits

Erlend E. Aasland report at bugs.python.org
Sun Sep 19 18:35:54 EDT 2021

New submission from Erlend E. Aasland <erlend.aasland at innova.no>:

I propose to add wrappers for the SQLite sqlite3_limit() C API. Using this API, it is possible to query and set limits on a connection basis. This will make it easier (and faster) to test various corner cases in the test suite without relying on test.support.bigmemtest.

Quoting from the SQLite sqlite3_limit() docs:

  Run-time limits are intended for use in applications that manage both their
  own internal database and also databases that are controlled by untrusted
  external sources. An example application might be a web browser that has its
  own databases for storing history and separate databases controlled by
  JavaScript applications downloaded off the Internet. The internal databases
  can be given the large, default limits. Databases managed by external
  sources can be given much smaller limits designed to prevent a denial of
  service attack.

See also:
  - https://sqlite.org/c3ref/limit.html
  - https://sqlite.org/c3ref/c_limit_attached.html
  - https://sqlite.org/limits.html

Limit categories (C&P from SQLite docs)

The maximum size of any string or BLOB or table row, in bytes.

The maximum length of an SQL statement, in bytes.

The maximum number of columns in a table definition or in the result set of a SELECT or the maximum number of columns in an index or in an ORDER BY or GROUP BY clause.

The maximum depth of the parse tree on any expression.

The maximum number of terms in a compound SELECT statement.

The maximum number of instructions in a virtual machine program used to implement an SQL statement. If sqlite3_prepare_v2() or the equivalent tries to allocate space for more than this many opcodes in a single prepared statement, an SQLITE_NOMEM error is returned.

The maximum number of arguments on a function.

The maximum number of attached databases.

The maximum length of the pattern argument to the LIKE or GLOB operators.

The maximum index number of any parameter in an SQL statement.

The maximum depth of recursion for triggers.

The maximum number of auxiliary worker threads that a single prepared statement may start.

assignee: erlendaasland
components: Extension Modules
messages: 402176
nosy: berker.peksag, erlendaasland, serhiy.storchaka
priority: low
severity: normal
status: open
title: [sqlite3] add support for changing connection limits
type: enhancement

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list