#1150893 sqlite3-pcre2: Please mark REGEXP as SQLITE_DETERMINISTIC and SQLITE_INNOCUOUS

Package:
sqlite3-pcre2
Source:
sqlite3-pcre2
Description:
Perl-compatible regular expression support for SQLite
Submitter:
Date:
2026-10-14 13:41:03 UTC
Severity:
normal
Tags:
#1150893#5
Date:
2026-10-14 13:38:31 UTC
From:
To:
SQLITE_DETERMINISTIC lets sqlite better optimize queries that use REGEXP and is required to use it in partial indexes.

SQLITE_INNOCUOUS would be nice to have but only matters when TRUSTED_SCHEMA is turned off.

https://sqlite.org/c3ref/c_deterministic.html#sqlitedeterministic
SQLITE_DETERMINISTIC
    The SQLITE_DETERMINISTIC flag means that the new function always gives the same output when the input parameters are the same. The abs() function is deterministic, for example, but randomblob() is not. Functions must be deterministic in order to be used in certain contexts such as with the WHERE clause of partial indexes or in generated columns. SQLite might also optimize deterministic functions by factoring them out of inner loops.



https://sqlite.org/c3ref/c_deterministic.html#sqliteinnocuous
SQLITE_INNOCUOUS
    The SQLITE_INNOCUOUS flag means that the function is unlikely to cause problems even if misused. An innocuous function should have no side effects and should not depend on any values other than its input parameters. The abs() function is an example of an innocuous function. The load_extension() SQL function is not innocuous because of its side effects.

    SQLITE_INNOCUOUS is similar to SQLITE_DETERMINISTIC, but is not exactly the same. The random() function is an example of a function that is innocuous but not deterministic.

    Some heightened security settings (SQLITE_DBCONFIG_TRUSTED_SCHEMA and PRAGMA trusted_schema=OFF) disable the use of SQL functions inside views and triggers and in schema structures such as CHECK constraints, DEFAULT clauses, expression indexes, partial indexes, and generated columns unless the function is tagged with SQLITE_INNOCUOUS. Most built-in functions are innocuous. Developers are advised to avoid using the SQLITE_INNOCUOUS flag for application-defined functions unless the function has been carefully audited and found to be free of potentially security-adverse side-effects and information-leaks.


change pcre2.c line 157 from

```sqlite3_create_function(db, "REGEXP", 2, SQLITE_UTF8, cache, regexp, NULL, NULL);```

to

```sqlite3_create_function(db, "REGEXP", 2, SQLITE_UTF8|SQLITE_DETERMINISTIC|SQLITE_INNOCUOUS, cache, regexp, NULL, NULL);```