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
|
// Return the handler default value
|
||||||
if (!stricmp(opname, "Dbname") || !stricmp(opname, "Database"))
|
if (!stricmp(opname, "Dbname") || !stricmp(opname, "Database"))
|
||||||
opval= (char*)GetDBName(NULL); // Current 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
|
else if (!stricmp(opname, "User")) // Connected user
|
||||||
opval= table->in_use->main_security_ctx.user;
|
opval= table->in_use->main_security_ctx.user;
|
||||||
else if (!stricmp(opname, "Host")) // Connected user host
|
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)
|
bool ha_connect::check_privileges(THD *thd, PTOS options)
|
||||||
{
|
{
|
||||||
if (!options->type) {
|
if (!options->type) {
|
||||||
if (options->tabname)
|
if (options->srcdef)
|
||||||
|
options->type= "MYSQL";
|
||||||
|
else if (options->tabname)
|
||||||
options->type= "PROXY";
|
options->type= "PROXY";
|
||||||
else
|
else
|
||||||
options->type= "DOS";
|
options->type= "DOS";
|
||||||
@ -3336,7 +3342,7 @@ static bool add_field(String *sql, const char *field_name, const char *type,
|
|||||||
if (len) {
|
if (len) {
|
||||||
error|= sql->append('(');
|
error|= sql->append('(');
|
||||||
error|= sql->append_ulonglong(len);
|
error|= sql->append_ulonglong(len);
|
||||||
if (dec) {
|
if (dec || !strcmp(type, "DOUBLE")) {
|
||||||
error|= sql->append(',');
|
error|= sql->append(',');
|
||||||
error|= sql->append_ulonglong(dec);
|
error|= sql->append_ulonglong(dec);
|
||||||
}
|
}
|
||||||
@ -3379,7 +3385,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
|||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
int port= 0, hdr= 0, mxr= 0, b= 0;
|
int port= 0, hdr= 0, mxr= 0, b= 0;
|
||||||
uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL);
|
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;
|
TABTYPE ttp= TAB_UNDEF;
|
||||||
MEM_ROOT *mem= thd->mem_root;
|
MEM_ROOT *mem= thd->mem_root;
|
||||||
PQRYRES qrp;
|
PQRYRES qrp;
|
||||||
@ -3546,6 +3552,11 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
|||||||
ok= false;
|
ok= false;
|
||||||
} // endif supfnc
|
} // 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
|
// Here we should test the flag column options when
|
||||||
// this function is called in case of CREATE .. SELECT
|
// this function is called in case of CREATE .. SELECT
|
||||||
|
|
||||||
@ -3561,7 +3572,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
|||||||
else
|
else
|
||||||
return HA_ERR_INTERNAL_ERROR; // Should never happen
|
return HA_ERR_INTERNAL_ERROR; // Should never happen
|
||||||
|
|
||||||
if (src && fnc == FNC_NO)
|
if (src)
|
||||||
qrp= SrcColumns(g, host, db, user, pwd, src, port);
|
qrp= SrcColumns(g, host, db, user, pwd, src, port);
|
||||||
else switch (ttp) {
|
else switch (ttp) {
|
||||||
case TAB_DBF:
|
case TAB_DBF:
|
||||||
@ -3606,7 +3617,12 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
|||||||
case TAB_PRX:
|
case TAB_PRX:
|
||||||
case TAB_TBL:
|
case TAB_TBL:
|
||||||
case TAB_XCL:
|
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;
|
break;
|
||||||
default:
|
default:
|
||||||
strcpy(g->Message, "System error during assisted discovery");
|
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);
|
cnm= encode(g, crp->Name);
|
||||||
type= PLGtoMYSQLtype(crp->Type, dbf);
|
type= PLGtoMYSQLtype(crp->Type, dbf);
|
||||||
len= crp->Length;
|
len= crp->Length;
|
||||||
|
dec= crp->Prec;
|
||||||
|
|
||||||
// Now add the field
|
// 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;
|
b= HA_ERR_OUT_OF_MEM;
|
||||||
} // endfor crp
|
} // endfor crp
|
||||||
|
|
||||||
@ -3780,6 +3797,9 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
|||||||
|
|
||||||
} // endif charset
|
} // endif charset
|
||||||
|
|
||||||
|
if (xtrace)
|
||||||
|
printf("s_init: %.*s\n", sql.length(), sql.ptr());
|
||||||
|
|
||||||
if (!b)
|
if (!b)
|
||||||
b= table_s->init_from_sql_statement_string(thd, true,
|
b= table_s->init_from_sql_statement_string(thd, true,
|
||||||
sql.ptr(), sql.length());
|
sql.ptr(), sql.length());
|
||||||
@ -3837,18 +3857,11 @@ int ha_connect::create(const char *name, TABLE *table_arg,
|
|||||||
|
|
||||||
// Check table type
|
// Check table type
|
||||||
if (type == TAB_UNDEF) {
|
if (type == TAB_UNDEF) {
|
||||||
if (!options->tabname) {
|
options->type= (options->srcdef) ? "MYSQL" :
|
||||||
strcpy(g->Message, "No table_type. Will be set to DOS");
|
(options->tabname) ? "PROXY" : "DOS";
|
||||||
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
|
type= GetTypeID(options->type);
|
||||||
type= TAB_DOS;
|
sprintf(g->Message, "No table_type. Will be set to %s", options->type);
|
||||||
options->type= "DOS";
|
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
|
||||||
} 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
|
|
||||||
|
|
||||||
} else if (type == TAB_NIY) {
|
} else if (type == TAB_NIY) {
|
||||||
sprintf(g->Message, "Unsupported table type %s", options->type);
|
sprintf(g->Message, "Unsupported table type %s", options->type);
|
||||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
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);
|
strcpy(sval, s);
|
||||||
} else if (!stricmp(what, "filename")) {
|
} else if (!stricmp(what, "filename")) {
|
||||||
// Return default file name
|
// Return default file name
|
||||||
char *ftype= Hc->GetStringOption("Type", "dos");
|
char *ftype= Hc->GetStringOption("Type", "*");
|
||||||
int i, n;
|
int i, n;
|
||||||
|
|
||||||
sval= (char*)PlugSubAlloc(g, NULL, strlen(Hc->GetTableName()) + 12);
|
if (IsFileType(GetTypeID(ftype))) {
|
||||||
strcat(strcpy(sval, Hc->GetTableName()), ".");
|
sval= (char*)PlugSubAlloc(g, NULL, strlen(Hc->GetTableName()) + 12);
|
||||||
n= strlen(sval);
|
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
|
} // endif FileType
|
||||||
for (i= 0; i < 12; i++)
|
|
||||||
if (!ftype[i]) {
|
|
||||||
sval[n+i]= 0;
|
|
||||||
break;
|
|
||||||
} else
|
|
||||||
sval[n+i]= tolower(ftype[i]);
|
|
||||||
|
|
||||||
} else
|
} else
|
||||||
sval = NULL;
|
sval = NULL;
|
||||||
@ -416,7 +419,7 @@ char *MYCAT::GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int MYCAT::GetColCatInfo(PGLOBAL g, PTABDEF defp)
|
int MYCAT::GetColCatInfo(PGLOBAL g, PTABDEF defp)
|
||||||
{
|
{
|
||||||
char *type= GetStringCatInfo(g, "Type", "DOS");
|
char *type= GetStringCatInfo(g, "Type", "*");
|
||||||
int i, loff, poff, nof, nlg;
|
int i, loff, poff, nof, nlg;
|
||||||
void *field= NULL;
|
void *field= NULL;
|
||||||
TABTYPE tc;
|
TABTYPE tc;
|
||||||
@ -598,8 +601,8 @@ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name,
|
|||||||
printf("GetTableDesc: name=%s am=%s\n", name, SVP(type));
|
printf("GetTableDesc: name=%s am=%s\n", name, SVP(type));
|
||||||
|
|
||||||
// If not specified get the type of this table
|
// If not specified get the type of this table
|
||||||
if (!type && !(type= Hc->GetStringOption("Type")))
|
if (!type)
|
||||||
type= (Hc->GetStringOption("Tabname")) ? "PROXY" : "DOS";
|
type= Hc->GetStringOption("Type","*");
|
||||||
|
|
||||||
return MakeTableDesc(g, name, type);
|
return MakeTableDesc(g, name, type);
|
||||||
} // end of GetTableDesc
|
} // end of GetTableDesc
|
||||||
|
@ -790,7 +790,7 @@ bool TDBMYSQL::OpenDB(PGLOBAL g)
|
|||||||
} // endif m_Res
|
} // endif m_Res
|
||||||
#endif // 0
|
#endif // 0
|
||||||
|
|
||||||
if (Srcdef)
|
if (!m_Rc && Srcdef)
|
||||||
if (SetColumnRanks(g))
|
if (SetColumnRanks(g))
|
||||||
return true;
|
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. */
|
/* of the object table that will be retrieved by GetData commands. */
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
|
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,
|
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
|
||||||
TYPE_INT, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT,
|
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))) {
|
if (!(s = GetTableShare(g, thd, db, name, mysql))) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else if (s->is_view) {
|
} 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;
|
return NULL;
|
||||||
} else
|
} else
|
||||||
n = s->fieldnames.count;
|
n = s->fieldnames.count;
|
||||||
@ -615,6 +617,8 @@ TDBTBC::TDBTBC(PPRXDEF tdp) : TDBCAT(tdp)
|
|||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
PQRYRES TDBTBC::GetResult(PGLOBAL g)
|
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
|
} // end of GetResult
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ typedef class TDBTBC *PTDBTBC;
|
|||||||
TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db,
|
TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db,
|
||||||
const char *name, bool& mysql);
|
const char *name, bool& mysql);
|
||||||
PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
|
PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
|
||||||
const char *name, bool info);
|
const char *name, bool& info);
|
||||||
|
|
||||||
void Remove_tshp(PCATLG cat);
|
void Remove_tshp(PCATLG cat);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user