Skip to content

Commit c316382

Browse files
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.
1 parent ac3cdf5 commit c316382

11 files changed

+6
-135
lines changed

ext/mysqli/mysqli.stub.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,11 +191,6 @@
191191
* @cvalue CURSOR_TYPE_SCROLLABLE
192192
*/
193193
const MYSQLI_CURSOR_TYPE_SCROLLABLE = UNKNOWN;
194-
/**
195-
* @var int
196-
* @cvalue STMT_ATTR_PREFETCH_ROWS
197-
*/
198-
const MYSQLI_STMT_ATTR_PREFETCH_ROWS = UNKNOWN;
199194

200195
/* column information */
201196
/**

ext/mysqli/mysqli_api.c

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,18 +1751,9 @@ PHP_FUNCTION(mysqli_stmt_attr_set)
17511751
mode = mode_in;
17521752
mode_p = &mode;
17531753
break;
1754-
case STMT_ATTR_PREFETCH_ROWS:
1755-
if (mode_in < 1) {
1756-
zend_argument_value_error(ERROR_ARG_POS(3), "must be greater than 0 for attribute MYSQLI_STMT_ATTR_PREFETCH_ROWS");
1757-
RETURN_THROWS();
1758-
}
1759-
mode = mode_in;
1760-
mode_p = &mode;
1761-
break;
17621754
default:
17631755
zend_argument_value_error(ERROR_ARG_POS(2), "must be one of "
1764-
"MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, "
1765-
"MYSQLI_STMT_ATTR_PREFETCH_ROWS, or STMT_ATTR_CURSOR_TYPE");
1756+
"MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH or STMT_ATTR_CURSOR_TYPE");
17661757
RETURN_THROWS();
17671758
}
17681759

@@ -1793,8 +1784,7 @@ PHP_FUNCTION(mysqli_stmt_attr_get)
17931784
/* Success corresponds to 0 return value and a non-zero value
17941785
* should only happen if the attr/option is unknown */
17951786
zend_argument_value_error(ERROR_ARG_POS(2), "must be one of "
1796-
"MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH, "
1797-
"MYSQLI_STMT_ATTR_PREFETCH_ROWS, or STMT_ATTR_CURSOR_TYPE");
1787+
"MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH or STMT_ATTR_CURSOR_TYPE");
17981788
RETURN_THROWS();
17991789
}
18001790

ext/mysqli/mysqli_arginfo.h

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ext/mysqli/tests/mysqli_constants.phpt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,6 @@ $expected_constants = array_merge($expected_constants, array(
137137
"MYSQLI_CURSOR_TYPE_SCROLLABLE" => true,
138138
));
139139

140-
$expected_constants = array_merge($expected_constants, array(
141-
"MYSQLI_STMT_ATTR_PREFETCH_ROWS" => true,
142-
));
143-
144140
$expected_constants['MYSQLI_OPT_SSL_VERIFY_SERVER_CERT'] = true;
145141

146142
/* pretty dump test, but that is the best way to mimic mysql.c */

ext/mysqli/tests/mysqli_stmt_attr_get.phpt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ require_once 'skipifconnectfailure.inc';
1313
$valid_attr = array(
1414
MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH,
1515
MYSQLI_STMT_ATTR_CURSOR_TYPE,
16-
MYSQLI_STMT_ATTR_PREFETCH_ROWS,
1716
);
1817

1918
$stmt = mysqli_stmt_init($link);
@@ -51,8 +50,7 @@ require_once 'skipifconnectfailure.inc';
5150
require_once 'clean_table.inc';
5251
?>
5352
--EXPECT--
54-
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
55-
mysqli_stmt object is already closed
53+
mysqli_stmt_attr_get(): Argument #2 ($attribute) must be one of MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH or STMT_ATTR_CURSOR_TYPE
5654
mysqli_stmt object is already closed
5755
mysqli_stmt object is already closed
5856
done!

ext/mysqli/tests/mysqli_stmt_attr_get_prefetch.phpt

Lines changed: 0 additions & 30 deletions
This file was deleted.

ext/mysqli/tests/mysqli_stmt_attr_set.phpt

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -160,63 +160,6 @@ require_once 'skipifconnectfailure.inc';
160160
var_dump($results2);
161161
}
162162

