php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #79914
Patch patch.79914 revision 2020-08-08 03:32 UTC by houxiaoxian1111 at 163 dot com
revision 2020-08-05 02:20 UTC by houxiaoxian1111 at 163 dot com
Patch patch.76742 revision 2020-07-30 06:59 UTC by houxiaoxian1111 at 163 dot com

Patch patch.79914 for PDO MySQL Bug #79914

Patch version 2020-08-05 02:20 UTC

Return to Bug #79914 | Download this patch
Patch Revisions: 2020-08-08 03:32 UTC | 2020-08-05 02:20 UTC

Developer: houxiaoxian1111@163.com

Line 1 (now 1), was 48 lines, now 47 lines

  diff -up origin/php-7.1.11/ext/pdo_mysql/mysql_driver.c new/php-7.1.11/ext/pdo_mysql/mysql_driver.c
  --- origin/php-7.1.11/ext/pdo_mysql/mysql_driver.c	2017-10-25 15:04:36.000000000 +0800
 +++ new/php-7.1.11/ext/pdo_mysql/mysql_driver.c	2020-08-08 08:44:30.000000000 +0800
 @@ -42,6 +42,55 @@
 +++ new/php-7.1.11/ext/pdo_mysql/mysql_driver.c	2020-07-30 11:10:49.000000000 +0800
 @@ -42,6 +42,54 @@
   #	define pdo_mysql_init(persistent) mysql_init(NULL)
   #endif
   
  +/* {{{ _pdo_mysql_stmt_error */
 +
  +int _pdo_mysql_stmt_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int line)
  +{
  +        pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data;
  +        pdo_error_type *pdo_err;
  +        pdo_mysql_error_info *einfo;
  +        pdo_mysql_stmt *S = NULL;
 +
 +
 +        PDO_DBG_ENTER("_pdo_mysql_stmt_error");
 +
 +
 +        PDO_DBG_ENTER("_pdo_mysql_error");
  +        PDO_DBG_INF_FMT("file=%s line=%d", file, line);
  +        S = (pdo_mysql_stmt*)stmt->driver_data;
  +        pdo_err = &stmt->error_code;
  +        einfo   = &S->einfo;
  +
  +        einfo->errcode = mysql_errno(H->server);
  +        einfo->file = file;
  +        einfo->line = line;
 +
 +
  +        if (einfo->errcode) {
  +                if (einfo->errcode == 2014) {
  +                        einfo->errmsg = pestrdup(
  +                                "Cannot execute queries while other unbuffered queries are active.  "
  +                                "Consider using PDOStatement::fetchAll().  Alternatively, if your code "
  +                                "is only ever going to run against mysql, you may enable query "
  +                                "buffering by setting the PDO::MYSQL_ATTR_USE_BUFFERED_QUERY attribute.",
 +                                dbh->is_persistent);
 +                                dbh->is_persistent);
  +                } else if (einfo->errcode == 2057) {
  +                        einfo->errmsg = pestrdup(
  +                                "A stored procedure returning result sets of different size was called. "
  +                                "This is not supported by libmysql",
  +                                dbh->is_persistent);
  +
  +                } else {
  +                        einfo->errmsg = pestrdup(mysql_error(H->server), dbh->is_persistent);
 +                }
 +                }
  +        } else { /* no error */
  +                strcpy(*pdo_err, PDO_ERR_NONE);
  +                PDO_DBG_RETURN(0);
  +        }


   int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int line)
   {
  diff -up origin/php-7.1.11/ext/pdo_mysql/mysql_statement.c new/php-7.1.11/ext/pdo_mysql/mysql_statement.c
  --- origin/php-7.1.11/ext/pdo_mysql/mysql_statement.c	2017-10-25 15:04:36.000000000 +0800
 +++ new/php-7.1.11/ext/pdo_mysql/mysql_statement.c	2020-08-08 08:45:15.000000000 +0800
 +++ new/php-7.1.11/ext/pdo_mysql/mysql_statement.c	2020-08-05 10:13:17.000000000 +0800
  @@ -119,10 +119,19 @@ static void pdo_mysql_stmt_set_row_count
   {
   	zend_long row_count;
   	pdo_mysql_stmt *S = stmt->driver_data;
Line 69 (now 68), was 28 lines, now 23 lines

   	if (row_count != (zend_long)-1) {
   		stmt->row_count = row_count;
  -	}
  +	}else {
 +        	if (!H->buffered) {
 +                	S->result = mysql_use_result(H->server);
 +        	} else {
 +                	S->result = mysql_store_result(H->server);
 +        	}
 +        	pdo_mysql_error_stmt_emulate_false(stmt);                
 +        	PDO_DBG_VOID_RETURN;
 +    	}
 +                if (!H->buffered) {
 +                        S->result = mysql_use_result(H->server);
 +                } else {
 +                        S->result = mysql_store_result(H->server);
 +                }
 +                pdo_mysql_error_stmt_emulate_false(stmt);                
 +                PDO_DBG_VOID_RETURN;
 +        }
   }
   /* }}} */
   
  diff -up origin/php-7.1.11/ext/pdo_mysql/php_pdo_mysql_int.h new/php-7.1.11/ext/pdo_mysql/php_pdo_mysql_int.h
  --- origin/php-7.1.11/ext/pdo_mysql/php_pdo_mysql_int.h	2017-10-25 15:04:36.000000000 +0800
 +++ new/php-7.1.11/ext/pdo_mysql/php_pdo_mysql_int.h	2020-08-08 08:43:59.000000000 +0800
 @@ -150,10 +150,12 @@ typedef struct {
  } pdo_mysql_stmt;
  
  extern pdo_driver_t pdo_mysql_driver;
 +extern int _pdo_mysql_stmt_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int line);
  
 +++ new/php-7.1.11/ext/pdo_mysql/php_pdo_mysql_int.h	2020-07-30 11:09:53.000000000 +0800
 @@ -154,6 +154,7 @@ extern pdo_driver_t pdo_mysql_driver;
   extern int _pdo_mysql_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, const char *file, int line);
   #define pdo_mysql_error(s) _pdo_mysql_error(s, NULL, __FILE__, __LINE__)
   #define pdo_mysql_error_stmt(s) _pdo_mysql_error(stmt->dbh, stmt, __FILE__, __LINE__)
  +#define pdo_mysql_error_stmt_emulate_false(s) _pdo_mysql_stmt_error(stmt->dbh, stmt, __FILE__, __LINE__)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 30 21:01:30 2024 UTC