Skip to content

Commit eb2f5df

Browse files
author
Martin Köditz
committed
Use Firebird constants for boolean data type. New Version 3.0.0 to keep track of related Firebird version
1 parent 9c95ac8 commit eb2f5df

7 files changed

+111
-47
lines changed

ibase_blobs.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
+----------------------------------------------------------------------+
3-
| PHP Version 7 |
3+
| PHP Version 7, 8 |
44
+----------------------------------------------------------------------+
55
| Copyright (c) The PHP Group |
66
+----------------------------------------------------------------------+
@@ -12,7 +12,14 @@
1212
| obtain it through the world-wide-web, please send a note to |
1313
| [email protected] so we can mail you a copy immediately. |
1414
+----------------------------------------------------------------------+
15-
| Authors: Ard Biesheuvel <[email protected]> |
15+
| Authors: Jouni Ahto <[email protected]> |
16+
| Andrew Avdeev <[email protected]> |
17+
| Ard Biesheuvel <[email protected]> |
18+
| Martin Koeditz <[email protected]> |
19+
| others |
20+
+----------------------------------------------------------------------+
21+
| You'll find history on Github |
22+
| https://github.com/FirebirdSQL/php-firebird/commits/master |
1623
+----------------------------------------------------------------------+
1724
*/
1825

ibase_query.c

+61-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
+----------------------------------------------------------------------+
3-
| PHP Version 7 |
3+
| PHP Version 7, 8 |
44
+----------------------------------------------------------------------+
55
| Copyright (c) The PHP Group |
66
+----------------------------------------------------------------------+
@@ -12,7 +12,14 @@
1212
| obtain it through the world-wide-web, please send a note to |
1313
| [email protected] so we can mail you a copy immediately. |
1414
+----------------------------------------------------------------------+
15-
| Authors: Ard Biesheuvel <[email protected]> |
15+
| Authors: Jouni Ahto <[email protected]> |
16+
| Andrew Avdeev <[email protected]> |
17+
| Ard Biesheuvel <[email protected]> |
18+
| Martin Koeditz <[email protected]> |
19+
| others |
20+
+----------------------------------------------------------------------+
21+
| You'll find history on Github |
22+
| https://github.com/FirebirdSQL/php-firebird/commits/master |
1623
+----------------------------------------------------------------------+
1724
*/
1825

