-
Notifications
You must be signed in to change notification settings - Fork 7.9k
WIP: Implement PDO::PARAM_BINARY #11674
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A quick overview of this seems to make sense, but then I know nothing about databases.
Also CI is failing on some of the new tests
After looking at it, Oddly, the |
Turns out I've overthought this a bit and I think the PDO type override is probably adequate in get_col. I think |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two minor comments of 2 details I noticed that might help you out here.
Original text: >If the user is specifying a PDO::PARAM_LOB, there's a good chance >that it's a binary file (i.e. an image), that is too fragile to >survive in a string, as escaping it is insufficient. Because >PDO_DBLIB relies on PDO to fill in a parameterized query and >submits the filled string to the server, it ends up mangling the >query. > >This adds logic in the PDO_DBLIB quoter to handle binary parameters >by using the SQL Server binary literal syntax (a hex string that >begins with `0x`). This resolves the issue because PDO consults the >quoter for filling in the query string.
...including a test. I'm not sure if the semantics are right here though. This does binary data if the DB returns it, instead of listening to the PDO param type. This does mean that binary data works like expected, but the binary bound to SQL_C_CHAR converting behaviour in some drivers[1] may be desired and specified instead... [1]: At least Db2i and SQL Server's drivers, when I tested them.
the PDO_DBLIB change predates the PDO_BINARY proposa, so...
7af4029
to
8a7b85c
Compare
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:
PARAM_LOB
for binding binary non-LOB, non-stream strings. Maybe it'd be fine for other drivers to do this?PARAM_BINARY
and be cherry-picked out.