|
|
@ -1,7 +1,7 @@ |
|
|
|
/************* Tabutil cpp Declares Source Code File (.CPP) ************/ |
|
|
|
/* Name: TABUTIL.CPP Version 1.1 */ |
|
|
|
/* */ |
|
|
|
/* (C) Copyright to the author Olivier BERTRAND 2013 - 2015 */ |
|
|
|
/* (C) Copyright to the author Olivier BERTRAND 2013 - 2016 */ |
|
|
|
/* */ |
|
|
|
/* Utility function used by the PROXY, XCOL, OCCUR, and TBL tables. */ |
|
|
|
/***********************************************************************/ |
|
|
@ -118,7 +118,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, |
|
|
|
FLD_LENGTH, FLD_SCALE, FLD_RADIX, FLD_NULL, |
|
|
|
FLD_REM, FLD_NO, FLD_CHARSET}; |
|
|
|
unsigned int length[] = {0, 4, 16, 4, 4, 4, 4, 4, 0, 32, 32}; |
|
|
|
char *fld, *colname, *chset, *fmt, v; |
|
|
|
char *pn, *tn, *fld, *colname, *chset, *fmt, v; |
|
|
|
int i, n, ncol = sizeof(buftyp) / sizeof(int); |
|
|
|
int prec, len, type, scale; |
|
|
|
int zconv = GetConvSize(); |
|
|
@ -130,7 +130,16 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db, |
|
|
|
PCOLRES crp; |
|
|
|
|
|
|
|
if (!info) { |
|
|
|
if (!(s = GetTableShare(g, thd, db, name, mysql))) { |
|
|
|
// Analyze the table name, it may have the format: [dbname.]tabname
|
|
|
|
if (strchr((char*)name, '.')) { |
|
|
|
tn = (char*)PlugDup(g, name); |
|
|
|
pn = strchr(tn, '.'); |
|
|
|
*pn++ = 0; |
|
|
|
db = tn; |
|
|
|
name = pn; |
|
|
|
} // endif pn
|
|
|
|
|
|
|
|
if (!(s = GetTableShare(g, thd, db, name, mysql))) { |
|
|
|
return NULL; |
|
|
|
} else if (s->is_view) { |
|
|
|
strcpy(g->Message, "Use MYSQL type to see columns from a view"); |
|
|
@ -315,7 +324,7 @@ bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR, int) |
|
|
|
} // endif pn
|
|
|
|
|
|
|
|
Tablep = new(g) XTAB(tab, def); |
|
|
|
Tablep->SetQualifier(db); |
|
|
|
Tablep->SetSchema(db); |
|
|
|
return false; |
|
|
|
} // end of DefineAM
|
|
|
|
|
|
|
@ -379,12 +388,12 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) |
|
|
|
LPCSTR cdb, curdb = hc->GetDBName(NULL); |
|
|
|
THD *thd = (hc->GetTable())->in_use; |
|
|
|
|
|
|
|
db = (char*)tabp->GetQualifier(); |
|
|
|
db = (char*)(tabp->GetSchema() ? tabp->GetSchema() : curdb); |
|
|
|
name = (char*)tabp->GetName(); |
|
|
|
|
|
|
|
// Check for eventual loop
|
|
|
|
for (PTABLE tp = To_Table; tp; tp = tp->Next) { |
|
|
|
cdb = (tp->Qualifier) ? tp->Qualifier : curdb; |
|
|
|
cdb = (tp->Schema) ? tp->Schema : curdb; |
|
|
|
|
|
|
|
if (!stricmp(name, tp->Name) && !stricmp(db, cdb)) { |
|
|
|
sprintf(g->Message, "Table %s.%s pointing on itself", db, name); |
|
|
@ -423,7 +432,7 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) |
|
|
|
} // endif Define
|
|
|
|
|
|
|
|
if (db) |
|
|
|
((PTDBMY)tdbp)->SetDatabase(tabp->GetQualifier()); |
|
|
|
((PTDBMY)tdbp)->SetDatabase(tabp->GetSchema()); |
|
|
|
|
|
|
|
if (Mode == MODE_UPDATE || Mode == MODE_DELETE) |
|
|
|
tdbp->SetName(Name); // For Make_Command
|
|
|
@ -757,7 +766,7 @@ void PRXCOL::WriteColumn(PGLOBAL g) |
|
|
|
/***********************************************************************/ |
|
|
|
TDBTBC::TDBTBC(PPRXDEF tdp) : TDBCAT(tdp) |
|
|
|
{ |
|
|
|
Db = (PSZ)tdp->Tablep->GetQualifier(); |
|
|
|
Db = (PSZ)tdp->Tablep->GetSchema(); |
|
|
|
Tab = (PSZ)tdp->Tablep->GetName(); |
|
|
|
} // end of TDBTBC constructor
|
|
|
|
|
|
|
|