11/* ************ Tabutil cpp Declares Source Code File (.CPP) ************/
22/* Name: TABUTIL.CPP Version 1.1 */
33/* */
4- /* (C) Copyright to the author Olivier BERTRAND 2013 - 2015 */
4+ /* (C) Copyright to the author Olivier BERTRAND 2013 - 2016 */
55/* */
66/* Utility function used by the PROXY, XCOL, OCCUR, and TBL tables. */
77/* **********************************************************************/
@@ -118,7 +118,7 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
118118 FLD_LENGTH, FLD_SCALE, FLD_RADIX, FLD_NULL,
119119 FLD_REM, FLD_NO, FLD_CHARSET};
120120 unsigned int length[] = {0 , 4 , 16 , 4 , 4 , 4 , 4 , 4 , 0 , 32 , 32 };
121- char *fld, *colname, *chset, *fmt, v;
121+ char *pn, *tn, * fld, *colname, *chset, *fmt, v;
122122 int i, n, ncol = sizeof (buftyp) / sizeof (int );
123123 int prec, len, type, scale;
124124 int zconv = GetConvSize ();
@@ -130,7 +130,16 @@ PQRYRES TabColumns(PGLOBAL g, THD *thd, const char *db,
130130 PCOLRES crp;
131131
132132 if (!info) {
133- if (!(s = GetTableShare (g, thd, db, name, mysql))) {
133+ // Analyze the table name, it may have the format: [dbname.]tabname
134+ if (strchr ((char *)name, ' .' )) {
135+ tn = (char *)PlugDup (g, name);
136+ pn = strchr (tn, ' .' );
137+ *pn++ = 0 ;
138+ db = tn;
139+ name = pn;
140+ } // endif pn
141+
142+ if (!(s = GetTableShare (g, thd, db, name, mysql))) {
134143 return NULL ;
135144 } else if (s->is_view ) {
136145 strcpy (g->Message , " Use MYSQL type to see columns from a view" );
@@ -315,7 +324,7 @@ bool PRXDEF::DefineAM(PGLOBAL g, LPCSTR, int)
315324 } // endif pn
316325
317326 Tablep = new (g) XTAB (tab, def);
318- Tablep->SetQualifier (db);
327+ Tablep->SetSchema (db);
319328 return false ;
320329 } // end of DefineAM
321330
@@ -379,12 +388,12 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b)
379388 LPCSTR cdb, curdb = hc->GetDBName (NULL );
380389 THD *thd = (hc->GetTable ())->in_use ;
381390
382- db = (char *)tabp->GetQualifier ( );
391+ db = (char *)( tabp->GetSchema () ? tabp-> GetSchema () : curdb );
383392 name = (char *)tabp->GetName ();
384393
385394 // Check for eventual loop
386395 for (PTABLE tp = To_Table; tp; tp = tp->Next ) {
387- cdb = (tp->Qualifier ) ? tp->Qualifier : curdb;
396+ cdb = (tp->Schema ) ? tp->Schema : curdb;
388397
389398 if (!stricmp (name, tp->Name ) && !stricmp (db, cdb)) {
390399 sprintf (g->Message , " Table %s.%s pointing on itself" , db, name);
@@ -423,7 +432,7 @@ PTDBASE TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b)
423432 } // endif Define
424433
425434 if (db)
426- ((PTDBMY)tdbp)->SetDatabase (tabp->GetQualifier ());
435+ ((PTDBMY)tdbp)->SetDatabase (tabp->GetSchema ());
427436
428437 if (Mode == MODE_UPDATE || Mode == MODE_DELETE)
429438 tdbp->SetName (Name); // For Make_Command
@@ -757,7 +766,7 @@ void PRXCOL::WriteColumn(PGLOBAL g)
757766/* **********************************************************************/
758767TDBTBC::TDBTBC (PPRXDEF tdp) : TDBCAT(tdp)
759768 {
760- Db = (PSZ)tdp->Tablep ->GetQualifier ();
769+ Db = (PSZ)tdp->Tablep ->GetSchema ();
761770 Tab = (PSZ)tdp->Tablep ->GetName ();
762771 } // end of TDBTBC constructor
763772
0 commit comments