@@ -87,7 +94,10 @@ typedef struct {
8794
*/
8895
typedef struct {
8996
union {
90-
zend_bool bval;
97+
// Boolean data type exists since FB 3.0
98+
#ifdef SQL_BOOLEAN
99+
FB_BOOLEAN bval;
100+
#endif
91101
short sval;
92102
float fval;
93103
ISC_LONG lval;
@@ -250,10 +260,13 @@ static int _php_ibase_alloc_array(ibase_array **ib_arrayp, XSQLDA *sqlda, /* {{{
250260
a->el_type = SQL_TEXT;
251261
a->el_size = ar_desc->array_desc_length;
252262
break;
253-
case blr_bool:
254-
a->el_type = SQL_BOOLEAN;
255-
a->el_size = sizeof(zend_bool);
256-
break;
263+
// Boolean data type exists since FB 3.0
264+
#ifdef SQL_BOOLEAN
265+
case blr_bool:
266+
a->el_type = SQL_BOOLEAN;
267+
a->el_size = sizeof(FB_BOOLEAN);
268+
break;
269+
#endif
257270
case blr_short:
258271
a->el_type = SQL_SHORT;
259272
a->el_size = sizeof(short);
@@ -595,11 +608,14 @@ static int _php_ibase_bind_array(zval *val, char *buf, zend_ulong buf_size, /* {
595608
convert_to_double(val);
596609
*(float*) buf = (float) Z_DVAL_P(val);
597610
break;
598-
case SQL_BOOLEAN:
599-
convert_to_boolean(val);
600-
// On Windows error unresolved symbol Z_BVAL_P is thrown, so we use Z_LVAL_P
601-
*(zend_bool*) buf = Z_LVAL_P(val);
602-
break;
611+
// Boolean data type exists since FB 3.0
612+
#ifdef SQL_BOOLEAN
613+
case SQL_BOOLEAN:
614+
convert_to_boolean(val);
615+
// On Windows error unresolved symbol Z_BVAL_P is thrown, so we use Z_LVAL_P
616+
*(FB_BOOLEAN*) buf = Z_LVAL_P(val);
617+
break;
618+
#endif
603619
case SQL_DOUBLE:
604620
convert_to_double(val);
605621
*(double*) buf = Z_DVAL_P(val);
@@ -786,38 +802,39 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval *b_vars, BIND_BUF *buf, /* {{{ */
786802
buf[i].val.qval = ib_blob.bl_qd;
787803
}
788804
continue;
789-
805+
// Boolean data type exists since FB 3.0
806+
#ifdef SQL_BOOLEAN
790807
case SQL_BOOLEAN:
791808

792809
switch (Z_TYPE_P(b_var)) {
793810
case IS_LONG:
794811
case IS_DOUBLE:
795812
case IS_TRUE:
796813
case IS_FALSE:
797-
*(bool *)var->sqldata = zend_is_true(b_var) ? 1 : 0;
814+
*(FB_BOOLEAN *)var->sqldata = zend_is_true(b_var) ? FB_TRUE : FB_FALSE;
798815
break;
799816
case IS_STRING:
800817
{
801818
zend_long lval;
802819
double dval;
803820

804821
if ((Z_STRLEN_P(b_var) == 0)) {
805-
*(bool *)var->sqldata = 0;
822+
*(FB_BOOLEAN *)var->sqldata = FB_FALSE;
806823
break;
807824
}
808825

809826
switch (is_numeric_string(Z_STRVAL_P(b_var), Z_STRLEN_P(b_var), &lval, &dval, 0)) {
810827
case IS_LONG:
811-
*(bool *)var->sqldata = (lval != 0) ? 1 : 0;
828+
*(FB_BOOLEAN *)var->sqldata = (lval != 0) ? FB_TRUE : FB_FALSE;
812829
break;
813830
case IS_DOUBLE:
814-
*(bool *)var->sqldata = (dval != 0) ? 1 : 0;
831+
*(FB_BOOLEAN *)var->sqldata = (dval != 0) ? FB_TRUE : FB_FALSE;
815832
break;
816833
default:
817834
if (!zend_binary_strncasecmp(Z_STRVAL_P(b_var), Z_STRLEN_P(b_var), "true", 4, 4)) {
818-
*(bool *)var->sqldata = 1;
835+
*(FB_BOOLEAN *)var->sqldata = FB_TRUE;
819836
} else if (!zend_binary_strncasecmp(Z_STRVAL_P(b_var), Z_STRLEN_P(b_var), "false", 5, 5)) {
820-
*(bool *)var->sqldata = 1;
837+
*(FB_BOOLEAN *)var->sqldata = FB_FALSE;
821838
} else {
822839
_php_ibase_module_error("Parameter %d: cannot convert string to boolean", i+1);
823840
rv = FAILURE;
@@ -836,7 +853,7 @@ static int _php_ibase_bind(XSQLDA *sqlda, zval *b_vars, BIND_BUF *buf, /* {{{ */
836853
}
837854
var->sqltype = SQL_BOOLEAN;
838855
continue;
839-
856+
#endif
840857
case SQL_ARRAY:
841858

842859
if (Z_TYPE_P(b_var) != IS_ARRAY) {
@@ -899,9 +916,12 @@ static void _php_ibase_alloc_xsqlda(XSQLDA *sqlda) /* {{{ */
899916
case SQL_VARYING:
900917
var->sqldata = safe_emalloc(sizeof(char), var->sqllen + sizeof(short), 0);
901918
break;
902-
case SQL_BOOLEAN:
903-
var->sqldata = emalloc(sizeof(zend_bool));
904-
break;
919+
// Boolean data type exists since FB 3.0
920+
#ifdef SQL_BOOLEAN
921+
case SQL_BOOLEAN:
922+
var->sqldata = emalloc(sizeof(FB_BOOLEAN));
923+
break;
924+
#endif
905925
case SQL_SHORT:
906926
var->sqldata = emalloc(sizeof(short));
907927
break;
@@ -1401,10 +1421,12 @@ static int _php_ibase_var_zval(zval *val, void *data, int type, int len, /* {{{
14011421
case SQL_TEXT:
14021422
ZVAL_STRINGL(val, (char*)data, len);
14031423
break;
1404-
// The query's field value is boolean
1405-
case SQL_BOOLEAN:
1406-
ZVAL_BOOL(val, *(bool *) data);
1407-
break;
1424+
// Boolean data type exists since FB 3.0
1425+
#ifdef SQL_BOOLEAN
1426+
case SQL_BOOLEAN:
1427+
ZVAL_BOOL(val, *(FB_BOOLEAN *) data);
1428+
break;
1429+
#endif
14081430
case SQL_SHORT:
14091431
n = *(short *) data;
14101432
goto _sql_long;
@@ -2000,10 +2022,12 @@ static void _php_ibase_field_info(zval *return_value, XSQLVAR *var) /* {{{ */
20002022
unsigned short precision = 0;
20012023

20022024
switch (var->sqltype & ~1) {
2003-
2004-
case SQL_BOOLEAN:
2005-
precision = 1;
2006-
break;
2025+
// Boolean data type exists since FB 3.0
2026+
#ifdef SQL_BOOLEAN
2027+
case SQL_BOOLEAN:
2028+
precision = 1;
2029+
break;
2030+
#endif
20072031
case SQL_SHORT:
20082032
precision = 4;
20092033
break;
@@ -2028,9 +2052,12 @@ static void _php_ibase_field_info(zval *return_value, XSQLVAR *var) /* {{{ */
20282052
case SQL_SHORT:
20292053
s = "SMALLINT";
20302054
break;
2031-
case SQL_BOOLEAN:
2032-
s = "BOOLEAN";
2033-
break;
2055+
// Boolean data type exists since FB 3.0
2056+
#ifdef SQL_BOOLEAN
2057+
case SQL_BOOLEAN:
2058+
s = "BOOLEAN";
2059+
break;
2060+
#endif
20342061
case SQL_LONG:
20352062
s = "INTEGER";
20362063
break;

ibase_service.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
+----------------------------------------------------------------------+
3-
| PHP Version 7 |
3+
| PHP Version 7, 8 |
44
+----------------------------------------------------------------------+
55
| Copyright (c) The PHP Group |
66
+----------------------------------------------------------------------+
@@ -12,7 +12,14 @@
1212
| obtain it through the world-wide-web, please send a note to |
1313
| [email protected] so we can mail you a copy immediately. |
1414
+----------------------------------------------------------------------+
15-
| Authors: Ard Biesheuvel <[email protected]> |
15+
| Authors: Jouni Ahto <[email protected]> |
16+
| Andrew Avdeev <[email protected]> |
17+
| Ard Biesheuvel <[email protected]> |
18+
| Martin Koeditz <[email protected]> |
19+
| others |
20+
+----------------------------------------------------------------------+
21+
| You'll find history on Github |
22+
| https://github.com/FirebirdSQL/php-firebird/commits/master |
1623
+----------------------------------------------------------------------+
1724
*/
1825

interbase.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
+----------------------------------------------------------------------+
3-
| PHP Version 7 |
3+
| PHP Version 7, 8 |
44
+----------------------------------------------------------------------+
55
| Copyright (c) The PHP Group |
66
+----------------------------------------------------------------------+
@@ -13,8 +13,13 @@
1313
| [email protected] so we can mail you a copy immediately. |
1414
+----------------------------------------------------------------------+
1515
| Authors: Jouni Ahto <[email protected]> |
16-
| Andrew Avdeev <[email protected]> |
17-
| Ard Biesheuvel <[email protected]> |
16+
| Andrew Avdeev <[email protected]> |
17+
| Ard Biesheuvel <[email protected]> |
18+
| Martin Koeditz <[email protected]> |
19+
| others |
20+
+----------------------------------------------------------------------+
21+
| You'll find history on Github |
22+
| https://github.com/FirebirdSQL/php-firebird/commits/master |
1823
+----------------------------------------------------------------------+
1924
*/
2025

php_ibase_includes.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
+----------------------------------------------------------------------+
3-
| PHP Version 7 |
3+
| PHP Version 7, 8 |
44
+----------------------------------------------------------------------+
55
| Copyright (c) The PHP Group |
66
+----------------------------------------------------------------------+
@@ -14,7 +14,12 @@
1414
+----------------------------------------------------------------------+
1515
| Authors: Jouni Ahto <[email protected]> |
1616
| Andrew Avdeev <[email protected]> |
17-
| Ard Biesheuvel <[email protected]> |
17+
| Ard Biesheuvel <[email protected]> |
18+
| Martin Koeditz <[email protected]> |
19+
| others |
20+
+----------------------------------------------------------------------+
21+
| You'll find history on Github |
22+
| https://github.com/FirebirdSQL/php-firebird/commits/master |
1823
+----------------------------------------------------------------------+
1924
*/
2025

php_ibase_udf.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
+----------------------------------------------------------------------+
3-
| PHP Version 7 |
3+
| PHP Version 7, 8 |
44
+----------------------------------------------------------------------+
55
| Copyright (c) The PHP Group |
66
+----------------------------------------------------------------------+
@@ -12,7 +12,14 @@
1212
| obtain it through the world-wide-web, please send a note to |
1313
| [email protected] so we can mail you a copy immediately. |
1414
+----------------------------------------------------------------------+
15-
| Author: Ard Biesheuvel <[email protected]> |
15+
| Authors: Jouni Ahto <[email protected]> |
16+
| Andrew Avdeev <[email protected]> |
17+
| Ard Biesheuvel <[email protected]> |
18+
| Martin Koeditz <[email protected]> |
19+
| others |
20+
+----------------------------------------------------------------------+
21+
| You'll find history on Github |
22+
| https://github.com/FirebirdSQL/php-firebird/commits/master |
1623
+----------------------------------------------------------------------+
1724
*/
1825

php_interbase.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
+----------------------------------------------------------------------+
3-
| PHP Version 7 |
3+
| PHP Version 7, 8 |
44
+----------------------------------------------------------------------+
55
| Copyright (c) The PHP Group |
66
+----------------------------------------------------------------------+
@@ -15,6 +15,11 @@
1515
| Authors: Jouni Ahto <[email protected]> |
1616
| Andrew Avdeev <[email protected]> |
1717
| Ard Biesheuvel <[email protected]> |
18+
| Martin Koeditz <[email protected]> |
19+
| others |
20+
+----------------------------------------------------------------------+
21+
| You'll find history on Github |
22+
| https://github.com/FirebirdSQL/php-firebird/commits/master |
1823
+----------------------------------------------------------------------+
1924
*/
2025

@@ -25,7 +30,8 @@ extern zend_module_entry ibase_module_entry;
2530
#define phpext_interbase_ptr &ibase_module_entry
2631

2732
#include "php_version.h"
28-
#define PHP_INTERBASE_VERSION "1.1.2"
33+
// Keep version in track with Firebird
34+
#define PHP_INTERBASE_VERSION "3.0.0"
2935

3036
PHP_MINIT_FUNCTION(ibase);
3137
PHP_RINIT_FUNCTION(ibase);

0 commit comments

Comments
 (0)