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
710e1bac
Commit
710e1bac
authored
Apr 07, 2021
by
Olivier Bertrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tabrest.cpp
parent
757aaa3b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
63 deletions
+8
-63
storage/connect/tabrest.cpp
storage/connect/tabrest.cpp
+8
-63
No files found.
storage/connect/tabrest.cpp
View file @
710e1bac
/************** tabrest C++ Program Source Code File (.CPP) ************/
/************** tabrest C++ Program Source Code File (.CPP) ************/
/* PROGRAM NAME: tabrest Version
1.9
*/
/* PROGRAM NAME: tabrest Version
2.0
*/
/* (C) Copyright to the author Olivier BERTRAND 2018 - 2021 */
/* (C) Copyright to the author Olivier BERTRAND 2018 - 2021 */
/* This program is the REST Web API support for MariaDB. */
/* This program is the REST Web API support for MariaDB. */
/* When compiled without MARIADB defined, it is the EOM module code. */
/* The way Connect handles NOSQL data returned by REST queries is */
/* The way Connect handles NOSQL data returned by REST queries is */
/* just by retrieving it as a file and then leave the existing data */
/* just by retrieving it as a file and then leave the existing data */
/* type tables (JSON, XML or CSV) process it as usual. */
/* type tables (JSON, XML or CSV) process it as usual. */
...
@@ -11,23 +10,13 @@
...
@@ -11,23 +10,13 @@
/***********************************************************************/
/***********************************************************************/
/* Definitions needed by the included files. */
/* Definitions needed by the included files. */
/***********************************************************************/
/***********************************************************************/
#if defined(MARIADB)
#include <my_global.h> // All MariaDB stuff
#include <my_global.h> // All MariaDB stuff
#include <mysqld.h>
#include <mysqld.h>
#include <sql_error.h>
#include <sql_error.h>
#else // !MARIADB OEM module
#if !defined(__WIN__) && !defined(_WINDOWS)
#include "mini-global.h"
#include <sys/types.h>
#define _MAX_PATH 260
#include <sys/wait.h>
#if !defined(REST_SOURCE)
#endif // !__WIN__ && !_WINDOWS
#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
/***********************************************************************/
/***********************************************************************/
/* Include application header files: */
/* Include application header files: */
...
@@ -56,33 +45,6 @@
...
@@ -56,33 +45,6 @@
static
XGETREST
getRestFnc
=
NULL
;
static
XGETREST
getRestFnc
=
NULL
;
static
int
Xcurl
(
PGLOBAL
g
,
PCSZ
Http
,
PCSZ
Uri
,
PCSZ
filename
);
static
int
Xcurl
(
PGLOBAL
g
,
PCSZ
Http
,
PCSZ
Uri
,
PCSZ
filename
);
#if !defined(MARIADB)
/***********************************************************************/
/* DB static variables. */
/***********************************************************************/
int
TDB
::
Tnum
;
int
DTVAL
::
Shift
;
int
CSORT
::
Limit
=
0
;
double
CSORT
::
Lg2
=
log
(
2.0
);
size_t
CSORT
::
Cpn
[
1000
]
=
{
0
};
/***********************************************************************/
/* These functions are exported from the REST library. */
/***********************************************************************/
extern
"C"
{
PTABDEF
__stdcall
GetREST
(
PGLOBAL
,
void
*
);
PQRYRES
__stdcall
ColREST
(
PGLOBAL
,
PTOS
,
char
*
,
char
*
,
bool
);
}
// extern "C"
/***********************************************************************/
/* This function returns a table definition class. */
/***********************************************************************/
PTABDEF
__stdcall
GetREST
(
PGLOBAL
g
,
void
*
memp
)
{
return
new
(
g
,
memp
)
RESTDEF
;
}
// end of GetREST
#endif // !MARIADB
/***********************************************************************/
/***********************************************************************/
/* Xcurl: retrieve the REST answer by executing cURL. */
/* Xcurl: retrieve the REST answer by executing cURL. */
/***********************************************************************/
/***********************************************************************/
...
@@ -129,9 +91,6 @@ int Xcurl(PGLOBAL g, PCSZ Http, PCSZ Uri, PCSZ filename)
...
@@ -129,9 +91,6 @@ int Xcurl(PGLOBAL g, PCSZ Http, PCSZ Uri, PCSZ filename)
rc
=
1
;
rc
=
1
;
}
// endif CreateProcess
}
// endif CreateProcess
#else // !__WIN__
#else // !__WIN__
#include <sys/types.h>
#include <sys/wait.h>
char
fn
[
600
];
char
fn
[
600
];
pid_t
pID
;
pid_t
pID
;
...
@@ -184,7 +143,7 @@ XGETREST GetRestFunction(PGLOBAL g)
...
@@ -184,7 +143,7 @@ XGETREST GetRestFunction(PGLOBAL g)
if
(
getRestFnc
)
if
(
getRestFnc
)
return
getRestFnc
;
return
getRestFnc
;
#if !defined(
MARIADB) || !defined(
REST_SOURCE)
#if !defined(REST_SOURCE)
if
(
trace
(
515
))
if
(
trace
(
515
))
htrc
(
"Looking for GetRest library
\n
"
);
htrc
(
"Looking for GetRest library
\n
"
);
...
@@ -237,9 +196,9 @@ XGETREST GetRestFunction(PGLOBAL g)
...
@@ -237,9 +196,9 @@ XGETREST GetRestFunction(PGLOBAL g)
return
NULL
;
return
NULL
;
}
// endif getdef
}
// endif getdef
#endif // !__WIN__
#endif // !__WIN__
#else
#else
// REST_SOURCE
getRestFnc
=
restGetFile
;
getRestFnc
=
restGetFile
;
#endif
#endif
// REST_SOURCE
return
getRestFnc
;
return
getRestFnc
;
}
// end of GetRestFunction
}
// end of GetRestFunction
...
@@ -247,11 +206,7 @@ XGETREST GetRestFunction(PGLOBAL g)
...
@@ -247,11 +206,7 @@ XGETREST GetRestFunction(PGLOBAL g)
/***********************************************************************/
/***********************************************************************/
/* Return the columns definition to MariaDB. */
/* Return the columns definition to MariaDB. */
/***********************************************************************/
/***********************************************************************/
#if defined(MARIADB)
PQRYRES
RESTColumns
(
PGLOBAL
g
,
PTOS
tp
,
char
*
tab
,
char
*
db
,
bool
info
)
PQRYRES
RESTColumns
(
PGLOBAL
g
,
PTOS
tp
,
char
*
tab
,
char
*
db
,
bool
info
)
#else // !MARIADB
PQRYRES
__stdcall
ColREST
(
PGLOBAL
g
,
PTOS
tp
,
char
*
tab
,
char
*
db
,
bool
info
)
#endif // !MARIADB
{
{
PQRYRES
qrp
=
NULL
;
PQRYRES
qrp
=
NULL
;
char
filename
[
_MAX_PATH
+
1
];
// MAX PATH ???
char
filename
[
_MAX_PATH
+
1
];
// MAX PATH ???
...
@@ -265,12 +220,7 @@ PQRYRES __stdcall ColREST(PGLOBAL g, PTOS tp, char *tab, char *db, bool info)
...
@@ -265,12 +220,7 @@ PQRYRES __stdcall ColREST(PGLOBAL g, PTOS tp, char *tab, char *db, bool info)
http
=
GetStringTableOption
(
g
,
tp
,
"Http"
,
NULL
);
http
=
GetStringTableOption
(
g
,
tp
,
"Http"
,
NULL
);
uri
=
GetStringTableOption
(
g
,
tp
,
"Uri"
,
NULL
);
uri
=
GetStringTableOption
(
g
,
tp
,
"Uri"
,
NULL
);
#if defined(MARIADB)
ftype
=
GetStringTableOption
(
g
,
tp
,
"Type"
,
"JSON"
);
ftype
=
GetStringTableOption
(
g
,
tp
,
"Type"
,
"JSON"
);
#else // !MARIADB
// OEM tables must specify the file type
ftype
=
GetStringTableOption
(
g
,
tp
,
"Ftype"
,
"JSON"
);
#endif // !MARIADB
fn
=
GetStringTableOption
(
g
,
tp
,
"Filename"
,
NULL
);
fn
=
GetStringTableOption
(
g
,
tp
,
"Filename"
,
NULL
);
if
(
!
fn
)
{
if
(
!
fn
)
{
...
@@ -333,12 +283,7 @@ bool RESTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
...
@@ -333,12 +283,7 @@ bool RESTDEF::DefineAM(PGLOBAL g, LPCSTR am, int poff)
if
(
!
curl
&&
!
(
grf
=
GetRestFunction
(
g
)))
if
(
!
curl
&&
!
(
grf
=
GetRestFunction
(
g
)))
curl
=
true
;
curl
=
true
;
#if defined(MARIADB)
ftype
=
GetStringCatInfo
(
g
,
"Type"
,
"JSON"
);
ftype
=
GetStringCatInfo
(
g
,
"Type"
,
"JSON"
);
#else // !MARIADB
// OEM tables must specify the file type
ftype
=
GetStringCatInfo
(
g
,
"Ftype"
,
"JSON"
);
#endif // !MARIADB
if
(
xt
)
if
(
xt
)
htrc
(
"ftype = %s am = %s
\n
"
,
ftype
,
SVP
(
am
));
htrc
(
"ftype = %s am = %s
\n
"
,
ftype
,
SVP
(
am
));
...
...
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