diff --git a/mysql-test/ndb/ndbcluster.sh b/mysql-test/ndb/ndbcluster.sh
index c09c013552eca19366b518df03c4b4cb89e00147..bc9aaf8caac039f3bfe4d2babb0f2e37bd8068c0 100644
--- a/mysql-test/ndb/ndbcluster.sh
+++ b/mysql-test/ndb/ndbcluster.sh
@@ -134,7 +134,7 @@ if [ ! -x "$exec_waiter" ]; then
 fi
 
 exec_mgmtclient="$exec_mgmtclient --no-defaults $NDB_MGM_EXTRA_OPTS"
-exec_mgmtsrvr="$exec_mgmtsrvr --no-defaults $NDB_MGMD_EXTRA_OPTS"
+exec_mgmtsrvr="$exec_mgmtsrvr $NDB_MGMD_EXTRA_OPTS"
 exec_ndb="$exec_ndb --no-defaults $NDBD_EXTRA_OPTS"
 exec_waiter="$exec_waiter --no-defaults"
 
diff --git a/ndb/tools/ndb_size.pl b/ndb/tools/ndb_size.pl
index e0085c619f07f63a1c3810735b27f421da0021af..c285a7590fdd903605007117f05cce791a5a5c21 100644
--- a/ndb/tools/ndb_size.pl
+++ b/ndb/tools/ndb_size.pl
@@ -147,7 +147,7 @@ foreach(@{$tables})
 	{
 	    my $fixed= 1+$size;
 	    my @dynamic=$dbh->selectrow_array("select avg(length(`"
-					      .$name.
+					      .$name
 					      ."`)) from `".$table.'`');
 	    $dynamic[0]=0 if !$dynamic[0];
 	    @realsize= ($fixed,$fixed,ceil($dynamic[0]));
diff --git a/sql/protocol.cc b/sql/protocol.cc
index 0a1b42f5236ce15c2626642b246ce6474a01aedb..15f7049ec2f3f994e9e9fc0c16d95cb9df1c8508 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -597,9 +597,23 @@ bool Protocol::send_fields(List<Item> *list, uint flags)
       else
       {
         /* With conversion */
+        uint max_char_len;
         int2store(pos, thd_charset->number);
-        uint char_len= field.length / item->collation.collation->mbmaxlen;
-        int4store(pos+2, char_len * thd_charset->mbmaxlen);
+        /*
+          For TEXT/BLOB columns, field_length describes the maximum data
+          length in bytes. There is no limit to the number of characters
+          that a TEXT column can store, as long as the data fits into
+          the designated space.
+          For the rest of textual columns, field_length is evaluated as
+          char_count * mbmaxlen, where character count is taken from the
+          definition of the column. In other words, the maximum number
+          of characters here is limited by the column definition.
+        */
+        max_char_len= (field.type >= (int) MYSQL_TYPE_TINY_BLOB &&
+                      field.type <= (int) MYSQL_TYPE_BLOB) ?
+                      field.length / item->collation.collation->mbminlen :
+                      field.length / item->collation.collation->mbmaxlen;
+        int4store(pos+2, max_char_len * thd_charset->mbmaxlen);
       }
       pos[6]= field.type;
       int2store(pos+7,field.flags);
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index c4da624537d3e32628ecb03d4abbcec3033aa648..eb0a7ade39068feaad1817193f6c4f848c2e4934 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -14638,7 +14638,70 @@ static void test_bug16144()
   mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (const void*) &flag);
   mysql_stmt_attr_get(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void*) &flag);
   DIE_UNLESS(flag == flag_orig);
+  mysql_stmt_close(stmt);
+}
+
+/*
+  Bug #15613: "libmysqlclient API function mysql_stmt_prepare returns wrong
+  field length"
+*/
+
+static void test_bug15613()
+{
+  MYSQL_STMT *stmt;
+  const char *stmt_text;
+  MYSQL_RES *metadata;
+  MYSQL_FIELD *field;
+  int rc;
+  myheader("test_bug15613");
 
+  /* I. Prepare the table */
+  rc= mysql_query(mysql, "set names latin1");
+  myquery(rc);
+  mysql_query(mysql, "drop table if exists t1");
+  rc= mysql_query(mysql,
+                  "create table t1 (t text character set utf8, "
+                                   "tt tinytext character set utf8, "
+                                   "mt mediumtext character set utf8, "
+                                   "lt longtext character set utf8, "
+                                   "vl varchar(255) character set latin1,"
+                                   "vb varchar(255) character set binary,"
+                                   "vu varchar(255) character set utf8)");
+  myquery(rc);
+
+  stmt= mysql_stmt_init(mysql);
+
+  /* II. Check SELECT metadata */
+  stmt_text= ("select t, tt, mt, lt, vl, vb, vu from t1");
+  rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+  metadata= mysql_stmt_result_metadata(stmt);
+  field= mysql_fetch_fields(metadata);
+  if (!opt_silent)
+  {
+    printf("Field lengths (client character set is latin1):\n"
+           "text character set utf8:\t\t%lu\n"
+           "tinytext character set utf8:\t\t%lu\n"
+           "mediumtext character set utf8:\t\t%lu\n"
+           "longtext character set utf8:\t\t%lu\n"
+           "varchar(255) character set latin1:\t%lu\n"
+           "varchar(255) character set binary:\t%lu\n"
+           "varchar(255) character set utf8:\t%lu\n",
+           field[0].length, field[1].length, field[2].length, field[3].length,
+           field[4].length, field[5].length, field[6].length);
+  }
+  DIE_UNLESS(field[0].length == 65535);
+  DIE_UNLESS(field[1].length == 255);
+  DIE_UNLESS(field[2].length == 16777215);
+  DIE_UNLESS(field[3].length == 4294967295UL);
+  DIE_UNLESS(field[4].length == 255);
+  DIE_UNLESS(field[5].length == 255);
+  DIE_UNLESS(field[6].length == 255);
+
+  /* III. Cleanup */
+  rc= mysql_query(mysql, "drop table t1");
+  myquery(rc);
+  rc= mysql_query(mysql, "set names default");
+  myquery(rc);
   mysql_stmt_close(stmt);
 }
 
@@ -14903,6 +14966,7 @@ static struct my_tests_st my_tests[]= {
   { "test_bug14845", test_bug14845 },
   { "test_bug15510", test_bug15510},
   { "test_bug16144", test_bug16144 },
+  { "test_bug15613", test_bug15613 },
   { 0, 0 }
 };