From 390597cf9a3baa330eba2013e2e1c1be744a19f0 Mon Sep 17 00:00:00 2001
From: unknown <venu@myvenu.com>
Date: Wed, 16 Apr 2003 16:47:01 -0700
Subject: [PATCH] Fix to have a reserved OK byte (prepare result)

sql/sql_prepare.cc:
  FFix to send a reserved OK byte on a prepared call
---
 libmysql/libmysql.c | 6 +++---
 sql/sql_prepare.cc  | 9 +++++----
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index cd3c567718c..c289867b85e 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -3925,9 +3925,9 @@ static my_bool read_prepare_result(MYSQL_STMT *stmt)
     DBUG_RETURN(1);
 
   pos= (uchar*) mysql->net.read_pos;
-  stmt->stmt_id= uint4korr(pos); pos+=4;
-  field_count=   uint2korr(pos); pos+=2;
-  param_count=   uint2korr(pos); pos+=2;
+  stmt->stmt_id= uint4korr(pos+1); pos+= 5;
+  field_count=   uint2korr(pos);   pos+= 2;
+  param_count=   uint2korr(pos);   pos+= 2;
 
   if (field_count != 0)
   {
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index c3e84849431..95ac57013da 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -145,10 +145,11 @@ void free_prep_stmt(PREP_STMT *stmt, TREE_FREE mode, void *not_used)
 static bool send_prep_stmt(PREP_STMT *stmt, uint columns)
 {
   NET  *net=&stmt->thd->net;
-  char buff[8];
-  int4store(buff, stmt->stmt_id);
-  int2store(buff+4, columns);
-  int2store(buff+6, stmt->param_count);
+  char buff[9];
+  buff[0]= 0;
+  int4store(buff+1, stmt->stmt_id);
+  int2store(buff+5, columns);
+  int2store(buff+7, stmt->param_count);
 #ifndef EMBEDDED_LIBRARY
   /* This should be fixed to work with prepared statements
    */
-- 
2.30.9