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;
/* 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
......
......@@ -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*);
......
......@@ -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);
......
......@@ -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;
......
/************** 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));
......
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