summaryrefslogtreecommitdiff
path: root/sql-common/client.c
diff options
context:
space:
mode:
authoranozdrin/alik@quad.opbmk <>2008-03-18 13:51:17 +0300
committeranozdrin/alik@quad.opbmk <>2008-03-18 13:51:17 +0300
commitfa6ed3cf36c7bf98b5f0c5476bc1ced1a3b78b2c (patch)
treee96aaaaa6d8f3413c11e63aee2802003dfc5b2bc /sql-common/client.c
parenteac3a26efab4f3886ba68ed24cc1ddfc453dfa0e (diff)
parentb7f7c7dc35f954901335199c6bb31c749d5e236b (diff)
downloadmariadb-git-fa6ed3cf36c7bf98b5f0c5476bc1ced1a3b78b2c.tar.gz
Merge quad.opbmk:/mnt/raid/alik/MySQL/devel/5.1
into quad.opbmk:/mnt/raid/alik/MySQL/devel/5.1-rt-merged
Diffstat (limited to 'sql-common/client.c')
-rw-r--r--sql-common/client.c28
1 files changed, 24 insertions, 4 deletions
diff --git a/sql-common/client.c b/sql-common/client.c
index 596c9f6c448..63c746a3f5a 100644
--- a/sql-common/client.c
+++ b/sql-common/client.c
@@ -695,6 +695,16 @@ cli_safe_read(MYSQL *mysql)
strmake(net->sqlstate, pos+1, SQLSTATE_LENGTH);
pos+= SQLSTATE_LENGTH+1;
}
+ else
+ {
+ /*
+ The SQL state hasn't been received -- it should be reset to HY000
+ (unknown error sql state).
+ */
+
+ strmov(net->sqlstate, unknown_sqlstate);
+ }
+
(void) strmake(net->last_error,(char*) pos,
min((uint) len,(uint) sizeof(net->last_error)-1));
}
@@ -733,11 +743,12 @@ my_bool
cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
const uchar *header, ulong header_length,
const uchar *arg, ulong arg_length, my_bool skip_check,
- MYSQL_STMT *stmt __attribute__((unused)))
+ MYSQL_STMT *stmt)
{
NET *net= &mysql->net;
my_bool result= 1;
init_sigpipe_variables
+ my_bool stmt_skip= stmt ? stmt->state != MYSQL_STMT_INIT_DONE : FALSE;
DBUG_ENTER("cli_advanced_command");
/* Don't give sigpipe errors if the client doesn't want them */
@@ -745,7 +756,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
if (mysql->net.vio == 0)
{ /* Do reconnect if possible */
- if (mysql_reconnect(mysql))
+ if (mysql_reconnect(mysql) || stmt_skip)
DBUG_RETURN(1);
}
if (mysql->status != MYSQL_STATUS_READY ||
@@ -777,7 +788,7 @@ cli_advanced_command(MYSQL *mysql, enum enum_server_command command,
goto end;
}
end_server(mysql);
- if (mysql_reconnect(mysql))
+ if (mysql_reconnect(mysql) || stmt_skip)
goto end;
if (net_write_command(net,(uchar) command, header, header_length,
arg, arg_length))
@@ -1911,7 +1922,13 @@ CLI_MYSQL_REAL_CONNECT(MYSQL *mysql,const char *host, const char *user,
(int) have_tcpip));
if (mysql->options.protocol == MYSQL_PROTOCOL_MEMORY)
goto error;
- /* Try also with PIPE or TCP/IP */
+
+ /*
+ Try also with PIPE or TCP/IP. Clear the error from
+ create_shared_memory().
+ */
+
+ net_clear_error(net);
}
else
{
@@ -2521,6 +2538,9 @@ my_bool mysql_reconnect(MYSQL *mysql)
if (stmt->state != MYSQL_STMT_INIT_DONE)
{
stmt->mysql= 0;
+ stmt->last_errno= CR_SERVER_LOST;
+ strmov(stmt->last_error, ER(CR_SERVER_LOST));
+ strmov(stmt->sqlstate, unknown_sqlstate);
}
else
{