[php-src] PR #11674: WIP: Implement PDO::PARAM_BINARY
| From: | NattyNarwhal | Date: | Tue, 11 Jul 2023 14:38:36 +0000 |
| Subject: | [php-src] PR #11674: WIP: Implement PDO::PARAM_BINARY | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-22996@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/11674
Author: NattyNarwhal
Adds a binary parameter type to PDO, making it semantically clear when you want a binary data
string. This is particularly useful for ODBC (which will hex-encode binary data bound as
SQL_C_CHAR) and DBLIB (which must escape binary data to avoid mangling the query over
the wire).
When merged, this closes GH-11462.
My testing so far is on macOS 13 on ARM, with an SQL Server 2016 instance elsewhere on Windows.
Only DBLIB, SQLite, and ODBC have been modified for this. I haven't added support to OCI8,
Firebird, MySQL, or Postgres; I'll likely do the latter two myself later if these make sense.
Notes:
* It does seem PDO_SQLite reuses PARAM_LOB for binding binary non-LOB, non-stream
strings. Maybe it'd be fine for other drivers to do this?
* The PDO_ODBC one actually doesn't use the bound type specified by the bind type argument, but
rather what's returned by the database. This adds support for binary data in a way that should
be independent on PARAM_BINARY and be cherry-picked out.
* Taking the user-provided type information into account would be a good idea, but require a
bigger refactor
* There are some test failures for PDO_ODBC, I'm not entire sure if related:
```
Bug #80783 (PDO ODBC truncates BLOB records at every 256th byte) [ext/pdo_odbc/tests/bug80783.phpt]
Bug #80783 (PDO ODBC truncates BLOB records at every 256th byte) [ext/pdo_odbc/tests/bug80783a.phpt]
via [ext/pdo_odbc/tests/common.phpt]
ODBC PDO Common: Bug #36798 (Error parsing named parameters with queries containing high-ascii
chars) [ext/pdo_odbc/tests/bug_36798.phpt]
```