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
3f444827
Commit
3f444827
authored
May 03, 2017
by
Olivier Bertrand
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'ob-10.1' into 10.1
parents
040ccce8
ce3c7cd9
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
176 additions
and
178 deletions
+176
-178
storage/connect/catalog.h
storage/connect/catalog.h
+0
-3
storage/connect/connect.cc
storage/connect/connect.cc
+2
-6
storage/connect/ha_connect.cc
storage/connect/ha_connect.cc
+28
-27
storage/connect/ha_connect.h
storage/connect/ha_connect.h
+1
-1
storage/connect/mongofam.cpp
storage/connect/mongofam.cpp
+4
-1
storage/connect/mycat.cc
storage/connect/mycat.cc
+0
-33
storage/connect/mycat.h
storage/connect/mycat.h
+0
-5
storage/connect/mysql-test/connect/disabled.def
storage/connect/mysql-test/connect/disabled.def
+4
-2
storage/connect/plgdbutl.cpp
storage/connect/plgdbutl.cpp
+10
-9
storage/connect/plugutil.cpp
storage/connect/plugutil.cpp
+13
-6
storage/connect/reldef.cpp
storage/connect/reldef.cpp
+6
-1
storage/connect/tabjson.cpp
storage/connect/tabjson.cpp
+6
-4
storage/connect/tabmgo.cpp
storage/connect/tabmgo.cpp
+55
-49
storage/connect/tabmgo.h
storage/connect/tabmgo.h
+4
-4
storage/connect/tabmul.cpp
storage/connect/tabmul.cpp
+36
-25
storage/connect/tabmul.h
storage/connect/tabmul.h
+3
-1
storage/connect/tabxml.cpp
storage/connect/tabxml.cpp
+4
-1
No files found.
storage/connect/catalog.h
View file @
3f444827
...
...
@@ -68,11 +68,9 @@ class DllExport CATALOG {
bool
GetDefHuge
(
void
)
{
return
DefHuge
;}
void
SetDefHuge
(
bool
b
)
{
DefHuge
=
b
;}
char
*
GetCbuf
(
void
)
{
return
Cbuf
;}
//char *GetDataPath(void) {return (char*)DataPath;}
// Methods
virtual
void
Reset
(
void
)
{}
//virtual void SetDataPath(PGLOBAL g, const char *path) {}
virtual
bool
CheckName
(
PGLOBAL
,
char
*
)
{
return
true
;}
virtual
bool
ClearName
(
PGLOBAL
,
PSZ
)
{
return
true
;}
virtual
PRELDEF
MakeOneTableDesc
(
PGLOBAL
,
LPCSTR
,
LPCSTR
)
{
return
NULL
;}
...
...
@@ -102,7 +100,6 @@ class DllExport CATALOG {
int
Cblen
;
/* Length of suballoc. buffer */
CURTAB
Ctb
;
/* Used to enumerate tables */
bool
DefHuge
;
/* true: tables default to huge */
//LPCSTR DataPath; /* Is the Path of DB data dir */
};
// end of class CATALOG
#endif // __CATALOG__H
storage/connect/connect.cc
View file @
3f444827
...
...
@@ -117,11 +117,10 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
handler
);
// Set the database path for this table
handler
->
SetDataPath
(
g
,
pathname
);
if
(
handler
->
SetDataPath
(
g
,
pathname
))
return
true
;
if
(
dbuserp
->
Catalog
)
{
// ((MYCAT *)dbuserp->Catalog)->SetHandler(handler); done later
// ((MYCAT *)dbuserp->Catalog)->SetDataPath(g, pathname);
return
false
;
// Nothing else to do
}
// endif Catalog
...
...
@@ -138,9 +137,6 @@ bool CntCheckDB(PGLOBAL g, PHC handler, const char *pathname)
if
(
!
(
dbuserp
->
Catalog
=
new
MYCAT
(
handler
)))
return
true
;
//((MYCAT *)dbuserp->Catalog)->SetDataPath(g, pathname);
//dbuserp->UseTemp= TMP_AUTO;
/*********************************************************************/
/* All is correct. */
/*********************************************************************/
...
...
storage/connect/ha_connect.cc
View file @
3f444827
...
...
@@ -212,7 +212,7 @@ PQRYRES VirColumns(PGLOBAL g, bool info);
PQRYRES
JSONColumns
(
PGLOBAL
g
,
char
*
db
,
char
*
dsn
,
PTOS
topt
,
bool
info
);
PQRYRES
XMLColumns
(
PGLOBAL
g
,
char
*
db
,
char
*
tab
,
PTOS
topt
,
bool
info
);
#if defined(MONGO_SUPPORT)
PQRYRES
MGOColumns
(
PGLOBAL
g
,
char
*
db
,
char
*
dsn
,
PTOS
topt
,
bool
info
);
PQRYRES
MGOColumns
(
PGLOBAL
g
,
char
*
db
,
PTOS
topt
,
bool
info
);
#endif // MONGO_SUPPORT
int
TranslateJDBCType
(
int
stp
,
char
*
tn
,
int
prec
,
int
&
len
,
char
&
v
);
void
PushWarning
(
PGLOBAL
g
,
THD
*
thd
,
int
level
);
...
...
@@ -1751,9 +1751,9 @@ void ha_connect::AddColName(char *cp, Field *fp)
/***********************************************************************/
/* This function sets the current database path. */
/***********************************************************************/
void
ha_connect
::
SetDataPath
(
PGLOBAL
g
,
const
char
*
path
)
bool
ha_connect
::
SetDataPath
(
PGLOBAL
g
,
const
char
*
path
)
{
datapath
=
SetPath
(
g
,
path
);
return
(
!
(
datapath
=
SetPath
(
g
,
path
))
);
}
// end of SetDataPath
/****************************************************************************/
...
...
@@ -2709,6 +2709,8 @@ PCFIL ha_connect::CheckCond(PGLOBAL g, PCFIL filp, const Item *cond)
if
(
x
)
return
NULL
;
else
pb0
=
pb1
=
pb2
=
ph0
=
ph1
=
ph2
=
NULL
;
if
(
trace
)
htrc
(
"Cond: Ftype=%d name=%s
\n
"
,
cond_item
->
functype
(),
...
...
@@ -4004,8 +4006,12 @@ int ha_connect::rnd_pos(uchar *buf, uchar *pos)
tdbp
->
SetFilter
(
NULL
);
rc
=
rnd_next
(
buf
);
}
else
rc
=
HA_ERR_KEY_NOT_FOUND
;
}
else
{
PGLOBAL
g
=
GetPlug
((
table
)
?
table
->
in_use
:
NULL
,
xp
);
strcpy
(
g
->
Message
,
"Not supported by this table type"
);
my_message
(
ER_UNKNOWN_ERROR
,
g
->
Message
,
MYF
(
0
));
rc
=
HA_ERR_INTERNAL_ERROR
;
}
// endif SetRecpos
DBUG_RETURN
(
rc
);
}
// end of rnd_pos
...
...
@@ -4071,9 +4077,13 @@ int ha_connect::info(uint flag)
}
// endif xmod
// This is necessary for getting file length
if
(
table
)
SetDataPath
(
g
,
table
->
s
->
db
.
str
);
else
if
(
table
)
{
if
(
SetDataPath
(
g
,
table
->
s
->
db
.
str
))
{
my_message
(
ER_UNKNOWN_ERROR
,
g
->
Message
,
MYF
(
0
));
DBUG_RETURN
(
HA_ERR_INTERNAL_ERROR
);
}
// endif SetDataPath
}
else
DBUG_RETURN
(
HA_ERR_INTERNAL_ERROR
);
// Should never happen
if
(
!
(
tdbp
=
GetTDB
(
g
)))
...
...
@@ -5562,13 +5572,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
break
;
#if defined(MONGO_SUPPORT)
case
TAB_MONGO
:
dsn
=
strz
(
g
,
create_info
->
connect_string
);
if
(
!
dsn
)
strcpy
(
g
->
Message
,
"Missing URI"
);
else
ok
=
true
;
ok
=
true
;
break
;
#endif // MONGO_SUPPORT
case
TAB_VIR
:
...
...
@@ -5595,12 +5599,10 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
char
*
cnm
,
*
rem
,
*
dft
,
*
xtra
,
*
key
,
*
fmt
;
int
i
,
len
,
prec
,
dec
,
typ
,
flg
;
// if (cat)
// cat->SetDataPath(g, table_s->db.str);
// else
// return HA_ERR_INTERNAL_ERROR; // Should never happen
dpath
=
SetPath
(
g
,
table_s
->
db
.
str
);
if
(
!
(
dpath
=
SetPath
(
g
,
table_s
->
db
.
str
)))
{
rc
=
HA_ERR_INTERNAL_ERROR
;
goto
err
;
}
// endif dpath
if
(
src
&&
ttp
!=
TAB_PIVOT
&&
ttp
!=
TAB_ODBC
&&
ttp
!=
TAB_JDBC
)
{
qrp
=
SrcColumns
(
g
,
host
,
db
,
user
,
pwd
,
src
,
port
);
...
...
@@ -5716,7 +5718,7 @@ static int connect_assisted_discovery(handlerton *, THD* thd,
break
;
#if defined(MONGO_SUPPORT)
case
TAB_MONGO
:
qrp
=
MGOColumns
(
g
,
(
char
*
)
db
,
dsn
,
topt
,
fnc
==
FNC_COL
);
qrp
=
MGOColumns
(
g
,
(
char
*
)
db
,
topt
,
fnc
==
FNC_COL
);
break
;
#endif // MONGO_SUPPORT
#if defined(LIBXML2_SUPPORT) || defined(DOMDOC_SUPPORT)
...
...
@@ -6521,11 +6523,10 @@ int ha_connect::create(const char *name, TABLE *table_arg,
PDBUSER
dup
=
PlgGetUser
(
g
);
PCATLG
cat
=
(
dup
)
?
dup
->
Catalog
:
NULL
;
SetDataPath
(
g
,
table_arg
->
s
->
db
.
str
);
if
(
cat
)
{
// cat->SetDataPath(g, table_arg->s->db.str);
if
(
SetDataPath
(
g
,
table_arg
->
s
->
db
.
str
))
{
my_message
(
ER_UNKNOWN_ERROR
,
g
->
Message
,
MYF
(
0
));
rc
=
HA_ERR_INTERNAL_ERROR
;
}
else
if
(
cat
)
{
#if defined(WITH_PARTITION_STORAGE_ENGINE)
if
(
part_info
)
strncpy
(
partname
,
...
...
storage/connect/ha_connect.h
View file @
3f444827
...
...
@@ -199,7 +199,7 @@ class ha_connect: public handler
bool
IsUnique
(
uint
n
);
char
*
GetDataPath
(
void
)
{
return
(
char
*
)
datapath
;}
void
SetDataPath
(
PGLOBAL
g
,
const
char
*
path
);
bool
SetDataPath
(
PGLOBAL
g
,
const
char
*
path
);
PTDB
GetTDB
(
PGLOBAL
g
);
int
OpenTable
(
PGLOBAL
g
,
bool
del
=
false
);
bool
CheckColumnList
(
PGLOBAL
g
);
...
...
storage/connect/mongofam.cpp
View file @
3f444827
...
...
@@ -767,6 +767,9 @@ void MGOFAM::CloseTableFile(PGLOBAL g, bool)
/***********************************************************************/
void
MGOFAM
::
Rewind
(
void
)
{
// TODO implement me
mongoc_cursor_t
*
cursor
=
mongoc_cursor_clone
(
Cursor
);
mongoc_cursor_destroy
(
Cursor
);
Cursor
=
cursor
;
}
// end of Rewind
storage/connect/mycat.cc
View file @
3f444827
...
...
@@ -484,39 +484,6 @@ void MYCAT::Reset(void)
{
}
// end of Reset
#if 0
/***********************************************************************/
/* This function sets the current database path. */
/***********************************************************************/
void MYCAT::SetPath(PGLOBAL g, LPCSTR *datapath, const char *path)
{
if (path) {
size_t len= strlen(path) + (*path != '.' ? 4 : 1);
char *buf= (char*)PlugSubAlloc(g, NULL, len);
if (PlugIsAbsolutePath(path))
{
strcpy(buf, path);
*datapath= buf;
return;
}
if (*path != '.') {
#if defined(__WIN__)
char *s= "\\";
#else // !__WIN__
char *s= "/";
#endif // !__WIN__
strcat
(
strcat
(
strcat
(
strcpy
(
buf
,
"."
),
s
),
path
),
s
);
}
else
strcpy
(
buf
,
path
);
*
datapath
=
buf
;
}
// endif path
}
// end of SetDataPath
#endif // 0
/***********************************************************************/
/* GetTableDesc: retrieve a table descriptor. */
/* Look for a table descriptor matching the name and type. */
...
...
storage/connect/mycat.h
View file @
3f444827
...
...
@@ -98,10 +98,7 @@ class MYCAT : public CATALOG {
// Methods
void
Reset
(
void
);
//void SetDataPath(PGLOBAL g, const char *path)
// {SetPath(g, &DataPath, path);}
bool
StoreIndex
(
PGLOBAL
,
PTABDEF
)
{
return
false
;}
// Temporary
// PRELDEF GetTableDesc(PGLOBAL g, LPCSTR name,
PRELDEF
GetTableDesc
(
PGLOBAL
g
,
PTABLE
tablep
,
LPCSTR
type
,
PRELDEF
*
prp
=
NULL
);
PTDB
GetTable
(
PGLOBAL
g
,
PTABLE
tablep
,
...
...
@@ -109,9 +106,7 @@ class MYCAT : public CATALOG {
void
ClearDB
(
PGLOBAL
g
);
protected:
// PRELDEF MakeTableDesc(PGLOBAL g, LPCSTR name, LPCSTR am);
PRELDEF
MakeTableDesc
(
PGLOBAL
g
,
PTABLE
tablep
,
LPCSTR
am
);
//void SetPath(PGLOBAL g, LPCSTR *datapath, const char *path);
// Members
ha_connect
*
Hc
;
// The Connect handler
...
...
storage/connect/mysql-test/connect/disabled.def
View file @
3f444827
...
...
@@ -9,7 +9,9 @@
# Do not use any TAB characters for whitespace.
#
##############################################################################
#
jdbc : Variable settings depend on machine configuration
#
jdbc_new : Variable settings depend on machine configuration
jdbc : Variable settings depend on machine configuration
jdbc_new : Variable settings depend on machine configuration
jdbc_oracle : Variable settings depend on machine configuration
jdbc_postgresql : Variable settings depend on machine configuration
json_mgo : Need MongoDB running and its C Driver installed
mongo : Need MongoDB running and its C Driver installed
storage/connect/plgdbutl.cpp
View file @
3f444827
...
...
@@ -387,26 +387,27 @@ char *SetPath(PGLOBAL g, const char *path)
char
*
buf
=
NULL
;
if
(
path
)
{
size_t
len
=
strlen
(
path
)
+
(
*
path
!=
'.'
?
4
:
1
);
size_t
len
=
strlen
(
path
)
+
(
*
path
!=
'.'
?
4
:
1
);
if
(
!
(
buf
=
(
char
*
)
PlgDBSubAlloc
(
g
,
NULL
,
len
)))
return
NULL
;
buf
=
(
char
*
)
PlugSubAlloc
(
g
,
NULL
,
len
);
if
(
PlugIsAbsolutePath
(
path
))
{
strcpy
(
buf
,
path
);
return
buf
;
}
// endif path
strcpy
(
buf
,
path
);
return
buf
;
}
// endif path
if
(
*
path
!=
'.'
)
{
#if defined(__WIN__)
char
*
s
=
"
\\
"
;
char
*
s
=
"
\\
"
;
#else // !__WIN__
char
*
s
=
"/"
;
char
*
s
=
"/"
;
#endif // !__WIN__
strcat
(
strcat
(
strcat
(
strcpy
(
buf
,
"."
),
s
),
path
),
s
);
}
else
strcpy
(
buf
,
path
);
}
// endif path
}
// endif path
return
buf
;
}
// end of SetPath
...
...
storage/connect/plugutil.cpp
View file @
3f444827
...
...
@@ -139,10 +139,17 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
htrc
(
"PlugInit: Language='%s'
\n
"
,
((
!
Language
)
?
"Null"
:
(
char
*
)
Language
));
if
(
!
(
g
=
(
PGLOBAL
)
malloc
(
sizeof
(
GLOBAL
))))
{
fprintf
(
stderr
,
MSG
(
GLOBAL_ERROR
),
(
int
)
sizeof
(
GLOBAL
));
return
NULL
;
}
else
{
try
{
g
=
new
GLOBAL
;
}
catch
(...)
{
fprintf
(
stderr
,
MSG
(
GLOBAL_ERROR
),
(
int
)
sizeof
(
GLOBAL
));
return
NULL
;
}
// end try/catch
//if (!(g = (PGLOBAL)malloc(sizeof(GLOBAL)))) {
// fprintf(stderr, MSG(GLOBAL_ERROR), (int)sizeof(GLOBAL));
// return NULL;
// } else {
g
->
Sarea
=
NULL
;
g
->
Createas
=
0
;
g
->
Alchecked
=
0
;
...
...
@@ -164,7 +171,7 @@ PGLOBAL PlugInit(LPCSTR Language, uint worksize)
}
else
g
->
Sarea_Size
=
worksize
;
}
/* endif g */
//
} /* endif g */
g
->
jump_level
=
-
1
;
/* New setting to allow recursive call of Plug */
return
(
g
);
...
...
@@ -183,7 +190,7 @@ int PlugExit(PGLOBAL g)
if
(
g
->
Sarea
)
free
(
g
->
Sarea
);
free
(
g
)
;
delete
g
;
return
rc
;
}
/* end of PlugExit */
...
...
storage/connect/reldef.cpp
View file @
3f444827
...
...
@@ -277,8 +277,13 @@ int TABDEF::GetColCatInfo(PGLOBAL g)
// Take care of the column definitions
i
=
poff
=
nof
=
nlg
=
0
;
#if defined(__WIN__)
// Offsets of HTML and DIR tables start from 0, DBF at 1
loff
=
(
tc
==
TAB_DBF
)
?
1
:
(
tc
==
TAB_XML
||
tc
==
TAB_DIR
)
?
-
1
:
0
;
loff
=
(
tc
==
TAB_DBF
)
?
1
:
(
tc
==
TAB_XML
||
tc
==
TAB_DIR
)
?
-
1
:
0
;
#else // !__WIN__
// Offsets of HTML tables start from 0, DIR and DBF at 1
loff
=
(
tc
==
TAB_DBF
||
tc
==
TAB_DIR
)
?
1
:
(
tc
==
TAB_XML
)
?
-
1
:
0
;
#endif // !__WIN__
while
(
true
)
{
// Default Offset depends on table type
...
...
storage/connect/tabjson.cpp
View file @
3f444827
...
...
@@ -120,7 +120,9 @@ PQRYRES JSONColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info)
return
NULL
;
}
// endif Fn
tdp
->
Database
=
SetPath
(
g
,
db
);
if
(
!
(
tdp
->
Database
=
SetPath
(
g
,
db
)))
return
NULL
;
tdp
->
Objname
=
GetStringTableOption
(
g
,
topt
,
"Object"
,
NULL
);
tdp
->
Base
=
GetIntegerTableOption
(
g
,
topt
,
"Base"
,
0
)
?
1
:
0
;
tdp
->
Pretty
=
GetIntegerTableOption
(
g
,
topt
,
"Pretty"
,
2
);
...
...
@@ -746,10 +748,10 @@ bool TDBJSN::OpenDB(PGLOBAL g)
return
true
;
}
// endswitch Jmode
}
// endif Use
if
(
Xcol
&&
Txfp
->
GetAmType
()
!=
TYPE_AM_MGO
)
To_Filter
=
NULL
;
// Imcompatible
if
(
Xcol
&&
Txfp
->
GetAmType
()
!=
TYPE_AM_MGO
)
To_Filter
=
NULL
;
// Imcompatible
}
// endif Use
return
TDBDOS
::
OpenDB
(
g
);
}
// end of OpenDB
...
...
storage/connect/tabmgo.cpp
View file @
3f444827
...
...
@@ -39,7 +39,7 @@
/* MGOColumns: construct the result blocks containing the description */
/* of all the columns of a document contained inside MongoDB. */
/***********************************************************************/
PQRYRES
MGOColumns
(
PGLOBAL
g
,
char
*
db
,
char
*
dsn
,
PTOS
topt
,
bool
info
)
PQRYRES
MGOColumns
(
PGLOBAL
g
,
char
*
db
,
PTOS
topt
,
bool
info
)
{
static
int
buftyp
[]
=
{
TYPE_STRING
,
TYPE_SHORT
,
TYPE_STRING
,
TYPE_INT
,
TYPE_INT
,
TYPE_SHORT
,
TYPE_SHORT
,
TYPE_STRING
};
...
...
@@ -64,7 +64,7 @@ PQRYRES MGOColumns(PGLOBAL g, char *db, char *dsn, PTOS topt, bool info)
/*********************************************************************/
mgd
=
new
(
g
)
MGODISC
(
g
,
(
int
*
)
length
);
if
((
n
=
mgd
->
GetColumns
(
g
,
db
,
dsn
,
topt
))
<
0
)
if
((
n
=
mgd
->
GetColumns
(
g
,
db
,
topt
))
<
0
)
goto
err
;
skipit:
...
...
@@ -142,7 +142,7 @@ MGODISC::MGODISC(PGLOBAL g, int *lg) {
/***********************************************************************/
/* Class used to get the columns of a mongo collection. */
/***********************************************************************/
int
MGODISC
::
GetColumns
(
PGLOBAL
g
,
char
*
db
,
char
*
dsn
,
PTOS
topt
)
int
MGODISC
::
GetColumns
(
PGLOBAL
g
,
char
*
db
,
PTOS
topt
)
{
bson_iter_t
iter
;
const
bson_t
*
doc
;
...
...
@@ -153,16 +153,11 @@ int MGODISC::GetColumns(PGLOBAL g, char *db, char *dsn, PTOS topt)
lvl
=
(
lvl
>
16
)
?
16
:
lvl
;
all
=
GetBooleanTableOption
(
g
,
topt
,
"Fullarray"
,
false
);
if
(
!
dsn
)
{
strcpy
(
g
->
Message
,
"Missing URI"
);
return
-
1
;
}
// endif dsn
/*********************************************************************/
/* Open the MongoDB collection. */
/*********************************************************************/
tdp
=
new
(
g
)
MGODEF
;
tdp
->
Uri
=
dsn
;
tdp
->
Uri
=
GetStringTableOption
(
g
,
topt
,
"Connect"
,
"mongodb://localhost:27017"
)
;
tdp
->
Tabname
=
GetStringTableOption
(
g
,
topt
,
"Name"
,
NULL
);
tdp
->
Tabname
=
GetStringTableOption
(
g
,
topt
,
"Tabname"
,
tdp
->
Tabname
);
tdp
->
Tabschema
=
GetStringTableOption
(
g
,
topt
,
"Dbname"
,
db
);
...
...
@@ -397,7 +392,7 @@ bool MGODEF::DefineAM(PGLOBAL g, LPCSTR, int poff)
else
if
(
!
Tabschema
)
Tabschema
=
GetStringCatInfo
(
g
,
"Dbname"
,
"*"
);
Uri
=
GetStringCatInfo
(
g
,
"Connect"
,
NULL
);
Uri
=
GetStringCatInfo
(
g
,
"Connect"
,
"mongodb://localhost:27017"
);
Colist
=
GetStringCatInfo
(
g
,
"Colist"
,
NULL
);
Filter
=
GetStringCatInfo
(
g
,
"Filter"
,
NULL
);
Base
=
GetIntCatInfo
(
"Base"
,
0
)
?
1
:
0
;
...
...
@@ -713,13 +708,13 @@ void TDBMGO::SetFilter(PFIL fp)
To_Filter
=
fp
;
if
(
fp
&&
Cursor
&&
Cnd
!=
Cond
)
{
mongoc_cursor_t
*
cursor
=
NULL
;
mongoc_cursor_t
*
cursor
=
MakeCursor
(
G
)
;
if
(
!
MakeCursor
(
G
,
cursor
)
)
{
if
(
cursor
)
{
mongoc_cursor_destroy
(
Cursor
);
Cursor
=
cursor
;
}
else
if
(
cursor
)
mongoc_cursor_destroy
(
cursor
);
}
else
htrc
(
"SetFilter: %s
\n
"
,
G
->
Message
);
}
// endif Cursor
...
...
@@ -728,10 +723,11 @@ void TDBMGO::SetFilter(PFIL fp)
/***********************************************************************/
/* OpenDB: Data Base open routine for MONGO access method. */
/***********************************************************************/
bool
TDBMGO
::
MakeCursor
(
PGLOBAL
g
,
mongoc_cursor_t
*
cursor
)
mongoc_cursor_t
*
TDBMGO
::
MakeCursor
(
PGLOBAL
g
)
{
const
char
*
p
;
PSTRG
s
=
NULL
;
const
char
*
p
;
mongoc_cursor_t
*
cursor
;
PSTRG
s
=
NULL
;
if
(
Pipe
)
{
if
(
trace
)
...
...
@@ -741,7 +737,7 @@ bool TDBMGO::MakeCursor(PGLOBAL g, mongoc_cursor_t *cursor)
if
(
!
p
)
{
strcpy
(
g
->
Message
,
"Missing ] in pipeline"
);
return
true
;
return
NULL
;
}
else
*
(
char
*
)
p
=
0
;
...
...
@@ -752,7 +748,7 @@ bool TDBMGO::MakeCursor(PGLOBAL g, mongoc_cursor_t *cursor)
if
(
To_Filter
->
MakeSelector
(
g
,
s
,
true
))
{
strcpy
(
g
->
Message
,
"Failed making selector"
);
return
true
;
return
NULL
;
}
else
s
->
Append
(
'}'
);
...
...
@@ -779,15 +775,15 @@ bool TDBMGO::MakeCursor(PGLOBAL g, mongoc_cursor_t *cursor)
if
(
!
Query
)
{
sprintf
(
g
->
Message
,
"Wrong pipeline: %s"
,
Error
.
message
);
return
true
;
return
NULL
;
}
// endif Query
C
ursor
=
mongoc_collection_aggregate
(
Collection
,
MONGOC_QUERY_NONE
,
c
ursor
=
mongoc_collection_aggregate
(
Collection
,
MONGOC_QUERY_NONE
,
Query
,
NULL
,
NULL
);
if
(
mongoc_cursor_error
(
C
ursor
,
&
Error
))
{
if
(
mongoc_cursor_error
(
c
ursor
,
&
Error
))
{
sprintf
(
g
->
Message
,
"Mongo aggregate Failure: %s"
,
Error
.
message
);
return
true
;
return
NULL
;
}
// endif cursor
}
else
{
...
...
@@ -813,7 +809,7 @@ bool TDBMGO::MakeCursor(PGLOBAL g, mongoc_cursor_t *cursor)
if
(
To_Filter
->
MakeSelector
(
g
,
s
,
true
))
{
strcpy
(
g
->
Message
,
"Failed making selector"
);
return
true
;
return
NULL
;
}
// endif Selector
To_Filter
=
NULL
;
// Not needed anymore
...
...
@@ -827,7 +823,7 @@ bool TDBMGO::MakeCursor(PGLOBAL g, mongoc_cursor_t *cursor)
if
(
!
Query
)
{
sprintf
(
g
->
Message
,
"Wrong filter: %s"
,
Error
.
message
);
return
true
;
return
NULL
;
}
// endif Query
}
else
...
...
@@ -858,13 +854,13 @@ bool TDBMGO::MakeCursor(PGLOBAL g, mongoc_cursor_t *cursor)
if
(
!
Opts
)
{
sprintf
(
g
->
Message
,
"Wrong options: %s"
,
Error
.
message
);
return
true
;
return
NULL
;
}
// endif Opts
C
ursor
=
mongoc_collection_find_with_opts
(
Collection
,
Query
,
Opts
,
NULL
);
c
ursor
=
mongoc_collection_find_with_opts
(
Collection
,
Query
,
Opts
,
NULL
);
}
// endif Pipe
return
false
;
return
cursor
;
}
// end of MakeCursor
/***********************************************************************/
...
...
@@ -876,33 +872,37 @@ bool TDBMGO::OpenDB(PGLOBAL g)
/*******************************************************************/
/* Table already open replace it at its beginning. */
/*******************************************************************/
mongoc_cursor_t
*
cursor
=
mongoc_cursor_clone
(
Cursor
);
mongoc_cursor_destroy
(
Cursor
);
Cursor
=
cursor
;
Fpos
=
-
1
;
}
else
{
/*******************************************************************/
/* First opening. */
/*******************************************************************/
if
(
Pipe
&&
Mode
!=
MODE_READ
)
{
strcpy
(
g
->
Message
,
"Pipeline tables are read only"
);
return
true
;
}
// endif Pipe
return
false
;
}
// endif Use
if
(
Init
(
g
))
return
true
;
/*********************************************************************/
/* First opening. */
/*********************************************************************/
if
(
Pipe
&&
Mode
!=
MODE_READ
)
{
strcpy
(
g
->
Message
,
"Pipeline tables are read only"
);
return
true
;
}
// endif Pipe
if
(
Mode
==
MODE_DELETE
&&
!
Next
)
{
// Delete all documents
if
(
!
mongoc_collection_remove
(
Collection
,
MONGOC_REMOVE_NONE
,
Query
,
NULL
,
&
Error
))
{
sprintf
(
g
->
Message
,
"Mongo remove all: %s"
,
Error
.
message
);
return
true
;
}
// endif remove
if
(
Init
(
g
))
return
true
;
}
else
if
(
Mode
==
MODE_INSERT
)
MakeColumnGroups
(
g
);
else
if
(
MakeCursor
(
g
,
Cursor
))
if
(
Mode
==
MODE_DELETE
&&
!
Next
)
{
// Delete all documents
if
(
!
mongoc_collection_remove
(
Collection
,
MONGOC_REMOVE_NONE
,
Query
,
NULL
,
&
Error
))
{
sprintf
(
g
->
Message
,
"Mongo remove all: %s"
,
Error
.
message
);
return
true
;
}
// endif remove
}
// endif Use
}
else
if
(
Mode
==
MODE_INSERT
)
MakeColumnGroups
(
g
);
else
if
(
!
(
Cursor
=
MakeCursor
(
g
)))
return
true
;
return
false
;
}
// end of OpenDB
...
...
@@ -1081,6 +1081,12 @@ int TDBMGO::WriteDB(PGLOBAL g)
}
// endif iter
if
(
b
)
{
if
(
trace
)
{
char
*
str
=
bson_as_json
(
query
,
NULL
);
htrc
(
"update query: %s
\n
"
,
str
);
bson_free
(
str
);
}
// endif trace
if
(
Mode
==
MODE_UPDATE
)
{
bson_t
child
;
bson_t
*
update
=
bson_new
();
...
...
storage/connect/tabmgo.h
View file @
3f444827
...
...
@@ -48,7 +48,7 @@ class MGODISC : public BLOCK {
MGODISC
(
PGLOBAL
g
,
int
*
lg
);
// Functions
int
GetColumns
(
PGLOBAL
g
,
char
*
db
,
char
*
dsn
,
PTOS
topt
);
int
GetColumns
(
PGLOBAL
g
,
char
*
db
,
PTOS
topt
);
bool
FindInDoc
(
PGLOBAL
g
,
bson_iter_t
*
iter
,
const
bson_t
*
doc
,
char
*
pcn
,
char
*
pfmt
,
int
i
,
int
k
,
bool
b
);
...
...
@@ -69,7 +69,7 @@ class DllExport MGODEF : public EXTDEF { /* Table description */
friend
class
TDBMGO
;
friend
class
MGOFAM
;
friend
class
MGODISC
;
friend
PQRYRES
MGOColumns
(
PGLOBAL
,
char
*
,
char
*
,
PTOS
,
bool
);
friend
PQRYRES
MGOColumns
(
PGLOBAL
,
char
*
,
PTOS
,
bool
);
public:
// Constructor
MGODEF
(
void
);
...
...
@@ -117,7 +117,7 @@ class DllExport TDBMGO : public TDBEXT {
friend
class
MGOCOL
;
friend
class
MGODEF
;
friend
class
MGODISC
;
friend
PQRYRES
MGOColumns
(
PGLOBAL
,
char
*
,
char
*
,
PTOS
,
bool
);
friend
PQRYRES
MGOColumns
(
PGLOBAL
,
char
*
,
PTOS
,
bool
);
public:
// Constructor
TDBMGO
(
PMGODEF
tdp
);
...
...
@@ -146,7 +146,7 @@ class DllExport TDBMGO : public TDBEXT {
protected:
bool
Init
(
PGLOBAL
g
);
bool
MakeCursor
(
PGLOBAL
g
,
mongoc_cursor_t
*
cursor
);
mongoc_cursor_t
*
MakeCursor
(
PGLOBAL
g
);
void
ShowDocument
(
bson_iter_t
*
i
,
const
bson_t
*
b
,
const
char
*
k
);
void
MakeColumnGroups
(
PGLOBAL
g
);
bool
DocWrite
(
PGLOBAL
g
,
PINCOL
icp
);
...
...
storage/connect/tabmul.cpp
View file @
3f444827
...
...
@@ -603,8 +603,9 @@ bool TDBMSD::InitFileNames(PGLOBAL g)
bool
DIRDEF
::
DefineAM
(
PGLOBAL
g
,
LPCSTR
,
int
)
{
Desc
=
Fn
=
GetStringCatInfo
(
g
,
"Filename"
,
NULL
);
Incl
=
(
GetIntCatInfo
(
"Subdir"
,
0
)
!=
0
);
Huge
=
(
GetIntCatInfo
(
"Huge"
,
0
)
!=
0
);
Incl
=
GetBoolCatInfo
(
"Subdir"
,
false
);
Huge
=
GetBoolCatInfo
(
"Huge"
,
false
);
Nodir
=
GetBoolCatInfo
(
"Nodir"
,
true
);
return
false
;
}
// end of DefineAM
...
...
@@ -654,12 +655,14 @@ void TDBDIR::Init(void)
TDBDIR
::
TDBDIR
(
PDIRDEF
tdp
)
:
TDBASE
(
tdp
)
{
To_File
=
tdp
->
Fn
;
Nodir
=
tdp
->
Nodir
;
Init
();
}
// end of TDBDIR standard constructor
TDBDIR
::
TDBDIR
(
PSZ
fpat
)
:
TDBASE
((
PTABDEF
)
NULL
)
{
To_File
=
fpat
;
Nodir
=
true
;
Init
();
}
// end of TDBDIR constructor
...
...
@@ -812,27 +815,32 @@ int TDBDIR::ReadDB(PGLOBAL g)
int
rc
=
RC_OK
;
#if defined(__WIN__)
if
(
hSearch
==
INVALID_HANDLE_VALUE
)
{
/*******************************************************************/
/* Start searching files in the target directory. The use of the */
/* Path function is required when called from TDBSDR. */
/*******************************************************************/
hSearch
=
FindFirstFile
(
Path
(
g
),
&
FileData
);
do
{
if
(
hSearch
==
INVALID_HANDLE_VALUE
)
{
/*****************************************************************/
/* Start searching files in the target directory. The use of */
/* the Path function is required when called from TDBSDR. */
/*****************************************************************/
hSearch
=
FindFirstFile
(
Path
(
g
),
&
FileData
);
if
(
hSearch
==
INVALID_HANDLE_VALUE
)
{
rc
=
RC_EF
;
break
;
}
else
iFile
++
;
if
(
hSearch
==
INVALID_HANDLE_VALUE
)
rc
=
RC_EF
;
else
iFile
++
;
}
else
{
if
(
!
FindNextFile
(
hSearch
,
&
FileData
))
{
// Restore file name and type pattern
_splitpath
(
To_File
,
NULL
,
NULL
,
Fname
,
Ftype
);
rc
=
RC_EF
;
break
;
}
else
iFile
++
;
}
else
{
if
(
!
FindNextFile
(
hSearch
,
&
FileData
))
{
// Restore file name and type pattern
_splitpath
(
To_File
,
NULL
,
NULL
,
Fname
,
Ftype
);
rc
=
RC_EF
;
}
else
iFile
++
;
}
// endif hSearch
}
// endif hSearch
}
while
(
Nodir
&&
FileData
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
);
if
(
rc
==
RC_OK
)
_splitpath
(
FileData
.
cFileName
,
NULL
,
NULL
,
Fname
,
Ftype
);
...
...
@@ -1225,8 +1233,9 @@ int TDBSDR::ReadDB(PGLOBAL g)
retry:
do
{
if
(
Sub
->
H
==
INVALID_HANDLE_VALUE
)
{
_makepath
(
Fpath
,
Drive
,
Direc
,
"*"
,
"."
);
Sub
->
H
=
FindFirstFile
(
Fpath
,
&
FileData
);
// _makepath(Fpath, Drive, Direc, "*", "."); why was this made?
_makepath
(
Fpath
,
Drive
,
Direc
,
"*"
,
NULL
);
Sub
->
H
=
FindFirstFile
(
Fpath
,
&
FileData
);
}
else
if
(
!
FindNextFile
(
Sub
->
H
,
&
FileData
))
{
FindClose
(
Sub
->
H
);
Sub
->
H
=
INVALID_HANDLE_VALUE
;
...
...
@@ -1234,8 +1243,9 @@ int TDBSDR::ReadDB(PGLOBAL g)
break
;
}
// endif findnext
}
while
(
!
(
FileData
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
||
*
FileData
.
cFileName
==
'.'
);
}
while
(
!
(
FileData
.
dwFileAttributes
&
FILE_ATTRIBUTE_DIRECTORY
)
||
(
*
FileData
.
cFileName
==
'.'
&&
(
!
FileData
.
cFileName
[
1
]
||
FileData
.
cFileName
[
1
]
==
'.'
)));
if
(
Sub
->
H
==
INVALID_HANDLE_VALUE
)
{
// No more sub-directories. Are we in a sub-directory?
...
...
@@ -1289,7 +1299,8 @@ int TDBSDR::ReadDB(PGLOBAL g)
if
(
lstat
(
Fpath
,
&
Fileinfo
)
<
0
)
{
sprintf
(
g
->
Message
,
"%s: %s"
,
Fpath
,
strerror
(
errno
));
rc
=
RC_FX
;
}
else
if
(
S_ISDIR
(
Fileinfo
.
st_mode
)
&&
*
Entry
->
d_name
!=
'.'
)
{
}
else
if
(
S_ISDIR
(
Fileinfo
.
st_mode
)
&&
strcmp
(
Entry
->
d_name
,
"."
)
&&
strcmp
(
Entry
->
d_name
,
".."
))
{
// Look in the name sub-directory
if
(
!
Sub
->
Next
)
{
PSUBDIR
sup
;
...
...
storage/connect/tabmul.h
View file @
3f444827
...
...
@@ -118,7 +118,8 @@ class DllExport DIRDEF : public TABDEF { /* Directory listing table */
// Members
PSZ
Fn
;
/* Path/Name of file search */
bool
Incl
;
/* true to include sub-directories */
bool
Huge
;
/* true if files can be larger than 2GB */
bool
Huge
;
/* true if files can be larger than 2GB */
bool
Nodir
;
/* true to exclude directories */
};
// end of DIRDEF
/***********************************************************************/
...
...
@@ -175,6 +176,7 @@ class TDBDIR : public TDBASE {
char
Direc
[
_MAX_DIR
];
// Search path
char
Fname
[
_MAX_FNAME
];
// File name
char
Ftype
[
_MAX_EXT
];
// File extention
bool
Nodir
;
// Exclude directories from file list
};
// end of class TDBDIR
/***********************************************************************/
...
...
storage/connect/tabxml.cpp
View file @
3f444827
...
...
@@ -157,7 +157,10 @@ PQRYRES XMLColumns(PGLOBAL g, char *db, char *tab, PTOS topt, bool info)
tdp
=
new
(
g
)
XMLDEF
;
tdp
->
Fn
=
fn
;
tdp
->
Database
=
SetPath
(
g
,
db
);
if
(
!
(
tdp
->
Database
=
SetPath
(
g
,
db
)))
return
NULL
;
tdp
->
Tabname
=
tab
;
tdp
->
Zipped
=
GetBooleanTableOption
(
g
,
topt
,
"Zipped"
,
false
);
tdp
->
Entry
=
GetStringTableOption
(
g
,
topt
,
"Entry"
,
NULL
);
...
...
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