summaryrefslogtreecommitdiff
path: root/sql/protocol.cc
diff options
context:
space:
mode:
authorholyfoot@deer.(none) <>2006-01-04 14:20:28 +0400
committerholyfoot@deer.(none) <>2006-01-04 14:20:28 +0400
commite8697cf428e59bc14e69d5b1ce1569b8d42e02d9 (patch)
treebcb306f8c631b6b3153296059aae11b7e290ded7 /sql/protocol.cc
parent795f744c5f1ba2d427128a7ecd3e12f1fe3cc0ff (diff)
downloadmariadb-git-e8697cf428e59bc14e69d5b1ce1569b8d42e02d9.tar.gz
Big patch to make embedded-server working in 5.x
Now it supports queries returning several results (particularly important with the SP)
Diffstat (limited to 'sql/protocol.cc')
-rw-r--r--sql/protocol.cc82
1 files changed, 43 insertions, 39 deletions
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 0a1b42f5236..98cded56871 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -29,6 +29,7 @@
static const unsigned int PACKET_BUFFER_EXTRA_ALLOC= 1024;
static void write_eof_packet(THD *thd, NET *net);
+void net_send_error_packet(THD *thd, uint sql_errno, const char *err);
#ifndef EMBEDDED_LIBRARY
bool Protocol::net_store_data(const char *from, uint length)
@@ -56,10 +57,6 @@ bool Protocol_prep::net_store_data(const char *from, uint length)
void net_send_error(THD *thd, uint sql_errno, const char *err)
{
-#ifndef EMBEDDED_LIBRARY
- uint length;
- char buff[MYSQL_ERRMSG_SIZE+2], *pos;
-#endif
NET *net= &thd->net;
bool generate_warning= thd->killed != THD::KILL_CONNECTION;
DBUG_ENTER("net_send_error");
@@ -106,42 +103,8 @@ void net_send_error(THD *thd, uint sql_errno, const char *err)
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_ERROR, sql_errno, err);
}
-#ifdef EMBEDDED_LIBRARY
- net->last_errno= sql_errno;
- strmake(net->last_error, err, sizeof(net->last_error)-1);
- strmov(net->sqlstate, mysql_errno_to_sqlstate(sql_errno));
-#else
-
- if (net->vio == 0)
- {
- if (thd->bootstrap)
- {
- /* In bootstrap it's ok to print on stderr */
- fprintf(stderr,"ERROR: %d %s\n",sql_errno,err);
- }
- DBUG_VOID_RETURN;
- }
+ net_send_error_packet(thd, sql_errno, err);
- if (net->return_errno)
- { // new client code; Add errno before message
- int2store(buff,sql_errno);
- pos= buff+2;
- if (thd->client_capabilities & CLIENT_PROTOCOL_41)
- {
- /* The first # is to make the protocol backward compatible */
- buff[2]= '#';
- pos= strmov(buff+3, mysql_errno_to_sqlstate(sql_errno));
- }
- length= (uint) (strmake(pos, err, MYSQL_ERRMSG_SIZE-1) - buff);
- err=buff;
- }
- else
- {
- length=(uint) strlen(err);
- set_if_smaller(length,MYSQL_ERRMSG_SIZE-1);
- }
- VOID(net_write_command(net,(uchar) 255, "", 0, (char*) err,length));
-#endif /* EMBEDDED_LIBRARY*/
thd->is_fatal_error=0; // Error message is given
thd->net.report_error= 0;
@@ -430,6 +393,47 @@ bool send_old_password_request(THD *thd)
return my_net_write(net, eof_buff, 1) || net_flush(net);
}
+
+void net_send_error_packet(THD *thd, uint sql_errno, const char *err)
+{
+ NET *net= &thd->net;
+ uint length;
+ char buff[MYSQL_ERRMSG_SIZE+2], *pos;
+
+ DBUG_ENTER("send_error_packet");
+
+ if (net->vio == 0)
+ {
+ if (thd->bootstrap)
+ {
+ /* In bootstrap it's ok to print on stderr */
+ fprintf(stderr,"ERROR: %d %s\n",sql_errno,err);
+ }
+ DBUG_VOID_RETURN;
+ }
+
+ if (net->return_errno)
+ { // new client code; Add errno before message
+ int2store(buff,sql_errno);
+ pos= buff+2;
+ if (thd->client_capabilities & CLIENT_PROTOCOL_41)
+ {
+ /* The first # is to make the protocol backward compatible */
+ buff[2]= '#';
+ pos= strmov(buff+3, mysql_errno_to_sqlstate(sql_errno));
+ }
+ length= (uint) (strmake(pos, err, MYSQL_ERRMSG_SIZE-1) - buff);
+ err=buff;
+ }
+ else
+ {
+ length=(uint) strlen(err);
+ set_if_smaller(length,MYSQL_ERRMSG_SIZE-1);
+ }
+ VOID(net_write_command(net,(uchar) 255, "", 0, (char*) err,length));
+ DBUG_VOID_RETURN;
+}
+
#endif /* EMBEDDED_LIBRARY */
/*