Then explain why half the test cases fail silently with the code as it was, and why all tests pass and run perfectly now?

--Wez.

Andrey Hristov wrote:
 Hi Wez,
I do never commit code which makes test case fail. Here not tests failed
therefore I did commit the code. In addition, (my_ulonglong) -1 is not 0. The
first value is returned from mysql_stmt_affected_rows() and
mysql_affected_rows() to indicate a failure. Both functions return unsigned
long and therefore to indicate an error they return a number of rows so far
thought that will not appear in a result set (or number of affected rows).
Therefore, I do think, if my mind is not borked :), that your fix is not
correct.

Andrey


Quoting Wez Furlong <[EMAIL PROTECTED]>:

wez        Wed Jul 13 22:03:55 2005 EDT

  Modified files:
    /php-src/ext/pdo_mysql    mysql_statement.c
  Log:
  it is not an error for a statement to return 0 rows.

  Andrey: please run the test suite before each commit!
This broke beta 3 and was clearly visible as a result of running the tests.

  Running further tests now.



http://cvs.php.net/diff.php/php-src/ext/pdo_mysql/mysql_statement.c?r1=1.41&r2=1.42&ty=u
Index: php-src/ext/pdo_mysql/mysql_statement.c
diff -u php-src/ext/pdo_mysql/mysql_statement.c:1.41 php-src/ext/pdo_mysql/mysql_statement.c:1.42 --- php-src/ext/pdo_mysql/mysql_statement.c:1.41 Tue Jul 12 15:22:05 2005
+++ php-src/ext/pdo_mysql/mysql_statement.c    Wed Jul 13 22:03:54 2005
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
 */

-/* $Id: mysql_statement.c,v 1.41 2005/07/12 19:22:05 andrey Exp $ */
+/* $Id: mysql_statement.c,v 1.42 2005/07/14 02:03:54 wez Exp $ */

 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -96,11 +96,9 @@
             my_bool on = 1;
/* if we have bound the buffers don't set the attribute again */
             if (!S->result) {
-                /*
- FIXME: using directly internal structs - but for now cleaner
-                then calling 2 times result_metadata.
-                */
-                for (i= 0; i < S->stmt->field_count; i++) {
+ /* FIXME: using directly internal structs - but for now cleaner
+                 * then calling 2 times result_metadata. */
+                for (i = 0; i < S->stmt->field_count; i++) {
                     switch (S->fields[i].type) {
                         case MYSQL_TYPE_MEDIUM_BLOB:
                         case MYSQL_TYPE_LONG_BLOB:
@@ -124,12 +122,12 @@

                 if (S->bound_result) {
                     int i;
-                        for (i = 0; i < stmt->column_count; i++) {
-                            efree(S->bound_result[i].buffer);
+                    for (i = 0; i < stmt->column_count; i++) {
+                        efree(S->bound_result[i].buffer);
                     }
-                        efree(S->bound_result);
-                        efree(S->out_null);
-                        efree(S->out_length);
+                    efree(S->bound_result);
+                    efree(S->out_null);
+                    efree(S->out_length);
                 }

                 stmt->column_count = (int)mysql_num_fields(S->result);
@@ -140,8 +138,8 @@
                 /* summon memory to hold the row */
                 for (i = 0; i < stmt->column_count; i++) {
                     S->bound_result[i].buffer_length =
- S->fields[i].max_length? S->fields[i].max_length: - S->fields[i].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];
@@ -156,11 +154,11 @@
         }

         ;
- if ((row_count= mysql_stmt_affected_rows(S->stmt)) != (my_ulonglong)-1) {
+        row_count = mysql_stmt_affected_rows(S->stmt);
+        if (row_cont != (my_ulonglong)-1) {
             stmt->row_count = row_count;
-            return 1;
         }
-        return 0;
+        return 1;
     }
 #endif
     /* ensure that we free any previous unfetched results */

--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php






--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to