sqlx icon indicating copy to clipboard operation
sqlx copied to clipboard

feat(sqlite): make thread_stack_size optional with safe defaults

Open ZenasSong opened this issue 2 months ago • 1 comments

Changes thread_stack_size from usize to Option<usize> to address concerns about safety and platform compatibility.

Key improvements:

  • Default to None, using Rust std's default stack size (typically 2MB)
  • Only apply custom stack size when explicitly configured
  • Safer for user callbacks with unpredictable stack requirements
  • Platform-agnostic (handles 32-bit vs 64-bit differences automatically)
  • Marked as an advanced option in documentation with appropriate warnings

This addresses the feedback from PR #3885 about hardcoded stack sizes being unsafe due to:

  1. Unpredictable stack needs of user-supplied callbacks
  2. Platform-specific requirements (32-bit vs 64-bit)
  3. Need for conservative defaults

Related: #3885

Does your PR solve an issue?

Delete this text and add "fixes #(issue number)".

Do not just list issue numbers here as they will not be automatically closed on merging this pull request unless prefixed with "fixes" or "closes".

Is this a breaking change?

Delete this text and answer yes/no and explain.

If yes, this pull request will need to wait for the next major release (0.{x + 1}.0)

Behavior changes can be breaking if significant enough. Consider Hyrum's Law:

With a sufficient number of users of an API,
it does not matter what you promise in the contract:
all observable behaviors of your system
will be depended on by somebody.

ZenasSong avatar Nov 01 '25 12:11 ZenasSong

@ZenasSong please run cargo fmt.

abonander avatar Nov 23 '25 05:11 abonander