]> granicus.if.org Git - php/commitdiff
Merge branch 'PHP-7.4' into PHP-8.0
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 18 Dec 2020 09:20:13 +0000 (10:20 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 18 Dec 2020 09:20:13 +0000 (10:20 +0100)
* PHP-7.4:
  MySQLnd: Support cursors in store/get result

1  2 
NEWS
ext/mysqli/tests/mysqli_stmt_get_result.phpt
ext/mysqlnd/mysqlnd_ps.c

diff --cc NEWS
index 8b0ce956009646e2beeddeaaa131b42043d0488c,6d4b264c7e87c830e917571f61b4329c5233833b..6226586aba183aa05fd26599f430b7c09ebec224
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -8,14 -8,18 +8,20 @@@ PH
  - MySQLi:
    . Fixed bug #67983 (mysqlnd with MYSQLI_OPT_INT_AND_FLOAT_NATIVE fails to
      interpret bit columns). (Nikita)
+   . Fixed bug #64638 (Fetching resultsets from stored procedure with cursor
+     fails). (Nikita)
+   . Fixed bug #72862 (segfault using prepared statements on stored procedures
+     that use a cursor). (Nikita)
+   . Fixed bug #77935 (Crash in mysqlnd_fetch_stmt_row_cursor when calling an SP
+     with a cursor). (Nikita)
  
 -07 Jan 2021, PHP 7.4.14
 +- PDO_Firebird:
 +  . Fixed bug #80521 (Parameters with underscores no longer recognized). (cmb,
 +    Simonov Denis)
 +
 +07 Jan 2021, PHP 8.0.1
  
  - Core:
 -  . Fixed bug #74558 (Can't rebind closure returned by Closure::fromCallable()).
 -    (cmb)
    . Fixed bug #80345 (PHPIZE configuration has outdated PHP_RELEASE_VERSION).
      (cmb)
    . Fixed bug #72964 (White space not unfolded for CC/Bcc headers). (cmb)
index 74b15dfae3b05b090a625352ecdaecb5d48d6385,fc07a1d2a2636852d3046db821c311850ce68a73..0f98217d598a38ed40a5f2a0756abbd12c982b23
@@@ -193,11 -178,26 +180,21 @@@ if (!function_exists('mysqli_stmt_get_r
      require_once("clean_table.inc");
  ?>
  --EXPECTF--
 -Warning: mysqli_stmt_fetch(): invalid object or resource mysqli_stmt
 - in %s on line %d
 -
 -Warning: mysqli_stmt_fetch(): invalid object or resource mysqli_stmt
 - in %s on line %d
 -
 -Warning: mysqli_stmt_get_result(): invalid object or resource mysqli_stmt
 - in %s on line %d
 +mysqli_stmt object is not fully initialized
 +mysqli_stmt object is not fully initialized
 +mysqli_stmt object is not fully initialized
- mysqli_stmt_get_result() cannot be used with cursors
- get_result() cannot be used with cursors
+ array(2) {
+   ["id"]=>
+   int(1)
+   ["label"]=>
+   string(1) "a"
+ }
+ array(2) {
+   ["id"]=>
+   int(2)
+   ["label"]=>
+   string(1) "b"
+ }
  [040] [2014] [Commands out of sync; you can't run this command now]
  [041] [0] []
  array(2) {
index d2ec46e8da11d3494e941a2e07faeb6f42353181,12aace6ec27e1b4ff644da2298d8f2ebf31067cf..deaf52de62213e55ef4cb0d240d2382b137f4eda
@@@ -36,7 -38,38 +36,37 @@@ enum_func_status mysqlnd_stmt_execute_g
  enum_func_status mysqlnd_stmt_execute_batch_generate_request(MYSQLND_STMT * const s, zend_uchar ** request, size_t *request_len, zend_bool * free_buffer);
  
  static void mysqlnd_stmt_separate_result_bind(MYSQLND_STMT * const stmt);
 -static void mysqlnd_stmt_separate_one_result_bind(MYSQLND_STMT * const stmt, const unsigned int param_no);
  
+ static enum_func_status mysqlnd_stmt_send_cursor_fetch_command(
+               const MYSQLND_STMT_DATA *stmt, unsigned max_rows)
+ {
+       MYSQLND_CONN_DATA *conn = stmt->conn;
+       zend_uchar buf[MYSQLND_STMT_ID_LENGTH /* statement id */ + 4 /* number of rows to fetch */];
+       const MYSQLND_CSTRING payload = {(const char*) buf, sizeof(buf)};
+       int4store(buf, stmt->stmt_id);
+       int4store(buf + MYSQLND_STMT_ID_LENGTH, max_rows);
+       if (conn->command->stmt_fetch(conn, payload) == FAIL) {
+               COPY_CLIENT_ERROR(stmt->error_info, *conn->error_info);
+               return FAIL;
+       }
+       return PASS;
+ }
+ static zend_bool mysqlnd_stmt_check_state(const MYSQLND_STMT_DATA *stmt)
+ {
+       const MYSQLND_CONN_DATA *conn = stmt->conn;
+       if (stmt->state != MYSQLND_STMT_WAITING_USE_OR_STORE) {
+               return 0;
+       }
+       if (stmt->cursor_exists) {
+               return GET_CONNECTION_STATE(&conn->state) == CONN_READY;
+       } else {
+               return GET_CONNECTION_STATE(&conn->state) == CONN_FETCHING_DATA;
+       }
+ }
  /* {{{ mysqlnd_stmt::store_result */
  static MYSQLND_RES *
  MYSQLND_METHOD(mysqlnd_stmt, store_result)(MYSQLND_STMT * const s)