mirror of
https://github.com/MariaDB/server.git
synced 2025-07-30 16:24:05 +03:00
Bugs#7278: Don't open a table if it contains columns with non-supported charsets
This commit is contained in:
37
sql/table.cc
37
sql/table.cc
@ -24,7 +24,8 @@
|
|||||||
|
|
||||||
/* Functions defined in this file */
|
/* Functions defined in this file */
|
||||||
|
|
||||||
static void frm_error(int error,TABLE *form,const char *name,int errortype);
|
static void frm_error(int error,TABLE *form,const char *name,
|
||||||
|
int errortype, int errarg);
|
||||||
static void fix_type_pointers(const char ***array, TYPELIB *point_to_type,
|
static void fix_type_pointers(const char ***array, TYPELIB *point_to_type,
|
||||||
uint types, char **names);
|
uint types, char **names);
|
||||||
static uint find_field(TABLE *form,uint start,uint length);
|
static uint find_field(TABLE *form,uint start,uint length);
|
||||||
@ -57,6 +58,7 @@ static byte* get_field_name(Field **buff,uint *length,
|
|||||||
2 Error (see frm_error)
|
2 Error (see frm_error)
|
||||||
3 Wrong data in .frm file
|
3 Wrong data in .frm file
|
||||||
4 Error (see frm_error)
|
4 Error (see frm_error)
|
||||||
|
5 Error (see frm_error: charset unavailable)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
|
int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
|
||||||
@ -64,7 +66,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
|
|||||||
{
|
{
|
||||||
reg1 uint i;
|
reg1 uint i;
|
||||||
reg2 uchar *strpos;
|
reg2 uchar *strpos;
|
||||||
int j,error;
|
int j,error, errarg= 0;
|
||||||
uint rec_buff_length,n_length,int_length,records,key_parts,keys,
|
uint rec_buff_length,n_length,int_length,records,key_parts,keys,
|
||||||
interval_count,interval_parts,read_length,db_create_options;
|
interval_count,interval_parts,read_length,db_create_options;
|
||||||
uint key_info_length, com_length;
|
uint key_info_length, com_length;
|
||||||
@ -436,10 +438,14 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!strpos[14])
|
if (!strpos[14])
|
||||||
charset= &my_charset_bin;
|
charset= &my_charset_bin;
|
||||||
else if (!(charset=get_charset((uint) strpos[14], MYF(0))))
|
else if (!(charset=get_charset((uint) strpos[14], MYF(0))))
|
||||||
charset= outparam->table_charset;
|
{
|
||||||
|
error= 5; // Unknown or unavailable charset
|
||||||
|
errarg= (int) strpos[14];
|
||||||
|
goto err_not_open;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!comment_length)
|
if (!comment_length)
|
||||||
{
|
{
|
||||||
@ -781,7 +787,7 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
|
|||||||
err_end: /* Here when no file */
|
err_end: /* Here when no file */
|
||||||
delete crypted;
|
delete crypted;
|
||||||
*root_ptr= old_root;
|
*root_ptr= old_root;
|
||||||
frm_error(error,outparam,name,ME_ERROR+ME_WAITTANG);
|
frm_error(error, outparam, name, ME_ERROR + ME_WAITTANG, errarg);
|
||||||
delete outparam->file;
|
delete outparam->file;
|
||||||
outparam->file=0; // For easyer errorchecking
|
outparam->file=0; // For easyer errorchecking
|
||||||
outparam->db_stat=0;
|
outparam->db_stat=0;
|
||||||
@ -966,7 +972,8 @@ ulong make_new_entry(File file, uchar *fileinfo, TYPELIB *formnames,
|
|||||||
|
|
||||||
/* error message when opening a form file */
|
/* error message when opening a form file */
|
||||||
|
|
||||||
static void frm_error(int error, TABLE *form, const char *name, myf errortype)
|
static void frm_error(int error, TABLE *form, const char *name,
|
||||||
|
myf errortype, int errarg)
|
||||||
{
|
{
|
||||||
int err_no;
|
int err_no;
|
||||||
char buff[FN_REFLEN];
|
char buff[FN_REFLEN];
|
||||||
@ -997,6 +1004,20 @@ static void frm_error(int error, TABLE *form, const char *name, myf errortype)
|
|||||||
fn_format(buff,form->real_name,form_dev,datext,2),my_errno);
|
fn_format(buff,form->real_name,form_dev,datext,2),my_errno);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 5:
|
||||||
|
{
|
||||||
|
const char *csname= get_charset_name((uint) errarg);
|
||||||
|
char tmp[10];
|
||||||
|
if (!csname || csname[0] =='?')
|
||||||
|
{
|
||||||
|
my_snprintf(tmp, sizeof(tmp), "#%d", errarg);
|
||||||
|
csname= tmp;
|
||||||
|
}
|
||||||
|
my_printf_error(ER_UNKNOWN_COLLATION,
|
||||||
|
"Unknown collation '%s' in table '%-.64s' definition",
|
||||||
|
MYF(0), csname, form->real_name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
default: /* Better wrong error than none */
|
default: /* Better wrong error than none */
|
||||||
case 4:
|
case 4:
|
||||||
my_error(ER_NOT_FORM_FILE,errortype,
|
my_error(ER_NOT_FORM_FILE,errortype,
|
||||||
|
Reference in New Issue
Block a user