You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
sqlite3 regression: bound values are not expanded in traced statements #89301
For SQLite 3.14.0 and newer, we're using the v2 trace API. This means that the trace callback receives a pointer to the sqlite3_stmt object. We can use the sqlite3_stmt pointer to retrieve expanded SQL string.
The following statement...:
cur.executemany("insert into t values(?)", ((v,) for v in range(3)))
...will produce the following traces:
insert into t values(0)
insert into t values(1)
insert into t values(2)
...instead of:
insert into t values(?)
insert into t values(?)
insert into t values(?)
changed the title [-][sqlite3] expand bound values in traced statements if possible[/-][+][sqlite3] expand bound values in traced statements when possible[/+]on Sep 8, 2021
changed the title [-][sqlite3] expand bound values in traced statements if possible[/-][+][sqlite3] expand bound values in traced statements when possible[/+]on Sep 8, 2021
Ah, one of my very first contributions, gh-84498, comes back to haunt me:
In gh-84498, we migrated from the old SQLite trace API (sqlite3_trace) to SQLite trace v2 API (sqlite3_trace_v2). #19581, which introduced this change, introduced a bug: the old trace API _implicitly_ expanded bound parameters; the new trace API does not. However, there was no tests for this behaviour, so the regression was unnoticed1.
So, this bpo is actually a bug fix; not a feature. It should be backported to 3.10, which contains the regression.
I'm preparing a fix for #28240, and I'll prepare a 3.10 backport including both #19581 and its upcoming fix.
Footnotes
There has been no bug reports regarding this change in behaviour, so it seems to have gone under most people's radar. ↩
changed the title [-][sqlite3] expand bound values in traced statements when possible[/-][+]sqlite3 regression: bound values are not expanded in traced statements[/+]on Apr 29, 2022
Activity
erlend-aasland commentedon Sep 8, 2021
For SQLite 3.14.0 and newer, we're using the v2 trace API. This means that the trace callback receives a pointer to the sqlite3_stmt object. We can use the sqlite3_stmt pointer to retrieve expanded SQL string.
The following statement...:
cur.executemany("insert into t values(?)", ((v,) for v in range(3)))
...will produce the following traces:
insert into t values(0)
insert into t values(1)
insert into t values(2)
...instead of:
insert into t values(?)
insert into t values(?)
insert into t values(?)
[-][sqlite3] expand bound values in traced statements if possible[/-][+][sqlite3] expand bound values in traced statements when possible[/+][-][sqlite3] expand bound values in traced statements if possible[/-][+][sqlite3] expand bound values in traced statements when possible[/+]JelleZijlstra commentedon Mar 9, 2022
New changeset d177751 by Erlend Egeberg Aasland in branch 'main':
bpo-45138: Expand traced SQL statements in
sqlite3trace callback (GH-28240)d177751
JelleZijlstra commentedon Mar 9, 2022
Thanks for the contribution!
2 remaining items
erlend-aasland commentedon Mar 9, 2022
Ah, one of my very first contributions, gh-84498, comes back to haunt me:
In gh-84498, we migrated from the old SQLite trace API (sqlite3_trace) to SQLite trace v2 API (sqlite3_trace_v2). #19581, which introduced this change, introduced a bug: the old trace API _implicitly_ expanded bound parameters; the new trace API does not. However, there was no tests for this behaviour, so the regression was unnoticed1.
So, this bpo is actually a bug fix; not a feature. It should be backported to 3.10, which contains the regression.
I'm preparing a fix for #28240, and I'll prepare a 3.10 backport including both #19581 and its upcoming fix.
Footnotes
There has been no bug reports regarding this change in behaviour, so it seems to have gone under most people's radar. ↩
miss-islington commentedon Mar 9, 2022
New changeset e801e88 by Erlend Egeberg Aasland in branch 'main':
bpo-45138: Revert #72427: Expand traced SQL statements (GH-31788)
e801e88
[-][sqlite3] expand bound values in traced statements when possible[/-][+]sqlite3 regression: bound values are not expanded in traced statements[/+]pythongh-89301: Fix regression with bound values in traced statements
gh-89301: Fix regression with bound values in traced SQLite statements (
[3.10] gh-89301: Fix regression with bound values in traced SQLite st…