mariadb/sql/handler.cc
unknown cfab46f546 Update copyright
Fixed memory leak on shutdown (Affects the embedded version & MyODBC)


client/client_priv.h:
  Update copyright
client/completion_hash.cc:
  Update copyright
client/completion_hash.h:
  Update copyright
client/connect_test.c:
  Update copyright
client/errmsg.c:
  Update copyright
client/get_password.c:
  Update copyright
client/insert_test.c:
  Update copyright
client/list_test.c:
  Update copyright
client/my_readline.h:
  Update copyright
client/mysql.cc:
  Update copyright
client/mysqladmin.c:
  Update copyright
client/mysqlbinlog.cc:
  Update copyright
client/mysqlcheck.c:
  Update copyright
client/mysqldump.c:
  Update copyright
client/mysqlimport.c:
  Update copyright
client/mysqlmanager-pwgen.c:
  Update copyright
client/mysqlmanagerc.c:
  Update copyright
client/mysqlshow.c:
  Update copyright
client/mysqltest.c:
  Update copyright
client/password.c:
  Update copyright
client/readline.cc:
  Update copyright
client/select_test.c:
  Update copyright
client/showdb_test.c:
  Update copyright
client/sql_string.cc:
  Update copyright
client/sql_string.h:
  Update copyright
client/ssl_test.c:
  Update copyright
client/thimble.cc:
  Update copyright
client/thread_test.c:
  Update copyright
div/deadlock_test.c:
  Update copyright
extra/comp_err.c:
  Update copyright
extra/my_print_defaults.c:
  Update copyright
extra/perror.c:
  Update copyright
extra/replace.c:
  Update copyright
extra/resolve_stack_dump.c:
  Update copyright
extra/resolveip.c:
  Update copyright
fs/database.c:
  Update copyright
fs/libmysqlfs.c:
  Update copyright
fs/mysqlcorbafs.c:
  Update copyright
fs/mysqlcorbafs.h:
  Update copyright
fs/mysqlcorbafs_test.c:
  Update copyright
heap/_check.c:
  Update copyright
heap/_rectest.c:
  Update copyright
heap/heapdef.h:
  Update copyright
heap/hp_block.c:
  Update copyright
heap/hp_clear.c:
  Update copyright
heap/hp_close.c:
  Update copyright
heap/hp_create.c:
  Update copyright
heap/hp_delete.c:
  Update copyright
heap/hp_extra.c:
  Update copyright
heap/hp_hash.c:
  Update copyright
heap/hp_info.c:
  Update copyright
heap/hp_open.c:
  Update copyright
heap/hp_panic.c:
  Update copyright
heap/hp_rename.c:
  Update copyright
heap/hp_rfirst.c:
  Update copyright
heap/hp_rkey.c:
  Update copyright
heap/hp_rlast.c:
  Update copyright
heap/hp_rnext.c:
  Update copyright
heap/hp_rprev.c:
  Update copyright
heap/hp_rrnd.c:
  Update copyright
heap/hp_rsame.c:
  Update copyright
heap/hp_scan.c:
  Update copyright
heap/hp_static.c:
  Update copyright
heap/hp_test1.c:
  Update copyright
heap/hp_test2.c:
  Update copyright
heap/hp_update.c:
  Update copyright
heap/hp_write.c:
  Update copyright
include/config-win.h:
  Update copyright
include/dbug.h:
  Update copyright
include/errmsg.h:
  Update copyright
include/ft_global.h:
  Update copyright
include/getopt.h:
  Update copyright
include/hash.h:
  Update copyright
include/heap.h:
  Update copyright
include/m_ctype.h:
  Update copyright
include/m_string.h:
  Update copyright
include/md5.h:
  Update copyright
include/merge.h:
  Update copyright
include/my_alarm.h:
  Update copyright
include/my_base.h:
  Update copyright
include/my_bitmap.h:
  Update copyright
include/my_dir.h:
  Update copyright
include/my_global.h:
  Update copyright
include/my_list.h:
  Update copyright
include/my_net.h:
  Update copyright
include/my_no_pthread.h:
  Update copyright
include/my_nosys.h:
  Update copyright
include/my_pthread.h:
  Update copyright
include/my_sys.h:
  Update copyright
include/my_tree.h:
  Update copyright
include/myisam.h:
  Update copyright
include/myisammrg.h:
  Update copyright
include/myisampack.h:
  Update copyright
include/mysql.h:
  Update copyright
include/mysql_com.h:
  Update copyright
include/mysql_embed.h:
  Update copyright
include/mysqld_error.h:
  Update copyright
include/mysys_err.h:
  Update copyright
include/nisam.h:
  Update copyright
include/queues.h:
  Update copyright
include/raid.h:
  Update copyright
include/sslopt-case.h:
  Update copyright
include/sslopt-longopts.h:
  Update copyright
include/sslopt-usage.h:
  Update copyright
include/sslopt-vars.h:
  Update copyright
include/t_ctype.h:
  Update copyright
include/thr_alarm.h:
  Update copyright
include/thr_lock.h:
  Update copyright
include/violite.h:
  Update copyright
isam/_cache.c:
  Update copyright
isam/_dbug.c:
  Update copyright
isam/_key.c:
  Update copyright
isam/_locking.c:
  Update copyright
isam/_packrec.c:
  Update copyright
isam/_page.c:
  Update copyright
isam/_search.c:
  Update copyright
isam/_statrec.c:
  Update copyright
isam/changed.c:
  Update copyright
isam/close.c:
  Update copyright
isam/create.c:
  Update copyright
isam/delete.c:
  Update copyright
isam/extra.c:
  Update copyright
