Edit report at https://bugs.php.net/bug.php?id=73191&edit=1
ID: 73191
Updated by: ab@php.net
Reported by: eion at robbmob dot com
Summary: "SQLColAttribute can't handle SQL_DESC_OCTET_LENGTH"
with Foxpro
Status: Not a bug
Type: Bug
Package: ODBC related
Operating System: Windows
PHP Version: 7.0.11
Assigned To: ab
Block user comment: N
Private report: N
New Comment:
ext/odbc doesn't set the ODBC version at runtime, it is compiled in. When compiled with ODBC
3.0 support, it is compatible with ODBC 2.x drivers as much as the specification of 3.0 is.
Why we started to support 3.0 by default is the fact, that there are indeed no more apps running on
ODBC 2.0. In the past few years, I haven't seen a bug about ODBC 2.0. Furthermore, ODBC 3.5
seems to be the usual case, whereby we don't rush into supporting it (in fact, there was no
incompatibility reports). But, and that's the actual issue - some drivers in the world claim to
support ODBC 3.x but don't implement it fully or are buggy in other ways.
Thus, the workarounds like the warning you see are only there because of such drivers. If you
compile ext/odbc without ODBC 3.0 support, several parts will be excluded, thus you'll have an
ext with pure ODBC 2.0 support. For the standard build, we have to handle the general case, however.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2016-09-28 19:56:08] eion at robbmob dot com
According to https://msdn.microsoft.com/en-us/library/ms716450(v=vs.85).aspx
the call to SQLColAttribute() with SQL_DESC_OCTET_LENGTH will result in an error:
"If FieldIdentifier is one of the following: ... SQL_DESC_OCTET_LENGTH ...
the Driver Manager returns SQL_ERROR with SQLSTATE HY091 (Invalid descriptor field identifier). No
further rules of this section apply."
I read this as expected behaviour that will happen with all ODBC 2.0 drivers when accessed using
ODBC 3.0 functions and thus shouldn't be a warning in PHP if it's expected to work with
ODBC 2.0 drivers.
------------------------------------------------------------------------
[2016-09-28 19:04:51] ab@php.net
Thanks for checking, Christoph. Yeah, it looks like not a PHP issue.
Our default builds are ODBC 3.0 by default, while some parts still maintain BC workarounds. The
error S1091 witnesses that the driver is ODBC 2.x. Besides that, the technology seems to be not
supported anymore - the support for the last FoxPro 9.0 product was discontinued over a year ago,
and there are no new versions.
@eion, an option for you were to compile the required ext/odbc variant while setting --with-odbcver
to like 0x0250 or other that is suitable for your app. The warning itself is useful as the actual
reason adding it was about drivers that have inconsistent ODBC 3.x implementation.
Thanks.
------------------------------------------------------------------------
[2016-09-28 16:00:03] cmb@php.net
That appears to be a bug in the Microsoft ODBC Visual FoxPro
driver (BTW, which version do you use?) Apparently, the driver
claims ODBC 3.0 compatibility, but doesn't know about
SQL_DESC_OCTET_LENGTH.
Not sure if we should do something here, besides reporting the
issue to Microsoft.
Anatol, what do you think?
------------------------------------------------------------------------
[2016-09-28 06:43:06] eion at robbmob dot com
Description:
------------
Every query with odbc_exec() that returns a string is outputting a PHP Warning of
"SQLColAttribute can't handle SQL_DESC_OCTET_LENGTH" when using the Foxpro driver.
The full error is
[28-Sep-2016 19:15:10 Pacific/Auckland] PHP Warning: odbc_exec(): SQLColAttribute can't handle
SQL_DESC_OCTET_LENGTH: [S1091] [Microsoft][ODBC Visual FoxPro Driver]Descriptor type out of range in
test.php on line 2
Looking at https://github.com/php/php-src/blob/master/ext/odbc/php_odbc.c#L1018
php_error_docref(NULL, E_WARNING, "SQLColAttribute can't handle SQL_DESC_OCTET_LENGTH:
[%s] %s", state, errtxt);
It appears that this warning should actually be a notice, or have some way of blocking this message.
This warning was added in http://git.php.net/?p=php-src.git;a=commit;h=268eb1999b1598a2a1a875c5f0172d5b615811ac
Test script:
---------------
<?php
$a = odbc_connect('Foxpro', '', '');
odbc_exec($a, "SELECT foo FROM bar");
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=73191&edit=1