summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2013-05-28 21:06:15 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2013-05-28 21:06:15 +0200
commit0aa4fb73a49993d3a73550ee624b62d7556f8515 (patch)
treefec128bc6b8e44eb261d2fc473639c586cb5debc /storage
parent9f7c3fedfacdc62a30e1c9cd4ef2cdf900abffba (diff)
downloadmariadb-git-0aa4fb73a49993d3a73550ee624b62d7556f8515.tar.gz
- 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
Diffstat (limited to 'storage')
-rw-r--r--storage/connect/ha_connect.cc4
-rw-r--r--storage/connect/tabpivot.cpp104
-rw-r--r--storage/connect/tabpivot.h64
3 files changed, 86 insertions, 86 deletions
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index db789dda5bd..829c194b61d 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -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;
diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp
index dbe702c7462..9beca56e773 100644
--- a/storage/connect/tabpivot.cpp
+++ b/storage/connect/tabpivot.cpp
@@ -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 --------------- */
/***********************************************************************/
diff --git a/storage/connect/tabpivot.h b/storage/connect/tabpivot.h
index 4a766700162..170c6b67ea4 100644
--- a/storage/connect/tabpivot.h
+++ b/storage/connect/tabpivot.h
@@ -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 -------------------------- */
/***********************************************************************/