isam/info.c:
  Update copyright
isam/isamchk.c:
  Update copyright
isam/isamdef.h:
  Update copyright
isam/log.c:
  Update copyright
isam/open.c:
  Update copyright
isam/panic.c:
  Update copyright
isam/range.c:
  Update copyright
isam/rfirst.c:
  Update copyright
isam/rkey.c:
  Update copyright
isam/rlast.c:
  Update copyright
isam/rnext.c:
  Update copyright
isam/rprev.c:
  Update copyright
isam/rrnd.c:
  Update copyright
isam/rsame.c:
  Update copyright
isam/rsamepos.c:
  Update copyright
isam/sort.c:
  Update copyright
isam/static.c:
  Update copyright
isam/test1.c:
  Update copyright
isam/test2.c:
  Update copyright
isam/test3.c:
  Update copyright
isam/update.c:
  Update copyright
isam/write.c:
  Update copyright
libmysql/conf_to_src.c:
  Update copyright
libmysql/dll.c:
  Update copyright
libmysql/errmsg.c:
  Update copyright
libmysql/get_password.c:
  Update copyright
libmysql/libmysql.c:
  Update copyright
libmysql/manager.c:
  Update copyright
libmysql/net.c:
  Update copyright
libmysql/password.c:
  Update copyright
libmysqld/lib_sql.cc:
  Update copyright
libmysqld/lib_vio.c:
  Update copyright
libmysqld/libmysqld.c:
  Update copyright
merge/mrg_close.c:
  Update copyright
merge/mrg_create.c:
  Update copyright
merge/mrg_def.h:
  Update copyright
merge/mrg_delete.c:
  Update copyright
merge/mrg_extra.c:
  Update copyright
merge/mrg_info.c:
  Update copyright
merge/mrg_locking.c:
  Update copyright
merge/mrg_open.c:
  Update copyright
merge/mrg_panic.c:
  Update copyright
merge/mrg_rrnd.c:
  Update copyright
merge/mrg_rsame.c:
  Update copyright
merge/mrg_static.c:
  Update copyright
merge/mrg_update.c:
  Update copyright
myisam/ft_boolean_search.c:
  Update copyright
myisam/ft_dump.c:
  Update copyright
myisam/ft_eval.h:
  Update copyright
myisam/ft_static.c:
  Update copyright
myisam/ft_stem.c:
  Update copyright
myisam/ft_stopwords.c:
  Update copyright
myisam/ft_test1.h:
  Update copyright
myisam/mi_cache.c:
  Update copyright
myisam/mi_changed.c:
  Update copyright
myisam/mi_check.c:
  Update copyright
myisam/mi_checksum.c:
  Update copyright
myisam/mi_close.c:
  Update copyright
myisam/mi_create.c:
  Update copyright
myisam/mi_dbug.c:
  Update copyright
myisam/mi_delete.c:
  Update copyright
myisam/mi_delete_all.c:
  Update copyright
myisam/mi_delete_table.c:
  Update copyright
myisam/mi_dynrec.c:
  Update copyright
myisam/mi_extra.c:
  Update copyright
myisam/mi_info.c:
  Update copyright
myisam/mi_key.c:
  Update copyright
myisam/mi_locking.c:
  Update copyright
myisam/mi_log.c:
  Update copyright
myisam/mi_open.c:
  Update copyright
myisam/mi_packrec.c:
  Update copyright
myisam/mi_page.c:
  Update copyright
myisam/mi_panic.c:
  Update copyright
myisam/mi_range.c:
  Update copyright
myisam/mi_rename.c:
  Update copyright
myisam/mi_rfirst.c:
  Update copyright
myisam/mi_rlast.c:
  Update copyright
myisam/mi_rnext_same.c:
  Update copyright
myisam/mi_rrnd.c:
  Update copyright
myisam/mi_rsame.c:
  Update copyright
myisam/mi_rsamepos.c:
  Update copyright
myisam/mi_scan.c:
  Update copyright
myisam/mi_search.c:
  Update copyright
myisam/mi_static.c:
  Update copyright
myisam/mi_statrec.c:
  Update copyright
myisam/mi_test1.c:
  Update copyright
myisam/mi_test2.c:
  Update copyright
myisam/mi_test3.c:
  Update copyright
myisam/mi_unique.c:
  Update copyright
myisam/mi_update.c:
  Update copyright
myisam/mi_write.c:
  Update copyright
myisam/myisamchk.c:
  Update copyright
myisam/myisampack.c:
  Update copyright
myisammrg/myrg_close.c:
  Update copyright
myisammrg/myrg_create.c:
  Update copyright
myisammrg/myrg_def.h:
  Update copyright
myisammrg/myrg_delete.c:
  Update copyright
myisammrg/myrg_locking.c:
  Update copyright
myisammrg/myrg_open.c:
  Update copyright
myisammrg/myrg_panic.c:
  Update copyright
myisammrg/myrg_rsame.c:
  Update copyright
myisammrg/myrg_static.c:
  Update copyright
myisammrg/myrg_update.c:
  Update copyright
myisammrg/myrg_write.c:
  Update copyright
mysql-test/r/gcc296.result:
  Update of benchmark results
mysql-test/r/innodb.result:
  Update of benchmark results
mysql-test/r/join_outer.result:
  Update of benchmark results
mysql-test/r/myisam.result:
  Update of benchmark results
mysys/array.c:
  Update copyright
mysys/charset.c:
  Fix for restart of character sets
mysys/checksum.c:
  Update copyright
mysys/default.c:
  Update copyright
mysys/errors.c:
  Update copyright
