Commit bdbe7430 authored by Olivier Bertrand's avatar Olivier Bertrand

- 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
parent 9bf8a685
...@@ -57,7 +57,7 @@ extern "C" int trace; ...@@ -57,7 +57,7 @@ extern "C" int trace;
/* Routines called internally by semantic routines. */ /* Routines called internally by semantic routines. */
/***********************************************************************/ /***********************************************************************/
void CntEndDB(PGLOBAL); 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. */ /* MySQL routines called externally by semantic routines. */
...@@ -387,7 +387,7 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp) ...@@ -387,7 +387,7 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp)
/***********************************************************************/ /***********************************************************************/
/* Evaluate all columns after a record is read. */ /* 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; RCODE rc= RC_OK;
PCOL colp; PCOL colp;
...@@ -706,7 +706,7 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id) ...@@ -706,7 +706,7 @@ int CntIndexInit(PGLOBAL g, PTDB ptdb, int id)
/* IndexRead: fetch a record having the index value. */ /* IndexRead: fetch a record having the index value. */
/***********************************************************************/ /***********************************************************************/
RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op, RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
const void *key, int len, bool mrr) const void *key, int len)
{ {
char *kp= (char*)key; char *kp= (char*)key;
int n; int n;
...@@ -783,7 +783,7 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op, ...@@ -783,7 +783,7 @@ RCODE CntIndexRead(PGLOBAL g, PTDB ptdb, OPVAL op,
xbp->SetNth(0); xbp->SetNth(0);
if ((rc= (RCODE)tdbp->ReadDB(g)) == RC_OK) if ((rc= (RCODE)tdbp->ReadDB(g)) == RC_OK)
rc= EvalColumns(g, tdbp, mrr); rc= EvalColumns(g, tdbp);
return rc; return rc;
} // end of CntIndexRead } // end of CntIndexRead
......
...@@ -36,8 +36,7 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp); ...@@ -36,8 +36,7 @@ bool CntRewindTable(PGLOBAL g, PTDB tdbp);
int CntCloseTable(PGLOBAL g, PTDB tdbp); int CntCloseTable(PGLOBAL g, PTDB tdbp);
int CntIndexInit(PGLOBAL g, PTDB tdbp, int id); int CntIndexInit(PGLOBAL g, PTDB tdbp, int id);
RCODE CntReadNext(PGLOBAL g, PTDB tdbp); RCODE CntReadNext(PGLOBAL g, PTDB tdbp);
RCODE CntIndexRead(PGLOBAL g, PTDB, OPVAL op, const void *k, int n, RCODE CntIndexRead(PGLOBAL g, PTDB, OPVAL op, const void *k, int n);
bool mrr = false);
RCODE CntWriteRow(PGLOBAL g, PTDB tdbp); RCODE CntWriteRow(PGLOBAL g, PTDB tdbp);
RCODE CntUpdateRow(PGLOBAL g, PTDB tdbp); RCODE CntUpdateRow(PGLOBAL g, PTDB tdbp);
RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all); RCODE CntDeleteRow(PGLOBAL g, PTDB tdbp, bool all);
...@@ -61,7 +60,7 @@ class TDBDOX: public TDBDOS { ...@@ -61,7 +60,7 @@ class TDBDOX: public TDBDOS {
friend int MakeIndex(PGLOBAL, PTDB, PIXDEF); friend int MakeIndex(PGLOBAL, PTDB, PIXDEF);
friend int CntCloseTable(PGLOBAL, PTDB); friend int CntCloseTable(PGLOBAL, PTDB);
friend int CntIndexInit(PGLOBAL, PTDB, int); 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 RCODE CntDeleteRow(PGLOBAL, PTDB, bool);
friend int CntIndexRange(PGLOBAL, PTDB, const uchar**, uint*, friend int CntIndexRange(PGLOBAL, PTDB, const uchar**, uint*,
bool*, key_part_map*); bool*, key_part_map*);
......
...@@ -455,7 +455,6 @@ ha_connect::ha_connect(handlerton *hton, TABLE_SHARE *table_arg) ...@@ -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; creat_query_id= (table && table->in_use) ? table->in_use->query_id : 0;
stop= false; stop= false;
alter= false; alter= false;
mrr= false;
indexing= -1; indexing= -1;
locked= 0; locked= 0;
data_file_name= NULL; data_file_name= NULL;
...@@ -2287,7 +2286,7 @@ int ha_connect::ReadIndexed(uchar *buf, OPVAL op, const uchar *key, uint key_len ...@@ -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); //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: case RC_OK:
xp->fnd++; xp->fnd++;
rc= MakeRecord((char*)buf); rc= MakeRecord((char*)buf);
......
...@@ -485,7 +485,6 @@ protected: ...@@ -485,7 +485,6 @@ protected:
bool valid_info; // True if xinfo is valid bool valid_info; // True if xinfo is valid
bool stop; // Used when creating index bool stop; // Used when creating index
bool alter; // True when converting to other engine bool alter; // True when converting to other engine
bool mrr; // True when getting index positions
int indexing; // Type of indexing for CONNECT int indexing; // Type of indexing for CONNECT
int locked; // Table lock int locked; // Table lock
THR_LOCK_DATA lock_data; THR_LOCK_DATA lock_data;
......
/************** MyConn C++ Program Source Code File (.CPP) **************/ /************** MyConn C++ Program Source Code File (.CPP) **************/
/* PROGRAM NAME: MYCONN */ /* PROGRAM NAME: MYCONN */
/* ------------- */ /* ------------- */
/* Version 1.7 */ /* Version 1.8 */
/* */ /* */
/* COPYRIGHT: */ /* COPYRIGHT: */
/* ---------- */ /* ---------- */
/* (C) Copyright to the author Olivier BERTRAND 2007-2013 */ /* (C) Copyright to the author Olivier BERTRAND 2007-2014 */
/* */ /* */
/* WHAT THIS PROGRAM DOES: */ /* WHAT THIS PROGRAM DOES: */
/* ----------------------- */ /* ----------------------- */
...@@ -47,7 +47,8 @@ ...@@ -47,7 +47,8 @@
#include "myconn.h" #include "myconn.h"
extern "C" int trace; 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 // Returns the current used port
uint GetDefaultPort(void) uint GetDefaultPort(void)
...@@ -340,6 +341,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, ...@@ -340,6 +341,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
const char *user, const char *pwd, const char *user, const char *pwd,
int pt) int pt)
{ {
const char *pipe = NULL;
uint cto = 60, nrt = 120; uint cto = 60, nrt = 120;
m_DB = mysql_init(NULL); m_DB = mysql_init(NULL);
...@@ -356,6 +358,16 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, ...@@ -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_READ_TIMEOUT, &nrt);
//mysql_options(m_DB, MYSQL_OPT_WRITE_TIMEOUT, ...); //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 0
if (pwd && !strcmp(pwd, "*")) { if (pwd && !strcmp(pwd, "*")) {
if (GetPromptAnswer(g, "*Enter password:")) { if (GetPromptAnswer(g, "*Enter password:")) {
...@@ -367,7 +379,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db, ...@@ -367,7 +379,7 @@ int MYSQLC::Open(PGLOBAL g, const char *host, const char *db,
} // endif pwd } // endif pwd
#endif // 0 #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) #if defined(_DEBUG)
sprintf(g->Message, "mysql_real_connect failed: (%d) %s", sprintf(g->Message, "mysql_real_connect failed: (%d) %s",
mysql_errno(m_DB), mysql_error(m_DB)); mysql_errno(m_DB), mysql_error(m_DB));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment