Re: [sqlite] builtin functions and strings with embedded nul characters

2016-07-07 Thread James K. Lowden
On Mon, 4 Jul 2016 13:07:18 +0200 R Smith wrote: > I think you are missing an important bit in all of this - the strings > in C is the problem, they think a Null character indicates > termination. It has nothing to do with how SQL stores data - SQLite > will store it with all

Re: [sqlite] builtin functions and strings with embedded nul characters

2016-07-04 Thread Simon Slavin
On 4 Jul 2016, at 12:07pm, R Smith wrote: > I prefer how Lazarus/Delphi does it (wrt the Pascal variant options as > opposed to C++) where a string is a record with first the encoding, the > length and then the actual bytes given. What Ryan said. Note that

Re: [sqlite] builtin functions and strings with embedded nul characters

2016-07-04 Thread R Smith
On 2016/07/04 10:22 AM, Rob Golsteijn wrote: @Clemens, It is indeed documented that the behaviour is undefined when using a bind_text variant. I missed that part of documentation. Hi Rob, The behaviour is undefined in ALL instances where you pass null characters through C strings

Re: [sqlite] builtin functions and strings with embedded nul characters

2016-07-04 Thread Clemens Ladisch
Rob Golsteijn wrote: > It is indeed documented that the behaviour is undefined when using a > bind_text variant. No. The documentation says: | The result of expressions involving strings with embedded NULs is undefined. Using a bind_text variant is just one of the ways to construct a string

Re: [sqlite] builtin functions and strings with embedded nul characters

2016-07-04 Thread Rob Golsteijn
@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

Re: [sqlite] builtin functions and strings with embedded nul characters

2016-07-01 Thread Roger Binns
On 01/07/16 05:04, Simon Slavin wrote: > On 1 Jul 2016, at 10:18am, Rob Golsteijn wrote: > >> For the tests below I assumed that the intention is that a string ends at >> the first embedded nul character. > > I'm not sure that this is the intent. > > The idea that

Re: [sqlite] builtin functions and strings with embedded nul characters

2016-07-01 Thread Clemens Ladisch
Rob Golsteijn wrote: > Due to a bug in our own code we inserted a string with embedded nul > character in the database. says: | The result of expressions involving strings with embedded NULs is | undefined. > I investigated how the builtin functions

Re: [sqlite] builtin functions and strings with embedded nul characters

2016-07-01 Thread Simon Slavin
On 1 Jul 2016, at 10:18am, Rob Golsteijn wrote: > For the tests below I assumed that the intention is that a string ends at the > first embedded nul character. I'm not sure that this is the intent. The idea that null is a terminating character is something that

[sqlite] builtin functions and strings with embedded nul characters

2016-07-01 Thread Rob Golsteijn
Hi List, Due to a bug in our own code we inserted a string with embedded nul character in the database. This caused strange behavior when we used the built-in function instr() on this data. As part of the analysis of this issue I investigated how the builtin functions handle strings with