diff --git a/ext/oci8/oci8.c b/ext/oci8/oci8.c index 01b2414a9e3..eed4a1c8f88 100644 --- a/ext/oci8/oci8.c +++ b/ext/oci8/oci8.c @@ -2634,7 +2634,7 @@ int php_oci_column_to_zval(php_oci_out_column *column, zval *value, int mode) void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_args) { zval *z_statement, *array; - zval *placeholder; + zval *placeholder = (zval*) NULL; /* zend_array *temp_array = (zend_array *) NULL;*/ php_oci_statement *statement; /* statement that will be fetched from */ #if (OCI_MAJOR_VERSION >= 12) @@ -2655,6 +2655,12 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg if (ZEND_NUM_ARGS() == 2) { fetch_mode = mode; } + + if (Z_ISREF_P(array)) + placeholder = Z_REFVAL_P(array); + else + placeholder = array; + } else if (expected_args == 2) { /* only for oci_fetch_array() */ @@ -2743,14 +2749,10 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg } #endif /* OCI_MAJOR_VERSION */ - if (expected_args > 2) { - if (Z_ISREF_P(array)) - placeholder = Z_REFVAL_P(array); - else - placeholder = array; - zval_dtor(placeholder); - } else { + if (placeholder == NULL) { placeholder = return_value; + } else { + zval_dtor(placeholder); } array_init(placeholder); @@ -2792,20 +2794,6 @@ void php_oci_fetch_row (INTERNAL_FUNCTION_PARAMETERS, int mode, int expected_arg } if (expected_args > 2) { - /* Only for ocifetchinto BC. In all other cases we return array, not long */ -#if 0 - zval *temp_array; - if (Z_ISREF_P(array)) - temp_array = Z_REFVAL_P(array); - else /* PHP7 will pass user buffer through 'array' as reference type. - * So this part of code may not be reached. */ - temp_array = array; - - /* copy array content in return_value into user buffer passed through - * reference variable 'array' */ - ZVAL_ARR(temp_array, Z_ARRVAL_P(return_value)); - zval_ptr_dtor(return_value); -#endif RETURN_LONG(statement->ncolumns); } } diff --git a/ext/oci8/tests/bind_sqltnum_11g.phpt b/ext/oci8/tests/bind_sqltnum_11g.phpt new file mode 100644 index 00000000000..1969893604c --- /dev/null +++ b/ext/oci8/tests/bind_sqltnum_11g.phpt @@ -0,0 +1,279 @@ +--TEST-- +Bind with SQLT_NUM +--SKIPIF-- + +--FILE-- + +===DONE=== + +--EXPECTF-- +Test 1 - baseline test +array(2) { + ["ID"]=> + array(1) { + [0]=> + string(3) "100" + } + ["VARCHAR2_T10"]=> + array(1) { + [0]=> + string(4) "Hood" + } +} +Test 2 - SQLT_NUM to a VARCHAR2 column + +Warning: oci_execute(): ORA-12899: %s (%s: 40, %s: 10) in %sbind_sqltnum_11g.php on line %d +string(%d) "ORA-12899: %s" + +TEST41 wrong bind type SQLT_NUM + +Warning: oci_execute(): ORA-12899: %s "%s"."BIND_SQLTNUM_TAB"."VARCHAR2_T10" (%s: 40, %s: 10) in %sbind_sqltnum_11g.php on line %d + +TEST42 insert numbers SQLT_NUM +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + NULL + } +} + +TEST43 insert numbers SQLT_NUM +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + NULL + } +} + +TEST44 +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + string(127) "-000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000" + } +} + +TEST45 +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + NULL + } +} + +TEST46 insert numbers +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + NULL + } +} + +TEST47 +array(1) { + ["NUMBER_T"]=> + array(1) { + [0]=> + NULL + } +} + +TEST48 +array(1) { + ["NUMBER_T92"]=> + array(1) { + [0]=> + string(1) "0" + } +} + +TEST49 +array(1) { + ["NUMBER_T92"]=> + array(1) { + [0]=> + string(1) "0" + } +} + +TEST50 + +Warning: oci_execute(): ORA-01438: %s in %sbind_sqltnum_11g.php on line %d +array(1) { + ["NUMBER_T92"]=> + array(0) { + } +} +===DONE=== diff --git a/ext/oci8/tests/drcp_cclass1.phpt b/ext/oci8/tests/drcp_cclass1.phpt index 5c78a2943e9..0a929317bb2 100644 --- a/ext/oci8/tests/drcp_cclass1.phpt +++ b/ext/oci8/tests/drcp_cclass1.phpt @@ -5,6 +5,9 @@ DRCP: Test setting connection class inline if (!extension_loaded('oci8')) die ("skip no oci8 extension"); require(dirname(__FILE__).'/connect.inc'); if (!$test_drcp) die("skip testing DRCP connection class only works in DRCP mode"); +// Looked for :pooled in EZ connect string +if (strpos($dbase, "/") !== false && stripos($dbase, ":pooled") === false) + die('skip DRCP test requires a DRCP pooled server connection'); if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches_sv); diff --git a/ext/oci8/tests/drcp_privileged.phpt b/ext/oci8/tests/drcp_privileged.phpt index 3871341bc50..c57216672f4 100644 --- a/ext/oci8/tests/drcp_privileged.phpt +++ b/ext/oci8/tests/drcp_privileged.phpt @@ -5,6 +5,9 @@ DRCP: privileged connect if (!extension_loaded('oci8')) die("skip no oci8 extension"); require(dirname(__FILE__)."/connect.inc"); if (!$test_drcp) die("skip requires DRCP connection"); +// Looked for :pooled in EZ connect string +if (strpos($dbase, "/") !== false && stripos($dbase, ":pooled") === false) + die('skip DRCP test requires a DRCP pooled server connection'); if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to be run as a DBA user"); ob_start(); phpinfo(INFO_MODULES); diff --git a/ext/oci8/tests/driver_name.phpt b/ext/oci8/tests/driver_name.phpt index ffef0328d94..758e3979a76 100644 --- a/ext/oci8/tests/driver_name.phpt +++ b/ext/oci8/tests/driver_name.phpt @@ -8,8 +8,9 @@ if (strcasecmp($user, "system") && strcasecmp($user, "sys")) die("skip needs to if ($test_drcp) die("skip as Output might vary with DRCP"); preg_match('/.*Release ([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)\.([[:digit:]]+)*/', oci_server_version($c), $matches); -if (!(isset($matches[0]) && ($matches[1] == 12 && $matches[2] == 1 && $matches[3] >= 0 - && $matches[4] >= 2) || ($matches[1] == 12 && $matches[2] > 1))) +if (!(isset($matches[0]) && + ($matches[1] == 12 && $matches[2] == 1 && $matches[3] >= 0 + && $matches[4] >= 2) || ($matches[1] == 12 && $matches[2] > 1))) { die("skip test expected to work only with Oracle 12.1.0.2 database or its later patchsets"); }