mirror of
https://github.com/php/php-src.git
synced 2025-08-15 13:38:49 +02:00
Remove MYSQLI_STMT_ATTR_PREFETCH_ROWS constant (#15485)
This feature was never implemented, and since the beginning, using this constant with mysqlnd would result in an error. This feature was only available with libmysqlclient which can no longer be used with mysqli. There are no plans to implement it in the future.
This commit is contained in:
parent
ac3cdf54df
commit
c316382acb
11 changed files with 6 additions and 135 deletions
|
@ -191,11 +191,6 @@ const MYSQLI_CURSOR_TYPE_FOR_UPDATE = UNKNOWN;
|
|||
* @cvalue CURSOR_TYPE_SCROLLABLE
|
||||
*/
|
||||
const MYSQLI_CURSOR_TYPE_SCROLLABLE = UNKNOWN;
|
||||
/**
|
||||
* @var int
|
||||
* @cvalue STMT_ATTR_PREFETCH_ROWS
|
||||
*/
|
||||
const MYSQLI_STMT_ATTR_PREFETCH_ROWS = UNKNOWN;
|
||||
|
||||
/* column information */
|
||||
/**
|
||||
|
|
|
@ -1751,18 +1751,9 @@ PHP_FUNCTION(mysqli_stmt_attr_set)
|
|||
mode = mode_in;
|
||||
mode_p = &mode;
|
||||
break;
|
||||
case STMT_ATTR_PREFETCH_ROWS:
|
||||
if (mode_in < 1) {
|
||||
zend_argument_value_error(ERROR_ARG_POS(3), "must be greater than 0 for attribute MYSQLI_STMT_ATTR_PREFETCH_ROWS");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
mode = mode_in;
|
||||
mode_p = &mode;
|
||||
break;
|
||||
default:
|
||||
zend_argument_value_error(ERROR_ARG_POS(2), "must be one of "
|
||||
"MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, "
|
||||
"MYSQLI_STMT_ATTR_PREFETCH_ROWS, or STMT_ATTR_CURSOR_TYPE");
|
||||
"MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH or STMT_ATTR_CURSOR_TYPE");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
|
@ -1793,8 +1784,7 @@ PHP_FUNCTION(mysqli_stmt_attr_get)
|
|||
/* Success corresponds to 0 return value and a non-zero value
|
||||
* should only happen if the attr/option is unknown */
|
||||
zend_argument_value_error(ERROR_ARG_POS(2), "must be one of "
|
||||
"MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, "
|
||||
"MYSQLI_STMT_ATTR_PREFETCH_ROWS, or STMT_ATTR_CURSOR_TYPE");
|
||||
"MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH or STMT_ATTR_CURSOR_TYPE");
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
|
|
3
ext/mysqli/mysqli_arginfo.h
generated
3
ext/mysqli/mysqli_arginfo.h
generated
|
@ -1,5 +1,5 @@
|
|||
/* This is a generated file, edit the .stub.php file instead.
|
||||
* Stub hash: c904ba3577e74cd390278004de0cf3594eb66f18 */
|
||||
* Stub hash: 6ab095be89ce9416df60f2dfaa1bd70732e33136 */
|
||||
|
||||
ZEND_BEGIN_ARG_WITH_RETURN_TYPE_MASK_EX(arginfo_mysqli_affected_rows, 0, 1, MAY_BE_LONG|MAY_BE_STRING)
|
||||
ZEND_ARG_OBJ_INFO(0, mysql, mysqli, 0)
|
||||
|
@ -1077,7 +1077,6 @@ static void register_mysqli_symbols(int module_number)
|
|||
REGISTER_LONG_CONSTANT("MYSQLI_CURSOR_TYPE_READ_ONLY", CURSOR_TYPE_READ_ONLY, CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_CURSOR_TYPE_FOR_UPDATE", CURSOR_TYPE_FOR_UPDATE, CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_CURSOR_TYPE_SCROLLABLE", CURSOR_TYPE_SCROLLABLE, CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_STMT_ATTR_PREFETCH_ROWS", STMT_ATTR_PREFETCH_ROWS, CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_NOT_NULL_FLAG", NOT_NULL_FLAG, CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_PRI_KEY_FLAG", PRI_KEY_FLAG, CONST_PERSISTENT);
|
||||
REGISTER_LONG_CONSTANT("MYSQLI_UNIQUE_KEY_FLAG", UNIQUE_KEY_FLAG, CONST_PERSISTENT);
|
||||
|
|
|
@ -137,10 +137,6 @@ $expected_constants = array_merge($expected_constants, array(
|
|||
"MYSQLI_CURSOR_TYPE_SCROLLABLE" => true,
|
||||
));
|
||||
|
||||
$expected_constants = array_merge($expected_constants, array(
|
||||
"MYSQLI_STMT_ATTR_PREFETCH_ROWS" => true,
|
||||
));
|
||||
|
||||
$expected_constants['MYSQLI_OPT_SSL_VERIFY_SERVER_CERT'] = true;
|
||||
|
||||
/* pretty dump test, but that is the best way to mimic mysql.c */
|
||||
|
|
|
@ -13,7 +13,6 @@ require_once 'skipifconnectfailure.inc';
|
|||
$valid_attr = array(
|
||||
MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH,
|
||||
MYSQLI_STMT_ATTR_CURSOR_TYPE,
|
||||
MYSQLI_STMT_ATTR_PREFETCH_ROWS,
|
||||
);
|
||||
|
||||
$stmt = mysqli_stmt_init($link);
|
||||
|
@ -51,8 +50,7 @@ require_once 'skipifconnectfailure.inc';
|
|||
require_once 'clean_table.inc';
|
||||
?>
|
||||
--EXPECT--
|
||||
mysqli_stmt_attr_get(): Argument #2 ($attribute) must be one of MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, MYSQLI_STMT_ATTR_PREFETCH_ROWS, or STMT_ATTR_CURSOR_TYPE
|
||||
mysqli_stmt object is already closed
|
||||
mysqli_stmt_attr_get(): Argument #2 ($attribute) must be one of MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH or STMT_ATTR_CURSOR_TYPE
|
||||
mysqli_stmt object is already closed
|
||||
mysqli_stmt object is already closed
|
||||
done!
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
--TEST--
|
||||
mysqli_stmt_attr_get() - prefetch
|
||||
--EXTENSIONS--
|
||||
mysqli
|
||||
--SKIPIF--
|
||||
<?php
|
||||
require_once 'skipifconnectfailure.inc';
|
||||
?>
|
||||
--XFAIL--
|
||||
prefetch isn't supported at the moment
|
||||
--FILE--
|
||||
<?php
|
||||
require 'table.inc';
|
||||
|
||||
$stmt = mysqli_stmt_init($link);
|
||||
mysqli_stmt_prepare($stmt, 'SELECT * FROM test');
|
||||
if (1 !== ($tmp = mysqli_stmt_attr_get($stmt, MYSQLI_STMT_ATTR_PREFETCH_ROWS))) {
|
||||
printf("[001] Expecting int/1, got %s/%s for attribute %s/%s\n",
|
||||
gettype($tmp), $tmp, $k, $attr);
|
||||
}
|
||||
$stmt->close();
|
||||
mysqli_close($link);
|
||||
print "done!";
|
||||
?>
|
||||
--CLEAN--
|
||||
<?php
|
||||
require_once 'clean_table.inc';
|
||||
?>
|
||||
--EXPECT--
|
||||
done!
|
|
@ -160,63 +160,6 @@ require_once 'skipifconnectfailure.inc';
|
|||
var_dump($results2);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// MYSQLI_STMT_ATTR_PREFETCH_ROWS
|
||||
//
|
||||
|
||||
$stmt = mysqli_stmt_init($link);
|
||||
$stmt->prepare("SELECT id, label FROM test");
|
||||
// Invalid prefetch value
|
||||
try {
|
||||
$stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 0);
|
||||
} catch (\ValueError $e) {
|
||||
echo $e->getMessage() . \PHP_EOL;
|
||||
}
|
||||
|
||||
if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 1)))
|
||||
printf("[020] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
|
||||
$stmt->execute();
|
||||
$id = $label = NULL;
|
||||
$stmt->bind_result($id, $label);
|
||||
$results = array();
|
||||
while ($stmt->fetch())
|
||||
$results[$id] = $label;
|
||||
$stmt->close();
|
||||
if (empty($results))
|
||||
printf("[021] Results should not be empty, subsequent tests will probably fail!\n");
|
||||
|
||||
/* prefetch is not supported
|
||||
$stmt = mysqli_stmt_init($link);
|
||||
$stmt->prepare("SELECT label FROM test");
|
||||
if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, -1)))
|
||||
printf("[022] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
|
||||
$stmt->close();
|
||||
|
||||
$stmt = mysqli_stmt_init($link);
|
||||
$stmt->prepare("SELECT label FROM test");
|
||||
if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, PHP_INT_MAX)))
|
||||
printf("[023] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
|
||||
$stmt->close();
|
||||
|
||||
$stmt = mysqli_stmt_init($link);
|
||||
$stmt->prepare("SELECT id, label FROM test");
|
||||
if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 2)))
|
||||
printf("[024] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
|
||||
$stmt->execute();
|
||||
$id = $label = NULL;
|
||||
$stmt->bind_result($id, $label);
|
||||
$results2 = array();
|
||||
while ($stmt->fetch())
|
||||
$results2[$id] = $label;
|
||||
$stmt->close();
|
||||
if ($results != $results2) {
|
||||
printf("[025] Results should not differ. Dumping both result sets.\n");
|
||||
var_dump($results);
|
||||
var_dump($results2);
|
||||
}
|
||||
*/
|
||||
|
||||
mysqli_close($link);
|
||||
print "done!";
|
||||
?>
|
||||
|
@ -226,9 +169,8 @@ require_once 'skipifconnectfailure.inc';
|
|||
?>
|
||||
--EXPECT--
|
||||
Error: mysqli_stmt object is not fully initialized
|
||||
mysqli_stmt_attr_set(): Argument #2 ($attribute) must be one of MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, MYSQLI_STMT_ATTR_PREFETCH_ROWS, or STMT_ATTR_CURSOR_TYPE
|
||||
mysqli_stmt_attr_set(): Argument #2 ($attribute) must be one of MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH or STMT_ATTR_CURSOR_TYPE
|
||||
mysqli_stmt::attr_set(): Argument #2 ($value) must be 0 or 1 for attribute MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH
|
||||
bool(true)
|
||||
mysqli_stmt::attr_set(): Argument #2 ($value) must be one of the MYSQLI_CURSOR_TYPE_* constants for attribute MYSQLI_STMT_ATTR_CURSOR_TYPE
|
||||
mysqli_stmt::attr_set(): Argument #2 ($value) must be greater than 0 for attribute MYSQLI_STMT_ATTR_PREFETCH_ROWS
|
||||
done!
|
||||
|
|
|
@ -206,7 +206,6 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_prepared_statement)(MYSQLND_CONN_DATA
|
|||
stmt->state = MYSQLND_STMT_INITTED;
|
||||
stmt->execute_cmd_buffer.length = MYSQLND_NET_CMD_BUFFER_MIN_SIZE;
|
||||
stmt->execute_cmd_buffer.buffer = mnd_emalloc(stmt->execute_cmd_buffer.length);
|
||||
stmt->prefetch_rows = MYSQLND_DEFAULT_PREFETCH_ROWS;
|
||||
|
||||
/*
|
||||
Mark that we reference the connection, thus it won't be
|
||||
|
|
|
@ -399,8 +399,7 @@ typedef enum param_bind_flags
|
|||
enum mysqlnd_stmt_attr
|
||||
{
|
||||
STMT_ATTR_UPDATE_MAX_LENGTH,
|
||||
STMT_ATTR_CURSOR_TYPE,
|
||||
STMT_ATTR_PREFETCH_ROWS
|
||||
STMT_ATTR_CURSOR_TYPE
|
||||
};
|
||||
|
||||
enum myslqnd_cursor_type
|
||||
|
|
|
@ -1552,18 +1552,6 @@ MYSQLND_METHOD(mysqlnd_stmt, attr_set)(MYSQLND_STMT * const s,
|
|||
stmt->flags = ival;
|
||||
break;
|
||||
}
|
||||
case STMT_ATTR_PREFETCH_ROWS: {
|
||||
unsigned long ival = *(unsigned long *) value;
|
||||
if (ival == 0) {
|
||||
ival = MYSQLND_DEFAULT_PREFETCH_ROWS;
|
||||
} else if (ival > 1) {
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
|
||||
DBG_INF("FAIL");
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
stmt->prefetch_rows = ival;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
SET_CLIENT_ERROR(stmt->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
|
||||
DBG_RETURN(FAIL);
|
||||
|
@ -1596,10 +1584,6 @@ MYSQLND_METHOD(mysqlnd_stmt, attr_get)(const MYSQLND_STMT * const s,
|
|||
*(unsigned long *) value = stmt->flags;
|
||||
DBG_INF_FMT("value=%lu", *(unsigned long *) value);
|
||||
break;
|
||||
case STMT_ATTR_PREFETCH_ROWS:
|
||||
*(unsigned long *) value = stmt->prefetch_rows;
|
||||
DBG_INF_FMT("value=%lu", *(unsigned long *) value);
|
||||
break;
|
||||
default:
|
||||
DBG_RETURN(FAIL);
|
||||
}
|
||||
|
|
|
@ -1267,7 +1267,6 @@ struct st_mysqlnd_stmt_data
|
|||
MYSQLND_ERROR_INFO error_info_impl;
|
||||
|
||||
bool update_max_length;
|
||||
zend_ulong prefetch_rows;
|
||||
|
||||
bool cursor_exists;
|
||||
mysqlnd_stmt_use_or_store_func default_rset_handler;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue