示例#1
0
TABLE_SHARE *GetTableShare(PGLOBAL g, THD *thd, const char *db, 
                                      const char *name, bool& mysql)
{
  char         key[256];
  uint         k;
//TABLE_LIST   table_list;
  TABLE_SHARE *s;

//table_list.init_one_table(db, strlen(db), name, strlen(name),
//                          NULL, TL_IGNORE);
	k = sprintf(key, "%s", db) + 1;
	k += sprintf(key + k, "%s", name);
  key[++k] = 0;

	if (!(s = alloc_table_share(db, name, key, ++k))) {
    strcpy(g->Message, "Error allocating share\n");
    return NULL;
    } // endif s

//        1           2          4            8 
//flags = GTS_TABLE | GTS_VIEW | GTS_NOLOCK | GTS_FORCE_DISCOVERY;

  if (!open_table_def(thd, s, GTS_TABLE | GTS_VIEW)) {
    if (!s->is_view) {
      if (stricmp(plugin_name(s->db_plugin)->str, "connect")) {
#if defined(MYSQL_SUPPORT)
        mysql = true;
#else   // !MYSQL_SUPPORT
        sprintf(g->Message, "%s.%s is not a CONNECT table", db, name);
        return NULL;
#endif   // MYSQL_SUPPORT
      } else
        mysql = false;

    } else {
      mysql = true;
    } // endif is_view

  } else {
    sprintf(g->Message, "Error %d opening share\n", s->error);
    free_table_share(s);
    return NULL;
  } // endif open_table_def

  return s;
} // end of GetTableShare
示例#2
0
TABLE_SHARE *mrn_create_tmp_table_share(TABLE_LIST *table_list, const char *path,
                                        int *error)
{
  uint key_length;
  TABLE_SHARE *share;
  THD *thd = current_thd;

  MRN_DBUG_ENTER_FUNCTION();
#ifdef MRN_HAVE_GET_TABLE_DEF_KEY
  const char *key;
  key_length = get_table_def_key(table_list, &key);
#else
  char key[MAX_DBKEY_LENGTH];
  key_length = create_table_def_key(thd, key, table_list, FALSE);
#endif
#if MYSQL_VERSION_ID >= 100002 && defined(MRN_MARIADB_P)
  share = alloc_table_share(table_list->db, table_list->table_name, key,
                            key_length);
#else
  share = alloc_table_share(table_list, key, key_length);
#endif
  if (!share)
  {
    *error = ER_CANT_OPEN_FILE;
    DBUG_RETURN(NULL);
  }
  share->tmp_table = INTERNAL_TMP_TABLE; // TODO: is this right?
  share->path.str = (char *) path;
  share->path.length = strlen(share->path.str);
  share->normalized_path.str = mrn_my_strdup(path, MYF(MY_WME));
  share->normalized_path.length = strlen(share->normalized_path.str);
  if (open_table_def(thd, share, GTS_TABLE))
  {
    *error = ER_CANT_OPEN_FILE;
    DBUG_RETURN(NULL);
  }
  DBUG_RETURN(share);
}