mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
- Fix setting default type to MYSQL->PROXY->DOS in some places where it
was not done correctly. - Fix a bug causing add_field to generate a syntax error on DOUBLE columns with a 0 decimal value. - Column can be undefined when Srcdef is specified. modified: storage/connect/ha_connect.cc storage/connect/mycat.cc storage/connect/tabmysql.cpp storage/connect/tabutil.cpp storage/connect/tabutil.h
This commit is contained in:
@ -680,6 +680,10 @@ char *ha_connect::GetStringOption(char *opname, char *sdef)
|
||||
// Return the handler default value
|
||||
if (!stricmp(opname, "Dbname") || !stricmp(opname, "Database"))
|
||||
opval= (char*)GetDBName(NULL); // Current database
|
||||
else if (!stricmp(opname, "Type")) // Default type
|
||||
opval= (!options) ? NULL :
|
||||
(options->srcdef) ? "MYSQL" :
|
||||
(options->tabname) ? "PROXY" : "DOS";
|
||||
else if (!stricmp(opname, "User")) // Connected user
|
||||
opval= table->in_use->main_security_ctx.user;
|
||||
else if (!stricmp(opname, "Host")) // Connected user host
|
||||
@ -2671,7 +2675,9 @@ int ha_connect::delete_all_rows()
|
||||
bool ha_connect::check_privileges(THD *thd, PTOS options)
|
||||
{
|
||||
if (!options->type) {
|
||||
if (options->tabname)
|
||||
if (options->srcdef)
|
||||
options->type= "MYSQL";
|
||||
else if (options->tabname)
|
||||
options->type= "PROXY";
|
||||
else
|
||||
options->type= "DOS";
|
||||
@ -3336,7 +3342,7 @@ static bool add_field(String *sql, const char *field_name, const char *type,
|
||||
if (len) {
|
||||
error|= sql->append('(');
|
||||
error|= sql->append_ulonglong(len);
|
||||
if (dec) {
|
||||
if (dec || !strcmp(type, "DOUBLE")) {
|
||||
error|= sql->append(',');
|
||||
error|= sql->append_ulonglong(dec);
|
||||
}
|
||||
@ -3379,7 +3385,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
||||
#endif // WIN32
|
||||
int port= 0, hdr= 0, mxr= 0, b= 0;
|
||||
uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL);
|
||||
bool ok= false, dbf= false;
|
||||
bool bif, ok= false, dbf= false;
|
||||
TABTYPE ttp= TAB_UNDEF;
|
||||
MEM_ROOT *mem= thd->mem_root;
|
||||
PQRYRES qrp;
|
||||
@ -3546,6 +3552,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
||||
ok= false;
|
||||
} // endif supfnc
|
||||
|
||||
if (src && fnc != FNC_NO) {
|
||||
strcpy(g->Message, "Cannot make catalog table from srcdef");
|
||||
ok= false;
|
||||
} // endif src
|
||||
|
||||
// Here we should test the flag column options when
|
||||
// this function is called in case of CREATE .. SELECT
|
||||
|
||||
@ -3561,7 +3572,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
||||
else
|
||||
return HA_ERR_INTERNAL_ERROR; // Should never happen
|
||||
|
||||
if (src && fnc == FNC_NO)
|
||||
if (src)
|
||||
qrp= SrcColumns(g, host, db, user, pwd, src, port);
|
||||
else switch (ttp) {
|
||||
case TAB_DBF:
|
||||
@ -3606,7 +3617,12 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
||||
case TAB_PRX:
|
||||
case TAB_TBL:
|
||||
case TAB_XCL:
|
||||
qrp= TabColumns(g, thd, db, tab, fnc == FNC_COL);
|
||||
bif= fnc == FNC_COL;
|
||||
qrp= TabColumns(g, thd, db, tab, bif);
|
||||
|
||||
if (!qrp && bif && fnc != FNC_COL) // tab is a view
|
||||
qrp= MyColumns(g, host, db, user, pwd, tab, NULL, port, false);
|
||||
|
||||
break;
|
||||
default:
|
||||
strcpy(g->Message, "System error during assisted discovery");
|
||||
@ -3624,9 +3640,10 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
||||
cnm= encode(g, crp->Name);
|
||||
type= PLGtoMYSQLtype(crp->Type, dbf);
|
||||
len= crp->Length;
|
||||
dec= crp->Prec;
|
||||
|
||||
// Now add the field
|
||||
if (add_field(&sql, cnm, type, len, 0, NOT_NULL_FLAG, 0))
|
||||
if (add_field(&sql, cnm, type, len, dec, NOT_NULL_FLAG, 0))
|
||||
b= HA_ERR_OUT_OF_MEM;
|
||||
} // endfor crp
|
||||
|
||||
@ -3780,6 +3797,9 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
||||
|
||||
} // endif charset
|
||||
|
||||
if (xtrace)
|
||||
printf("s_init: %.*s\n", sql.length(), sql.ptr());
|
||||
|
||||
if (!b)
|
||||
b= table_s->init_from_sql_statement_string(thd, true,
|
||||
sql.ptr(), sql.length());
|
||||
@ -3837,18 +3857,11 @@ int ha_connect::create(const char *name, TABLE *table_arg,
|
||||
|
||||
// Check table type
|
||||
if (type == TAB_UNDEF) {
|
||||
if (!options->tabname) {
|
||||
strcpy(g->Message, "No table_type. Will be set to DOS");
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
|
||||
type= TAB_DOS;
|
||||
options->type= "DOS";
|
||||
} else {
|
||||
strcpy(g->Message, "No table_type. Will be set to PROXY");
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
|
||||
type= TAB_PRX;
|
||||
options->type= "PROXY";
|
||||
} // endif fnc
|
||||
|
||||
options->type= (options->srcdef) ? "MYSQL" :
|
||||
(options->tabname) ? "PROXY" : "DOS";
|
||||
type= GetTypeID(options->type);
|
||||
sprintf(g->Message, "No table_type. Will be set to %s", options->type);
|
||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
|
||||
} else if (type == TAB_NIY) {
|
||||
sprintf(g->Message, "Unsupported table type %s", options->type);
|
||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||
|
@ -390,20 +390,23 @@ char *MYCAT::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef)
|
||||
strcpy(sval, s);
|
||||
} else if (!stricmp(what, "filename")) {
|
||||
// Return default file name
|
||||
char *ftype= Hc->GetStringOption("Type", "dos");
|
||||
char *ftype= Hc->GetStringOption("Type", "*");
|
||||
int i, n;
|
||||
|
||||
sval= (char*)PlugSubAlloc(g, NULL, strlen(Hc->GetTableName()) + 12);
|
||||
strcat(strcpy(sval, Hc->GetTableName()), ".");
|
||||
n= strlen(sval);
|
||||
if (IsFileType(GetTypeID(ftype))) {
|
||||
sval= (char*)PlugSubAlloc(g, NULL, strlen(Hc->GetTableName()) + 12);
|
||||
strcat(strcpy(sval, Hc->GetTableName()), ".");
|
||||
n= strlen(sval);
|
||||
|
||||
// Fold ftype to lower case
|
||||
for (i= 0; i < 12; i++)
|
||||
if (!ftype[i]) {
|
||||
sval[n+i]= 0;
|
||||
break;
|
||||
} else
|
||||
sval[n+i]= tolower(ftype[i]);
|
||||
|
||||
// Fold ftype to lower case
|
||||
for (i= 0; i < 12; i++)
|
||||
if (!ftype[i]) {
|
||||
sval[n+i]= 0;
|
||||
break;
|
||||
} else
|
||||
sval[n+i]= tolower(ftype[i]);
|
||||
} // endif FileType
|
||||
|
||||
} else
|
||||
sval = NULL;
|
||||
@ -416,7 +419,7 @@ char *MYCAT::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef)
|
||||
/***********************************************************************/
|
||||
int MYCAT::GetColCatInfo(PGLOBAL g, PTABDEF defp)
|
||||
{
|
||||
char *type= GetStringCatInfo(g, "Type", "DOS");
|
||||
char *type= GetStringCatInfo(g, "Type", "*");
|
||||
int i, loff, poff, nof, nlg;
|
||||
void *field= NULL;
|
||||
TABTYPE tc;
|
||||
@ -598,8 +601,8 @@ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name,
|
||||
printf("GetTableDesc: name=%s am=%s\n", name, SVP(type));
|
||||
|
||||
// If not specified get the type of this table
|
||||
if (!type && !(type= Hc->GetStringOption("Type")))
|
||||
type= (Hc->GetStringOption("Tabname")) ? "PROXY" : "DOS";
|
||||
if (!type)
|
||||
type= Hc->GetStringOption("Type","*");
|
||||
|
||||
return MakeTableDesc(g, name, type);
|
||||
} // end of GetTableDesc
|
||||
|
@ -790,7 +790,7 @@ bool TDBMYSQL::OpenDB(PGLOBAL g)
|
||||
} // endif m_Res
|
||||
#endif // 0
|
||||
|
||||
if (Srcdef)
|
||||
if (!m_Rc && Srcdef)
|
||||
if (SetColumnRanks(g))
|
||||
return true;
|
||||
|
||||
|
@ -120,7 +120,7 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db,
|
||||
/* of the object table that will be retrieved by GetData commands. */
|
||||
/************************************************************************/
|
||||
PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
|
||||
const char *name, bool info)
|
||||
const char *name, bool& info)
|
||||
{
|
||||
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
|
||||
TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT,
|
||||
@ -143,7 +143,9 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
|
||||
if (!(s = GetTableShare(g, thd, db, name, mysql))) {
|
||||
return NULL;
|
||||
} else if (s->is_view) {
|
||||
strcpy(g->Message, "Cannot retreive Proxy columns from a view");
|
||||
strcpy(g->Message, "Use MYSQL type to see columns from a view");
|
||||
info = true; // To tell caller name is a view
|
||||
free_table_share(s);
|
||||
return NULL;
|
||||
} else
|
||||
n = s->fieldnames.count;
|
||||
@ -615,6 +617,8 @@ TDBTBC::TDBTBC(PPRXDEF tdp) : TDBCAT(tdp)
|
||||
/***********************************************************************/
|
||||
PQRYRES TDBTBC::GetResult(PGLOBAL g)
|
||||
{
|
||||
return TabColumns(g, current_thd, Db, Tab, false);
|
||||
bool b = false;
|
||||
|
||||
return TabColumns(g, current_thd, Db, Tab, b);
|
||||
} // end of GetResult
|
||||
|
||||
|
@ -18,7 +18,7 @@ typedef class TDBTBC *PTDBTBC;
|
||||
TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db,
|
||||
const char *name, bool& mysql);
|
||||
PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
|
||||
const char *name, bool info);
|
||||
const char *name, bool& info);
|
||||
|
||||
void Remove_tshp(PCATLG cat);
|
||||
|
||||
|
Reference in New Issue
Block a user