Commit 7cd94c68 authored by Olivier Bertrand's avatar Olivier Bertrand

Merge branch 'ob-10.0' into 10.0

parents e37372c1 0891ae2f
/* 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
......
......@@ -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
......
/************* 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
......
/*************** 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
......
......@@ -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
......
......@@ -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;
......
......@@ -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)
......
/************* 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment