Browse Source

Add oci_client_version() returning the runtime Oracle client library version - predominantly useful for the test suite

pull/271/head
Christopher Jones 15 years ago
parent
commit
199510ef07
  1. 36
      ext/oci8/oci8.c
  2. 11
      ext/oci8/oci8_interface.c
  3. 1
      ext/oci8/php_oci8_int.h
  4. 20
      ext/oci8/tests/clientversion.phpt
  5. 20
      ext/oci8/tests/clientversion_92.phpt

36
ext/oci8/oci8.c

@ -447,6 +447,9 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_result, 0, 0, 2)
ZEND_ARG_INFO(0, column_number_or_name)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_oci_client_version, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_oci_server_version, 0, 0, 1)
ZEND_ARG_INFO(0, connection_resource)
ZEND_END_ARG_INFO()
@ -681,6 +684,7 @@ static unsigned char arginfo_oci_bind_array_by_name[] = { 3, BYREF_NONE, BYREF_N
#define arginfo_oci_password_change NULL
#define arginfo_oci_new_cursor NULL
#define arginfo_oci_result NULL
#define arginfo_oci_client_version NULL
#define arginfo_oci_server_version NULL
#define arginfo_oci_statement_type NULL
#define arginfo_oci_num_rows NULL
@ -761,6 +765,7 @@ PHP_FUNCTION(oci_num_fields);
PHP_FUNCTION(oci_parse);
PHP_FUNCTION(oci_new_cursor);
PHP_FUNCTION(oci_result);
PHP_FUNCTION(oci_client_version);
PHP_FUNCTION(oci_server_version);
PHP_FUNCTION(oci_statement_type);
PHP_FUNCTION(oci_num_rows);
@ -836,6 +841,7 @@ zend_function_entry php_oci_functions[] = {
PHP_FE(oci_parse, arginfo_oci_parse)
PHP_FE(oci_new_cursor, arginfo_oci_new_cursor)
PHP_FE(oci_result, arginfo_oci_result)
PHP_FE(oci_client_version, arginfo_oci_client_version)
PHP_FE(oci_server_version, arginfo_oci_server_version)
PHP_FE(oci_statement_type, arginfo_oci_statement_type)
PHP_FE(oci_num_rows, arginfo_oci_num_rows)
@ -1295,6 +1301,7 @@ PHP_RSHUTDOWN_FUNCTION(oci)
PHP_MINFO_FUNCTION(oci)
{
char buf[32];
char *ver;
php_info_print_table_start();
php_info_print_table_row(2, "OCI8 Support", "enabled");
@ -1306,6 +1313,11 @@ PHP_MINFO_FUNCTION(oci)
snprintf(buf, sizeof(buf), "%ld", OCI_G(num_links));
php_info_print_table_row(2, "Active Connections", buf);
#if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2)))
php_oci_client_get_version(&ver TSRMLS_DC);
php_info_print_table_row(2, "Oracle Run-time Client Library Version", ver);
efree(ver);
#endif
#if defined(OCI_MAJOR_VERSION) && defined(OCI_MINOR_VERSION)
snprintf(buf, sizeof(buf), "%d.%d", OCI_MAJOR_VERSION, OCI_MINOR_VERSION);
#elif defined(PHP_OCI8_ORACLE_VERSION)
@ -2384,6 +2396,30 @@ int php_oci_password_change(php_oci_connection *connection, char *user, int user
return 0;
} /* }}} */
/* {{{ php_oci_client_get_version()
*
* Get Oracle client library version
*/
void php_oci_client_get_version(char **version TSRMLS_DC)
{
char version_buff[256];
sword major_version = 0;
sword minor_version = 0;
sword update_num = 0;
sword patch_num = 0;
sword port_update_num = 0;
#if ((OCI_MAJOR_VERSION > 10) || ((OCI_MAJOR_VERSION == 10) && (OCI_MINOR_VERSION >= 2))) /* OCIClientVersion only available 10.2 onwards */
PHP_OCI_CALL(OCIClientVersion, (&major_version, &minor_version, &update_num, &patch_num, &port_update_num));
snprintf(version_buff, sizeof(version_buff), "%d.%d.%d.%d.%d", major_version, minor_version, update_num, patch_num, port_update_num);
#else
memcpy(version_buff, "Unknown", sizeof("Unknown"));
#endif
*version = estrdup(version_buff);
} /* }}} */
/* {{{ php_oci_server_get_version()
*
* Get Oracle server version

11
ext/oci8/oci8_interface.c

@ -2002,6 +2002,17 @@ PHP_FUNCTION(oci_result)
}
/* }}} */
/* {{{ proto string oci_client_version()
Return a string containing runtime client library version information */
PHP_FUNCTION(oci_client_version)
{
char *version = NULL;
php_oci_client_get_version(&version TSRMLS_CC);
RETURN_STRING(version, 0);
}
/* }}} */
/* {{{ proto string oci_server_version(resource connection)
Return a string containing server version information */
PHP_FUNCTION(oci_server_version)

1
ext/oci8/php_oci8_int.h

@ -385,6 +385,7 @@ int php_oci_connection_commit(php_oci_connection * TSRMLS_DC);
int php_oci_connection_release(php_oci_connection *connection TSRMLS_DC);
int php_oci_password_change(php_oci_connection *, char *, int, char *, int, char *, int TSRMLS_DC);
void php_oci_client_get_version(char ** TSRMLS_DC);
int php_oci_server_get_version(php_oci_connection *, char ** TSRMLS_DC);
void php_oci_fetch_row(INTERNAL_FUNCTION_PARAMETERS, int, int);

20
ext/oci8/tests/clientversion.phpt

@ -0,0 +1,20 @@
--TEST--
oci_client_version()
--SKIPIF--
<?php
if (!extension_loaded('oci8')) die("skip no oci8 extension");
if (preg_match('/^1[012]\./', oci_client_version()) != 1) {
die("skip test expected to work only with Oracle 10g or greater version of client");
}
?>
--FILE--
<?php
echo oci_client_version(), "\n";
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
%d.%d.%d.%d.%d
===DONE===

20
ext/oci8/tests/clientversion_92.phpt

@ -0,0 +1,20 @@
--TEST--
oci_client_version() for Oracle 9.2 client libraries
--SKIPIF--
<?php
if (!extension_loaded('oci8')) die("skip no oci8 extension");
if (preg_match('/Unknown/', oci_client_version()) != 1) {
die("skip test expected to work only with Oracle 9gR2 client libraries");
}
?>
--FILE--
<?php
echo oci_client_version(), "\n";
?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
Unknown
===DONE===
Loading…
Cancel
Save