1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Fixed compiler warnings from connect engine

- clang complains about register in C++
- Removed not used variables
- Fixed bug when printing date in filamdbf.cpp
- Added {} to fix warning about dangling else
- Changed connect_done_func() to be global to remove conflict with header
  files
- Added extra () around assignment in if
This commit is contained in:
Monty
2019-08-08 22:52:22 +03:00
committed by Sergei Golubchik
parent de8b51fdc9
commit a38f47e90c
23 changed files with 81 additions and 62 deletions

View File

@ -253,7 +253,7 @@ PQRYRES DBFColumns(PGLOBAL g, PCSZ dp, PCSZ fn, bool info)
mainhead.Encryptflag, mainhead.Mdxflag, mainhead.Language); mainhead.Encryptflag, mainhead.Mdxflag, mainhead.Language);
htrc("%hd records, last changed %02d/%02d/%d\n", htrc("%hd records, last changed %02d/%02d/%d\n",
mainhead.Records(), mainhead.Filedate[1], mainhead.Filedate[2], mainhead.Records(), mainhead.Filedate[1], mainhead.Filedate[2],
mainhead.Filedate[0] + (mainhead.Filedate[0] <= 30) ? 2000 : 1900); mainhead.Filedate[0] + ((mainhead.Filedate[0] <= 30) ? 2000 : 1900));
htrc("Field Type Offset Len Dec Set Mdx\n"); htrc("Field Type Offset Len Dec Set Mdx\n");
} // endif trace } // endif trace

View File

@ -647,7 +647,7 @@ int ZBKFAM::WriteBuffer(PGLOBAL g)
int ZBKFAM::DeleteRecords(PGLOBAL g, int irc) int ZBKFAM::DeleteRecords(PGLOBAL g, int irc)
{ {
if (irc == RC_EF) { if (irc == RC_EF) {
LPCSTR name = Tdbp->GetName(); (void) Tdbp->GetName(); // XXX Should be removed ?
PDOSDEF defp = (PDOSDEF)Tdbp->GetDef(); PDOSDEF defp = (PDOSDEF)Tdbp->GetDef();
defp->SetBlock(0); defp->SetBlock(0);
@ -673,7 +673,7 @@ void ZBKFAM::CloseTableFile(PGLOBAL g, bool)
int rc = RC_OK; int rc = RC_OK;
if (Tdbp->GetMode() == MODE_INSERT) { if (Tdbp->GetMode() == MODE_INSERT) {
LPCSTR name = Tdbp->GetName(); (void) Tdbp->GetName(); // XXX Should be removed?
PDOSDEF defp = (PDOSDEF)Tdbp->GetDef(); PDOSDEF defp = (PDOSDEF)Tdbp->GetDef();
if (CurNum && !Closing) { if (CurNum && !Closing) {
@ -1355,7 +1355,7 @@ void ZLBFAM::CloseTableFile(PGLOBAL g, bool)
int rc = RC_OK; int rc = RC_OK;
if (Tdbp->GetMode() == MODE_INSERT) { if (Tdbp->GetMode() == MODE_INSERT) {
LPCSTR name = Tdbp->GetName(); (void) Tdbp->GetName(); // XXX Should be removed?
PDOSDEF defp = (PDOSDEF)Tdbp->GetDef(); PDOSDEF defp = (PDOSDEF)Tdbp->GetDef();
// Closing is True if last Write was in error // Closing is True if last Write was in error

View File

@ -1547,13 +1547,14 @@ int BLKFAM::WriteBuffer(PGLOBAL g)
// T_Stream is the temporary stream or the table file stream itself // T_Stream is the temporary stream or the table file stream itself
if (!T_Stream) if (!T_Stream)
{
if (UseTemp /*&& Tdbp->GetMode() == MODE_UPDATE*/) { if (UseTemp /*&& Tdbp->GetMode() == MODE_UPDATE*/) {
if (OpenTempFile(g)) if (OpenTempFile(g))
return RC_FX; return RC_FX;
} else } else
T_Stream = Stream; T_Stream = Stream;
}
if (UseTemp) { if (UseTemp) {
/*****************************************************************/ /*****************************************************************/
/* We are using a temporary file. Before writing the updated */ /* We are using a temporary file. Before writing the updated */

View File

@ -1223,12 +1223,16 @@ bool FILTER::Eval(PGLOBAL g)
PDBUSER dup = PlgGetUser(g); PDBUSER dup = PlgGetUser(g);
if (Opc <= OP_XX) if (Opc <= OP_XX)
{
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
{
// Evaluate the object and eventually convert it. // Evaluate the object and eventually convert it.
if (Arg(i)->Eval(g)) if (Arg(i)->Eval(g))
return TRUE; return TRUE;
else if (Test[i].Conv) else if (Test[i].Conv)
Val(i)->SetValue_pval(Arg(i)->GetValue()); Val(i)->SetValue_pval(Arg(i)->GetValue());
}
}
if (trace(1)) if (trace(1))
htrc(" Filter: op=%d type=%d %d B_T=%d %d val=%p %p\n", htrc(" Filter: op=%d type=%d %d B_T=%d %d val=%p %p\n",

View File

@ -243,9 +243,6 @@ void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
static int yy_start_stack_ptr = 0; static int yy_start_stack_ptr = 0;
static int yy_start_stack_depth = 0; static int yy_start_stack_depth = 0;
static int *yy_start_stack = 0; static int *yy_start_stack = 0;
static void yy_push_state YY_PROTO(( int new_state ));
static void yy_pop_state YY_PROTO(( void ));
static int yy_top_state YY_PROTO(( void ));
static void *yy_flex_alloc YY_PROTO(( unsigned int )); static void *yy_flex_alloc YY_PROTO(( unsigned int ));
static void *yy_flex_realloc YY_PROTO(( void *, unsigned int )); static void *yy_flex_realloc YY_PROTO(( void *, unsigned int ));
@ -1266,6 +1263,7 @@ FILE *file;
} }
#ifdef NOT_USED
#ifdef YY_USE_PROTOS #ifdef YY_USE_PROTOS
static void yy_push_state( int new_state ) static void yy_push_state( int new_state )
#else #else
@ -1297,7 +1295,6 @@ int new_state;
BEGIN(new_state); BEGIN(new_state);
} }
static void yy_pop_state() static void yy_pop_state()
{ {
if ( --yy_start_stack_ptr < 0 ) if ( --yy_start_stack_ptr < 0 )
@ -1311,6 +1308,7 @@ static int yy_top_state()
{ {
return yy_start_stack[yy_start_stack_ptr - 1]; return yy_start_stack[yy_start_stack_ptr - 1];
} }
#endif /* NOT_USED */
#ifdef YY_USE_PROTOS #ifdef YY_USE_PROTOS

View File

@ -782,7 +782,7 @@ static int connect_init_func(void *p)
@brief @brief
Plugin clean up Plugin clean up
*/ */
static int connect_done_func(void *) int connect_done_func(void *)
{ {
int error= 0; int error= 0;
PCONNECT pc, pn; PCONNECT pc, pn;

View File

@ -112,8 +112,6 @@ static PROFILE *MRUProfile[N_CACHED_PROFILES] = {NULL};
//static CRITICAL_SECTION PROFILE_CritSect = CRITICAL_SECTION_INIT("PROFILE_CritSect"); //static CRITICAL_SECTION PROFILE_CritSect = CRITICAL_SECTION_INIT("PROFILE_CritSect");
static const char hex[17] = "0123456789ABCDEF";
BOOL WritePrivateProfileString(LPCSTR section, LPCSTR entry, BOOL WritePrivateProfileString(LPCSTR section, LPCSTR entry,
LPCSTR string, LPCSTR filename); LPCSTR string, LPCSTR filename);

View File

@ -347,7 +347,7 @@ bool JAVAConn::GetJVM(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
bool JAVAConn::Open(PGLOBAL g) bool JAVAConn::Open(PGLOBAL g)
{ {
bool brc = true, err = false; bool brc = true;
jboolean jt = (trace(1)); jboolean jt = (trace(1));
// Link or check whether jvm library was linked // Link or check whether jvm library was linked

View File

@ -769,7 +769,6 @@ bool JDBConn::Connect(PJPARM sop)
int irc = RC_FX; int irc = RC_FX;
bool err = false; bool err = false;
jint rc; jint rc;
jboolean jt = (trace(1));
PGLOBAL& g = m_G; PGLOBAL& g = m_G;
/*******************************************************************/ /*******************************************************************/
@ -939,7 +938,7 @@ int JDBConn::Rewind(PCSZ sql)
if (gmID(m_G, fetchid, "Fetch", "(I)Z")) if (gmID(m_G, fetchid, "Fetch", "(I)Z"))
return -1; return -1;
jboolean b = env->CallBooleanMethod(job, fetchid, 0); (void) env->CallBooleanMethod(job, fetchid, 0);
rbuf = m_Rows; rbuf = m_Rows;
} else if (ExecuteCommand(sql) != RC_FX) } else if (ExecuteCommand(sql) != RC_FX)
@ -1191,7 +1190,7 @@ int JDBConn::ExecuteUpdate(PCSZ sql)
/***********************************************************************/ /***********************************************************************/
int JDBConn::GetResultSize(PCSZ sql, PCOL colp) int JDBConn::GetResultSize(PCSZ sql, PCOL colp)
{ {
int rc, n = 0; int rc;
if ((rc = ExecuteQuery(sql)) != RC_OK) if ((rc = ExecuteQuery(sql)) != RC_OK)
return -1; return -1;
@ -1493,7 +1492,6 @@ bool JDBConn::SetParam(JDBCCOL *colp)
PCSZ fnc = "Unknown"; PCSZ fnc = "Unknown";
uint n; uint n;
short len, tp; short len, tp;
int crow = 0;
PQRYRES qrp = cap->Qrp; PQRYRES qrp = cap->Qrp;
PCOLRES crp; PCOLRES crp;
jboolean rc = false; jboolean rc = false;

View File

@ -247,7 +247,7 @@ my_bool JSNX::ParseJpath(PGLOBAL g)
{ {
char *p, *p1 = NULL, *p2 = NULL, *pbuf = NULL; char *p, *p1 = NULL, *p2 = NULL, *pbuf = NULL;
int i; int i;
my_bool a, mul = false; my_bool a;
if (Parsed) if (Parsed)
return false; // Already done return false; // Already done
@ -424,7 +424,6 @@ PVAL JSNX::GetColumnValue(PGLOBAL g, PJSON row, int i)
/*********************************************************************************/ /*********************************************************************************/
PJVAL JSNX::GetRowValue(PGLOBAL g, PJSON row, int i, my_bool b) PJVAL JSNX::GetRowValue(PGLOBAL g, PJSON row, int i, my_bool b)
{ {
my_bool expd = false;
PJAR arp; PJAR arp;
PJVAL val = NULL; PJVAL val = NULL;
@ -763,7 +762,7 @@ my_bool JSNX::WriteValue(PGLOBAL g, PJVAL jvalp)
PSZ JSNX::Locate(PGLOBAL g, PJSON jsp, PJVAL jvp, int k) PSZ JSNX::Locate(PGLOBAL g, PJSON jsp, PJVAL jvp, int k)
{ {
PSZ str = NULL; PSZ str = NULL;
my_bool b = false, err = true; my_bool err = true;
g->Message[0] = 0; g->Message[0] = 0;
@ -885,7 +884,7 @@ my_bool JSNX::LocateValue(PJVAL jvp)
PSZ JSNX::LocateAll(PGLOBAL g, PJSON jsp, PJVAL jvp, int mx) PSZ JSNX::LocateAll(PGLOBAL g, PJSON jsp, PJVAL jvp, int mx)
{ {
PSZ str = NULL; PSZ str = NULL;
my_bool b = false, err = true; my_bool err = true;
PJPN jnp; PJPN jnp;
if (!jsp) { if (!jsp) {
@ -1352,7 +1351,7 @@ static PBSON MakeBinResult(PGLOBAL g, UDF_ARGS *args, PJSON top, ulong len, int
bsnp->Pretty = pretty; bsnp->Pretty = pretty;
if (bsnp->Filename = (char*)args->args[0]) { if ((bsnp->Filename = (char*)args->args[0])) {
bsnp->Filename = MakePSZ(g, args, 0); bsnp->Filename = MakePSZ(g, args, 0);
strncpy(bsnp->Msg, bsnp->Filename, BMX); strncpy(bsnp->Msg, bsnp->Filename, BMX);
} else } else
@ -3755,11 +3754,13 @@ my_bool jsonlocate_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
strcpy(message, "Third argument is not an integer (rank)"); strcpy(message, "Third argument is not an integer (rank)");
return true; return true;
} else if (args->arg_count > 3) } else if (args->arg_count > 3)
{
if (args->arg_type[3] != INT_RESULT) { if (args->arg_type[3] != INT_RESULT) {
strcpy(message, "Fourth argument is not an integer (memory)"); strcpy(message, "Fourth argument is not an integer (memory)");
return true; return true;
} else } else
more += (ulong)*(longlong*)args->args[2]; more += (ulong)*(longlong*)args->args[2];
}
CalcLen(args, false, reslen, memlen); CalcLen(args, false, reslen, memlen);
@ -5178,7 +5179,7 @@ char *jbin_object_delete(UDF_INIT *initid, UDF_ARGS *args, char *result,
PCSZ key; PCSZ key;
PJOB jobp; PJOB jobp;
PJVAL jvp = MakeValue(g, args, 0, &top); PJVAL jvp = MakeValue(g, args, 0, &top);
PJSON jsp = jvp->GetJson(); (void) jvp->GetJson(); // XXX Should be removed?
if (CheckPath(g, args, top, jvp, 2)) if (CheckPath(g, args, top, jvp, 2))
PUSH_WARNING(g->Message); PUSH_WARNING(g->Message);
@ -5889,7 +5890,7 @@ long long countin(UDF_INIT *initid, UDF_ARGS *args, char *result,
memcpy(str2, args->args[1], lg); memcpy(str2, args->args[1], lg);
str2[lg] = 0; str2[lg] = 0;
while (s = strstr(s, str2)) { while ((s = strstr(s, str2))) {
n++; n++;
s += lg; s += lg;
} // endwhile } // endwhile

View File

@ -190,7 +190,7 @@ bool CloseMemMap(void *memory, size_t dwSize)
{ {
if (memory) { if (memory) {
// All this must be redesigned // All this must be redesigned
int rc = msync((char*)memory, dwSize, MS_SYNC); msync((char*)memory, dwSize, MS_SYNC);
return (munmap((char*)memory, dwSize) < 0) ? true : false; return (munmap((char*)memory, dwSize) < 0) ? true : false;
} else } else
return false; return false;

View File

@ -140,7 +140,7 @@ PQRYRES MyColumns(PGLOBAL g, THD *thd, const char *host, const char *db,
PCSZ fmt; PCSZ fmt;
char *fld, *colname, *chset, v, buf[128], uns[16], zero[16]; char *fld, *colname, *chset, v, buf[128], uns[16], zero[16];
int i, n, nf = 0, ncol = sizeof(buftyp) / sizeof(int); int i, n, nf = 0, ncol = sizeof(buftyp) / sizeof(int);
int len, type, prec, rc, k = 0; int len, type, prec, rc;
bool b; bool b;
PQRYRES qrp; PQRYRES qrp;
PCOLRES crp; PCOLRES crp;

View File

@ -425,6 +425,8 @@ char *ExtractFromPath(PGLOBAL g, char *pBuff, char *FileName, OPVAL op)
return pBuff; return pBuff;
} // end of PlgExtractFromPath } // end of PlgExtractFromPath
#ifdef NOT_USED
/***********************************************************************/ /***********************************************************************/
/* Check the occurence and matching of a pattern against a string. */ /* Check the occurence and matching of a pattern against a string. */
/* Because this function is only used for catalog name checking, */ /* Because this function is only used for catalog name checking, */
@ -443,6 +445,7 @@ static bool PlugCheckPattern(PGLOBAL g, LPCSTR string, LPCSTR pat)
return true; return true;
} // end of PlugCheckPattern } // end of PlugCheckPattern
#endif /* NOT_USED */
/***********************************************************************/ /***********************************************************************/
/* PlugEvalLike: evaluates a LIKE clause. */ /* PlugEvalLike: evaluates a LIKE clause. */

View File

@ -562,8 +562,6 @@ int TDBDOS::ResetTableOpt(PGLOBAL g, bool dop, bool dox)
MaxSize = -1; // Size must be recalculated MaxSize = -1; // Size must be recalculated
Cardinal = -1; // as well as Cardinality Cardinal = -1; // as well as Cardinality
PTXF xp = Txfp;
To_Filter = NULL; // Disable filtering To_Filter = NULL; // Disable filtering
//To_BlkIdx = NULL; // and index filtering //To_BlkIdx = NULL; // and index filtering
To_BlkFil = NULL; // and block filtering To_BlkFil = NULL; // and block filtering
@ -635,8 +633,9 @@ int TDBDOS::MakeBlockValues(PGLOBAL g)
PDOSDEF defp = (PDOSDEF)To_Def; PDOSDEF defp = (PDOSDEF)To_Def;
PDOSCOL colp = NULL; PDOSCOL colp = NULL;
PDBUSER dup = PlgGetUser(g); PDBUSER dup = PlgGetUser(g);
PCATLG cat = defp->GetCat();
//void *memp = cat->GetDescp(); //void *memp = cat->GetDescp();
(void) defp->GetCat(); // XXX Should be removed?
if ((nrec = defp->GetElemt()) < 2) { if ((nrec = defp->GetElemt()) < 2) {
if (!To_Def->Partitioned()) { if (!To_Def->Partitioned()) {
@ -998,15 +997,17 @@ bool TDBDOS::GetBlockValues(PGLOBAL g)
{ {
char filename[_MAX_PATH]; char filename[_MAX_PATH];
int i, lg, n[NZ]; int i, lg, n[NZ];
int nrec, block = 0, last = 0, allocblk = 0; int nrec, block = 0, last = 0;
int len; int len;
bool newblk = false; bool newblk = false;
size_t ndv, nbm, nbk, blk; size_t ndv, nbm, nbk, blk;
FILE *opfile; FILE *opfile;
PCOLDEF cdp; PCOLDEF cdp;
PDOSDEF defp = (PDOSDEF)To_Def; PDOSDEF defp = (PDOSDEF)To_Def;
PCATLG cat = defp->GetCat(); PDBUSER dup = PlgGetUser(g);
PDBUSER dup = PlgGetUser(g);
(void) defp->GetCat(); // XXX Should be removed?
#if 0 #if 0
if (Mode == MODE_INSERT && Txfp->GetAmType() == TYPE_AM_DOS) if (Mode == MODE_INSERT && Txfp->GetAmType() == TYPE_AM_DOS)
@ -1287,7 +1288,7 @@ PBF TDBDOS::InitBlockFilter(PGLOBAL g, PFIL filp)
} // endif blk } // endif blk
int i, op = filp->GetOpc(), opm = filp->GetOpm(), n = 0; int i, op = filp->GetOpc(), opm = filp->GetOpm();
bool cnv[2]; bool cnv[2];
PCOL colp; PCOL colp;
PXOB arg[2] = {NULL,NULL}; PXOB arg[2] = {NULL,NULL};
@ -1330,13 +1331,14 @@ PBF TDBDOS::InitBlockFilter(PGLOBAL g, PFIL filp)
bfp = new(g) BLKSPCIN(g, this, op, opm, arg, Txfp->Nrec); bfp = new(g) BLKSPCIN(g, this, op, opm, arg, Txfp->Nrec);
} else if (blk && Txfp->Nrec > 1 && colp->IsClustered()) } else if (blk && Txfp->Nrec > 1 && colp->IsClustered())
{
// Clustered column and constant array // Clustered column and constant array
if (colp->GetClustered() == 2) if (colp->GetClustered() == 2)
bfp = new(g) BLKFILIN2(g, this, op, opm, arg); bfp = new(g) BLKFILIN2(g, this, op, opm, arg);
else else
bfp = new(g) BLKFILIN(g, this, op, opm, arg); bfp = new(g) BLKFILIN(g, this, op, opm, arg);
}
} // endif this } // endif this
#if 0 #if 0
} else if (filp->GetArgType(0) == TYPE_SCALF && } else if (filp->GetArgType(0) == TYPE_SCALF &&
@ -1412,12 +1414,12 @@ PBF TDBDOS::CheckBlockFilari(PGLOBAL g, PXOB *arg, int op, bool *cnv)
//bool conv = false, xdb2 = false, ok = false, b[2]; //bool conv = false, xdb2 = false, ok = false, b[2];
//PXOB *xarg1, *xarg2 = NULL, xp[2]; //PXOB *xarg1, *xarg2 = NULL, xp[2];
int i, n = 0, type[2] = {0,0}; int i, n = 0, type[2] = {0,0};
bool conv = false, xdb2 = false, ok = false; bool conv = false, xdb2 = false;
PXOB *xarg2 = NULL, xp[2]; PXOB xp[2];
PCOL colp; PCOL colp;
//LSTVAL *vlp = NULL; //LSTVAL *vlp = NULL;
//SFROW *sfr[2]; //SFROW *sfr[2];
PBF *fp = NULL, bfp = NULL; PBF bfp = NULL;
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
switch (arg[i]->GetType()) { switch (arg[i]->GetType()) {
@ -1648,7 +1650,7 @@ int TDBDOS::TestBlock(PGLOBAL g)
int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add) int TDBDOS::MakeIndex(PGLOBAL g, PIXDEF pxdf, bool add)
{ {
int k, n, rc = RC_OK; int k, n, rc = RC_OK;
bool fixed, doit, sep, b = (pxdf != NULL); bool fixed, doit, sep;
PCOL *keycols, colp; PCOL *keycols, colp;
PIXDEF xdp, sxp = NULL; PIXDEF xdp, sxp = NULL;
PKPDEF kdp; PKPDEF kdp;
@ -2822,6 +2824,7 @@ bool DOSCOL::SetBitMap(PGLOBAL g)
bool DOSCOL::CheckSorted(PGLOBAL g) bool DOSCOL::CheckSorted(PGLOBAL g)
{ {
if (Sorted) if (Sorted)
{
if (OldVal) { if (OldVal) {
// Verify whether this column is sorted all right // Verify whether this column is sorted all right
if (OldVal->CompareValue(Value) > 0) { if (OldVal->CompareValue(Value) > 0) {
@ -2834,7 +2837,7 @@ bool DOSCOL::CheckSorted(PGLOBAL g)
} else } else
OldVal = AllocateValue(g, Value); OldVal = AllocateValue(g, Value);
}
return false; return false;
} // end of CheckSorted } // end of CheckSorted

View File

@ -53,7 +53,6 @@
/***********************************************************************/ /***********************************************************************/
extern int num_read, num_there, num_eq[2]; // Statistics extern int num_read, num_there, num_eq[2]; // Statistics
static const longlong M2G = 0x80000000; static const longlong M2G = 0x80000000;
static const longlong M4G = (longlong)2 * M2G;
char BINCOL::Endian = 'H'; char BINCOL::Endian = 'H';
/***********************************************************************/ /***********************************************************************/

View File

@ -312,12 +312,13 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
} else if (*p == q) { } else if (*p == q) {
if (phase == 0) { if (phase == 0) {
if (blank) if (blank)
{
if (++nerr > mxr) { if (++nerr > mxr) {
sprintf(g->Message, MSG(MISPLACED_QUOTE), num_read); sprintf(g->Message, MSG(MISPLACED_QUOTE), num_read);
goto err; goto err;
} else } else
goto skip; goto skip;
}
n = 0; n = 0;
phase = digit = 1; phase = digit = 1;
} else if (phase == 1) { } else if (phase == 1) {
@ -342,11 +343,13 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
} else { } else {
if (phase == 2) if (phase == 2)
{
if (++nerr > mxr) { if (++nerr > mxr) {
sprintf(g->Message, MSG(MISPLACED_QUOTE), num_read); sprintf(g->Message, MSG(MISPLACED_QUOTE), num_read);
goto err; goto err;
} else } else
goto skip; goto skip;
}
// isdigit cannot be used here because of debug assert // isdigit cannot be used here because of debug assert
if (!strchr("0123456789", *p)) { if (!strchr("0123456789", *p)) {
@ -363,11 +366,13 @@ PQRYRES CSVColumns(PGLOBAL g, PCSZ dp, PTOS topt, bool info)
} // endif's *p } // endif's *p
if (phase == 1) if (phase == 1)
{
if (++nerr > mxr) { if (++nerr > mxr) {
sprintf(g->Message, MSG(UNBALANCE_QUOTE), num_read); sprintf(g->Message, MSG(UNBALANCE_QUOTE), num_read);
goto err; goto err;
} else } else
goto skip; goto skip;
}
if (n) { if (n) {
len[i] = MY_MAX(len[i], n); len[i] = MY_MAX(len[i], n);
@ -741,6 +746,7 @@ bool TDBCSV::OpenDB(PGLOBAL g)
PCSVCOL colp; PCSVCOL colp;
if (!Fields) // May have been set in TABFMT::OpenDB if (!Fields) // May have been set in TABFMT::OpenDB
{
if (Mode != MODE_UPDATE && Mode != MODE_INSERT) { if (Mode != MODE_UPDATE && Mode != MODE_INSERT) {
for (colp = (PCSVCOL)Columns; colp; colp = (PCSVCOL)colp->Next) for (colp = (PCSVCOL)Columns; colp; colp = (PCSVCOL)colp->Next)
if (!colp->IsSpecial() && !colp->IsVirtual()) if (!colp->IsSpecial() && !colp->IsVirtual())
@ -753,6 +759,7 @@ bool TDBCSV::OpenDB(PGLOBAL g)
for (cdp = tdp->GetCols(); cdp; cdp = cdp->GetNext()) for (cdp = tdp->GetCols(); cdp; cdp = cdp->GetNext())
if (!cdp->IsSpecial() && !cdp->IsVirtual()) if (!cdp->IsSpecial() && !cdp->IsVirtual())
Fields++; Fields++;
}
Offset = (int*)PlugSubAlloc(g, NULL, sizeof(int) * Fields); Offset = (int*)PlugSubAlloc(g, NULL, sizeof(int) * Fields);
Fldlen = (int*)PlugSubAlloc(g, NULL, sizeof(int) * Fields); Fldlen = (int*)PlugSubAlloc(g, NULL, sizeof(int) * Fields);
@ -774,6 +781,7 @@ bool TDBCSV::OpenDB(PGLOBAL g)
} // endfor i } // endfor i
if (Field) if (Field)
{
// Prepare writing fields // Prepare writing fields
if (Mode != MODE_UPDATE) { if (Mode != MODE_UPDATE) {
for (colp = (PCSVCOL)Columns; colp; colp = (PCSVCOL)colp->Next) for (colp = (PCSVCOL)Columns; colp; colp = (PCSVCOL)colp->Next)
@ -796,8 +804,8 @@ bool TDBCSV::OpenDB(PGLOBAL g)
Fldlen[i] = len; Fldlen[i] = len;
Fldtyp[i] = IsTypeNum(cdp->GetType()); Fldtyp[i] = IsTypeNum(cdp->GetType());
} // endif cdp } // endif cdp
}
} // endif Use } // endif Use
if (Header) { if (Header) {
// Check that the Lrecl is at least equal to the header line length // Check that the Lrecl is at least equal to the header line length
@ -1046,6 +1054,7 @@ bool TDBCSV::PrepareWriting(PGLOBAL g)
strcat(To_Line, sep); strcat(To_Line, sep);
if (Field[i]) if (Field[i])
{
if (!strlen(Field[i])) { if (!strlen(Field[i])) {
// Generally null fields are not quoted // Generally null fields are not quoted
if (Quoted > 2) if (Quoted > 2)
@ -1074,8 +1083,8 @@ bool TDBCSV::PrepareWriting(PGLOBAL g)
else else
strcat(To_Line, Field[i]); strcat(To_Line, Field[i]);
}
} // endfor i } // endfor i
#if defined(_DEBUG) #if defined(_DEBUG)
assert ((unsigned)nlen == strlen(To_Line)); assert ((unsigned)nlen == strlen(To_Line));
@ -1129,11 +1138,13 @@ int TDBCSV::CheckWrite(PGLOBAL g)
// Check whether record is too int // Check whether record is too int
for (int i = 0; i < Fields; i++) for (int i = 0; i < Fields; i++)
{
if (Field[i]) { if (Field[i]) {
if (!(n = strlen(Field[i]))) if (!(n = strlen(Field[i])))
n += (Quoted > 2 ? 2 : 0); n += (Quoted > 2 ? 2 : 0);
else if (strchr(Field[i], Sep) || (Qot && *Field[i] == Qot) else if (strchr(Field[i], Sep) || (Qot && *Field[i] == Qot)
|| Quoted > 1 || (Quoted == 1 && !Fldtyp[i])) || Quoted > 1 || (Quoted == 1 && !Fldtyp[i]))
{
if (!Qot) { if (!Qot) {
sprintf(g->Message, MSG(SEP_IN_FIELD), i + 1); sprintf(g->Message, MSG(SEP_IN_FIELD), i + 1);
return -1; return -1;
@ -1146,14 +1157,14 @@ int TDBCSV::CheckWrite(PGLOBAL g)
n += 2; // Outside quotes n += 2; // Outside quotes
} // endif } // endif
}
if ((nlen += n) > maxlen) { if ((nlen += n) > maxlen) {
strcpy(g->Message, MSG(LINE_TOO_LONG)); strcpy(g->Message, MSG(LINE_TOO_LONG));
return -1; return -1;
} // endif nlen } // endif nlen
} // endif Field } // endif Field
}
return nlen; return nlen;
} // end of CheckWrite } // end of CheckWrite

View File

@ -378,7 +378,7 @@ bool TDBJDBC::MakeInsert(PGLOBAL g)
int len = 0; int len = 0;
uint pos; uint pos;
bool b = false; bool b = false;
PTABLE tablep = To_Table; // PTABLE tablep = To_Table;
PCOL colp; PCOL colp;
for (colp = Columns; colp; colp = colp->GetNext()) for (colp = Columns; colp; colp = colp->GetNext())
@ -582,11 +582,13 @@ bool TDBJDBC::OpenDB(PGLOBAL g)
if (Memory < 3) { if (Memory < 3) {
// Method will depend on cursor type // Method will depend on cursor type
if ((Rbuf = Query ? Jcp->Rewind(Query->GetStr()) : 0) < 0) if ((Rbuf = Query ? Jcp->Rewind(Query->GetStr()) : 0) < 0)
{
if (Mode != MODE_READX) { if (Mode != MODE_READX) {
Jcp->Close(); Jcp->Close();
return true; return true;
} else } else
Rbuf = 0; Rbuf = 0;
}
} else } else
Rbuf = Qrp->Nblin; Rbuf = Qrp->Nblin;
@ -1017,7 +1019,7 @@ JDBCCOL::JDBCCOL(JDBCCOL *col1, PTDB tdbp) : EXTCOL(col1, tdbp)
void JDBCCOL::ReadColumn(PGLOBAL g) void JDBCCOL::ReadColumn(PGLOBAL g)
{ {
PTDBJDBC tdbp = (PTDBJDBC)To_Tdb; PTDBJDBC tdbp = (PTDBJDBC)To_Tdb;
int i = tdbp->Fpos - 1, n = tdbp->CurNum; int i = tdbp->Fpos - 1;
if (tdbp->Memory == 3) { if (tdbp->Memory == 3) {
// Get the value from the stored memory // Get the value from the stored memory
@ -1137,8 +1139,6 @@ int TDBXJDC::GetMaxSize(PGLOBAL g)
/***********************************************************************/ /***********************************************************************/
bool TDBXJDC::OpenDB(PGLOBAL g) bool TDBXJDC::OpenDB(PGLOBAL g)
{ {
bool rc = false;
if (trace(1)) if (trace(1))
htrc("JDBC OpenDB: tdbp=%p tdb=R%d use=%d mode=%d\n", htrc("JDBC OpenDB: tdbp=%p tdb=R%d use=%d mode=%d\n",
this, Tdb_No, Use, Mode); this, Tdb_No, Use, Mode);

View File

@ -255,11 +255,13 @@ int JSONDISC::GetColumns(PGLOBAL g, PCSZ db, PCSZ dsn, PTOS topt)
jsp = (tjsp->GetDoc()) ? tjsp->GetDoc()->GetValue(0) : NULL; jsp = (tjsp->GetDoc()) ? tjsp->GetDoc()->GetValue(0) : NULL;
} else { } else {
if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0))) if (!(tdp->Lrecl = GetIntegerTableOption(g, topt, "Lrecl", 0)))
{
if (!mgo) { if (!mgo) {
sprintf(g->Message, "LRECL must be specified for pretty=%d", tdp->Pretty); sprintf(g->Message, "LRECL must be specified for pretty=%d", tdp->Pretty);
return 0; return 0;
} else } else
tdp->Lrecl = 8192; // Should be enough tdp->Lrecl = 8192; // Should be enough
}
tdp->Ending = GetIntegerTableOption(g, topt, "Ending", CRLF); tdp->Ending = GetIntegerTableOption(g, topt, "Ending", CRLF);
@ -1315,7 +1317,7 @@ bool JSONCOL::ParseJpath(PGLOBAL g)
{ {
char *p, *p1 = NULL, *p2 = NULL, *pbuf = NULL; char *p, *p1 = NULL, *p2 = NULL, *pbuf = NULL;
int i; int i;
bool a, mul = false; bool a;
if (Parsed) if (Parsed)
return false; // Already done return false; // Already done
@ -1545,7 +1547,6 @@ void JSONCOL::ReadColumn(PGLOBAL g)
PVAL JSONCOL::GetColumnValue(PGLOBAL g, PJSON row, int i) PVAL JSONCOL::GetColumnValue(PGLOBAL g, PJSON row, int i)
{ {
int n = Nod - 1; int n = Nod - 1;
bool expd = false;
PJAR arp; PJAR arp;
PJVAL val = NULL; PJVAL val = NULL;
@ -2106,12 +2107,14 @@ int TDBJSON::Cardinality(PGLOBAL g)
if (!g) if (!g)
return (Xcol || Multiple) ? 0 : 1; return (Xcol || Multiple) ? 0 : 1;
else if (Cardinal < 0) else if (Cardinal < 0)
{
if (!Multiple) { if (!Multiple) {
if (MakeDocument(g) == RC_OK) if (MakeDocument(g) == RC_OK)
Cardinal = Doc->size(); Cardinal = Doc->size();
} else } else
return 10; return 10;
}
return Cardinal; return Cardinal;
} // end of Cardinality } // end of Cardinality

View File

@ -671,8 +671,8 @@ TDBDIR::TDBDIR(PSZ fpat) : TDBASE((PTABDEF)NULL)
/***********************************************************************/ /***********************************************************************/
char* TDBDIR::Path(PGLOBAL g) char* TDBDIR::Path(PGLOBAL g)
{ {
PCATLG cat = PlgGetCatalog(g); (void) PlgGetCatalog(g); // XXX Should be removed?
PTABDEF defp = (PTABDEF)To_Def; PTABDEF defp = (PTABDEF)To_Def;
#if defined(__WIN__) #if defined(__WIN__)
if (!*Drive) { if (!*Drive) {
@ -708,9 +708,9 @@ PCOL TDBDIR::MakeCol(PGLOBAL g, PCOLDEF cdp, PCOL cprec, int n)
int TDBDIR::GetMaxSize(PGLOBAL g) int TDBDIR::GetMaxSize(PGLOBAL g)
{ {
if (MaxSize < 0) { if (MaxSize < 0) {
int rc, n = -1; int n = -1;
#if defined(__WIN__) #if defined(__WIN__)
int rc;
// Start searching files in the target directory. // Start searching files in the target directory.
hSearch = FindFirstFile(Path(g), &FileData); hSearch = FindFirstFile(Path(g), &FileData);

View File

@ -246,7 +246,7 @@ bool MYSQLDEF::ParseURL(PGLOBAL g, char *url, bool b)
// Found that if the string is: // Found that if the string is:
// user:@hostname:port/db/table // user:@hostname:port/db/table
// Then password is a null string, so set to NULL // Then password is a null string, so set to NULL
if ((pwd[0] == 0)) if (pwd[0] == 0)
Password = NULL; Password = NULL;
else else
Password = pwd; Password = pwd;

View File

@ -112,7 +112,7 @@ bool user_connect::user_init()
if (g) if (g)
printf("%s\n", g->Message); printf("%s\n", g->Message);
int rc= PlugExit(g); (void) PlugExit(g);
g= NULL; g= NULL;
if (dup) if (dup)

View File

@ -35,7 +35,7 @@
//typedef struct _global *PGLOBAL; //typedef struct _global *PGLOBAL;
typedef class user_connect *PCONNECT; typedef class user_connect *PCONNECT;
typedef class ha_connect *PHC; typedef class ha_connect *PHC;
static int connect_done_func(void *); int connect_done_func(void *);
/*****************************************************************************/ /*****************************************************************************/
/* The CONNECT users. There should be one by connected users. */ /* The CONNECT users. There should be one by connected users. */

View File

@ -1129,7 +1129,7 @@ void STRBLK::SetValues(PVBLK pv, int k, int n)
CheckType(pv) CheckType(pv)
PSZ *sp = ((STRBLK*)pv)->Strp; PSZ *sp = ((STRBLK*)pv)->Strp;
for (register int i = k; i < n; i++) for (int i = k; i < n; i++)
Strp[i] = (!pv->IsNull(i)) ? sp[i] : NULL; Strp[i] = (!pv->IsNull(i)) ? sp[i] : NULL;
} // end of SetValues } // end of SetValues