]> granicus.if.org Git - php/commitdiff
MFH: Fixed bug #34001 (pdo_mysql truncates numberic fields at 4 chars)
authorIlia Alshanetsky <iliaa@php.net>
Thu, 1 Sep 2005 01:57:01 +0000 (01:57 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Thu, 1 Sep 2005 01:57:01 +0000 (01:57 +0000)
NEWS
ext/pdo_mysql/mysql_statement.c

diff --git a/NEWS b/NEWS
index 9988c73462c26da8983e7e3ece78548e0c0b0c45..d9f6998c7b9c3f4f7f03f8f495c62d24cdb0a0a0 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,7 @@ PHP                                                                        NEWS
 - Fixed bug #34062 (Crash in catch block when many arguments are used).
   (Dmitry)
 - Fixed bug #34045 (Buffer overflow with serialized object). (Dmitry)
+- Fixed bug #34001 (pdo_mysql truncates numberic fields at 4 chars). (Ilia)
 - Fixed bug #33999 (object remains object when cast to int). (Dmitry)
 - Fixed bug #33996 (No information given for fatal error on passing invalid
   value to typed argument). (Dmitry)
index 43587345a958f6cce900a1ac61aa0cea5ec3916d..51255b7f120d5d6c6ccd36feddd3784ebda0071c 100755 (executable)
@@ -121,9 +121,27 @@ static int pdo_mysql_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
                                                mysql_stmt_attr_set(S->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, &on);
                                                calc_max_length = 0;
                                        }
-                                       S->bound_result[i].buffer_length =
-                                               S->fields[i].max_length? S->fields[i].max_length:
-                                               S->fields[i].length;
+                                       switch (S->fields[i].type) {
+                                               case FIELD_TYPE_INT24:
+                                                       S->bound_result[i].buffer_length = MAX_MEDIUMINT_WIDTH;
+                                                       break;
+                                               case FIELD_TYPE_LONG:
+                                                       S->bound_result[i].buffer_length = MAX_INT_WIDTH;
+                                                       break;
+                                               case FIELD_TYPE_LONGLONG:
+                                                       S->bound_result[i].buffer_length = MAX_BIGINT_WIDTH;
+                                                       break;
+                                               case FIELD_TYPE_TINY:
+                                                       S->bound_result[i].buffer_length = MAX_TINYINT_WIDTH;
+                                                       break;
+                                               case FIELD_TYPE_SHORT:
+                                                       S->bound_result[i].buffer_length = MAX_SMALLINT_WIDTH;
+                                                       break;
+                                               default:
+                                                       S->bound_result[i].buffer_length =
+                                                               S->fields[i].max_length? S->fields[i].max_length:
+                                                               S->fields[i].length;
+                                       }
                                        S->bound_result[i].buffer = emalloc(S->bound_result[i].buffer_length);
                                        S->bound_result[i].is_null = &S->out_null[i];
                                        S->bound_result[i].length = &S->out_length[i];