Merge remote-tracking branch 'connect/10.2' into 10.2

This commit is contained in:
Oleksandr Byelkin 2019-10-30 21:56:35 +01:00
commit 6680b04961
7 changed files with 319 additions and 334 deletions

View File

@ -73,10 +73,6 @@ ELSE(NOT UNIX)
tabwmi.cpp tabwmi.h tabmac.cpp tabmac.h macutil.cpp macutil.h) tabwmi.cpp tabwmi.h tabmac.cpp tabmac.h macutil.cpp macutil.h)
# Add exception handling to the CONNECT project) # Add exception handling to the CONNECT project)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHsc") 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) SET(IPHLPAPI_LIBRARY iphlpapi.lib)
IF(MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES Clang)) IF(MSVC AND (CMAKE_CXX_COMPILER_ID MATCHES Clang))
# Connect does not work with clang-cl # Connect does not work with clang-cl
@ -328,7 +324,12 @@ IF(CONNECT_WITH_REST)
# INCLUDE_DIRECTORIES(${CPPRESTSDK_INCLUDE_DIR}) # INCLUDE_DIRECTORIES(${CPPRESTSDK_INCLUDE_DIR})
# If needed edit next line to set the path to libcpprest.so # If needed edit next line to set the path to libcpprest.so
SET(REST_LIBRARY -lcpprest) SET(REST_LIBRARY -lcpprest)
# MESSAGE (STATUS ${REST_LIBRARY}) 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) ENDIF(UNIX)
IF(REST_LIBRARY) IF(REST_LIBRARY)
SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp restget.cpp tabrest.h) SET(CONNECT_SOURCES ${CONNECT_SOURCES} tabrest.cpp restget.cpp tabrest.h)

View File

