svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps_codec.c trunk/ext/mysqlnd/mysqlnd_ps_codec.c
| From: | Andrey Hristov | Date: | Wed, 22 Sep 2010 14:26:43 +0000 |
| Subject: | svn: /php/php-src/ branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps_codec.c trunk/ext/mysqlnd/mysqlnd_ps_codec.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-63542@lists.php.net to get a copy of this message | ||
andrey Wed, 22 Sep 2010 14:26:43 +0000
Revision: http://svn.php.net/viewvc?view=revision&revision=303675
Log:
fix for bug 52891 - optimize a bit
Bug: http://bugs.php.net/52891 (Closed) Wrong data inserted
with mysqli/mysqlnd when using bind_param,value>LONG_MAX
Changed paths:
U php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps_codec.c
U php/php-src/trunk/ext/mysqlnd/mysqlnd_ps_codec.c
Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps_codec.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps_codec.c 2010-09-22 14:07:40 UTC (rev 303674)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_ps_codec.c 2010-09-22 14:26:43 UTC (rev 303675)
@@ -626,7 +626,9 @@
(stmt->param_bind[i].type == MYSQL_TYPE_LONG || stmt->param_bind[i].type ==
MYSQL_TYPE_LONGLONG))
{
/* always copy the var, because we do many conversions */
- if (PASS != mysqlnd_stmt_copy_it(&copies, stmt->param_bind[i].zv, stmt->param_count, i
TSRMLS_CC)) {
+ if (Z_TYPE_P(stmt->param_bind[i].zv) != IS_LONG &&
+ PASS != mysqlnd_stmt_copy_it(&copies, stmt->param_bind[i].zv, stmt->param_count, i
TSRMLS_CC))
+ {
SET_OOM_ERROR(stmt->error_info);
goto end;
}
@@ -634,7 +636,7 @@
if it doesn't fit in a long send it as a string.
Check bug #52891 : Wrong data inserted with mysqli/mysqlnd when using bind_param, value >
LONG_MAX
*/
- {
+ if (Z_TYPE_P(stmt->param_bind[i].zv) != IS_LONG) {
zval *tmp_data = (copies && copies[i])? copies[i]: stmt->param_bind[i].zv;
convert_to_double_ex(&tmp_data);
if (Z_DVAL_P(tmp_data) > LONG_MAX || Z_DVAL_P(tmp_data) < LONG_MIN) {
@@ -677,8 +679,9 @@
if it doesn't fit in a long send it as a string.
Check bug #52891 : Wrong data inserted with mysqli/mysqlnd when using bind_param, value >
LONG_MAX
*/
- {
+ if (Z_TYPE_P(stmt->param_bind[i].zv) != IS_LONG) {
zval *tmp_data = (copies && copies[i])? copies[i]: stmt->param_bind[i].zv;
+
convert_to_double_ex(&tmp_data);
if (Z_DVAL_P(tmp_data) > LONG_MAX || Z_DVAL_P(tmp_data) < LONG_MIN) {
convert_to_string_ex(&tmp_data);
Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_ps_codec.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_ps_codec.c 2010-09-22 14:07:40 UTC (rev 303674)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_ps_codec.c 2010-09-22 14:26:43 UTC (rev 303675)
@@ -626,7 +626,9 @@
(stmt->param_bind[i].type == MYSQL_TYPE_LONG || stmt->param_bind[i].type ==
MYSQL_TYPE_LONGLONG))
{
/* always copy the var, because we do many conversions */
- if (PASS != mysqlnd_stmt_copy_it(&copies, stmt->param_bind[i].zv, stmt->param_count, i
TSRMLS_CC)) {
+ if (Z_TYPE_P(stmt->param_bind[i].zv) != IS_LONG &&
+ PASS != mysqlnd_stmt_copy_it(&copies, stmt->param_bind[i].zv, stmt->param_count, i
TSRMLS_CC))
+ {
SET_OOM_ERROR(stmt->error_info);
goto end;
}
@@ -634,7 +636,7 @@
if it doesn't fit in a long send it as a string.
Check bug #52891 : Wrong data inserted with mysqli/mysqlnd when using bind_param, value >
LONG_MAX
*/
- {
+ if (Z_TYPE_P(stmt->param_bind[i].zv) != IS_LONG) {
zval *tmp_data = (copies && copies[i])? copies[i]: stmt->param_bind[i].zv;
convert_to_double_ex(&tmp_data);
if (Z_DVAL_P(tmp_data) > LONG_MAX || Z_DVAL_P(tmp_data) < LONG_MIN) {
@@ -677,8 +679,9 @@
if it doesn't fit in a long send it as a string.
Check bug #52891 : Wrong data inserted with mysqli/mysqlnd when using bind_param, value >
LONG_MAX
*/
- {
+ if (Z_TYPE_P(stmt->param_bind[i].zv) != IS_LONG) {
zval *tmp_data = (copies && copies[i])? copies[i]: stmt->param_bind[i].zv;
+
convert_to_double_ex(&tmp_data);
if (Z_DVAL_P(tmp_data) > LONG_MAX || Z_DVAL_P(tmp_data) < LONG_MIN) {
convert_to_string_ex(&tmp_data);