diff options
-rw-r--r-- | storage/connect/csort.cpp | 1 | ||||
-rw-r--r-- | storage/connect/filamfix.cpp | 1 | ||||
-rw-r--r-- | storage/connect/ha_connect.cc | 91 | ||||
-rw-r--r-- | storage/connect/ha_connect.h | 17 | ||||
-rw-r--r-- | storage/connect/inihandl.c | 1 | ||||
-rw-r--r-- | storage/connect/osutil.h | 2 | ||||
-rw-r--r-- | storage/connect/taboccur.cpp | 2 | ||||
-rw-r--r-- | storage/connect/tabpivot.cpp | 2 | ||||
-rw-r--r-- | storage/connect/tabtbl.cpp | 2 | ||||
-rw-r--r-- | storage/connect/tabxcl.cpp | 2 | ||||
-rw-r--r-- | storage/connect/value.cpp | 7 |
11 files changed, 56 insertions, 72 deletions
diff --git a/storage/connect/csort.cpp b/storage/connect/csort.cpp index 0f4818d47b6..4a49666c914 100644 --- a/storage/connect/csort.cpp +++ b/storage/connect/csort.cpp @@ -56,6 +56,7 @@ #include "global.h" #include "plgdbsem.h" /* For MBLOCK type definition */ #include "csort.h" /* CSort class definition */ +#include "osutil.h" #if !defined(BIGSORT) #define BIGSORT 200000 diff --git a/storage/connect/filamfix.cpp b/storage/connect/filamfix.cpp index d493a2f2568..a92d9766933 100644 --- a/storage/connect/filamfix.cpp +++ b/storage/connect/filamfix.cpp @@ -46,6 +46,7 @@ #include "plgdbsem.h" #include "filamfix.h" #include "tabdos.h" +#include "osutil.h" #ifndef INVALID_SET_FILE_POINTER #define INVALID_SET_FILE_POINTER 0xFFFFFFFF diff --git a/storage/connect/ha_connect.cc b/storage/connect/ha_connect.cc index 3325d39f1d8..265eb520744 100644 --- a/storage/connect/ha_connect.cc +++ b/storage/connect/ha_connect.cc @@ -265,7 +265,7 @@ bool PushWarning(PGLOBAL g, PTDBASE tdbp) !(thd= (phc->GetTable())->in_use)) return true; - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); return false; } // end of PushWarning @@ -414,51 +414,25 @@ static int connect_done_func(void *p) they are needed to function. */ -static CONNECT_SHARE *get_share(const char *table_name, TABLE *table) +CONNECT_SHARE *ha_connect::get_share() { - CONNECT_SHARE *share; - uint length; - char *tmp_name; - - length=(uint) strlen(table_name); - - if (!(share= (CONNECT_SHARE *)table->s->ha_data)) { - if (!(share= (CONNECT_SHARE *)alloc_root(&table->s->mem_root, sizeof(*share) + length + 1))) - return NULL; - bzero(share, sizeof(*share)); - tmp_name= (char*)(share + 1); - - share->table_name_length=length; - share->table_name=tmp_name; - strmov(share->table_name, table_name); - - thr_lock_init(&share->lock); + CONNECT_SHARE *tmp_share; + lock_shared_ha_data(); + if (!(tmp_share= static_cast<CONNECT_SHARE*>(get_ha_share_ptr()))) + { + tmp_share= new CONNECT_SHARE; + if (!tmp_share) + goto err; mysql_mutex_init(con_key_mutex_CONNECT_SHARE_mutex, - &share->mutex, MY_MUTEX_INIT_FAST); - } // endif share - - share->use_count++; - return share; + &tmp_share->mutex, MY_MUTEX_INIT_FAST); + set_ha_share_ptr(static_cast<Handler_share*>(tmp_share)); + } +err: + unlock_shared_ha_data(); + return tmp_share; } -/** - @brief - Free lock controls. We call this whenever we close a table. If the table had - the last reference to the share, then we free memory associated with it. -*/ - -static int free_share(CONNECT_SHARE *share) -{ - if (!--share->use_count) { - thr_lock_delete(&share->lock); - mysql_mutex_destroy(&share->mutex); - TRASH(share, sizeof(*share)); - } // endif share - - return 0; -} - static handler* connect_create_handler(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root) @@ -1017,7 +991,7 @@ PIXDEF ha_connect::GetIndexInfo(void) xdp= new(g) INDEXDEF(name, unique, n); // Get the the key parts info - for (int k= 0; (unsigned)k < kp.key_parts; k++) { + for (int k= 0; (unsigned)k < kp.user_defined_key_parts; k++) { pn= (char*)kp.key_part[k].field->field_name; name= (char*)PlugSubAlloc(g, NULL, strlen(pn) + 1); strcpy(name, pn); // This is probably unuseful @@ -1029,7 +1003,7 @@ PIXDEF ha_connect::GetIndexInfo(void) #if 0 // NIY // Index on auto increment column can be an XXROW index if (kp.key_part[k].field->flags & AUTO_INCREMENT_FLAG && - kp.key_parts == 1) { + kp.uder_defined_key_parts == 1) { char *type= GetStringOption("Type", "DOS"); TABTYPE typ= GetTypeID(type); @@ -1045,7 +1019,7 @@ PIXDEF ha_connect::GetIndexInfo(void) pkp= kpp; } // endfor k - xdp->SetNParts(kp.key_parts); + xdp->SetNParts(kp.user_defined_key_parts); if (pxd) pxd->SetNext(xdp); @@ -1875,7 +1849,7 @@ int ha_connect::open(const char *name, int mode, uint test_if_locked) if (xtrace) printf("open: name=%s mode=%d test=%ud\n", name, mode, test_if_locked); - if (!(share= get_share(name, table))) + if (!(share= get_share())) DBUG_RETURN(1); thr_lock_data_init(&share->lock,&lock,NULL); @@ -1914,7 +1888,7 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT* check_opt) rc= HA_ERR_INTERNAL_ERROR; } else if ((rc= ((PTDBASE)tdbp)->ResetTableOpt(g, true))) { if (rc == RC_INFO) { - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); rc= 0; } else rc = HA_ERR_INTERNAL_ERROR; @@ -1929,8 +1903,7 @@ int ha_connect::optimize(THD* thd, HA_CHECK_OPT* check_opt) /** @brief - Closes a table. We call the free_share() function to free any resources - that we have allocated in the "shared" structure. + Closes a table. @details Called from sql_base.cc, sql_select.cc, and table.cc. In sql_select.cc it is @@ -1952,7 +1925,7 @@ int ha_connect::close(void) if (tdbp && xp->last_query_id == valid_query_id) rc= CloseTable(xp->g); - DBUG_RETURN(free_share(share) || rc); + DBUG_RETURN(rc); } // end of close @@ -2939,7 +2912,7 @@ int ha_connect::external_lock(THD *thd, int lock_type) // This is an error while builing index #if defined(_DEBUG) // Make it a warning to avoid crash - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); rc= 0; #else // !_DEBUG my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); @@ -3494,7 +3467,7 @@ static int connect_assisted_discovery(handlerton *hton, THD* thd, topt->type= (src) ? "MYSQL" : (tab) ? "PROXY" : "DOS"; ttp= GetTypeID(topt->type); sprintf(g->Message, "No table_type. Was set to %s", topt->type); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); } else if (ttp == TAB_NIY) { sprintf(g->Message, "Unsupported table type %s", topt->type); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); @@ -3936,7 +3909,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, (options->tabname) ? "PROXY" : "DOS"; type= GetTypeID(options->type); sprintf(g->Message, "No table_type. Will be set to %s", options->type); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); } else if (type == TAB_NIY) { sprintf(g->Message, "Unsupported table type %s", options->type); my_message(ER_UNKNOWN_ERROR, g->Message, MYF(0)); @@ -3979,7 +3952,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, case TAB_OCCUR: if (options->srcdef) { strcpy(g->Message, "Cannot check looping reference"); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); } else if (options->tabname) { if (!stricmp(options->tabname, create_info->alias) && (!options->dbname || !stricmp(options->dbname, table_arg->s->db.str))) { @@ -4178,7 +4151,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, strcat(strcat(buf, "."), lwt); sprintf(g->Message, "No file name. Table will use %s", buf); - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, g->Message); strcat(strcat(strcpy(dbpath, "./"), table->s->db.str), "/"); PlugSetPath(fn, buf, dbpath); @@ -4189,12 +4162,12 @@ int ha_connect::create(const char *name, TABLE *table_arg, sprintf(g->Message, "Error %d creating file %s", errno, fn); push_warning(table->in_use, - MYSQL_ERROR::WARN_LEVEL_WARN, 0, g->Message); + Sql_condition::WARN_LEVEL_WARN, 0, g->Message); } else ::close(h); if (type == TAB_FMT || options->readonly) - push_warning(table->in_use, MYSQL_ERROR::WARN_LEVEL_WARN, 0, + push_warning(table->in_use, Sql_condition::WARN_LEVEL_WARN, 0, "Congratulation, you just created a read-only void table!"); } // endif buf @@ -4207,7 +4180,7 @@ int ha_connect::create(const char *name, TABLE *table_arg, // We should be in CREATE TABLE if (thd_sql_command(table->in_use) != SQLCOM_CREATE_TABLE) - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, "Wrong command in create, please contact CONNECT team"); // Get the index definitions @@ -4260,7 +4233,7 @@ bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *info, // TO DO: really implement and check it. THD *thd= current_thd; - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, "The current version of CONNECT did not check what you changed in ALTER. Use at your own risk"); if (table) { @@ -4273,7 +4246,7 @@ bool ha_connect::check_if_incompatible_data(HA_CREATE_INFO *info, PGLOBAL g= GetPlug(thd); if (!g) - push_warning(thd, MYSQL_ERROR::WARN_LEVEL_WARN, 0, + push_warning(thd, Sql_condition::WARN_LEVEL_WARN, 0, "Execute OPTIMIZE TABLE to remake the indexes"); else g->Xchk= new(g) XCHK; diff --git a/storage/connect/ha_connect.h b/storage/connect/ha_connect.h index abf82b2d1a8..d248b351081 100644 --- a/storage/connect/ha_connect.h +++ b/storage/connect/ha_connect.h @@ -123,12 +123,20 @@ struct ha_field_option_struct CONNECT_SHARE is a structure that will be shared among all open handlers. This example implements the minimum of what you will probably need. */ -typedef struct st_connect_share { - char *table_name; - uint table_name_length, use_count; +class CONNECT_SHARE : public Handler_share { +public: mysql_mutex_t mutex; THR_LOCK lock; -} CONNECT_SHARE; + CONNECT_SHARE() + { + thr_lock_init(&lock); + } + ~CONNECT_SHARE() + { + thr_lock_delete(&lock); + mysql_mutex_destroy(&mutex); + } +}; typedef class ha_connect *PHC; @@ -139,6 +147,7 @@ class ha_connect: public handler { THR_LOCK_DATA lock; ///< MySQL lock CONNECT_SHARE *share; ///< Shared lock info + CONNECT_SHARE *get_share(); public: ha_connect(handlerton *hton, TABLE_SHARE *table_arg); diff --git a/storage/connect/inihandl.c b/storage/connect/inihandl.c index 0dc7a53faf3..f0637155f2d 100644 --- a/storage/connect/inihandl.c +++ b/storage/connect/inihandl.c @@ -29,6 +29,7 @@ //#include <sys/types.h> //#include <memory.h> #include "my_global.h" +#include "osutil.h" #include "global.h" #include "inihandl.h" diff --git a/storage/connect/osutil.h b/storage/connect/osutil.h index 63a3e18084c..a6bdb5521b8 100644 --- a/storage/connect/osutil.h +++ b/storage/connect/osutil.h @@ -9,7 +9,6 @@ #define MB_OK 0x00000000 -#if defined(__cplusplus) #if !defined(__MINMAX_DEFINED) #define __MINMAX_DEFINED #ifndef max @@ -19,7 +18,6 @@ #define min(x,y) (((x)<(y))?(x):(y)) #endif #endif -#endif /* __cplusplus */ #ifdef __cplusplus extern "C" { diff --git a/storage/connect/taboccur.cpp b/storage/connect/taboccur.cpp index 478edb14f9e..f0a5a1c38f0 100644 --- a/storage/connect/taboccur.cpp +++ b/storage/connect/taboccur.cpp @@ -12,6 +12,7 @@ /* Include relevant section of system dependant header files. */ /***********************************************************************/ #include "my_global.h" +#include "table.h" // MySQL table definitions #if defined(WIN32) #include <stdlib.h> #include <stdio.h> @@ -36,7 +37,6 @@ /***********************************************************************/ /* Include application header files: */ /***********************************************************************/ -#include "table.h" // MySQL table definitions #include "global.h" #include "plgdbsem.h" #include "reldef.h" diff --git a/storage/connect/tabpivot.cpp b/storage/connect/tabpivot.cpp index 9beca56e773..c28091df34f 100644 --- a/storage/connect/tabpivot.cpp +++ b/storage/connect/tabpivot.cpp @@ -16,6 +16,7 @@ /* Include relevant sections of the operating system header file. */ /***********************************************************************/ #include "my_global.h" +#include "table.h" // MySQL table definitions #if defined(WIN32) #if defined(__BORLANDC__) #define __MFC_COMPAT__ // To define min/max as macro @@ -35,7 +36,6 @@ /* plgdbsem.h is header containing the DB application declarations. */ /***********************************************************************/ #define FRM_VER 6 -#include "table.h" // MySQL table definitions #include "sql_const.h" #include "field.h" #include "global.h" diff --git a/storage/connect/tabtbl.cpp b/storage/connect/tabtbl.cpp index 6b90b3861aa..534834350af 100644 --- a/storage/connect/tabtbl.cpp +++ b/storage/connect/tabtbl.cpp @@ -38,6 +38,7 @@ /***********************************************************************/ //#include "sql_base.h" #include "my_global.h" +#include "table.h" // MySQL table definitions #if defined(WIN32) #include <stdlib.h> #include <stdio.h> @@ -62,7 +63,6 @@ /***********************************************************************/ /* Include application header files: */ /***********************************************************************/ -#include "table.h" // MySQL table definitions #include "global.h" // global declarations #include "plgdbsem.h" // DB application declarations #include "reldef.h" // DB definition declares diff --git a/storage/connect/tabxcl.cpp b/storage/connect/tabxcl.cpp index 96da0571271..eb9e9c0e4dc 100644 --- a/storage/connect/tabxcl.cpp +++ b/storage/connect/tabxcl.cpp @@ -16,6 +16,7 @@ /* Include relevant section of system dependant header files. */ /***********************************************************************/ #include "my_global.h" +#include "table.h" // MySQL table definitions #if defined(WIN32) #include <stdlib.h> #include <stdio.h> @@ -40,7 +41,6 @@ /***********************************************************************/ /* Include application header files: */ /***********************************************************************/ -#include "table.h" // MySQL table definitions #include "global.h" #include "plgdbsem.h" #include "plgcnx.h" // For DB types diff --git a/storage/connect/value.cpp b/storage/connect/value.cpp index e75a6e41557..10e3be7e889 100644 --- a/storage/connect/value.cpp +++ b/storage/connect/value.cpp @@ -27,6 +27,9 @@ /* Include relevant MariaDB header file. */ /***********************************************************************/ #include "my_global.h" +#include "sql_class.h" +#include "sql_time.h" + #if defined(WIN32) //#include <windows.h> #else // !WIN32 @@ -49,6 +52,7 @@ #include "valblk.h" #define NO_FUNC // Already defined in ODBConn #include "plgcnx.h" // For DB types +#include "osutil.h" /***********************************************************************/ /* Check macro's. */ @@ -1249,9 +1253,6 @@ void DTVAL::SetTimeShift(void) /* though the gmtime C function. The purpose of this function is to */ /* extend the range of valid dates by accepting negative time values. */ /***********************************************************************/ -#include "sql_class.h" -#include "sql_time.h" - static void TIME_to_localtime(struct tm *tm, const MYSQL_TIME *ltime) { bzero(tm, sizeof(*tm)); |