Skip to content

Fix RawStmt stmt_len with Unicode statements#194

Open
alexmac wants to merge 1 commit into
lelit:v7from
alexmac:alex/fix-rawstmt-stmt-len-unicode
Open

Fix RawStmt stmt_len with Unicode statements#194
alexmac wants to merge 1 commit into
lelit:v7from
alexmac:alex/fix-rawstmt-stmt-len-unicode

Conversation

@alexmac
Copy link
Copy Markdown

@alexmac alexmac commented May 25, 2026

RawStmt.stmt_len was being run through the byte-offset-to-string-index mapper as if it were an absolute offset, but PostgreSQL reports it as a length relative to stmt_location. That works by accident for plain ASCII, but in multi-statement SQL with Unicode earlier in the string, the length gets shortened because it’s converted from byte offset stmt_len instead of from the real byte end position stmt_location + stmt_len.

The fix converts both byte positions, start and end, into Python string indexes, then subtracts them. So stmt_len stays a character length that can be used with sql[stmt_location:stmt_location + stmt_len], even when earlier statements contain multibyte characters like €.

@codecov-commenter
Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (v7@deb6263). Learn more about missing BASE report.
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@          Coverage Diff          @@
##             v7     #194   +/-   ##
=====================================
  Coverage      ?   99.55%           
=====================================
  Files         ?       22           
  Lines         ?     7259           
  Branches      ?        0           
=====================================
  Hits          ?     7227           
  Misses        ?       32           
  Partials      ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@alexmac alexmac force-pushed the alex/fix-rawstmt-stmt-len-unicode branch from 78c75fe to 8ebbf85 Compare May 28, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants