Edit report at https://bugs.php.net/bug.php?id=69354&edit=1
ID: 69354
Updated by: ab@php.net
Reported by: php at mdjnet dot dk
Summary: Incorrect use of SQLColAttributes with ODBC 3.0
-Status: Assigned
+Status: Feedback
Type: Bug
Package: ODBC related
Operating System: All
PHP Version: 5.6.7
Assigned To: ab
Block user comment: N
Private report: N
New Comment:
Please check the latest 5.5+ snapshots, the fixes was cherry picked.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2015-04-03 06:21:13] php at mdjnet dot dk
I just tried out the rf265928 snapshot, and it works fine. The odbc trace shows that now
SQLColAttribute is called instead of SQLColAttributes.
------------------------------------------------------------------------
[2015-04-02 20:55:13] php at mdjnet dot dk
Try to shoot this into your registry (assuming you put the driver in c:\windows\system32, and that
you have a 64 bit Windows, otherwise remove the Wow6432Node part):
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\TestOdbc]
"UsageCount"=dword:00000001
"Setup"="C:\\Windows\\System32\\TestOdbc.dll"
"Driver"="C:\\Windows\\System32\\TestOdbc.dll"
"APILevel"=dword:00000001
"ConnectFunction"="YYN"
"DriverODBCVer"="03.00"
"FileExtns"=""
"FileUsage"=dword:00000000
"SQLLevel"=dword:00000000
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\ODBC\ODBCINST.INI\ODBC Drivers]
"TestOdbc"="Installed"
- and you should have a driver ready to configure a DSN for. No database, no nothing else required,
the odbc driver has it all within it.
------------------------------------------------------------------------
[2015-04-02 20:40:38] ab@php.net
Yeah, I require really
- a mdb file or sql file to import
- which registry keys are to edit
- the exact php code
we call it "a self enclosed reproduce case" :) Otherwise it's really shooting in the
sky.
I was adding a test http://git.php.net/?p=php-src.git;a=commitdiff;h=f26592846f8190fdab6cb148e484a4aeb032c096
based on your PHP example, however it doesn't repro on the usual drivers. Also, maybe it's
already fixed in master, so worth to check that snap. If it is, one could think about backporting it
into 5.5/6
Thanks.
------------------------------------------------------------------------
[2015-04-02 19:44:07] php at mdjnet dot dk
I have now created a dummy odbc driver, capable of practically nothing, but enough to demonstrate
the error. It can be downloaded from http://www.mdjnet.dk/testodbc.dll. I will leave it
there, while this bug is open.
You will have to install it "manually", by editing the relevant registry keys. Create a
DSN called TEST using the driver, and then you can simply run the script from my previous post. I am
myself using Windows 7, apache 2.4.12 and of course php 5.6.7.
You will see the message "Allowed memory size of 134217728 bytes exhausted (tried to allocate
1996545750 bytes)" in the error log (because only the one column is queried with the script, so
displaysize in php_odbc.c is uninitialized).
Then edit the script a little, use "select ID,TNAME from table1" instead. Now you will see
the string "This is a v", it is cut to 11 characters (because displaysize is now set by
the previous column to apparently 11), and if you query the driver by any other program, you will
receive the string "This is a very, very, very, very, very ... long string indeed!". I
made a very long string to make sure the truncation was visible, I could apparently have stopped at
12 characters. If you start the ODBC trace while running the script, you will see that
SQLColAttributes returns -1 for 1013.
Let me know, if anything else is required to reproduce it.
------------------------------------------------------------------------
[2015-04-02 19:34:08] ab@php.net
Please check this snapshot http://windows.php.net/downloads/snaps/master/rf265928/
. I've integrated appropriate usage SQLColAttribute usage for ODBC 3.x and a couple of other
compliance fixes.
With your snippet - I couldn't reproduce the behavior you describe with SQL Server or mdb
driver. For this reason I've put the patches into master only, maybe yet. Maybe you should give
me an exact CREATE TABLE and data.
The idea of using the ODBC 3.x APIs is actually good, I've also seen that there are many other
APIs from 2.x used in ext/odbc. However the docs state some high compatibilty grade (with exception
of some edge cases), so maybe it's also plausible to fix issues as they show up.
Thanks.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=69354
--
Edit this bug report at https://bugs.php.net/bug.php?id=69354&edit=1