Commit e89cb7f2 authored by Olivier Bertrand's avatar Olivier Bertrand

Translate column names to UTF-8 in ha_connect::pre_create.

parent 9ca150aa
...@@ -3133,6 +3133,22 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key, ...@@ -3133,6 +3133,22 @@ ha_rows ha_connect::records_in_range(uint inx, key_range *min_key,
DBUG_RETURN(rows); DBUG_RETURN(rows);
} // end of records_in_range } // end of records_in_range
/**
Convert an ISO-8859-1 column name to UTF-8
*/
char *ha_connect::encode(PGLOBAL g, char *cnm)
{
char *buf= (char*)PlugSubAlloc(g, NULL, strlen(cnm) * 3);
uint dummy_errors;
uint32 len= copy_and_convert(buf, strlen(cnm) * 3,
&my_charset_utf8_bin,
cnm, strlen(cnm),
&my_charset_latin1,
&dummy_errors);
buf[len]= '\0';
return buf;
} // end of Encode
/** /**
Store field definition for create. Store field definition for create.
...@@ -3349,7 +3365,7 @@ bool ha_connect::pre_create(THD *thd, void *crt_info, void *alt_info) ...@@ -3349,7 +3365,7 @@ bool ha_connect::pre_create(THD *thd, void *crt_info, void *alt_info)
} // endif ttp } // endif ttp
if (ok) { if (ok) {
char *length, *decimals, *nm, *rem; char *length, *decimals, *cnm, *rem;
int i, len, dec; int i, len, dec;
bool b; bool b;
LEX_STRING *comment, *name; LEX_STRING *comment, *name;
...@@ -3392,18 +3408,18 @@ bool ha_connect::pre_create(THD *thd, void *crt_info, void *alt_info) ...@@ -3392,18 +3408,18 @@ bool ha_connect::pre_create(THD *thd, void *crt_info, void *alt_info)
} // endif qrp } // endif qrp
for (i= 0; i < qrp->Nblin; i++) { for (i= 0; i < qrp->Nblin; i++) {
crp = qrp->Colresp; // Column Name crp= qrp->Colresp; // Column Name
nm= crp->Kdata->GetCharValue(i); cnm= encode(g, crp->Kdata->GetCharValue(i));
name= thd->make_lex_string(NULL, nm, strlen(nm), true); name= thd->make_lex_string(NULL, cnm, strlen(cnm), true);
crp = crp->Next; // Data Type crp= crp->Next; // Data Type
type= PLGtoMYSQL(crp->Kdata->GetIntValue(i), true); type= PLGtoMYSQL(crp->Kdata->GetIntValue(i), true);
crp = crp->Next; // Type Name crp= crp->Next; // Type Name
crp = crp->Next; // Precision (length) crp= crp->Next; // Precision (length)
len= crp->Kdata->GetIntValue(i); len= crp->Kdata->GetIntValue(i);
length= (char*)PlugSubAlloc(g, NULL, 8); length= (char*)PlugSubAlloc(g, NULL, 8);
sprintf(length, "%d", len); sprintf(length, "%d", len);
crp = crp->Next; // Length crp= crp->Next; // Length
crp = crp->Next; // Scale (precision) crp= crp->Next; // Scale (precision)
if ((dec= crp->Kdata->GetIntValue(i))) { if ((dec= crp->Kdata->GetIntValue(i))) {
decimals= (char*)PlugSubAlloc(g, NULL, 8); decimals= (char*)PlugSubAlloc(g, NULL, 8);
......
...@@ -347,6 +347,7 @@ char *GetValStr(OPVAL vop, bool neg); ...@@ -347,6 +347,7 @@ char *GetValStr(OPVAL vop, bool neg);
protected: protected:
char *GetListOption(char *opname, const char *oplist, char *def= NULL); char *GetListOption(char *opname, const char *oplist, char *def= NULL);
char *encode(PGLOBAL g, char *cnm);
bool add_fields(THD *thd, void *alter_info, bool add_fields(THD *thd, void *alter_info,
LEX_STRING *field_name, LEX_STRING *field_name,
enum_field_types type, enum_field_types type,
......
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