From 9dff84347d6cb758c0027501c58345ef877773a3 Mon Sep 17 00:00:00 2001
From: Konstantin Osipov <kostja@sun.com>
Date: Fri, 9 Oct 2009 13:06:41 +0400
Subject: [PATCH] Backport to 5.4 the following changesets:

revno: 2476.785.24
committer: kostja@bodhi.(none)
timestamp: Tue 2007-10-16 20:19:00 +0400
message:
  Reflect a rename of a member in the client ABI (a compatible change).
----------------------------------------------------------
revno: 2476.423.26
committer: kostja@bodhi.(none)
timestamp: Tue 2007-10-16 20:12:37 +0400
message:
  Update the client ABI to reflect member rename
  (this is a backward-compatible change).
----------------------------------------------------------
revno: 2476.785.22
committer: kostja@bodhi.(none)
timestamp: Tue 2007-10-16 19:37:25 +0400
message:
  Remove some remains of support of 3.22 protocol. This was in fact dead code,
  since the option to talk 3.22 protocol was removed in 4.1 and there
  is no other protocol negotiation mechanism besides this option.

include/mysql.h.pp:
  Update ABI.
include/mysql_com.h:
  Remove an unused 3.22 protocol member.
sql/field.cc:
  Remove an unused 3.22 protocol check.
sql/mysqld.cc:
  Remove an unused 3.22 protocol check.
sql/net_serv.cc:
  Remove an unused 3.22 protocol variable initialization.
sql/protocol.cc:
  Remove an unused 3.22 protocol check.
---
 include/mysql.h.pp  | 10 +++++-----
 include/mysql_com.h | 10 +++++-----
 sql/field.cc        |  3 +--
 sql/mysqld.cc       |  3 ---
 sql/net_serv.cc     |  2 +-
 sql/protocol.cc     | 28 ++++++++++------------------
 6 files changed, 22 insertions(+), 34 deletions(-)

diff --git a/include/mysql.h.pp b/include/mysql.h.pp
index 633cde4113..fcbcea6187 100644
--- a/include/mysql.h.pp
+++ b/include/mysql.h.pp
@@ -28,15 +28,15 @@ typedef struct st_net {
   unsigned int *return_status;
   unsigned char reading_or_writing;
   char save_char;
-  my_bool unused0;
-  my_bool unused;
-  my_bool compress;
   my_bool unused1;
+  my_bool unused2;
+  my_bool compress;
+  my_bool unused3;
   unsigned char *query_cache_query;
   unsigned int last_errno;
   unsigned char error;
-  my_bool unused2;
-  my_bool return_errno;
+  my_bool unused4;
+  my_bool unused5;
   char last_error[512];
   char sqlstate[5 +1];
   void *extension;
diff --git a/include/mysql_com.h b/include/mysql_com.h
index db5a5eb874..672c359a6f 100644
--- a/include/mysql_com.h
+++ b/include/mysql_com.h
@@ -254,10 +254,10 @@ typedef struct st_net {
   unsigned int *return_status;
   unsigned char reading_or_writing;
   char save_char;
-  my_bool unused0; /* Please remove with the next incompatible ABI change. */
-  my_bool unused; /* Please remove with the next incompatible ABI change */
-  my_bool compress;
   my_bool unused1; /* Please remove with the next incompatible ABI change. */
+  my_bool unused2; /* Please remove with the next incompatible ABI change */
+  my_bool compress;
+  my_bool unused3; /* Please remove with the next incompatible ABI change. */
   /*
     Pointer to query object in query cache, do not equal NULL (0) for
     queries in cache that have not stored its results yet
@@ -270,8 +270,8 @@ typedef struct st_net {
   unsigned char *query_cache_query;
   unsigned int last_errno;
   unsigned char error; 
-  my_bool unused2; /* Please remove with the next incompatible ABI change. */
-  my_bool return_errno;
+  my_bool unused4; /* Please remove with the next incompatible ABI change. */
+  my_bool unused5; /* Please remove with the next incompatible ABI change. */
   /** Client library error message buffer. Actually belongs to struct MYSQL. */
   char last_error[MYSQL_ERRMSG_SIZE];
   /** Client library sqlstate buffer. Set along with the error message. */
diff --git a/sql/field.cc b/sql/field.cc
index 64b156fbdc..c71ecc253f 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -9828,8 +9828,7 @@ bool Create_field::init(THD *thd, char *fld_name, enum_field_types fld_type,
     break;
   case MYSQL_TYPE_DATE:
     /* Old date type. */
-    if (protocol_version != PROTOCOL_VERSION-1)
-      sql_type= MYSQL_TYPE_NEWDATE;
+    sql_type= MYSQL_TYPE_NEWDATE;
     /* fall trough */
   case MYSQL_TYPE_NEWDATE:
     length= 10;
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index e2d4de4dc5..0e76b5f565 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4892,9 +4892,6 @@ static void create_new_thread(THD *thd)
   NET *net=&thd->net;
   DBUG_ENTER("create_new_thread");
 
-  if (protocol_version > 9)
-    net->return_errno=1;
-
   /*
     Don't allow too many connections. We roughly check here that we allow
     only (max_connections + 1) connections.
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 7ff26c50af..7a830e0961 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -125,7 +125,7 @@ my_bool my_net_init(NET *net, Vio* vio)
 				     MYF(MY_WME))))
     DBUG_RETURN(1);
   net->buff_end=net->buff+net->max_packet;
-  net->error=0; net->return_errno=0; net->return_status=0;
+  net->error=0; net->return_status=0;
   net->pkt_nr=net->compress_pkt_nr=0;
   net->write_pos=net->read_pos = net->buff;
   net->last_error[0]=0;
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 7abc051af6..86f95755bd 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -394,27 +394,19 @@ bool net_send_error_packet(THD *thd, uint sql_errno, const char *err,
     DBUG_RETURN(FALSE);
   }
 
-  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= (uchar*) strmov((char*) buff+3, sqlstate);
-    }
-    length= (uint) (strmake((char*) pos, err, MYSQL_ERRMSG_SIZE-1) -
-                    (char*) buff);
-    err= (char*) buff;
-  }
-  else
+  int2store(buff,sql_errno);
+  pos= buff+2;
+  if (thd->client_capabilities & CLIENT_PROTOCOL_41)
   {
-    length=(uint) strlen(err);
-    set_if_smaller(length,MYSQL_ERRMSG_SIZE-1);
+    /* The first # is to make the protocol backward compatible */
+    buff[2]= '#';
+    pos= (uchar*) strmov((char*) buff+3, sqlstate);
   }
+  length= (uint) (strmake((char*) pos, err, MYSQL_ERRMSG_SIZE-1) -
+                  (char*) buff);
+  err= (char*) buff;
   DBUG_RETURN(net_write_command(net,(uchar) 255, (uchar*) "", 0, (uchar*) err,
-                         length));
+                                length));
 }
 
 #endif /* EMBEDDED_LIBRARY */
-- 
2.30.9