Bug #70104 [Fbk->Asn]: odbc_fetch_array returns uninitialized values for Booleans

From: Date: Tue, 06 Oct 2020 22:55:11 +0000
Subject: Bug #70104 [Fbk->Asn]: odbc_fetch_array returns uninitialized values for Booleans
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-229432@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70104&edit=1

 ID:                 70104
 User updated by:    brucebailey320 at gmail dot com
 Reported by:        brucebailey320 at gmail dot com
 Summary:            odbc_fetch_array returns uninitialized values for
                     Booleans
-Status:             Feedback
+Status:             Assigned
 Type:               Bug
 Package:            ODBC related
 Operating System:   Linux
 PHP Version:        5.6.11
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

You can go ahead and close this defect


Previous Comments:
------------------------------------------------------------------------
[2020-10-06 14:41:43] cmb@php.net

I cannot reproduce that with PHP 7.3 and the PostgreSQL
Unicode(x64) driver on a PostgreSQL 10 database server (on
Windows).  The boolean fields are reported to be SQL_VARCHARs,
with a length of 1 (byte), and are returned as expected.

Is that still an issue for you with any of the actively supported
PHP versions[1]?

[1] <https://www.php.net/supported-versions.php>

------------------------------------------------------------------------
[2015-07-20 19:42:11] brucebailey320 at gmail dot com

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 this bug report at https://bugs.php.net/bug.php?id=70104&edit=1


Thread (4 messages)

« previous php.bugs (#229432) next »