2078
static void my_close_table(STRUCT_TABLE *table)
2081
#if 0 // Removed by Brian
2084
share = (TABLE_SHARE *) ((char *) table + sizeof(TABLE));
2085
share->free_table_share();
2088
delete_table(table, true); // TODO: Q, why did Stewart remove this?
2094
* This function returns NULL if the table cannot be opened
2095
* because this is not a MySQL thread.
2097
static STRUCT_TABLE *my_open_table(XTThreadPtr self, XTDatabaseHPtr XT_UNUSED(db), XTPathStrPtr tab_path, xtWord1 table_type)
2099
THD *thd = current_thd;
2100
char path_buffer[PATH_MAX];
2102
char database_name[XT_IDENTIFIER_NAME_SIZE];
2104
char *buffer, *path, *db_name, *name;
2109
/* If we have no MySQL thread, then we cannot open this table!
2110
* What this means is the thread is probably the sweeper or the
2116
/* GOTCHA: Check if the table name is a partitian,
2117
* if so we need to remove the partition
2118
* extension, in order for this to work!
2120
* Reason: the parts of a partition table do not
2123
xt_strcpy(PATH_MAX, path_buffer, tab_path->ps_path);
2124
table_name = xt_last_name_of_path(path_buffer);
2128
if ((ptr = strstr(table_name, "#P#")))
2132
xt_2nd_last_name_of_path(XT_IDENTIFIER_NAME_SIZE, database_name, path_buffer);
2134
size = sizeof(TABLE) + sizeof(TABLE_SHARE) +
2135
strlen(path_buffer) + 1 +
2136
strlen(database_name) + 1 + strlen(table_name) + 1;
2137
if (!(buffer = (char *) xt_malloc(self, size)))
2139
table = (TABLE *) buffer;
2140
buffer += sizeof(TABLE);
2141
share = (TABLE_SHARE *) buffer;
2142
buffer += sizeof(TABLE_SHARE);
2145
strcpy(path, path_buffer);
2146
buffer += strlen(path_buffer) + 1;
2148
strcpy(db_name, database_name);
2149
buffer += strlen(database_name) + 1;
2151
strcpy(name, table_name);
2153
/* Required to call 'open_table_from_share'! */
2154
LEX *old_lex, new_lex;
2157
thd->lex = &new_lex;
2158
new_lex.current_select= NULL;
2162
char tab_name[XT_IDENTIFIER_NAME_SIZE];
2164
uint32_t tab_name_len = TableIdentifier::filename_to_tablename(name, tab_name, XT_IDENTIFIER_NAME_SIZE);
2166
TableIdentifier *ident = NULL;
2167
if (table_type == XT_TABLE_TYPE_TEMPORARY) {
2168
std::string tmp_path(drizzle_tmpdir);
2169
tmp_path.append("/");
2170
tmp_path.append(table_name);
2171
ident = new TableIdentifier(db_name, tab_name, tmp_path);
2172
} else if (table_type == XT_TABLE_TYPE_STANDARD) {
2173
ident = new TableIdentifier(
2174
std::string(db_name),
2175
std::string(tab_name, tab_name_len),
2176
message::Table::STANDARD);
2179
n.append(data_home);
2183
n.append(table_name);
2184
//ident = new TableIdentifier(
2185
// std::string(db_name),
2186
// std::string(tab_name, tab_name_len),
2187
// message::Table::INTERNAL);
2188
ident = new TableIdentifier(db_name, tab_name, n);
2190
share->init(db_name, 0, name, path);
2191
if ((error = share->open_table_def(*thd, *ident)) ||
2192
(error = share->open_table_from_share(thd, "", 0, 0, *table)))
2194
xt_free(self, table);
2197
xt_throw_sulxterr(XT_CONTEXT, XT_ERR_LOADING_MYSQL_DIC, tab_path->ps_path, (u_long) error);
2203
#if MYSQL_VERSION_ID < 60000
2204
#if MYSQL_VERSION_ID < 50123
2205
init_tmp_table_share(share, db_name, 0, name, path);
2207
init_tmp_table_share(thd, share, db_name, 0, name, path);
2210
#if MYSQL_VERSION_ID < 60004
2211
init_tmp_table_share(share, db_name, 0, name, path);
2213
init_tmp_table_share(thd, share, db_name, 0, name, path);
2217
/* If MySQL shutsdown while we are just starting up, they
2218
* they kill the plugin sub-system before calling
2219
* shutdown for the engine!
2221
if (!ha_resolve_by_legacy_type(thd, DB_TYPE_PBXT)) {
2222
xt_free(self, table);
2225
xt_throw_xterr(XT_CONTEXT, XT_ERR_MYSQL_SHUTDOWN);
2229
if ((error = open_table_def(thd, share, 0))) {
2230
xt_free(self, table);
2233
xt_throw_sulxterr(XT_CONTEXT, XT_ERR_LOADING_MYSQL_DIC, tab_path->ps_path, (u_long) error);
2237
#if MYSQL_VERSION_ID >= 50404
2238
if ((error = open_table_from_share(thd, share, "", 0, (uint) READ_ALL, 0, table, OTM_OPEN)))
2240
if ((error = open_table_from_share(thd, share, "", 0, (uint) READ_ALL, 0, table, FALSE)))
2243
xt_free(self, table);
2246
xt_throw_sulxterr(XT_CONTEXT, XT_ERR_LOADING_MYSQL_DIC, tab_path->ps_path, (u_long) error);
2254
/* GOTCHA: I am the plug-in!!! Therefore, I should not hold
2255
* a reference to myself. By holding this reference I prevent
2256
* plugin_shutdown() and reap_plugins() in sql_plugin.cc
2257
* from doing their job on shutdown!
2260
plugin_unlock(NULL, table->s->db_plugin);
2261
table->s->db_plugin = NULL;
2054
2268
static bool my_match_index(XTDDIndex *ind, KEY *index)
2056
KEY_PART_INFO *key_part;
2057
KEY_PART_INFO *key_part_end;
2270
KeyPartInfo *key_part;
2271
KeyPartInfo *key_part_end;
2059
2273
XTDDColumnRef *cref;