summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Bertrand <bertrandop@gmail.com>2014-03-27 19:07:17 +0100
committerOlivier Bertrand <bertrandop@gmail.com>2014-03-27 19:07:17 +0100
commitbdbe7430bc16d8cff18733b84de5db62c89ad5d9 (patch)
tree3c0ffc754749454b256b7707a8d841d7ab39955a
parent9bf8a68577c48bec2e9bdd86026dd7207d34f556 (diff)
downloadmariadb-git-bdbe7430bc16d8cff18733b84de5db62c89ad5d9.tar.gz
- Make local MySQL connection default to unix socket on Linux or enable
to use named pipe on Windows by specifying the host as '.' This addresses MDEV-5952. modified: storage/connect/myconn.cpp - Clean some unused code modified: storage/connect/connect.cc storage/connect/connect.h storage/connect/ha_connect.cc storage/connect/ha_connect.h
-rw-r--r--storage/connect/connect.cc8
-rw-r--r--storage/connect/connect.h5
-rw-r--r--storage/connect/ha_connect.cc3
-rw-r--r--storage/connect/ha_connect.h1
-rw-r--r--storage/connect/myconn.cpp20
5 files changed, 23 insertions, 14 deletions
diff --git a/storage/connect/connect.cc b/storage/connect/connect.cc
index 66cd139c85e..879814833d4 100644
--- a/storage/connect/connect.cc
+++ b/storage/connect/connect.cc
@@ -57,7 +57,7 @@ extern "C" int trace;
/* Routines called internally by semantic routines. */
/***********************************************************************/
void CntEndDB(PGLOBAL);
-RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool mrr= false);
+RCODE EvalColumns(PGLOBAL g, PTDB tdbp);
/***********************************************************************/
/* MySQL routines called externally by semantic routines. */
@@ -387,7 +387,7 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp)
/***********************************************************************/
/* Evaluate all columns after a record is read. */
/***********************************************************************/
-RCODE EvalColumns(PGLOBAL g, PTDB tdbp, bool mrr)
+RCODE EvalColumns(PGLOBAL g, PTDB tdbp)
{
RCODE rc= RC_OK;
PCOL colp;
@@ -706,7 +706,7 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id)
/* IndexRead: fetch a record having the index value. */
/***********************************************************************/
RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
- const void *key, int len, bool mrr)
+ const void *key, int len)
{
char *kp= (char*)key;
int n;
@@ -783,7 +783,7 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
xbp->SetNth(0);
if ((rc= (RCODE)tdbp->ReadDB(g)) == RC_OK)
- rc= EvalColumns(g, tdbp, mrr);
+ rc= EvalColumns(g, tdbp);
return rc;
} // end of CntIndexRead
diff --git a/storage/connect/connect.h b/storage/connect/connect.h
index be423fcb575..4c9cee46daf 100644
--- a/storage/connect/connect.h
+++ b/storage/connect/connect.h
@@ -36,8 +36,7 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp);
int CntCloseTable(PGLOBAL g, PTDB tdbp);
int CntIndexInit(PGLOBAL g, PTDB tdbp, int id);
RCODE CntReadNext(PGLOBAL g, PTDB tdbp);
-RCODE CntIndexRead(PGLOBAL g, PTDB, OPVAL op, const void *k, int n,
- bool mrr = false);
+RCODE CntIndexRead(PGLOBAL g, PTDB, OPVAL op, const void *k, int n);
RCODE CntWriteRow(PGLOBAL g, PTDB tdbp);
RCODE CntUpdateRow(PGLOBAL g, PTDB tdbp);
RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all);
@@ -61,7 +60,7 @@ class TDBDOX: public TDBDOS {
friend int MakeIndex(PGLOBAL, PTDB, PIXDEF);
friend int CntCloseTable(PGLOBAL, PTDB);
friend int CntIndexInit(PGLOBAL, PTDB, int);
- friend RCODE CntIndexRead(PGLOBAL, PTDB, OPVAL, const void*, int, bool);
+ friend RCODE CntIndexRead(PGLOBAL, PTDB, OPVAL, const void*, int);
friend RCODE CntDeleteRow(PGLOBAL, PTDB, bool);
friend int CntIndexRange(PGLOBAL, PTDB, const uchar**, uint*,
bool*, key_part_map*);
diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc
index bb090e925bc..b0b8aeb8c0d 100644
--- a/storage/connect/ha_connect.cc
+++ b/storage/connect/ha_connect.cc
@@ -455,7 +455,6 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg)
creat_query_id= (table && table->in_use) ? table->in_use->query_id : 0;
stop= false;
alter= false;
- mrr= false;
indexing= -1;
locked= 0;
data_file_name= NULL;
@@ -2287,7 +2286,7 @@ int ha_connect::ReadIndexed(uchar *buf, OPVAL op, const uchar *key, uint key_len
//statistic_increment(ha_read_key_count, &LOCK_status);
- switch (CntIndexRead(xp->g, tdbp, op, key, (int)key_len, mrr)) {
+ switch (CntIndexRead(xp->g, tdbp, op, key, (int)key_len)) {
case RC_OK:
xp->fnd++;
rc= MakeRecord((char*)buf);
diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h
index 7d4ef94e6c4..f277209a78c 100644
--- a/storage/connect/ha_connect.h
+++ b/storage/connect/ha_connect.h
@@ -485,7 +485,6 @@ protected:
bool valid_info; // True if xinfo is valid
bool stop; // Used when creating index
bool alter; // True when converting to other engine
- bool mrr; // True when getting index positions
int indexing; // Type of indexing for CONNECT
int locked; // Table lock
THR_LOCK_DATA lock_data;
diff --git a/storage/connect/myconn.cpp b/storage/connect/myconn.cpp
index 13a6f996605..3d0a3d86136 100644
--- a/storage/connect/myconn.cpp
+++ b/storage/connect/myconn.cpp
@@ -1,11 +1,11 @@
/************** MyConn C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: MYCONN */
/* ------------- */
-/* Version 1.7 */
+/* Version 1.8 */
/* */
/* COPYRIGHT: */
/* ---------- */
-/* (C) Copyright to the author Olivier BERTRAND 2007-2013 */
+/* (C) Copyright to the author Olivier BERTRAND 2007-2014 */
/* */
/* WHAT THIS PROGRAM DOES: */
/* ----------------------- */
@@ -47,7 +47,8 @@
#include "myconn.h"
extern "C" int trace;
-extern MYSQL_PLUGIN_IMPORT uint mysqld_port;
+extern MYSQL_PLUGIN_IMPORT uint mysqld_port;
+extern MYSQL_PLUGIN_IMPORT char *mysqld_unix_port;
// Returns the current used port
uint GetDefaultPort(void)
@@ -340,6 +341,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
const char *user, const char *pwd,
int pt)
{
+ const char *pipe = NULL;
uint cto = 60, nrt = 120;
m_DB = mysql_init(NULL);
@@ -356,6 +358,16 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
mysql_options(m_DB, MYSQL_OPT_READ_TIMEOUT, &nrt);
//mysql_options(m_DB, MYSQL_OPT_WRITE_TIMEOUT, ...);
+#if defined(WIN32)
+ if (!strcmp(host, ".")) {
+ mysql_options(m_DB, MYSQL_OPT_NAMED_PIPE, NULL);
+ pipe = mysqld_unix_port;
+ } // endif host
+#else // !WIN32
+ if (!strcmp(host, "localhost"))
+ pipe = mysqld_unix_port;
+#endif // !WIN32
+
#if 0
if (pwd && !strcmp(pwd, "*")) {
if (GetPromptAnswer(g, "*Enter password:")) {
@@ -367,7 +379,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
} // endif pwd
#endif // 0
- if (!mysql_real_connect(m_DB, host, user, pwd, db, pt, NULL, CLIENT_MULTI_RESULTS)) {
+ if (!mysql_real_connect(m_DB, host, user, pwd, db, pt, pipe, CLIENT_MULTI_RESULTS)) {
#if defined(_DEBUG)
sprintf(g->Message, "mysql_real_connect failed: (%d) %s",
mysql_errno(m_DB), mysql_error(m_DB));