Segmentation fault on odbc_fetch_array (PHP)
I have a PHP program that runs fine on CentOS 5.11 (Vertica 7.0.2/PHP 5.1.6-15/ODBC 2.2.11-10), but it's hitting a segmentation fault on CentOS 6.6 (Vertica 7.0.2/PHP 5.3.3-40/ODBC 2.2.14-14).
I've reproduced the problem in this simple PHP script:
$conn = odbc_connect("VerticaDSN", "user", "passwd");
$sql = "SELECT DATEDIFF('second', TO_TIMESTAMP('1970-01-01 00:00:00', 'YYYY-MM-DD HH24:MI:SS'), MIN(Timestamp)) AS value FROM metrics_fact";
$result = odbc_exec($conn, $sql);
$row = odbc_fetch_array($result);
I've stripped out the debug lines for clarity, but the gist is that I'm getting a segmentation fault on the odbc_fetch() call. It is worth noting that the sql line given works when I try it in vsql, but it does return 0 rows with my current db contents.
On the other hand, it words fine on CentOS 5.11 under the same conditions.
I've tried using xdebug to look at this and I also tried running it with USE_ZEND_ALLOC=0, but I didn't get any more helpful info or different behavior.
Any suggestions?
Thanks,
Jester
Comments
And, in another data point, this works fine when I tried a different query that does return some data.
Jester
Well, I have managed to isolate the problem further and find a workaround.
There are three different possibilities in play when a query is made:
As a workaround, though, I do a simple query to see if there is a value there first. If it fails (case 1), then I don't do the real SQL query. If it succeeds, the real SQL query will work.
Jester