diff options
Diffstat (limited to 'storage/connect/tabpivot.cpp')
-rw-r--r-- | storage/connect/tabpivot.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp index 2b0c43dac9f..401ffa3780e 100644 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -5,7 +5,7 @@ /* */ /* COPYRIGHT: */ /* ---------- */ -/* (C) Copyright to the author Olivier BERTRAND 2005-2013 */ +/* (C) Copyright to the author Olivier BERTRAND 2005-2015 */ /* */ /* WHAT THIS PROGRAM DOES: */ /* ----------------------- */ @@ -49,7 +49,6 @@ #include "tabpivot.h" #include "valblk.h" #include "ha_connect.h" -#include "mycat.h" // For GetHandler /***********************************************************************/ /* Make the Pivot table column list. */ @@ -150,11 +149,18 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) query = Tabsrc; // Open a MySQL connection for this table - if (Myc.Open(g, Host, Database, User, Pwd, Port)) - return NULL; - else + if (!Myc.Open(g, Host, Database, User, Pwd, Port)) { b = true; + // Returned values must be in their original character set + if (Myc.ExecSQL(g, "SET character_set_results=NULL", &w) == RC_FX) + goto err; + else + Myc.FreeResult(); + + } else + return NULL; + // Send the source command to MySQL if (Myc.ExecSQL(g, query, &w) == RC_FX) goto err; @@ -241,6 +247,10 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) } else { // The query was limited, we must get pivot column values + // Returned values must be in their original character set +// if (Myc.ExecSQL(g, "SET character_set_results=NULL", &w) == RC_FX) +// goto err; + query = (char*)PlugSubAlloc(g, NULL, 0); sprintf(query, "SELECT DISTINCT `%s` FROM `%s`", Picol, Tabname); PlugSubAlloc(g, NULL, strlen(query) + 1); @@ -284,8 +294,7 @@ PQRYRES PIVAID::MakePivotColumns(PGLOBAL g) valp->SetValue_pvblk(Rblkp, i); colname = valp->GetCharString(buf); - crp->Name = (char*)PlugSubAlloc(g, NULL, strlen(colname) + 1); - strcpy(crp->Name, colname); + crp->Name = PlugDup(g, colname); crp->Flag = 1; // Add this column |