Commit 9644415f authored by Olivier Bertrand's avatar Olivier Bertrand

- Fix MDEV-16672 Connect: Warnings with 10.0

  filamtxt.cpp: DOSFAM::RenameTempFile: Change sprintf to snprintf.
  filamvct.cpp: VECFAM::RenameTempFile: Change sprintf to snprintf.
  javaconn.cpp:
    Add JAVAConn::GetUTFString function.
    Use it instead of env->GetStringUTFChars.
    Fix wrong identation.
  javaconn.h: Add GetUTFString declaration.
  jdbconn.cpp:
    Use GetUTFString function instead of env->GetStringUTFChars.
  jmgoconn.cpp:
    Use GetUTFString function instead of env->GetStringUTFChars.
    Fix wrong identation.
  jsonudf.cpp: change 139 to BMX line 4631.
  tabjmg.cpp:
    Add ReleaseStringUTF.
    Fix wrong identation.
  tabpivot.cpp: Fix wrong identation.
  tabutil.cpp: TDBPRX::GetSubTable: Change sprintf to snprintf.
  modified:   storage/connect/filamtxt.cpp
  modified:   storage/connect/filamvct.cpp
  modified:   storage/connect/javaconn.cpp
  modified:   storage/connect/javaconn.h
  modified:   storage/connect/jdbconn.cpp
  modified:   storage/connect/jmgoconn.cpp
  modified:   storage/connect/jsonudf.cpp
  modified:   storage/connect/tabjmg.cpp
  modified:   storage/connect/tabpivot.cpp
  modified:   storage/connect/tabutil.cpp

- Fix MDEV-16895 CONNECT engine's get_error_message can cause buffer
                 overflow and server crash with long queries
  ha_connect_cc: Update version.
    get_error_message: Remove charset conversion.
  modified:   storage/connect/ha_connect.cc

- Fix a server crash on inserting bigint to a JDBC table
  JDBConn::SetUUID:
    Suppress check on ctyp that causes a server crash because ctyp
    can be negative and this triggers an DEBUG_ASSERT on return.
  modified:   storage/connect/jdbconn.cpp

- Update jdbc.result
  mysql-test/connect/r/jdbc.result: Recorded to reflect a message change.
  modified:   storage/connect/mysql-test/connect/r/jdbc.result
