diff options
author | Olivier Bertrand <bertrandop@gmail.com> | 2013-05-28 21:06:15 +0200 |
---|---|---|
committer | Olivier Bertrand <bertrandop@gmail.com> | 2013-05-28 21:06:15 +0200 |
commit | 0aa4fb73a49993d3a73550ee624b62d7556f8515 (patch) | |
tree | fec128bc6b8e44eb261d2fc473639c586cb5debc /storage/connect/tabpivot.cpp | |
parent | 9f7c3fedfacdc62a30e1c9cd4ef2cdf900abffba (diff) | |
download | mariadb-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/connect/tabpivot.cpp')
-rw-r--r-- | storage/connect/tabpivot.cpp | 104 |
1 files changed, 52 insertions, 52 deletions
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 --------------- */ /***********************************************************************/ |