Bug #70104 [NEW]: odbc_fetch_array returns uninitialized values for Booleans

From: Date: Mon, 20 Jul 2015 19:42:14 +0000
Subject: Bug #70104 [NEW]: odbc_fetch_array returns uninitialized values for Booleans
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194574@lists.php.net to get a copy of this message
From:             brucebailey320 at gmail dot com
Operating system: Linux
PHP version:      5.6.11
Package:          ODBC related
Bug Type:         Bug
Bug description:odbc_fetch_array returns uninitialized values for Booleans

Description:
------------
The PHP function odbc_fetch_array returns uninitialized values for
PostgreSQL boolean values.  On older systems, this function returned '1'
for true and '0' for false values.  On our 64 bit system, the boolean
values appear to be uninitialized data.

Additional information

Increasing buffer size in php_odbc.c (odbc.so) in function
odbc_bindcols, just prior to call to SQLBindCol makes problem stop
exhibiting.
SQLColAttributes(...,SQL_COLUMN_TYPE,...) returns type of SQL_VARCHAR on
system with problem, SQL_CHAR on system where code works as expected.
SQLColAttributes is deprecated (shouldn't matter, though)

Recreation steps:

// Create table/data in PostgreSQL

DROP TABLE IF EXISTS public.persons;
create table public.persons (id int, name varchar(255), switch_sw
boolean);
insert into public.persons values (0, 'smith', true);
insert into public.persons values (1, 'jones', false);
insert into public.persons values (2, 'bailey', true);
insert into public.persons values (3, 'johnson', false);


Software levels

kernel - Linux C921189 3.10.0-123.20.1.el7.x86_64 . . . GNU/Linux
ODBC - libodbc.so.1 (cannot exactly determine version)
PostgreSQL - 9.3.0
PHP - 5.6.7

This system is little endian


Test script:
---------------
<?php

   if(!($conn = odbc_connect("..." , "..." , "...")))
      die("odbc_connect failed\n");

   if(!($rows = odbc_exec($conn, "select * from persons;")))
      die("odbc_exec failed\n");

   for(;;)
   {
      if (!($row = odbc_fetch_array ($rows)))
         break;

      print_r($row);
   }

   odbc_close($conn);
?>


Expected result:
----------------
Array
(
    [id] => 0
    [name] => smith
    [switch_sw] => 1
)
. . .


Actual result:
--------------
Array
(
    [id] => 0
    [name] => smith
    [switch_sw] => . // some unreadable binary content
)
. . .


-- 
Edit bug report at https://bugs.php.net/bug.php?id=70104&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=70104&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=70104&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=70104&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=70104&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=70104&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=70104&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=70104&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=70104&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=70104&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=70104&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=70104&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=70104&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=70104&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70104&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=70104&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=70104&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=70104&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=70104&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=70104&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=70104&r=mysqlcfg



Thread (4 messages)

« previous php.bugs (#194574) next »