MySQL is optimized for the 'delete all records in a table' case. A side
effect of this optimization is that MySQL will return zero for the number
of rows affected in this situation. Doing a 'select count(*) from the_table'
before deleting all records will give you a value for the number of rows
affected, though this value may change between the SELECT and and DELETE
since MySQL 3.20.X does not support table locking. This is fixed in
version 3.21.X
SYNOPSIS:
int mysql_eof(MYSQL_RES *)
DESCRIPTION:
Returns a value != 0 if the last call to mysql_fetch_row
returned nothing because the end of the result set has been reached.
mysql_errorSYNOPSIS:
char *mysql_error(MYSQL *mysql)
DESCRIPTION:
mysql_fetch_fieldSYNOPSIS:
DESCRIPTION:
mysql_fetch_lengthsSYNOPSIS:
DESCRIPTION:
Returns the length of all columns in a query result set. If you
plan on retrieving data that contains a \0 you must use this function
to get the actual length of the field value.
mysql_fetch_rowSYNOPSIS:
DESCRIPTION:
Fetch the 'next' row in the query result. Will return a NULL pointer
when all rows have been retrieved.
mysql_field_seekSYNOPSIS:
void mysql_field_seek(MYSQL_RES *result, int field)
DESCRIPTION:
Put the column cursor on column number field, which
should be within the range from 0 to mysql_num_fields(MYSQL_RES*)-1
mysql_free_resultSYNOPSIS:
DESCRIPTION:
Free memory used to store a query result. Should be called whenever
you have finished using the results of a mysql_store_result() call
mysql_get_client_infoSYNOPSIS:
DESCRIPTION:
This function simply returns a string containing version information
for the client library currently in use.
mysql_get_host_infoSYNOPSIS:
DESCRIPTION:
mysql_get_proto_infoSYNOPSIS:
DESCRIPTION:
Get protocol version used by connection. MySQL implements dynamic
protocols based on client capabilities. In version 3.20.X this doesn't
really do anything, but in future versions it will for example allow one
client to connect using the current protocol, while another connects
using encryption and compression.
mysql_get_server_infoSYNOPSIS:
DESCRIPTION:
mysql_insert_idSYNOPSIS:
int mysql_insert_id(MYSQL *mysql)
DESCRIPTION:
Returns ID generated for AUTO_INCREMENT field on result variable 'res'.
mysql_list_dbsSYNOPSIS:
MYSQL_RES *mysql_list_dbs(MYSQL *mysql, const char *wild);
DESCRIPTION:
Provided to ease porting of mSQL applications.
Similar to doing 'SHOW databases [ LIKE wild-card ]' as a
query.
mysql_list_fieldsSYNOPSIS:
MYSQL_RES *mysql_list_fields(MYSQL *mysql, const char *table, const
char *wild);
DESCRIPTION:
Provided to ease porting of mSQL applications.
Similar to doing 'SHOW fields [FROM table] [FROM database] [LIKE
wild-card]' in a query.
mysql_list_processesSYNOPSIS:
DESCRIPTION:
Get a list of the thread currently running on the MySQL database engine.
You must have process privileges.
mysql_list_tablesSYNOPSIS:
MYSQL_RES *mysql_list_tables(MYSQL *mysql, const char *wild);
DESCRIPTION:
Provided to ease porting of mSQL applications.
Similar to doing 'SHOW tables [FROM database]' as a query.
mysql_num_fieldsSYNOPSIS:
DESCRIPTION:
EXAMPLE:
MYSQL mysql;
MYSQL_RES *result;
int fields;
if ( mysql_query( &mysql, "SELECT * FROM emp_master" ) == 0 )
{
result = mysql_store_result( &mysql );
if ( result != NULL )
{
fields = mysql_num_fields( result );
printf( "Retrieved %u fields\n", fields );
}
else
printf( "Query failed\n" );
}
else
abort();
SEE ALSO:
mysql_num_rowsSYNOPSIS:
DESCRIPTION:
EXAMPLE:
MYSQL mysql;
MYSQL_RES *result;
int rows;
if ( mysql_query( &mysql, "SELECT * FROM emp_master" ) == 0 )
{
result = mysql_store_result( &mysql );
if ( result != NULL )
{
rows = mysql_num_rows( result );
printf( "Retrieved %u rows\n", rows );
}
else
printf( "Query failed\n" );
}
else
abort();
SEE ALSO:
mysql_querySYNOPSIS:
int mysql_query(MYSQL *mysql, const char *query);
DESCRIPTION:
Executes the SQL query pointed to by query on the database
pointed to by mysql. This function will return zero if the query
executed properly. A non-zero result indicates an error. A call to
mysql_error will retrieve the error message.
Calling mysql_num_rows will give you the number of rows returned
by the query.
If you have an AUTO_INCREMENT field in the table being updated and
you are doing an INSERT, you can find the newly assigned field value by
checking mysql_insert_id.
mysql_real_querySYNOPSIS:
int mysql_real_query(MYSQL *mysql, const char *query, uint length);
DESCRIPTION:
This function is called by mysql_query after it does a
strlen function call to calculate the length of the query string.
It could be used if your program allocates a fixed buffer for the query
string.
You'll have to use this function if you have data with un-escaped \0 values.
mysql_reloadSYNOPSIS:
DESCRIPTION:
Have the MySQL database engine reload the user permissions table, flush
all caches and close all open tables not in use. This should be done before
running isamchk on any table.
Requires user to have reload privileges.
mysql_select_dbSYNOPSIS:
int mysql_select_db(MYSQL *mysql, const char *db);
DESCRIPTION:
Attempt to connect to the database pointed to by db, on the
machine pointed to by mysql. The MySQL database engine on the
server will use the login and password contained in mysql to
authenticate the connection.
A successful call to mysql_connect is necessary before
mysql_select_db can be used.
In general mysql_select_db must be called successfully before
attempting to query a database. The exceptions are queries such as the
following.
SHOW DATABASES like 'A%';
SELECT 1+1; # SELECT without using tables.
mysql_shutdownSYNOPSIS:
DESCRIPTION:
mysql_statSYNOPSIS:
DESCRIPTION:
Returns the info similar to 'mysqladmin version' as a character
string. This includes uptime in seconds, running threads, questions, reloads
and open tables information. This is essentially the same as the mysqladmin
programs stat option.
mysql_store_resultSYNOPSIS:
DESCRIPTION:
Reads the result to the client. You must use this or mysql_use_result()
to get the result from the server. You must always use mysql_store_result()
or mysql_use_result() after you have executed a successful query.
mysql_store_result() returns NULL on error or if the statement
didn't return any data. You can check for errors with:
if (!(result=mysql_store_result(&mysql)) && mysql_num_fields(&mysql))
fputs(mysql_error(&mysql),stderr);
A call to mysql_free_result() must be made when you're done to free memory.
mysql_use_resultSYNOPSIS:
DESCRIPTION:
The same as mysql_store_result(), except that the result is
fetched dynamically from the server for each 'mysql_fetch_row()'.
This should not be used on interactive applications since it ties up the
server. This helps to hold down the memory usage on the client side.