Skip to content

Conversation

billschaller
Copy link

This bug is also referenced in
#44643
pdo_odbc has had well-documented issues with parameterised queries accessing SQL Server for a long time. The issue is that when SQLDescribeParam does not return information about an input query parameter, pdo_odbc treats the parameter as a LONGVARCHAR or LONGVARBINARY. This patch modifies pdo_odbc to treat input parameters of less than 4000 characters in length as VARCHAR when the server does not return useful parameter information in response to the SQLDescribeParam call. This fixes behavior on SQL server, and shouldn't adversely affect behavior on other DBMS's, because the others for the most part return valid parameter info.

Bill Schaller added 2 commits March 10, 2014 07:44
This bug is also referenced in
[#44643](https://bugs.php.net/bug.php?id=44643)
pdo_odbc has had well-documented issues with parameterised queries accessing SQL Server for a long time. The issue is that when SQLDescribeParam does not return information about an input query parameter, pdo_odbc treats the parameter as a LONGVARCHAR or LONGVARBINARY. This patch modifies pdo_odbc to treat input parameters of less than 4000 characters in length as VARCHAR when the server does not return useful parameter information in response to the SQLDescribeParam call. This fixes behavior on SQL server, and shouldn't adversely affect behavior on other DBMS's, because the others for the most part return valid parameter info.
Corrected issue with string lengths in fixed prepared statement code.
@billschaller
Copy link
Author

Travic-CI fail is unrelated.

@smalyshev
Copy link
Contributor

@zeroedin-bill could you add a test for this problem too?

@billschaller
Copy link
Author

@smalyshev @remus32 I'm not entirely sure how to go about adding an effective test for this. I'm not using this patch in production anywhere, and didn't go at testing it very extensively other than to verify some previously broken statements work with SQL Server 20XX.

I'm not sure how many people are using this extension, or how this change would affect usage on other platforms where SQLDescribeParam doesn't behave nicely. Many older versions of DBMSs (Teradata, DB/2, PostgreSQL, MSSQL, others) and some current versions of DBMSs such as SQL Server.

I think the changes provided here are a step towards the right solution, but it would take a programmer more experienced with the ODBC API than I to validate and craft tests for it.

@krakjoe
Copy link
Member

krakjoe commented Jan 4, 2017

The reason nobody has moved on this is because it doesn't have any tests, or consensus that this is a good solution.

What I suggest is that you start a discussion on internals, this should draw out commentators and help to build a consensus.

Alternatively, if you consider this work abandoned, please close this PR.

@billschaller
Copy link
Author

@krakjoe - happy to close it. There is a SQL server driver for Linux coming out soon so the issue is moot anyway. And I don't even have to use SQL server anymore, anyway (thank goodness).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants