Skip to content

ext/pdo_firebird: Added Pdo\Firebird::ATTR_API_VERSION #14916

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ext/pdo_firebird/firebird_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions ext/pdo_firebird/pdo_firebird.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */
REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_DATE_FORMAT", (zend_long) PDO_FB_ATTR_DATE_FORMAT);
REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIME_FORMAT", (zend_long) PDO_FB_ATTR_TIME_FORMAT);
REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIMESTAMP_FORMAT", (zend_long) PDO_FB_ATTR_TIMESTAMP_FORMAT);
REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_API_VERSION", (zend_long) PDO_FB_ATTR_API_VERSION);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, is this related to the server, or the driver?

As it might make more sense to expose it via PDO::ATTR_SERVER_INFO

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only related to the header file ibase.h at build time.

The server side is completely irrelevant.

The client side is somewhat involved, but due to factors such as updates, the header file version at the time of build and the client version do not always match.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, then this is fine.

REGISTER_PDO_CLASS_CONST_LONG("FB_TRANSACTION_ISOLATION_LEVEL", (zend_long) PDO_FB_TRANSACTION_ISOLATION_LEVEL);
REGISTER_PDO_CLASS_CONST_LONG("FB_READ_COMMITTED", (zend_long) PDO_FB_READ_COMMITTED);
REGISTER_PDO_CLASS_CONST_LONG("FB_REPEATABLE_READ", (zend_long) PDO_FB_REPEATABLE_READ);
Expand Down Expand Up @@ -93,11 +94,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();
}
/* }}} */
1 change: 1 addition & 0 deletions ext/pdo_firebird/php_pdo_firebird_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions ext/pdo_firebird/tests/get_api_version.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
PDO_Firebird: get api version
--EXTENSIONS--
pdo_firebird
--SKIPIF--
<?php require('skipif.inc'); ?>
--XLEAK--
A bug in firebird causes a memory leak when calling `isc_attach_database()`.
See https://github.com/FirebirdSQL/firebird/issues/7849
--FILE--
<?php
require("testdb.inc");
$dbh = getDbConnection();
echo $dbh->getAttribute(PDO::FB_ATTR_API_VERSION) . "\n";
echo 'done!';
?>
--EXPECTF--
%d
done!
Loading