<commit_before>/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */


/* Handler-calling-functions */

#ifdef __GNUC__
#pragma implementation				// gcc: Class implementation
#endif

#include "mysql_priv.h"
#include "ha_heap.h"
#include "ha_myisam.h"
#include "ha_myisammrg.h"
#ifdef HAVE_ISAM
#include "ha_isam.h"
#include "ha_isammrg.h"
#endif
#ifdef HAVE_BERKELEY_DB
#include "ha_berkeley.h"
#endif
#ifdef HAVE_INNOBASE_DB
#include "ha_innodb.h"
#else
#define innobase_query_caching_of_table_permitted(X,Y,Z) 1
#endif
#include <myisampack.h>
#include <errno.h>

	/* static functions defined in this file */

static int NEAR_F delete_file(const char *name,const char *ext,int extflag);

ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count,
      ha_read_key_count, ha_read_next_count, ha_read_prev_count,
      ha_read_first_count, ha_read_last_count,
      ha_commit_count, ha_rollback_count,
      ha_read_rnd_count, ha_read_rnd_next_count;

const char *ha_table_type[] = {
  "", "DIAB_ISAM","HASH","MISAM","PISAM","RMS_ISAM","HEAP", "ISAM",
  "MRG_ISAM","MYISAM", "MRG_MYISAM", "BDB", "INNODB", "GEMINI", "?", "?",NullS
};

TYPELIB ha_table_typelib=
{
  array_elements(ha_table_type)-3, "", ha_table_type
};

const char *ha_row_type[] = {
  "", "FIXED", "DYNAMIC", "COMPRESSED","?","?","?"
};

const char *tx_isolation_names[] =
{ "READ-UNCOMMITTED", "READ-COMMITTED", "REPEATABLE-READ", "SERIALIZABLE",
  NullS};
TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names)-1,"",
			       tx_isolation_names};

enum db_type ha_resolve_by_name(char *name, uint namelen)
{
  enum db_type result = DB_TYPE_UNKNOWN;
  if (!my_strcasecmp(&my_charset_latin1, name, "HEAP") ||
      !my_strcasecmp(&my_charset_latin1, name, "MEMORY")) {
    result = DB_TYPE_HEAP;
  } else
  if (!my_strcasecmp(&my_charset_latin1, name, "MRG_MYISAM") ||
      !my_strcasecmp(&my_charset_latin1, name, "MERGE")) {
    result = DB_TYPE_MRG_MYISAM;
  } else
  if (!my_strcasecmp(&my_charset_latin1, name, "MYISAM")) {
    result = DB_TYPE_MYISAM;
  } else
  if (!my_strcasecmp(&my_charset_latin1, name, "BDB") ||
      !my_strcasecmp(&my_charset_latin1, name, "BERKELEYDB")) {
    result = DB_TYPE_BERKELEY_DB;
  } else
  if (!my_strcasecmp(&my_charset_latin1, name, "INNODB") ||
      !my_strcasecmp(&my_charset_latin1, name, "INNOBASE")) {
    result = DB_TYPE_INNODB;
  } else
  if (!my_strcasecmp(&my_charset_latin1, name, "ISAM")) {
    result = DB_TYPE_ISAM;
  } else
  if (!my_strcasecmp(&my_charset_latin1, name, "DEFAULT")) {
    result = (enum db_type) current_thd->variables.table_type;
  }
  return result;
}

	/* Use other database handler if databasehandler is not incompiled */

enum db_type ha_checktype(enum db_type database_type)
{
  switch (database_type) {
#ifdef HAVE_BERKELEY_DB
  case DB_TYPE_BERKELEY_DB:
    if (berkeley_skip) break;
    return (database_type);
#endif
#ifdef HAVE_INNOBASE_DB
  case DB_TYPE_INNODB:
    if (innodb_skip) break;
    return (database_type);
#endif
#ifndef NO_HASH
  case DB_TYPE_HASH:
#endif
#ifdef HAVE_ISAM
  case DB_TYPE_ISAM:
    if (isam_skip) break;
    return (database_type);
  case DB_TYPE_MRG_ISAM:
    return (isam_skip ? DB_TYPE_MRG_MYISAM : database_type);
#else
  case DB_TYPE_MRG_ISAM:
    return (DB_TYPE_MRG_MYISAM);
#endif
  case DB_TYPE_HEAP:
  case DB_TYPE_MYISAM:
  case DB_TYPE_MRG_MYISAM:
    return (database_type);			/* Database exists on system */
  default:
    break;
  }
  /* Use this as default */
  return((enum db_type) current_thd->variables.table_type);
} /* ha_checktype */


