segfault与unixODBC(DB2)+ PHP + CentOS [英] segfault with unixODBC (DB2) + PHP + CentOS
问题描述
经过2天的战斗,我尝试在这里请求帮助。我使用unixODBC(2.2.11)在CentOS 5.4服务器上使用DB2(iSeries)和PHP(5.3)。我想是从PHP升级到5.1到5.3,我得到PHP的segfault某些查询。经过一番调查,我发现这个问题出现在一些长char字段的查询,例如这个表:
TABLE b $ b CONTRACTID NUMERIC,
SOMETEXT CHAR(583)
)
简单的代码段激发了segfault:
try {
$ conn = new PDO(odbc:。 dsn,$ username,$ password,array(
PDO :: ATTR_ERRMODE => PDO :: ERRMODE_EXCEPTION)
);
}
catch(Exception $ e){
echo $ e-> getMessage();
}
$ sql ='SELECT * FROM LIB.TABLE';
$ stmt = $ conn-> prepare($ sql);
$ vals = $ stmt-> execute();
$ rows = $ stmt-> fetchAll(PDO :: FETCH_ASSOC);
是否有任何列长度限制或与unixODBC和/或PHP> = 5.1的错误?
这个web应用程序工作相当不错,然后我遇到了这个问题..
Btw,我测试了一个更新的64位CentOS 6.2机器与unixODBC 2.2.14和PHP 5.3,并且问题是一样的。
任何帮助非常感谢,
感谢
fabien
UPDATE:
使用PHP odbc函数,它的工作原理:
$ conn = odbc_connect($ dsn,$ username,$ password);
$ res = odbc_exec($ conn,$ sql);
$ rows = odbc_fetch_array($ res);因此,这个问题更多地与PDO相关,任何想法?
这里有同样的问题。发现64位php-odbc模块在返回具有NULL值的字段时导致seg故障。解决方法是合并其中可能存在NULL值的每个字段。这不是一个好的解决方案。我正在查看php-odbc.c代码,但我不能保证修复。
解决方法:
SELECT COALESCE(CHAR(fieldname) ,'')FROM ...
我想要用32位版本替换这个服务器。我有其他工作正常。
After 2 days battling, I try asking help here. I'm using unixODBC (2.2.11) to work with DB2 (iSeries) and PHP (5.3) on a CentOS 5.4 server. I guess it's since the upgrade of PHP from 5.1 to 5.3, I get PHP to segfault on certain queries. After some investigation, I discovered the problem appears on some queries with long char fields, for example with this table :
TABLE (
CONTRACTID NUMERIC,
SOMETEXT CHAR(583)
)
This simple piece of code provokes the segfault :
try {
$conn = new PDO("odbc:".$dsn, $username, $password, array(
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
);
}
catch (Exception $e) {
echo $e->getMessage();
}
$sql = 'SELECT * FROM LIB.TABLE ';
$stmt = $conn->prepare($sql);
$vals = $stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
Is there any column length limit or a bug with unixODBC and/or PHP >= 5.1 ? This web application worked quite great, then I got into this problem..
Btw, I tested with a more up-to-date 64bits CentOS 6.2 machine with unixODBC 2.2.14 and PHP 5.3, and the problem is the same.
Any help greatly appreciated,
Thanks
fabien
UPDATE : Using the PHP odbc functions, it works :
$conn = odbc_connect($dsn, $username, $password);
$res = odbc_exec($conn, $sql);
$rows = odbc_fetch_array($res);
So the problem is more tied to PDO, any idea?
Ran into the same problem here. Found that the 64-bit php-odbc module is causing the seg fault when returning a field with a NULL value. A workaround is to coalesce each field in which a NULL value could exist. It's not a good solution. I'm looking at the php-odbc.c code, but I can't guarantee a fix.
Workaround: SELECT COALESCE(CHAR(fieldname),'') FROM ...
I think I'm going to replace this server with a 32-bit version. I have others that work just fine.
这篇关于segfault与unixODBC(DB2)+ PHP + CentOS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!