13.6.6.5 Restrictions on Server-Side Cursors对服务器端指针的约束

Server-side cursors are implemented in the C API using the mysql_stmt_attr_set() function. 服务器端指针在C API中使用mysql_stmt_attr_set()函数实现。The same implementation is used for cursors in stored routines. 存储例程中的指针也使用相同的实现。A server-side cursor enables a result set to be generated on the server side, but not transferred to the client except for those rows that the client requests. 服务器端指针允许在服务器端生成结果集,但除了客户端请求的那些行之外,结果集不会传输到客户端。For example, if a client executes a query but is only interested in the first row, the remaining rows are not transferred.例如,如果客户机执行一个查询,但只对第一行感兴趣,则不传输其余的行。

In MySQL, a server-side cursor is materialized into an internal temporary table. 在MySQL中,服务器端指针具体化为一个内部临时表。Initially, this is a MEMORY table, but is converted to a MyISAM table when its size exceeds the minimum value of the max_heap_table_size and tmp_table_size system variables. 最初,这是一个MEMORY表,但当它的大小超过max_heap_table_sizetmp_table_size系统变量的最小值时,它将转换为MyISAM表。The same restrictions apply to internal temporary tables created to hold the result set for a cursor as for other uses of internal temporary tables. 为保存指针的结果集而创建的内部临时表的限制与内部临时表的其他用途相同。See Section 8.4.4, “Internal Temporary Table Use in MySQL”. 请参阅第8.4.4节,“MySQL中的内部临时表使用”One limitation of the implementation is that for a large result set, retrieving its rows through a cursor might be slow.该实现的一个限制是,对于大型结果集,通过指针检索其行可能很慢。

Cursors are read only; you cannot use a cursor to update rows.指针是只读的;不能使用指针更新行。

UPDATE WHERE CURRENT OF and DELETE WHERE CURRENT OF are not implemented, because updatable cursors are not supported.未实现UPDATE WHERE CURRENT OFDELETE WHERE CURRENT OF,因为不支持可更新的指针。

Cursors are nonholdable (not held open after a commit).指针是不可保持的(提交后不保持打开状态)。

Cursors are asensitive.指针是非敏感的。

Cursors are nonscrollable.指针是不可滚动的。

Cursors are not named. The statement handler acts as the cursor ID.指针未命名。语句处理程序充当指针ID。

You can have open only a single cursor per prepared statement. 每个准备好的语句只能打开一个指针。If you need several cursors, you must prepare several statements.如果你需要几个指针,你必须准备几个语句。

You cannot use a cursor for a statement that generates a result set if the statement is not supported in prepared mode. 如果在准备模式下不支持生成结果集的语句,则不能对该语句使用指针。This includes statements such as CHECK TABLE, HANDLER READ, and SHOW BINLOG EVENTS.这包括CHECK TABLEHANDLER READSHOW BINLOG事件等语句。