summaryrefslogtreecommitdiff
path: root/storage/connect/myconn.cpp
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2013-05-19 19:25:06 +0200
committerOlivier Bertrand <bertrandop@gmail.com>2013-05-19 19:25:06 +0200
commitc035bde34c3a5a63451b51031d508a425ce9a3ae (patch)
tree40f513d803531c29a04dd18934ab20e799fba964 /storage/connect/myconn.cpp
parent3c76e0e2ad05229ea1718b6e9c3dce85d75aaa4d (diff)
downloadmariadb-git-c035bde34c3a5a63451b51031d508a425ce9a3ae.tar.gz
- Allowing views and queries as parameters for PROXY base tables
NOTE: Checking for looping references cannot be done when using views as parameters. This should not be allowed on production servers and should be dependant on a system variable and/or on speciel grant. modified: storage/connect/CMakeLists.txt storage/connect/connect.cc storage/connect/ha_connect.cc storage/connect/myconn.cpp storage/connect/myconn.h storage/connect/mysql-test/connect/r/fmt.result storage/connect/mysql-test/connect/r/pivot.result storage/connect/mysql-test/connect/t/fmt.test storage/connect/mysql-test/connect/t/pivot.test storage/connect/plgdbsem.h storage/connect/plugutil.c storage/connect/tabcol.cpp storage/connect/tabcol.h storage/connect/tabfmt.cpp storage/connect/tabmysql.cpp storage/connect/tabmysql.h storage/connect/taboccur.cpp storage/connect/taboccur.h storage/connect/tabpivot.cpp storage/connect/tabpivot.h storage/connect/tabtbl.cpp storage/connect/tabutil.cpp storage/connect/tabutil.h storage/connect/xtable.h
Diffstat (limited to 'storage/connect/myconn.cpp')
-rw-r--r--storage/connect/myconn.cpp38
1 files changed, 32 insertions, 6 deletions
diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp
index fab2af54aa7..5320171beeb 100644
--- a/storage/connect/myconn.cpp
+++ b/storage/connect/myconn.cpp
@@ -66,13 +66,13 @@ extern MYSQL_PLUGIN_IMPORT uint mysqld_port;
/************************************************************************/
/* MyColumns: constructs the result blocks containing all columns */
-/* of a MySQL table that will be retrieved by GetData commands. */
-/* key = TRUE when called from Create Table to get key informations. */
+/* of a MySQL table or view. */
+/* info = TRUE to get catalog column informations. */
/************************************************************************/
PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
const char *user, const char *pwd,
const char *table, const char *colpat,
- int port, bool key, bool info)
+ int port, bool info)
{
static int buftyp[] = {TYPE_STRING, TYPE_SHORT, TYPE_STRING, TYPE_INT,
TYPE_STRING, TYPE_SHORT, TYPE_SHORT, TYPE_SHORT,
@@ -124,9 +124,6 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
length[0] = 128;
} // endif info
-//if (!key) // We are not called from Create table
-// ncol--; // No date format column yet
-
/**********************************************************************/
/* Allocate the structures used to refer to the result set. */
/**********************************************************************/
@@ -219,6 +216,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
crp->Kdata->SetValue(fld, i);
} // endfor i
+#if 0
if (k > 1) {
// Multicolumn primary key
PVBLK vbp = qrp->Colresp->Next->Next->Next->Next->Kdata;
@@ -228,6 +226,7 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
vbp->SetValue(k, i);
} // endif k
+#endif // 0
/**********************************************************************/
/* Close MySQL connection. */
@@ -240,6 +239,33 @@ PQRYRES MyColumns(PGLOBAL g, const char *host, const char *db,
return qrp;
} // end of MyColumns
+/************************************************************************/
+/* SrcColumns: constructs the result blocks containing all columns */
+/* resulting from an SQL source definition query execution. */
+/************************************************************************/
+PQRYRES SrcColumns(PGLOBAL g, const char *host, const char *db,
+ const char *user, const char *pwd,
+ const char *srcdef, int port)
+ {
+ int w;
+ MYSQLC myc;
+ PQRYRES qrp = NULL;
+
+ if (!port)
+ port = mysqld_port;
+
+ // Open a MySQL connection for this table
+ if (myc.Open(g, host, db, user, pwd, port))
+ return NULL;
+
+ // Send the source command to MySQL
+ if (myc.ExecSQL(g, srcdef, &w) == RC_OK)
+ qrp = myc.GetResult(g);
+
+ myc.Close();
+ return qrp;
+ } // end of SrcColumns
+
/* -------------------------- Class MYSQLC --------------------------- */
/***********************************************************************/