function oci_lob_is_equal(OCILob $lob_descriptor_first, OCILob $lob_descriptor_second): bool {}
-function oci_lob_export(OCILob $lob_descriptor, string $path, ?int $start = null, ?int $length = null): bool {}
+function oci_lob_export(OCILob $lob_descriptor, string $filename, ?int $start = null, ?int $length = null): bool {}
/**
* @alias oci_lob_export
* @deprecated
*/
-function ociwritelobtofile(OCILob $lob_descriptor, string $path, ?int $start = null, ?int $length = null): bool {}
+function ociwritelobtofile(OCILob $lob_descriptor, string $filename, ?int $start = null, ?int $length = null): bool {}
/**
* @param resource $connection_resource
/**
* @param resource $statement_resource
*/
-function oci_set_prefetch($statement_resource, int $number_of_rows): ?bool {}
+function oci_set_prefetch($statement_resource, int $number_of_rows): bool {}
/**
* @param resource $statement_resource
* @alias oci_set_prefetch
* @deprecated
*/
-function ocisetprefetch($statement_resource, int $number_of_rows): ?bool {}
+function ocisetprefetch($statement_resource, int $number_of_rows): bool {}
/**
* @param resource $connection_resource
* @alias oci_lob_export
* @return bool
*/
- public function writetofile(string $path, ?int $start = null, ?int $length = null) {}
+ public function writetofile(string $filename, ?int $start = null, ?int $length = null) {}
/**
* @alias oci_lob_export
* @return bool
*/
- public function export(string $path, ?int $start = null, ?int $length = null) {}
+ public function export(string $filename, ?int $start = null, ?int $length = null) {}
/**
* @alias oci_lob_write_temporary
/* This is a generated file, edit the .stub.php file instead.
- * Stub hash: 2d553815c21edd58bc29b1ca8d294d5750fd7312 */
+ * Stub hash: 6cdc7c967ce80c39eaef1c860ba8f8aa2cb3c979 */
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_define_by_name, 0, 3, _IS_BOOL, 0)
ZEND_ARG_INFO(0, statement_resource)
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_lob_export, 0, 2, _IS_BOOL, 0)
ZEND_ARG_OBJ_INFO(0, lob_descriptor, OCILob, 0)
- ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, start, IS_LONG, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
ZEND_ARG_INFO(0, statement_resource)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_set_prefetch, 0, 2, _IS_BOOL, 1)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_oci_set_prefetch, 0, 2, _IS_BOOL, 0)
ZEND_ARG_INFO(0, statement_resource)
ZEND_ARG_TYPE_INFO(0, number_of_rows, IS_LONG, 0)
ZEND_END_ARG_INFO()
#define arginfo_class_OCILob_getbuffering arginfo_class_OCILob_load
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_OCILob_writetofile, 0, 0, 1)
- ZEND_ARG_TYPE_INFO(0, path, IS_STRING, 0)
+ ZEND_ARG_TYPE_INFO(0, filename, IS_STRING, 0)
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, start, IS_LONG, 1, "null")
ZEND_ARG_TYPE_INFO_WITH_DEFAULT_VALUE(0, length, IS_LONG, 1, "null")
ZEND_END_ARG_INFO()
#define OCI_STMT_CALL 10
#endif
+#define ERROR_ARG_POS(arg_num) (getThis() ? (arg_num-1) : (arg_num))
+
/* {{{ Register a callback function for Oracle Transparent Application Failover (TAF) */
PHP_FUNCTION(oci_register_taf_callback)
{
ZEND_PARSE_PARAMETERS_END();
if (!name_len) {
- php_error_docref(NULL, E_WARNING, "Column name cannot be empty");
- RETURN_FALSE;
+ zend_argument_value_error(2, "cannot be empty");
+ RETURN_THROWS();
}
PHP_OCI_ZVAL_TO_STATEMENT(stmt, statement);
}
if (max_array_len <= 0) {
- php_error_docref(NULL, E_WARNING, "Maximum array length must be greater than zero");
- RETURN_FALSE;
+ zend_argument_value_error(4, "must be greater than 0");
+ RETURN_THROWS();
}
if (php_oci_bind_array_by_name(statement, name, (sb4) name_len, bind_var, max_array_len, max_item_len, type)) {
RETURN_THROWS();
}
+ if (offset < 0) {
+ zend_argument_value_error(ERROR_ARG_POS(3), "must be greater than or equal to 0");
+ RETURN_THROWS();
+ }
+
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor);
- if (offset < 0) {
- php_error_docref(NULL, E_WARNING, "Offset parameter must be greater than or equal to 0");
- RETURN_FALSE;
- }
-
if (php_oci_lob_write(descriptor, (ub4) offset, data, (ub4) data_len, &bytes_written)) {
RETURN_FALSE;
}
char *filename;
size_t filename_len;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Op", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len) == FAILURE) {
RETURN_THROWS();
}
RETURN_FALSE;
}
- if (CHECK_NULL_PATH(filename, filename_len)) {
- php_error_docref(NULL, E_WARNING, "filename must not contain null bytes");
- RETURN_FALSE;
- }
-
PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor);
if (php_oci_lob_import(descriptor, filename)) {
RETURN_THROWS();
}
+ if (length <= 0) {
+ zend_argument_value_error(ERROR_ARG_POS(2), "must be greater than 0");
+ RETURN_THROWS();
+ }
+
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor);
- if (length <= 0) {
- php_error_docref(NULL, E_WARNING, "Length parameter must be greater than 0");
- RETURN_FALSE;
- }
-
if (php_oci_lob_read(descriptor, length, descriptor->lob_current_position, &buffer, &buffer_len)) {
RETURN_FALSE;
}
RETURN_THROWS();
}
- if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
- php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
- RETURN_FALSE;
+ if (trim_length < 0) {
+ zend_argument_value_error(ERROR_ARG_POS(2), "must be greater than or equal to 0");
+ RETURN_THROWS();
}
- if (trim_length < 0) {
- php_error_docref(NULL, E_WARNING, "Length must be greater than or equal to zero");
+ if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
+ php_error_docref(NULL, E_WARNING, "Unable to find descriptor property");
RETURN_FALSE;
}
if (offset_is_null) {
offset = -1;
} else if (offset < 0) {
- php_error_docref(NULL, E_WARNING, "Offset must be greater than or equal to 0");
- RETURN_FALSE;
+ zend_argument_value_error(ERROR_ARG_POS(2), "must be greater than or equal to 0");
+ RETURN_THROWS();
}
if (length_is_null) {
length = -1;
} else if (length < 0) {
- php_error_docref(NULL, E_WARNING, "Length must be greater than or equal to 0");
- RETURN_FALSE;
+ zend_argument_value_error(ERROR_ARG_POS(3), "must be greater than or equal to 0");
+ RETURN_THROWS();
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
RETURN_THROWS();
}
+ if (length_is_null) {
+ length = -1;
+ } else if (length < 0) {
+ zend_argument_value_error(3, "must be greater than or equal to 0");
+ RETURN_THROWS();
+ }
+
if ((tmp_dest = zend_hash_str_find(Z_OBJPROP_P(z_descriptor_dest), "descriptor", sizeof("descriptor")-1)) == NULL) {
php_error_docref(NULL, E_WARNING, "Unable to find descriptor property. The first argument should be valid descriptor object");
RETURN_FALSE;
PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp_dest, descriptor_dest);
PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp_from, descriptor_from);
- if (length_is_null) {
- length = -1;
- } else if (length < 0) {
- php_error_docref(NULL, E_WARNING, "Length parameter must be greater than 0");
- RETURN_FALSE;
- }
-
if (php_oci_lob_copy(descriptor_dest, descriptor_from, length)) {
RETURN_FALSE;
}
php_stream *stream;
ub4 lob_length;
- if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Os|l!l!", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len, &start, &start_is_null, &length, &length_is_null) == FAILURE) {
+ if (zend_parse_method_parameters(ZEND_NUM_ARGS(), getThis(), "Op|l!l!", &z_descriptor, oci_lob_class_entry_ptr, &filename, &filename_len, &start, &start_is_null, &length, &length_is_null) == FAILURE) {
RETURN_THROWS();
}
if (start_is_null) {
start = -1;
} else if (start < 0) {
- php_error_docref(NULL, E_WARNING, "Start parameter must be greater than or equal to 0");
- RETURN_FALSE;
+ zend_argument_value_error(ERROR_ARG_POS(3), "must be greater than or equal to 0");
+ RETURN_THROWS();
}
if (length_is_null) {
length = -1;
} else if (length < 0) {
- php_error_docref(NULL, E_WARNING, "length parameter must be greater than or equal to 0");
- RETURN_FALSE;
+ zend_argument_value_error(ERROR_ARG_POS(4), "must be greater than or equal to 0");
+ RETURN_THROWS();
}
if ((tmp = zend_hash_str_find(Z_OBJPROP_P(z_descriptor), "descriptor", sizeof("descriptor")-1)) == NULL) {
RETURN_FALSE;
}
- if (CHECK_NULL_PATH(filename, filename_len)) {
- php_error_docref(NULL, E_WARNING, "filename must not contain null bytes");
- RETURN_FALSE;
- }
-
PHP_OCI_ZVAL_TO_DESCRIPTOR(tmp, descriptor);
if (php_oci_lob_get_length(descriptor, &lob_length)) {
PHP_OCI_ZVAL_TO_STATEMENT(z_statement, statement);
if (size < 0) {
- php_error_docref(NULL, E_WARNING, "Number of rows to be prefetched has to be greater than or equal to 0");
- return;
+ zend_argument_value_error(2, "must be greater than or equal to 0");
+ RETURN_THROWS();
}
if (php_oci_statement_set_prefetch(statement, (ub4)size)) {
PHP_OCI_ZVAL_TO_CONNECTION(z_connection, connection);
if (!user_len) {
- php_error_docref(NULL, E_WARNING, "Username cannot be empty");
- RETURN_FALSE;
+ zend_argument_value_error(2, "cannot be empty");
+ RETURN_THROWS();
}
if (!pass_old_len) {
- php_error_docref(NULL, E_WARNING, "Old password cannot be empty");
- RETURN_FALSE;
+ zend_argument_value_error(3, "cannot be empty");
+ RETURN_THROWS();
}
if (!pass_new_len) {
- php_error_docref(NULL, E_WARNING, "New password cannot be empty");
- RETURN_FALSE;
+ zend_argument_value_error(4, "cannot be empty");
+ RETURN_THROWS();
}
if (php_oci_password_change(connection, user, (int) user_len, pass_old, (int) pass_old_len, pass_new, (int) pass_new_len)) {
} else if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "ssss", &dbname, &dbname_len, &user, &user_len, &pass_old, &pass_old_len, &pass_new, &pass_new_len) == SUCCESS) {
if (!user_len) {
- php_error_docref(NULL, E_WARNING, "Username cannot be empty");
- RETURN_FALSE;
+ zend_argument_value_error(2, "cannot be empty");
+ RETURN_THROWS();
}
if (!pass_old_len) {
- php_error_docref(NULL, E_WARNING, "Old password cannot be empty");
- RETURN_FALSE;
+ zend_argument_value_error(3, "cannot be empty");
+ RETURN_THROWS();
}
if (!pass_new_len) {
- php_error_docref(NULL, E_WARNING, "New password cannot be empty");
- RETURN_FALSE;
+ zend_argument_value_error(4, "cannot be empty");
+ RETURN_THROWS();
}
connection = php_oci_do_connect_ex(user, (int) user_len, pass_old, (int) pass_old_len, pass_new, (int) pass_new_len, dbname, (int) dbname_len, NULL, OCI_DEFAULT, 0, 0);
$array = Array("06-DEC-05","10-DEC-80","21-AUG-91","26-OCT-17","05-NOV-05");
-oci_bind_array_by_name($statement, ":c1", $array, 0, 0, SQLT_ODT);
+try {
+ oci_bind_array_by_name($statement, ":c1", $array, 0, 0, SQLT_ODT);
+} catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+}
oci_execute($statement);
echo "Done\n";
?>
--EXPECTF--
-Warning: oci_bind_array_by_name(): Maximum array length must be greater than zero in %s on line %d
+oci_bind_array_by_name(): Argument #4 ($maximum_array_length) must be greater than 0
Warning: oci_execute(): ORA-%r(01008|57000)%r: %s in %s on line %d
array(5) {
$string = '';
var_dump(oci_define_by_name($stmt, "STRING", $string, 20));
var_dump(oci_define_by_name($stmt, "STRING", $string, 20));
-var_dump(oci_define_by_name($stmt, "", $string, 20));
+try {
+ var_dump(oci_define_by_name($stmt, "", $string, 20));
+} catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+}
oci_execute($stmt);
--EXPECTF--
bool(true)
bool(false)
-
-Warning: oci_define_by_name(): Column name cannot be empty in %s on line %d
-bool(false)
+oci_define_by_name(): Argument #2 ($column_name) cannot be empty
string(4) "some"
Done
oci_bind_by_name($statement, ":mylob", $clob, -1, OCI_B_CLOB);
oci_execute($statement, OCI_DEFAULT);
$clob->save("long data");
-$clob->save("long data", -1);
$clob->save("long data", 0);
-oci_commit($c);
+try {
+ $clob->save("long data", -1);
+} catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+}
+oci_commit($c);
$query = 'SELECT * FROM lob_test ORDER BY mykey ASC';
$statement = oci_parse ($c, $query);
?>
--EXPECTF--
-Warning: OCILob::save(): Offset parameter must be greater than or equal to 0 in %s on line %d
+OCILob::save(): Argument #2 ($offset) must be greater than or equal to 0
string(4) "data"
string(9) "long data"
string(9) "long data"
$row = oci_fetch_array($s);
var_dump($row['BLOB']->load());
- var_dump($row['BLOB']->truncate(($i-1)*10));
+ try {
+ var_dump($row['BLOB']->truncate(($i-1)*10));
+ } catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+ }
oci_commit($c);
}
$row = oci_fetch_array($s);
var_dump($row['BLOB']->load());
-var_dump($row['BLOB']->truncate(-1));
var_dump($row['BLOB']->truncate(0));
+try {
+ var_dump($row['BLOB']->truncate(-1));
+} catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+}
+
oci_commit($c);
require __DIR__.'/drop_table.inc';
string(10) "this is a "
bool(true)
string(0) ""
-
-Warning: OCILob::truncate(): Length must be greater than or equal to zero in %s on line %d
-bool(false)
+OCILob::truncate(): Argument #1 ($length) must be greater than or equal to 0
string(0) ""
-
-Warning: OCILob::truncate(): Length must be greater than or equal to zero in %s on line %d
-bool(false)
bool(true)
+OCILob::truncate(): Argument #1 ($length) must be greater than or equal to 0
Done
oci_bind_by_name($statement,":v_blob", $blob,-1,OCI_B_BLOB);
oci_execute($statement, OCI_DEFAULT);
+echo "Writing blob\n";
var_dump($blob->write("some string here. string, I said"));
oci_commit($c);
$dummy = oci_new_descriptor($c, OCI_D_LOB);
+//--------------------------------------------------
+
+echo "\noci_lob_copy invalid args\n";
+
var_dump(oci_lob_copy($dummy, $row1[0]));
var_dump(oci_lob_copy($row2[0], $dummy));
-
var_dump(oci_lob_copy($row2[0], $row1[0], 0));
-var_dump(oci_lob_copy($row2[0], $row1[0], -1));
var_dump(oci_lob_copy($row2[0], $row1[0], 100000));
+try {
+ var_dump(oci_lob_copy($row2[0], $row1[0], -1));
+} catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+}
+
+//--------------------------------------------------
+
+echo "\noci_lob_size tests\n";
+
var_dump(oci_lob_size($row2[0]));
unset($dummy->descriptor);
var_dump(oci_lob_size($dummy));
oci_rollback($c);
-oci_rollback($c);
-oci_commit($c);
-oci_commit($c);
+
+//--------------------------------------------------
+
+echo "\nQuery test\n";
$select_sql = "SELECT blob FROM ".$schema.$table_name." WHERE id = 2 FOR UPDATE";
$s = oci_parse($c, $select_sql);
?>
--EXPECTF--
+Writing blob
int(32)
+oci_lob_copy invalid args
+
Warning: oci_lob_copy(): OCI_INVALID_HANDLE in %s on line %d
bool(false)
Warning: oci_lob_copy(): OCI_INVALID_HANDLE in %s on line %d
bool(false)
bool(false)
-
-Warning: oci_lob_copy(): Length parameter must be greater than 0 in %s on line %d
-bool(false)
bool(true)
+oci_lob_copy(): Argument #3 ($length) must be greater than or equal to 0
+
+oci_lob_size tests
int(0)
Warning: oci_lob_size(): Unable to find descriptor property in %s on line %d
bool(false)
+
+Query test
array(2) {
[0]=>
string(0) ""
var_dump($blob->truncate(1));
var_dump($blob->truncate(1));
var_dump($blob->truncate(2));
-var_dump($blob->truncate(-1));
var_dump($blob->read(2));
var_dump($blob->import("does_not_exist"));
var_dump($blob->saveFile("does_not_exist"));
+try {
+ var_dump($blob->truncate(-1));
+} catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+}
+
require(__DIR__.'/drop_table.inc');
echo "Done\n";
Warning: OCILob::truncate(): Size must be less than or equal to the current LOB size in %s on line %d
bool(false)
-Warning: OCILob::truncate(): Length must be greater than or equal to zero in %s on line %d
-bool(false)
-
Warning: OCILob::read(): Offset must be less than size of the LOB in %s on line %d
bool(false)
Warning: OCILob::savefile(): Can't open file %s in %s on line %d
bool(false)
+OCILob::truncate(): Argument #1 ($length) must be greater than or equal to 0
Done
?>
--INI--
display_errors = On
-error_reporting = E_WARNING
--FILE--
<?php
echo "Test 1: Import\n";
$lob = oci_new_descriptor($c, OCI_D_LOB);
-$r = $lob->savefile("/tmp/abc\0def");
-var_dump($r);
+try {
+ $lob->savefile("/tmp/abc\0def");
+} catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+}
echo "Test 2: Export\n";
-$r = $lob->export("/tmp/abc\0def");
-var_dump($r);
+try {
+ $lob->export("/tmp/abc\0def");
+} catch (ValueError $e) {
+ echo $e->getMessage(), "\n";
+}
?>
--EXPECTF--
Test 1: Import
-
-Warning: OCILob::savefile(): filename must not contain null bytes in %s on line %d
-bool(false)
+OCILob::savefile(): Argument #1 ($filename) must not contain any null bytes
Test 2: Export
-
-Warning: OCILob::export(): filename must not contain null bytes in %s on line %d
-bool(false)
+OCILob::export(): Argument #1 ($filename) must not contain any null bytes
}
// Various values for prefetch
-$pref = array(0,1,501,499,250,12345,-12345,-1);
+$pref = array(0,1,501,499,250,12345);
foreach($pref as $value) {
echo"-----------------------------------------------\n";
echo "Test with Prefetch value set to $value \n";
fetch_frm_plsql($c,$cur1);
}
+// Various invalid values for prefetch
+$pref = array(-12345,-1);
+foreach($pref as $value) {
+ try {
+ echo "-----------------------------------------------\n";
+ echo "Test with Prefetch (invalid) value set to $value \n";
+ echo "-----------------------------------------------\n";
+ $cur1 = oci_new_cursor($c);
+ fetch_frm_php($c,$cur1,$value);
+ fetch_frm_plsql($c,$cur1);
+ } catch(ValueError $e) {
+ echo $e->getMessage(), "\n";
+ }
+}
+
// This function sets the prefetch count to the given $value and fetches one row .
int(0)
NULL
-----------------------------------------------
-Test with Prefetch value set to -12345
+Test with Prefetch (invalid) value set to -12345
-----------------------------------------------
-
-Warning: oci_set_prefetch(): Number of rows to be prefetched has to be greater than or equal to 0 in %s on line %d
-Fetch Row from PHP
-array(2) {
- [0]=>
- string(%d) "0"
- [1]=>
- string(%d) "test0"
-}
-Fetch Row from PL/SQL
-int(101)
-string(%d) "test101"
+oci_set_prefetch(): Argument #2 ($number_of_rows) must be greater than or equal to 0
-----------------------------------------------
-Test with Prefetch value set to -1
+Test with Prefetch (invalid) value set to -1
-----------------------------------------------
-
-Warning: oci_set_prefetch(): Number of rows to be prefetched has to be greater than or equal to 0 in %s on line %d
-Fetch Row from PHP
-array(2) {
- [0]=>
- string(%d) "0"
- [1]=>
- string(%d) "test0"
-}
-Fetch Row from PL/SQL
-int(101)
-string(%d) "test101"
+oci_set_prefetch(): Argument #2 ($number_of_rows) must be greater than or equal to 0
Done