Commit f2e14736 authored by Alexander Barkov's avatar Alexander Barkov

Removing direct access to thd, using functions:

- thd_query_string() insted of thd->query_string
- thd_sql_command() instead ot thd->lex->sql_command
- table_share->s.db.str instead of thd->db

modified:
  storage/connect/connect.cc
  storage/connect/ha_connect.cc
parent 33b95315
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
/* global.h is header containing all global declarations. */ /* global.h is header containing all global declarations. */
/* plgdbsem.h is header containing the DB applic. declarations. */ /* plgdbsem.h is header containing the DB applic. declarations. */
/***********************************************************************/ /***********************************************************************/
#define MYSQL_SERVER 1
#define DONT_DEFINE_VOID #define DONT_DEFINE_VOID
#include "handler.h" #include "handler.h"
#undef OFFSET #undef OFFSET
......
...@@ -2794,6 +2794,8 @@ int ha_connect::external_lock(THD *thd, int lock_type) ...@@ -2794,6 +2794,8 @@ int ha_connect::external_lock(THD *thd, int lock_type)
PGLOBAL g= GetPlug(thd, xp); PGLOBAL g= GetPlug(thd, xp);
DBUG_ENTER("ha_connect::external_lock"); DBUG_ENTER("ha_connect::external_lock");
DBUG_ASSERT(thd == current_thd);
if (xtrace) if (xtrace)
printf("%p external_lock: lock_type=%d\n", this, lock_type); printf("%p external_lock: lock_type=%d\n", this, lock_type);
...@@ -2914,16 +2916,16 @@ int ha_connect::external_lock(THD *thd, int lock_type) ...@@ -2914,16 +2916,16 @@ int ha_connect::external_lock(THD *thd, int lock_type)
} // endif MODE_ANY } // endif MODE_ANY
if (xtrace) { if (xtrace) {
printf("%p external_lock: cmdtype=%d\n", this, thd->lex->sql_command); LEX_STRING *query_string= thd_query_string(thd);
printf("Cmd=%.*s\n", (int) thd->query_string.length(), printf("%p external_lock: cmdtype=%d\n", this, thd_sql_command(thd));
thd->query_string.str()); printf("Cmd=%.*s\n", (int) query_string->length, query_string->str);
} // endif xtrace } // endif xtrace
// Next code is temporarily replaced until sql_command is set // Next code is temporarily replaced until sql_command is set
stop= false; stop= false;
if (newmode == MODE_WRITE) { if (newmode == MODE_WRITE) {
switch (thd->lex->sql_command) { switch (thd_sql_command(thd)) {
case SQLCOM_CREATE_TABLE: case SQLCOM_CREATE_TABLE:
case SQLCOM_INSERT: case SQLCOM_INSERT:
case SQLCOM_LOAD: case SQLCOM_LOAD:
...@@ -2963,13 +2965,13 @@ int ha_connect::external_lock(THD *thd, int lock_type) ...@@ -2963,13 +2965,13 @@ int ha_connect::external_lock(THD *thd, int lock_type)
newmode= MODE_ANY; newmode= MODE_ANY;
break; break;
default: default:
printf("Unsupported sql_command=%d", thd->lex->sql_command); printf("Unsupported sql_command=%d", thd_sql_command(thd));
sprintf(g->Message, "Unsupported sql_command=%d", thd->lex->sql_command); sprintf(g->Message, "Unsupported sql_command=%d", thd_sql_command(thd));
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
} // endswitch newmode } // endswitch newmode
} else if (newmode == MODE_READ) { } else if (newmode == MODE_READ) {
switch (thd->lex->sql_command) { switch (thd_sql_command(thd)) {
case SQLCOM_CREATE_TABLE: case SQLCOM_CREATE_TABLE:
xcheck= true; xcheck= true;
cras= true; cras= true;
...@@ -3000,8 +3002,8 @@ int ha_connect::external_lock(THD *thd, int lock_type) ...@@ -3000,8 +3002,8 @@ int ha_connect::external_lock(THD *thd, int lock_type)
newmode= MODE_ANY; newmode= MODE_ANY;
break; break;
default: default:
printf("Unsupported sql_command=%d", thd->lex->sql_command); printf("Unsupported sql_command=%d", thd_sql_command(thd));
sprintf(g->Message, "Unsupported sql_command=%d", thd->lex->sql_command); sprintf(g->Message, "Unsupported sql_command=%d", thd_sql_command(thd));
DBUG_RETURN(HA_ERR_INTERNAL_ERROR); DBUG_RETURN(HA_ERR_INTERNAL_ERROR);
} // endswitch newmode } // endswitch newmode
...@@ -3387,7 +3389,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ...@@ -3387,7 +3389,6 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL); uint tm, fnc= FNC_NO, supfnc= (FNC_NO | FNC_COL);
bool bif, ok= false, dbf= false; bool bif, ok= false, dbf= false;
TABTYPE ttp= TAB_UNDEF; TABTYPE ttp= TAB_UNDEF;
MEM_ROOT *mem= thd->mem_root;
PQRYRES qrp; PQRYRES qrp;
PCOLRES crp; PCOLRES crp;
PGLOBAL g= GetPlug(thd, NULL); PGLOBAL g= GetPlug(thd, NULL);
...@@ -3436,7 +3437,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ...@@ -3436,7 +3437,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
} // endif option_list } // endif option_list
if (!db) if (!db)
db= thd->db; // Default value db= table_s->db.str; // Default value
// Check table type // Check table type
if (ttp == TAB_UNDEF) { if (ttp == TAB_UNDEF) {
...@@ -3568,7 +3569,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, ...@@ -3568,7 +3569,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd,
PCATLG cat= (dup) ? dup->Catalog : NULL; PCATLG cat= (dup) ? dup->Catalog : NULL;
if (cat) if (cat)
cat->SetDataPath(g, thd->db); cat->SetDataPath(g, table_s->db.str);
else else
return HA_ERR_INTERNAL_ERROR; // Should never happen return HA_ERR_INTERNAL_ERROR; // Should never happen
...@@ -3907,7 +3908,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, ...@@ -3907,7 +3908,7 @@ int ha_connect::create(const char *name, TABLE *table_arg,
push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message);
} else if (options->tabname) { } else if (options->tabname) {
if (!stricmp(options->tabname, create_info->alias) && if (!stricmp(options->tabname, create_info->alias) &&
(!options->dbname || !stricmp(options->dbname, thd->db))) { (!options->dbname || !stricmp(options->dbname, table_arg->s->db.str))) {
sprintf(g->Message, "A %s table cannot refer to itself", sprintf(g->Message, "A %s table cannot refer to itself",
options->type); options->type);
my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0));
......
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