Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
7cd94c68
Commit
7cd94c68
authored
Jan 10, 2016
by
Olivier Bertrand
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ob-10.0' into 10.0
parents
e37372c1
0891ae2f
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
61 additions
and
42 deletions
+61
-42
storage/connect/mycat.cc
storage/connect/mycat.cc
+17
-14
storage/connect/mycat.h
storage/connect/mycat.h
+6
-4
storage/connect/reldef.cpp
storage/connect/reldef.cpp
+8
-5
storage/connect/reldef.h
storage/connect/reldef.h
+7
-5
storage/connect/tabmysql.cpp
storage/connect/tabmysql.cpp
+1
-1
storage/connect/tabpivot.cpp
storage/connect/tabpivot.cpp
+2
-2
storage/connect/tabtbl.cpp
storage/connect/tabtbl.cpp
+3
-3
storage/connect/tabutil.cpp
storage/connect/tabutil.cpp
+17
-8
No files found.
storage/connect/mycat.cc
View file @
7cd94c68
/* Copyright (C) Olivier Bertrand 2004 - 201
5
/* Copyright (C) Olivier Bertrand 2004 - 201
6
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 - 201
5
*/
/* Author: Olivier Bertrand 2012 - 201
6
*/
/* */
/* 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
->
Get
Qualifier
())
tdp
->
Database
=
SetPath
(
g
,
tablep
->
Get
Qualifier
());
if
(
tablep
->
Get
Schema
())
tdp
->
Database
=
SetPath
(
g
,
tablep
->
Get
Schema
());
tdbp
=
tdp
->
GetTable
(
g
,
mode
);
}
// endif tdp
...
...
storage/connect/mycat.h
View file @
7cd94c68
...
...
@@ -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
...
...
storage/connect/reldef.cpp
View file @
7cd94c68
/************* 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-201
5
*/
/* (C) Copyright to the author Olivier BERTRAND 2004-201
6
*/
/* */
/* 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
...
...
storage/connect/reldef.h
View file @
7cd94c68
/*************** 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-201
5
*/
/* (C) Copyright to the author Olivier BERTRAND 2004-201
6
*/
/* */
/* 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
...
...
storage/connect/tabmysql.cpp
View file @
7cd94c68
...
...
@@ -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
...
...
storage/connect/tabpivot.cpp
View file @
7cd94c68
...
...
@@ -348,7 +348,7 @@ bool PIVOTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
return
TRUE
;
Tabname
=
(
char
*
)
Tablep
->
GetName
();
DB
=
(
char
*
)
Tablep
->
Get
Qualifier
();
DB
=
(
char
*
)
Tablep
->
Get
Schema
();
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
->
Set
Qualifier
(
Database
);
tablep
->
Set
Schema
(
Database
);
if
(
!
(
Tdbp
=
GetSubTable
(
g
,
tablep
,
true
)))
return
true
;
...
...
storage/connect/tabtbl.cpp
View file @
7cd94c68
...
...
@@ -5,7 +5,7 @@
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to PlugDB Software Development 2008-201
5
*/
/* (C) Copyright to PlugDB Software Development 2008-201
6
*/
/* 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
->
Set
Qualifier
(
pdb
);
tbl
->
Set
Schema
(
pdb
);
if
(
trace
)
htrc
(
"TBL: Name=%s db=%s
\n
"
,
tbl
->
GetName
(),
tbl
->
Get
Qualifier
());
htrc
(
"TBL: Name=%s db=%s
\n
"
,
tbl
->
GetName
(),
tbl
->
Get
Schema
());
// Link the blocks
if
(
Tablep
)
...
...
storage/connect/tabutil.cpp
View file @
7cd94c68
/************* Tabutil cpp Declares Source Code File (.CPP) ************/
/* Name: TABUTIL.CPP Version 1.1 */
/* */
/* (C) Copyright to the author Olivier BERTRAND 2013 - 201
5
*/
/* (C) Copyright to the author Olivier BERTRAND 2013 - 201
6
*/
/* */
/* 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
->
Set
Qualifier
(
db
);
Tablep
->
Set
Schema
(
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
->
Get
Qualifier
());
((
PTDBMY
)
tdbp
)
->
SetDatabase
(
tabp
->
Get
Schema
());
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
->
Get
Qualifier
();
Db
=
(
PSZ
)
tdp
->
Tablep
->
Get
Schema
();
Tab
=
(
PSZ
)
tdp
->
Tablep
->
GetName
();
}
// end of TDBTBC constructor
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment