Skip to content

Remove MYSQLI_STMT_ATTR_PREFETCH_ROWS constant #15485

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions ext/mysqli/mysqli.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,6 @@
* @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 */
/**
Expand Down
14 changes: 2 additions & 12 deletions ext/mysqli/mysqli_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down Expand Up @@ -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();
}

Expand Down
3 changes: 1 addition & 2 deletions ext/mysqli/mysqli_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions ext/mysqli/tests/mysqli_constants.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
4 changes: 1 addition & 3 deletions ext/mysqli/tests/mysqli_stmt_attr_get.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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!
30 changes: 0 additions & 30 deletions ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt

This file was deleted.

60 changes: 1 addition & 59 deletions ext/mysqli/tests/mysqli_stmt_attr_set.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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!";
?>
Expand All @@ -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!
1 change: 0 additions & 1 deletion ext/mysqlnd/mysqlnd_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions ext/mysqlnd/mysqlnd_enum_n_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 0 additions & 16 deletions ext/mysqlnd/mysqlnd_ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down
1 change: 0 additions & 1 deletion ext/mysqlnd/mysqlnd_structs.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading