Commit 481916ff authored by Olivier Bertrand's avatar Olivier Bertrand

Update ha_connect::pre_create to restore the code translating

of SQL types previously done in the removed function MyODBCCols.

Modified:
ha_connect.cc
parent fb1ff4e9
...@@ -3383,7 +3383,7 @@ bool ha_connect::pre_create(THD *thd, void *crt_info, void *alt_info) ...@@ -3383,7 +3383,7 @@ bool ha_connect::pre_create(THD *thd, void *crt_info, void *alt_info)
if (ok) { if (ok) {
char *length, *decimals, *cnm, *rem; char *length, *decimals, *cnm, *rem;
int i, len, dec; int i, len, dec, typ;
enum_field_types type; enum_field_types type;
PDBUSER dup= PlgGetUser(g); PDBUSER dup= PlgGetUser(g);
PCATLG cat= (dup) ? dup->Catalog : NULL; PCATLG cat= (dup) ? dup->Catalog : NULL;
...@@ -3463,6 +3463,7 @@ bool ha_connect::pre_create(THD *thd, void *crt_info, void *alt_info) ...@@ -3463,6 +3463,7 @@ bool ha_connect::pre_create(THD *thd, void *crt_info, void *alt_info)
} else // Not a catalog table } else // Not a catalog table
for (i= 0; !b && i < qrp->Nblin; i++) { for (i= 0; !b && i < qrp->Nblin; i++) {
rem= ""; rem= "";
typ= len= dec= 0;
length= ""; length= "";
decimals= NULL; decimals= NULL;
tm= NOT_NULL_FLAG; tm= NOT_NULL_FLAG;
...@@ -3475,12 +3476,10 @@ bool ha_connect::pre_create(THD *thd, void *crt_info, void *alt_info) ...@@ -3475,12 +3476,10 @@ bool ha_connect::pre_create(THD *thd, void *crt_info, void *alt_info)
name= thd->make_lex_string(NULL, cnm, strlen(cnm), true); name= thd->make_lex_string(NULL, cnm, strlen(cnm), true);
break; break;
case FLD_TYPE: case FLD_TYPE:
type= PLGtoMYSQL(crp->Kdata->GetIntValue(i), true); typ= crp->Kdata->GetIntValue(i);
break; break;
case FLD_PREC: case FLD_PREC:
len= crp->Kdata->GetIntValue(i); len= crp->Kdata->GetIntValue(i);
length= (char*)PlugSubAlloc(g, NULL, 8);
sprintf(length, "%d", len);
break; break;
case FLD_SCALE: case FLD_SCALE:
if ((dec= crp->Kdata->GetIntValue(i))) { if ((dec= crp->Kdata->GetIntValue(i))) {
...@@ -3508,6 +3507,29 @@ bool ha_connect::pre_create(THD *thd, void *crt_info, void *alt_info) ...@@ -3508,6 +3507,29 @@ bool ha_connect::pre_create(THD *thd, void *crt_info, void *alt_info)
break; // Ignore break; // Ignore
} // endswitch Fld } // endswitch Fld
#if defined(ODBC_SUPPORT)
if (ttp == TAB_ODBC) {
int plgtyp;
// typ must be PLG type, not SQL type
if (!(plgtyp= TranslateSQLType(typ, dec, len))) {
sprintf(g->Message, "Unsupported SQL type %d", typ);
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
return true;
} else
typ= plgtyp;
// Some data sources do not count dec in length
if (typ == TYPE_FLOAT)
len += (dec + 2); // To be safe
} // endif ttp
#endif // ODBC_SUPPORT
// Make the arguments as required by add_fields
type= PLGtoMYSQL(typ, true);
length= (char*)PlugSubAlloc(g, NULL, 8);
sprintf(length, "%d", len);
comment= thd->make_lex_string(NULL, rem, strlen(rem), true); comment= thd->make_lex_string(NULL, rem, strlen(rem), true);
// Now add the field // Now add the field
...@@ -3724,7 +3746,7 @@ bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *info, ...@@ -3724,7 +3746,7 @@ bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *info,
// TO DO: implement it. // TO DO: implement it.
if (table) if (table)
push_warning(table->in_use, MYSQL_ERROR::WARN_LEVEL_WARN, 0, push_warning(table->in_use, MYSQL_ERROR::WARN_LEVEL_WARN, 0,
"No check done for compatible changes, you are on your own!"); "No check done for compatible changes, you are onyour own!");
DBUG_RETURN(COMPATIBLE_DATA_YES); DBUG_RETURN(COMPATIBLE_DATA_YES);
} }
......
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