Skip to content

Commit

Permalink
Update to version 1.07 (as for MariaDB 10.2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Buggynours committed Jan 9, 2020
1 parent 0043593 commit 0b624de
Show file tree
Hide file tree
Showing 33 changed files with 913 additions and 721 deletions.
53 changes: 32 additions & 21 deletions storage/connect/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,26 @@ user_connect.h valblk.h value.h xindex.h xobject.h xtable.h)
add_definitions( -DMARIADB -DFORCE_INIT_OF_VARS -Dconnect_EXPORTS)
add_definitions( -DHUGE_SUPPORT -DGZ_SUPPORT )

macro(DISABLE_WARNING W)
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-error=${W}")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-${W}" DEBUG)
endmacro()

#
# OS specific C flags, definitions and source files.
#
IF(UNIX)
MY_CHECK_AND_SET_COMPILER_FLAG("-Wall -Wmissing-declarations")
if(NOT WITH_WARNINGS)
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-unused-function")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-unused-variable")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-unused-value")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-parentheses")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-strict-aliasing")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-misleading-indentation")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-format-truncation")
MY_CHECK_AND_SET_COMPILER_FLAG("-Wno-implicit-fallthrough")
DISABLE_WARNING("unused-function")
DISABLE_WARNING("unused-variable")
DISABLE_WARNING("unused-value")
DISABLE_WARNING("parentheses")
DISABLE_WARNING("strict-aliasing")
DISABLE_WARNING("misleading-indentation")
DISABLE_WARNING("format-truncation")
DISABLE_WARNING("implicit-fallthrough")
DISABLE_WARNING("type-limits")
endif(NOT WITH_WARNINGS)

add_definitions( -DUNIX -DLINUX -DUBUNTU )
Expand All @@ -68,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
Expand Down Expand Up @@ -171,7 +172,8 @@ IF(CONNECT_WITH_ODBC)
# the library 'libiodbc' gets compiled with 'sql'h.
# This will also need changes in the sources (e.g. #include <isql.h>).

find_path(ODBC_INCLUDE_DIR sql.h
find_file(ODBC_INCLUDES sql.h
PATHS
/usr/include
/usr/include/odbc
/usr/local/include
Expand All @@ -181,7 +183,7 @@ IF(CONNECT_WITH_ODBC)
#"C:/Program Files/Microsoft SDKs/Windows/v7.0A/include"
#"C:/Program Files/Microsoft SDKs/Windows/v6.0a/include"
#"C:/Program Files (x86)/Microsoft SDKs/Windows/v7.0A/include"
DOC "Specify the directory containing sql.h."
DOC "Specify the path to sql.h."
)

find_library(ODBC_LIBRARY
Expand All @@ -200,9 +202,10 @@ IF(CONNECT_WITH_ODBC)
DOC "Specify the ODBC driver manager library here."
)

mark_as_advanced(ODBC_LIBRARY ODBC_INCLUDE_DIR)
mark_as_advanced(ODBC_LIBRARY ODBC_INCLUDES)

IF(ODBC_INCLUDE_DIR AND ODBC_LIBRARY)
IF(ODBC_INCLUDES AND ODBC_LIBRARY)
get_filename_component(ODBC_INCLUDE_DIR "${ODBC_INCLUDES}" PATH)
set(CMAKE_REQUIRED_LIBRARIES ${ODBC_LIBRARY})
set(CMAKE_REQUIRED_INCLUDES ${ODBC_INCLUDE_DIR})
CHECK_CXX_SOURCE_COMPILES(
Expand Down Expand Up @@ -316,19 +319,27 @@ OPTION(CONNECT_WITH_REST "Compile CONNECT storage engine with REST support" ON)

IF(CONNECT_WITH_REST)
MESSAGE(STATUS "=====> REST support is ON")
FIND_PACKAGE(cpprestsdk)
SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp tabrest.h)
add_definitions(-DREST_SUPPORT)
FIND_PACKAGE(cpprestsdk QUIET)
IF (cpprestsdk_FOUND)
MESSAGE(STATUS "=====> cpprestsdk found")
IF(UNIX)
# INCLUDE_DIRECTORIES(${CPPRESTSDK_INCLUDE_DIR})
# 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")
# MESSAGE(STATUS "=====> cpprestsdk package not found")
ENDIF (cpprestsdk_FOUND)
ENDIF(CONNECT_WITH_REST)

Expand Down
4 changes: 2 additions & 2 deletions storage/connect/array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ char *ARRAY::GetStringValue(int n)
/***********************************************************************/
bool ARRAY::Find(PVAL valp)
{
register int n;
int n;
PVAL vp;

if (Type != valp->GetType()) {
Expand Down Expand Up @@ -1042,7 +1042,7 @@ MULAR::MULAR(PGLOBAL g, int n) : CSORT(false)
/***********************************************************************/
int MULAR::Qcompare(int *i1, int *i2)
{
register int i, n = 0;
int i, n = 0;

for (i = 0; i < Narray; i++)
if ((n = Pars[i]->Qcompare(i1, i2)))
Expand Down
69 changes: 36 additions & 33 deletions storage/connect/connect.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */

/***********************************************************************/
/* Author Olivier BERTRAND bertrandop@gmail.com 2004-2017 */
/* Author Olivier BERTRAND bertrandop@gmail.com 2004-2019 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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 = ((PTDBDOX)tdbp)->Txfp->UpdateSortedRows(g);
rc = ((PTDBDOS)tdbp)->GetTxfp()->UpdateSortedRows(g);

switch (rc) {
case RC_FX:
Expand All @@ -590,7 +593,7 @@ int CntCloseTable(PGLOBAL g, PTDB tdbp, bool nox, bool abort)

if (!tdbp->IsRemote()) {
// Make all the eventual indexes
PTDBDOX tbxp = (PTDBDOX)tdbp;
PTDBDOS tbxp = (PTDBDOS)tdbp;
tbxp->ResetKindex(g, NULL);
tbxp->SetKey_Col(NULL);
rc = tbxp->ResetTableOpt(g, true, tbxp->GetDef()->Indexable() == 1);
Expand Down Expand Up @@ -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;
PTDBDOX tdbp;
DOXDEF *dfp;
PTDBDOS tdbp;
DOSDEF *dfp;

if (!ptdb)
return -1;
Expand All @@ -630,9 +633,9 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id, bool sorted)
} else if (ptdb->GetDef()->Indexable() == 3) {
return 1;
} else
tdbp= (PTDBDOX)ptdb;
tdbp= (PTDBDOS)ptdb;

dfp= (DOXDEF*)tdbp->To_Def;
dfp= (DOSDEF*)tdbp->GetDef();

//if (!(k= colp->GetKey()))
// if (colp->GetOpt() >= 2) {
Expand All @@ -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;

Expand All @@ -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)
Expand Down Expand Up @@ -707,7 +710,7 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
int n, x;
RCODE rc;
XXBASE *xbp;
PTDBDOX tdbp;
PTDBDOS tdbp;

if (!ptdb)
return RC_FX;
Expand All @@ -733,12 +736,12 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,

goto rnd;
} else
tdbp= (PTDBDOX)ptdb;
tdbp= (PTDBDOS)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
Expand All @@ -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;
Expand All @@ -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)) {
Expand Down Expand Up @@ -837,7 +840,7 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,
bool b, rcb;
PVAL valp;
PCOL colp;
PTDBDOX tdbp;
PTDBDOS tdbp;
XXBASE *xbp;

if (!ptdb)
Expand All @@ -862,35 +865,35 @@ int CntIndexRange(PGLOBAL g, PTDB ptdb, const uchar* *key, uint *len,

return k[1] - k[0] + 1;
} else
tdbp= (PTDBDOX)ptdb;
tdbp= (PTDBDOS)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)) {
Expand Down
2 changes: 2 additions & 0 deletions storage/connect/connect.h
Original file line number Diff line number Diff line change
Expand Up @@ -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! */
Expand Down Expand Up @@ -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
22 changes: 11 additions & 11 deletions storage/connect/csort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,9 @@ void CSORT::DebugSort(int ph, int n, int *base, int *mid, int *tmp)
/***********************************************************************/
int CSORT::Qsortx(void)
{
register int c;
register int lo, hi, min;
register int i, j, rc = 0;
int c;
int lo, hi, min;
int i, j, rc = 0;
// To do: rc should be checked for being used uninitialized
int *top;
#ifdef DEBTRACE
Expand Down Expand Up @@ -344,7 +344,7 @@ int CSORT::Qsortx(void)
/***********************************************************************/
void CSORT::Qstx(int *base, int *max)
{
register int *i, *j, *jj, *mid, *him, c;
int *i, *j, *jj, *mid, *him, c;
int *tmp;
int lo, hi, rc;
size_t zlo, zhi, cnm;
Expand Down Expand Up @@ -543,9 +543,9 @@ void CSORT::Qstx(int *base, int *max)
/***********************************************************************/
int CSORT::Qsortc(void)
{
register int c;
register int lo, hi, min;
register int i, j, k, m, rc = 0;
int c;
int lo, hi, min;
int i, j, k, m, rc = 0;
// To do: rc should be checked for being used uninitialized
int *max;
#ifdef DEBTRACE
Expand Down Expand Up @@ -720,7 +720,7 @@ int CSORT::Qsortc(void)
/***********************************************************************/
void CSORT::Qstc(int *base, int *max)
{
register int *i, *j, *jj, *lt, *eq, *gt, *mid;
int *i, *j, *jj, *lt, *eq, *gt, *mid;
int c = 0, lo, hi, rc;
size_t zlo, zhi, cnm;

Expand Down Expand Up @@ -907,9 +907,9 @@ void CSORT::Qstc(int *base, int *max)
/***********************************************************************/
void CSORT::Istc(int *base, int *hi, int *max)
{
register int c = 0;
register int *lo;
register int *i, *j;
int c = 0;
int *lo;
int *i, *j;

/*********************************************************************/
/* First put smallest element, which must be in the first THRESH, */
Expand Down
Loading

0 comments on commit 0b624de

Please sign in to comment.