[php-src] PR #13972: SQLite pdo::quote use ('foo'||x'0000'||'bar') for null bytes
| From: | divinity76 | Date: | Mon, 15 Apr 2024 15:38:28 +0000 |
| Subject: | [php-src] PR #13972: SQLite pdo::quote use ('foo'||x'0000'||'bar') for null bytes | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-25764@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/13972
Author: divinity76
resolves issue GH-13952,
this is basically a smart_str() version of PR #13956
per https://github.com/php/php-src/pull/13962#issuecomment-2056696180
this is 1 of the 4 proposed alternatives to the problem, and the pros of this solution is that it
produces smaller queries than the alternatives, and retains the sqlite datatype 'string'
(instead of changing it to blob), and should make PDO::quote faster as we now avoid the overhead of
copying data to/from sqlite3_snprintf.
The cons of this solution, that I can think of right now,
is that the implementation is non-trivial,
involves a bunch of php-allocator-reallocs() (PR #13956 does not invovle reallocs, as it
pre-computes the length.
also worth noting that php allocator's reallocs() are faster than libc realloc, often avoiding
talking to the OS),
and SQLite's LENGTH(('foo'||x'00'||'bar')) returns 3 instead of
7,
and binary strings gets the datatype 'string' instead of 'blob' (that can be
considered both a pro and a con)