From ea78c5744b958ddcd6946faf5ca24f115275a366 Mon Sep 17 00:00:00 2001 From: Sergei Golubchik Date: Mon, 22 Jan 2018 20:10:57 +0100 Subject: [PATCH] MDEV-13988 connect.drop-open-error fails PCOLRES::Length is the length in characters, not in bytes (because it's printed as length in "VARCHAR(N)"). So convert it into characters using cs->mbmaxlen. --- storage/connect/myconn.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp index 08bb24e14df..fe00f6a1eab 100644 --- a/storage/connect/myconn.cpp +++ b/storage/connect/myconn.cpp @@ -933,8 +933,9 @@ PQRYRES MYSQLC::GetResult(PGLOBAL g, bool pdb) crp->Prec = (crp->Type == TYPE_DOUBLE || crp->Type == TYPE_DECIM) ? fld->decimals : 0; - crp->Length = MY_MAX(fld->length, fld->max_length); - crp->Clen = GetTypeSize(crp->Type, crp->Length); + CHARSET_INFO *cs= get_charset(fld->charsetnr, MYF(0)); + crp->Clen = GetTypeSize(crp->Type, fld->length); + crp->Length = fld->length / (cs ? cs->mbmaxlen : 1); uns = (fld->flags & (UNSIGNED_FLAG | ZEROFILL_FLAG)) ? true : false; if (!(crp->Kdata = AllocValBlock(g, NULL, crp->Type, m_Rows,