163-
164-
//
165-
// MYSQLI_STMT_ATTR_PREFETCH_ROWS
166-
//
167-
168-
$stmt = mysqli_stmt_init($link);
169-
$stmt->prepare("SELECT id, label FROM test");
170-
// Invalid prefetch value
171-
try {
172-
$stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 0);
173-
} catch (\ValueError $e) {
174-
echo $e->getMessage() . \PHP_EOL;
175-
}
176-
177-
if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 1)))
178-
printf("[020] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
179-
$stmt->execute();
180-
$id = $label = NULL;
181-
$stmt->bind_result($id, $label);
182-
$results = array();
183-
while ($stmt->fetch())
184-
$results[$id] = $label;
185-
$stmt->close();
186-
if (empty($results))
187-
printf("[021] Results should not be empty, subsequent tests will probably fail!\n");
188-
189-
/* prefetch is not supported
190-
$stmt = mysqli_stmt_init($link);
191-
$stmt->prepare("SELECT label FROM test");
192-
if (false !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, -1)))
193-
printf("[022] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
194-
$stmt->close();
195-
196-
$stmt = mysqli_stmt_init($link);
197-
$stmt->prepare("SELECT label FROM test");
198-
if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, PHP_INT_MAX)))
199-
printf("[023] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
200-
$stmt->close();
201-
202-
$stmt = mysqli_stmt_init($link);
203-
$stmt->prepare("SELECT id, label FROM test");
204-
if (true !== ($tmp = $stmt->attr_set(MYSQLI_STMT_ATTR_PREFETCH_ROWS, 2)))
205-
printf("[024] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
206-
$stmt->execute();
207-
$id = $label = NULL;
208-
$stmt->bind_result($id, $label);
209-
$results2 = array();
210-
while ($stmt->fetch())
211-
$results2[$id] = $label;
212-
$stmt->close();
213-
if ($results != $results2) {
214-
printf("[025] Results should not differ. Dumping both result sets.\n");
215-
var_dump($results);
216-
var_dump($results2);
217-
}
218-
*/
219-
220163
mysqli_close($link);
221164
print "done!";
222165
?>
@@ -226,9 +169,8 @@ require_once 'skipifconnectfailure.inc';
226169
?>
227170
--EXPECT--
228171
Error: mysqli_stmt object is not fully initialized
229-
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
172+
mysqli_stmt_attr_set(): Argument #2 ($attribute) must be one of MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH or STMT_ATTR_CURSOR_TYPE
230173
mysqli_stmt::attr_set(): Argument #2 ($value) must be 0 or 1 for attribute MYSQLI_STMT_ATTR_UPDATE_MAX_LENGTH
231174
bool(true)
232175
mysqli_stmt::attr_set(): Argument #2 ($value) must be one of the MYSQLI_CURSOR_TYPE_* constants for attribute MYSQLI_STMT_ATTR_CURSOR_TYPE
233-
mysqli_stmt::attr_set(): Argument #2 ($value) must be greater than 0 for attribute MYSQLI_STMT_ATTR_PREFETCH_ROWS
234176
done!

ext/mysqlnd/mysqlnd_driver.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,6 @@ MYSQLND_METHOD(mysqlnd_object_factory, get_prepared_statement)(MYSQLND_CONN_DATA
206206
stmt->state = MYSQLND_STMT_INITTED;
207207
stmt->execute_cmd_buffer.length = MYSQLND_NET_CMD_BUFFER_MIN_SIZE;
208208
stmt->execute_cmd_buffer.buffer = mnd_emalloc(stmt->execute_cmd_buffer.length);
209-
stmt->prefetch_rows = MYSQLND_DEFAULT_PREFETCH_ROWS;
210209

211210
/*
212211
Mark that we reference the connection, thus it won't be

ext/mysqlnd/mysqlnd_enum_n_def.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -399,8 +399,7 @@ typedef enum param_bind_flags
399399
enum mysqlnd_stmt_attr
400400
{
401401
STMT_ATTR_UPDATE_MAX_LENGTH,
402-
STMT_ATTR_CURSOR_TYPE,
403-
STMT_ATTR_PREFETCH_ROWS
402+
STMT_ATTR_CURSOR_TYPE
404403
};
405404

406405
enum myslqnd_cursor_type

ext/mysqlnd/mysqlnd_ps.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1552,18 +1552,6 @@ MYSQLND_METHOD(mysqlnd_stmt, attr_set)(MYSQLND_STMT * const s,
15521552
stmt->flags = ival;
15531553
break;
15541554
}
1555-
case STMT_ATTR_PREFETCH_ROWS: {
1556-
unsigned long ival = *(unsigned long *) value;
1557-
if (ival == 0) {
1558-
ival = MYSQLND_DEFAULT_PREFETCH_ROWS;
1559-
} else if (ival > 1) {
1560-
SET_CLIENT_ERROR(stmt->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
1561-
DBG_INF("FAIL");
1562-
DBG_RETURN(FAIL);
1563-
}
1564-
stmt->prefetch_rows = ival;
1565-
break;
1566-
}
15671555
default:
15681556
SET_CLIENT_ERROR(stmt->error_info, CR_NOT_IMPLEMENTED, UNKNOWN_SQLSTATE, "Not implemented");
15691557
DBG_RETURN(FAIL);
@@ -1596,10 +1584,6 @@ MYSQLND_METHOD(mysqlnd_stmt, attr_get)(const MYSQLND_STMT * const s,
15961584
*(unsigned long *) value = stmt->flags;
15971585
DBG_INF_FMT("value=%lu", *(unsigned long *) value);
15981586
break;
1599-
case STMT_ATTR_PREFETCH_ROWS:
1600-
*(unsigned long *) value = stmt->prefetch_rows;
1601-
DBG_INF_FMT("value=%lu", *(unsigned long *) value);
1602-
break;
16031587
default:
16041588
DBG_RETURN(FAIL);
16051589
}

ext/mysqlnd/mysqlnd_structs.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1267,7 +1267,6 @@ struct st_mysqlnd_stmt_data
12671267
MYSQLND_ERROR_INFO error_info_impl;
12681268

12691269
bool update_max_length;
1270-
zend_ulong prefetch_rows;
12711270

12721271
bool cursor_exists;
12731272
mysqlnd_stmt_use_or_store_func default_rset_handler;

0 commit comments

Comments
 (0)