summaryrefslogtreecommitdiff
path: root/libmysql/libmysql.c
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2004-12-15 01:37:22 +0300
committerunknown <konstantin@mysql.com>2004-12-15 01:37:22 +0300
commit83fce55a3ae79c0033e372cb7ec48a3248307d6e (patch)
treef6691f78f66d284205393bb523fdc5586ae82c81 /libmysql/libmysql.c
parentd9b62f824b15803a1474e29314967b5118481b5f (diff)
downloadmariadb-git-83fce55a3ae79c0033e372cb7ec48a3248307d6e.tar.gz
A fix of return value of mysql_stmt_bind_result() and cleanup.
include/errmsg.h: New libmysql error status code CR_NO_STMT_METADATA libmysql/errmsg.c: Error message for CR_STMT_NO_METADATA. Adding an empty line to shorten further diffs when new error messages are added (as suggested by Monty). libmysql/libmysql.c: Return error from mysql_stmt_bind_result() if the statement contains no metadata. A few comments fixed. tests/client_test.c: Tests fixed: mysql_stmt_bind_result now returns error if there is no metadata.
Diffstat (limited to 'libmysql/libmysql.c')
-rw-r--r--libmysql/libmysql.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 8989dc18fd7..a71e99a5642 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -2139,12 +2139,12 @@ static void update_stmt_fields(MYSQL_STMT *stmt)
DESCRIPTION
This function should be used after mysql_stmt_execute().
You can safely check that prepared statement has a result set by calling
- mysql_stmt_num_fields(): if number of fields is not zero, you can call
+ mysql_stmt_field_count(): if number of fields is not zero, you can call
this function to get fields metadata.
Next steps you may want to make:
- find out number of columns in result set by calling
mysql_num_fields(res) (the same value is returned by
- mysql_stmt_num_fields)
+ mysql_stmt_field_count())
- fetch metadata for any column with mysql_fetch_field,
mysql_fetch_field_direct, mysql_fetch_fields, mysql_field_seek.
- free returned MYSQL_RES structure with mysql_free_result.
@@ -3882,11 +3882,10 @@ my_bool STDCALL mysql_stmt_bind_result(MYSQL_STMT *stmt, MYSQL_BIND *bind)
if (!bind_count)
{
- if ((int) stmt->state < (int) MYSQL_STMT_PREPARE_DONE)
- {
- set_stmt_error(stmt, CR_NO_PREPARE_STMT, unknown_sqlstate);
- }
- DBUG_RETURN(0);
+ int errorcode= (int) stmt->state < (int) MYSQL_STMT_PREPARE_DONE ?
+ CR_NO_PREPARE_STMT : CR_NO_STMT_METADATA;
+ set_stmt_error(stmt, errorcode, unknown_sqlstate);
+ DBUG_RETURN(1);
}
/*
@@ -4278,7 +4277,7 @@ static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data)
row+= (stmt->field_count+9)/8; /* skip null bits */
bit= 4; /* first 2 bits are reserved */
- /* Go throw all fields and calculate metadata */
+ /* Go through all fields and calculate metadata */
for (bind= stmt->bind, end= bind + stmt->field_count, field= stmt->fields ;
bind < end ;
bind++, field++)