diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c index 82df4ae40ffd8..d8380dbdee784 100644 --- a/ext/pdo_firebird/firebird_driver.c +++ b/ext/pdo_firebird/firebird_driver.c @@ -1177,6 +1177,10 @@ static int pdo_firebird_get_attribute(pdo_dbh_t *dbh, zend_long attr, zval *val) } return 1; + case PDO_FB_ATTR_API_VERSION: + ZVAL_LONG(val, FB_API_VER); + return 1; + case PDO_ATTR_SERVER_VERSION: case PDO_ATTR_SERVER_INFO: *tmp = 0; diff --git a/ext/pdo_firebird/pdo_firebird.c b/ext/pdo_firebird/pdo_firebird.c index ce4c6d69102ff..2c69afacb00f7 100644 --- a/ext/pdo_firebird/pdo_firebird.c +++ b/ext/pdo_firebird/pdo_firebird.c @@ -93,11 +93,15 @@ PHP_MSHUTDOWN_FUNCTION(pdo_firebird) /* {{{ */ PHP_MINFO_FUNCTION(pdo_firebird) /* {{{ */ { char version[64]; + char api_version[8]; isc_get_client_version(version); + snprintf(api_version, 7, "%d", FB_API_VER); + php_info_print_table_start(); php_info_print_table_row(2, "PDO Driver for Firebird", "enabled"); php_info_print_table_row(2, "Client Library Version", version); + php_info_print_table_row(2, "Firebird API version", api_version); php_info_print_table_end(); } /* }}} */ diff --git a/ext/pdo_firebird/pdo_firebird.stub.php b/ext/pdo_firebird/pdo_firebird.stub.php index 080d566bed8aa..bbbd15115bab3 100644 --- a/ext/pdo_firebird/pdo_firebird.stub.php +++ b/ext/pdo_firebird/pdo_firebird.stub.php @@ -19,6 +19,9 @@ class Firebird extends PDO /** @cvalue PDO_FB_ATTR_TIMESTAMP_FORMAT */ public const int ATTR_TIMESTAMP_FORMAT = UNKNOWN; + /** @cvalue PDO_FB_ATTR_API_VERSION */ + public const int ATTR_API_VERSION = UNKNOWN; + /** @cvalue PDO_FB_TRANSACTION_ISOLATION_LEVEL */ public const int TRANSACTION_ISOLATION_LEVEL = UNKNOWN; diff --git a/ext/pdo_firebird/pdo_firebird_arginfo.h b/ext/pdo_firebird/pdo_firebird_arginfo.h index 02e7dac15a5f7..b9d5d3a89de4c 100644 --- a/ext/pdo_firebird/pdo_firebird_arginfo.h +++ b/ext/pdo_firebird/pdo_firebird_arginfo.h @@ -1,5 +1,5 @@ /* This is a generated file, edit the .stub.php file instead. - * Stub hash: 584b20b65c1ebccf82f894cb9e16ea76a2b1aa1e */ + * Stub hash: 84acb963a6d147625c986e66ec313a0927314af2 */ static const zend_function_entry class_Pdo_Firebird_methods[] = { ZEND_FE_END @@ -31,6 +31,12 @@ static zend_class_entry *register_class_Pdo_Firebird(zend_class_entry *class_ent zend_declare_typed_class_constant(class_entry, const_ATTR_TIMESTAMP_FORMAT_name, &const_ATTR_TIMESTAMP_FORMAT_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); zend_string_release(const_ATTR_TIMESTAMP_FORMAT_name); + zval const_ATTR_API_VERSION_value; + ZVAL_LONG(&const_ATTR_API_VERSION_value, PDO_FB_ATTR_API_VERSION); + zend_string *const_ATTR_API_VERSION_name = zend_string_init_interned("ATTR_API_VERSION", sizeof("ATTR_API_VERSION") - 1, 1); + zend_declare_typed_class_constant(class_entry, const_ATTR_API_VERSION_name, &const_ATTR_API_VERSION_value, ZEND_ACC_PUBLIC, NULL, (zend_type) ZEND_TYPE_INIT_MASK(MAY_BE_LONG)); + zend_string_release(const_ATTR_API_VERSION_name); + zval const_TRANSACTION_ISOLATION_LEVEL_value; ZVAL_LONG(&const_TRANSACTION_ISOLATION_LEVEL_value, PDO_FB_TRANSACTION_ISOLATION_LEVEL); zend_string *const_TRANSACTION_ISOLATION_LEVEL_name = zend_string_init_interned("TRANSACTION_ISOLATION_LEVEL", sizeof("TRANSACTION_ISOLATION_LEVEL") - 1, 1); diff --git a/ext/pdo_firebird/php_pdo_firebird_int.h b/ext/pdo_firebird/php_pdo_firebird_int.h index dc1e4bb7f4086..a462eba5c6165 100644 --- a/ext/pdo_firebird/php_pdo_firebird_int.h +++ b/ext/pdo_firebird/php_pdo_firebird_int.h @@ -142,6 +142,7 @@ enum { PDO_FB_ATTR_DATE_FORMAT = PDO_ATTR_DRIVER_SPECIFIC, PDO_FB_ATTR_TIME_FORMAT, PDO_FB_ATTR_TIMESTAMP_FORMAT, + PDO_FB_ATTR_API_VERSION, /* * transaction isolation level diff --git a/ext/pdo_firebird/tests/get_api_version.phpt b/ext/pdo_firebird/tests/get_api_version.phpt new file mode 100644 index 0000000000000..eeb77b62a6582 --- /dev/null +++ b/ext/pdo_firebird/tests/get_api_version.phpt @@ -0,0 +1,19 @@ +--TEST-- +PDO_Firebird: get api version +--EXTENSIONS-- +pdo_firebird +--SKIPIF-- + +--XLEAK-- +A bug in firebird causes a memory leak when calling `isc_attach_database()`. +See https://github.com/FirebirdSQL/firebird/issues/7849 +--FILE-- +getAttribute(Pdo\Firebird::ATTR_API_VERSION) . "\n"; +echo 'done!'; +?> +--EXPECTF-- +%d +done!