Commit 5158be8f authored by Narayanan V's avatar Narayanan V

Bug#44232 Error msg should be improved when collation not supported.

When a user selected an unsupported character set for an
IBMDB2I table, error 2501 or 2511 may have been returned,
giving the appearance of an internal programming error.

This patch consolidates these errors into a single descriptive
error message for the common case of an unsupported character
set.

The new error number is 2504 and indicates a user error.
The errors 2501 and 2511 remain to indicate cases of internal
programming errors.
parent a5184bb3
......@@ -268,8 +268,15 @@ static int32 getNewTextDesc(const int32 inType,
RESULT_INT32);
if (unlikely(arguments->base.result.s_int32.r_int32 < 0))
{
getErrTxt(DB2I_ERR_ILECALL,"QlgCvtTextDescToDesc",arguments->base.result.s_int32.r_int32);
DBUG_RETURN(DB2I_ERR_ILECALL);
if (arguments->base.result.s_int32.r_int32 == Qlg_InDescriptorNotFound)
{
DBUG_RETURN(DB2I_ERR_UNSUPP_CHARSET);
}
else
{
getErrTxt(DB2I_ERR_ILECALL,"QlgCvtTextDescToDesc",arguments->base.result.s_int32.r_int32);
DBUG_RETURN(DB2I_ERR_ILECALL);
}
}
// Store the conversion information into a cache entry
......@@ -428,8 +435,13 @@ int32 convertIANAToDb2Ccsid(const char* parmIANADesc, uint16* db2Ccsid)
int aixEncodingScheme;
int db2EncodingScheme;
rc = convertTextDesc(Qlg_TypeIANA, Qlg_TypeAS400CCSID, parmIANADesc, aixCcsidString);
if (rc != 0)
if (unlikely(rc))
{
if (rc == DB2I_ERR_UNSUPP_CHARSET)
getErrTxt(DB2I_ERR_UNSUPP_CHARSET, parmIANADesc);
return rc;
}
aixCcsid = atoi(aixCcsidString);
rc = getEncodingScheme(aixCcsid, aixEncodingScheme);
if (rc != 0)
......@@ -646,32 +658,38 @@ static int32 openNewConversion(enum_conversionDirection direction,
there equivalent iconv descriptions.
*/
rc = convertTextDesc(Qlg_TypeIANA, Qlg_TypeAix41, mysqlCSName, mysqlAix41Desc);
if (rc)
if (unlikely(rc))
{
if (rc == DB2I_ERR_UNSUPP_CHARSET)
getErrTxt(DB2I_ERR_UNSUPP_CHARSET, mysqlCSName);
DBUG_RETURN(rc);
}
CHARSET_INFO *cs= &my_charset_bin;
(uint)(cs->cset->long10_to_str)(cs,db2CcsidString,sizeof(db2CcsidString), 10, db2CCSID);
rc = convertTextDesc(Qlg_TypeAS400CCSID, Qlg_TypeAix41, db2CcsidString, db2Aix41Desc);
if (rc)
DBUG_RETURN(rc);
if (unlikely(rc))
{
if (rc == DB2I_ERR_UNSUPP_CHARSET)
getErrTxt(DB2I_ERR_UNSUPP_CHARSET, mysqlCSName);
DBUG_RETURN(rc);
}
/* Call iconv to open the conversion. */
if (direction == toDB2)
{
newConversion = iconv_open(db2Aix41Desc, mysqlAix41Desc);
if (newConversion == (iconv_t) -1)
{
getErrTxt(DB2I_ERR_ICONV_OPEN, mysqlAix41Desc, db2Aix41Desc, errno);
DBUG_RETURN(DB2I_ERR_ICONV_OPEN);
}
}
else
{
newConversion = iconv_open(mysqlAix41Desc, db2Aix41Desc);
if (newConversion == (iconv_t) -1)
{
getErrTxt(DB2I_ERR_ICONV_OPEN, db2Aix41Desc, mysqlAix41Desc, errno);
DBUG_RETURN(DB2I_ERR_ICONV_OPEN);
}
}
if (unlikely(newConversion == (iconv_t) -1))
{
getErrTxt(DB2I_ERR_UNSUPP_CHARSET, mysqlCSName);
DBUG_RETURN(DB2I_ERR_UNSUPP_CHARSET);
}
/* Insert the new conversion into the cache. */
......
......@@ -151,7 +151,7 @@ int ha_ibmdb2i::convertFieldChars(enum_conversionDirection direction,
if (unlikely(conversion == (iconv_t)(-1)))
{
return (DB2I_ERR_ICONV_OPEN);
return (DB2I_ERR_UNSUPP_CHARSET);
}
size_t initOLen= olen;
......@@ -670,6 +670,13 @@ int ha_ibmdb2i::getFieldTypeMapping(Field* field,
if (rtnCode)
return rtnCode;
}
// Check whether there is a character conversion available.
iconv_t temp;
int32 rc = getConversion(toDB2, fieldCharSet, db2Ccsid, temp);
if (unlikely(rc))
return rc;
sprintf(stringBuildBuffer, " CCSID %d ", db2Ccsid);
mapping.append(stringBuildBuffer);
}
......
......@@ -52,7 +52,7 @@ static const char* engineErrors[MAX_MSGSTRING] =
{"Error opening codeset conversion from %.64s to %.64s (errno = %d)"},
{"Invalid %-.10s name '%-.128s'"},
{"Unsupported move from '%-.128s' to '%-.128s' on RENAME TABLE statement"},
{"Unsupported schema '%-.128s' specified on RENAME TABLE statement"},
{"The %-.64s character set is not supported."},
{"Auto_increment is not allowed for a partitioned table"},
{"Character set conversion error due to unknown encoding scheme %d"},
{""},
......
......@@ -54,7 +54,7 @@ enum DB2I_errors
DB2I_ERR_ICONV_OPEN,
DB2I_ERR_INVALID_NAME,
DB2I_ERR_RENAME_MOVE,
DB2I_ERR_RENAME_QTEMP,
DB2I_ERR_UNSUPP_CHARSET,
DB2I_ERR_PART_AUTOINC,
DB2I_ERR_UNKNOWN_ENCODING,
DB2I_ERR_RESERVED,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment