2003-05-31 15:15:46 +05:00
|
|
|
/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
|
|
|
|
|
|
|
extern const char *unknown_sqlstate;
|
2003-06-05 23:19:56 +03:00
|
|
|
extern const char *not_error_sqlstate;
|
2003-05-31 15:15:46 +05:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2006-06-19 22:11:01 +05:00
|
|
|
extern CHARSET_INFO *default_client_charset_info;
|
2003-05-31 15:15:46 +05:00
|
|
|
MYSQL_FIELD *unpack_fields(MYSQL_DATA *data,MEM_ROOT *alloc,uint fields,
|
|
|
|
my_bool default_value, uint server_capabilities);
|
|
|
|
void free_rows(MYSQL_DATA *cur);
|
|
|
|
void free_old_query(MYSQL *mysql);
|
|
|
|
void end_server(MYSQL *mysql);
|
|
|
|
my_bool mysql_reconnect(MYSQL *mysql);
|
2003-06-17 21:32:31 +05:00
|
|
|
void mysql_read_default_options(struct st_mysql_options *options,
|
|
|
|
const char *filename,const char *group);
|
2003-11-20 22:06:25 +02:00
|
|
|
my_bool
|
2003-09-17 15:18:18 +05:00
|
|
|
cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
|
|
|
|
const char *header, ulong header_length,
|
2006-06-01 17:06:42 +05:00
|
|
|
const char *arg, ulong arg_length, my_bool skip_check,
|
|
|
|
MYSQL_STMT *stmt);
|
A fix and a test case for Bug#15752 "Lost connection to MySQL server
when calling a SP from C API"
The bug was caused by lack of checks for misuse in mysql_real_query.
A stored procedure always returns at least one result, which is the
status of execution of the procedure itself.
This result, or so-called OK packet, is similar to a result
returned by INSERT/UPDATE/CREATE operations: it contains the overall
status of execution, the number of affected rows and the number of
warnings. The client test program attached to the bug did not read this
result and ivnoked the next query. In turn, libmysql had no check for
such scenario and mysql_real_query was simply trying to send that query
without reading the pending response, thus messing up the communication
protocol.
The fix is to return an error from mysql_real_query when it's called
prior to retrieval of all pending results.
client/mysqlbinlog.cc:
net_safe_read -> cli_safe_read
include/mysql.h:
Remove a private function from the public header.
include/mysql_com.h:
Remove a define that is never used.
include/sql_common.h:
Add a declaration for cli_safe_read - a function that reads one packet
from the server.
libmysql/libmysql.c:
net_safe_read -> cli_safe_read
Return CR_COMMANDS_OUT_OF_SYNC on attempt to execute a statement
using a connection which has pending result sets.
sql-common/client.c:
Actual fix for Bug#15752: if the server has pending result sets for
the client, return CR_COMMANDS_OUT_OF_SYNC on attempt to execute
another query. Similarly to the behaviour of mysql_use_result(),
multiple result sets block the connection and must be fetched
before it can be used for another query.
This uncovered an error in the protocol: the server doesn't drop
SERVER_MORE_RESULTS_EXISTS status flag upon an error, so in case of
a multi-query like SELECT 1; SELECT syntax_error; SELECT 2;
the client has no way to know that the server won't ever come to
execution of the third query and won't return any result sets for it.
For now, fix it in cli_safe_read, as a proper fix requires extension
of the client-server protocol.
sql/protocol.cc:
Remove a name that is never used.
sql/slave.cc:
net_safe_read -> cli_safe_read
tests/mysql_client_test.c:
Make 'query' a local variable to avoid name clash.
Add a test case for Bug#15752 "Lost connection to MySQL server when
calling an SP from C API"
2006-07-24 14:56:53 +04:00
|
|
|
unsigned long cli_safe_read(MYSQL *mysql);
|
2003-09-17 15:18:18 +05:00
|
|
|
void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode,
|
|
|
|
const char *sqlstate);
|
2004-03-12 18:53:45 +03:00
|
|
|
void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate);
|
2003-05-31 15:15:46 +05:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define protocol_41(A) ((A)->server_capabilities & CLIENT_PROTOCOL_41)
|
|
|
|
|