- Fix crash when a null qrp is returned for OCCUR tables
in connect_assisted_discovery modified: storage/connect/ha_connect.cc - Change CRLF line endings to LF modified: storage/connect/tabpivot.cpp storage/connect/tabpivot.h
This commit is contained in:
parent
9f7c3fedfa
commit
0aa4fb73a4
@ -3604,7 +3604,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
||||
if (src && ttp != TAB_PIVOT) {
|
||||
qrp= SrcColumns(g, host, db, user, pwd, src, port);
|
||||
|
||||
if (ttp == TAB_OCCUR)
|
||||
if (qrp && ttp == TAB_OCCUR)
|
||||
if (OcrSrcCols(g, qrp, col, ocl, rnk)) {
|
||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||
return HA_ERR_INTERNAL_ERROR;
|
||||
@ -3660,7 +3660,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
|
||||
if (!qrp && bif && fnc != FNC_COL) // tab is a view
|
||||
qrp= MyColumns(g, host, db, user, pwd, tab, NULL, port, false);
|
||||
|
||||
if (ttp == TAB_OCCUR && fnc != FNC_COL)
|
||||
if (qrp && ttp == TAB_OCCUR && fnc != FNC_COL)
|
||||
if (OcrColumns(g, qrp, col, ocl, rnk)) {
|
||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||
return HA_ERR_INTERNAL_ERROR;
|
||||
|
@ -63,7 +63,7 @@ PQRYRES PivotColumns(PGLOBAL g, const char *tab, const char *src,
|
||||
int port)
|
||||
{
|
||||
PIVAID pvd(tab, src, picol, fncol, host, db, user, pwd, port);
|
||||
|
||||
|
||||
return pvd.MakePivotColumns(g);
|
||||
} // end of PivotColumns
|
||||
|
||||
@ -96,8 +96,8 @@ PIVAID::PIVAID(const char *tab, const char *src, const char *picol,
|
||||
PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
||||
{
|
||||
char *query, *colname, buf[32];
|
||||
int ndif, nblin, w = 0;
|
||||
PVAL valp;
|
||||
int ndif, nblin, w = 0;
|
||||
PVAL valp;
|
||||
PCOLRES *pcrp, crp, fncrp = NULL;
|
||||
|
||||
if (!Tabsrc && Tabname) {
|
||||
@ -110,20 +110,20 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
||||
} else
|
||||
query = Tabsrc;
|
||||
|
||||
// Open a MySQL connection for this table
|
||||
if (Myc.Open(g, Host, Database, User, Pwd, Port))
|
||||
return NULL;
|
||||
|
||||
// Send the source command to MySQL
|
||||
if (Myc.ExecSQL(g, query, &w) == RC_FX) {
|
||||
Myc.Close();
|
||||
return NULL;
|
||||
} // endif Exec
|
||||
|
||||
// We must have a storage query to get pivot column values
|
||||
Qryp = Myc.GetResult(g);
|
||||
Myc.Close();
|
||||
|
||||
// Open a MySQL connection for this table
|
||||
if (Myc.Open(g, Host, Database, User, Pwd, Port))
|
||||
return NULL;
|
||||
|
||||
// Send the source command to MySQL
|
||||
if (Myc.ExecSQL(g, query, &w) == RC_FX) {
|
||||
Myc.Close();
|
||||
return NULL;
|
||||
} // endif Exec
|
||||
|
||||
// We must have a storage query to get pivot column values
|
||||
Qryp = Myc.GetResult(g);
|
||||
Myc.Close();
|
||||
|
||||
if (!Fncol) {
|
||||
for (crp = Qryp->Colresp; crp; crp = crp->Next)
|
||||
if (!Picol || stricmp(Picol, crp->Name))
|
||||
@ -168,33 +168,33 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
||||
return NULL;
|
||||
} // endif
|
||||
|
||||
// Before calling sort, initialize all
|
||||
// Before calling sort, initialize all
|
||||
nblin = Qryp->Nblin;
|
||||
|
||||
Index.Size = nblin * sizeof(int);
|
||||
Index.Sub = TRUE; // Should be small enough
|
||||
|
||||
if (!PlgDBalloc(g, NULL, Index))
|
||||
return NULL;
|
||||
|
||||
Offset.Size = (nblin + 1) * sizeof(int);
|
||||
Offset.Sub = TRUE; // Should be small enough
|
||||
|
||||
if (!PlgDBalloc(g, NULL, Offset))
|
||||
return NULL;
|
||||
|
||||
ndif = Qsort(g, nblin);
|
||||
|
||||
if (ndif < 0) // error
|
||||
return NULL;
|
||||
|
||||
// Allocate the Value used to retieve column names
|
||||
Index.Size = nblin * sizeof(int);
|
||||
Index.Sub = TRUE; // Should be small enough
|
||||
|
||||
if (!PlgDBalloc(g, NULL, Index))
|
||||
return NULL;
|
||||
|
||||
Offset.Size = (nblin + 1) * sizeof(int);
|
||||
Offset.Sub = TRUE; // Should be small enough
|
||||
|
||||
if (!PlgDBalloc(g, NULL, Offset))
|
||||
return NULL;
|
||||
|
||||
ndif = Qsort(g, nblin);
|
||||
|
||||
if (ndif < 0) // error
|
||||
return NULL;
|
||||
|
||||
// Allocate the Value used to retieve column names
|
||||
if (!(valp = AllocateValue(g, Rblkp->GetType(),
|
||||
Rblkp->GetVlen(),
|
||||
Rblkp->GetPrec())))
|
||||
return NULL;
|
||||
|
||||
// Now make the functional columns
|
||||
Rblkp->GetVlen(),
|
||||
Rblkp->GetPrec())))
|
||||
return NULL;
|
||||
|
||||
// Now make the functional columns
|
||||
for (int i = 0; i < ndif; i++) {
|
||||
if (i) {
|
||||
crp = (PCOLRES)PlugSubAlloc(g, NULL, sizeof(COLRES));
|
||||
@ -202,8 +202,8 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
||||
} else
|
||||
crp = fncrp;
|
||||
|
||||
// Get the value that will be the generated column name
|
||||
valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]);
|
||||
// Get the value that will be the generated column name
|
||||
valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]);
|
||||
colname = valp->GetCharString(buf);
|
||||
crp->Name = (char*)PlugSubAlloc(g, NULL, strlen(colname) + 1);
|
||||
strcpy(crp->Name, colname);
|
||||
@ -220,15 +220,15 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
||||
return Qryp;
|
||||
} // end of MakePivotColumns
|
||||
|
||||
/***********************************************************************/
|
||||
/* PIVAID: Compare routine for sorting pivot column values. */
|
||||
/***********************************************************************/
|
||||
int PIVAID::Qcompare(int *i1, int *i2)
|
||||
{
|
||||
// TODO: the actual comparison between pivot column result values.
|
||||
return Rblkp->CompVal(*i1, *i2);
|
||||
} // end of Qcompare
|
||||
|
||||
/***********************************************************************/
|
||||
/* PIVAID: Compare routine for sorting pivot column values. */
|
||||
/***********************************************************************/
|
||||
int PIVAID::Qcompare(int *i1, int *i2)
|
||||
{
|
||||
// TODO: the actual comparison between pivot column result values.
|
||||
return Rblkp->CompVal(*i1, *i2);
|
||||
} // end of Qcompare
|
||||
|
||||
/* --------------- Implementation of the PIVOT classes --------------- */
|
||||
|
||||
/***********************************************************************/
|
||||
|
@ -10,40 +10,40 @@ typedef class TDBPIVOT *PTDBPIVOT;
|
||||
typedef class FNCCOL *PFNCCOL;
|
||||
typedef class SRCCOL *PSRCCOL;
|
||||
|
||||
/***********************************************************************/
|
||||
/* This class is used to generate PIVOT table column definitions. */
|
||||
/***********************************************************************/
|
||||
class PIVAID : public CSORT {
|
||||
friend class FNCCOL;
|
||||
friend class SRCCOL;
|
||||
public:
|
||||
// Constructor
|
||||
/***********************************************************************/
|
||||
/* This class is used to generate PIVOT table column definitions. */
|
||||
/***********************************************************************/
|
||||
class PIVAID : public CSORT {
|
||||
friend class FNCCOL;
|
||||
friend class SRCCOL;
|
||||
public:
|
||||
// Constructor
|
||||
PIVAID(const char *tab, const char *src, const char *picol,
|
||||
const char *fncol, const char *host, const char *db,
|
||||
const char *user, const char *pwd, int port);
|
||||
|
||||
// Methods
|
||||
PQRYRES MakePivotColumns(PGLOBAL g);
|
||||
|
||||
// The sorting function
|
||||
virtual int Qcompare(int *, int *);
|
||||
|
||||
protected:
|
||||
// Members
|
||||
MYSQLC Myc; // MySQL connection class
|
||||
char *Host; // Host machine to use
|
||||
char *User; // User logon info
|
||||
char *Pwd; // Password logon info
|
||||
char *Database; // Database to be used by server
|
||||
PQRYRES Qryp; // Points to Query result block
|
||||
char *Tabname; // Name of source table
|
||||
char *Tabsrc; // SQL of source table
|
||||
char *Picol; // Pivot column name
|
||||
char *Fncol; // Function column name
|
||||
PVBLK Rblkp; // The value block of the pivot column
|
||||
int Port; // MySQL port number
|
||||
}; // end of class PIVAID
|
||||
|
||||
const char *user, const char *pwd, int port);
|
||||
|
||||
// Methods
|
||||
PQRYRES MakePivotColumns(PGLOBAL g);
|
||||
|
||||
// The sorting function
|
||||
virtual int Qcompare(int *, int *);
|
||||
|
||||
protected:
|
||||
// Members
|
||||
MYSQLC Myc; // MySQL connection class
|
||||
char *Host; // Host machine to use
|
||||
char *User; // User logon info
|
||||
char *Pwd; // Password logon info
|
||||
char *Database; // Database to be used by server
|
||||
PQRYRES Qryp; // Points to Query result block
|
||||
char *Tabname; // Name of source table
|
||||
char *Tabsrc; // SQL of source table
|
||||
char *Picol; // Pivot column name
|
||||
char *Fncol; // Function column name
|
||||
PVBLK Rblkp; // The value block of the pivot column
|
||||
int Port; // MySQL port number
|
||||
}; // end of class PIVAID
|
||||
|
||||
/* -------------------------- PIVOT classes -------------------------- */
|
||||
|
||||
/***********************************************************************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user