PDO_DBLIB: Quote LOB arguments as binary literals #10343
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.I've also added a unit test for this.
Questions not raised in the commit:
PDO::PARAM_LOB
the best option for this? I picked this because the end-user I was working with (as did I) expected binary behaviour out of it, but that might be too much of an assumption, especially since there's not really LOBs involved, just binaries. Would aPARAM_BINARY
make sense? If so, as a modifier or its own type? Added to base PDO or just DBLIB?Resolves GH-10312.