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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
5ce6ec3f
Commit
5ce6ec3f
authored
Jan 19, 2020
by
Oleksandr Byelkin
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'connect/10.1' into 10.1
parents
f31bf6f0
85f2217c
Changes
44
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
44 changed files
with
1299 additions
and
1010 deletions
+1299
-1010
storage/connect/CMakeLists.txt
storage/connect/CMakeLists.txt
+14
-6
storage/connect/connect.cc
storage/connect/connect.cc
+36
-33
storage/connect/connect.h
storage/connect/connect.h
+2
-0
storage/connect/filter.h
storage/connect/filter.h
+0
-1
storage/connect/ha_connect.cc
storage/connect/ha_connect.cc
+28
-40
storage/connect/inihandl.cpp
storage/connect/inihandl.cpp
+1
-1
storage/connect/jdbconn.cpp
storage/connect/jdbconn.cpp
+8
-3
storage/connect/mycat.cc
storage/connect/mycat.cc
+11
-104
storage/connect/mycat.h
storage/connect/mycat.h
+2
-2
storage/connect/myconn.cpp
storage/connect/myconn.cpp
+6
-6
storage/connect/mysql-test/connect/disabled.def
storage/connect/mysql-test/connect/disabled.def
+1
-0
storage/connect/mysql-test/connect/r/grant.result
storage/connect/mysql-test/connect/r/grant.result
+87
-87
storage/connect/mysql-test/connect/r/ini_grant.result
storage/connect/mysql-test/connect/r/ini_grant.result
+13
-13
storage/connect/mysql-test/connect/r/mysql_grant.result
storage/connect/mysql-test/connect/r/mysql_grant.result
+12
-12
storage/connect/mysql-test/connect/r/xml2_grant.result
storage/connect/mysql-test/connect/r/xml2_grant.result
+15
-15
storage/connect/mysql-test/connect/r/xml_grant.result
storage/connect/mysql-test/connect/r/xml_grant.result
+15
-15
storage/connect/mysql-test/connect/t/grant.inc
storage/connect/mysql-test/connect/t/grant.inc
+15
-15
storage/connect/mysql-test/connect/t/grant.test
storage/connect/mysql-test/connect/t/grant.test
+13
-12
storage/connect/mysql-test/connect/t/grant2.test
storage/connect/mysql-test/connect/t/grant2.test
+130
-130
storage/connect/mysql-test/connect/t/ini_grant.result
storage/connect/mysql-test/connect/t/ini_grant.result
+89
-0
storage/connect/mysql-test/connect/t/ini_grant.test
storage/connect/mysql-test/connect/t/ini_grant.test
+13
-13
storage/connect/mysql-test/connect/t/mysql_grant.test
storage/connect/mysql-test/connect/t/mysql_grant.test
+12
-12
storage/connect/plgdbsem.h
storage/connect/plgdbsem.h
+18
-11
storage/connect/reldef.cpp
storage/connect/reldef.cpp
+197
-81
storage/connect/reldef.h
storage/connect/reldef.h
+6
-3
storage/connect/restget.cpp
storage/connect/restget.cpp
+19
-23
storage/connect/tabcmg.cpp
storage/connect/tabcmg.cpp
+14
-9
storage/connect/tabdos.cpp
storage/connect/tabdos.cpp
+16
-7
storage/connect/tabdos.h
storage/connect/tabdos.h
+0
-1
storage/connect/tabfix.cpp
storage/connect/tabfix.cpp
+1
-1
storage/connect/tabfmt.cpp
storage/connect/tabfmt.cpp
+3
-2
storage/connect/tabjson.cpp
storage/connect/tabjson.cpp
+27
-17
storage/connect/tabmysql.cpp
storage/connect/tabmysql.cpp
+7
-2
storage/connect/tabodbc.cpp
storage/connect/tabodbc.cpp
+4
-2
storage/connect/tabrest.cpp
storage/connect/tabrest.cpp
+111
-31
storage/connect/tabrest.h
storage/connect/tabrest.h
+21
-0
storage/connect/tabutil.cpp
storage/connect/tabutil.cpp
+14
-2
storage/connect/tabutil.h
storage/connect/tabutil.h
+2
-1
storage/connect/tabvct.cpp
storage/connect/tabvct.cpp
+3
-0
storage/connect/tabxml.cpp
storage/connect/tabxml.cpp
+3
-1
storage/connect/valblk.cpp
storage/connect/valblk.cpp
+3
-1
storage/connect/value.cpp
storage/connect/value.cpp
+294
-289
storage/connect/xindex.cpp
storage/connect/xindex.cpp
+9
-5
storage/connect/xtable.h
storage/connect/xtable.h
+4
-1
No files found.
storage/connect/CMakeLists.txt
View file @
5ce6ec3f
...
...
@@ -73,10 +73,6 @@ ELSE(NOT UNIX)
tabwmi.cpp tabwmi.h tabmac.cpp tabmac.h macutil.cpp macutil.h
)
# Add exception handling to the CONNECT project)
SET
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
/EHsc"
)
SET
(
CMAKE_CXX_FLAGS_RELEASE
"
${
CMAKE_CXX_FLAGS_RELEASE
}
/MD"
)
SET
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
/MDd"
)
SET
(
CMAKE_CXX_FLAGS_RELWITHDEBINFO
"
${
CMAKE_CXX_FLAGS_RELWITHDEBINFO
}
/MD"
)
SET
(
CMAKE_CXX_FLAGS_MINSIZEREL
"
${
CMAKE_CXX_FLAGS_MINSIZEREL
}
/MD"
)
SET
(
IPHLPAPI_LIBRARY iphlpapi.lib
)
IF
(
MSVC
AND
(
CMAKE_CXX_COMPILER_ID MATCHES Clang
))
# Connect does not work with clang-cl
...
...
@@ -322,6 +318,9 @@ ENDIF(CONNECT_WITH_MONGO)
OPTION
(
CONNECT_WITH_REST
"Compile CONNECT storage engine with REST support"
ON
)
IF
(
CONNECT_WITH_REST
)
MESSAGE
(
STATUS
"=====> REST support is ON"
)
SET
(
CONNECT_SOURCES
${
CONNECT_SOURCES
}
tabrest.cpp tabrest.h
)
add_definitions
(
-DREST_SUPPORT
)
FIND_PACKAGE
(
cpprestsdk QUIET
)
IF
(
cpprestsdk_FOUND
)
IF
(
UNIX
)
...
...
@@ -329,9 +328,18 @@ IF(CONNECT_WITH_REST)
# If needed edit next line to set the path to libcpprest.so
SET
(
REST_LIBRARY -lcpprest
)
MESSAGE
(
STATUS
${
REST_LIBRARY
}
)
ELSE
(
NOT UNIX
)
# Next line sets debug compile mode matching cpprest_2_10d.dll
# when it was binary installed (can be change later in Visual Studio)
# Comment it out if not needed depending on your cpprestsdk installation.
SET
(
CMAKE_CXX_FLAGS_DEBUG
"
${
CMAKE_CXX_FLAGS_DEBUG
}
/MDd"
)
ENDIF
(
UNIX
)
SET
(
CONNECT_SOURCES
${
CONNECT_SOURCES
}
tabrest.cpp restget.cpp tabrest.h
)
add_definitions
(
-DREST_SUPPORT
)
# IF(REST_LIBRARY) why this? how about Windows
SET
(
CONNECT_SOURCES
${
CONNECT_SOURCES
}
restget.cpp
)
add_definitions
(
-DREST_SOURCE
)
# ENDIF()
ELSE
(
NOT cpprestsdk_FOUND
)
# MESSAGE(STATUS "=====> cpprestsdk package not found")
ENDIF
(
cpprestsdk_FOUND
)
ENDIF
(
CONNECT_WITH_REST
)
...
...
storage/connect/connect.cc
View file @
5ce6ec3f
...
...
@@ -16,7 +16,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */
/***********************************************************************/
/* Author Olivier BERTRAND bertrandop@gmail.com 2004-201
7
*/
/* Author Olivier BERTRAND bertrandop@gmail.com 2004-201
9
*/
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
...
...
@@ -389,6 +389,9 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool reset, bool mrr)
try
{
for
(
colp
=
tdbp
->
GetColumns
();
rc
==
RC_OK
&&
colp
;
colp
=
colp
->
GetNext
())
{
xtrc
(
2
,
"Going to read column %s of table %s
\n
"
,
colp
->
GetName
(),
tdbp
->
GetName
());
if
(
reset
)
colp
->
Reset
();
...
...
@@ -563,7 +566,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
rc
=
tdbp
->
DeleteDB
(
g
,
RC_EF
);
// Specific A.M. delete routine
}
else
if
(
tdbp
->
GetMode
()
==
MODE_UPDATE
&&
tdbp
->
IsIndexed
())
rc
=
((
PTDBDO
X
)
tdbp
)
->
Txfp
->
UpdateSortedRows
(
g
);
rc
=
((
PTDBDO
S
)
tdbp
)
->
GetTxfp
()
->
UpdateSortedRows
(
g
);
switch
(
rc
)
{
case
RC_FX
:
...
...
@@ -590,7 +593,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
if
(
!
tdbp
->
IsRemote
())
{
// Make all the eventual indexes
PTDBDO
X
tbxp
=
(
PTDBDOX
)
tdbp
;
PTDBDO
S
tbxp
=
(
PTDBDOS
)
tdbp
;
tbxp
->
ResetKindex
(
g
,
NULL
);
tbxp
->
SetKey_Col
(
NULL
);
rc
=
tbxp
->
ResetTableOpt
(
g
,
true
,
tbxp
->
GetDef
()
->
Indexable
()
==
1
);
...
...
@@ -619,8 +622,8 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)
int
CntIndexInit
(
PGLOBAL
g
,
PTDB
ptdb
,
int
id
,
bool
sorted
)
{
PIXDEF
xdp
;
PTDBDO
X
tdbp
;
DO
X
DEF
*
dfp
;
PTDBDO
S
tdbp
;
DO
S
DEF
*
dfp
;
if
(
!
ptdb
)
return
-
1
;
...
...
@@ -630,9 +633,9 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted)
}
else
if
(
ptdb
->
GetDef
()
->
Indexable
()
==
3
)
{
return
1
;
}
else
tdbp
=
(
PTDBDO
X
)
ptdb
;
tdbp
=
(
PTDBDO
S
)
ptdb
;
dfp
=
(
DO
XDEF
*
)
tdbp
->
To_Def
;
dfp
=
(
DO
SDEF
*
)
tdbp
->
GetDef
()
;
//if (!(k= colp->GetKey()))
// if (colp->GetOpt() >= 2) {
...
...
@@ -642,16 +645,16 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted)
// This is a pseudo indexed sorted block optimized column
// return 0;
if
(
tdbp
->
To_Kindex
)
if
(((
XXBASE
*
)
tdbp
->
To_Kindex
)
->
GetID
()
==
id
)
{
tdbp
->
To_Kindex
->
Reset
();
// Same index
return
(
tdbp
->
To_Kindex
->
IsMul
())
?
2
:
1
;
if
(
tdbp
->
GetKindex
()
)
if
(((
XXBASE
*
)
tdbp
->
GetKindex
()
)
->
GetID
()
==
id
)
{
tdbp
->
GetKindex
()
->
Reset
();
// Same index
return
(
tdbp
->
GetKindex
()
->
IsMul
())
?
2
:
1
;
}
else
{
tdbp
->
To_Kindex
->
Close
();
tdbp
->
To_Kindex
=
NULL
;
tdbp
->
GetKindex
()
->
Close
();
tdbp
->
SetKindex
(
NULL
)
;
}
// endif colp
for
(
xdp
=
dfp
->
To_Indx
;
xdp
;
xdp
=
xdp
->
GetNext
())
for
(
xdp
=
dfp
->
GetIndx
()
;
xdp
;
xdp
=
xdp
->
GetNext
())
if
(
xdp
->
GetID
()
==
id
)
break
;
...
...
@@ -673,7 +676,7 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted)
if
(
tdbp
->
InitialyzeIndex
(
g
,
xdp
,
sorted
))
return
0
;
return
(
tdbp
->
To_Kindex
->
IsMul
())
?
2
:
1
;
return
(
tdbp
->
GetKindex
()
->
IsMul
())
?
2
:
1
;
}
// end of CntIndexInit
#if defined(WORDS_BIGENDIAN)
...
...
@@ -707,7 +710,7 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
int
n
,
x
;
RCODE
rc
;
XXBASE
*
xbp
;
PTDBDO
X
tdbp
;
PTDBDO
S
tdbp
;
if
(
!
ptdb
)
return
RC_FX
;
...
...
@@ -733,12 +736,12 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
goto
rnd
;
}
else
tdbp
=
(
PTDBDO
X
)
ptdb
;
tdbp
=
(
PTDBDO
S
)
ptdb
;
// Set reference values and index operator
if
(
!
tdbp
->
To_Link
||
!
tdbp
->
To_Kindex
)
{
if
(
!
tdbp
->
GetLink
()
||
!
tdbp
->
GetKindex
()
)
{
// if (!tdbp->To_Xdp) {
sprintf
(
g
->
Message
,
"Index not initialized for table %s"
,
tdbp
->
Name
);
sprintf
(
g
->
Message
,
"Index not initialized for table %s"
,
tdbp
->
GetName
()
);
return
RC_FX
;
#if 0
} // endif !To_Xdp
...
...
@@ -751,7 +754,7 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
#endif // 0
}
// endif !To_Kindex
xbp
=
(
XXBASE
*
)
tdbp
->
To_Kindex
;
xbp
=
(
XXBASE
*
)
tdbp
->
GetKindex
()
;
if
(
kr
)
{
char
*
kp
=
(
char
*
)
kr
->
key
;
...
...
@@ -761,13 +764,13 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
PVAL
valp
;
PCOL
colp
;
for
(
n
=
0
;
n
<
tdbp
->
Knum
;
n
++
)
{
colp
=
(
PCOL
)
tdbp
->
To_Key_Col
[
n
]
;
for
(
n
=
0
;
n
<
tdbp
->
GetKnum
()
;
n
++
)
{
colp
=
(
PCOL
)
tdbp
->
Key
(
n
)
;
if
(
colp
->
GetColUse
(
U_NULLS
))
kp
++
;
// Skip null byte
valp
=
tdbp
->
To_Link
[
n
]
->
GetValue
();
valp
=
tdbp
->
Link
(
n
)
->
GetValue
();
if
(
!
valp
->
IsTypeNum
())
{
if
(
colp
->
GetColUse
(
U_VAR
))
{
...
...
@@ -837,7 +840,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
bool
b
,
rcb
;
PVAL
valp
;
PCOL
colp
;
PTDBDO
X
tdbp
;
PTDBDO
S
tdbp
;
XXBASE
*
xbp
;
if
(
!
ptdb
)
...
...
@@ -862,35 +865,35 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
return
k
[
1
]
-
k
[
0
]
+
1
;
}
else
tdbp
=
(
PTDBDO
X
)
ptdb
;
tdbp
=
(
PTDBDO
S
)
ptdb
;
if
(
!
tdbp
->
To_Kindex
||
!
tdbp
->
To_Link
)
{
if
(
!
tdbp
->
To_Xdp
)
{
sprintf
(
g
->
Message
,
"Index not initialized for table %s"
,
tdbp
->
Name
);
if
(
!
tdbp
->
GetKindex
()
||
!
tdbp
->
GetLink
()
)
{
if
(
!
tdbp
->
GetXdp
()
)
{
sprintf
(
g
->
Message
,
"Index not initialized for table %s"
,
tdbp
->
GetName
()
);
DBUG_PRINT
(
"Range"
,
(
"%s"
,
g
->
Message
));
return
-
1
;
}
else
// Dynamic index
return
tdbp
->
To_Xdp
->
GetMaxSame
();
// TODO a better estimate
return
tdbp
->
GetXdp
()
->
GetMaxSame
();
// TODO a better estimate
}
else
xbp
=
(
XXBASE
*
)
tdbp
->
To_Kindex
;
xbp
=
(
XXBASE
*
)
tdbp
->
GetKindex
()
;
for
(
b
=
false
,
i
=
0
;
i
<
2
;
i
++
)
{
p
=
kp
=
key
[
i
];
if
(
kp
)
{
for
(
n
=
0
;
n
<
tdbp
->
Knum
;
n
++
)
{
for
(
n
=
0
;
n
<
tdbp
->
GetKnum
()
;
n
++
)
{
if
(
kmap
[
i
]
&
(
key_part_map
)(
1
<<
n
))
{
if
(
b
==
true
)
// Cannot do indexing with missing intermediate key
return
-
1
;
colp
=
(
PCOL
)
tdbp
->
To_Key_Col
[
n
]
;
colp
=
(
PCOL
)
tdbp
->
Key
(
n
)
;
if
(
colp
->
GetColUse
(
U_NULLS
))
p
++
;
// Skip null byte ???
valp
=
tdbp
->
To_Link
[
n
]
->
GetValue
();
valp
=
tdbp
->
Link
(
n
)
->
GetValue
();
if
(
!
valp
->
IsTypeNum
())
{
if
(
colp
->
GetColUse
(
U_VAR
))
{
...
...
storage/connect/connect.h
View file @
5ce6ec3f
...
...
@@ -46,6 +46,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
bool
*
incl
,
key_part_map
*
kmap
);
PGLOBAL
CntExit
(
PGLOBAL
g
);
#if 0
/***********************************************************************/
/* Definition of classes XKPDEF, DOXDEF, TDBDOX */
/* These classes purpose is chiefly to access protected items! */
...
...
@@ -76,3 +77,4 @@ class XKPDEF: public KPARTDEF {
public:
XKPDEF(const char *name, int n) : KPARTDEF((PSZ)name, n) {}
}; // end of class XKPDEF
#endif // 0
storage/connect/filter.h
View file @
5ce6ec3f
...
...
@@ -48,7 +48,6 @@ class DllExport FILTER : public XOBJECT { /* Filter description block */
PVAL
&
Val
(
int
i
)
{
return
Test
[
i
].
Value
;}
bool
&
Conv
(
int
i
)
{
return
Test
[
i
].
Conv
;}
void
SetNext
(
PFIL
filp
)
{
Next
=
filp
;}
bool
MakeSelector
(
PGLOBAL
g
,
PSTRG
s
);
// Methods
virtual
void
Reset
(
void
);
...
...
storage/connect/ha_connect.cc
View file @
5ce6ec3f
...
...
@@ -170,9 +170,9 @@
#define JSONMAX 10 // JSON Default max grp size
extern
"C"
{
char
version
[]
=
"Version 1.0
6.0010 June 01
, 2019"
;
char
version
[]
=
"Version 1.0
7.0001 November 12
, 2019"
;
#if defined(__WIN__)
char
compver
[]
=
"Version 1.0
6.0010
"
__DATE__
" "
__TIME__
;
char
compver
[]
=
"Version 1.0
7.0001
"
__DATE__
" "
__TIME__
;
char
slash
=
'\\'
;
#else // !__WIN__
char
slash
=
'/'
;
...
...
@@ -1045,6 +1045,8 @@ TABTYPE ha_connect::GetRealType(PTOS pos)
case
TAB_REST
:
type
=
TAB_NIY
;
break
;
default:
break
;
}
// endswitch type
#endif // REST_SUPPORT
...
...
@@ -2964,10 +2966,12 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond)
case
Item_func
:
:
LE_FUNC
:
vop
=
OP_LE
;
break
;
case
Item_func
:
:
GE_FUNC
:
vop
=
OP_GE
;
break
;
case
Item_func
:
:
GT_FUNC
:
vop
=
OP_GT
;
break
;
#if MYSQL_VERSION_ID > 100200
case
Item_func
:
:
LIKE_FUNC
:
vop
=
OP_LIKE
;
neg
=
((
Item_func_opt_neg
*
)
condf
)
->
negated
;
break
;
vop
=
OP_LIKE
;
neg
=
((
Item_func_like
*
)
condf
)
->
negated
;
break
;
#endif // VERSION_ID > 100200
case
Item_func
:
:
ISNOTNULL_FUNC
:
neg
=
true
;
// fall through
...
...
@@ -3785,9 +3789,9 @@ int ha_connect::index_init(uint idx, bool sorted)
active_index
=
MAX_KEY
;
rc
=
HA_ERR_INTERNAL_ERROR
;
}
else
if
(
tdbp
->
GetKindex
())
{
if
(((
PTDBDO
X
)
tdbp
)
->
To_Kindex
->
GetNum_K
())
{
if
(((
PTDBDO
S
)
tdbp
)
->
GetKindex
()
->
GetNum_K
())
{
if
(
tdbp
->
GetFtype
()
!=
RECFM_NAF
)
((
PTDBDO
X
)
tdbp
)
->
GetTxfp
()
->
ResetBuffer
(
g
);
((
PTDBDO
S
)
tdbp
)
->
GetTxfp
()
->
ResetBuffer
(
g
);
active_index
=
idx
;
// } else { // Void table
...
...
@@ -4503,34 +4507,13 @@ bool ha_connect::check_privileges(THD *thd, PTOS options, char *dbn, bool quick)
case
TAB_DIR
:
case
TAB_ZIP
:
case
TAB_OEM
:
#ifdef NO_EMBEDDED_ACCESS_CHECKS
return
false
;
#endif
/*
Check FILE_ACL
If table or table->mdl_ticket is NULL - it's a DLL, e.g. CREATE TABLE.
if the table has an MDL_EXCLUSIVE lock - it's a DDL too, e.g. the
insert step of CREATE ... SELECT.
Otherwise it's a DML, the table was normally opened, locked,
privilege were already checked, and table->grant.privilege is set.
With SQL SECURITY DEFINER, table->grant.privilege has definer's privileges.
Unless we're in prelocking mode, in this case table->grant.privilege
is only checked in start_stmt(), not in external_lock().
*/
if
(
!
table
||
!
table
->
mdl_ticket
||
table
->
mdl_ticket
->
get_type
()
==
MDL_EXCLUSIVE
)
return
check_access
(
thd
,
FILE_ACL
,
db
,
NULL
,
NULL
,
0
,
0
);
if
((
!
quick
&&
thd
->
lex
->
requires_prelocking
())
||
table
->
grant
.
privilege
&
FILE_ACL
)
return
false
;
status_var_increment
(
thd
->
status_var
.
access_denied_errors
);
my_error
(
access_denied_error_code
(
thd
->
password
),
MYF
(
0
),
thd
->
security_ctx
->
priv_user
,
thd
->
security_ctx
->
priv_host
,
(
thd
->
password
?
ER
(
ER_YES
)
:
ER
(
ER_NO
)));
return
true
;
if
(
table
&&
table
->
pos_in_table_list
)
// if SELECT
{
//Switch_to_definer_security_ctx backup_ctx(thd, table->pos_in_table_list);
return
check_global_access
(
thd
,
FILE_ACL
);
}
else
return
check_global_access
(
thd
,
FILE_ACL
);
case
TAB_ODBC
:
case
TAB_JDBC
:
case
TAB_MONGO
:
...
...
@@ -5653,6 +5636,8 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
case
TAB_CSV
:
ttp
=
TAB_REST
;
break
;
default:
break
;
}
// endswitch type
#endif // REST_SUPPORT
}
// endif ttp
...
...
@@ -6062,7 +6047,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
}
// endif !nblin
for
(
i
=
0
;
!
rc
&&
i
<
qrp
->
Nblin
;
i
++
)
{
typ
=
len
=
prec
=
dec
=
0
;
typ
=
len
=
prec
=
dec
=
flg
=
0
;
tm
=
NOT_NULL_FLAG
;
cnm
=
(
char
*
)
"noname"
;
dft
=
xtra
=
key
=
fmt
=
tn
=
NULL
;
...
...
@@ -6102,6 +6087,9 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
if
(
crp
->
Kdata
->
GetIntValue
(
i
))
tm
=
0
;
// Nullable
break
;
case
FLD_FLAG
:
flg
=
crp
->
Kdata
->
GetIntValue
(
i
);
break
;
case
FLD_FORMAT
:
fmt
=
(
crp
->
Kdata
)
?
crp
->
Kdata
->
GetCharValue
(
i
)
:
NULL
;
...
...
@@ -6233,7 +6221,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
// Now add the field
if
(
add_field
(
&
sql
,
cnm
,
typ
,
prec
,
dec
,
key
,
tm
,
rem
,
dft
,
xtra
,
fmt
,
0
,
dbf
,
v
))
fmt
,
flg
,
dbf
,
v
))
rc
=
HA_ERR_OUT_OF_MEM
;
}
// endfor i
...
...
@@ -7379,14 +7367,14 @@ maria_declare_plugin(connect)
&
connect_storage_engine
,
"CONNECT"
,
"Olivier Bertrand"
,
"Management of External Data (SQL/NOSQL/MED), including
many file forma
ts"
,
"Management of External Data (SQL/NOSQL/MED), including
Rest query resul
ts"
,
PLUGIN_LICENSE_GPL
,
connect_init_func
,
/* Plugin Init */
connect_done_func
,
/* Plugin Deinit */
0x010
6
,
/* version number (1.06
) */
0x010
7
,
/* version number (1.07
) */
NULL
,
/* status variables */
connect_system_variables
,
/* system variables */
"1.0
6.0010
"
,
/* string version */
"1.0
7.0001
"
,
/* string version */
MariaDB_PLUGIN_MATURITY_STABLE
/* maturity */
}
maria_declare_plugin_end
;
storage/connect/inihandl.cpp
View file @
5ce6ec3f
...
...
@@ -194,7 +194,7 @@ static void PROFILE_Save( FILE *file, PROFILESECTION *section )
}
for
(
key
=
section
->
key
;
key
;
key
=
key
->
next
)
if
(
key
->
name
[
0
])
{
if
(
key
->
name
&&
key
->
name
[
0
])
{
fprintf
(
file
,
"%s"
,
SVP
(
key
->
name
));
if
(
key
->
value
)
...
...
storage/connect/jdbconn.cpp
View file @
5ce6ec3f
...
...
@@ -1196,9 +1196,14 @@ int JDBConn::GetResultSize(PCSZ sql, PCOL colp)
if
((
rc
=
ExecuteQuery
(
sql
))
!=
RC_OK
)
return
-
1
;
if
((
rc
=
Fetch
())
>
0
)
SetColumnValue
(
1
,
NULL
,
colp
->
GetValue
());
else
if
((
rc
=
Fetch
())
>
0
)
{
try
{
SetColumnValue
(
1
,
NULL
,
colp
->
GetValue
());
}
catch
(...)
{
return
-
4
;
}
// end catch
}
else
return
-
2
;
if
((
rc
=
Fetch
())
!=
0
)
...
...
storage/connect/mycat.cc
View file @
5ce6ec3f
...
...
@@ -95,7 +95,7 @@
#endif // ZIP_SUPPORT
#if defined(REST_SUPPORT)
#include "tabrest.h"
#endif // R
est
_SUPPORT
#endif // R
EST
_SUPPORT
#include "mycat.h"
/***********************************************************************/
...
...
@@ -104,8 +104,9 @@
#if defined(__WIN__)
extern
"C"
HINSTANCE
s_hModule
;
// Saved module handle
#endif // !__WIN__
PQRYRES
OEMColumns
(
PGLOBAL
g
,
PTOS
topt
,
char
*
tab
,
char
*
db
,
bool
info
);
#if defined(JAVA_SUPPORT) || defined(CMGO_SUPPORT)
bool
MongoEnabled
(
void
);
#endif // JAVA_SUPPORT || CMGO_SUPPORT
/***********************************************************************/
/* Get the plugin directory. */
...
...
@@ -347,100 +348,6 @@ uint GetFuncID(const char *func)
return
fnc
;
}
// end of GetFuncID
/***********************************************************************/
/* OEMColumn: Get table column info for an OEM table. */
/***********************************************************************/
PQRYRES
OEMColumns
(
PGLOBAL
g
,
PTOS
topt
,
char
*
tab
,
char
*
db
,
bool
info
)
{
typedef
PQRYRES
(
__stdcall
*
XCOLDEF
)
(
PGLOBAL
,
void
*
,
char
*
,
char
*
,
bool
);
const
char
*
module
,
*
subtype
;
char
c
,
soname
[
_MAX_PATH
],
getname
[
40
]
=
"Col"
;
#if defined(__WIN__)
HANDLE
hdll
;
/* Handle to the external DLL */
#else // !__WIN__
void
*
hdll
;
/* Handle for the loaded shared library */
#endif // !__WIN__
XCOLDEF
coldef
=
NULL
;
PQRYRES
qrp
=
NULL
;
module
=
topt
->
module
;
subtype
=
topt
->
subtype
;
if
(
!
module
||
!
subtype
)
return
NULL
;
/*********************************************************************/
/* Ensure that the .dll doesn't have a path. */
/* This is done to ensure that only approved dll from the system */
/* directories are used (to make this even remotely secure). */
/*********************************************************************/
if
(
check_valid_path
(
module
,
strlen
(
module
)))
{
strcpy
(
g
->
Message
,
"Module cannot contain a path"
);
return
NULL
;
}
else
PlugSetPath
(
soname
,
module
,
GetPluginDir
());
// The exported name is always in uppercase
for
(
int
i
=
0
;
;
i
++
)
{
c
=
subtype
[
i
];
getname
[
i
+
3
]
=
toupper
(
c
);
if
(
!
c
)
break
;
}
// endfor i
#if defined(__WIN__)
// Load the Dll implementing the table
if
(
!
(
hdll
=
LoadLibrary
(
soname
)))
{
char
buf
[
256
];
DWORD
rc
=
GetLastError
();
sprintf
(
g
->
Message
,
MSG
(
DLL_LOAD_ERROR
),
rc
,
soname
);
FormatMessage
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
NULL
,
rc
,
0
,
(
LPTSTR
)
buf
,
sizeof
(
buf
),
NULL
);
strcat
(
strcat
(
g
->
Message
,
": "
),
buf
);
return
NULL
;
}
// endif hDll
// Get the function returning an instance of the external DEF class
if
(
!
(
coldef
=
(
XCOLDEF
)
GetProcAddress
((
HINSTANCE
)
hdll
,
getname
)))
{
sprintf
(
g
->
Message
,
MSG
(
PROCADD_ERROR
),
GetLastError
(),
getname
);
FreeLibrary
((
HMODULE
)
hdll
);
return
NULL
;
}
// endif coldef
#else // !__WIN__
const
char
*
error
=
NULL
;
// Load the desired shared library
if
(
!
(
hdll
=
dlopen
(
soname
,
RTLD_LAZY
)))
{
error
=
dlerror
();
sprintf
(
g
->
Message
,
MSG
(
SHARED_LIB_ERR
),
soname
,
SVP
(
error
));
return
NULL
;
}
// endif Hdll
// Get the function returning an instance of the external DEF class
if
(
!
(
coldef
=
(
XCOLDEF
)
dlsym
(
hdll
,
getname
)))
{
error
=
dlerror
();
sprintf
(
g
->
Message
,
MSG
(
GET_FUNC_ERR
),
getname
,
SVP
(
error
));
dlclose
(
hdll
);
return
NULL
;
}
// endif coldef
#endif // !__WIN__
// Just in case the external Get function does not set error messages
sprintf
(
g
->
Message
,
"Error getting column info from %s"
,
subtype
);
// Get the table column definition
qrp
=
coldef
(
g
,
topt
,
tab
,
db
,
info
);
#if defined(__WIN__)
FreeLibrary
((
HMODULE
)
hdll
);
#else // !__WIN__
dlclose
(
hdll
);
#endif // !__WIN__
return
qrp
;
}
// end of OEMColumns
/* ------------------------- Class CATALOG --------------------------- */
/***********************************************************************/
...
...
@@ -481,10 +388,10 @@ void MYCAT::Reset(void)
/* GetTableDesc: retrieve a table descriptor. */
/* Look for a table descriptor matching the name and type. */
/***********************************************************************/
P
REL
DEF
MYCAT
::
GetTableDesc
(
PGLOBAL
g
,
PTABLE
tablep
,
P
TAB
DEF
MYCAT
::
GetTableDesc
(
PGLOBAL
g
,
PTABLE
tablep
,
LPCSTR
type
,
PRELDEF
*
)
{
P
REL
DEF
tdp
=
NULL
;
P
TAB
DEF
tdp
=
NULL
;
if
(
trace
(
1
))
htrc
(
"GetTableDesc: name=%s am=%s
\n
"
,
tablep
->
GetName
(),
SVP
(
type
));
...
...
@@ -505,12 +412,12 @@ PRELDEF MYCAT::GetTableDesc(PGLOBAL g, PTABLE tablep,
/* MakeTableDesc: make a table/view description. */
/* Note: caller must check if name already exists before calling it. */
/***********************************************************************/
P
REL
DEF
MYCAT
::
MakeTableDesc
(
PGLOBAL
g
,
PTABLE
tablep
,
LPCSTR
am
)
P
TAB
DEF
MYCAT
::
MakeTableDesc
(
PGLOBAL
g
,
PTABLE
tablep
,
LPCSTR
am
)
{
TABTYPE
tc
;
LPCSTR
name
=
(
PSZ
)
PlugDup
(
g
,
tablep
->
GetName
());
LPCSTR
schema
=
(
PSZ
)
PlugDup
(
g
,
tablep
->
GetSchema
());
P
REL
DEF
tdp
=
NULL
;
P
TAB
DEF
tdp
=
NULL
;
if
(
trace
(
1
))
htrc
(
"MakeTableDesc: name=%s schema=%s am=%s
\n
"
,
...
...
@@ -578,8 +485,8 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am)
}
// endswitch
// Do make the table/view definition
if
(
tdp
&&
tdp
->
Define
(
g
,
this
,
name
,
schema
,
am
))
tdp
=
NULL
;
if
(
tdp
&&
tdp
->
Define
(
g
,
this
,
name
,
schema
,
am
))
tdp
=
NULL
;
if
(
trace
(
1
))
htrc
(
"Table %s made
\n
"
,
am
);
...
...
@@ -592,7 +499,7 @@ PRELDEF MYCAT::MakeTableDesc(PGLOBAL g, PTABLE tablep, LPCSTR am)
/***********************************************************************/
PTDB
MYCAT
::
GetTable
(
PGLOBAL
g
,
PTABLE
tablep
,
MODE
mode
,
LPCSTR
type
)
{
P
REL
DEF
tdp
;
P
TAB
DEF
tdp
;
PTDB
tdbp
=
NULL
;
// LPCSTR name= tablep->GetName();
...
...
storage/connect/mycat.h
View file @
5ce6ec3f
...
...
@@ -102,14 +102,14 @@ class MYCAT : public CATALOG {
// Methods
void
Reset
(
void
);
bool
StoreIndex
(
PGLOBAL
,
PTABDEF
)
{
return
false
;}
// Temporary
P
REL
DEF
GetTableDesc
(
PGLOBAL
g
,
PTABLE
tablep
,
P
TAB
DEF
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:
P
REL
DEF
MakeTableDesc
(
PGLOBAL
g
,
PTABLE
tablep
,
LPCSTR
am
);
P
TAB
DEF
MakeTableDesc
(
PGLOBAL
g
,
PTABLE
tablep
,
LPCSTR
am
);
// Members
ha_connect
*
Hc
;
// The Connect handler
...
...
storage/connect/myconn.cpp
View file @
5ce6ec3f
...
...
@@ -472,7 +472,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
int
pt
,
const
char
*
csname
)
{
const
char
*
pipe
=
NULL
;
uint
cto
=
10
,
nrt
=
20
;
//uint
cto = 10, nrt = 20;
my_bool
my_true
=
1
;
m_DB
=
mysql_init
(
NULL
);
...
...
@@ -485,11 +485,11 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
if
(
trace
(
1
))
htrc
(
"MYSQLC Open: m_DB=%.4X size=%d
\n
"
,
m_DB
,
(
int
)
sizeof
(
*
m_DB
));
// Removed to do like FEDERATED do
// Removed to do like FEDERATED do
es
//mysql_options(m_DB, MYSQL_READ_DEFAULT_GROUP, "client-mariadb");
mysql_options
(
m_DB
,
MYSQL_OPT_USE_REMOTE_CONNECTION
,
NULL
);
mysql_options
(
m_DB
,
MYSQL_OPT_CONNECT_TIMEOUT
,
&
cto
);
mysql_options
(
m_DB
,
MYSQL_OPT_READ_TIMEOUT
,
&
nrt
);
//
mysql_options(m_DB, MYSQL_OPT_USE_REMOTE_CONNECTION, NULL);
//
mysql_options(m_DB, MYSQL_OPT_CONNECT_TIMEOUT, &cto);
//
mysql_options(m_DB, MYSQL_OPT_READ_TIMEOUT, &nrt);
//mysql_options(m_DB, MYSQL_OPT_WRITE_TIMEOUT, ...);
#if defined(__WIN__)
...
...
@@ -879,7 +879,7 @@ MYSQL_FIELD *MYSQLC::GetNextField(void)
PQRYRES
MYSQLC
::
GetResult
(
PGLOBAL
g
,
bool
pdb
)
{
PCSZ
fmt
;
char
*
name
,
v
;
char
*
name
,
v
=
0
;
int
n
;
bool
uns
;
PCOLRES
*
pcrp
,
crp
;
...
...
storage/connect/mysql-test/connect/disabled.def
View file @
5ce6ec3f
...
...
@@ -20,4 +20,5 @@ mongo_c : Need MongoDB running and its C Driver installed
mongo_java_2 : Need MongoDB running and its Java Driver installed
mongo_java_3 : Need MongoDB running and its Java Driver installed
tbl_thread : Bug MDEV-9844,10179,14214 03/01/2018 OB Option THREAD removed
grant2 : Until fixed
#vcol : Different error code on different versions
storage/connect/mysql-test/connect/r/grant.result
View file @
5ce6ec3f
This diff is collapsed.
Click to expand it.
storage/connect/mysql-test/connect/r/ini_grant.result
View file @
5ce6ec3f
...
...
@@ -32,7 +32,7 @@ sec val
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT';
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
SELECT user();
user()
root@localhost
...
...
@@ -42,21 +42,21 @@ SELECT user();
user()
user@localhost
INSERT INTO t1 VALUES ('sec2','val2');
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
SELECT * FROM t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
UPDATE t1 SET val='val11';
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DELETE FROM t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
TRUNCATE TABLE t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
ALTER TABLE t1 READONLY=1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DROP TABLE t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
CREATE VIEW v1 AS SELECT * FROM t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
# Testing a VIEW created with FILE privileges but accessed with no FILE
SELECT user();
user()
...
...
@@ -66,13 +66,13 @@ SELECT user();
user()
user@localhost
SELECT * FROM v1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
INSERT INTO v1 VALUES ('sec3','val3');
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
UPDATE v1 SET val='val11';
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DELETE FROM v1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DROP VIEW v1;
DROP TABLE t1;
DROP USER user@localhost;
...
...
storage/connect/mysql-test/connect/r/mysql_grant.result
View file @
5ce6ec3f
...
...
@@ -9,7 +9,7 @@ SELECT user();
user()
user@localhost
CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=MySQL OPTION_LIST='host=localhost,user=root1,port=PORT';
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
SELECT user();
user()
root@localhost
...
...
@@ -25,19 +25,19 @@ SELECT user();
user()
user@localhost
SELECT * FROM t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
INSERT INTO t1 VALUES ('xxx');
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DELETE FROM t1 WHERE a='xxx';
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
UPDATE t1 SET a='yyy' WHERE a='xxx';
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
TRUNCATE TABLE t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
ALTER TABLE t1 READONLY=1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
CREATE VIEW v1 AS SELECT * FROM t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
# Testing a VIEW created with FILE privileges but accessed with no FILE
SELECT user();
user()
...
...
@@ -47,13 +47,13 @@ SELECT user();
user()
user@localhost
SELECT * FROM v1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
INSERT INTO v1 VALUES (2);
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
UPDATE v1 SET a=123;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DELETE FROM v1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
SELECT user();
user()
root@localhost
...
...
storage/connect/mysql-test/connect/r/xml2_grant.result
View file @
5ce6ec3f
...
...
@@ -33,7 +33,7 @@ a
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=libxml2,rownode=row' FILE_NAME='t1.EXT';
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
SELECT user();
user()
root@localhost
...
...
@@ -43,23 +43,23 @@ SELECT user();
user()
user@localhost
INSERT INTO t1 VALUES (10);
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
SELECT * FROM t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
UPDATE t1 SET a=20;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DELETE FROM t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
TRUNCATE TABLE t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
ALTER TABLE t1 READONLY=1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
ALTER TABLE t1 FILE_NAME='t2.EXT';
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DROP TABLE t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
CREATE VIEW v1 AS SELECT * FROM t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
# Testing a VIEW created with FILE privileges but accessed with no FILE
SELECT user();
user()
...
...
@@ -69,13 +69,13 @@ SELECT user();
user()
user@localhost
SELECT * FROM v1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
INSERT INTO v1 VALUES (2);
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
UPDATE v1 SET a=123;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DELETE FROM v1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
SELECT user();
user()
root@localhost
...
...
@@ -89,7 +89,7 @@ SELECT user();
user()
user@localhost
ALTER TABLE t1 FILE_NAME='t1.EXT';
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DROP TABLE t1;
DROP USER user@localhost;
#
...
...
storage/connect/mysql-test/connect/r/xml_grant.result
View file @
5ce6ec3f
...
...
@@ -31,7 +31,7 @@ a
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (a INT NOT NULL) ENGINE=CONNECT TABLE_TYPE=XML OPTION_LIST='xmlsup=domdoc,rownode=row' FILE_NAME='t1.EXT';
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
SELECT user();
user()
root@localhost
...
...
@@ -41,23 +41,23 @@ SELECT user();
user()
user@localhost
INSERT INTO t1 VALUES (10);
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
SELECT * FROM t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
UPDATE t1 SET a=20;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DELETE FROM t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
TRUNCATE TABLE t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
ALTER TABLE t1 READONLY=1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
ALTER TABLE t1 FILE_NAME='t2.EXT';
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DROP TABLE t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
CREATE VIEW v1 AS SELECT * FROM t1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
# Testing a VIEW created with FILE privileges but accessed with no FILE
SELECT user();
user()
...
...
@@ -67,13 +67,13 @@ SELECT user();
user()
user@localhost
SELECT * FROM v1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
INSERT INTO v1 VALUES (2);
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
UPDATE v1 SET a=123;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DELETE FROM v1;
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
SELECT user();
user()
root@localhost
...
...
@@ -87,7 +87,7 @@ SELECT user();
user()
user@localhost
ALTER TABLE t1 FILE_NAME='t1.EXT';
ERROR
28000: Access denied for user 'user'@'localhost' (using password: NO)
ERROR
42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DROP TABLE t1;
DROP USER user@localhost;
#
...
...
storage/connect/mysql-test/connect/t/grant.inc
View file @
5ce6ec3f
...
...
@@ -25,7 +25,7 @@ DROP TABLE t1;
# Making sure DROP erased the data file
--
error
1
--
remove_file
$MYSQLD_DATADIR
/
test
/
t1
.
$FILE_EXT
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
--
eval
CREATE
TABLE
t1
(
a
INT
NOT
NULL
)
ENGINE
=
CONNECT
$TABLE_OPTIONS
FILE_NAME
=
't1.EXT'
--
connection
default
SELECT
user
();
...
...
@@ -33,23 +33,23 @@ SELECT user();
INSERT
INTO
t1
VALUES
(
10
);
--
connection
user
SELECT
user
();
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
INSERT
INTO
t1
VALUES
(
10
);
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
SELECT
*
FROM
t1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
UPDATE
t1
SET
a
=
20
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
DELETE
FROM
t1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
TRUNCATE
TABLE
t1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
ALTER
TABLE
t1
READONLY
=
1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
ALTER
TABLE
t1
FILE_NAME
=
't2.EXT'
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
DROP
TABLE
t1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
CREATE
VIEW
v1
AS
SELECT
*
FROM
t1
;
--
echo
# Testing a VIEW created with FILE privileges but accessed with no FILE
--
connection
default
...
...
@@ -57,13 +57,13 @@ SELECT user();
CREATE
SQL
SECURITY
INVOKER
VIEW
v1
AS
SELECT
*
FROM
t1
;
--
connection
user
SELECT
user
();
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
SELECT
*
FROM
v1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
INSERT
INTO
v1
VALUES
(
2
);
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
UPDATE
v1
SET
a
=
123
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
DELETE
FROM
v1
;
--
connection
default
SELECT
user
();
...
...
@@ -74,7 +74,7 @@ DROP TABLE t1;
INSERT
INTO
t1
VALUES
(
10
);
--
connection
user
SELECT
user
();
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
ALTER
TABLE
t1
FILE_NAME
=
't1.EXT'
;
--
connection
default
DROP
TABLE
t1
;
...
...
storage/connect/mysql-test/connect/t/grant.test
View file @
5ce6ec3f
...
...
@@ -11,7 +11,7 @@ REVOKE FILE ON *.* FROM user@localhost;
--
connect
(
user
,
localhost
,
user
,,)
--
connection
user
SELECT
user
();
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
CREATE
TABLE
t1
(
path
VARCHAR
(
256
)
NOT
NULL
flag
=
1
,
fname
VARCHAR
(
256
)
NOT
NULL
,
...
...
@@ -28,23 +28,24 @@ CREATE TABLE t1 (
)
ENGINE
=
CONNECT
TABLE_TYPE
=
DIR
FILE_NAME
=
'*.*'
;
# "size>0" to skip directory names on Windows
--
replace_result
$MYSQLD_DATADIR
DATADIR
/
--
sorted_result
SELECT
fname
,
ftype
,
size
FROM
t1
WHERE
size
>
0
;
--
connection
user
SELECT
user
();
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
SELECT
*
FROM
t1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
INSERT
INTO
t1
VALUES
();
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
DELETE
FROM
t1
WHERE
path
=
'xxx'
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
UPDATE
t1
SET
path
=
'yyy'
WHERE
path
=
'xxx'
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
TRUNCATE
TABLE
t1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
ALTER
TABLE
t1
READONLY
=
1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
CREATE
VIEW
v1
AS
SELECT
*
FROM
t1
;
--
echo
# Testing a VIEW created with FILE privileges but accessed with no FILE
...
...
@@ -53,13 +54,13 @@ SELECT user();
CREATE
SQL
SECURITY
INVOKER
VIEW
v1
AS
SELECT
*
FROM
t1
;
--
connection
user
SELECT
user
();
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
SELECT
*
FROM
v1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
INSERT
INTO
v1
VALUES
(
1
,
1
,
1
,
1
);
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
UPDATE
v1
SET
path
=
123
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
DELETE
FROM
v1
;
--
disconnect
user
...
...
storage/connect/mysql-test/connect/t/grant2.test
View file @
5ce6ec3f
This diff is collapsed.
Click to expand it.
storage/connect/mysql-test/connect/t/ini_grant.result
0 → 100644
View file @
5ce6ec3f
#
# Checking FILE privileges
#
set sql_mode="";
GRANT ALL PRIVILEGES ON *.* TO user@localhost;
REVOKE FILE ON *.* FROM user@localhost;
set sql_mode=default;
connect user,localhost,user,,;
connection user;
SELECT user();
user()
user@localhost
CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI;
Warnings:
Warning 1105 No file name. Table will use t1.ini
INSERT INTO t1 VALUES ('sec1','val1');
SELECT * FROM t1;
sec val
sec1 val1
UPDATE t1 SET val='val11';
SELECT * FROM t1;
sec val
sec1 val11
DELETE FROM t1;
SELECT * FROM t1;
sec val
INSERT INTO t1 VALUES('sec2','val2');
TRUNCATE TABLE t1;
SELECT * FROM t1;
sec val
CREATE VIEW v1 AS SELECT * FROM t1;
SELECT * FROM v1;
sec val
DROP VIEW v1;
DROP TABLE t1;
CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT';
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
connection default;
SELECT user();
user()
root@localhost
CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CONNECT TABLE_TYPE=INI FILE_NAME='t1.EXT';
INSERT INTO t1 VALUES ('sec1','val1');
connection user;
SELECT user();
user()
user@localhost
INSERT INTO t1 VALUES ('sec2','val2');
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
SELECT * FROM t1;
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
UPDATE t1 SET val='val11';
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DELETE FROM t1;
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
TRUNCATE TABLE t1;
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
ALTER TABLE t1 READONLY=1;
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DROP TABLE t1;
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
CREATE VIEW v1 AS SELECT * FROM t1;
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
# Testing a VIEW created with FILE privileges but accessed with no FILE
connection default;
SELECT user();
user()
root@localhost
CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT * FROM t1;
connection user;
SELECT user();
user()
user@localhost
SELECT * FROM v1;
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
INSERT INTO v1 VALUES ('sec3','val3');
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
UPDATE v1 SET val='val11';
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
DELETE FROM v1;
ERROR 42000: Access denied; you need (at least one of) the FILE privilege(s) for this operation
disconnect user;
connection default;
DROP VIEW v1;
DROP TABLE t1;
DROP USER user@localhost;
#
# Checking FILE privileges: done
#
storage/connect/mysql-test/connect/t/ini_grant.test
View file @
5ce6ec3f
...
...
@@ -29,7 +29,7 @@ DROP TABLE t1;
# Making sure DROP erased the data file
--
error
1
--
remove_file
$MYSQLD_DATADIR
/
test
/
t1
.
ini
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
CREATE
TABLE
t1
(
sec
CHAR
(
10
)
NOT
NULL
FLAG
=
1
,
val
CHAR
(
10
)
NOT
NULL
)
ENGINE
=
CONNECT
TABLE_TYPE
=
INI
FILE_NAME
=
't1.EXT'
;
--
connection
default
SELECT
user
();
...
...
@@ -37,21 +37,21 @@ CREATE TABLE t1 (sec CHAR(10) NOT NULL FLAG=1, val CHAR(10) NOT NULL) ENGINE=CON
INSERT
INTO
t1
VALUES
(
'sec1'
,
'val1'
);
--
connection
user
SELECT
user
();
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
INSERT
INTO
t1
VALUES
(
'sec2'
,
'val2'
);
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
SELECT
*
FROM
t1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
UPDATE
t1
SET
val
=
'val11'
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
DELETE
FROM
t1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
TRUNCATE
TABLE
t1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
ALTER
TABLE
t1
READONLY
=
1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
DROP
TABLE
t1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
CREATE
VIEW
v1
AS
SELECT
*
FROM
t1
;
--
echo
# Testing a VIEW created with FILE privileges but accessed with no FILE
--
connection
default
...
...
@@ -59,13 +59,13 @@ SELECT user();
CREATE
SQL
SECURITY
INVOKER
VIEW
v1
AS
SELECT
*
FROM
t1
;
--
connection
user
SELECT
user
();
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
SELECT
*
FROM
v1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
INSERT
INTO
v1
VALUES
(
'sec3'
,
'val3'
);
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
UPDATE
v1
SET
val
=
'val11'
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
DELETE
FROM
v1
;
--
disconnect
user
--
connection
default
...
...
storage/connect/mysql-test/connect/t/mysql_grant.test
View file @
5ce6ec3f
...
...
@@ -27,7 +27,7 @@ set sql_mode=default;
--
connection
user
SELECT
user
();
--
replace_result
$PORT
PORT
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
--
eval
CREATE
TABLE
t1
(
a
INT
NOT
NULL
)
ENGINE
=
CONNECT
TABLE_TYPE
=
MySQL
OPTION_LIST
=
'host=localhost,user=root1,port=$PORT'
--
connection
default
SELECT
user
();
...
...
@@ -38,19 +38,19 @@ INSERT INTO t1remote VALUES (10),(20),(30);
SELECT
*
FROM
t1
;
--
connection
user
SELECT
user
();
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
SELECT
*
FROM
t1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
INSERT
INTO
t1
VALUES
(
'xxx'
);
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
DELETE
FROM
t1
WHERE
a
=
'xxx'
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
UPDATE
t1
SET
a
=
'yyy'
WHERE
a
=
'xxx'
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
TRUNCATE
TABLE
t1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
ALTER
TABLE
t1
READONLY
=
1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
CREATE
VIEW
v1
AS
SELECT
*
FROM
t1
;
--
echo
# Testing a VIEW created with FILE privileges but accessed with no FILE
...
...
@@ -59,13 +59,13 @@ SELECT user();
CREATE
SQL
SECURITY
INVOKER
VIEW
v1
AS
SELECT
*
FROM
t1
;
--
connection
user
SELECT
user
();
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
SELECT
*
FROM
v1
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
INSERT
INTO
v1
VALUES
(
2
);
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
UPDATE
v1
SET
a
=
123
;
--
error
ER_ACCESS_DENIED_ERROR
--
error
ER_
SPECIFIC_
ACCESS_DENIED_ERROR
DELETE
FROM
v1
;
--
disconnect
user
...
...
storage/connect/plgdbsem.h
View file @
5ce6ec3f
...
...
@@ -149,16 +149,22 @@ enum AMT {TYPE_AM_ERROR = 0, /* Type not defined */
TYPE_AM_MGO
=
194
,
/* MGO access method type no */
TYPE_AM_OUT
=
200
};
/* Output relations (storage) */
enum
RECFM
{
RECFM_NAF
=
-
2
,
/* Not a file */
RECFM_OEM
=
-
1
,
/* OEM file access method */
RECFM_VAR
=
0
,
/* Varying length DOS files */
RECFM_FIX
=
1
,
/* Fixed length DOS files */
RECFM_BIN
=
2
,
/* Binary DOS files (also fixed) */
RECFM_VCT
=
3
,
/* VCT formatted files */
RECFM_ODBC
=
4
,
/* Table accessed via ODBC */
RECFM_JDBC
=
5
,
/* Table accessed via JDBC */
RECFM_PLG
=
6
,
/* Table accessed via PLGconn */
RECFM_DBF
=
7
};
/* DBase formatted file */
enum
RECFM
{
RECFM_DFLT
=
0
,
/* Default table type */
RECFM_NAF
=
1
,
/* Not a file table */
RECFM_OEM
=
2
,
/* OEM table */
RECFM_VAR
=
3
,
/* Varying length DOS files */
RECFM_FIX
=
4
,
/* Fixed length DOS files */
RECFM_BIN
=
5
,
/* Binary DOS files (also fixed) */
RECFM_DBF
=
6
,
/* DBase formatted file */
RECFM_CSV
=
7
,
/* CSV file */
RECFM_FMT
=
8
,
/* FMT formatted file */
RECFM_VCT
=
9
,
/* VCT formatted files */
RECFM_XML
=
10
,
/* XML formatted files */
RECFM_JASON
=
11
,
/* JASON formatted files */
RECFM_DIR
=
12
,
/* DIR table */
RECFM_ODBC
=
13
,
/* Table accessed via ODBC */
RECFM_JDBC
=
14
,
/* Table accessed via JDBC */
RECFM_PLG
=
15
};
/* Table accessed via PLGconn */
enum
MISC
{
DB_TABNO
=
1
,
/* DB routines in Utility Table */
MAX_MULT_KEY
=
10
,
/* Max multiple key number */
...
...
@@ -537,7 +543,8 @@ enum XFLD {FLD_NO = 0, /* Not a field definition item */
FLD_FORMAT
=
16
,
/* Field format */
FLD_CAT
=
17
,
/* Table catalog */
FLD_SCHEM
=
18
,
/* Table schema */
FLD_TABNAME
=
19
};
/* Column Table name */
FLD_TABNAME
=
19
,
/* Column Table name */
FLD_FLAG
=
20
};
/* Field flag (CONNECT specific) */
/***********************************************************************/
/* Result of last SQL noconv query. */
...
...
storage/connect/reldef.cpp
View file @
5ce6ec3f
This diff is collapsed.
Click to expand it.
storage/connect/reldef.h
View file @
5ce6ec3f
...
...
@@ -84,10 +84,12 @@ class DllExport TABDEF : public RELDEF { /* Logical table descriptor */
void
SetNext
(
PTABDEF
tdfp
)
{
Next
=
tdfp
;}
int
GetMultiple
(
void
)
{
return
Multiple
;}
int
GetPseudo
(
void
)
{
return
Pseudo
;}
PCSZ
GetPath
(
void
);
RECFM
GetRecfm
(
void
)
{
return
Recfm
;}
PCSZ
GetPath
(
void
);
//PSZ GetPath(void)
// {return (Database) ? (PSZ)Database : Cat->GetDataPath();}
bool
SepIndex
(
void
)
{
return
GetBoolCatInfo
(
"SepIndex"
,
false
);}
RECFM
GetTableFormat
(
const
char
*
type
);
bool
SepIndex
(
void
)
{
return
GetBoolCatInfo
(
"SepIndex"
,
false
);}
bool
IsReadOnly
(
void
)
{
return
Read_Only
;}
virtual
AMT
GetDefType
(
void
)
{
return
TYPE_AM_TAB
;}
virtual
PIXDEF
GetIndx
(
void
)
{
return
NULL
;}
...
...
@@ -108,7 +110,8 @@ class DllExport TABDEF : public RELDEF { /* Logical table descriptor */
// Members
PCSZ
Schema
;
/* Table schema (for ODBC) */
PCSZ
Desc
;
/* Table description */
uint
Catfunc
;
/* Catalog function ID */
RECFM
Recfm
;
/* File or table format */
uint
Catfunc
;
/* Catalog function ID */
int
Card
;
/* (max) number of rows in table */
int
Elemt
;
/* Number of rows in blocks or rowset */
int
Sort
;
/* Table already sorted ??? */
...
...
storage/connect/restget.cpp
View file @
5ce6ec3f
...
...
@@ -4,12 +4,6 @@
/***********************************************************************/
#include <cpprest/filestream.h>
#include <cpprest/http_client.h>
#if defined(MARIADB)
#include <my_global.h>
#else
#include "mini-global.h"
#define _OS_H_INCLUDED // Prevent os.h to be called
#endif
using
namespace
utility
::
conversions
;
// String conversions utilities
using
namespace
web
;
// Common features like URIs.
...
...
@@ -17,24 +11,26 @@ using namespace web::http; // Common HTTP functionality
using
namespace
web
::
http
::
client
;
// HTTP client features
using
namespace
concurrency
::
streams
;
// Asynchronous streams
#include "global.h"
typedef
const
char
*
PCSZ
;
extern
"C"
int
restGetFile
(
char
*
m
,
bool
xt
,
PCSZ
http
,
PCSZ
uri
,
PCSZ
fn
);
/***********************************************************************/
/* Make a local copy of the requested file. */
/***********************************************************************/
int
restGetFile
(
PGLOBAL
g
,
PCSZ
http
,
PCSZ
uri
,
PCSZ
fn
)
int
restGetFile
(
char
*
m
,
bool
xt
,
PCSZ
http
,
PCSZ
uri
,
PCSZ
fn
)
{
int
rc
=
0
;
bool
xt
=
trace
(
515
);
auto
fileStream
=
std
::
make_shared
<
ostream
>
();
if
(
!
http
||
!
fn
)
{
strcpy
(
g
->
Message
,
"Missing http or filename"
);
return
2
;
//strcpy(g->Message, "Missing http or filename");
strcpy
(
m
,
"Missing http or filename"
);
return
2
;
}
// endif
if
(
xt
)
htrc
(
"restGetFile: fn=%s
\n
"
,
fn
);
fprintf
(
stderr
,
"restGetFile: fn=%s
\n
"
,
fn
);
// Open stream to output file.
pplx
::
task
<
void
>
requestTask
=
fstream
::
open_ostream
(
to_string_t
(
fn
))
...
...
@@ -42,7 +38,7 @@ int restGetFile(PGLOBAL g, PCSZ http, PCSZ uri, PCSZ fn)
*
fileStream
=
outFile
;
if
(
xt
)
htrc
(
"Outfile isopen=%d
\n
"
,
outFile
.
is_open
());
fprintf
(
stderr
,
"Outfile isopen=%d
\n
"
,
outFile
.
is_open
());
// Create http_client to send the request.
http_client
client
(
to_string_t
(
http
));
...
...
@@ -58,8 +54,8 @@ int restGetFile(PGLOBAL g, PCSZ http, PCSZ uri, PCSZ fn)
// Handle response headers arriving.
.
then
([
=
](
http_response
response
)
{
if
(
xt
)
htrc
(
"Received response status code:%u
\n
"
,
response
.
status_code
());
fprintf
(
stderr
,
"Received response status code:%u
\n
"
,
response
.
status_code
());
// Write response body into the file.
return
response
.
body
().
read_to_end
(
fileStream
->
streambuf
());
...
...
@@ -68,27 +64,27 @@ int restGetFile(PGLOBAL g, PCSZ http, PCSZ uri, PCSZ fn)
// Close the file stream.
.
then
([
=
](
size_t
n
)
{
if
(
xt
)
htrc
(
"Return size=%
u
\n
"
,
n
);
fprintf
(
stderr
,
"Return size=%z
u
\n
"
,
n
);
return
fileStream
->
close
();
});
// Wait for all the outstanding I/O to complete and handle any exceptions
try
{
requestTask
.
wait
();
if
(
xt
)
htrc
(
"In Wait
\n
"
);
fprintf
(
stderr
,
"Waiting
\n
"
);
requestTask
.
wait
();
}
catch
(
const
std
::
exception
&
e
)
{
if
(
xt
)
htrc
(
"Error exception: %s
\n
"
,
e
.
what
());
sprintf
(
g
->
Message
,
"Error exception: %s"
,
e
.
what
());
rc
=
1
;
fprintf
(
stderr
,
"Error exception: %s
\n
"
,
e
.
what
());
sprintf
(
m
,
"Error exception: %s"
,
e
.
what
());
rc
=
1
;
}
// end try/catch
if
(
xt
)
htrc
(
"restget done: rc=%d
\n
"
,
rc
);
fprintf
(
stderr
,
"restget done: rc=%d
\n
"
,
rc
);
return
rc
;
}
// end of restGetFile
storage/connect/tabcmg.cpp
View file @
5ce6ec3f
...
...
@@ -53,25 +53,30 @@ bool CMGDISC::FindInDoc(PGLOBAL g, bson_iter_t *iter, const bson_t *doc,
{
if
(
!
doc
||
bson_iter_init
(
iter
,
doc
))
{
const
char
*
key
;
char
colname
[
65
];
char
fmt
[
129
];
bool
newcol
;
char
colname
[
65
];
char
fmt
[
129
];
bool
newcol
;
size_t
n
;
while
(
bson_iter_next
(
iter
))
{
key
=
bson_iter_key
(
iter
);
newcol
=
true
;
if
(
pcn
)
{
strncpy
(
colname
,
pcn
,
64
);
colname
[
64
]
=
0
;
strncat
(
strncat
(
colname
,
"_"
,
65
),
key
,
65
);
n
=
sizeof
(
colname
)
-
1
;
strncpy
(
colname
,
pcn
,
n
);
colname
[
n
]
=
0
;
n
-=
strlen
(
colname
);
strncat
(
strncat
(
colname
,
"_"
,
n
),
key
,
n
-
1
);
}
else
strcpy
(
colname
,
key
);
if
(
pfmt
)
{
strncpy
(
fmt
,
pfmt
,
128
);
fmt
[
128
]
=
0
;
strncat
(
strncat
(
fmt
,
"."
,
129
),
key
,
129
);
n
=
sizeof
(
fmt
)
-
1
;
strncpy
(
fmt
,
pfmt
,
n
);
fmt
[
n
]
=
0
;
n
-=
strlen
(
fmt
);
strncat
(
strncat
(
fmt
,
"."
,
n
),
key
,
n
-
1
);
}
else
strcpy
(
fmt
,
key
);
...
...
storage/connect/tabdos.cpp
View file @
5ce6ec3f
...
...
@@ -45,7 +45,7 @@
#include "global.h"
#include "osutil.h"
#include "plgdbsem.h"
#include "catalog.h"
//
#include "catalog.h"
#include "mycat.h"
#include "xindex.h"
#include "filamap.h"
...
...
@@ -161,7 +161,12 @@ bool DOSDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
//Last = GetIntCatInfo("Last", 0);
Ending
=
GetIntCatInfo
(
"Ending"
,
CRLF
);
if
(
Recfm
==
RECFM_FIX
||
Recfm
==
RECFM_BIN
)
{
if
(
Ending
<=
0
)
{
Ending
=
(
Recfm
==
RECFM_BIN
||
Recfm
==
RECFM_VCT
)
?
0
:
CRLF
;
SetIntCatInfo
(
"Ending"
,
Ending
);
}
// endif ending
if
(
Recfm
==
RECFM_FIX
||
Recfm
==
RECFM_BIN
)
{
Huge
=
GetBoolCatInfo
(
"Huge"
,
Cat
->
GetDefHuge
());
Padded
=
GetBoolCatInfo
(
"Padded"
,
false
);
Blksize
=
GetIntCatInfo
(
"Blksize"
,
0
);
...
...
@@ -191,7 +196,8 @@ bool DOSDEF::GetOptFileName(PGLOBAL g, char *filename)
case
RECFM_FIX
:
ftype
=
".fop"
;
break
;
case
RECFM_BIN
:
ftype
=
".bop"
;
break
;
case
RECFM_VCT
:
ftype
=
".vop"
;
break
;
case
RECFM_DBF
:
ftype
=
".dbp"
;
break
;
case
RECFM_CSV
:
ftype
=
".cop"
;
break
;
case
RECFM_DBF
:
ftype
=
".dbp"
;
break
;
default:
sprintf
(
g
->
Message
,
MSG
(
INVALID_FTYPE
),
Recfm
);
return
true
;
...
...
@@ -261,7 +267,8 @@ bool DOSDEF::DeleteIndexFile(PGLOBAL g, PIXDEF pxdf)
case
RECFM_FIX
:
ftype
=
".fnx"
;
break
;
case
RECFM_BIN
:
ftype
=
".bnx"
;
break
;
case
RECFM_VCT
:
ftype
=
".vnx"
;
break
;
case
RECFM_DBF
:
ftype
=
".dbx"
;
break
;
case
RECFM_CSV
:
ftype
=
".cnx"
;
break
;
case
RECFM_DBF
:
ftype
=
".dbx"
;
break
;
default:
sprintf
(
g
->
Message
,
MSG
(
BAD_RECFM_VAL
),
Recfm
);
return
true
;
...
...
@@ -2257,7 +2264,7 @@ int TDBDOS::ReadDB(PGLOBAL g)
/***********************************************************************/
bool
TDBDOS
::
PrepareWriting
(
PGLOBAL
)
{
if
(
!
Ftype
&&
(
Mode
==
MODE_INSERT
||
Txfp
->
GetUseTemp
()))
{
if
(
Ftype
==
RECFM_VAR
&&
(
Mode
==
MODE_INSERT
||
Txfp
->
GetUseTemp
()))
{
char
*
p
;
/*******************************************************************/
...
...
@@ -2542,7 +2549,8 @@ void DOSCOL::ReadColumn(PGLOBAL g)
/*********************************************************************/
/* For a variable length file, check if the field exists. */
/*********************************************************************/
if
(
tdbp
->
Ftype
==
RECFM_VAR
&&
strlen
(
tdbp
->
To_Line
)
<
(
unsigned
)
Deplac
)
if
((
tdbp
->
Ftype
==
RECFM_VAR
||
tdbp
->
Ftype
==
RECFM_CSV
)
&&
strlen
(
tdbp
->
To_Line
)
<
(
unsigned
)
Deplac
)
field
=
0
;
else
if
(
Dsp
)
for
(
i
=
0
;
i
<
field
;
i
++
)
...
...
@@ -2552,7 +2560,8 @@ void DOSCOL::ReadColumn(PGLOBAL g)
switch
(
tdbp
->
Ftype
)
{
case
RECFM_VAR
:
case
RECFM_FIX
:
// Fixed length text file
case
RECFM_DBF
:
// Fixed length DBase file
case
RECFM_CSV
:
// Variable length CSV or FMT file
case
RECFM_DBF
:
// Fixed length DBase file
if
(
Nod
)
switch
(
Buf_Type
)
{
case
TYPE_INT
:
case
TYPE_SHORT
:
...
...
storage/connect/tabdos.h
View file @
5ce6ec3f
...
...
@@ -80,7 +80,6 @@ class DllExport DOSDEF : public TABDEF { /* Logical table description */
PCSZ
Entry
;
/* Zip entry name or pattern */
PCSZ
Pwd
;
/* Zip password */
PIXDEF
To_Indx
;
/* To index definitions blocks */
RECFM
Recfm
;
/* 0:VAR, 1:FIX, 2:BIN, 3:VCT, 6:DBF */
bool
Mapped
;
/* 0: disk file, 1: memory mapped file */
bool
Zipped
;
/* true for zipped table file */
bool
Mulentries
;
/* true for multiple entries */
...
...
storage/connect/tabfix.cpp
View file @
5ce6ec3f
...
...
@@ -84,7 +84,7 @@ PTDB TDBFIX::Clone(PTABS t)
tp
=
new
(
g
)
TDBFIX
(
g
,
this
);
if
(
Ftype
<
2
)
{
if
(
Ftype
==
RECFM_VAR
||
Ftype
==
RECFM_FIX
)
{
// File is text
PDOSCOL
cp1
,
cp2
;
...
...
storage/connect/tabfmt.cpp
View file @
5ce6ec3f
/************* TabFmt C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: TABFMT */
/* ------------- */
/* Version 3.9.
2
*/
/* Version 3.9.
3
*/
/* */
/* COPYRIGHT: */
/* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2001 - 201
7
*/
/* (C) Copyright to the author Olivier BERTRAND 2001 - 201
9
*/
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
...
...
@@ -477,6 +477,7 @@ bool CSVDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
if
(
DOSDEF
::
DefineAM
(
g
,
"CSV"
,
poff
))
return
true
;
Recfm
=
RECFM_CSV
;
GetCharCatInfo
(
"Separator"
,
","
,
buf
,
sizeof
(
buf
));
Sep
=
(
strlen
(
buf
)
==
2
&&
buf
[
0
]
==
'\\'
&&
buf
[
1
]
==
't'
)
?
'\t'
:
*
buf
;
Quoted
=
GetIntCatInfo
(
"Quoted"
,
-
1
);
...
...
storage/connect/tabjson.cpp
View file @
5ce6ec3f
...
...
@@ -394,10 +394,11 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
bool
JSONDISC
::
Find
(
PGLOBAL
g
,
PJVAL
jvp
,
PCSZ
key
,
int
j
)
{
char
*
p
,
*
pc
=
colname
+
strlen
(
colname
);
int
ars
;
PJOB
job
;
PJAR
jar
;
char
*
p
,
*
pc
=
colname
+
strlen
(
colname
);
int
ars
;
size_t
n
;
PJOB
job
;
PJAR
jar
;
if
((
valp
=
jvp
?
jvp
->
GetValue
()
:
NULL
))
{
jcol
.
Type
=
valp
->
GetType
();
...
...
@@ -423,8 +424,10 @@ bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j)
PCSZ
k
=
jrp
->
GetKey
();
if
(
*
k
!=
'$'
)
{
strncat
(
strncat
(
fmt
,
sep
,
128
),
k
,
128
);
strncat
(
strncat
(
colname
,
"_"
,
64
),
k
,
64
);
n
=
sizeof
(
fmt
)
-
strlen
(
fmt
)
-
1
;
strncat
(
strncat
(
fmt
,
sep
,
n
),
k
,
n
-
strlen
(
sep
));
n
=
sizeof
(
colname
)
-
strlen
(
colname
)
-
1
;
strncat
(
strncat
(
colname
,
"_"
,
n
),
k
,
n
-
1
);
}
// endif Key
if
(
Find
(
g
,
jrp
->
GetVal
(),
k
,
j
+
1
))
...
...
@@ -443,19 +446,26 @@ bool JSONDISC::Find(PGLOBAL g, PJVAL jvp, PCSZ key, int j)
ars
=
MY_MIN
(
jar
->
GetSize
(
false
),
1
);
for
(
int
k
=
0
;
k
<
ars
;
k
++
)
{
if
(
!
tdp
->
Xcol
||
stricmp
(
tdp
->
Xcol
,
key
))
{
sprintf
(
buf
,
"%d"
,
k
);
if
(
tdp
->
Uri
)
strncat
(
strncat
(
fmt
,
sep
,
128
),
buf
,
128
);
else
strncat
(
strncat
(
strncat
(
fmt
,
"["
,
128
),
buf
,
128
),
"]"
,
128
);
n
=
sizeof
(
fmt
)
-
(
strlen
(
fmt
)
+
1
);
if
(
all
)
strncat
(
strncat
(
colname
,
"_"
,
64
),
buf
,
64
);
if
(
!
tdp
->
Xcol
||
stricmp
(
tdp
->
Xcol
,
key
))
{
sprintf
(
buf
,
"%d"
,
k
);
}
else
strncat
(
fmt
,
(
tdp
->
Uri
?
sep
:
"[*]"
),
128
);
if
(
tdp
->
Uri
)
{
strncat
(
strncat
(
fmt
,
sep
,
n
),
buf
,
n
-
strlen
(
sep
));
}
else
{
strncat
(
strncat
(
fmt
,
"["
,
n
),
buf
,
n
-
1
);
strncat
(
fmt
,
"]"
,
n
-
(
strlen
(
buf
)
+
1
));
}
// endif uri
if
(
all
)
{
n
=
sizeof
(
colname
)
-
(
strlen
(
colname
)
+
1
);
strncat
(
strncat
(
colname
,
"_"
,
n
),
buf
,
n
-
1
);
}
// endif all
}
else
{
strncat
(
fmt
,
(
tdp
->
Uri
?
sep
:
"[*]"
),
n
);
}
if
(
Find
(
g
,
jar
->
GetValue
(
k
),
""
,
j
))
return
true
;
...
...
storage/connect/tabmysql.cpp
View file @
5ce6ec3f
...
...
@@ -342,11 +342,13 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
Delayed
=
!!
GetIntCatInfo
(
"Delayed"
,
0
);
}
else
{
// MYSQL access from a PROXY table
Tabschema
=
GetStringCatInfo
(
g
,
"Database"
,
Tabschema
?
Tabschema
:
PlugDup
(
g
,
"*"
));
TABLE_SHARE
*
s
;
Tabschema
=
GetStringCatInfo
(
g
,
"Database"
,
Tabschema
?
Tabschema
:
PlugDup
(
g
,
"*"
));
Isview
=
GetBoolCatInfo
(
"View"
,
false
);
// We must get other connection parms from the calling table
Remove_tshp
(
Cat
);
s
=
Remove_tshp
(
Cat
);
url
=
GetStringCatInfo
(
g
,
"Connect"
,
NULL
);
if
(
!
url
||
!*
url
)
{
...
...
@@ -365,6 +367,9 @@ bool MYSQLDEF::DefineAM(PGLOBAL g, LPCSTR am, int)
}
// endif url
Tabname
=
Name
;
// Needed for column description
Restore_tshp
(
Cat
,
s
);
}
// endif am
if
((
Srcdef
=
GetStringCatInfo
(
g
,
"Srcdef"
,
NULL
)))
{
...
...
storage/connect/tabodbc.cpp
View file @
5ce6ec3f
...
...
@@ -605,8 +605,10 @@ bool TDBODBC::OpenDB(PGLOBAL g)
Cnp
->
InitValue
(
g
);
if
((
n
=
Ocp
->
GetResultSize
(
Query
->
GetStr
(),
Cnp
))
<
0
)
{
strcpy
(
g
->
Message
,
"Cannot get result size"
);
return
true
;
char
*
msg
=
PlugDup
(
g
,
g
->
Message
);
sprintf
(
g
->
Message
,
"Get result size: %s (rc=%d)"
,
msg
,
n
);
return
true
;
}
else
if
(
n
)
{
Ocp
->
m_Rows
=
n
;
...
...
storage/connect/tabrest.cpp
View file @
5ce6ec3f
/**************
* Rest C++ Program Source Code File (.CPP) **
************/
/* PROGRAM NAME:
Rest Version 1.5
*/
/**************
tabrest C++ Program Source Code File (.CPP)
************/
/* PROGRAM NAME:
tabrest Version 1.7
*/
/* (C) Copyright to the author Olivier BERTRAND 2018 - 2019 */
/* This program is the REST Web API support for MariaDB. */
/* When compiled without MARIADB defined, it is the EOM module code. */
...
...
@@ -9,13 +9,18 @@
/* Definitions needed by the included files. */
/***********************************************************************/
#if defined(MARIADB)
#include <my_global.h> // All MariaDB stuff
#include <my_global.h>
// All MariaDB stuff
#else // !MARIADB OEM module
#include "mini-global.h"
#define _MAX_PATH 260
#if !defined(__WIN__)
#if !defined(REST_SOURCE)
#if defined(__WIN__) || defined(_WINDOWS)
#include <windows.h>
#else // !__WIN__
#define __stdcall
#include <dlfcn.h> // dlopen(), dlclose(), dlsym() ...
#endif // !__WIN__
#endif // !REST_SOURCE
#define _OS_H_INCLUDED // Prevent os.h to be called
#endif // !MARIADB
...
...
@@ -23,7 +28,6 @@
/* Include application header files: */
/* global.h is header containing all global declarations. */
/* plgdbsem.h is header containing the DB application declarations. */
/* (x)table.h is header containing the TDBASE declarations. */
/***********************************************************************/
#include "global.h"
#include "plgdbsem.h"
...
...
@@ -31,22 +35,14 @@
#include "filamtxt.h"
#include "tabdos.h"
#include "plgxml.h"
#if defined(XML_SUPPORT)
#include "tabxml.h"
#endif // XML_SUPPORT
#include "tabjson.h"
#include "tabfmt.h"
#include "tabrest.h"
/***********************************************************************/
/* Get the file from the Web. */
/***********************************************************************/
int
restGetFile
(
PGLOBAL
g
,
PCSZ
http
,
PCSZ
uri
,
PCSZ
fn
);
#if defined(__WIN__)
static
PCSZ
slash
=
"
\\
"
;
#else // !__WIN__
static
PCSZ
slash
=
"/"
;
#define stricmp strcasecmp
#endif // !__WIN__
static
XGETREST
getRestFnc
=
NULL
;
#if !defined(MARIADB)
/***********************************************************************/
...
...
@@ -75,6 +71,74 @@ PTABDEF __stdcall GetREST(PGLOBAL g, void *memp)
}
// end of GetREST
#endif // !MARIADB
/***********************************************************************/
/* GetREST: get the external TABDEF from OEM module. */
/***********************************************************************/
XGETREST
GetRestFunction
(
PGLOBAL
g
)
{
if
(
getRestFnc
)
return
getRestFnc
;
#if !defined(MARIADB) || !defined(REST_SOURCE)
if
(
trace
(
515
))
htrc
(
"Looking for GetRest library
\n
"
);
#if defined(__WIN__) || defined(_WINDOWS)
HANDLE
Hdll
;
const
char
*
soname
=
"GetRest.dll"
;
// Module name
if
(
!
(
Hdll
=
LoadLibrary
(
soname
)))
{
char
buf
[
256
];
DWORD
rc
=
GetLastError
();
sprintf
(
g
->
Message
,
MSG
(
DLL_LOAD_ERROR
),
rc
,
soname
);
FormatMessage
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
NULL
,
rc
,
0
,
(
LPTSTR
)
buf
,
sizeof
(
buf
),
NULL
);
strcat
(
strcat
(
g
->
Message
,
": "
),
buf
);
return
NULL
;
}
// endif Hdll
// Get the function returning an instance of the external DEF class
if
(
!
(
getRestFnc
=
(
XGETREST
)
GetProcAddress
((
HINSTANCE
)
Hdll
,
"restGetFile"
)))
{
char
buf
[
256
];
DWORD
rc
=
GetLastError
();
sprintf
(
g
->
Message
,
MSG
(
PROCADD_ERROR
),
rc
,
"restGetFile"
);
FormatMessage
(
FORMAT_MESSAGE_FROM_SYSTEM
|
FORMAT_MESSAGE_IGNORE_INSERTS
,
NULL
,
rc
,
0
,
(
LPTSTR
)
buf
,
sizeof
(
buf
),
NULL
);
strcat
(
strcat
(
g
->
Message
,
": "
),
buf
);
FreeLibrary
((
HMODULE
)
Hdll
);
return
NULL
;
}
// endif getRestFnc
#else // !__WIN__
void
*
Hso
;
const
char
*
error
=
NULL
;
const
char
*
soname
=
"GetRest.so"
;
// Module name
// Load the desired shared library
if
(
!
(
Hso
=
dlopen
(
soname
,
RTLD_LAZY
)))
{
error
=
dlerror
();
sprintf
(
g
->
Message
,
MSG
(
SHARED_LIB_ERR
),
soname
,
SVP
(
error
));
return
NULL
;
}
// endif Hdll
// Get the function returning an instance of the external DEF class
if
(
!
(
getRestFnc
=
(
XGETREST
)
dlsym
(
Hso
,
"restGetFile"
)))
{
error
=
dlerror
();
sprintf
(
g
->
Message
,
MSG
(
GET_FUNC_ERR
),
"restGetFile"
,
SVP
(
error
));
dlclose
(
Hso
);
return
NULL
;
}
// endif getdef
#endif // !__WIN__
#else
getRestFnc
=
restGetFile
;
#endif
return
getRestFnc
;
}
// end of GetRestFunction
/***********************************************************************/
/* Return the columns definition to MariaDB. */
/***********************************************************************/
...
...
@@ -87,6 +151,10 @@ PQRYRES __stdcall ColREST(PGLOBAL g, PTOS tp, char *tab, char *db, bool info)
PQRYRES
qrp
=
NULL
;
char
filename
[
_MAX_PATH
+
1
];
// MAX PATH ???
PCSZ
http
,
uri
,
fn
,
ftype
;
XGETREST
grf
=
GetRestFunction
(
g
);
if
(
!
grf
)
return
NULL
;
http
=
GetStringTableOption
(
g
,
tp
,
"Http"
,
NULL
);
uri
=
GetStringTableOption
(
g
,
tp
,
"Uri"
,
NULL
);
...
...
@@ -100,18 +168,20 @@ PQRYRES __stdcall ColREST(PGLOBAL g, PTOS tp, char *tab, char *db, bool info)
// We used the file name relative to recorded datapath
strcat
(
strcat
(
strcat
(
strcpy
(
filename
,
"."
),
slash
),
db
),
slash
);
strncat
(
filename
,
fn
,
_MAX_PATH
);
strncat
(
filename
,
fn
,
_MAX_PATH
-
strlen
(
filename
)
);
// Retrieve the file from the web and copy it locally
if
(
http
&&
restGetFile
(
g
,
http
,
uri
,
filename
))
{
// sprintf(g->Message, "Failed to get file at %s", http);
}
else
if
(
!
stricmp
(
ftype
,
"XML"
))
qrp
=
XMLColumns
(
g
,
db
,
tab
,
tp
,
info
);
else
if
(
!
stricmp
(
ftype
,
"JSON"
))
if
(
http
&&
grf
(
g
->
Message
,
trace
(
515
),
http
,
uri
,
filename
))
{
// sprintf(g->Message, "Failed to get file at %s", http);
}
else
if
(
!
stricmp
(
ftype
,
"JSON"
))
qrp
=
JSONColumns
(
g
,
db
,
NULL
,
tp
,
info
);
else
if
(
!
stricmp
(
ftype
,
"CSV"
))
qrp
=
CSVColumns
(
g
,
NULL
,
tp
,
info
);
else
#if defined(XML_SUPPORT)
else
if
(
!
stricmp
(
ftype
,
"XML"
))
qrp
=
XMLColumns
(
g
,
db
,
tab
,
tp
,
info
);
#endif // XML_SUPPORT
else
sprintf
(
g
->
Message
,
"Usupported file type %s"
,
ftype
);
return
qrp
;
...
...
@@ -124,9 +194,14 @@ PQRYRES __stdcall ColREST(PGLOBAL g, PTOS tp, char *tab, char *db, bool info)
/***********************************************************************/
bool
RESTDEF
::
DefineAM
(
PGLOBAL
g
,
LPCSTR
am
,
int
poff
)
{
char
filename
[
_MAX_PATH
+
1
];
char
filename
[
_MAX_PATH
+
1
];
int
rc
=
0
,
n
;
LPCSTR
ftype
;
bool
xt
=
trace
(
515
);
LPCSTR
ftype
;
XGETREST
grf
=
GetRestFunction
(
g
);
if
(
!
grf
)
return
true
;
#if defined(MARIADB)
ftype
=
GetStringCatInfo
(
g
,
"Type"
,
"JSON"
);
...
...
@@ -135,11 +210,13 @@ bool RESTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
ftype
=
GetStringCatInfo
(
g
,
"Ftype"
,
"JSON"
);
#endif // !MARIADB
if
(
trace
(
515
)
)
if
(
xt
)
htrc
(
"ftype = %s am = %s
\n
"
,
ftype
,
SVP
(
am
));
n
=
(
!
stricmp
(
ftype
,
"JSON"
))
?
1
#if defined(XML_SUPPORT)
:
(
!
stricmp
(
ftype
,
"XML"
))
?
2
#endif // XML_SUPPORT
:
(
!
stricmp
(
ftype
,
"CSV"
))
?
3
:
0
;
if
(
n
==
0
)
{
...
...
@@ -154,19 +231,22 @@ bool RESTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
// We used the file name relative to recorded datapath
//PlugSetPath(filename, Fn, GetPath());
strncat
(
strcpy
(
filename
,
GetPath
()),
Fn
,
_MAX_PATH
);
strcpy
(
filename
,
GetPath
());
strncat
(
filename
,
Fn
,
_MAX_PATH
-
strlen
(
filename
));
// Retrieve the file from the web and copy it locally
rc
=
restGetFile
(
g
,
Http
,
Uri
,
filename
);
rc
=
grf
(
g
->
Message
,
xt
,
Http
,
Uri
,
filename
);
if
(
trace
(
515
)
)
if
(
xt
)
htrc
(
"Return from restGetFile: rc=%d
\n
"
,
rc
);
if
(
rc
)
return
true
;
else
switch
(
n
)
{
case
1
:
Tdp
=
new
(
g
)
JSONDEF
;
break
;
case
2
:
Tdp
=
new
(
g
)
XMLDEF
;
break
;
#if defined(XML_SUPPORT)
case
2
:
Tdp
=
new
(
g
)
XMLDEF
;
break
;
#endif // XML_SUPPORT
case
3
:
Tdp
=
new
(
g
)
CSVDEF
;
break
;
default:
Tdp
=
NULL
;
}
// endswitch n
...
...
@@ -175,7 +255,7 @@ bool RESTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
if
(
Tdp
&&
Tdp
->
Define
(
g
,
Cat
,
Name
,
Schema
,
"REST"
))
Tdp
=
NULL
;
// Error occured
if
(
trace
(
515
)
)
if
(
xt
)
htrc
(
"Tdp defined
\n
"
,
rc
);
// Return true in case of error
...
...
storage/connect/tabrest.h
View file @
5ce6ec3f
...
...
@@ -5,6 +5,27 @@
/***********************************************************************/
#pragma once
#if defined(__WIN__)
static
PCSZ
slash
=
"
\\
"
;
#else // !__WIN__
static
PCSZ
slash
=
"/"
;
#define stricmp strcasecmp
#endif // !__WIN__
typedef
int
(
__stdcall
*
XGETREST
)
(
char
*
,
bool
,
PCSZ
,
PCSZ
,
PCSZ
);
/***********************************************************************/
/* Functions used by REST. */
/***********************************************************************/
XGETREST
GetRestFunction
(
PGLOBAL
g
);
#if defined(REST_SOURCE)
extern
"C"
int
restGetFile
(
char
*
m
,
bool
xt
,
PCSZ
http
,
PCSZ
uri
,
PCSZ
fn
);
#endif // REST_SOURCE
#if defined(MARIADB)
PQRYRES
RESTColumns
(
PGLOBAL
g
,
PTOS
tp
,
char
*
tab
,
char
*
db
,
bool
info
);
#endif // !MARIADB
/***********************************************************************/
/* Restest table. */
/***********************************************************************/
...
...
storage/connect/tabutil.cpp
View file @
5ce6ec3f
...
...
@@ -59,11 +59,23 @@ int GetConvSize(void);
/* Used by MYSQL tables to get MySQL parameters from the calling proxy */
/* table (PROXY, TBL, XCL, or OCCUR) when used by one of these. */
/************************************************************************/
void
Remove_tshp
(
PCATLG
cat
)
TABLE_SHARE
*
Remove_tshp
(
PCATLG
cat
)
{
((
MYCAT
*
)
cat
)
->
GetHandler
()
->
tshp
=
NULL
;
TABLE_SHARE
*
s
=
((
MYCAT
*
)
cat
)
->
GetHandler
()
->
tshp
;
((
MYCAT
*
)
cat
)
->
GetHandler
()
->
tshp
=
NULL
;
return
s
;
}
// end of Remove_thsp
/************************************************************************/
/* Used by MYSQL tables to get MySQL parameters from the calling proxy */
/* table (PROXY, TBL, XCL, or OCCUR) when used by one of these. */
/************************************************************************/
void
Restore_tshp
(
PCATLG
cat
,
TABLE_SHARE
*
s
)
{
((
MYCAT
*
)
cat
)
->
GetHandler
()
->
tshp
=
s
;
}
// end of Restore_thsp
/************************************************************************/
/* GetTableShare: allocates and open a table share. */
/************************************************************************/
...
...
storage/connect/tabutil.h
View file @
5ce6ec3f
...
...
@@ -18,7 +18,8 @@ TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db,
PQRYRES
TabColumns
(
PGLOBAL
g
,
THD
*
thd
,
const
char
*
db
,
const
char
*
name
,
bool
&
info
);
void
Remove_tshp
(
PCATLG
cat
);
TABLE_SHARE
*
Remove_tshp
(
PCATLG
cat
);
void
Restore_tshp
(
PCATLG
cat
,
TABLE_SHARE
*
s
);
/* -------------------------- PROXY classes -------------------------- */
...
...
storage/connect/tabvct.cpp
View file @
5ce6ec3f
...
...
@@ -115,11 +115,14 @@ bool VCTDEF::DefineAM(PGLOBAL g, LPCSTR, int poff)
Recfm
=
RECFM_VCT
;
// poff is no more in use; This will have to be revisited
#if 0
// For packed files the logical record length is calculated in poff
if (poff != Lrecl) {
Lrecl = poff;
SetIntCatInfo("Lrecl", poff);
} // endif poff
#endif // 0
Padded
=
false
;
Blksize
=
0
;
...
...
storage/connect/tabxml.cpp
View file @
5ce6ec3f
...
...
@@ -240,7 +240,9 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info)
more:
if
(
vp
->
atp
)
{
strncpy
(
colname
,
vp
->
atp
->
GetName
(
g
),
sizeof
(
colname
));
size_t
z
=
sizeof
(
colname
)
-
1
;
strncpy
(
colname
,
vp
->
atp
->
GetName
(
g
),
z
);
colname
[
z
]
=
0
;
strncat
(
xcol
->
Name
,
colname
,
XLEN
(
xcol
->
Name
));
switch
(
vp
->
atp
->
GetText
(
g
,
buf
,
sizeof
(
buf
)))
{
...
...
storage/connect/valblk.cpp
View file @
5ce6ec3f
...
...
@@ -206,6 +206,7 @@ void VALBLK::ChkIndx(int n)
{
if
(
n
<
0
||
n
>=
Nval
)
{
PGLOBAL
&
g
=
Global
;
xtrc
(
1
,
"ChkIndx: n=%d Nval=%d
\n
"
,
n
,
Nval
);
strcpy
(
g
->
Message
,
MSG
(
BAD_VALBLK_INDX
));
throw
Type
;
}
// endif n
...
...
@@ -216,7 +217,8 @@ void VALBLK::ChkTyp(PVAL v)
{
if
(
Check
&&
(
Type
!=
v
->
GetType
()
||
Unsigned
!=
v
->
IsUnsigned
()))
{
PGLOBAL
&
g
=
Global
;
strcpy
(
g
->
Message
,
MSG
(
VALTYPE_NOMATCH
));
xtrc
(
1
,
"ChkTyp: Type=%d valType=%d
\n
"
,
Type
,
v
->
GetType
());
strcpy
(
g
->
Message
,
MSG
(
VALTYPE_NOMATCH
));
throw
Type
;
}
// endif Type
...
...
storage/connect/value.cpp
View file @
5ce6ec3f
This diff is collapsed.
Click to expand it.
storage/connect/xindex.cpp
View file @
5ce6ec3f
...
...
@@ -659,7 +659,7 @@ bool XINDEX::Make(PGLOBAL g, PIXDEF sxp)
/* Not true for DBF tables because of eventual soft deleted lines. */
/* Note: for Num_K = 1 any non null value is Ok. */
/*********************************************************************/
if
(
Srtd
&&
!
filp
&&
Tdbp
->
Ftype
!=
RECFM_VAR
if
(
Srtd
&&
!
filp
&&
Tdbp
->
Ftype
!=
RECFM_VAR
&&
Tdbp
->
Ftype
!=
RECFM_CSV
&&
Tdbp
->
Txfp
->
GetAmType
()
!=
TYPE_AM_DBF
)
{
Incr
=
(
Num_K
>
1
)
?
To_Rec
[
1
]
:
Num_K
;
PlgDBfree
(
Record
);
...
...
@@ -837,7 +837,8 @@ bool XINDEX::SaveIndex(PGLOBAL g, PIXDEF sxp)
case
RECFM_FIX
:
ftype
=
".fnx"
;
break
;
case
RECFM_BIN
:
ftype
=
".bnx"
;
break
;
case
RECFM_VCT
:
ftype
=
".vnx"
;
break
;
case
RECFM_DBF
:
ftype
=
".dbx"
;
break
;
case
RECFM_CSV
:
ftype
=
".cnx"
;
break
;
case
RECFM_DBF
:
ftype
=
".dbx"
;
break
;
default:
sprintf
(
g
->
Message
,
MSG
(
INVALID_FTYPE
),
Tdbp
->
Ftype
);
return
true
;
...
...
@@ -990,7 +991,8 @@ bool XINDEX::Init(PGLOBAL g)
case
RECFM_FIX
:
ftype
=
".fnx"
;
break
;
case
RECFM_BIN
:
ftype
=
".bnx"
;
break
;
case
RECFM_VCT
:
ftype
=
".vnx"
;
break
;
case
RECFM_DBF
:
ftype
=
".dbx"
;
break
;
case
RECFM_CSV
:
ftype
=
".cnx"
;
break
;
case
RECFM_DBF
:
ftype
=
".dbx"
;
break
;
default:
sprintf
(
g
->
Message
,
MSG
(
INVALID_FTYPE
),
Tdbp
->
Ftype
);
return
true
;
...
...
@@ -1243,7 +1245,8 @@ bool XINDEX::MapInit(PGLOBAL g)
case
RECFM_FIX
:
ftype
=
".fnx"
;
break
;
case
RECFM_BIN
:
ftype
=
".bnx"
;
break
;
case
RECFM_VCT
:
ftype
=
".vnx"
;
break
;
case
RECFM_DBF
:
ftype
=
".dbx"
;
break
;
case
RECFM_CSV
:
ftype
=
".cnx"
;
break
;
case
RECFM_DBF
:
ftype
=
".dbx"
;
break
;
default:
sprintf
(
g
->
Message
,
MSG
(
INVALID_FTYPE
),
Tdbp
->
Ftype
);
return
true
;
...
...
@@ -1457,7 +1460,8 @@ bool XINDEX::GetAllSizes(PGLOBAL g,/* int &ndif,*/ int &numk)
case
RECFM_FIX
:
ftype
=
".fnx"
;
break
;
case
RECFM_BIN
:
ftype
=
".bnx"
;
break
;
case
RECFM_VCT
:
ftype
=
".vnx"
;
break
;
case
RECFM_DBF
:
ftype
=
".dbx"
;
break
;
case
RECFM_CSV
:
ftype
=
".cnx"
;
break
;
case
RECFM_DBF
:
ftype
=
".dbx"
;
break
;
default:
sprintf
(
g
->
Message
,
MSG
(
INVALID_FTYPE
),
Tdbp
->
Ftype
);
return
true
;
...
...
storage/connect/xtable.h
View file @
5ce6ec3f
...
...
@@ -173,9 +173,12 @@ class DllExport TDBASE : public TDB {
inline
void
SetKindex
(
PKXBASE
kxp
)
{
To_Kindex
=
kxp
;}
// Properties
virtual
PKXBASE
GetKindex
(
void
)
{
return
To_Kindex
;}
PKXBASE
GetKindex
(
void
)
{
return
To_Kindex
;}
PXOB
*
GetLink
(
void
)
{
return
To_Link
;}
PIXDEF
GetXdp
(
void
)
{
return
To_Xdp
;}
void
ResetKindex
(
PGLOBAL
g
,
PKXBASE
kxp
);
PCOL
Key
(
int
i
)
{
return
(
To_Key_Col
)
?
To_Key_Col
[
i
]
:
NULL
;}
PXOB
Link
(
int
i
)
{
return
(
To_Link
)
?
To_Link
[
i
]
:
NULL
;
}
// Methods
virtual
bool
IsUsingTemp
(
PGLOBAL
)
{
return
false
;}
...
...
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