summaryrefslogtreecommitdiff
path: root/ext/interbase
diff options
context:
space:
mode:
Diffstat (limited to 'ext/interbase')
-rw-r--r--ext/interbase/ibase_blobs.c4
-rw-r--r--ext/interbase/ibase_events.c29
-rw-r--r--ext/interbase/ibase_query.c17
-rw-r--r--ext/interbase/ibase_service.c13
-rw-r--r--ext/interbase/interbase.c19
-rwxr-xr-xext/interbase/php_ibase_includes.h4
-rw-r--r--ext/interbase/php_ibase_udf.c4
-rw-r--r--ext/interbase/php_interbase.h4
-rw-r--r--ext/interbase/tests/bug45373.phpt49
-rw-r--r--ext/interbase/tests/bug45575.phpt22
-rw-r--r--ext/interbase/tests/bug46247.phpt36
-rw-r--r--ext/interbase/tests/bug46543.phpt28
-rw-r--r--ext/interbase/tests/ibase_affected_rows_001.phpt32
-rw-r--r--ext/interbase/tests/ibase_close_001.phpt25
-rw-r--r--ext/interbase/tests/ibase_drop_db_001.phpt31
-rw-r--r--ext/interbase/tests/ibase_errmsg_001.phpt22
-rw-r--r--ext/interbase/tests/ibase_free_query_001.phpt28
-rw-r--r--ext/interbase/tests/ibase_num_fields_001.phpt25
-rw-r--r--ext/interbase/tests/ibase_num_params_001.phpt32
-rw-r--r--ext/interbase/tests/ibase_param_info_001.phpt55
-rw-r--r--ext/interbase/tests/ibase_rollback_001.phpt41
-rw-r--r--ext/interbase/tests/ibase_trans_001.phpt21
-rw-r--r--ext/interbase/tests/ibase_trans_002.phpt34
-rwxr-xr-xext/interbase/tests/interbase.inc5
24 files changed, 539 insertions, 41 deletions
diff --git a/ext/interbase/ibase_blobs.c b/ext/interbase/ibase_blobs.c
index ce994aed7..035fbd6ed 100644
--- a/ext/interbase/ibase_blobs.c
+++ b/ext/interbase/ibase_blobs.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ibase_blobs.c,v 1.9.2.1.2.4 2007/12/31 07:20:07 sebastian Exp $ */
+/* $Id: ibase_blobs.c,v 1.9.2.1.2.5 2008/12/31 11:17:38 sebastian Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
diff --git a/ext/interbase/ibase_events.c b/ext/interbase/ibase_events.c
index 6a9f13d50..f228e48d7 100644
--- a/ext/interbase/ibase_events.c
+++ b/ext/interbase/ibase_events.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ibase_events.c,v 1.8.2.1.2.2 2007/12/31 07:20:07 sebastian Exp $ */
+/* $Id: ibase_events.c,v 1.8.2.1.2.5 2008/12/31 11:17:38 sebastian Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -260,7 +260,7 @@ PHP_FUNCTION(ibase_set_event_handler)
* link resource id (int) as arguments. The value returned from the function is
* used to determine if the event handler should remain set.
*/
-
+ char *cb_name;
zval **args[17], **cb_arg;
ibase_db_link *ib_link;
ibase_event *event;
@@ -268,8 +268,8 @@ PHP_FUNCTION(ibase_set_event_handler)
int link_res_id;
RESET_ERRMSG;
-
- /* no more than 15 events */
+
+ /* Minimum and maximum number of arguments allowed */
if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > 17) {
WRONG_PARAM_COUNT;
}
@@ -280,6 +280,12 @@ PHP_FUNCTION(ibase_set_event_handler)
/* get a working link */
if (Z_TYPE_PP(args[0]) != IS_STRING) {
+ /* resource, callback, event_1 [, ... event_15]
+ * No more than 15 events
+ */
+ if (ZEND_NUM_ARGS() < 3 || ZEND_NUM_ARGS() > 17) {
+ WRONG_PARAM_COUNT;
+ }
cb_arg = args[1];
i = 2;
@@ -291,8 +297,10 @@ PHP_FUNCTION(ibase_set_event_handler)
link_res_id = Z_LVAL_PP(args[0]);
} else {
-
- if (ZEND_NUM_ARGS() > 16) {
+ /* callback, event_1 [, ... event_15]
+ * No more than 15 events
+ */
+ if (ZEND_NUM_ARGS() < 2 || ZEND_NUM_ARGS() > 16) {
WRONG_PARAM_COUNT;
}
@@ -304,11 +312,12 @@ PHP_FUNCTION(ibase_set_event_handler)
}
/* get the callback */
- if (!zend_is_callable(*cb_arg, 0, NULL)) {
- _php_ibase_module_error("Callback argument %s is not a callable function"
- TSRMLS_CC, Z_STRVAL_PP(cb_arg));
+ if (!zend_is_callable(*cb_arg, 0, &cb_name)) {
+ _php_ibase_module_error("Callback argument %s is not a callable function" TSRMLS_CC, cb_name);
+ efree(cb_name);
RETURN_FALSE;
}
+ efree(cb_name);
/* allocate the event resource */
event = (ibase_event *) safe_emalloc(sizeof(ibase_event), 1, 0);
diff --git a/ext/interbase/ibase_query.c b/ext/interbase/ibase_query.c
index b1062ef95..308c89285 100644
--- a/ext/interbase/ibase_query.c
+++ b/ext/interbase/ibase_query.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ibase_query.c,v 1.23.2.1.2.11 2007/12/31 07:20:07 sebastian Exp $ */
+/* $Id: ibase_query.c,v 1.23.2.1.2.13 2008/12/31 11:17:38 sebastian Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -1819,16 +1819,17 @@ PHP_FUNCTION(ibase_execute)
if (bind_n != expected_n) {
php_error_docref(NULL TSRMLS_CC, (bind_n < expected_n) ? E_WARNING : E_NOTICE,
"Statement expects %d arguments, %d given", expected_n, bind_n);
+
if (bind_n < expected_n) {
break;
}
-
- } else if (bind_n > 0) { /* have variables to bind */
- args = (zval ***) do_alloca(ZEND_NUM_ARGS() * sizeof(zval **));
+ }
+
+ /* have variables to bind */
+ args = (zval ***) do_alloca((expected_n + 1) * sizeof(zval **));
- if (FAILURE == zend_get_parameters_array_ex(ZEND_NUM_ARGS(), args)) {
- break;
- }
+ if (FAILURE == zend_get_parameters_array_ex((expected_n + 1), args)) {
+ break;
}
/* Have we used this cursor before and it's still open (exec proc has no cursor) ? */
diff --git a/ext/interbase/ibase_service.c b/ext/interbase/ibase_service.c
index d3d18c848..15ccb10a2 100644
--- a/ext/interbase/ibase_service.c
+++ b/ext/interbase/ibase_service.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ibase_service.c,v 1.11.2.2.2.6 2007/12/31 07:20:07 sebastian Exp $ */
+/* $Id: ibase_service.c,v 1.11.2.2.2.8 2008/12/31 11:17:38 sebastian Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -229,8 +229,7 @@ PHP_FUNCTION(ibase_service_attach)
user, isc_spb_password, (char)plen, pass, host);
if (spb_len > sizeof(buf) || spb_len == -1) {
- _php_ibase_module_error("Internal error: insufficient buffer space for SPB (%ld)"
- TSRMLS_CC, spb_len);
+ _php_ibase_module_error("Internal error: insufficient buffer space for SPB (%d)" TSRMLS_CC, spb_len);
RETURN_FALSE;
}
@@ -451,8 +450,7 @@ static void _php_ibase_backup_restore(INTERNAL_FUNCTION_PARAMETERS, char operati
}
if (spb_len > sizeof(buf) || spb_len <= 0) {
- _php_ibase_module_error("Internal error: insufficient buffer space for SPB (%ld)"
- TSRMLS_CC, spb_len);
+ _php_ibase_module_error("Internal error: insufficient buffer space for SPB (%d)" TSRMLS_CC, spb_len);
RETURN_FALSE;
}
@@ -560,8 +558,7 @@ options_argument:
}
if (spb_len > sizeof(buf) || spb_len == -1) {
- _php_ibase_module_error("Internal error: insufficient buffer space for SPB (%ld)"
- TSRMLS_CC, spb_len);
+ _php_ibase_module_error("Internal error: insufficient buffer space for SPB (%d)" TSRMLS_CC, spb_len);
RETURN_FALSE;
}
diff --git a/ext/interbase/interbase.c b/ext/interbase/interbase.c
index 47d0d3e9a..5517f1c64 100644
--- a/ext/interbase/interbase.c
+++ b/ext/interbase/interbase.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: interbase.c,v 1.225.2.4.2.8 2007/12/31 07:20:07 sebastian Exp $ */
+/* $Id: interbase.c,v 1.225.2.4.2.10 2008/12/31 11:17:38 sebastian Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -894,8 +894,13 @@ PHP_FUNCTION(ibase_trans)
if (Z_TYPE_PP(args[i]) == IS_RESOURCE) {
- ZEND_FETCH_RESOURCE2(ib_link[link_cnt], ibase_db_link *, args[i], -1,
- LE_LINK, le_link, le_plink);
+ if (!ZEND_FETCH_RESOURCE2_NO_RETURN(ib_link[link_cnt], ibase_db_link *, args[i], -1, LE_LINK, le_link, le_plink)) {
+ efree(teb);
+ efree(tpb);
+ efree(ib_link);
+ efree(args);
+ RETURN_FALSE;
+ }
/* copy the most recent modifier string into tbp[] */
memcpy(&tpb[TPB_MAX_SIZE * link_cnt], last_tpb, TPB_MAX_SIZE);
@@ -959,8 +964,10 @@ PHP_FUNCTION(ibase_trans)
if (link_cnt == 0) {
link_cnt = 1;
- ZEND_FETCH_RESOURCE2(ib_link[0], ibase_db_link *, NULL, IBG(default_link), LE_LINK,
- le_link, le_plink);
+ if (!ZEND_FETCH_RESOURCE2_NO_RETURN(ib_link[0], ibase_db_link *, NULL, IBG(default_link), LE_LINK, le_link, le_plink)) {
+ efree(ib_link);
+ RETURN_FALSE;
+ }
result = isc_start_transaction(IB_STATUS, &tr_handle, 1, &ib_link[0]->handle, tpb_len, last_tpb);
}
diff --git a/ext/interbase/php_ibase_includes.h b/ext/interbase/php_ibase_includes.h
index 57195e132..35889c094 100755
--- a/ext/interbase/php_ibase_includes.h
+++ b/ext/interbase/php_ibase_includes.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_ibase_includes.h,v 1.16.2.1.2.3 2008/01/23 01:22:57 iliaa Exp $ */
+/* $Id: php_ibase_includes.h,v 1.16.2.1.2.4 2008/12/31 11:17:38 sebastian Exp $ */
#ifndef PHP_IBASE_INCLUDES_H
#define PHP_IBASE_INCLUDES_H
diff --git a/ext/interbase/php_ibase_udf.c b/ext/interbase/php_ibase_udf.c
index 4237222e5..b1d8104c9 100644
--- a/ext/interbase/php_ibase_udf.c
+++ b/ext/interbase/php_ibase_udf.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_ibase_udf.c,v 1.9.2.1.2.3 2007/12/31 07:20:07 sebastian Exp $ */
+/* $Id: php_ibase_udf.c,v 1.9.2.1.2.4 2008/12/31 11:17:38 sebastian Exp $ */
/**
* This UDF library adds the ability to call PHP functions from SQL
diff --git a/ext/interbase/php_interbase.h b/ext/interbase/php_interbase.h
index 7437abff1..2307d3ccf 100644
--- a/ext/interbase/php_interbase.h
+++ b/ext/interbase/php_interbase.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2008 The PHP Group |
+ | Copyright (c) 1997-2009 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_interbase.h,v 1.71.2.1.2.2 2007/12/31 07:20:07 sebastian Exp $ */
+/* $Id: php_interbase.h,v 1.71.2.1.2.3 2008/12/31 11:17:38 sebastian Exp $ */
#ifndef PHP_INTERBASE_H
#define PHP_INTERBASE_H
diff --git a/ext/interbase/tests/bug45373.phpt b/ext/interbase/tests/bug45373.phpt
new file mode 100644
index 000000000..8ec71df15
--- /dev/null
+++ b/ext/interbase/tests/bug45373.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Bug #45373 (php crash on query with errors in params)
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+ require("interbase.inc");
+
+ $db = ibase_connect($test_base);
+
+
+ $sql = "select * from test1 where i = ? and c = ?";
+
+ $q = ibase_prepare($db, $sql);
+ $r = ibase_execute($q, 1, 'test table not created with isql');
+ var_dump(ibase_fetch_assoc($r));
+ ibase_free_result($r);
+
+ $r = ibase_execute($q, 1, 'test table not created with isql', 1);
+ var_dump(ibase_fetch_assoc($r));
+ ibase_free_result($r);
+
+ $r = ibase_execute($q, 1);
+ var_dump(ibase_fetch_assoc($r));
+
+?>
+--EXPECTF--
+array(2) {
+ ["I"]=>
+ int(1)
+ ["C"]=>
+ string(32) "test table not created with isql"
+}
+
+Notice: ibase_execute(): Statement expects 2 arguments, 3 given in %sbug45373.php on line %d
+array(2) {
+ ["I"]=>
+ int(1)
+ ["C"]=>
+ string(32) "test table not created with isql"
+}
+
+Warning: ibase_execute(): Statement expects 2 arguments, 1 given in %sbug45373.php on line %d
+
+Warning: ibase_fetch_assoc(): supplied argument is not a valid Firebird/InterBase result resource in %sbug45373.php on line %d
+bool(false)
+
+Warning: Unknown: invalid statement handle in Unknown on line 0
diff --git a/ext/interbase/tests/bug45575.phpt b/ext/interbase/tests/bug45575.phpt
new file mode 100644
index 000000000..ca0fa831e
--- /dev/null
+++ b/ext/interbase/tests/bug45575.phpt
@@ -0,0 +1,22 @@
+--TEST--
+Bug #45575 (Segfault with invalid non-string as event handler callback)
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$db = ibase_connect($test_base);
+
+function foobar($var) { var_dump($var); return true; }
+
+ibase_set_event_handler($db, null, 'TEST1');
+ibase_set_event_handler($db, 1, 'TEST1');
+ibase_set_event_handler('foobar', 'TEST1');
+
+?>
+--EXPECTF--
+Warning: ibase_set_event_handler(): Callback argument is not a callable function in %s on line %d
+
+Warning: ibase_set_event_handler(): Callback argument 1 is not a callable function in %s on line %d
diff --git a/ext/interbase/tests/bug46247.phpt b/ext/interbase/tests/bug46247.phpt
new file mode 100644
index 000000000..ffd153b5f
--- /dev/null
+++ b/ext/interbase/tests/bug46247.phpt
@@ -0,0 +1,36 @@
+--TEST--
+Bug #46247 (ibase_set_event_handler() is allowing to pass callback without event)
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$db = ibase_connect($test_base);
+
+function test() { }
+
+ibase_set_event_handler();
+
+ibase_set_event_handler('test', 1);
+ibase_set_event_handler($db, 'test', 1);
+ibase_set_event_handler(NULL, 'test', 1);
+
+
+ibase_set_event_handler('foo', 1);
+ibase_set_event_handler($db, 'foo', 1);
+ibase_set_event_handler(NULL, 'foo', 1);
+
+?>
+--EXPECTF--
+
+Warning: Wrong parameter count for ibase_set_event_handler() in %s on line %d
+
+Warning: ibase_set_event_handler(): supplied argument is not a valid InterBase link resource in %s on line %d
+
+Warning: ibase_set_event_handler(): Callback argument foo is not a callable function in %s on line %d
+
+Warning: ibase_set_event_handler(): Callback argument foo is not a callable function in %s on line %d
+
+Warning: ibase_set_event_handler(): supplied argument is not a valid InterBase link resource in %s on line %d
diff --git a/ext/interbase/tests/bug46543.phpt b/ext/interbase/tests/bug46543.phpt
new file mode 100644
index 000000000..59e088c3d
--- /dev/null
+++ b/ext/interbase/tests/bug46543.phpt
@@ -0,0 +1,28 @@
+--TEST--
+Bug #46543 (ibase_trans() memory leaks when using wrong parameters)
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+@ibase_close();
+
+ibase_trans(1);
+ibase_trans();
+ibase_trans('foo');
+ibase_trans(fopen(__FILE__, 'r'));
+
+$x = ibase_connect($test_base);
+ibase_trans(1, 2, $x, $x, 3);
+
+?>
+--EXPECTF--
+Warning: ibase_trans(): no Firebird/InterBase link resource supplied in %s on line %d
+
+Warning: ibase_trans(): no Firebird/InterBase link resource supplied in %s on line %d
+
+Warning: ibase_trans(): no Firebird/InterBase link resource supplied in %s on line %d
+
+Warning: ibase_trans(): supplied resource is not a valid Firebird/InterBase link resource in %s on line %d
diff --git a/ext/interbase/tests/ibase_affected_rows_001.phpt b/ext/interbase/tests/ibase_affected_rows_001.phpt
new file mode 100644
index 000000000..398a84c8b
--- /dev/null
+++ b/ext/interbase/tests/ibase_affected_rows_001.phpt
@@ -0,0 +1,32 @@
+--TEST--
+ibase_affected_rows(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+ibase_query($x, 'INSERT INTO test1 VALUES (1, 100)');
+ibase_query($x, 'INSERT INTO test1 VALUES (10000, 100)');
+
+ibase_query($x, 'UPDATE test1 SET i = 10000');
+var_dump(ibase_affected_rows($x));
+
+
+ibase_query($x, 'UPDATE test1 SET i = 10000 WHERE i = 2.0');
+var_dump(ibase_affected_rows($x));
+
+ibase_query($x, 'UPDATE test1 SET i =');
+var_dump(ibase_affected_rows($x));
+
+
+?>
+--EXPECTF--
+int(3)
+int(0)
+
+Warning: ibase_query(): Dynamic SQL Error SQL error code = -104 %s on line %d
+int(0)
diff --git a/ext/interbase/tests/ibase_close_001.phpt b/ext/interbase/tests/ibase_close_001.phpt
new file mode 100644
index 000000000..25412d484
--- /dev/null
+++ b/ext/interbase/tests/ibase_close_001.phpt
@@ -0,0 +1,25 @@
+--TEST--
+ibase_close(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+var_dump(ibase_close($x));
+var_dump(ibase_close($x));
+var_dump(ibase_close());
+var_dump(ibase_close('foo'));
+
+?>
+--EXPECTF--
+bool(true)
+bool(true)
+
+Warning: ibase_close(): %d is not a valid Firebird/InterBase link resource in %s on line %d
+bool(false)
+
+Warning: ibase_close(): %d is not a valid Firebird/InterBase link resource in %s on line %d
+bool(false)
diff --git a/ext/interbase/tests/ibase_drop_db_001.phpt b/ext/interbase/tests/ibase_drop_db_001.phpt
new file mode 100644
index 000000000..b5cabced5
--- /dev/null
+++ b/ext/interbase/tests/ibase_drop_db_001.phpt
@@ -0,0 +1,31 @@
+--TEST--
+ibase_drop_db(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+unlink($file = tempnam('/tmp',"php_ibase_test"));
+
+
+$db = ibase_query(IBASE_CREATE,
+ sprintf("CREATE SCHEMA '%s' USER '%s' PASSWORD '%s' DEFAULT CHARACTER SET %s",$file,
+ $user, $password, ($charset = ini_get('ibase.default_charset')) ? $charset : 'NONE'));
+
+var_dump($db);
+var_dump(ibase_drop_db($db));
+var_dump(ibase_drop_db(1));
+var_dump(ibase_drop_db(NULL));
+
+?>
+--EXPECTF--
+resource(%d) of type (Firebird/InterBase link)
+bool(true)
+
+Warning: ibase_drop_db(): supplied resource is not a valid Firebird/InterBase link resource in %s on line %d
+bool(false)
+
+Warning: ibase_drop_db(): %d is not a valid Firebird/InterBase link resource in %s on line %d
+bool(false)
diff --git a/ext/interbase/tests/ibase_errmsg_001.phpt b/ext/interbase/tests/ibase_errmsg_001.phpt
new file mode 100644
index 000000000..ad0e827f9
--- /dev/null
+++ b/ext/interbase/tests/ibase_errmsg_001.phpt
@@ -0,0 +1,22 @@
+--TEST--
+ibase_errmsg(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+ibase_query('SELECT Foobar');
+var_dump(ibase_errmsg());
+
+ibase_close($x);
+var_dump(ibase_errmsg());
+
+?>
+--EXPECTF--
+Warning: ibase_query(): Dynamic SQL Error SQL error code = -104 %s on line %d
+string(%d) "Dynamic SQL Error SQL error code = -104 %s"
+bool(false)
diff --git a/ext/interbase/tests/ibase_free_query_001.phpt b/ext/interbase/tests/ibase_free_query_001.phpt
new file mode 100644
index 000000000..bedec7173
--- /dev/null
+++ b/ext/interbase/tests/ibase_free_query_001.phpt
@@ -0,0 +1,28 @@
+--TEST--
+ibase_free_query(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+$q =ibase_prepare($x, 'SELECT 1 FROM test1 WHERE i = ?');
+$q =ibase_prepare($x, 'SELECT 1 FROM test1 WHERE i = ?');
+$q = ibase_prepare($x, 'SELECT 1 FROM test1 WHERE i = ?');
+
+var_dump(ibase_free_query($q));
+var_dump(ibase_free_query($q));
+var_dump(ibase_free_query($x));
+
+?>
+--EXPECTF--
+bool(true)
+
+Warning: ibase_free_query(): 11 is not a valid Firebird/InterBase query resource in %s on line %d
+bool(false)
+
+Warning: ibase_free_query(): supplied resource is not a valid Firebird/InterBase query resource in %s on line %d
+bool(false)
diff --git a/ext/interbase/tests/ibase_num_fields_001.phpt b/ext/interbase/tests/ibase_num_fields_001.phpt
new file mode 100644
index 000000000..510b0f6f5
--- /dev/null
+++ b/ext/interbase/tests/ibase_num_fields_001.phpt
@@ -0,0 +1,25 @@
+--TEST--
+ibase_num_fields(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+var_dump(ibase_num_fields(ibase_query('SELECT * FROM test1')));
+
+var_dump(ibase_num_fields(1));
+var_dump(ibase_num_fields());
+
+?>
+--EXPECTF--
+int(2)
+
+Warning: ibase_num_fields(): supplied argument is not a valid Firebird/InterBase result resource in %s on line %d
+bool(false)
+
+Warning: Wrong parameter count for ibase_num_fields() in %s on line %d
+NULL
diff --git a/ext/interbase/tests/ibase_num_params_001.phpt b/ext/interbase/tests/ibase_num_params_001.phpt
new file mode 100644
index 000000000..2cacc50f3
--- /dev/null
+++ b/ext/interbase/tests/ibase_num_params_001.phpt
@@ -0,0 +1,32 @@
+--TEST--
+ibase_num_params(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+$rs = ibase_prepare('SELECT * FROM test1 WHERE 1 = ? AND 2 = ?');
+var_dump(ibase_num_params($rs));
+
+$rs = ibase_prepare('SELECT * FROM test1 WHERE 1 = ? AND 2 = ?');
+var_dump(ibase_num_params());
+
+$rs = ibase_prepare('SELECT * FROM test1 WHERE 1 = ? AND 2 = ? AND 3 = :x');
+var_dump(ibase_num_params($rs));
+
+
+?>
+--EXPECTF--
+int(2)
+
+Warning: Wrong parameter count for ibase_num_params() in %s on line %d
+NULL
+
+Warning: ibase_prepare(): Dynamic SQL Error SQL error code = -206 %s in %s on line %d
+
+Warning: ibase_num_params(): supplied argument is not a valid Firebird/InterBase query resource in %s on line %d
+bool(false)
diff --git a/ext/interbase/tests/ibase_param_info_001.phpt b/ext/interbase/tests/ibase_param_info_001.phpt
new file mode 100644
index 000000000..3dd92ba7a
--- /dev/null
+++ b/ext/interbase/tests/ibase_param_info_001.phpt
@@ -0,0 +1,55 @@
+--TEST--
+ibase_param_info(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+$rs = ibase_prepare('SELECT * FROM test1 WHERE 1 = ? AND 2 = ?');
+var_dump(ibase_param_info($rs, 1));
+
+print "---\n";
+
+var_dump(ibase_param_info($rs, 100));
+
+print "---\n";
+
+var_dump(ibase_param_info(100));
+
+
+?>
+--EXPECTF--
+array(10) {
+ [0]=>
+ string(0) ""
+ ["name"]=>
+ string(0) ""
+ [1]=>
+ string(0) ""
+ ["alias"]=>
+ string(0) ""
+ [2]=>
+ string(0) ""
+ ["relation"]=>
+ string(0) ""
+ [3]=>
+ string(1) "4"
+ ["length"]=>
+ string(1) "4"
+ [4]=>
+ string(7) "INTEGER"
+ ["type"]=>
+ string(7) "INTEGER"
+}
+---
+bool(false)
+---
+
+Warning: Wrong parameter count for ibase_param_info() in %s on line %d
+NULL
+
+Warning: Unknown: invalid statement handle in Unknown on line 0
diff --git a/ext/interbase/tests/ibase_rollback_001.phpt b/ext/interbase/tests/ibase_rollback_001.phpt
new file mode 100644
index 000000000..3cde5e9d4
--- /dev/null
+++ b/ext/interbase/tests/ibase_rollback_001.phpt
@@ -0,0 +1,41 @@
+--TEST--
+ibase_rollback(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+ibase_query('INSERT INTO test1 VALUES (100, 2)');
+ibase_query('INSERT INTO test1 VALUES (100, 2)');
+ibase_query('INSERT INTO test1 VALUES (100, 2)');
+
+$rs = ibase_query('SELECT COUNT(*) FROM test1 WHERE i = 100');
+var_dump(ibase_fetch_row($rs));
+
+var_dump(ibase_rollback($x));
+
+$rs = ibase_query('SELECT COUNT(*) FROM test1 WHERE i = 100');
+var_dump(ibase_fetch_row($rs));
+
+var_dump(ibase_rollback($x));
+var_dump(ibase_rollback());
+
+?>
+--EXPECTF--
+array(1) {
+ [0]=>
+ int(3)
+}
+bool(true)
+array(1) {
+ [0]=>
+ int(0)
+}
+bool(true)
+
+Warning: ibase_rollback(): invalid transaction handle (expecting explicit transaction start) in %s on line %d
+bool(false)
diff --git a/ext/interbase/tests/ibase_trans_001.phpt b/ext/interbase/tests/ibase_trans_001.phpt
new file mode 100644
index 000000000..cceb60e9a
--- /dev/null
+++ b/ext/interbase/tests/ibase_trans_001.phpt
@@ -0,0 +1,21 @@
+--TEST--
+ibase_trans(): Basic test
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+var_dump(ibase_trans($x));
+var_dump(ibase_trans(1));
+var_dump(ibase_close());
+var_dump(ibase_close($x));
+
+?>
+--EXPECTF--
+resource(%d) of type (Firebird/InterBase transaction)
+resource(%d) of type (Firebird/InterBase transaction)
+bool(true)
+bool(true)
diff --git a/ext/interbase/tests/ibase_trans_002.phpt b/ext/interbase/tests/ibase_trans_002.phpt
new file mode 100644
index 000000000..be7c073ca
--- /dev/null
+++ b/ext/interbase/tests/ibase_trans_002.phpt
@@ -0,0 +1,34 @@
+--TEST--
+ibase_trans(): Basic operations
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+require("interbase.inc");
+
+$x = ibase_connect($test_base);
+
+$trans = ibase_trans(IBASE_DEFAULT, $x);
+$sth = ibase_prepare($trans, 'INSERT INTO test1 VALUES (?, ?)');
+
+$res = ibase_execute($sth, 100, 100);
+var_dump($res);
+
+ibase_commit($trans);
+
+$rs = ibase_query($x, 'SELECT * FROM test1 WHERE i = 100');
+var_dump(ibase_fetch_assoc($rs));
+
+ibase_free_query($sth);
+unset($res);
+
+?>
+--EXPECT--
+int(1)
+array(2) {
+ ["I"]=>
+ int(100)
+ ["C"]=>
+ string(3) "100"
+}
diff --git a/ext/interbase/tests/interbase.inc b/ext/interbase/tests/interbase.inc
index eea3bebe7..3254ace95 100755
--- a/ext/interbase/tests/interbase.inc
+++ b/ext/interbase/tests/interbase.inc
@@ -1,4 +1,4 @@
-<?php /* $Id: interbase.inc,v 1.10 2004/06/01 08:38:33 abies Exp $ */
+<?php /* $Id: interbase.inc,v 1.10.6.1 2008/10/07 12:53:08 felipe Exp $ */
srand((double)microtime()*1000000);
@@ -104,6 +104,9 @@ function rand_number($len , $prec = -1, $sign = 1)
}
} else if ($prec == 0) {
$n = substr(rand() . rand(), 0, rand() % $len + 1);
+ } else if (($prec - $len) == 0) {
+ $n = substr(rand() . rand(), 0, 1);
+ $n .= "." . substr(rand(), 0, $prec);
} else {
$n = substr(rand() . rand(), 0, rand() % ($len - $prec) + 1);
$n .= "." . substr(rand(), 0, $prec);