@ -16,7 +16,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335 USA */ 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: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
@ -389,6 +389,9 @@ RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool reset, bool mrr)
try { try {
for (colp = tdbp->GetColumns(); rc == RC_OK && colp; for (colp = tdbp->GetColumns(); rc == RC_OK && colp;
colp = colp->GetNext()) { colp = colp->GetNext()) {
xtrc(2, "Going to read column %s of table %s\n",
colp->GetName(), tdbp->GetName());
if (reset) if (reset)
colp->Reset(); colp->Reset();

View File

@ -1196,9 +1196,14 @@ int JDBConn::GetResultSize(PCSZ sql, PCOL colp)
if ((rc = ExecuteQuery(sql)) != RC_OK) if ((rc = ExecuteQuery(sql)) != RC_OK)
return -1; return -1;
if ((rc = Fetch()) > 0) if ((rc = Fetch()) > 0) {
try {
SetColumnValue(1, NULL, colp->GetValue()); SetColumnValue(1, NULL, colp->GetValue());
else } catch (...) {
return -4;
} // end catch
} else
return -2; return -2;
if ((rc = Fetch()) != 0) if ((rc = Fetch()) != 0)

View File

@ -1,33 +0,0 @@
/***********************************************************************/
/* Definitions needed by the included files. */
/***********************************************************************/
#if !defined(MY_GLOBAL_H)
#define MY_GLOBAL_H
typedef unsigned int uint;
typedef unsigned int uint32;
typedef unsigned short ushort;
typedef unsigned long ulong;
typedef unsigned long DWORD;
typedef char *LPSTR;
typedef const char *LPCSTR;
typedef int BOOL;
#if defined(_WINDOWS)
typedef void *HANDLE;
#else
typedef int HANDLE;
#endif
typedef char *PSZ;
typedef const char *PCSZ;
typedef unsigned char BYTE;
typedef unsigned char uchar;
typedef long long longlong;
typedef unsigned long long ulonglong;
typedef char my_bool;
struct charset_info_st {};
typedef const charset_info_st CHARSET_INFO;
#define FALSE 0
#define TRUE 1
#define Item char
#define MY_MAX(a,b) ((a>b)?(a):(b))
#define MY_MIN(a,b) ((a<b)?(a):(b))
#endif // MY_GLOBAL_H

View File

@ -605,7 +605,9 @@ bool TDBODBC::OpenDB(PGLOBAL g)
Cnp->InitValue(g); Cnp->InitValue(g);
if ((n = Ocp->GetResultSize(Query->GetStr(), Cnp)) < 0) { if ((n = Ocp->GetResultSize(Query->GetStr(), Cnp)) < 0) {
strcpy(g->Message, "Cannot get result size"); char* msg = PlugDup(g, g->Message);
sprintf(g->Message, "Get result size: %s (rc=%d)", msg, n);
return true; return true;
} else if (n) { } else if (n) {
Ocp->m_Rows = n; Ocp->m_Rows = n;

View File

@ -206,6 +206,7 @@ void VALBLK::ChkIndx(int n)
{ {
if (n < 0 || n >= Nval) { if (n < 0 || n >= Nval) {
PGLOBAL& g = Global; PGLOBAL& g = Global;
xtrc(1, "ChkIndx: n=%d Nval=%d\n", n, Nval);
strcpy(g->Message, MSG(BAD_VALBLK_INDX)); strcpy(g->Message, MSG(BAD_VALBLK_INDX));
throw Type; throw Type;
} // endif n } // endif n
@ -216,6 +217,7 @@ void VALBLK::ChkTyp(PVAL v)
{ {
if (Check && (Type != v->GetType() || Unsigned != v->IsUnsigned())) { if (Check && (Type != v->GetType() || Unsigned != v->IsUnsigned())) {
PGLOBAL& g = Global; PGLOBAL& g = Global;
xtrc(1, "ChkTyp: Type=%d valType=%d\n", Type, v->GetType());
strcpy(g->Message, MSG(VALTYPE_NOMATCH)); strcpy(g->Message, MSG(VALTYPE_NOMATCH));
throw Type; throw Type;
} // endif Type } // endif Type

View File

@ -537,7 +537,7 @@ const char *VALUE::GetXfmt(void)
} // endswitch Type } // endswitch Type
return fmt; return fmt;
} // end of GetFmt } // end of GetXFmt
/***********************************************************************/ /***********************************************************************/
/* Returns a BYTE indicating the comparison between two values. */ /* Returns a BYTE indicating the comparison between two values. */
@ -644,7 +644,7 @@ int TYPVAL<TYPE>::GetValLen(void)
{ {
char c[32]; char c[32];
return sprintf(c, Fmt, Tval); return snprintf(c, 32, Fmt, Tval);
} // end of GetValLen } // end of GetValLen
template <> template <>
@ -652,7 +652,7 @@ int TYPVAL<double>::GetValLen(void)
{ {
char c[32]; char c[32];
return sprintf(c, Fmt, Prec, Tval); return snprintf(c, 32, Fmt, Prec, Tval);
} // end of GetValLen } // end of GetValLen
/***********************************************************************/ /***********************************************************************/
@ -907,7 +907,8 @@ char *TYPVAL<TYPE>::GetCharString(char *p)
template <> template <>
char *TYPVAL<double>::GetCharString(char *p) char *TYPVAL<double>::GetCharString(char *p)
{ {
sprintf(p, Fmt, Prec, Tval); // Most callers use a 32 long buffer
snprintf(p, 32, Fmt, Prec, Tval);
return p; return p;
} // end of GetCharString } // end of GetCharString
@ -1204,7 +1205,9 @@ bool TYPVAL<TYPE>::Compall(PGLOBAL g, PVAL *vp, int np, OPVAL op)
template <class TYPE> template <class TYPE>
bool TYPVAL<TYPE>::FormatValue(PVAL vp, PCSZ fmt) bool TYPVAL<TYPE>::FormatValue(PVAL vp, PCSZ fmt)
{ {
char *buf = (char*)vp->GetTo_Val(); // Should be big enough // This function is wrong and should never be called
assert(false);
char *buf = (char*)vp->GetTo_Val(); // Not big enough
int n = sprintf(buf, fmt, Tval); int n = sprintf(buf, fmt, Tval);
return (n > vp->GetValLen()); return (n > vp->GetValLen());
@ -1389,7 +1392,7 @@ bool TYPVAL<PSZ>::SetValue_char(const char *cp, int n)
Reset(); Reset();
Null = false; Null = false;
} // endif p } // endif cp
return rc; return rc;
} // end of SetValue_char } // end of SetValue_char
@ -1591,7 +1594,7 @@ int TYPVAL<PSZ>::ShowValue(char *buf, int buflen)
int len = (Null) ? 0 : strlen(Strp); int len = (Null) ? 0 : strlen(Strp);
if (buf && buf != Strp) { if (buf && buf != Strp) {
memset(buf, ' ', buflen + 1); memset(buf, ' ', (size_t)buflen + 1);
memcpy(buf, Strp, MY_MIN(len, buflen)); memcpy(buf, Strp, MY_MIN(len, buflen));
} // endif buf } // endif buf
@ -2192,6 +2195,7 @@ void BINVAL::SetValue(ulonglong n)
Len = 8; Len = 8;
} else } else
SetValue((uint)n); SetValue((uint)n);
} // end of SetValue } // end of SetValue
/***********************************************************************/ /***********************************************************************/
@ -2506,7 +2510,8 @@ bool DTVAL::MakeTime(struct tm *ptm)
if ((t -= (n * FOURYEARS)) > 2000000000) if ((t -= (n * FOURYEARS)) > 2000000000)
return true; return true;
} } // endif t
Tval= (int) t; Tval= (int) t;
if (trace(2)) if (trace(2))