handler *get_new_handler(TABLE *table, enum db_type db_type)
{
  switch (db_type) {
#ifndef NO_HASH
  return new ha_hash(table);
#endif
#ifdef HAVE_ISAM
  case DB_TYPE_MRG_ISAM:
    return new ha_isammrg(table);
  case DB_TYPE_ISAM:<commit_msg>Revert behaviour change introduced in WL1280. Fixes tests.<commit_after>/* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */


/* Handler-calling-functions */

#ifdef __GNUC__
#pragma implementation				// gcc: Class implementation
#endif

#include "mysql_priv.h"
#include "ha_heap.h"
#include "ha_myisam.h"
#include "ha_myisammrg.h"
#ifdef HAVE_ISAM
#include "ha_isam.h"
#include "ha_isammrg.h"
#endif
#ifdef HAVE_BERKELEY_DB
#include "ha_berkeley.h"
#endif
#ifdef HAVE_INNOBASE_DB
#include "ha_innodb.h"
#else
#define innobase_query_caching_of_table_permitted(X,Y,Z) 1
#endif
#include <myisampack.h>
#include <errno.h>

	/* static functions defined in this file */

static int NEAR_F delete_file(const char *name,const char *ext,int extflag);

ulong ha_read_count, ha_write_count, ha_delete_count, ha_update_count,
      ha_read_key_count, ha_read_next_count, ha_read_prev_count,
      ha_read_first_count, ha_read_last_count,
      ha_commit_count, ha_rollback_count,
      ha_read_rnd_count, ha_read_rnd_next_count;

const char *ha_table_type[] = {
  "", "DIAB_ISAM","HASH","MISAM","PISAM","RMS_ISAM","HEAP", "ISAM",
  "MRG_ISAM","MYISAM", "MRG_MYISAM", "BDB", "INNODB", "GEMINI", "?", "?",NullS
};

TYPELIB ha_table_typelib=
{
  array_elements(ha_table_type)-3, "", ha_table_type
};

const char *ha_row_type[] = {
  "", "FIXED", "DYNAMIC", "COMPRESSED","?","?","?"
};

const char *tx_isolation_names[] =
{ "READ-UNCOMMITTED", "READ-COMMITTED", "REPEATABLE-READ", "SERIALIZABLE",
  NullS};
TYPELIB tx_isolation_typelib= {array_elements(tx_isolation_names)-1,"",
			       tx_isolation_names};

enum db_type ha_resolve_by_name(char *name, uint namelen)
{
  enum db_type result = DB_TYPE_UNKNOWN;
  if (!my_strcasecmp(&my_charset_latin1, name, "HEAP") ||
      !my_strcasecmp(&my_charset_latin1, name, "MEMORY")) {
    result = DB_TYPE_HEAP;
  } else
  if (!my_strcasecmp(&my_charset_latin1, name, "MRG_MYISAM") ||
      !my_strcasecmp(&my_charset_latin1, name, "MERGE")) {
    result = DB_TYPE_MRG_MYISAM;
  } else
  if (!my_strcasecmp(&my_charset_latin1, name, "MYISAM")) {
    result = DB_TYPE_MYISAM;
  } else
  if (!my_strcasecmp(&my_charset_latin1, name, "BDB") ||
      !my_strcasecmp(&my_charset_latin1, name, "BERKELEYDB")) {
    result = DB_TYPE_BERKELEY_DB;
  } else
  if (!my_strcasecmp(&my_charset_latin1, name, "INNODB") ||
      !my_strcasecmp(&my_charset_latin1, name, "INNOBASE")) {
    result = DB_TYPE_INNODB;
  } else
  if (!my_strcasecmp(&my_charset_latin1, name, "ISAM")) {
    result = DB_TYPE_ISAM;
  } else
  if (!my_strcasecmp(&my_charset_latin1, name, "DEFAULT")) {
    result = (enum db_type) current_thd->variables.table_type;
  }
  return result;
}

	/* Use other database handler if databasehandler is not incompiled */

enum db_type ha_checktype(enum db_type database_type)
{
  switch (database_type) {
#ifdef HAVE_BERKELEY_DB
  case DB_TYPE_BERKELEY_DB:
    if (berkeley_skip) break;
    return (database_type);
#endif
#ifdef HAVE_INNOBASE_DB
  case DB_TYPE_INNODB:
    if (innodb_skip) break;
    return (database_type);
#endif
#ifndef NO_HASH
  case DB_TYPE_HASH:
#endif
#ifdef HAVE_ISAM
  case DB_TYPE_ISAM:
    if (isam_skip) break;
    return (database_type);
  case DB_TYPE_MRG_ISAM:
    return (isam_skip ? DB_TYPE_MRG_MYISAM : database_type);
#else
  case DB_TYPE_MRG_ISAM:
    return (DB_TYPE_MRG_MYISAM);
#endif
  case DB_TYPE_HEAP:
  case DB_TYPE_MYISAM:
  case DB_TYPE_MRG_MYISAM:
    return (database_type);			/* Database exists on system */
  default:
    break;
  }
  /* Use this as default */
#if 0
  return((enum db_type) current_thd->variables.table_type);
#else
  return(DB_TYPE_MYISAM);
#endif
} /* ha_checktype */


handler *get_new_handler(TABLE *table, enum db_type db_type)
{
  switch (db_type) {
#ifndef NO_HASH
  return new ha_hash(table);
#endif
#ifdef HAVE_ISAM
  case DB_TYPE_MRG_ISAM:
    return new ha_isammrg(table);
  case DB_TYPE_ISAM:
{'fraction_non_alphanumeric': 0.11048158640226628, 'fraction_numerical': 0.007735890172150795, 'mean_word_length': 4.762084118016322, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7007589', 'n_tokens_mistral': 3548, 'n_tokens_neox': 3433, 'n_words': 831}