From 5c7949af6b3e927854b14889940483b827553197 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 7 Dec 2004 19:12:29 +0200 Subject: Fix for a bug #6996 BitKeeper/etc/ignore: Added analyse.test client/mysqladmin.c to the ignore list libmysql/libmysql.c: Fix for a bug #6996 This fix enables that after all rows are read from a buffered result, mysql_stmt_data_seek(stmt,0) can rewind a counter to the beginning, so that rows can be re-fetched. tests/client_test.c: Addition of a test for fix of the bug #6996 in client_test.c --- libmysql/libmysql.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libmysql') diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index cb20c5181a8..99fa0299de9 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -4413,6 +4413,12 @@ mysql_stmt_data_seek(MYSQL_STMT *stmt, my_ulonglong row) for (; tmp && row; --row, tmp= tmp->next) ; stmt->data_cursor= tmp; + if (!row && tmp) + { + /* Rewind the counter */ + stmt->read_row_func= stmt_read_row_buffered; + stmt->state= MYSQL_STMT_EXECUTE_DONE; + } DBUG_VOID_RETURN; } -- cgit v1.2.1 From 111fa31f616a87435a844b9a0d5ad16ec4da8382 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 10 Dec 2004 20:07:00 +0400 Subject: A fix (bug #7129: Test failure: 'type_ranges' when using '--ps-protocol' bug #7126: Test failure: 'func_str' when using '--ps-protocol' bug #7130: Test failure: 'type_uint' when using '--ps-protocol'). --- libmysql/libmysql.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'libmysql') diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 99fa0299de9..8989dc18fd7 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -3663,8 +3663,8 @@ static void fetch_result_with_conversion(MYSQL_BIND *param, MYSQL_FIELD *field, case MYSQL_TYPE_INT24: /* mediumint is sent as 4 bytes int */ case MYSQL_TYPE_LONG: { - long value= sint4korr(*row); - longlong data= field_is_unsigned ? (longlong) (unsigned long) value : + int32 value= sint4korr(*row); + longlong data= field_is_unsigned ? (longlong) (uint32) value : (longlong) value; fetch_long_with_conversion(param, field, data); *row+= 4; -- cgit v1.2.1 From 83fce55a3ae79c0033e372cb7ec48a3248307d6e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 15 Dec 2004 01:37:22 +0300 Subject: 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. --- libmysql/errmsg.c | 12 +++++++++--- libmysql/libmysql.c | 15 +++++++-------- 2 files changed, 16 insertions(+), 11 deletions(-) (limited to 'libmysql') diff --git a/libmysql/errmsg.c b/libmysql/errmsg.c index 710bf4ccd8d..5fa94e5ff0d 100644 --- a/libmysql/errmsg.c +++ b/libmysql/errmsg.c @@ -78,7 +78,9 @@ const char *client_errors[]= "Invalid connection handle", "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)", "Row retrieval was canceled by mysql_stmt_close() call", - "Attempt to read column without prior row fetch" + "Attempt to read column without prior row fetch", + "Prepared statement contains no metadata", + "" }; /* Start of code added by Roberto M. Serqueira - martinsc@uol.com.br - 05.24.2001 */ @@ -137,7 +139,9 @@ const char *client_errors[]= "Invalid connection handle", "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)", "Row retrieval was canceled by mysql_stmt_close() call", - "Attempt to read column without prior row fetch" + "Attempt to read column without prior row fetch", + "Prepared statement contains no metadata", + "" }; #else /* ENGLISH */ @@ -194,7 +198,9 @@ const char *client_errors[]= "Invalid connection handle", "Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled)", "Row retrieval was canceled by mysql_stmt_close() call", - "Attempt to read column without prior row fetch" + "Attempt to read column without prior row fetch", + "Prepared statement contains no metadata", + "" }; #endif 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++) -- cgit v1.2.1 From 33959dc1a4fa638e67bb98892a466692b9ba402e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 15 Dec 2004 12:36:01 +0100 Subject: fix for bug #7285: Disable start of embedded server when need to connect to an external server with mysqld. libmysql/libmysql.c: fix for bug #7285: Disable start of embedded server when need to connect to an external server with libmysqld. Calling mysql_server_init with a negative value for argc will not start the embedded server. --- libmysql/libmysql.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'libmysql') diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index a71e99a5642..b180e86392d 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -158,7 +158,8 @@ int STDCALL mysql_server_init(int argc __attribute__((unused)), (void) signal(SIGPIPE, SIG_IGN); #endif #ifdef EMBEDDED_LIBRARY - result= init_embedded_server(argc, argv, groups); + if (argc > -1) + result= init_embedded_server(argc, argv, groups); #endif } #ifdef THREAD -- cgit v1.2.1