mysys/getopt.c:
  Cleanup
mysys/getvar.c:
  Update copyright
mysys/hash.c:
  Update copyright
mysys/list.c:
  Update copyright
mysys/make-conf.c:
  Update copyright
mysys/md5.c:
  Update copyright
mysys/mf_brkhant.c:
  Update copyright
mysys/mf_cache.c:
  Update copyright
mysys/mf_casecnv.c:
  Update copyright
mysys/mf_dirname.c:
  Update copyright
mysys/mf_fn_ext.c:
  Update copyright
mysys/mf_format.c:
  Update copyright
mysys/mf_getdate.c:
  Update copyright
mysys/mf_iocache.c:
  Update copyright
mysys/mf_iocache2.c:
  Update copyright
mysys/mf_keycache.c:
  Update copyright
mysys/mf_loadpath.c:
  Update copyright
mysys/mf_pack.c:
  Update copyright
mysys/mf_path.c:
  Update copyright
mysys/mf_qsort.c:
  Update copyright
mysys/mf_qsort2.c:
  Update copyright
mysys/mf_radix.c:
  Update copyright
mysys/mf_same.c:
  Update copyright
mysys/mf_sleep.c:
  Update copyright
mysys/mf_sort.c:
  Update copyright
mysys/mf_soundex.c:
  Update copyright
mysys/mf_stripp.c:
  Update copyright
mysys/mf_tempfile.c:
  Update copyright
mysys/mf_unixpath.c:
  Update copyright
mysys/mf_util.c:
  Update copyright
mysys/mf_wcomp.c:
  Update copyright
mysys/mf_wfile.c:
  Update copyright
mysys/mulalloc.c:
  Update copyright
mysys/my_alarm.c:
  Update copyright
mysys/my_alloc.c:
  Update copyright
mysys/my_append.c:
  Update copyright
mysys/my_bit.c:
  Update copyright
mysys/my_bitmap.c:
  Update copyright
mysys/my_chsize.c:
  Update copyright
mysys/my_clock.c:
  Update copyright
mysys/my_compress.c:
  Update copyright
mysys/my_copy.c:
  Update copyright
mysys/my_create.c:
  Update copyright
mysys/my_delete.c:
  Update copyright
mysys/my_div.c:
  Update copyright
mysys/my_dup.c:
  Update copyright
mysys/my_error.c:
  Update copyright
mysys/my_fopen.c:
  Update copyright
mysys/my_fstream.c:
  Update copyright
mysys/my_getwd.c:
  Update copyright
mysys/my_init.c:
  Free 'once_alloc' memory at shutdown.
mysys/my_lib.c:
  Update copyright
mysys/my_lock.c:
  Update copyright
mysys/my_lockmem.c:
  Update copyright
mysys/my_lread.c:
  Update copyright
mysys/my_lwrite.c:
  Update copyright
mysys/my_malloc.c:
  Update copyright
mysys/my_messnc.c:
  Update copyright
mysys/my_mkdir.c:
  Update copyright
mysys/my_net.c:
  Update copyright
mysys/my_once.c:
  Update copyright
mysys/my_open.c:
  Update copyright
mysys/my_pread.c:
  Update copyright
mysys/my_pthread.c:
  Update copyright
mysys/my_quick.c:
  Update copyright
mysys/my_read.c:
  Update copyright
mysys/my_realloc.c:
  Update copyright
mysys/my_redel.c:
  Update copyright
mysys/my_rename.c:
  Update copyright
mysys/my_seek.c:
  Update copyright
mysys/my_static.c:
  Update copyright
mysys/my_static.h:
  Update copyright
mysys/my_symlink.c:
  Update copyright
mysys/my_symlink2.c:
  Update copyright
mysys/my_tempnam.c:
  Update copyright
mysys/my_thr_init.c:
  Update copyright
mysys/my_vsnprintf.c:
  Update copyright
mysys/my_wincond.c:
  Update copyright
mysys/my_winthread.c:
  Update copyright
mysys/my_write.c:
  Update copyright
mysys/mysys_priv.h:
  Update copyright
mysys/ptr_cmp.c:
  Update copyright
mysys/queues.c:
  Update copyright
mysys/raid.cc:
  Update copyright
mysys/safemalloc.c:
  Update copyright
mysys/string.c:
  Update copyright
mysys/test_charset.c:
  Update copyright
mysys/test_dir.c:
  Update copyright
mysys/test_fn.c:
  Update copyright
mysys/testhash.c:
  Update copyright
mysys/thr_alarm.c:
  Update copyright
mysys/thr_lock.c:
  Update copyright
mysys/thr_mutex.c:
  Update copyright
mysys/thr_rwlock.c:
  Update copyright
mysys/tree.c:
  Update copyright
mysys/typelib.c:
  Update copyright
pstack/debug.c:
  Update copyright
pstack/debug.h:
  Update copyright
pstack/demangle.h:
  Update copyright
pstack/ieee.c:
  Update copyright
pstack/ieee.h:
  Update copyright
pstack/pstack.c:
  Update copyright
readline/bind.c:
  Cleanup empty lines
readline/complete.c:
  Cleanup empty lines
readline/display.c:
  Cleanup empty lines
readline/funmap.c:
  Cleanup empty lines
readline/histexpand.c:
  Cleanup empty lines
readline/histfile.c:
  Cleanup empty lines
readline/history.c:
  Cleanup empty lines
readline/history.h:
  Cleanup empty lines
readline/input.c:
  Cleanup empty lines
readline/kill.c:
  Cleanup empty lines
readline/readline.c:
  Cleanup empty lines
readline/readline.h:
  Cleanup empty lines
