com php-src: Boolean data type support, added in Firebird 3. Fixes #74462.: ext/pdo_firebird/firebird_statement.c ext/pdo_firebir
d/tests/bug_74462.phpt
| From: | Anatol Belski | Date: | Tue, 03 Jul 2018 17:04:11 +0000 |
| Subject: | com php-src: Boolean data type support, added in Firebird 3. Fixes #74462.: ext/pdo_firebird/firebird_statement.c ext/pdo_firebir d/tests/bug_74462.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-102389@lists.php.net to get a copy of this message | ||
Commit: 78f23a6dd47c845393b27250f2a2bcc2decd79be
Author: Dorin Marcoci <dorin.marcoci@marcodor.com> Sat, 13 May 2017 17:27:15 +0300
Committer: Anatol Belski <ab@php.net> Tue, 3 Jul 2018 19:04:11 +0200
Parents: e51b364a50a81c9df77368eedb0156d6670f6c16
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=78f23a6dd47c845393b27250f2a2bcc2decd79be
Log:
Boolean data type support, added in Firebird 3. Fixes #74462.
Bugs:
https://bugs.php.net/74462
Changed paths:
M ext/pdo_firebird/firebird_statement.c
A ext/pdo_firebird/tests/bug_74462.phpt
Diff:
diff --git a/ext/pdo_firebird/firebird_statement.c b/ext/pdo_firebird/firebird_statement.c
index 6d42f22..f28ffa0 100644
--- a/ext/pdo_firebird/firebird_statement.c
+++ b/ext/pdo_firebird/firebird_statement.c
@@ -1,4 +1,4 @@
-/*
+/*
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
@@ -229,6 +229,9 @@ static int firebird_stmt_describe(pdo_stmt_t *stmt, int colno) /* {{{ */
#endif
col->param_type = PDO_PARAM_INT;
break;
+ case SQL_BOOLEAN:
+ col->param_type = PDO_PARAM_BOOL;
+ break;
default:
col->param_type = PDO_PARAM_STR;
break;
@@ -416,6 +419,11 @@ static int firebird_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, /*
{{
*ptr = FETCH_BUF(S->fetch_buf[colno], char, CHAR_BUF_LEN, NULL);
*len = slprintf(*ptr, CHAR_BUF_LEN, "%F" , *(double*)var->sqldata);
break;
+ case SQL_BOOLEAN:
+ *len = sizeof(zend_bool);
+ *ptr = FETCH_BUF(S->fetch_buf[colno], zend_bool, 1, NULL);
+ *(zend_bool*)*ptr = *(FB_BOOLEAN*)var->sqldata;
+ break;
case SQL_TYPE_DATE:
isc_decode_sql_date((ISC_DATE*)var->sqldata, &t);
fmt = S->H->date_format ? S->H->date_format : PDO_FB_DEF_DATE_FMT;
diff --git a/ext/pdo_firebird/tests/bug_74462.phpt b/ext/pdo_firebird/tests/bug_74462.phpt
new file mode 100644
index 0000000..4a8d2c9
--- /dev/null
+++ b/ext/pdo_firebird/tests/bug_74462.phpt
@@ -0,0 +1,29 @@
+--TEST--
+PDO_Firebird: Bug #74462 Returns only NULLs for boolean fields
+--SKIPIF--
+<?php if (!extension_loaded('interbase') ||
!extension_loaded('pdo_firebird')) die('skip');
+?>
+--FILE--
+<?php
+require 'testdb.inc';
+$C = new PDO('firebird:dbname='.$test_base, $user, $password) or die;
+@$C->exec('drop table atable');
+$C->exec('create table atable (id integer not null, abool boolean)');
+$C->exec('insert into atable (id, abool) values (1, true)');
+$C->exec('insert into atable (id, abool) values (2, false)');
+$C->exec('insert into atable (id, abool) values (3, null)');
+$S = $C->query('select abool from atable order by id');
+$D = $S->fetchAll(PDO::FETCH_COLUMN);
+unset($S);
+unset($C);
+var_dump($D);
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ bool(true)
+ [1]=>
+ bool(false)
+ [2]=>
+ NULL
+}
\ No newline at end of file