11 aug 2016, Dominique Devienne:

On Thu, Aug 11, 2016 at 1:10 PM, Anthony Lansbergen <anth...@adesys.nl>
wrote:

Hello,

I needed a way to make parameterized texts for logging in my current
project.
For this purpose I missed a function in sqlite: group_replace, so I made
an extension.
The function is just like group_concat, an aggregate function, but it
replaces keys with values in a string instead of concattenating strings.

I put the code online, it's publicly available at:

https://github.com/adesys/sqlite3_group_replace_extension

It seems to work fine, but since this is my first extension, can someone
please take a look at it and check if it is bug free :-)


From https://www.sqlite.org/c3ref/value_blob.html:
Please pay particular attention to the fact that the pointer returned from
[...] sqlite3_value_text(),
[...] can be invalidated by a subsequent call to [...]
sqlite3_value_text(), [...]

I'd also check sqlite3_value_type() explicitly for SQLITE_TEXT to avoid
implicit conversions.

Who frees p->result in _final()? No one IMHO. So leak I think.

I didn't check the rest of the logic deeply. --DD

PS: I'm also a little wary of aligned issues from the allocation done by
sqlite3_aggregate_context()
but I guess that's the C++ dev talking. Back in my C days (a long time
ago...) I don't remember
worrying about it, so maybe that's a C++ thing only.


UpdateL the memory issue is resolved in yodays commit in 
https://github.com/adesys/sqlite3_group_replace_extension
at least in my test.
E, Pasma
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to