readline/vi_mode.c:
  Cleanup empty lines
sql/cache_manager.cc:
  Update copyright
sql/cache_manager.h:
  Update copyright
sql/convert.cc:
  Update copyright
sql/custom_conf.h:
  Update copyright
sql/derror.cc:
  Update copyright
sql/field.cc:
  Update copyright
sql/field.h:
  Update copyright
sql/field_conv.cc:
  Update copyright
sql/filesort.cc:
  Update copyright
sql/frm_crypt.cc:
  Update copyright
sql/ha_berkeley.cc:
  Update copyright
sql/ha_heap.cc:
  Update copyright
sql/ha_heap.h:
  Update copyright
sql/ha_innobase.cc:
  Update copyright
sql/ha_isam.cc:
  Update copyright
sql/ha_isam.h:
  Update copyright
sql/ha_isammrg.cc:
  Update copyright
sql/ha_isammrg.h:
  Update copyright
sql/ha_myisam.cc:
  Update copyright
sql/handler.cc:
  Update copyright
sql/hash_filo.cc:
  Update copyright
sql/hash_filo.h:
  Update copyright
sql/hostname.cc:
  Update copyright
sql/init.cc:
  Update copyright
sql/item.cc:
  Update copyright
sql/item.h:
  Update copyright
sql/item_buff.cc:
  Update copyright
sql/item_cmpfunc.cc:
  Update copyright
sql/item_cmpfunc.h:
  Update copyright
sql/item_create.cc:
  Update copyright
sql/item_create.h:
  Update copyright
sql/item_func.cc:
  Update copyright
sql/item_strfunc.cc:
  Update copyright
sql/item_sum.cc:
  Update copyright
sql/item_sum.h:
  Update copyright
sql/item_timefunc.cc:
  Update copyright
sql/item_timefunc.h:
  Update copyright
sql/item_uniq.cc:
  Update copyright
sql/item_uniq.h:
  Update copyright
sql/key.cc:
  Update copyright
sql/lex_symbol.h:
  Update copyright
sql/lock.cc:
  Update copyright
sql/log.cc:
  Update copyright
sql/log_event.cc:
  Update copyright
sql/log_event.h:
  Update copyright
sql/matherr.c:
  Update copyright
sql/mf_iocache.cc:
  Update copyright
sql/mini_client.cc:
  Update copyright
sql/mini_client.h:
  Update copyright
sql/my_lock.c:
  Update copyright
sql/mysqld.cc:
  Update copyright
sql/net_pkg.cc:
  Update copyright
sql/net_serv.cc:
  Update copyright
sql/opt_sum.cc:
  Update copyright
sql/password.c:
  Update copyright
sql/procedure.cc:
  Update copyright
sql/procedure.h:
  Update copyright
sql/records.cc:
  Update copyright
sql/repl_failsafe.cc:
  Update copyright
sql/slave.cc:
  Update copyright
sql/slave.h:
  Update copyright
sql/sql_acl.cc:
  Update copyright
sql/sql_acl.h:
  Update copyright
sql/sql_analyse.cc:
  Update copyright
sql/sql_analyse.h:
  Update copyright
sql/sql_base.cc:
  Update copyright
sql/sql_cache.cc:
  Update copyright
sql/sql_class.cc:
  Update copyright
sql/sql_class.h:
  Update copyright
sql/sql_crypt.cc:
  Update copyright
sql/sql_crypt.h:
  Update copyright
sql/sql_db.cc:
  Update copyright
sql/sql_delete.cc:
  Update copyright
sql/sql_handler.cc:
  Update copyright
sql/sql_insert.cc:
  Update copyright
sql/sql_lex.cc:
  Update copyright
sql/sql_lex.h:
  Update copyright
sql/sql_list.cc:
  Update copyright
sql/sql_list.h:
  Update copyright
sql/sql_load.cc:
  Update copyright
sql/sql_map.cc:
  Update copyright
sql/sql_map.h:
  Update copyright
sql/sql_parse.cc:
  Update copyright
sql/sql_rename.cc:
  Update copyright
sql/sql_repl.cc:
  Update copyright
sql/sql_select.h:
  Update copyright
sql/sql_string.cc:
  Update copyright
sql/sql_string.h:
  Update copyright
sql/sql_table.cc:
  Update copyright
sql/sql_test.cc:
  Update copyright
sql/sql_udf.cc:
  Update copyright
sql/sql_udf.h:
  Update copyright
sql/stacktrace.c:
  Update copyright
sql/structs.h:
  Update copyright
sql/table.cc:
  Update copyright
sql/table.h:
  Update copyright
sql/thr_malloc.cc:
  Update copyright
sql/time.cc:
  Update copyright
sql/udf_example.cc:
  Update copyright
sql/uniques.cc:
  Update copyright
sql/unireg.cc:
  Update copyright
sql/unireg.h:
  Update copyright
strings/atof.c:
  Update copyright
strings/bchange.c:
  Update copyright
strings/bcmp.c:
  Update copyright
strings/bcopy-duff.c:
  Update copyright
strings/bfill.c:
  Update copyright
strings/bmove.c:
  Update copyright
strings/bmove512.c:
  Update copyright
strings/bmove_upp.c:
  Update copyright
strings/bzero.c:
  Update copyright
strings/conf_to_src.c:
  Update copyright
strings/ctype-big5.c:
  Update copyright
strings/ctype-czech.c:
  Update copyright
strings/ctype-euc_kr.c:
  Update copyright
strings/ctype-gb2312.c:
  Update copyright
strings/ctype-gbk.c:
  Update copyright
strings/ctype-latin1_de.c:
  Update copyright
