sqlean
sqlean copied to clipboard
regexp_replace() returning incorrect pointer?
Hello, I am trying to use the re extension for RegEx (on Windows, compiling for 32-bit). Functions all work, except for the regexp_replace function. It returns correctly when it doesn't find anything to replace, but there is a strange effect when something is replaced:
My Test case is select regexp_replace('The current year is AD 2025', '[0-9]+', '2050')
The result varies on each call. For example, here are ten calls: mainThe current year is AD sqlThe current year is AD 2 The current year is AD 2050 The current year is AD 2050 sqlite_masterThe current ye tbl_name='AAA' AND type!='t mainThe current year is AD sqlite_masterThe current ye The current year is AD 2050 TEXTThe current year is AD
It behaves as if the call I make to sqlite_column_text() returns a pointer that is a variable number of bytes smaller than the actual start of the result string. I thus read some other bit of memory before the actual value starts, and loss the end of the value (I copy a number of bytes returned by sqlite3_column_bytes()).
Any ideas of what might be wrong?
-- James Powell
Thanks for noticing! Unfortunately, I don't have a Windows machine to check this issue. Will look into it when I have a chance.
The source code for the regexp_replace()
function looks pretty awful, but it passes the tests on Linux / macOS.
Found the bug and fixed it in 0.15.3.
Thanks!