C API Function Descriptions
2190
mysql_thread_id()
, do not use it. To get the connection ID, execute a
SELECT CONNECTION_ID()
query and retrieve the result.
Return Values
The thread ID of the current connection.
Errors
None.
20.6.6.71.
mysql_use_result()
MYSQL_RES *mysql_use_result(MYSQL *mysql)
Description
After invoking
mysql_query()
or
mysql_real_query()
, you must call
mysql_store_result()
or
mysql_use_result()
for every statement that successfully produces a result set (
SELECT
,
SHOW
,
DESCRIBE
,
EXPLAIN
,
CHECK TABLE
, and so forth). You must also call
mysql_free_result()
after
you are done with the result set.
mysql_use_result()
initiates a result set retrieval but does not actually read the result set into the
client like
mysql_store_result()
does. Instead, each row must be retrieved individually by making
calls to
mysql_fetch_row()
. This reads the result of a query directly from the server without storing
it in a temporary table or local buffer, which is somewhat faster and uses much less memory than
mysql_store_result()
. The client allocates memory only for the current row and a communication
buffer that may grow up to
max_allowed_packet
[466]
bytes.
On the other hand, you shouldn't use
mysql_use_result()
if you are doing a lot of processing for
each row on the client side, or if the output is sent to a screen on which the user may type a
^S
(stop
scroll). This ties up the server and prevent other threads from updating any tables from which the data
is being fetched.
When using
mysql_use_result()
, you must execute
mysql_fetch_row()
until a
NULL
value is
returned, otherwise, the unfetched rows are returned as part of the result set for your next query. The C
API gives the error
Commands out of sync; you can't run this command now
if you forget
to do this!
You may not use
mysql_data_seek()
,
mysql_row_seek()
,
mysql_row_tell()
,
mysql_num_rows()
, or
mysql_affected_rows()
with a result returned from
mysql_use_result()
, nor may you issue other queries until
mysql_use_result()
has finished.
(However, after you have fetched all the rows,
mysql_num_rows()
accurately returns the number of
rows fetched.)
You must call
mysql_free_result()
once you are done with the result set.
When using the
libmysqld
embedded server, the memory benefits are essentially lost because
memory usage incrementally increases with each row retrieved until
mysql_free_result()
is
called.
Return Values
A
MYSQL_RES
result structure.
NULL
if an error occurred.
Errors
mysql_use_result()
resets
mysql_error()
and
mysql_errno()
if it succeeds.
•
CR_COMMANDS_OUT_OF_SYNC
[2942]
Commands were executed in an improper order.
Содержание 5.0
Страница 1: ...MySQL 5 0 Reference Manual ...
Страница 18: ...xviii ...
Страница 60: ...40 ...
Страница 396: ...376 ...
Страница 578: ...558 ...
Страница 636: ...616 ...
Страница 844: ...824 ...
Страница 1234: ...1214 ...
Страница 1426: ...MySQL Proxy Scripting 1406 The following diagram shows an overview of the classes exposed by MySQL Proxy ...
Страница 1427: ...MySQL Proxy Scripting 1407 ...
Страница 1734: ...1714 ...
Страница 1752: ...1732 ...
Страница 1783: ...Configuring Connector ODBC 1763 ...
Страница 1793: ...Connector ODBC Examples 1773 ...
Страница 1839: ...Connector Net Installation 1819 2 You must choose the type of installation to perform ...
Страница 1842: ...Connector Net Installation 1822 5 Once the installation has been completed click Finish to exit the installer ...
Страница 1864: ...Connector Net Visual Studio Integration 1844 Figure 20 24 Debug Stepping Figure 20 25 Function Stepping 1 of 2 ...
Страница 2850: ...2830 ...
Страница 2854: ...2834 ...
Страница 2928: ...2908 ...
Страница 3000: ...2980 ...
Страница 3122: ...3102 ...
Страница 3126: ...3106 ...
Страница 3174: ...3154 ...
Страница 3232: ...3212 ...