strings/ctype-sjis.c:
  Update copyright
strings/ctype-tis620.c:
  Update copyright
strings/ctype-ujis.c:
  Update copyright
strings/ctype.c:
  Update copyright
strings/do_ctype.c:
  Update copyright
strings/int2str.c:
  Update copyright
strings/is_prefix.c:
  Update copyright
strings/llstr.c:
  Update copyright
strings/longlong2str.c:
  Update copyright
strings/memcmp.c:
  Update copyright
strings/memcpy.c:
  Update copyright
strings/memset.c:
  Update copyright
strings/r_strinstr.c:
  Update copyright
strings/str2int.c:
  Update copyright
strings/str_test.c:
  Update copyright
strings/strappend.c:
  Update copyright
strings/strcat.c:
  Update copyright
strings/strcend.c:
  Update copyright
strings/strchr.c:
  Update copyright
strings/strcmp.c:
  Update copyright
strings/strcont.c:
  Update copyright
strings/strend.c:
  Update copyright
strings/strfill.c:
  Update copyright
strings/strings-not-used.h:
  Update copyright
strings/strinstr.c:
  Update copyright
strings/strlen.c:
  Update copyright
strings/strmake.c:
  Update copyright
strings/strmov.c:
  Update copyright
strings/strnlen.c:
  Update copyright
strings/strnmov.c:
  Update copyright
strings/strrchr.c:
  Update copyright
strings/strstr.c:
  Update copyright
strings/strto.c:
  Update copyright
strings/strtol.c:
  Update copyright
strings/strtoll.c:
  Update copyright
strings/strtoul.c:
  Update copyright
strings/strtoull.c:
  Update copyright
strings/strxmov.c:
  Update copyright
strings/strxnmov.c:
  Update copyright
strings/t_ctype.h:
  Update copyright
strings/udiv.c:
  Update copyright
tools/mysqlmanager.c:
  Update copyright
vio/test-ssl.c:
  Update copyright
vio/test-sslclient.c:
  Update copyright
vio/test-sslserver.c:
  Update copyright
vio/vio.c:
  Update copyright
vio/viosocket.c:
  Update copyright
vio/viossl.c:
  Update copyright
vio/viosslfactories.c:
  Update copyright
vio/viotest-ssl.c:
  Update copyright
2001-12-06 14:10:51 +02:00

794 lines
18 KiB
C++

