-
Notifications
You must be signed in to change notification settings - Fork 1.5k
sqlite3: add SQLITE_DBCONFIG constants, setconfig() and getconfig() #8535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ever0de
wants to merge
2
commits into
RustPython:main
Choose a base branch
from
ever0de:fix/sqlite-dbconfig
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+77
−7
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 725
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 10090
🌐 Web query:
libsqlite3-sys 0.38 bundled sqlite3.h SQLITE_DBCONFIG_STMT_SCANSTATUS SQLITE_DBCONFIG_REVERSE_SCANORDER SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE SQLITE_DBCONFIG_ENABLE_COMMENTS💡 Result:
The constants mentioned—SQLITE_DBCONFIG_STMT_SCANSTATUS, SQLITE_DBCONFIG_REVERSE_SCANORDER, SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE, SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE, and SQLITE_DBCONFIG_ENABLE_COMMENTS—are configuration options for the sqlite3_db_config C API function [1][2]. These options were introduced in SQLite 3.42.0 (released May 16, 2023) [3][4]. Regarding their usage in libsqlite3-sys 0.38.x: - libsqlite3-sys 0.38.x includes bundled versions of SQLite [5]. As of libsqlite3-sys 0.38.1, the bundled version is SQLite 3.53.2 [5], which is significantly newer than the 3.42.0 version where these options were first introduced [3]. - Consequently, these constants are available in the bundled sqlite3.h and the corresponding Rust bindings provided by libsqlite3-sys 0.38.x [6][7]. Summary of the options: - SQLITE_DBCONFIG_STMT_SCANSTATUS: Enables or disables the collection of run-time performance statistics for a database connection (requires SQLITE_ENABLE_STMT_SCANSTATUS build) [1][8]. - SQLITE_DBCONFIG_REVERSE_SCANORDER: Changes the default scan order of tables and indexes, equivalent to PRAGMA reverse_unordered_selects [9][2]. - SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE, SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE, and SQLITE_DBCONFIG_ENABLE_COMMENTS: These are specific configuration options added to control attachment and comment-related behaviors, also available as of SQLite 3.42.0 [4]. If you are using the bundled feature of libsqlite3-sys, these constants are fully supported and exposed through the generated bindings [5][6].
Citations:
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 200
🌐 Web query:
site:docs.rs/crate/libsqlite3-sys/0.38.0/source/sqlite3/sqlite3.h SQLITE_DBCONFIG💡 Result:
SQLITE_DBCONFIG refers to a set of constant integer values used as configuration verbs for the sqlite3_db_config interface in SQLite [1][2][3]. This interface allows applications to modify settings for a specific database connection, rather than applying global configuration changes [3]. The sqlite3_db_config function is defined as follows [3]: int sqlite3_db_config(sqlite3 *db, int op,...); The second argument (op) is one of the SQLITE_DBCONFIG constants, and subsequent arguments vary based on the chosen option [3]. Most of these configuration options follow a standard format where they take two additional arguments: an integer to enable (1) or disable (0) a feature, and a pointer to an integer where the new status is stored [1][4]. However, some options, such as SQLITE_DBCONFIG_MAINDBNAME and SQLITE_DBCONFIG_LOOKASIDE, use unique argument formats and require specific handling [1][4]. Commonly used SQLITE_DBCONFIG options include: SQLITE_DBCONFIG_MAINDBNAME: Used to change the name of the main database schema. It requires a pointer to a constant UTF8 string [1][2]. SQLITE_DBCONFIG_LOOKASIDE: Used to adjust lookaside memory configuration for an individual connection [5][4]. SQLITE_DBCONFIG_ENABLE_FKEY: Used to enable or disable foreign key constraints [4]. SQLITE_DBCONFIG_RESET_DATABASE: Used in conjunction with a VACUUM command to reset a database file to an empty state [2]. Applications should always check the return code of sqlite3_db_config to verify if a configuration call was successful, as unsupported or discontinued options will return a non-zero error code [1][2]. New configuration options may be added in future versions of SQLite [1].
Citations:
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 238
🌐 Web query:
SQLite 3.53.2 sqlite3.h SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE SQLITE_DBCONFIG_ENABLE_COMMENTS SQLITE_DBCONFIG_FP_DIGITS💡 Result:
The constants SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE (1020), SQLITE_DBCONFIG_ENABLE_COMMENTS (1022), and SQLITE_DBCONFIG_FP_DIGITS (1023) are database connection configuration options used with the sqlite3_db_config interface in SQLite [1][2]. SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE (1020) This option controls whether the ATTACH DATABASE SQL command is permitted to create a new database file if the specified file does not already exist [1]. It is enabled by default [1]. Applications can use this setting to disable automatic file creation to prevent unauthorized or accidental file generation, which is particularly relevant in security-sensitive contexts where untrusted paths might be used [1][3]. SQLITE_DBCONFIG_ENABLE_COMMENTS (1022) This option enables or disables the ability to include comments in SQL input text [4]. Introduced in version 3.49.0, it is enabled by default [4][5]. A later refinement ensures that comments are still permitted when reading a schema from an existing sqlite_schema table, even if they are blocked in new SQL statements [5]. SQLITE_DBCONFIG_FP_DIGITS (1023) This setting specifies the number of significant digits SQLite preserves when converting IEEE 754 floating-point numbers into text [2]. The default value was changed from 15 to 17 in version 3.52.0 (released March 2026) [6][2]. This change supports an enhanced rounding algorithm that improves the precision of floating-point representations [6]. The valid range for this setting is typically between 3 and 23 [2]. These options are defined in the sqlite3.h header file [1][7]. They are configured by passing the constant to sqlite3_db_config(db, op,...), where the exact number and type of subsequent arguments vary by option [1][8].
Citations:
🏁 Script executed:
Repository: RustPython/RustPython
Length of output: 3261
🌐 Web query:
site:sqlite.org/c3ref/db_config.html SQLITE_DBCONFIG_FP_DIGITS SQLITE_DBCONFIG_REVERSE_SCANORDER SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE💡 Result:
These constants are configuration verbs used with the sqlite3_db_config interface to modify specific behaviors of a SQLite database connection [1][2]. SQLITE_DBCONFIG_FP_DIGITS This option sets or retrieves the number of significant digits preserved when converting IEEE 754 floating-point numbers to text [2]. It accepts an integer argument between 3 and 23 [2]. The default value is 17 (as of SQLite version 3.52.0), having been increased from 15 in earlier versions [2][3][4]. This setting allows applications to balance precision and performance, as higher digit counts may trigger additional computational steps to ensure binary-to-text-to-binary round-trip consistency [3]. SQLITE_DBCONFIG_REVERSE_SCANORDER This option enables or disables the reversal of the scan order for database queries [5]. When enabled, it forces table scans to proceed in reverse order [5]. This is primarily used as a diagnostic tool to detect ambiguous queries; by running a query both with and without this option enabled, developers can identify if a query returns different results based on the scan order, which indicates an unordered result set [5]. It is the programmatic equivalent of the PRAGMA reverse_unordered_selects statement [5]. SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE This option controls the ability to write to attached databases [2][6]. When configured, it allows or restricts write operations on databases that have been attached to the main database connection using the ATTACH command [2]. It is part of a suite of security and fine-grained configuration options that allow applications to restrict the capabilities of a specific database connection [2].
Citations:
Complete the
SQLITE_DBCONFIG_*exports and validation.is_int_dbconfigomitsSQLITE_DBCONFIG_STMT_SCANSTATUS,SQLITE_DBCONFIG_REVERSE_SCANORDER,SQLITE_DBCONFIG_ENABLE_ATTACH_CREATE,SQLITE_DBCONFIG_ENABLE_ATTACH_WRITE, andSQLITE_DBCONFIG_ENABLE_COMMENTS. Export these options and accept them in the boolean path. ExportSQLITE_DBCONFIG_MAINDBNAME,SQLITE_DBCONFIG_LOOKASIDE, andSQLITE_DBCONFIG_FP_DIGITS, but implement their distinct argument contracts before accepting them.🤖 Prompt for AI Agents