- 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) {
|
if (src && ttp != TAB_PIVOT) {
|
||||||
qrp= SrcColumns(g, host, db, user, pwd, src, port);
|
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)) {
|
if (OcrSrcCols(g, qrp, col, ocl, rnk)) {
|
||||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||||
return HA_ERR_INTERNAL_ERROR;
|
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
|
if (!qrp && bif && fnc != FNC_COL) // tab is a view
|
||||||
qrp= MyColumns(g, host, db, user, pwd, tab, NULL, port, false);
|
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)) {
|
if (OcrColumns(g, qrp, col, ocl, rnk)) {
|
||||||
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
|
||||||
return HA_ERR_INTERNAL_ERROR;
|
return HA_ERR_INTERNAL_ERROR;
|
||||||
|
@ -63,7 +63,7 @@ PQRYRES PivotColumns(PGLOBAL g, const char *tab, const char *src,
|
|||||||
int port)
|
int port)
|
||||||
{
|
{
|
||||||
PIVAID pvd(tab, src, picol, fncol, host, db, user, pwd, port);
|
PIVAID pvd(tab, src, picol, fncol, host, db, user, pwd, port);
|
||||||
|
|
||||||
return pvd.MakePivotColumns(g);
|
return pvd.MakePivotColumns(g);
|
||||||
} // end of PivotColumns
|
} // end of PivotColumns
|
||||||
|
|
||||||
@ -96,8 +96,8 @@ PIVAID::PIVAID(const char *tab, const char *src, const char *picol,
|
|||||||
PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
||||||
{
|
{
|
||||||
char *query, *colname, buf[32];
|
char *query, *colname, buf[32];
|
||||||
int ndif, nblin, w = 0;
|
int ndif, nblin, w = 0;
|
||||||
PVAL valp;
|
PVAL valp;
|
||||||
PCOLRES *pcrp, crp, fncrp = NULL;
|
PCOLRES *pcrp, crp, fncrp = NULL;
|
||||||
|
|
||||||
if (!Tabsrc && Tabname) {
|
if (!Tabsrc && Tabname) {
|
||||||
@ -110,20 +110,20 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
|||||||
} else
|
} else
|
||||||
query = Tabsrc;
|
query = Tabsrc;
|
||||||
|
|
||||||
// Open a MySQL connection for this table
|
// Open a MySQL connection for this table
|
||||||
if (Myc.Open(g, Host, Database, User, Pwd, Port))
|
if (Myc.Open(g, Host, Database, User, Pwd, Port))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// 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) {
|
||||||
Myc.Close();
|
Myc.Close();
|
||||||
return NULL;
|
return NULL;
|
||||||
} // endif Exec
|
} // endif Exec
|
||||||
|
|
||||||
// We must have a storage query to get pivot column values
|
// We must have a storage query to get pivot column values
|
||||||
Qryp = Myc.GetResult(g);
|
Qryp = Myc.GetResult(g);
|
||||||
Myc.Close();
|
Myc.Close();
|
||||||
|
|
||||||
if (!Fncol) {
|
if (!Fncol) {
|
||||||
for (crp = Qryp->Colresp; crp; crp = crp->Next)
|
for (crp = Qryp->Colresp; crp; crp = crp->Next)
|
||||||
if (!Picol || stricmp(Picol, crp->Name))
|
if (!Picol || stricmp(Picol, crp->Name))
|
||||||
@ -168,33 +168,33 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
|||||||
return NULL;
|
return NULL;
|
||||||
} // endif
|
} // endif
|
||||||
|
|
||||||
// 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))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
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))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ndif = Qsort(g, nblin);
|
ndif = Qsort(g, nblin);
|
||||||
|
|
||||||
if (ndif < 0) // error
|
if (ndif < 0) // error
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// 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())))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
// 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));
|
||||||
@ -202,8 +202,8 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
|||||||
} 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
|
||||||
valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]);
|
valp->SetValue_pvblk(Rblkp, Pex[Pof[i]]);
|
||||||
colname = valp->GetCharString(buf);
|
colname = valp->GetCharString(buf);
|
||||||
crp->Name = (char*)PlugSubAlloc(g, NULL, strlen(colname) + 1);
|
crp->Name = (char*)PlugSubAlloc(g, NULL, strlen(colname) + 1);
|
||||||
strcpy(crp->Name, colname);
|
strcpy(crp->Name, colname);
|
||||||
@ -220,15 +220,15 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g)
|
|||||||
return Qryp;
|
return Qryp;
|
||||||
} // end of MakePivotColumns
|
} // end of MakePivotColumns
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* PIVAID: Compare routine for sorting pivot column values. */
|
/* PIVAID: Compare routine for sorting pivot column values. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
int PIVAID::Qcompare(int *i1, int *i2)
|
int PIVAID::Qcompare(int *i1, int *i2)
|
||||||
{
|
{
|
||||||
// TODO: the actual comparison between pivot column result values.
|
// TODO: the actual comparison between pivot column result values.
|
||||||
return Rblkp->CompVal(*i1, *i2);
|
return Rblkp->CompVal(*i1, *i2);
|
||||||
} // end of Qcompare
|
} // end of Qcompare
|
||||||
|
|
||||||
/* --------------- Implementation of the PIVOT classes --------------- */
|
/* --------------- Implementation of the PIVOT classes --------------- */
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
@ -10,40 +10,40 @@ typedef class TDBPIVOT *PTDBPIVOT;
|
|||||||
typedef class FNCCOL *PFNCCOL;
|
typedef class FNCCOL *PFNCCOL;
|
||||||
typedef class SRCCOL *PSRCCOL;
|
typedef class SRCCOL *PSRCCOL;
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
/* This class is used to generate PIVOT table column definitions. */
|
/* This class is used to generate PIVOT table column definitions. */
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
class PIVAID : public CSORT {
|
class PIVAID : public CSORT {
|
||||||
friend class FNCCOL;
|
friend class FNCCOL;
|
||||||
friend class SRCCOL;
|
friend class SRCCOL;
|
||||||
public:
|
public:
|
||||||
// Constructor
|
// Constructor
|
||||||
PIVAID(const char *tab, const char *src, const char *picol,
|
PIVAID(const char *tab, const char *src, const char *picol,
|
||||||
const char *fncol, const char *host, const char *db,
|
const char *fncol, const char *host, const char *db,
|
||||||
const char *user, const char *pwd, int port);
|
const char *user, const char *pwd, int port);
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
PQRYRES MakePivotColumns(PGLOBAL g);
|
PQRYRES MakePivotColumns(PGLOBAL g);
|
||||||
|
|
||||||
// The sorting function
|
// The sorting function
|
||||||
virtual int Qcompare(int *, int *);
|
virtual int Qcompare(int *, int *);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Members
|
// Members
|
||||||
MYSQLC Myc; // MySQL connection class
|
MYSQLC Myc; // MySQL connection class
|
||||||
char *Host; // Host machine to use
|
char *Host; // Host machine to use
|
||||||
char *User; // User logon info
|
char *User; // User logon info
|
||||||
char *Pwd; // Password logon info
|
char *Pwd; // Password logon info
|
||||||
char *Database; // Database to be used by server
|
char *Database; // Database to be used by server
|
||||||
PQRYRES Qryp; // Points to Query result block
|
PQRYRES Qryp; // Points to Query result block
|
||||||
char *Tabname; // Name of source table
|
char *Tabname; // Name of source table
|
||||||
char *Tabsrc; // SQL of source table
|
char *Tabsrc; // SQL of source table
|
||||||
char *Picol; // Pivot column name
|
char *Picol; // Pivot column name
|
||||||
char *Fncol; // Function column name
|
char *Fncol; // Function column name
|
||||||
PVBLK Rblkp; // The value block of the pivot column
|
PVBLK Rblkp; // The value block of the pivot column
|
||||||
int Port; // MySQL port number
|
int Port; // MySQL port number
|
||||||
}; // end of class PIVAID
|
}; // end of class PIVAID
|
||||||
|
|
||||||
/* -------------------------- PIVOT classes -------------------------- */
|
/* -------------------------- PIVOT classes -------------------------- */
|
||||||
|
|
||||||
/***********************************************************************/
|
/***********************************************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user