parent c69efab3
...@@ -1173,11 +1173,11 @@ int DOSFAM::RenameTempFile(PGLOBAL g) ...@@ -1173,11 +1173,11 @@ int DOSFAM::RenameTempFile(PGLOBAL g)
remove(filetemp); // May still be there from previous error remove(filetemp); // May still be there from previous error
if (rename(filename, filetemp)) { // Save file for security if (rename(filename, filetemp)) { // Save file for security
sprintf(g->Message, MSG(RENAME_ERROR), snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
filename, filetemp, strerror(errno)); filename, filetemp, strerror(errno));
throw 51; throw 51;
} else if (rename(tempname, filename)) { } else if (rename(tempname, filename)) {
sprintf(g->Message, MSG(RENAME_ERROR), snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
tempname, filename, strerror(errno)); tempname, filename, strerror(errno));
rc = rename(filetemp, filename); // Restore saved file rc = rename(filetemp, filename); // Restore saved file
throw 52; throw 52;
......
...@@ -353,7 +353,7 @@ int VCTFAM::Cardinality(PGLOBAL g) ...@@ -353,7 +353,7 @@ int VCTFAM::Cardinality(PGLOBAL g)
} // endif split } // endif split
return (Block) ? ((Block - 1) * Nrec + Last) : 0; return (Block) ? ((Block - 1) * Nrec + Last) : 0;
} // end of Cardinality } // end of Cardinality
/***********************************************************************/ /***********************************************************************/
...@@ -2458,11 +2458,11 @@ int VECFAM::RenameTempFile(PGLOBAL g) ...@@ -2458,11 +2458,11 @@ int VECFAM::RenameTempFile(PGLOBAL g)
remove(filetemp); // May still be there from previous error remove(filetemp); // May still be there from previous error
if (rename(filename, filetemp)) { // Save file for security if (rename(filename, filetemp)) { // Save file for security
sprintf(g->Message, MSG(RENAME_ERROR), snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
filename, filetemp, strerror(errno)); filename, filetemp, strerror(errno));
rc = RC_FX; rc = RC_FX;
} else if (rename(tempname, filename)) { } else if (rename(tempname, filename)) {
sprintf(g->Message, MSG(RENAME_ERROR), snprintf(g->Message, MAX_STR, MSG(RENAME_ERROR),
tempname, filename, strerror(errno)); tempname, filename, strerror(errno));
rc = rename(filetemp, filename); // Restore saved file rc = rename(filetemp, filename); // Restore saved file
rc = RC_FX; rc = RC_FX;
......
...@@ -170,7 +170,7 @@ ...@@ -170,7 +170,7 @@
#define JSONMAX 10 // JSON Default max grp size #define JSONMAX 10 // JSON Default max grp size
extern "C" { extern "C" {
char version[]= "Version 1.06.0007 March 11, 2018"; char version[]= "Version 1.06.0007 August 06, 2018";
#if defined(__WIN__) #if defined(__WIN__)
char compver[]= "Version 1.06.0007 " __DATE__ " " __TIME__; char compver[]= "Version 1.06.0007 " __DATE__ " " __TIME__;
char slash= '\\'; char slash= '\\';
...@@ -3303,23 +3303,15 @@ bool ha_connect::get_error_message(int error, String* buf) ...@@ -3303,23 +3303,15 @@ bool ha_connect::get_error_message(int error, String* buf)
{ {
DBUG_ENTER("ha_connect::get_error_message"); DBUG_ENTER("ha_connect::get_error_message");
if (xp && xp->g) { if (xp && xp->g) {
PGLOBAL g= xp->g; PGLOBAL g = xp->g;
char msg[3072]; // MAX_STR * 3
uint dummy_errors;
uint32 len= copy_and_convert(msg, strlen(g->Message) * 3,
system_charset_info,
g->Message, strlen(g->Message),
&my_charset_latin1,
&dummy_errors);
if (trace(1)) if (trace(1))
htrc("GEM(%d): len=%u %s\n", error, len, g->Message); htrc("GEM(%d): %s\n", error, g->Message);
msg[len]= '\0'; buf->append(g->Message);
buf->copy(msg, (uint)strlen(msg), system_charset_info); } else
} else buf->append("Cannot retrieve error message");
buf->copy("Cannot retrieve msg", 19, system_charset_info);
DBUG_RETURN(false); DBUG_RETURN(false);
} // end of get_error_message } // end of get_error_message
......
...@@ -138,6 +138,16 @@ JAVAConn::JAVAConn(PGLOBAL g, PCSZ wrapper) ...@@ -138,6 +138,16 @@ JAVAConn::JAVAConn(PGLOBAL g, PCSZ wrapper)
// EndCom(); // EndCom();
// } // end of ~JAVAConn // } // end of ~JAVAConn
char *JAVAConn::GetUTFString(jstring s)
{
char *str;
const char *utf = env->GetStringUTFChars(s, nullptr);
str = PlugDup(m_G, utf);
env->ReleaseStringUTFChars(s, utf);
env->DeleteLocalRef(s);
return str;
} // end of GetUTFString
/***********************************************************************/ /***********************************************************************/
/* Screen for errors. */ /* Screen for errors. */
...@@ -152,17 +162,15 @@ bool JAVAConn::Check(jint rc) ...@@ -152,17 +162,15 @@ bool JAVAConn::Check(jint rc)
"toString", "()Ljava/lang/String;"); "toString", "()Ljava/lang/String;");
if (exc != nullptr && tid != nullptr) { if (exc != nullptr && tid != nullptr) {
jstring s = (jstring)env->CallObjectMethod(exc, tid); s = (jstring)env->CallObjectMethod(exc, tid);
const char *utf = env->GetStringUTFChars(s, (jboolean)false); Msg = GetUTFString(s);
env->DeleteLocalRef(s);
Msg = PlugDup(m_G, utf);
} else } else
Msg = "Exception occured"; Msg = "Exception occured";
env->ExceptionClear(); env->ExceptionClear();
} else if (rc < 0) { } else if (rc < 0) {
s = (jstring)env->CallObjectMethod(job, errid); s = (jstring)env->CallObjectMethod(job, errid);
Msg = (char*)env->GetStringUTFChars(s, (jboolean)false); Msg = GetUTFString(s);
} else } else
Msg = NULL; Msg = NULL;
......
...@@ -90,6 +90,7 @@ class DllExport JAVAConn : public BLOCK { ...@@ -90,6 +90,7 @@ class DllExport JAVAConn : public BLOCK {
// Java operations // Java operations
protected: protected:
char *GetUTFString(jstring s);
bool gmID(PGLOBAL g, jmethodID& mid, const char *name, const char *sig); bool gmID(PGLOBAL g, jmethodID& mid, const char *name, const char *sig);
bool Check(jint rc = 0); bool Check(jint rc = 0);
......
...@@ -707,21 +707,14 @@ bool JDBConn::SetUUID(PGLOBAL g, PTDBJDBC tjp) ...@@ -707,21 +707,14 @@ bool JDBConn::SetUUID(PGLOBAL g, PTDBJDBC tjp)
goto err; goto err;
} // endif rc } // endif rc
// Returns 666 is case of error // Should return 666 is case of error (not done yet)
//jtyp = env->CallIntMethod(job, typid, 5, nullptr); ctyp = (int)env->CallIntMethod(job, intfldid, 5, nullptr);
//if (Check((jtyp == 666) ? -1 : 1)) { //if (Check((ctyp == 666) ? -1 : 1)) {
// sprintf(g->Message, "Getting jtyp: %s", Msg); // sprintf(g->Message, "Getting ctyp: %s", Msg);
// goto err; // goto err;
//} // endif ctyp //} // endif ctyp
ctyp = (int)env->CallIntMethod(job, intfldid, 5, nullptr);
if (Check(ctyp)) {
sprintf(g->Message, "Getting ctyp: %s", Msg);
goto err;
} // endif ctyp
if (ctyp == 1111) if (ctyp == 1111)
((PJDBCCOL)colp)->uuid = true; ((PJDBCCOL)colp)->uuid = true;
...@@ -836,11 +829,11 @@ bool JDBConn::Connect(PJPARM sop) ...@@ -836,11 +829,11 @@ bool JDBConn::Connect(PJPARM sop)
jstring s = (jstring)env->CallObjectMethod(job, qcid); jstring s = (jstring)env->CallObjectMethod(job, qcid);
if (s != nullptr) { if (s != nullptr) {
char *qch = (char*)env->GetStringUTFChars(s, (jboolean)false); char *qch = GetUTFString(s);
m_IDQuoteChar[0] = *qch; m_IDQuoteChar[0] = *qch;
} else { } else {
s = (jstring)env->CallObjectMethod(job, errid); s = (jstring)env->CallObjectMethod(job, errid);
Msg = (char*)env->GetStringUTFChars(s, (jboolean)false); Msg = GetUTFString(s);
} // endif s } // endif s
} // endif qcid } // endif qcid
...@@ -1018,7 +1011,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) ...@@ -1018,7 +1011,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
cn = nullptr; cn = nullptr;
if (cn) { if (cn) {
field = env->GetStringUTFChars(cn, (jboolean)false); field = GetUTFString(cn);
val->SetValue_psz((PSZ)field); val->SetValue_psz((PSZ)field);
} else } else
val->Reset(); val->Reset();
...@@ -1092,8 +1085,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val) ...@@ -1092,8 +1085,7 @@ void JDBConn::SetColumnValue(int rank, PSZ name, PVAL val)
cn = nullptr; cn = nullptr;
if (cn) { if (cn) {
const char *field = env->GetStringUTFChars(cn, (jboolean)false); val->SetValue_psz((PSZ)GetUTFString(cn));
val->SetValue_psz((PSZ)field);
} else } else
val->Reset(); val->Reset();
...@@ -1372,19 +1364,19 @@ bool JDBConn::SetParam(JDBCCOL *colp) ...@@ -1372,19 +1364,19 @@ bool JDBConn::SetParam(JDBCCOL *colp)
for (i = 0, n = 0; i < size; i++) { for (i = 0, n = 0; i < size; i++) {
crp = qrp->Colresp; crp = qrp->Colresp;
js = (jstring)env->GetObjectArrayElement(s, n++); js = (jstring)env->GetObjectArrayElement(s, n++);
sval = (PSZ)env->GetStringUTFChars(js, 0); sval = GetUTFString(js);
crp->Kdata->SetValue(sval, i); crp->Kdata->SetValue(sval, i);
crp = crp->Next; crp = crp->Next;
js = (jstring)env->GetObjectArrayElement(s, n++); js = (jstring)env->GetObjectArrayElement(s, n++);
sval = (PSZ)env->GetStringUTFChars(js, 0); sval = GetUTFString(js);
crp->Kdata->SetValue(sval, i); crp->Kdata->SetValue(sval, i);
crp = crp->Next; crp = crp->Next;
js = (jstring)env->GetObjectArrayElement(s, n++); js = (jstring)env->GetObjectArrayElement(s, n++);
sval = (PSZ)env->GetStringUTFChars(js, 0); sval = GetUTFString(js);
crp->Kdata->SetValue(sval, i); crp->Kdata->SetValue(sval, i);
crp = crp->Next; crp = crp->Next;
js = (jstring)env->GetObjectArrayElement(s, n++); js = (jstring)env->GetObjectArrayElement(s, n++);
sval = (PSZ)env->GetStringUTFChars(js, 0); sval = GetUTFString(js);
crp->Kdata->SetValue(sval, i); crp->Kdata->SetValue(sval, i);
} // endfor i } // endfor i
...@@ -1470,7 +1462,7 @@ bool JDBConn::SetParam(JDBCCOL *colp) ...@@ -1470,7 +1462,7 @@ bool JDBConn::SetParam(JDBCCOL *colp)
return NULL; return NULL;
} // endif label } // endif label
name = env->GetStringUTFChars(label, (jboolean)false); name = GetUTFString(label);
crp = qrp->Colresp; // Column_Name crp = qrp->Colresp; // Column_Name
crp->Kdata->SetValue((char*)name, i); crp->Kdata->SetValue((char*)name, i);
n = env->GetIntArrayElements(val, 0); n = env->GetIntArrayElements(val, 0);
......
...@@ -522,7 +522,7 @@ PSZ JMgoConn::GetDocument(void) ...@@ -522,7 +522,7 @@ PSZ JMgoConn::GetDocument(void)
jdc = (jstring)env->CallObjectMethod(job, getdocid); jdc = (jstring)env->CallObjectMethod(job, getdocid);
if (jdc) if (jdc)
doc = (PSZ)env->GetStringUTFChars(jdc, (jboolean)false); doc = (PSZ)GetUTFString(jdc);
} // endif getdocid } // endif getdocid
...@@ -690,7 +690,7 @@ jobject JMgoConn::MakeDoc(PGLOBAL g, PJNCOL jcp) ...@@ -690,7 +690,7 @@ jobject JMgoConn::MakeDoc(PGLOBAL g, PJNCOL jcp)
} // endif Jncolp } // endif Jncolp
return parent; return parent;
} // end of MakeDoc } // end of MakeDoc
/***********************************************************************/ /***********************************************************************/
...@@ -807,7 +807,7 @@ PSZ JMgoConn::GetColumnValue(PSZ path) ...@@ -807,7 +807,7 @@ PSZ JMgoConn::GetColumnValue(PSZ path)
fn = (jstring)env->CallObjectMethod(job, objfldid, jn); fn = (jstring)env->CallObjectMethod(job, objfldid, jn);
if (fn) if (fn)
fld = (PSZ)env->GetStringUTFChars(fn, (jboolean)false); fld = (PSZ)GetUTFString(fn);
} // endif objfldid } // endif objfldid
......
...@@ -4631,7 +4631,7 @@ char *jbin_array(UDF_INIT *initid, UDF_ARGS *args, char *result, ...@@ -4631,7 +4631,7 @@ char *jbin_array(UDF_INIT *initid, UDF_ARGS *args, char *result,
bsp = NULL; bsp = NULL;
if (!bsp && (bsp = JbinAlloc(g, args, initid->max_length, NULL))) if (!bsp && (bsp = JbinAlloc(g, args, initid->max_length, NULL)))
strncpy(bsp->Msg, g->Message, 139); strncpy(bsp->Msg, g->Message, BMX);
// Keep result of constant function // Keep result of constant function
g->Xchk = (initid->const_item) ? bsp : NULL; g->Xchk = (initid->const_item) ? bsp : NULL;
......
...@@ -238,8 +238,7 @@ DROP TABLE t1, connect.emp; ...@@ -238,8 +238,7 @@ DROP TABLE t1, connect.emp;
CREATE TABLE t2 (command varchar(128) not null,number int(5) not null flag=1,message varchar(255) flag=2) ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:mariadb://localhost:PORT/connect' OPTION_LIST='User=root,Execsrc=1'; CREATE TABLE t2 (command varchar(128) not null,number int(5) not null flag=1,message varchar(255) flag=2) ENGINE=CONNECT TABLE_TYPE=JDBC CONNECTION='jdbc:mariadb://localhost:PORT/connect' OPTION_LIST='User=root,Execsrc=1';
SELECT * FROM t2 WHERE command='drop table tx1'; SELECT * FROM t2 WHERE command='drop table tx1';
command number message command number message
drop table tx1 0 Execute: java.sql.SQLSyntaxErrorException: Unknown table 'connect.tx1' drop table tx1 0 Execute: java.sql.SQLSyntaxErrorException: (conn:24) Unknown table 'connect.tx1'
Query is : drop table tx1
SELECT * FROM t2 WHERE command = 'create table tx1 (a int not null, b char(32), c double(8,2))'; SELECT * FROM t2 WHERE command = 'create table tx1 (a int not null, b char(32), c double(8,2))';
command number message command number message
create table tx1 (a int not null, b char(32), c double(8,2)) 0 Affected rows create table tx1 (a int not null, b char(32), c double(8,2)) 0 Affected rows
......
...@@ -72,7 +72,7 @@ bool JMGDISC::Find(PGLOBAL g) ...@@ -72,7 +72,7 @@ bool JMGDISC::Find(PGLOBAL g)
bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt, bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
int ncol, int k) int ncol, int k)
{ {
const char *key; const char *key, *utf;
char colname[65]; char colname[65];
char fmt[129]; char fmt[129];
bool rc = true; bool rc = true;
...@@ -101,7 +101,10 @@ bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt, ...@@ -101,7 +101,10 @@ bool JMGDISC::ColDesc(PGLOBAL g, jobject obj, char *pcn, char *pfmt,
continue; continue;
jkey = (jstring)Jcp->env->CallObjectMethod(Jcp->job, bvnameid); jkey = (jstring)Jcp->env->CallObjectMethod(Jcp->job, bvnameid);
key = Jcp->env->GetStringUTFChars(jkey, (jboolean)false); utf = Jcp->env->GetStringUTFChars(jkey, nullptr);
key = PlugDup(g, utf);
Jcp->env->ReleaseStringUTFChars(jkey, utf);
Jcp->env->DeleteLocalRef(jkey);
if (pcn) { if (pcn) {
strncpy(colname, pcn, 64); strncpy(colname, pcn, 64);
...@@ -457,8 +460,8 @@ PSZ JMGCOL::GetJpath(PGLOBAL g, bool proj) ...@@ -457,8 +460,8 @@ PSZ JMGCOL::GetJpath(PGLOBAL g, bool proj)
} else } else
*p2++ = *p1; *p2++ = *p1;
*p2 = 0; *p2 = 0;
return projpath; return projpath;
} else } else
return Jpath; return Jpath;
......
...@@ -107,12 +107,12 @@ bool PIVAID::SkipColumn(PCOLRES crp, char *skc) ...@@ -107,12 +107,12 @@ bool PIVAID::SkipColumn(PCOLRES crp, char *skc)
/***********************************************************************/ /***********************************************************************/
PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
{ {
char *p, *query, *colname, *skc, buf[64]; char *p, *query, *colname, *skc, buf[64];
int ndif, nblin, w = 0; int ndif, nblin, w = 0;
bool b = false; bool b = false;
PVAL valp; PVAL valp;
PQRYRES qrp; PQRYRES qrp;
PCOLRES *pcrp, crp, fncrp = NULL; PCOLRES *pcrp, crp, fncrp = NULL;
try { try {
// Are there columns to skip? // Are there columns to skip?
...@@ -186,7 +186,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) ...@@ -186,7 +186,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} // endif picol } // endif picol
// Prepare the column list // Prepare the column list
for (pcrp = &Qryp->Colresp; crp = *pcrp; ) for (pcrp = &Qryp->Colresp; crp = *pcrp; )
if (SkipColumn(crp, skc)) { if (SkipColumn(crp, skc)) {
// Ignore this column // Ignore this column
...@@ -205,95 +205,95 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) ...@@ -205,95 +205,95 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} else } else
pcrp = &crp->Next; pcrp = &crp->Next;
if (!Rblkp) { if (!Rblkp) {
strcpy(g->Message, MSG(NO_DEF_PIVOTCOL)); strcpy(g->Message, MSG(NO_DEF_PIVOTCOL));
goto err; goto err;
} else if (!fncrp) { } else if (!fncrp) {
strcpy(g->Message, MSG(NO_DEF_FNCCOL)); strcpy(g->Message, MSG(NO_DEF_FNCCOL));
goto err; goto err;
} // endif } // endif
if (Tabsrc) { if (Tabsrc) {
Myc.Close(); Myc.Close();
b = false; b = false;
// Before calling sort, initialize all // Before calling sort, initialize all
nblin = Qryp->Nblin; nblin = Qryp->Nblin;
Index.Size = nblin * sizeof(int); Index.Size = nblin * sizeof(int);
Index.Sub = TRUE; // Should be small enough Index.Sub = TRUE; // Should be small enough
if (!PlgDBalloc(g, NULL, Index)) if (!PlgDBalloc(g, NULL, Index))
goto err; goto err;
Offset.Size = (nblin + 1) * sizeof(int); Offset.Size = (nblin + 1) * sizeof(int);
Offset.Sub = TRUE; // Should be small enough Offset.Sub = TRUE; // Should be small enough
if (!PlgDBalloc(g, NULL, Offset)) if (!PlgDBalloc(g, NULL, Offset))
goto err; goto err;
ndif = Qsort(g, nblin); ndif = Qsort(g, nblin);
if (ndif < 0) // error if (ndif < 0) // error
goto err; goto err;
} else { } else {
// The query was limited, we must get pivot column values // The query was limited, we must get pivot column values
// Returned values must be in their original character set // Returned values must be in their original character set
// if (Myc.ExecSQL(g, "SET character_set_results=NULL", &w) == RC_FX) // if (Myc.ExecSQL(g, "SET character_set_results=NULL", &w) == RC_FX)
// goto err; // goto err;
query = (char*)PlugSubAlloc(g, NULL, 0); query = (char*)PlugSubAlloc(g, NULL, 0);
sprintf(query, "SELECT DISTINCT `%s` FROM `%s`", Picol, Tabname); sprintf(query, "SELECT DISTINCT `%s` FROM `%s`", Picol, Tabname);
PlugSubAlloc(g, NULL, strlen(query) + 1); PlugSubAlloc(g, NULL, strlen(query) + 1);
Myc.FreeResult(); Myc.FreeResult();
// Send the source command to MySQL // Send the source command to MySQL
if (Myc.ExecSQL(g, query, &w) == RC_FX) if (Myc.ExecSQL(g, query, &w) == RC_FX)
goto err; goto err;
// We must have a storage query to get pivot column values // We must have a storage query to get pivot column values
if (!(qrp = Myc.GetResult(g, true))) if (!(qrp = Myc.GetResult(g, true)))
goto err; goto err;
Myc.Close(); Myc.Close();
b = false; b = false;
// Get the column list // Get the column list
crp = qrp->Colresp; crp = qrp->Colresp;
Rblkp = crp->Kdata; Rblkp = crp->Kdata;
ndif = qrp->Nblin; ndif = qrp->Nblin;
} // endif Tabsrc } // endif Tabsrc
// Allocate the Value used to retieve column names // Allocate the Value used to retieve column names
if (!(valp = AllocateValue(g, Rblkp->GetType(), if (!(valp = AllocateValue(g, Rblkp->GetType(),
Rblkp->GetVlen(), Rblkp->GetVlen(),
Rblkp->GetPrec()))) Rblkp->GetPrec())))
goto err; goto err;
// Now make the functional columns // Now make the functional columns
for (int i = 0; i < ndif; i++) { for (int i = 0; i < ndif; i++) {
if (i) { if (i) {
crp = (PCOLRES)PlugSubAlloc(g, NULL, sizeof(COLRES)); crp = (PCOLRES)PlugSubAlloc(g, NULL, sizeof(COLRES));
memcpy(crp, fncrp, sizeof(COLRES)); memcpy(crp, fncrp, sizeof(COLRES));
} else } else
crp = fncrp; crp = fncrp;
// Get the value that will be the generated column name // Get the value that will be the generated column name
if (Tabsrc) if (Tabsrc)
valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]); valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]);
else else
valp->SetValue_pvblk(Rblkp, i); valp->SetValue_pvblk(Rblkp, i);
colname = valp->GetCharString(buf); colname = valp->GetCharString(buf);
crp->Name = PlugDup(g, colname); crp->Name = PlugDup(g, colname);
crp->Flag = 1; crp->Flag = 1;
// Add this column // Add this column
*pcrp = crp; *pcrp = crp;
crp->Next = NULL; crp->Next = NULL;
pcrp = &crp->Next; pcrp = &crp->Next;
} // endfor i } // endfor i
// We added ndif columns and removed 2 (picol and fncol) // We added ndif columns and removed 2 (picol and fncol)
Qryp->Nbcol += (ndif - 2); Qryp->Nbcol += (ndif - 2);
...@@ -306,10 +306,10 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) ...@@ -306,10 +306,10 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
} // end catch } // end catch
err: err:
if (b) if (b)
Myc.Close(); Myc.Close();
return NULL; return NULL;
} // end of MakePivotColumns } // end of MakePivotColumns
/***********************************************************************/ /***********************************************************************/
......
...@@ -429,7 +429,7 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b) ...@@ -429,7 +429,7 @@ PTDB TDBPRX::GetSubTable(PGLOBAL g, PTABLE tabp, bool b)
char buf[MAX_STR]; char buf[MAX_STR];
strcpy(buf, g->Message); strcpy(buf, g->Message);
sprintf(g->Message, "Error accessing %s.%s: %s", db, name, buf); snprintf(g->Message, MAX_STR, "Error accessing %s.%s: %s", db, name, buf);
hc->tshp = NULL; hc->tshp = NULL;
goto err; goto err;
} // endif Define } // endif Define
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment