@Clemens,
It is indeed documented that the behaviour is undefined when using a bind_text variant. I missed that part of documentation. On the other, as shown in my test queries, it is possible to construct strings with embedded nuls in sql itself, not using the C api (so technically, not allowing nuls could be a limitation of the C API). And as also remarked before by Simon an (embedded) nul is special in C-like languages. That made me wonder if sqlite would see an embedded nul as a "normal" character. Therefor my tests to see how sqlite functions operate on strings containing such nuls. From my experiments I could not include whether nul was "normal" or "special". The way I constructed TEXT values with embedded nuls is just a minor variation on how we add (unix) newlines in sql: 'line1' || x'0a' || 'line2". So, if nuls were a normal character this way to construct such a string with embedded nuls would not be very strange. I understand that changing the implementation would be a risk for backward compatibility and that most developers (including my company) do not want to used embedded nuls. My post was mainly intended to SHOW that string functions behave inconsistent when they contain embedded nuls, and WARN developers for this. Therefor, I asked to document if embedded nuls in string are allowed, e.g. on the www.sqlite.org/lang_corefunc.html. @Simon, Our original bug was caused by specifying an incorrect length for our C string using the C API. After we found our bug I did my tests, shown in my original post, using the SQlite command line tool. Rob Golsteijn wrote: > Due to a bug in our own code we inserted a string with embedded nul > character in the database. <http://www.sqlite.org/c3ref/bind_blob.html> says: | The result of expressions involving strings with embedded NULs is | undefined. > I investigated how the builtin functions handle strings with embedded > nul characters. Everything you found falls under the label "undefined". -------------------------------------------------- > Below my test queries (sqlite version 3.11.1), executed on TEXT data and BLOB > data. Nice set of tests. Did you execute them in the SQLite command-line tool or your own program ? Simon. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users