SQLite supports embedded NUL in strings, both via the C API and SQL. For example this will create one:
INSERT INTO table VALUES('abc' || x'00' || 'def');
Many of the user defined string functions such as quote, upper/lower, length, replace, (r)trim stop their operations at the first NUL rather than at the end of the string.
Somewhat related you can also create UTF16 sequences with odd numbers of bytes using the insert sequence above because || operates on bytes not characters.
This topic was discussed on the mailing list:
http://thread.gmane.org/gmane.comp.db.sqlite.general/68307/focus=68400
<hr><i>drh added on 2011-10-13 18:01:28:</i><br>
Updated documentation to try to make it clearer that the result of
expressions involving strings with embedded NUL characters is undefined.
Also added more detail to the documentation on sqlite3_prepare(),
sqlite3_bind_text(), and sqlite3_result_text() to try to clear up confusion
about the use of NUL terminators.
|