summaryrefslogtreecommitdiff
path: root/ext/sybase_ct
diff options
context:
space:
mode:
authorSean Finney <seanius@debian.org>2009-04-10 14:09:48 +0200
committerSean Finney <seanius@debian.org>2009-04-10 14:09:48 +0200
commitcd0b49c72aee33b3e44a9c589fcd93b9e1c7a64f (patch)
tree1315c623bb7d9dfa8d366fa9cd2c6834ceeb5da5 /ext/sybase_ct
parent9ea47aab740772adf0c69d8c94b208a464e599ea (diff)
downloadphp-cd0b49c72aee33b3e44a9c589fcd93b9e1c7a64f.tar.gz
Imported Upstream version 5.2.9.dfsg.1upstream/5.2.9.dfsg.1
Diffstat (limited to 'ext/sybase_ct')
-rw-r--r--ext/sybase_ct/php_sybase_ct.c47
-rw-r--r--ext/sybase_ct/php_sybase_ct.h4
-rw-r--r--ext/sybase_ct/tests/bug29064.phpt10
-rw-r--r--ext/sybase_ct/tests/bug30312.phpt10
-rw-r--r--ext/sybase_ct/tests/skipif.inc7
-rw-r--r--ext/sybase_ct/tests/test.inc8
-rw-r--r--ext/sybase_ct/tests/test_appname.phpt12
-rw-r--r--ext/sybase_ct/tests/test_unbuffered_no_full_fetch.phpt37
8 files changed, 83 insertions, 52 deletions
diff --git a/ext/sybase_ct/php_sybase_ct.c b/ext/sybase_ct/php_sybase_ct.c
index 820170db7..645b6f44d 100644
--- a/ext/sybase_ct/php_sybase_ct.c
+++ b/ext/sybase_ct/php_sybase_ct.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: php_sybase_ct.c,v 1.103.2.5.2.14 2007/12/31 07:20:13 sebastian Exp $ */
+/* $Id: php_sybase_ct.c,v 1.103.2.5.2.17 2008/12/31 11:17:46 sebastian Exp $ */
#ifdef HAVE_CONFIG_H
@@ -138,6 +138,21 @@ static int _clean_invalid_results(zend_rsrc_list_entry *le TSRMLS_DC)
#define efree_n(x) { efree(x); x = NULL; }
#define efree_if(x) if (x) efree_n(x)
+#ifdef PHP_SYBASE_DEBUG
+#define FREE_SYBASE_RESULT(result) \
+ if (result) { \
+ fprintf(stderr, "_free_sybase_result(%p) called from line #%d\n", result, __LINE__); \
+ fflush(stderr); \
+ _free_sybase_result(result); \
+ result = NULL; \
+ }
+#else
+#define FREE_SYBASE_RESULT(result) \
+ if (result) { \
+ _free_sybase_result(result); \
+ result = NULL; \
+ }
+#endif
static void _free_sybase_result(sybase_result *result)
{
int i, j;
@@ -191,7 +206,7 @@ static void php_free_sybase_result(zend_rsrc_list_entry *rsrc TSRMLS_DC)
php_sybase_finish_results(result TSRMLS_CC);
}
- _free_sybase_result(result);
+ FREE_SYBASE_RESULT(result);
}
static void _close_sybase_link(zend_rsrc_list_entry *rsrc TSRMLS_DC)
@@ -1109,8 +1124,6 @@ static int php_sybase_finish_results(sybase_result *result TSRMLS_DC)
case CS_CANCELED:
default:
- _free_sybase_result(result);
- result = NULL;
retcode = CS_FAIL;
break;
}
@@ -1143,7 +1156,7 @@ static int php_sybase_fetch_result_row (sybase_result *result, int numrows)
}
if (numrows!=-1) numrows+= result->num_rows;
- while ((retcode=ct_fetch(result->sybase_ptr->cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, NULL))==CS_SUCCEED) {
+ while ((retcode=ct_fetch(result->sybase_ptr->cmd, CS_UNUSED, CS_UNUSED, CS_UNUSED, NULL))==CS_SUCCEED || retcode == CS_ROW_FAIL) {
result->num_rows++;
i= result->store ? result->num_rows- 1 : 0;
if (i >= result->blocks_initialized*SYBASE_ROWS_BLOCK) {
@@ -1216,7 +1229,7 @@ static int php_sybase_fetch_result_row (sybase_result *result, int numrows)
break;
default:
- _free_sybase_result(result);
+ FREE_SYBASE_RESULT(result);
result = NULL;
retcode = CS_FAIL; /* Just to be sure */
break;
@@ -1425,17 +1438,9 @@ static void php_sybase_query (INTERNAL_FUNCTION_PARAMETERS, int buffered)
INIT_PZVAL(tmp);
ZEND_FETCH_RESOURCE(result, sybase_result *, &tmp, -1, "Sybase result", le_result);
- /* Causes the following segfault:
- Program received signal SIGSEGV, Segmentation fault.
- 0x8144380 in _efree (ptr=0x81fe024, __zend_filename=0x81841a0 "php4/ext/sybase_ct/php_sybase_ct.c",
- __zend_lineno=946, __zend_orig_filename=0x0, __zend_orig_lineno=0) at php4/Zend/zend_alloc.c:229
- php4/Zend/zend_alloc.c:229:7284:beg:0x8144380
- */
- #if O_TIMM
if (result) {
php_sybase_finish_results(result TSRMLS_CC);
}
- #endif
zval_ptr_dtor(&tmp);
zend_list_delete(sybase_ptr->active_result_index);
@@ -1590,9 +1595,7 @@ static void php_sybase_query (INTERNAL_FUNCTION_PARAMETERS, int buffered)
/* Retry deadlocks up until deadlock_retry_count times */
if (sybase_ptr->deadlock && SybCtG(deadlock_retry_count) != -1 && ++deadlock_count > SybCtG(deadlock_retry_count)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Sybase: Retried deadlock %d times [max: %ld], giving up", deadlock_count- 1, SybCtG(deadlock_retry_count));
- if (result != NULL) {
- _free_sybase_result(result);
- }
+ FREE_SYBASE_RESULT(result);
break;
}
@@ -1611,9 +1614,7 @@ static void php_sybase_query (INTERNAL_FUNCTION_PARAMETERS, int buffered)
* optimization, we could try not to fetch results in known
* deadlock conditions, but deadlock is (should be) rare.
*/
- if (result != NULL) {
- _free_sybase_result(result);
- }
+ FREE_SYBASE_RESULT(result);
}
if (status == Q_SUCCESS) {
@@ -1621,9 +1622,7 @@ static void php_sybase_query (INTERNAL_FUNCTION_PARAMETERS, int buffered)
}
if (status == Q_FAILURE) {
- if (result != NULL) {
- _free_sybase_result(result);
- }
+ FREE_SYBASE_RESULT(result);
RETURN_FALSE;
}
diff --git a/ext/sybase_ct/php_sybase_ct.h b/ext/sybase_ct/php_sybase_ct.h
index 8260ce5fc..3fe22a132 100644
--- a/ext/sybase_ct/php_sybase_ct.h
+++ b/ext/sybase_ct/php_sybase_ct.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 |
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_sybase_ct.h,v 1.19.2.2.2.2 2007/12/31 07:20:13 sebastian Exp $ */
+/* $Id: php_sybase_ct.h,v 1.19.2.2.2.3 2008/12/31 11:17:46 sebastian Exp $ */
#ifndef PHP_SYBASE_CT_H
#define PHP_SYBASE_CT_H
diff --git a/ext/sybase_ct/tests/bug29064.phpt b/ext/sybase_ct/tests/bug29064.phpt
index 97596fff2..a96d88288 100644
--- a/ext/sybase_ct/tests/bug29064.phpt
+++ b/ext/sybase_ct/tests/bug29064.phpt
@@ -6,7 +6,7 @@ Sybase-CT bug #29064 (Exact numeric/decimal/money datatypes lose precision)
<?php
/* This file is part of PHP test framework for ext/sybase_ct
*
- * $Id: bug29064.phpt,v 1.1 2004/07/11 16:57:24 thekid Exp $
+ * $Id: bug29064.phpt,v 1.1.6.1 2008/11/08 14:24:55 thekid Exp $
*/
require('test.inc');
@@ -112,9 +112,9 @@ array(2) {
["test_tinyint"]=>
int(123)
["test_real"]=>
- string(16) "123456789.123457"
+ string(18) "123456789.12345679"
["test_double"]=>
- string(16) "123456789.123457"
+ string(18) "123456789.12345679"
}
[1]=>
array(10) {
@@ -135,9 +135,9 @@ array(2) {
["test_tinyint"]=>
int(255)
["test_real"]=>
- string(17) "-123456789.123457"
+ string(19) "-123456789.12345679"
["test_double"]=>
- string(17) "-123456789.123457"
+ string(19) "-123456789.12345679"
}
}
bool(true)
diff --git a/ext/sybase_ct/tests/bug30312.phpt b/ext/sybase_ct/tests/bug30312.phpt
index c71a39e86..19dda3dbe 100644
--- a/ext/sybase_ct/tests/bug30312.phpt
+++ b/ext/sybase_ct/tests/bug30312.phpt
@@ -6,7 +6,7 @@ Sybase-CT bug #30312 (sybase_unbuffered_query calls)
<?php
/* This file is part of PHP test framework for ext/sybase_ct
*
- * $Id: bug30312.phpt,v 1.1.4.1 2007/03/14 11:46:06 thekid Exp $
+ * $Id: bug30312.phpt,v 1.1.4.2 2008/11/08 14:24:38 thekid Exp $
*/
require('test.inc');
@@ -14,14 +14,14 @@ Sybase-CT bug #30312 (sybase_unbuffered_query calls)
$db= sybase_connect_ex();
- $query= sybase_unbuffered_query('select getdate()');
+ $query= sybase_unbuffered_query('select datepart(yy, getdate())');
$array= sybase_fetch_array($query);
var_dump($array[0]);
- $query= sybase_unbuffered_query('select getdate()');
+ $query= sybase_unbuffered_query('select datepart(yy, getdate())');
$array= sybase_fetch_array($query);
var_dump($array[0]);
?>
--EXPECTF--
-string(%d) "%s %d %d %d:%d%s"
-string(%d) "%s %d %d %d:%d%s"
+int(%d)
+int(%d)
diff --git a/ext/sybase_ct/tests/skipif.inc b/ext/sybase_ct/tests/skipif.inc
index ac5fa2fe5..a2fb163f9 100644
--- a/ext/sybase_ct/tests/skipif.inc
+++ b/ext/sybase_ct/tests/skipif.inc
@@ -1,8 +1,13 @@
<?php
/* This file is part of PHP test framework for ext/sybase_ct
*
- * $Id: skipif.inc,v 1.2 2004/11/22 15:15:50 dmitry Exp $
+ * $Id: skipif.inc,v 1.2.4.1 2008/11/08 15:39:32 felipe Exp $
*/
+ require 'test.inc';
+
if (!extension_loaded('sybase_ct')) die('skip Sybase-CT extension not loaded');
+
+ sybase_min_server_severity(11);
+ if (!@sybase_connect(HOST, USER, PASSWORD)) die('skip Unable to connect');
?>
diff --git a/ext/sybase_ct/tests/test.inc b/ext/sybase_ct/tests/test.inc
index f5e4465a6..ca99b5e8b 100644
--- a/ext/sybase_ct/tests/test.inc
+++ b/ext/sybase_ct/tests/test.inc
@@ -1,13 +1,13 @@
<?php
/* This file is part of PHP test framework for ext/sybase_ct
*
- * $Id: test.inc,v 1.4.6.3 2007/05/22 11:36:55 thekid Exp $
+ * $Id: test.inc,v 1.4.6.4 2008/11/08 11:59:57 thekid Exp $
*/
// Change if needed
- define('HOST', '****');
- define('USER', '****');
- define('PASSWORD', '****');
+ define('HOST', getenv('PHP_SYBASE_HOST'));
+ define('USER', getenv('PHP_SYBASE_USER'));
+ define('PASSWORD', getenv('PHP_SYBASE_PASS'));
define('TEMPDB', 'tempdb');
// {{{ bool sybase_msg_handler(int msgnumber, int severity, int state, int line, string text)
diff --git a/ext/sybase_ct/tests/test_appname.phpt b/ext/sybase_ct/tests/test_appname.phpt
index d409ae222..1f1c6b9b0 100644
--- a/ext/sybase_ct/tests/test_appname.phpt
+++ b/ext/sybase_ct/tests/test_appname.phpt
@@ -6,7 +6,7 @@ Sybase-CT application name
<?php
/* This file is part of PHP test framework for ext/sybase_ct
*
- * $Id: test_appname.phpt,v 1.2 2005/02/06 12:59:03 thekid Exp $
+ * $Id: test_appname.phpt,v 1.2.4.1 2008/11/08 12:01:10 thekid Exp $
*/
require('test.inc');
@@ -35,7 +35,6 @@ Sybase-CT application name
);
var_dump(
- $r,
compare_string($program_name, $r[0]['program_name']),
compare_string($hostname, $r[0]['hostname'])
);
@@ -52,14 +51,5 @@ Sybase-CT application name
where
program_name = "phpt_test"
<<< Return: resource
-array(1) {
- [0]=>
- array(2) {
- ["hostname"]=>
- string(10) "php.net%s"
- ["program_name"]=>
- string(16) "phpt_test%s"
- }
-}
bool(true)
bool(true)
diff --git a/ext/sybase_ct/tests/test_unbuffered_no_full_fetch.phpt b/ext/sybase_ct/tests/test_unbuffered_no_full_fetch.phpt
new file mode 100644
index 000000000..c38bbf822
--- /dev/null
+++ b/ext/sybase_ct/tests/test_unbuffered_no_full_fetch.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Sybase-CT unbuffered query without full fetching
+--SKIPIF--
+<?php require('skipif.inc'); ?>
+--FILE--
+<?php
+/* This file is part of PHP test framework for ext/sybase_ct
+ *
+ * $Id: test_unbuffered_no_full_fetch.phpt,v 1.1.4.2 2008/11/08 14:28:26 thekid Exp $
+ */
+
+ require('test.inc');
+
+ $db= sybase_connect_ex();
+ var_dump($db);
+
+ // Fetch #1
+ $q= sybase_unbuffered_query('select name from master..systypes', $db);
+ var_dump($q, key(sybase_fetch_assoc($q)));
+
+ // Fetch #2 - without having fetched all rows from previous query
+ $q= sybase_unbuffered_query('select name from master..systypes', $db);
+ var_dump($q, key(sybase_fetch_assoc($q)));
+
+ // Close - without having fetched all rows from previous query
+ sybase_close($db);
+ echo 'CLOSED';
+?>
+--EXPECTF--
+resource(%d) of type (sybase-ct link)
+resource(%d) of type (sybase-ct result)
+string(4) "name"
+
+Notice: sybase_unbuffered_query(): called without first fetching all rows from a previous unbuffered query in %s on line %d
+resource(%d) of type (sybase-ct result)
+string(4) "name"
+CLOSED