/* 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_innobase.h"
#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_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)-4,"",
ha_table_type+1};
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};
/* 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:
return(berkeley_skip ? DB_TYPE_MYISAM : database_type);
#endif
#ifdef HAVE_INNOBASE_DB
case DB_TYPE_INNODB:
return(innodb_skip ? DB_TYPE_MYISAM : database_type);
#endif
#ifndef NO_HASH
case DB_TYPE_HASH:
#endif
#ifdef HAVE_ISAM
case DB_TYPE_ISAM:
case DB_TYPE_MRG_ISAM:
#endif
case DB_TYPE_HEAP:
case DB_TYPE_MYISAM:
case DB_TYPE_MRG_MYISAM:
return (database_type); /* Database exists on system */
default:
break;
}
return(DB_TYPE_MYISAM); /* Use this as default */
} /* 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:
return new ha_isam(table);
#endif
#ifdef HAVE_BERKELEY_DB
case DB_TYPE_BERKELEY_DB:
return new ha_berkeley(table);
#endif
#ifdef HAVE_INNOBASE_DB
case DB_TYPE_INNODB:
return new ha_innobase(table);
#endif
case DB_TYPE_HEAP:
return new ha_heap(table);
case DB_TYPE_MYISAM:
default: // should never happen
return new ha_myisam(table);
case DB_TYPE_MRG_MYISAM:
return new ha_myisammrg(table);
}
}
int ha_init()
{
#ifdef HAVE_BERKELEY_DB
if (!berkeley_skip)
{
int error;
if ((error=berkeley_init()))
return error;
if (!berkeley_skip) // If we couldn't use handler
opt_using_transactions=1;
else
have_berkeley_db=SHOW_OPTION_DISABLED;
}
#endif
#ifdef HAVE_INNOBASE_DB
if (!innodb_skip)
{
if (innobase_init())
return -1;
if (!innodb_skip) // If we couldn't use handler
opt_using_transactions=1;
else
have_innodb=SHOW_OPTION_DISABLED;
}
#endif
return 0;
}
/* close, flush or restart databases */
/* Ignore this for other databases than ours */
int ha_panic(enum ha_panic_function flag)
{
int error=0;
#ifndef NO_HASH
error|=h_panic(flag); /* fix hash */
#endif
#ifdef HAVE_ISAM
error|=mrg_panic(flag);
error|=nisam_panic(flag);
#endif
error|=heap_panic(flag);
error|=mi_panic(flag);
error|=myrg_panic(flag);
#ifdef HAVE_BERKELEY_DB
if (!berkeley_skip)
error|=berkeley_end();
#endif
#ifdef HAVE_INNOBASE_DB
if (!innodb_skip)
error|=innobase_end();
#endif
return error;
} /* ha_panic */
void ha_drop_database(char* path)
{
#ifdef HAVE_INNOBASE_DB
if (!innodb_skip)
innobase_drop_database(path);
#endif
}
void ha_close_connection(THD* thd)
{
#ifdef HAVE_INNOBASE_DB
if (!innodb_skip)
innobase_close_connection(thd);
#endif
}
/*
This is used to commit or rollback a single statement depending
on the value of error
*/
int ha_autocommit_or_rollback(THD *thd, int error)
{
DBUG_ENTER("ha_autocommit_or_rollback");
#ifdef USING_TRANSACTIONS
if (opt_using_transactions)
{
if (!error)
{
if (ha_commit_stmt(thd))
error=1;
}
else
(void) ha_rollback_stmt(thd);
thd->tx_isolation=thd->session_tx_isolation;
}
#endif
DBUG_RETURN(error);
}
int ha_commit_trans(THD *thd, THD_TRANS* trans)
{
int error=0;
DBUG_ENTER("ha_commit");
#ifdef USING_TRANSACTIONS
if (opt_using_transactions)
{
/* Update the binary log if we have cached some queries */
if (trans == &thd->transaction.all && mysql_bin_log.is_open() &&
my_b_tell(&thd->transaction.trans_log))
{
mysql_bin_log.write(&thd->transaction.trans_log);
reinit_io_cache(&thd->transaction.trans_log,
WRITE_CACHE, (my_off_t) 0, 0, 1);
thd->transaction.trans_log.end_of_file= max_binlog_cache_size;
}
#ifdef HAVE_BERKELEY_DB
if (trans->bdb_tid)
{
if ((error=berkeley_commit(thd,trans->bdb_tid)))
{
my_error(ER_ERROR_DURING_COMMIT, MYF(0), error);
error=1;
}
trans->bdb_tid=0;
}
#endif
#ifdef HAVE_INNOBASE_DB
if (trans->innobase_tid)
{
if ((error=innobase_commit(thd,trans->innobase_tid)))
{
my_error(ER_ERROR_DURING_COMMIT, MYF(0), error);
error=1;
}
trans->innodb_active_trans=0;
if (trans == &thd->transaction.all)
query_cache.invalidate(Query_cache_table::INNODB);
}
#endif
if (error && trans == &thd->transaction.all && mysql_bin_log.is_open())
sql_print_error("Error: Got error during commit; Binlog is not up to date!");
thd->tx_isolation=thd->session_tx_isolation;
}
#endif // using transactions
DBUG_RETURN(error);
}
int ha_rollback_trans(THD *thd, THD_TRANS *trans)
{
int error=0;
DBUG_ENTER("ha_rollback");
#ifdef USING_TRANSACTIONS
if (opt_using_transactions)
{
#ifdef HAVE_BERKELEY_DB
if (trans->bdb_tid)
{
if ((error=berkeley_rollback(thd, trans->bdb_tid)))
{
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), error);
error=1;
}
trans->bdb_tid=0;
}
#endif
#ifdef HAVE_INNOBASE_DB
if (trans->innobase_tid)
{
if ((error=innobase_rollback(thd, trans->innobase_tid)))
{
my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), error);
error=1;
}
trans->innodb_active_trans=0;
}
#endif
if (trans == &thd->transaction.all)
reinit_io_cache(&thd->transaction.trans_log,
WRITE_CACHE, (my_off_t) 0, 0, 1);
thd->transaction.trans_log.end_of_file= max_binlog_cache_size;
thd->tx_isolation=thd->session_tx_isolation;
}
#endif /* USING_TRANSACTIONS */
DBUG_RETURN(error);
}
bool ha_flush_logs()
{
bool result=0;
#ifdef HAVE_BERKELEY_DB
if (!berkeley_skip && berkeley_flush_logs())
result=1;
#endif
#ifdef HAVE_INNOBASE_DB
if (!innodb_skip && innobase_flush_logs())
result=1;
#endif
return result;
}
/*
This should return ENOENT if the file doesn't exists.
The .frm file will be deleted only if we return 0 or ENOENT
*/
int ha_delete_table(enum db_type table_type, const char *path)
{
handler *file=get_new_handler((TABLE*) 0, table_type);
if (!file)
return ENOENT;
int error=file->delete_table(path);
delete file;
return error;
}
void ha_store_ptr(byte *buff, uint pack_length, my_off_t pos)
{
switch (pack_length) {
#if SIZEOF_OFF_T > 4
case 8: mi_int8store(buff,pos); break;
case 7: mi_int7store(buff,pos); break;
case 6: mi_int6store(buff,pos); break;
case 5: mi_int5store(buff,pos); break;
#endif
case 4: mi_int4store(buff,pos); break;
case 3: mi_int3store(buff,pos); break;
case 2: mi_int2store(buff,(uint) pos); break;
case 1: buff[0]= (uchar) pos; break;
}
return;
}
my_off_t ha_get_ptr(byte *ptr, uint pack_length)
{
my_off_t pos;
switch (pack_length) {
#if SIZEOF_OFF_T > 4
case 8:
pos= (my_off_t) mi_uint8korr(ptr);
break;
case 7:
pos= (my_off_t) mi_uint7korr(ptr);
break;
case 6:
pos= (my_off_t) mi_uint6korr(ptr);
break;
case 5:
pos= (my_off_t) mi_uint5korr(ptr);
break;
#endif
case 4:
pos= (my_off_t) mi_uint4korr(ptr);
break;
case 3:
pos= (my_off_t) mi_uint3korr(ptr);
break;
case 2:
pos= (my_off_t) mi_uint2korr(ptr);
break;
case 1:
pos= (my_off_t) mi_uint2korr(ptr);
break;
default:
pos=0; // Impossible
break;
}
return pos;
}
/****************************************************************************
** General handler functions
****************************************************************************/
/* Open database-handler. Try O_RDONLY if can't open as O_RDWR */
/* Don't wait for locks if not HA_OPEN_WAIT_IF_LOCKED is set */
int handler::ha_open(const char *name, int mode, int test_if_locked)
{
int error;
DBUG_ENTER("handler::open");
DBUG_PRINT("enter",("name: %s db_type: %d db_stat: %d mode: %d lock_test: %d",
name, table->db_type, table->db_stat, mode, test_if_locked));
if ((error=open(name,mode,test_if_locked)))
{
if ((error == EACCES || error == EROFS) && mode == O_RDWR &&
(table->db_stat & HA_TRY_READ_ONLY))
{
table->db_stat|=HA_READ_ONLY;
error=open(name,O_RDONLY,test_if_locked);
}
}
if (error)
{
my_errno=error; /* Safeguard */
DBUG_PRINT("error",("error: %d errno: %d",error,errno));
}
else
{
if (table->db_options_in_use & HA_OPTION_READ_ONLY_DATA)
table->db_stat|=HA_READ_ONLY;
}
if (!error)
{
if (!alloc_root_inited(&table->mem_root)) // If temporary table
ref=(byte*) sql_alloc(ALIGN_SIZE(ref_length)*2);
else
ref=(byte*) alloc_root(&table->mem_root, ALIGN_SIZE(ref_length)*2);
if (!ref)
{
close();
error=HA_ERR_OUT_OF_MEM;
}
else
dupp_ref=ref+ALIGN_SIZE(ref_length);
}
DBUG_RETURN(error);
}
int handler::check(THD* thd, HA_CHECK_OPT* check_opt)
{
return HA_ADMIN_NOT_IMPLEMENTED;
}
int handler::backup(THD* thd, HA_CHECK_OPT* check_opt)
{
return HA_ADMIN_NOT_IMPLEMENTED;
}
int handler::restore(THD* thd, HA_CHECK_OPT* check_opt)
{
return HA_ADMIN_NOT_IMPLEMENTED;
}
int handler::repair(THD* thd, HA_CHECK_OPT* check_opt)
{
return HA_ADMIN_NOT_IMPLEMENTED;
}
int handler::optimize(THD* thd, HA_CHECK_OPT* check_opt)
{
return HA_ADMIN_NOT_IMPLEMENTED;
}
int handler::analyze(THD* thd, HA_CHECK_OPT* check_opt)
{
return HA_ADMIN_NOT_IMPLEMENTED;
}
/* Read first row from a table */
int handler::rnd_first(byte * buf)
{
register int error;
DBUG_ENTER("handler::rnd_first");
statistic_increment(ha_read_first_count,&LOCK_status);
(void) rnd_init();
while ((error= rnd_next(buf)) == HA_ERR_RECORD_DELETED) ;
(void) rnd_end();
DBUG_RETURN(error);
}
/*
The following function is only needed for tables that may be temporary tables
during joins
*/
int handler::restart_rnd_next(byte *buf, byte *pos)
{
return HA_ERR_WRONG_COMMAND;
}
/* Set a timestamp in record */
void handler::update_timestamp(byte *record)
{
long skr= (long) current_thd->query_start();
#ifdef WORDS_BIGENDIAN
if (table->db_low_byte_first)
{
int4store(record,skr);
}
else
#endif
longstore(record,skr);
return;
}
/* Updates field with field_type NEXT_NUMBER according to following:
** if field = 0 change field to the next free key in database.
*/
void handler::update_auto_increment()
{
longlong nr;
THD *thd;
DBUG_ENTER("update_auto_increment");
if (table->next_number_field->val_int() != 0)
{
auto_increment_column_changed=0;
DBUG_VOID_RETURN;
}
thd=current_thd;
if ((nr=thd->next_insert_id))
thd->next_insert_id=0; // Clear after use
else
nr=get_auto_increment();
thd->insert_id((ulonglong) nr);
table->next_number_field->store(nr);
auto_increment_column_changed=1;
DBUG_VOID_RETURN;
}
longlong handler::get_auto_increment()
{
longlong nr;
int error;
(void) extra(HA_EXTRA_KEYREAD);
index_init(table->next_number_index);
error=index_last(table->record[1]);
if (error)
nr=1;
else
nr=(longlong) table->next_number_field->
val_int_offset(table->rec_buff_length)+1;
(void) extra(HA_EXTRA_NO_KEYREAD);
index_end();
return nr;
}
/* Print error that we got from handler function */
void handler::print_error(int error, myf errflag)
{
DBUG_ENTER("print_error");
DBUG_PRINT("enter",("error: %d",error));
int textno=ER_GET_ERRNO;
switch (error) {
case EAGAIN:
textno=ER_FILE_USED;
break;
case ENOENT:
textno=ER_FILE_NOT_FOUND;
break;
case HA_ERR_KEY_NOT_FOUND:
case HA_ERR_NO_ACTIVE_RECORD:
case HA_ERR_END_OF_FILE:
textno=ER_KEY_NOT_FOUND;
break;
case HA_ERR_WRONG_TABLE_DEF:
textno=ER_WRONG_MRG_TABLE;
break;
case HA_ERR_FOUND_DUPP_KEY:
{
uint key_nr=get_dup_key(error);
if ((int) key_nr >= 0)
{
/* Write the dupplicated key in the error message */
char key[MAX_KEY_LENGTH];
String str(key,sizeof(key));
key_unpack(&str,table,(uint) key_nr);
uint max_length=MYSQL_ERRMSG_SIZE-(uint) strlen(ER(ER_DUP_ENTRY));
if (str.length() >= max_length)
{
str.length(max_length-4);
str.append("...");
}
my_error(ER_DUP_ENTRY,MYF(0),str.c_ptr(),key_nr+1);
DBUG_VOID_RETURN;
}
textno=ER_DUP_KEY;
break;
}
case HA_ERR_FOUND_DUPP_UNIQUE:
textno=ER_DUP_UNIQUE;
break;
case HA_ERR_RECORD_CHANGED:
textno=ER_CHECKREAD;
break;
case HA_ERR_CRASHED:
textno=ER_NOT_KEYFILE;
break;
case HA_ERR_CRASHED_ON_USAGE:
textno=ER_CRASHED_ON_USAGE;
break;
case HA_ERR_CRASHED_ON_REPAIR:
textno=ER_CRASHED_ON_REPAIR;
break;
case HA_ERR_OUT_OF_MEM:
my_error(ER_OUT_OF_RESOURCES,errflag);
DBUG_VOID_RETURN;
case HA_ERR_WRONG_COMMAND:
textno=ER_ILLEGAL_HA;
break;
case HA_ERR_OLD_FILE:
textno=ER_OLD_KEYFILE;
break;
case HA_ERR_UNSUPPORTED:
textno=ER_UNSUPPORTED_EXTENSION;
break;
case HA_ERR_RECORD_FILE_FULL:
textno=ER_RECORD_FILE_FULL;
break;
case HA_ERR_LOCK_WAIT_TIMEOUT:
textno=ER_LOCK_WAIT_TIMEOUT;
break;
case HA_ERR_LOCK_TABLE_FULL:
textno=ER_LOCK_TABLE_FULL;
break;
case HA_ERR_LOCK_DEADLOCK:
textno=ER_LOCK_DEADLOCK;
break;
case HA_ERR_READ_ONLY_TRANSACTION:
textno=ER_READ_ONLY_TRANSACTION;
break;
case HA_ERR_CANNOT_ADD_FOREIGN:
textno=ER_CANNOT_ADD_FOREIGN;
break;
case HA_ERR_ROW_IS_REFERENCED:
textno=ER_ROW_IS_REFERENCED;
break;
case HA_ERR_NO_REFERENCED_ROW:
textno=ER_NO_REFERENCED_ROW;
break;
default:
{
my_error(ER_GET_ERRNO,errflag,error);
DBUG_VOID_RETURN;
}
}
my_error(textno,errflag,table->table_name,error);
DBUG_VOID_RETURN;
}
/* Return key if error because of duplicated keys */
uint handler::get_dup_key(int error)
{
DBUG_ENTER("get_dup_key");
table->file->errkey = (uint) -1;
if (error == HA_ERR_FOUND_DUPP_KEY || error == HA_ERR_FOUND_DUPP_UNIQUE)
info(HA_STATUS_ERRKEY | HA_STATUS_NO_LOCK);
DBUG_RETURN(table->file->errkey);
}
int handler::delete_table(const char *name)
{
int error=0;
for (const char **ext=bas_ext(); *ext ; ext++)
{
if (delete_file(name,*ext,2))
{
if ((error=errno) != ENOENT)
break;
}
}
return error;
}
int handler::rename_table(const char * from, const char * to)
{
DBUG_ENTER("handler::rename_table");
for (const char **ext=bas_ext(); *ext ; ext++)
{
if (rename_file_ext(from,to,*ext))
DBUG_RETURN(my_errno);
}
DBUG_RETURN(0);
}
/* Tell the handler to turn on or off logging to the handler's
recovery log
*/
int ha_recovery_logging(THD *thd, bool on)
{
int error=0;
DBUG_ENTER("ha_recovery_logging");
DBUG_RETURN(error);
}
int handler::index_next_same(byte *buf, const byte *key, uint keylen)
{
int error;
if (!(error=index_next(buf)))
{
if (key_cmp(table, key, active_index, keylen))
{
table->status=STATUS_NOT_FOUND;
error=HA_ERR_END_OF_FILE;
}
}
return error;
}
/*
This is called to delete all rows in a table
If the handler don't support this, then this function will
return HA_ERR_WRONG_COMMAND and MySQL will delete the rows one
by one.
*/
int handler::delete_all_rows()
{
return (my_errno=HA_ERR_WRONG_COMMAND);
}
/****************************************************************************
** Some general functions that isn't in the handler class
****************************************************************************/
/* Initiates table-file and calls apropriate database-creator */
/* Returns 1 if something got wrong */
int ha_create_table(const char *name, HA_CREATE_INFO *create_info,
bool update_create_info)
{
int error;
TABLE table;
DBUG_ENTER("ha_create_table");
if (openfrm(name,"",0,(uint) READ_ALL, 0, &table))
DBUG_RETURN(1);
if (update_create_info)
{
update_create_info_from_table(create_info, &table);
if (table.file->option_flag() & HA_DROP_BEFORE_CREATE)
table.file->delete_table(name); // Needed for BDB tables
}
error=table.file->create(name,&table,create_info);
VOID(closefrm(&table));
if (error)
{
if (table.db_type == DB_TYPE_INNODB)
{
/* Creation of InnoDB table cannot fail because of an OS error:
put error as the number */
my_error(ER_CANT_CREATE_TABLE,MYF(ME_BELL+ME_WAITTANG),name,error);
}
else
my_error(ER_CANT_CREATE_TABLE,MYF(ME_BELL+ME_WAITTANG),name,my_errno);
}
DBUG_RETURN(error != 0);
}
/* Use key cacheing on all databases */
void ha_key_cache(void)
{
if (keybuff_size)
(void) init_key_cache(keybuff_size,0);
} /* ha_key_cache */
static int NEAR_F delete_file(const char *name,const char *ext,int extflag)
{
char buff[FN_REFLEN];
VOID(fn_format(buff,name,"",ext,extflag | 4));
return(my_delete_with_symlink(buff,MYF(MY_WME)));
}