1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

- 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:
Olivier Bertrand
2013-05-28 21:06:15 +02:00
parent 9f7c3fedfa
commit 0aa4fb73a4
3 changed files with 86 additions and 86 deletions

View File

@@ -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 --------------- */
/***********************************************************************/