summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2016-01-09 20:52:17 +0100
committerOlivier Bertrand <bertrandop@gmail.com>2016-01-09 20:52:17 +0100
commit0891ae2fbb77c96a7fbeeb2ce9973d22da596f2a (patch)
tree6af9062522d15d6b0ae0e930f8c8a32e41a847af
parent6883e5c4c40d1411dcc7c43bbb7cbb3f2d0ab251 (diff)
downloadmariadb-git-0891ae2fbb77c96a7fbeeb2ce9973d22da596f2a.tar.gz
- Fix MDEV-9239. Meanwhile, make all references to the database in XTAB Schema
(was sometimes in XTAB Catalog) modified: storage/connect/mycat.cc modified: storage/connect/mycat.h modified: storage/connect/reldef.cpp modified: storage/connect/reldef.h modified: storage/connect/tabmysql.cpp modified: storage/connect/tabpivot.cpp modified: storage/connect/tabtbl.cpp modified: storage/connect/tabutil.cpp
-rw-r--r--storage/connect/mycat.cc31
-rw-r--r--storage/connect/mycat.h10
-rw-r--r--storage/connect/reldef.cpp13
-rw-r--r--storage/connect/reldef.h12
-rw-r--r--storage/connect/tabmysql.cpp2
-rw-r--r--storage/connect/tabpivot.cpp4
-rw-r--r--storage/connect/tabtbl.cpp6
-rw-r--r--storage/connect/tabutil.cpp25
8 files changed, 61 insertions, 42 deletions
diff --git a/storage/connect/mycat.cc b/storage/connect/mycat.cc
index 2e9085b4c87..97ad980dd6a 100644
--- a/storage/connect/mycat.cc
+++ b/storage/connect/mycat.cc
@@ -1,4 +1,4 @@
-/* Copyright (C) Olivier Bertrand 2004 - 2015
+/* Copyright (C) Olivier Bertrand 2004 - 2016
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,7 +18,7 @@
/* ------------- */
/* Version 1.4 */
/* */
-/* Author: Olivier Bertrand 2012 - 2015 */
+/* Author: Olivier Bertrand 2012 - 2016 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -509,30 +509,33 @@ void MYCAT::SetPath(PGLOBAL g, LPCSTR *datapath, const char *path)
/* GetTableDesc: retrieve a table descriptor. */
/* Look for a table descriptor matching the name and type. */
/***********************************************************************/
-PRELDEF MYCAT::GetTableDesc(PGLOBAL g, LPCSTR name,
+PRELDEF MYCAT::GetTableDesc(PGLOBAL g, PTABLE tablep,
LPCSTR type, PRELDEF *)
{
if (trace)
- printf("GetTableDesc: name=%s am=%s\n", name, SVP(type));
+ printf("GetTableDesc: name=%s am=%s\n", tablep->GetName(), SVP(type));
// If not specified get the type of this table
if (!type)
type= Hc->GetStringOption("Type","*");
- return MakeTableDesc(g, name, type);
+ return MakeTableDesc(g, tablep, type);
} // end of GetTableDesc
/***********************************************************************/
/* MakeTableDesc: make a table/view description. */
/* Note: caller must check if name already exists before calling it. */
/***********************************************************************/
-PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am)
+PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am)
{
TABTYPE tc;
+ LPCSTR name = (PSZ)PlugDup(g, tablep->GetName());
+ LPCSTR schema = (PSZ)PlugDup(g, tablep->GetSchema());
PRELDEF tdp= NULL;
if (trace)
- printf("MakeTableDesc: name=%s am=%s\n", name, SVP(am));
+ printf("MakeTableDesc: name=%s schema=%s am=%s\n",
+ name, SVP(schema), SVP(am));
/*********************************************************************/
/* Get a unique enum identifier for types. */
@@ -571,11 +574,11 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am)
case TAB_VIR: tdp= new(g) VIRDEF; break;
case TAB_JSON: tdp= new(g) JSONDEF; break;
default:
- sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name);
+ sprintf(g->Message, MSG(BAD_TABLE_TYPE), am, name);
} // endswitch
// Do make the table/view definition
- if (tdp && tdp->Define(g, this, name, am))
+ if (tdp && tdp->Define(g, this, name, schema, am))
tdp= NULL;
return tdp;
@@ -588,20 +591,20 @@ PTDB MYCAT::GetTable(PGLOBAL g, PTABLE tablep, MODE mode, LPCSTR type)
{
PRELDEF tdp;
PTDB tdbp= NULL;
- LPCSTR name= tablep->GetName();
+// LPCSTR name= tablep->GetName();
if (trace)
- printf("GetTableDB: name=%s\n", name);
+ printf("GetTableDB: name=%s\n", tablep->GetName());
// Look for the description of the requested table
- tdp= GetTableDesc(g, name, type);
+ tdp= GetTableDesc(g, tablep, type);
if (tdp) {
if (trace)
printf("tdb=%p type=%s\n", tdp, tdp->GetType());
- if (tablep->GetQualifier())
- tdp->Database = SetPath(g, tablep->GetQualifier());
+ if (tablep->GetSchema())
+ tdp->Database = SetPath(g, tablep->GetSchema());
tdbp= tdp->GetTable(g, mode);
} // endif tdp
diff --git a/storage/connect/mycat.h b/storage/connect/mycat.h
index dfcbb2f6766..05163f08f1b 100644
--- a/storage/connect/mycat.h
+++ b/storage/connect/mycat.h
@@ -100,15 +100,17 @@ class MYCAT : public CATALOG {
//void SetDataPath(PGLOBAL g, const char *path)
// {SetPath(g, &DataPath, path);}
bool StoreIndex(PGLOBAL, PTABDEF) {return false;} // Temporary
- PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name,
- LPCSTR type, PRELDEF *prp = NULL);
+// PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name,
+ PRELDEF GetTableDesc(PGLOBAL g, PTABLE tablep,
+ LPCSTR type, PRELDEF *prp = NULL);
PTDB GetTable(PGLOBAL g, PTABLE tablep,
MODE mode = MODE_READ, LPCSTR type = NULL);
void ClearDB(PGLOBAL g);
protected:
- PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am);
-//void SetPath(PGLOBAL g, LPCSTR *datapath, const char *path);
+// PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am);
+ PRELDEF MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am);
+ //void SetPath(PGLOBAL g, LPCSTR *datapath, const char *path);
// Members
ha_connect *Hc; // The Connect handler
diff --git a/storage/connect/reldef.cpp b/storage/connect/reldef.cpp
index 8f9328c0b2f..e455bc8f1a5 100644
--- a/storage/connect/reldef.cpp
+++ b/storage/connect/reldef.cpp
@@ -1,11 +1,11 @@
/************* RelDef CPP Program Source Code File (.CPP) **************/
/* PROGRAM NAME: RELDEF */
/* ------------- */
-/* Version 1.4 */
+/* Version 1.5 */
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */
+/* (C) Copyright to the author Olivier BERTRAND 2004-2016 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -37,6 +37,7 @@
#include "plgdbsem.h"
#include "reldef.h"
#include "colblk.h"
+#include "tabcol.h"
#include "filamap.h"
#include "filamfix.h"
#include "filamvct.h"
@@ -217,11 +218,13 @@ TABDEF::TABDEF(void)
/***********************************************************************/
/* Define: initialize the table definition block from XDB file. */
/***********************************************************************/
-bool TABDEF::Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am)
+bool TABDEF::Define(PGLOBAL g, PCATLG cat,
+ LPCSTR name, LPCSTR schema, LPCSTR am)
{
int poff = 0;
- Name = (PSZ)PlugDup(g, name);
+ Name = (PSZ)name;
+ Schema = (PSZ)schema;
Cat = cat;
Hc = ((MYCAT*)cat)->GetHandler();
Catfunc = GetFuncID(GetStringCatInfo(g, "Catfunc", NULL));
@@ -569,7 +572,7 @@ PTABDEF OEMDEF::GetXdef(PGLOBAL g)
} // endif Cbuf
// Here "OEM" should be replace by a more useful value
- if (xdefp->Define(g, cat, Name, "OEM"))
+ if (xdefp->Define(g, cat, Name, Schema, "OEM"))
return NULL;
// Ok, return external block
diff --git a/storage/connect/reldef.h b/storage/connect/reldef.h
index dada5716dbe..bc1bd2ddd74 100644
--- a/storage/connect/reldef.h
+++ b/storage/connect/reldef.h
@@ -1,7 +1,7 @@
/*************** RelDef H Declares Source Code File (.H) ***************/
-/* Name: RELDEF.H Version 1.5 */
+/* Name: RELDEF.H Version 1.6 */
/* */
-/* (C) Copyright to the author Olivier BERTRAND 2004-2015 */
+/* (C) Copyright to the author Olivier BERTRAND 2004-2016 */
/* */
/* This file contains the DEF classes definitions. */
/***********************************************************************/
@@ -50,7 +50,8 @@ class DllExport RELDEF : public BLOCK { // Relation definition block
int GetCharCatInfo(PSZ what, PSZ sdef, char *buf, int size);
char *GetStringCatInfo(PGLOBAL g, PSZ what, PSZ sdef);
virtual int Indexable(void) {return 0;}
- virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am) = 0;
+ virtual bool Define(PGLOBAL g, PCATLG cat,
+ LPCSTR name, LPCSTR schema, LPCSTR am) = 0;
virtual PTDB GetTable(PGLOBAL g, MODE mode) = 0;
protected:
@@ -97,8 +98,9 @@ class DllExport TABDEF : public RELDEF { /* Logical table descriptor */
int GetColCatInfo(PGLOBAL g);
void SetIndexInfo(void);
bool DropTable(PGLOBAL g, PSZ name);
- virtual bool Define(PGLOBAL g, PCATLG cat, LPCSTR name, LPCSTR am);
- virtual bool DefineAM(PGLOBAL, LPCSTR, int) = 0;
+ virtual bool Define(PGLOBAL g, PCATLG cat,
+ LPCSTR name, LPCSTR schema, LPCSTR am);
+ virtual bool DefineAM(PGLOBAL, LPCSTR, int) = 0;
protected:
// Members
diff --git a/storage/connect/tabmysql.cpp b/storage/connect/tabmysql.cpp
index 658f3513b07..b9cede52a21 100644
--- a/storage/connect/tabmysql.cpp
+++ b/storage/connect/tabmysql.cpp
@@ -334,7 +334,7 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
Delayed = !!GetIntCatInfo("Delayed", 0);
} else {
// MYSQL access from a PROXY table
- Database = GetStringCatInfo(g, "Database", "*");
+ Database = GetStringCatInfo(g, "Database", Schema ? Schema : "*");
Isview = GetBoolCatInfo("View", false);
// We must get other connection parms from the calling table
diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp
index b628e26d3c7..256b454741c 100644
--- a/storage/connect/tabpivot.cpp
+++ b/storage/connect/tabpivot.cpp
@@ -348,7 +348,7 @@ bool PIVOTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
return TRUE;
Tabname = (char*)Tablep->GetName();
- DB = (char*)Tablep->GetQualifier();
+ DB = (char*)Tablep->GetSchema();
Tabsrc = (char*)Tablep->GetSrc();
Host = GetStringCatInfo(g, "Host", "localhost");
@@ -529,7 +529,7 @@ bool TDBPIVOT::GetSourceTable(PGLOBAL g)
// Get the new table description block of this source table
PTABLE tablep = new(g) XTAB("whatever", Tabsrc);
- tablep->SetQualifier(Database);
+ tablep->SetSchema(Database);
if (!(Tdbp = GetSubTable(g, tablep, true)))
return true;
diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp
index 7f979eaf4be..6b72c715517 100644
--- a/storage/connect/tabtbl.cpp
+++ b/storage/connect/tabtbl.cpp
@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to PlugDB Software Development 2008-2015 */
+/* (C) Copyright to PlugDB Software Development 2008-2016 */
/* Author: Olivier BERTRAND */
/* */
/* WHAT THIS PROGRAM DOES: */
@@ -130,10 +130,10 @@ bool TBLDEF::DefineAM(PGLOBAL g, LPCSTR, int)
// Allocate the TBLIST block for that table
tbl = new(g) XTAB(pn, def);
- tbl->SetQualifier(pdb);
+ tbl->SetSchema(pdb);
if (trace)
- htrc("TBL: Name=%s db=%s\n", tbl->GetName(), tbl->GetQualifier());
+ htrc("TBL: Name=%s db=%s\n", tbl->GetName(), tbl->GetSchema());
// Link the blocks
if (Tablep)
diff --git a/storage/connect/tabutil.cpp b/storage/connect/tabutil.cpp
index 331a7f45d4d..4069cdbed2a 100644
--- a/storage/connect/tabutil.cpp
+++ b/storage/connect/tabutil.cpp
@@ -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