diff options
author | Davi Arnaut <davi.arnaut@oracle.com> | 2010-07-23 17:14:35 -0300 |
---|---|---|
committer | Davi Arnaut <davi.arnaut@oracle.com> | 2010-07-23 17:14:35 -0300 |
commit | e83f1d37c497383f25aee772371692ea561190a4 (patch) | |
tree | 34993c1eeb34970e4c3ffef7f0a41b6e14095d89 | |
parent | fb91a923306ae845977bbdcc7e6de1836b3dadd9 (diff) | |
download | mariadb-git-e83f1d37c497383f25aee772371692ea561190a4.tar.gz |
WL#5498: Remove dead and unused source code
Remove unused source code and associated paraphernalia.
33 files changed, 28 insertions, 1703 deletions
diff --git a/client/Makefile.am b/client/Makefile.am index 04f0ac39b0e..393573a061e 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -62,7 +62,6 @@ mysqlbinlog_SOURCES = mysqlbinlog.cc \ $(top_srcdir)/mysys/my_new.cc \ $(top_srcdir)/mysys/my_bit.c \ $(top_srcdir)/mysys/my_bitmap.c \ - $(top_srcdir)/mysys/my_vle.c \ $(top_srcdir)/mysys/base64.c mysqlbinlog_LDADD = $(LDADD) $(CXXLDFLAGS) diff --git a/include/Makefile.am b/include/Makefile.am index aa6ffa78ee5..e30588de065 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -38,11 +38,11 @@ noinst_HEADERS = lf.h my_bit.h \ myisam.h myisampack.h myisammrg.h ft_global.h\ mysys_err.h my_base.h \ my_nosys.h my_alarm.h queues.h rijndael.h sha1.h sha2.h \ - my_aes.h my_tree.h my_trie.h hash.h thr_alarm.h \ + my_aes.h my_tree.h hash.h thr_alarm.h \ thr_lock.h t_ctype.h violite.h my_md5.h base64.h \ my_handler.h my_time.h service_versions.h \ my_rdtsc.h mysql/psi/psi_abi_v1.h mysql/psi/psi_abi_v2.h \ - my_vle.h my_user.h my_atomic.h atomic/nolock.h \ + my_user.h my_atomic.h atomic/nolock.h \ atomic/rwlock.h atomic/x86-gcc.h atomic/generic-msvc.h \ atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h \ atomic/solaris.h mysql/innodb_priv.h my_compiler.h diff --git a/include/my_net.h b/include/my_net.h index 1b8425984ae..5762f5da06e 100644 --- a/include/my_net.h +++ b/include/my_net.h @@ -14,9 +14,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ /* - thread safe version of some common functions: - my_inet_ntoa - This file is also used to make handling of sockets and ioctl() portable accross systems. @@ -76,10 +73,6 @@ C_MODE_START #define in_addr_t uint32 #endif -/* Thread safe or portable version of some functions */ - -void my_inet_ntoa(struct in_addr in, char *buf); - /* Handling of gethostbyname_r() */ diff --git a/include/my_sys.h b/include/my_sys.h index c5702ec7395..369a6b5b82b 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -101,10 +101,6 @@ extern int my_errno; /* Last error in mysys */ #define MY_GIVE_INFO 2 /* Give time info about process*/ #define MY_DONT_FREE_DBUG 4 /* Do not call DBUG_END() in my_end() */ -#define MY_REMOVE_NONE 0 /* Params for modify_defaults_file */ -#define MY_REMOVE_OPTION 1 -#define MY_REMOVE_SECTION 2 - #define ME_HIGHBYTE 8 /* Shift for colours */ #define ME_NOCUR 1 /* Don't use curses message */ #define ME_OLDWIN 2 /* Use old window */ @@ -266,13 +262,6 @@ extern const char *my_defaults_file; extern my_bool timed_mutexes; -typedef struct wild_file_pack /* Struct to hold info when selecting files */ -{ - uint wilds; /* How many wildcards */ - uint not_pos; /* Start of not-theese-files */ - char * *wild; /* Pointer to wildcards */ -} WF_PACK; - enum loglevel { ERROR_LEVEL, WARNING_LEVEL, @@ -568,7 +557,6 @@ typedef int (*Process_option_func)(void *ctx, const char *group_name, /* Prototypes for mysys and my_func functions */ extern int my_copy(const char *from,const char *to,myf MyFlags); -extern int my_append(const char *from,const char *to,myf MyFlags); extern int my_delete(const char *name,myf MyFlags); extern int my_getwd(char * buf,size_t size,myf MyFlags); extern int my_setwd(const char *dir,myf MyFlags); @@ -584,7 +572,6 @@ extern File my_register_filename(File fd, const char *FileName, extern File my_create(const char *FileName,int CreateFlags, int AccessFlags, myf MyFlags); extern int my_close(File Filedes,myf MyFlags); -extern File my_dup(File file, myf MyFlags); extern int my_mkdir(const char *dir, int Flags, myf MyFlags); extern int my_readlink(char *to, const char *filename, myf MyFlags); extern int my_is_symlink(const char *filename); @@ -713,9 +700,6 @@ extern char * my_load_path(char * to, const char *path, const char *own_path_prefix); extern int wild_compare(const char *str,const char *wildstr, pbool str_is_pattern); -extern WF_PACK *wf_comp(char * str); -extern int wf_test(struct wild_file_pack *wf_pack,const char *name); -extern void wf_end(struct wild_file_pack *buffer); extern my_bool array_append_string_unique(const char *str, const char **array, size_t size); extern void get_date(char * to,int timeflag,time_t use_time); @@ -729,8 +713,6 @@ extern int end_record_cache(RECORD_CACHE *info); extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos, const uchar *record,size_t length); extern int flush_write_cache(RECORD_CACHE *info); -extern long my_clock(void); -extern sig_handler sigtstp_handler(int signal_number); extern void handle_recived_signals(void); extern sig_handler my_set_alarm_variable(int signo); @@ -852,9 +834,6 @@ extern int my_load_defaults(const char *conf_file, const char **groups, int *argc, char ***argv, const char ***); extern int load_defaults(const char *conf_file, const char **groups, int *argc, char ***argv); -extern int modify_defaults_file(const char *file_location, const char *option, - const char *option_value, - const char *section_name, int remove_option); extern int my_search_option_files(const char *conf_file, int *argc, char ***argv, uint *args_used, Process_option_func func, void *func_ctx, diff --git a/include/my_trie.h b/include/my_trie.h deleted file mode 100644 index 72dd485af04..00000000000 --- a/include/my_trie.h +++ /dev/null @@ -1,141 +0,0 @@ -/* Copyright (C) 2005 MySQL 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; version 2 of the License. - - 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 */ - -#ifndef _trie_h -#define _trie_h -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct st_trie_node -{ - uint16 leaf; /* Depth from root node if match, 0 else */ - uchar c; /* Label on this edge */ - struct st_trie_node *next; /* Next label */ - struct st_trie_node *links; /* Array of edges leaving this node */ - struct st_trie_node *fail; /* AC failure function */ -} TRIE_NODE; - -typedef struct st_trie -{ - TRIE_NODE root; - MEM_ROOT mem_root; - CHARSET_INFO *charset; - uint32 nnodes; - uint32 nwords; -} TRIE; - -typedef struct st_ac_trie_state -{ - TRIE *trie; - TRIE_NODE *node; -} AC_TRIE_STATE; - -extern TRIE *trie_init (TRIE *trie, CHARSET_INFO *charset); -extern void trie_free (TRIE *trie); -extern my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen); -extern my_bool ac_trie_prepare (TRIE *trie); -extern void ac_trie_init (TRIE *trie, AC_TRIE_STATE *state); - - -/* `trie_goto' is internal function and shouldn't be used. */ - -static inline TRIE_NODE *trie_goto (TRIE_NODE *root, TRIE_NODE *node, uchar c) -{ - TRIE_NODE *next; - DBUG_ENTER("trie_goto"); - for (next= node->links; next; next= next->next) - if (next->c == c) - DBUG_RETURN(next); - if (root == node) - DBUG_RETURN(root); - DBUG_RETURN(NULL); -} - - -/* - SYNOPSIS - int ac_trie_next (AC_TRIE_STATE *state, uchar *c); - state - valid pointer to `AC_TRIE_STATE' - c - character to lookup - - DESCRIPTION - Implementation of search using Aho-Corasick automaton. - Performs char-by-char search. - - RETURN VALUE - `ac_trie_next' returns length of matched word or 0. -*/ - -static inline int ac_trie_next (AC_TRIE_STATE *state, uchar *c) -{ - TRIE_NODE *root, *node; - DBUG_ENTER("ac_trie_next"); - DBUG_ASSERT(state && c); - root= &state->trie->root; - node= state->node; - while (! (state->node= trie_goto(root, node, *c))) - node= node->fail; - DBUG_RETURN(state->node->leaf); -} - - -/* - SYNOPSIS - my_bool trie_search (TRIE *trie, const uchar *key, uint keylen); - trie - valid pointer to `TRIE' - key - valid pointer to key to insert - keylen - non-0 key length - - DESCRIPTION - Performs key lookup in trie. - - RETURN VALUE - `trie_search' returns `true' if key is in `trie'. Otherwise, - `false' is returned. - - NOTES - Consecutive search here is "best by test". arrays are very short, so - binary search or hashing would add too much complexity that would - overweight speed gain. Especially because compiler can optimize simple - consecutive loop better (tested) -*/ - -static inline my_bool trie_search (TRIE *trie, const uchar *key, uint keylen) -{ - TRIE_NODE *node; - uint k; - DBUG_ENTER("trie_search"); - DBUG_ASSERT(trie && key && keylen); - node= &trie->root; - - for (k= 0; k < keylen; k++) - { - uchar p; - if (! (node= node->links)) - DBUG_RETURN(FALSE); - p= key[k]; - while (p != node->c) - if (! (node= node->next)) - DBUG_RETURN(FALSE); - } - - DBUG_RETURN(node->leaf > 0); -} - -#ifdef __cplusplus -} -#endif -#endif diff --git a/include/my_vle.h b/include/my_vle.h deleted file mode 100644 index c09f82229c4..00000000000 --- a/include/my_vle.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (C) 2005 MySQL 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; version 2 of the License. - - 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 */ - -#ifndef VLE_H -#define VLE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include "my_global.h" - -/* - The size (in bytes) required to store the object ITEM, which can be - either an expression or a type (since sizeof() is used on the item). -*/ -#define my_vle_sizeof(ITEM) (((sizeof(ITEM) * CHAR_BIT) + 6) / 7) - -uchar *my_vle_encode(uchar *vle, size_t max, ulong value); -uchar const *my_vle_decode(ulong *value_ptr, uchar const *vle); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared index 53264f2e559..f98863951e3 100644 --- a/libmysql/Makefile.shared +++ b/libmysql/Makefile.shared @@ -61,9 +61,8 @@ mysysobjects1 = my_init.lo my_static.lo my_malloc.lo \ mf_format.lo mf_path.lo mf_unixpath.lo my_fopen.lo \ my_symlink.lo my_fstream.lo mf_arr_appstr.lo \ mf_loadpath.lo my_pthread.lo my_thr_init.lo \ - thr_mutex.lo mulalloc.lo string.lo \ - default.lo default_modify.lo \ - my_compress.lo array.lo my_once.lo list.lo my_net.lo \ + thr_mutex.lo mulalloc.lo string.lo default.lo \ + my_compress.lo array.lo my_once.lo list.lo \ charset.lo charset-def.lo hash.lo mf_iocache.lo \ mf_iocache2.lo my_seek.lo my_sleep.lo \ my_pread.lo mf_cache.lo md5.lo sha1.lo \ diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt index 6f553ef9c11..a7efcb024ec 100644 --- a/libmysqld/CMakeLists.txt +++ b/libmysqld/CMakeLists.txt @@ -67,7 +67,7 @@ SET(SQL_EMBEDDED_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc ../sql/sql_truncate.cc ../sql/sql_lex.cc ../sql/keycaches.cc ../sql/sql_list.cc ../sql/sql_load.cc ../sql/sql_locale.cc - ../sql/sql_binlog.cc ../sql/sql_manager.cc ../sql/sql_map.cc + ../sql/sql_binlog.cc ../sql/sql_manager.cc ../sql/sql_parse.cc ../sql/sql_partition.cc ../sql/sql_plugin.cc ../sql/debug_sync.cc ../sql/sql_prepare.cc ../sql/sql_rename.cc ../sql/sql_repl.cc diff --git a/libmysqld/Makefile.am b/libmysqld/Makefile.am index 9d8c5edaa12..1ffa349bcfe 100644 --- a/libmysqld/Makefile.am +++ b/libmysqld/Makefile.am @@ -66,7 +66,7 @@ sqlsources = derror.cc field.cc field_conv.cc strfunc.cc filesort.cc \ sql_profile.cc sql_truncate.cc datadict.cc \ sql_analyse.cc sql_base.cc sql_cache.cc sql_class.cc \ sql_crypt.cc sql_db.cc sql_delete.cc sql_error.cc sql_insert.cc \ - sql_lex.cc sql_list.cc sql_manager.cc sql_map.cc \ + sql_lex.cc sql_list.cc sql_manager.cc \ scheduler.cc sql_connect.cc sql_parse.cc \ sql_prepare.cc sql_derived.cc sql_rename.cc \ sql_select.cc sql_do.cc sql_show.cc set_var.cc sys_vars.cc \ diff --git a/mysql-test/suite/perfschema/r/server_init.result b/mysql-test/suite/perfschema/r/server_init.result index ac340f8eb67..70205c7f104 100644 --- a/mysql-test/suite/perfschema/r/server_init.result +++ b/mysql-test/suite/perfschema/r/server_init.result @@ -56,10 +56,6 @@ where name like "wait/synch/mutex/sql/LOCK_thread_count"; count(name) 1 select count(name) from MUTEX_INSTANCES -where name like "wait/synch/mutex/sql/LOCK_mapped_file"; -count(name) -1 -select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/LOCK_status"; count(name) 1 diff --git a/mysql-test/suite/perfschema/t/server_init.test b/mysql-test/suite/perfschema/t/server_init.test index cd9357cce67..b0bbe7b1bae 100644 --- a/mysql-test/suite/perfschema/t/server_init.test +++ b/mysql-test/suite/perfschema/t/server_init.test @@ -81,9 +81,6 @@ select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/LOCK_thread_count"; select count(name) from MUTEX_INSTANCES - where name like "wait/synch/mutex/sql/LOCK_mapped_file"; - -select count(name) from MUTEX_INSTANCES where name like "wait/synch/mutex/sql/LOCK_status"; select count(name) from MUTEX_INSTANCES diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt index 83615c82e2a..ab0799b22f9 100644 --- a/mysys/CMakeLists.txt +++ b/mysys/CMakeLists.txt @@ -17,23 +17,23 @@ INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys) -SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_modify.c +SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c mf_format.c mf_getdate.c mf_iocache.c mf_iocache2.c mf_keycache.c mf_keycaches.c mf_loadpath.c mf_pack.c mf_path.c mf_qsort.c mf_qsort2.c mf_radix.c mf_same.c mf_sort.c mf_soundex.c mf_arr_appstr.c mf_tempdir.c - mf_tempfile.c mf_unixpath.c mf_wcomp.c mf_wfile.c mulalloc.c my_access.c - my_aes.c my_alarm.c my_alloc.c my_append.c my_bit.c my_bitmap.c my_chsize.c - my_clock.c my_compress.c my_copy.c my_crc32.c my_create.c my_delete.c + mf_tempfile.c mf_unixpath.c mf_wcomp.c mulalloc.c my_access.c + my_aes.c my_alarm.c my_alloc.c my_bit.c my_bitmap.c my_chsize.c + my_compress.c my_copy.c my_crc32.c my_create.c my_delete.c my_div.c my_error.c my_file.c my_fopen.c my_fstream.c my_gethostbyname.c my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_handler.c my_init.c my_lib.c my_lock.c my_lockmem.c my_malloc.c my_mess.c - my_mkdir.c my_mmap.c my_net.c my_once.c my_open.c my_pread.c my_pthread.c + my_mkdir.c my_mmap.c my_once.c my_open.c my_pread.c my_pthread.c my_quick.c my_read.c my_redel.c my_rename.c my_seek.c my_sleep.c my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_write.c ptr_cmp.c queues.c stacktrace.c rijndael.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c - thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c + thr_rwlock.c tree.c typelib.c base64.c my_memmem.c my_getpagesize.c lf_alloc-pin.c lf_dynarray.c lf_hash.c my_atomic.c my_getncpus.c my_rdtsc.c) diff --git a/mysys/Makefile.am b/mysys/Makefile.am index a9e3f16c548..357fa321da6 100644 --- a/mysys/Makefile.am +++ b/mysys/Makefile.am @@ -24,31 +24,29 @@ LDADD = libmysys.a $(top_builddir)/strings/libmystrings.a $(top_builddir)/dbug noinst_HEADERS = mysys_priv.h my_static.h my_handler_errors.h libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \ mf_path.c mf_loadpath.c my_file.c \ - my_open.c my_create.c my_dup.c my_seek.c my_read.c \ + my_open.c my_create.c my_seek.c my_read.c \ my_pread.c my_write.c my_getpagesize.c \ mf_keycaches.c my_crc32.c \ mf_iocache.c mf_iocache2.c mf_cache.c mf_tempfile.c \ mf_tempdir.c my_lock.c mf_brkhant.c my_alarm.c \ my_malloc.c my_once.c mulalloc.c \ - my_alloc.c my_new.cc my_vle.c my_atomic.c lf_hash.c \ + my_alloc.c my_new.cc my_atomic.c lf_hash.c \ lf_dynarray.c lf_alloc-pin.c \ my_fopen.c my_fstream.c my_getsystime.c \ my_error.c errors.c my_div.c my_mess.c \ mf_format.c mf_same.c mf_dirname.c mf_fn_ext.c \ my_symlink.c my_symlink2.c \ mf_pack.c mf_unixpath.c mf_arr_appstr.c \ - mf_wcomp.c mf_wfile.c my_gethwaddr.c \ + mf_wcomp.c my_gethwaddr.c \ mf_qsort.c mf_qsort2.c mf_sort.c \ ptr_cmp.c mf_radix.c queues.c my_getncpus.c \ - tree.c trie.c list.c hash.c array.c string.c typelib.c \ - my_copy.c my_append.c my_lib.c \ + tree.c list.c hash.c array.c string.c typelib.c \ + my_copy.c my_lib.c \ my_delete.c my_rename.c my_redel.c \ - my_chsize.c my_clock.c \ - my_quick.c my_lockmem.c my_static.c \ + my_chsize.c my_quick.c my_lockmem.c my_static.c \ my_sync.c my_getopt.c my_mkdir.c \ - default_modify.c default.c \ - my_compress.c checksum.c \ - my_net.c my_port.c my_sleep.c \ + default.c my_compress.c checksum.c \ + my_port.c my_sleep.c \ charset.c charset-def.c my_bitmap.c my_bit.c md5.c \ my_gethostbyname.c rijndael.c my_aes.c sha1.c \ my_handler.c my_largepage.c \ diff --git a/mysys/default_modify.c b/mysys/default_modify.c deleted file mode 100644 index edf4907cd4b..00000000000 --- a/mysys/default_modify.c +++ /dev/null @@ -1,252 +0,0 @@ -/* Copyright (C) 2005 MySQL 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; version 2 of the License. - - 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 */ - -#include "my_global.h" -#include "mysys_priv.h" -#include "m_string.h" -#include <my_dir.h> - -#define BUFF_SIZE 1024 -#define RESERVE 1024 /* Extend buffer with this extent */ - -#ifdef _WIN32 -#define NEWLINE "\r\n" -#define NEWLINE_LEN 2 -#else -#define NEWLINE "\n" -#define NEWLINE_LEN 1 -#endif - -static char *add_option(char *dst, const char *option_value, - const char *option, int remove_option); - - -/* - Add/remove option to the option file section. - - SYNOPSYS - modify_defaults_file() - file_location The location of configuration file to edit - option The name of the option to look for (can be NULL) - option value The value of the option we would like to set (can be NULL) - section_name The name of the section (must be NOT NULL) - remove_option This defines what we want to remove: - - MY_REMOVE_NONE -- nothing to remove; - - MY_REMOVE_OPTION -- remove the specified option; - - MY_REMOVE_SECTION -- remove the specified section; - IMPLEMENTATION - We open the option file first, then read the file line-by-line, - looking for the section we need. At the same time we put these lines - into a buffer. Then we look for the option within this section and - change/remove it. In the end we get a buffer with modified version of the - file. Then we write it to the file, truncate it if needed and close it. - Note that there is a small time gap, when the file is incomplete, - and this theoretically might introduce a problem. - - RETURN - 0 - ok - 1 - some error has occured. Probably due to the lack of resourses - 2 - cannot open the file -*/ - -int modify_defaults_file(const char *file_location, const char *option, - const char *option_value, - const char *section_name, int remove_option) -{ - FILE *cnf_file; - MY_STAT file_stat; - char linebuff[BUFF_SIZE], *src_ptr, *dst_ptr, *file_buffer; - size_t opt_len= 0, optval_len= 0, sect_len, new_opt_len, reserve_extended; - uint nr_newlines= 0, buffer_size; - my_bool in_section= FALSE, opt_applied= 0; - int reserve_occupied= 0; - DBUG_ENTER("modify_defaults_file"); - - if (!(cnf_file= my_fopen(file_location, O_RDWR | O_BINARY, MYF(0)))) - DBUG_RETURN(2); - - /* my_fstat doesn't use the flag parameter */ - if (my_fstat(my_fileno(cnf_file), &file_stat, MYF(0))) - goto malloc_err; - - if (option && option_value) - { - opt_len= strlen(option); - optval_len= strlen(option_value); - } - - new_opt_len= opt_len + 1 + optval_len + NEWLINE_LEN; - - /* calculate the size of the buffer we need */ - reserve_extended= (opt_len + - 1 + /* For '=' char */ - optval_len + /* Option value len */ - NEWLINE_LEN + /* Space for newline */ - RESERVE); /* Some additional space */ - - buffer_size= (file_stat.st_size + - 1); /* The ending zero */ - - /* - Reserve space to read the contents of the file and some more - for the option we want to add. - */ - if (!(file_buffer= (char*) my_malloc(buffer_size + reserve_extended, - MYF(MY_WME)))) - goto malloc_err; - - sect_len= strlen(section_name); - - for (dst_ptr= file_buffer; fgets(linebuff, BUFF_SIZE, cnf_file); ) - { - /* Skip over whitespaces */ - for (src_ptr= linebuff; my_isspace(&my_charset_latin1, *src_ptr); - src_ptr++) - {} - - if (!*src_ptr) /* Empty line */ - { - nr_newlines++; - continue; - } - - /* correct the option (if requested) */ - if (option && in_section && !strncmp(src_ptr, option, opt_len) && - (*(src_ptr + opt_len) == '=' || - my_isspace(&my_charset_latin1, *(src_ptr + opt_len)) || - *(src_ptr + opt_len) == '\0')) - { - char *old_src_ptr= src_ptr; - src_ptr= strend(src_ptr+ opt_len); /* Find the end of the line */ - - /* could be negative */ - reserve_occupied+= (int) new_opt_len - (int) (src_ptr - old_src_ptr); - if (reserve_occupied >= (int) reserve_extended) - { - reserve_extended= (uint) reserve_occupied + RESERVE; - if (!(file_buffer= (char*) my_realloc(file_buffer, buffer_size + - reserve_extended, - MYF(MY_WME|MY_FREE_ON_ERROR)))) - goto malloc_err; - } - opt_applied= 1; - dst_ptr= add_option(dst_ptr, option_value, option, remove_option); - } - else - { - /* - If we are going to the new group and have an option to apply, do - it now. If we are removing a single option or the whole section - this will only trigger opt_applied flag. - */ - - if (in_section && !opt_applied && *src_ptr == '[') - { - dst_ptr= add_option(dst_ptr, option_value, option, remove_option); - opt_applied= 1; /* set the flag to do write() later */ - reserve_occupied= new_opt_len+ opt_len + 1 + NEWLINE_LEN; - } - - for (; nr_newlines; nr_newlines--) - dst_ptr= strmov(dst_ptr, NEWLINE); - - /* Skip the section if MY_REMOVE_SECTION was given */ - if (!in_section || remove_option != MY_REMOVE_SECTION) - dst_ptr= strmov(dst_ptr, linebuff); - } - /* Look for a section */ - if (*src_ptr == '[') - { - /* Copy the line to the buffer */ - if (!strncmp(++src_ptr, section_name, sect_len)) - { - src_ptr+= sect_len; - /* Skip over whitespaces. They are allowed after section name */ - for (; my_isspace(&my_charset_latin1, *src_ptr); src_ptr++) - {} - - if (*src_ptr != ']') - { - in_section= FALSE; - continue; /* Missing closing parenthesis. Assume this was no group */ - } - - if (remove_option == MY_REMOVE_SECTION) - dst_ptr= dst_ptr - strlen(linebuff); - - in_section= TRUE; - } - else - in_section= FALSE; /* mark that this section is of no interest to us */ - } - } - - /* - File ended. Apply an option or set opt_applied flag (in case of - MY_REMOVE_SECTION) so that the changes are saved. Do not do anything - if we are removing non-existent option. - */ - - if (!opt_applied && in_section && (remove_option != MY_REMOVE_OPTION)) - { - /* New option still remains to apply at the end */ - if (!remove_option && *(dst_ptr - 1) != '\n') - dst_ptr= strmov(dst_ptr, NEWLINE); - dst_ptr= add_option(dst_ptr, option_value, option, remove_option); - opt_applied= 1; - } - for (; nr_newlines; nr_newlines--) - dst_ptr= strmov(dst_ptr, NEWLINE); - - if (opt_applied) - { - /* Don't write the file if there are no changes to be made */ - if (my_chsize(my_fileno(cnf_file), (my_off_t) (dst_ptr - file_buffer), 0, - MYF(MY_WME)) || - my_fseek(cnf_file, 0, MY_SEEK_SET, MYF(0)) || - my_fwrite(cnf_file, (uchar*) file_buffer, (size_t) (dst_ptr - file_buffer), - MYF(MY_NABP))) - goto err; - } - if (my_fclose(cnf_file, MYF(MY_WME))) - DBUG_RETURN(1); - - my_free(file_buffer); - DBUG_RETURN(0); - -err: - my_free(file_buffer); -malloc_err: - my_fclose(cnf_file, MYF(0)); - DBUG_RETURN(1); /* out of resources */ -} - - -static char *add_option(char *dst, const char *option_value, - const char *option, int remove_option) -{ - if (!remove_option) - { - dst= strmov(dst, option); - if (*option_value) - { - *dst++= '='; - dst= strmov(dst, option_value); - } - /* add a newline */ - dst= strmov(dst, NEWLINE); - } - return dst; -} diff --git a/mysys/make-conf.c b/mysys/make-conf.c deleted file mode 100644 index 0dacde4dee0..00000000000 --- a/mysys/make-conf.c +++ /dev/null @@ -1,71 +0,0 @@ -/* Copyright (C) 2000 MySQL 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; version 2 of the License. - - 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 */ - -/* make-conf.c - * make a charset .conf file out of a ctype-charset.c file. - */ - -#ifndef CHARSET -#error You must define the charset, e.g.: -DCHARSET=latin1 -#endif - -/* some pre-processor tricks to get us going */ -#define _STRINGIZE_HELPER(x) #x -#define STRINGIZE(x) _STRINGIZE_HELPER(x) - -#define _JOIN_WORDS_HELPER(a, b) a ## b -#define JOIN_WORDS(a, b) _JOIN_WORDS_HELPER(a, b) - -#define CH_SRC ctype- ## CHARSET ## .c -#define CH_INCLUDE STRINGIZE(CH_SRC) - -/* aaaah, that's better */ -#include <my_my_global.h> -#include CH_INCLUDE - -#include <stdio.h> -#include <stdlib.h> - -#define ROW_LEN 16 - -void print_array(const char *name, const uchar *array, uint size); - -int main(void) -{ - printf("# Configuration file for the " - STRINGIZE(CHARSET) - " character set.\n"); - - print_array("ctype", JOIN_WORDS(ctype_, CHARSET), 257); - print_array("to_lower", JOIN_WORDS(to_lower_, CHARSET), 256); - print_array("to_upper", JOIN_WORDS(to_upper_, CHARSET), 256); - print_array("sort_order", JOIN_WORDS(sort_order_, CHARSET), 256); - - exit(EXIT_SUCCESS); -} - -void print_array(const char *name, const uchar *array, uint size) -{ - uint i; - - printf("\n# The %s array must have %d elements.\n", name, size); - - for (i = 0; i < size; ++i) { - printf(" %02X", array[i]); - - if ((i+1) % ROW_LEN == size % ROW_LEN) - printf("\n"); - } -} diff --git a/mysys/mf_wfile.c b/mysys/mf_wfile.c deleted file mode 100644 index 95c4c006b2c..00000000000 --- a/mysys/mf_wfile.c +++ /dev/null @@ -1,123 +0,0 @@ -/* Copyright (C) 2000 MySQL 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; version 2 of the License. - - 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 */ - -/* Functions for finding files with wildcards */ - -/* - The following file-name-test is supported: - - "name [[,] name...] ; Matches any of used filenames. - Each name can have "*" and/or "?" - wild-cards. - - [wildspec [,]] !wildspec2 ; File that matches wildspec and not - wildspec2. -*/ - -#include "mysys_priv.h" -#include <m_string.h> - - /* Store wildcard-string in a easyer format */ - -WF_PACK *wf_comp(char * str) -{ - uint ant; - int not_pos; - register char * pos; - char * buffer; - WF_PACK *ret; - DBUG_ENTER("wf_comp"); - - not_pos= -1; /* Skip space and '!' in front */ - while (*str == ' ') - str++; - if (*str == '!') - { - not_pos=0; - while (*++str == ' ') {}; - } - if (*str == 0) /* Empty == everything */ - DBUG_RETURN((WF_PACK *) NULL); - - ant=1; /* Count filespecs */ - for (pos=str ; *pos ; pos++) - ant+= test(*pos == ' ' || *pos == ','); - - if ((ret= (WF_PACK*) my_malloc((uint) ant*(sizeof(char **)+2)+ - sizeof(WF_PACK)+ (uint) strlen(str)+1, - MYF(MY_WME))) - == 0) - DBUG_RETURN((WF_PACK *) NULL); - ret->wild= (char **) (ret+1); - buffer= (char *) (ret->wild+ant); - - ant=0; - for (pos=str ; *pos ; str= pos) - { - ret->wild[ant++]=buffer; - while (*pos != ' ' && *pos != ',' && *pos != '!' && *pos) - *buffer++ = *pos++; - - *buffer++ = '\0'; - while (*pos == ' ' || *pos == ',' || *pos == '!' ) - if (*pos++ == '!' && not_pos <0) - not_pos=(int) ant; - } - - ret->wilds=ant; - if (not_pos <0) - ret->not_pos=ant; - else - ret->not_pos=(uint) not_pos; - - DBUG_PRINT("exit",("antal: %d not_pos: %d",ret->wilds,ret->not_pos)); - DBUG_RETURN(ret); -} /* wf_comp */ - - - /* Test if a given filename is matched */ - -int wf_test(register WF_PACK *wf_pack, register const char *name) -{ - reg2 uint i; - reg3 uint not_pos; - DBUG_ENTER("wf_test"); - - if (! wf_pack || wf_pack->wilds == 0) - DBUG_RETURN(0); /* Everything goes */ - - not_pos=wf_pack->not_pos; - for (i=0 ; i < not_pos; i++) - if (wild_compare(name,wf_pack->wild[i],0) == 0) - goto found; - if (i) - DBUG_RETURN(1); /* No-match */ - -found: -/* Test that it isn't in not-list */ - - for (i=not_pos ; i < wf_pack->wilds; i++) - if (wild_compare(name,wf_pack->wild[i],0) == 0) - DBUG_RETURN(1); - DBUG_RETURN(0); -} /* wf_test */ - - - /* We need this because program don't know with malloc we used */ - -void wf_end(WF_PACK *buffer) -{ - DBUG_ENTER("wf_end"); - my_free(buffer); - DBUG_VOID_RETURN; -} /* wf_end */ diff --git a/mysys/my_append.c b/mysys/my_append.c deleted file mode 100644 index 1ef3905b6f5..00000000000 --- a/mysys/my_append.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (C) 2000 MySQL 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; version 2 of the License. - - 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 */ - -#include "mysys_priv.h" -#include <sys/stat.h> -#include <m_string.h> -#if defined(HAVE_UTIME_H) -#include <utime.h> -#elif defined(HAVE_SYS_UTIME_H) -#include <sys/utime.h> -#elif !defined(HPUX10) -struct utimbuf { - time_t actime; - time_t modtime; -}; -#endif - -/* - Append a file to another - - NOTES - Don't set MY_FNABP or MY_NABP bits on when calling this function -*/ - -int my_append(const char *from, const char *to, myf MyFlags) -{ - size_t Count; - File from_file,to_file; - uchar buff[IO_SIZE]; - DBUG_ENTER("my_append"); - DBUG_PRINT("my",("from %s to %s MyFlags %d", from, to, MyFlags)); - - from_file= to_file= -1; - - if ((from_file=my_open(from,O_RDONLY,MyFlags)) >= 0) - { - if ((to_file=my_open(to,O_APPEND | O_WRONLY,MyFlags)) >= 0) - { - while ((Count=my_read(from_file,buff,IO_SIZE,MyFlags)) != 0) - if (Count == (uint) -1 || - my_write(to_file,buff,Count,MYF(MyFlags | MY_NABP))) - goto err; - if (my_close(from_file,MyFlags) | my_close(to_file,MyFlags)) - DBUG_RETURN(-1); /* Error on close */ - DBUG_RETURN(0); - } - } -err: - if (from_file >= 0) (void) my_close(from_file,MyFlags); - if (to_file >= 0) (void) my_close(to_file,MyFlags); - DBUG_RETURN(-1); -} diff --git a/mysys/my_clock.c b/mysys/my_clock.c deleted file mode 100644 index da04feb462f..00000000000 --- a/mysys/my_clock.c +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (C) 2000 MySQL 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; version 2 of the License. - - 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 */ - -#include "my_global.h" - -#if !defined(_MSC_VER) && !defined(__BORLANDC__) -#include "mysys_priv.h" -#include <sys/times.h> -#endif - -long my_clock(void) -{ -#if !defined(__WIN__) - struct tms tmsbuf; - (void) times(&tmsbuf); - return (tmsbuf.tms_utime + tmsbuf.tms_stime); -#else - return clock(); -#endif -} diff --git a/mysys/my_dup.c b/mysys/my_dup.c deleted file mode 100644 index 5fdd6e9f364..00000000000 --- a/mysys/my_dup.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (C) 2000 MySQL 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; version 2 of the License. - - 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 */ - -#include "mysys_priv.h" -#include "mysys_err.h" -#include <my_dir.h> -#include <errno.h> -#if defined(__WIN__) -#include <share.h> -#endif - - /* Open a file */ - -File my_dup(File file, myf MyFlags) -{ - File fd; - const char *filename; - DBUG_ENTER("my_dup"); - DBUG_PRINT("my",("file: %d MyFlags: %d", file, MyFlags)); -#ifdef _WIN32 - fd= my_win_dup(file); -#else - fd= dup(file); -#endif - filename= (((uint) file < my_file_limit) ? - my_file_info[(int) file].name : "Unknown"); - DBUG_RETURN(my_register_filename(fd, filename, FILE_BY_DUP, - EE_FILENOTFOUND, MyFlags)); -} /* my_open */ diff --git a/mysys/my_init.c b/mysys/my_init.c index dbf1bfe761c..a3ca6159c77 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -138,9 +138,6 @@ my_bool my_init(void) #ifdef THREAD if (my_thread_global_init()) return 1; -#if !defined(__WIN__) - sigfillset(&my_signals); /* signals blocked by mf_brkhant */ -#endif #endif /* THREAD */ { DBUG_ENTER("my_init"); diff --git a/mysys/my_net.c b/mysys/my_net.c deleted file mode 100644 index e584e541175..00000000000 --- a/mysys/my_net.c +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (C) 2000 MySQL AB, 2008-2009 Sun Microsystems, Inc - - 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; version 2 of the License. - - 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 */ - -/* thread safe version of some common functions */ - -#include "mysys_priv.h" -#include <m_string.h> - -/* for thread safe my_inet_ntoa */ -#if !defined(__WIN__) -#include <netdb.h> -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif -#ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> -#endif -#ifdef HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif -#endif /* !defined(__WIN__) */ - -void my_inet_ntoa(struct in_addr in, char *buf) -{ - char *ptr; - mysql_mutex_lock(&THR_LOCK_net); - ptr=inet_ntoa(in); - strmov(buf,ptr); - mysql_mutex_unlock(&THR_LOCK_net); -} diff --git a/mysys/my_static.c b/mysys/my_static.c index 2869b43543a..d7354555f3d 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -43,9 +43,6 @@ struct st_my_file_info *my_file_info= my_file_info_default; int my_dont_interrupt=0; volatile int _my_signals=0; struct st_remember _my_sig_remember[MAX_SIGNALS]={{0,0}}; -#ifdef THREAD -sigset_t my_signals; /* signals blocked by mf_brkhant */ -#endif /* from mf_reccache.c */ ulong my_default_record_cache_size=RECORD_CACHE_SIZE; diff --git a/mysys/my_static.h b/mysys/my_static.h index 2c9cef0f101..7fde15ff133 100644 --- a/mysys/my_static.h +++ b/mysys/my_static.h @@ -25,9 +25,6 @@ C_MODE_START #include <signal.h> #define MAX_SIGNALS 10 /* Max signals under a dont-allow */ -#define MIN_KEYBLOCK (min(IO_SIZE,1024)) -#define MAX_KEYBLOCK 8192 /* Max keyblocklength == 8*IO_SIZE */ -#define MAX_BLOCK_TYPES MAX_KEYBLOCK/MIN_KEYBLOCK struct st_remember { int number; @@ -48,9 +45,6 @@ extern struct st_my_file_info my_file_info_default[MY_NFILE]; extern ulonglong query_performance_frequency, query_performance_offset; -#if defined(THREAD) && !defined(__WIN__) -extern sigset_t my_signals; /* signals blocked by mf_brkhant */ -#endif C_MODE_END #endif /* MYSYS_MY_STATIC_INCLUDED */ diff --git a/mysys/my_vle.c b/mysys/my_vle.c deleted file mode 100644 index 09f297eb553..00000000000 --- a/mysys/my_vle.c +++ /dev/null @@ -1,109 +0,0 @@ -/* Copyright (C) 2005 MySQL 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; version 2 of the License. - - 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 */ - -/* - Variable length encoding. - - A method to store an arbitrary-size non-negative integer. We let the - most significant bit of the number indicate that the next byte - should be contatenated to form the real number. -*/ - -#include "my_vle.h" - -/* - Function to encode an unsigned long as VLE. The bytes for the VLE - will be written to the location pointed to by 'out'. The maximum - number of bytes written will be 'max'. - - PARAMETERS - - out Pointer to beginning of where to store VLE bytes. - max Maximum number of bytes to write. - n Number to encode. - - RETURN VALUE - On success, one past the end of the array containing the VLE - bytes. On failure, the 'out' pointer is returned. -*/ - -uchar* -my_vle_encode(uchar* out, size_t max, ulong n) -{ - uchar buf[my_vle_sizeof(n)]; - uchar *ptr= buf; - size_t len; - - do - { - *ptr++= (uchar) (n & 0x7F); - n>>= 7; - } - while (n > 0); - - len= ptr - buf; - - if (len <= max) - { - /* - The bytes are stored in reverse order in 'buf'. Let's write them - in correct order to the output buffer and set the MSB at the - same time. - */ - while (ptr-- > buf) - { - uchar v= *ptr; - if (ptr > buf) - v|= 0x80; - *out++= v; - } - } - - return out; -} - -/* - Function to decode a VLE representation of an integral value. - - - PARAMETERS - - result_ptr Pointer to an unsigned long where the value will be written. - vle Pointer to the VLE bytes. - - RETURN VALUE - - One-past the end of the VLE bytes. The routine will never read - more than sizeof(*result_ptr) + 1 bytes. -*/ - -uchar const* -my_vle_decode(ulong *result_ptr, uchar const *vle) -{ - ulong result= 0; - size_t cnt= 1; - - do - { - result<<= 7; - result|= (*vle & 0x7F); - } - while ((*vle++ & 0x80) && ++cnt <= sizeof(*result_ptr) + 1); - - if (cnt <= sizeof(*result_ptr) + 1) - *result_ptr= result; - - return vle; -} diff --git a/mysys/test_fn.c b/mysys/test_fn.c deleted file mode 100644 index 249cc878390..00000000000 --- a/mysys/test_fn.c +++ /dev/null @@ -1,69 +0,0 @@ -/* Copyright (C) 2000 MySQL 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; version 2 of the License. - - 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 */ - -#include "mysys_priv.h" - -const char *test_names[]= -{ - "/usr/my/include/srclib/myfunc/dbug/test", - "test", - "dbug/test", - "/usr/my/srclib/myfunc/dbug/test", - "/usr/monty/oldcopy/jazz/setupp.frm", - "~/monty.tst", - "~/dbug/monty.tst", - "./hejsan", - "./dbug/test", - "../dbug/test", - "../myfunc/test", - "../../monty/rutedit", - "/usr/monty//usr/monty/rutedit", - "/usr/./monty/rutedit", - "/usr/my/../monty/rutedit", - "/usr/my/~/rutedit", - "~/../my", - "~/../my/srclib/myfunc/test", - "~/../my/srclib/myfunc/./dbug/test", - "/../usr/my/srclib/dbug", - "c/../my", - "/c/../my", - NullS, -}; - -int main(int argc __attribute__((unused)), char **argv) -{ - const char **pos; - char buff[FN_REFLEN],buff2[FN_REFLEN]; - DBUG_ENTER ("main"); - DBUG_PROCESS (argv[0]); - MY_INIT(argv[0]); - - if (argv[1] && argv[1][1] == '#') - DBUG_PUSH(argv[1]+2); - - for (pos=test_names; *pos ; pos++) - { - printf("org : '%s'\n",*pos); - printf("pack: '%s'\n",fn_format(buff,*pos,"","",8)); - printf("unpack: '%s'\n",fn_format(buff2,*pos,"","",4)); - unpack_filename(buff,buff); - if (strcmp(buff,buff2) != 0) - { - printf("error on cmp: '%s' != '%s'\n",buff,buff2); - } - puts(""); - } - DBUG_RETURN(0); -} diff --git a/mysys/trie.c b/mysys/trie.c deleted file mode 100644 index b2e93fcceac..00000000000 --- a/mysys/trie.c +++ /dev/null @@ -1,236 +0,0 @@ -/* Copyright (C) 2005 MySQL 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; version 2 of the License. - - 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 */ - -/* - Implementation of trie and Aho-Corasick automaton. - Supports only charsets that can be compared byte-wise. - - TODO: - Add character frequencies. Can increase lookup speed - up to 30%. - Implement character-wise comparision. -*/ - - -#include "mysys_priv.h" -#include <m_string.h> -#include <my_trie.h> -#include <my_base.h> - - -/* - SYNOPSIS - TRIE *trie_init (TRIE *trie, CHARSET_INFO *charset); - - DESCRIPTION - Allocates or initializes a `TRIE' object. If `trie' is a `NULL' - pointer, the function allocates, initializes, and returns a new - object. Otherwise, the object is initialized and the address of - the object is returned. If `trie_init()' allocates a new object, - it will be freed when `trie_free()' is called. - - RETURN VALUE - An initialized `TRIE*' object. `NULL' if there was insufficient - memory to allocate a new object. -*/ - -TRIE *trie_init (TRIE *trie, CHARSET_INFO *charset) -{ - MEM_ROOT mem_root; - DBUG_ENTER("trie_init"); - DBUG_ASSERT(charset); - init_alloc_root(&mem_root, - (sizeof(TRIE_NODE) * 128) + ALLOC_ROOT_MIN_BLOCK_SIZE, - sizeof(TRIE_NODE) * 128); - if (! trie) - { - if (! (trie= (TRIE *)alloc_root(&mem_root, sizeof(TRIE)))) - { - free_root(&mem_root, MYF(0)); - DBUG_RETURN(NULL); - } - } - - memcpy(&trie->mem_root, &mem_root, sizeof(MEM_ROOT)); - trie->root.leaf= 0; - trie->root.c= 0; - trie->root.next= NULL; - trie->root.links= NULL; - trie->root.fail= NULL; - trie->charset= charset; - trie->nnodes= 0; - trie->nwords= 0; - DBUG_RETURN(trie); -} - - -/* - SYNOPSIS - void trie_free (TRIE *trie); - trie - valid pointer to `TRIE' - - DESCRIPTION - Frees the memory allocated for a `trie'. - - RETURN VALUE - None. -*/ - -void trie_free (TRIE *trie) -{ - MEM_ROOT mem_root; - DBUG_ENTER("trie_free"); - DBUG_ASSERT(trie); - memcpy(&mem_root, &trie->mem_root, sizeof(MEM_ROOT)); - free_root(&mem_root, MYF(0)); - DBUG_VOID_RETURN; -} - - -/* - SYNOPSIS - my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen); - trie - valid pointer to `TRIE' - key - valid pointer to key to insert - keylen - non-0 key length - - DESCRIPTION - Inserts new key into trie. - - RETURN VALUE - Upon successful completion, `trie_insert' returns `FALSE'. Otherwise - `TRUE' is returned. - - NOTES - If this function fails you must assume `trie' is broken. - However it can be freed with trie_free(). -*/ - -my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen) -{ - TRIE_NODE *node; - TRIE_NODE *next; - uchar p; - uint k; - DBUG_ENTER("trie_insert"); - DBUG_ASSERT(trie && key && keylen); - node= &trie->root; - trie->root.fail= NULL; - for (k= 0; k < keylen; k++) - { - p= key[k]; - for (next= node->links; next; next= next->next) - if (next->c == p) - break; - - if (! next) - { - TRIE_NODE *tmp= (TRIE_NODE *)alloc_root(&trie->mem_root, - sizeof(TRIE_NODE)); - if (! tmp) - DBUG_RETURN(TRUE); - tmp->leaf= 0; - tmp->c= p; - tmp->links= tmp->fail= tmp->next= NULL; - trie->nnodes++; - if (! node->links) - { - node->links= tmp; - } - else - { - for (next= node->links; next->next; next= next->next) /* no-op */; - next->next= tmp; - } - node= tmp; - } - else - { - node= next; - } - } - node->leaf= keylen; - trie->nwords++; - DBUG_RETURN(FALSE); -} - - -/* - SYNOPSIS - my_bool trie_prepare (TRIE *trie); - trie - valid pointer to `TRIE' - - DESCRIPTION - Constructs Aho-Corasick automaton. - - RETURN VALUE - Upon successful completion, `trie_prepare' returns `FALSE'. Otherwise - `TRUE' is returned. -*/ - -my_bool ac_trie_prepare (TRIE *trie) -{ - TRIE_NODE **tmp_nodes; - TRIE_NODE *node; - uint32 fnode= 0; - uint32 lnode= 0; - DBUG_ENTER("trie_prepare"); - DBUG_ASSERT(trie); - - tmp_nodes= (TRIE_NODE **)my_malloc(trie->nnodes * sizeof(TRIE_NODE *), MYF(0)); - if (! tmp_nodes) - DBUG_RETURN(TRUE); - - trie->root.fail= &trie->root; - for (node= trie->root.links; node; node= node->next) - { - node->fail= &trie->root; - tmp_nodes[lnode++]= node; - } - - while (fnode < lnode) - { - TRIE_NODE *current= (TRIE_NODE *)tmp_nodes[fnode++]; - for (node= current->links; node; node= node->next) - { - TRIE_NODE *fail= current->fail; - tmp_nodes[lnode++]= node; - while (! (node->fail= trie_goto(&trie->root, fail, node->c))) - fail= fail->fail; - } - } - my_free(tmp_nodes); - DBUG_RETURN(FALSE); -} - - -/* - SYNOPSIS - void ac_trie_init (TRIE *trie, AC_TRIE_STATE *state); - trie - valid pointer to `TRIE' - state - value pointer to `AC_TRIE_STATE' - - DESCRIPTION - Initializes `AC_TRIE_STATE' object. -*/ - -void ac_trie_init (TRIE *trie, AC_TRIE_STATE *state) -{ - DBUG_ENTER("ac_trie_init"); - DBUG_ASSERT(trie && state); - state->trie= trie; - state->node= &trie->root; - DBUG_VOID_RETURN; -} diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt index 7107a68ee84..b3ac22aca01 100644 --- a/sql/CMakeLists.txt +++ b/sql/CMakeLists.txt @@ -60,7 +60,7 @@ SET (SQL_SOURCE sql_cache.cc sql_class.cc sql_client.cc sql_crypt.cc sql_crypt.h sql_cursor.cc sql_db.cc sql_delete.cc sql_derived.cc sql_do.cc sql_error.cc sql_handler.cc sql_help.cc sql_insert.cc sql_lex.cc - sql_list.cc sql_load.cc sql_manager.cc sql_map.cc sql_parse.cc + sql_list.cc sql_load.cc sql_manager.cc sql_parse.cc sql_partition.cc sql_plugin.cc sql_prepare.cc sql_rename.cc debug_sync.cc debug_sync.h sql_repl.cc sql_select.cc sql_show.cc sql_state.c sql_string.cc diff --git a/sql/Makefile.am b/sql/Makefile.am index 4b1ecbbc8da..7fed55f3cd6 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -90,7 +90,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ item_create.h item_subselect.h item_row.h \ sql_priv.h item_geofunc.h sql_bitmap.h \ procedure.h sql_class.h sql_lex.h sql_list.h \ - sql_map.h sql_string.h unireg.h \ + sql_string.h unireg.h \ sql_error.h field.h handler.h mysqld_suffix.h \ sql_profile.h mysqld.h sql_help.h frm_crypt.h \ ha_ndbcluster.h ha_ndbcluster_cond.h \ @@ -135,7 +135,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \ item_row.cc item_geofunc.cc item_xmlfunc.cc \ field.cc strfunc.cc key.cc sql_class.cc sql_list.cc \ net_serv.cc protocol.cc sql_state.c \ - lock.cc sql_string.cc sql_manager.cc sql_map.cc \ + lock.cc sql_string.cc sql_manager.cc \ main.cc mysqld.cc password.c hash_filo.cc hostname.cc \ sql_connect.cc scheduler.cc sql_parse.cc \ keycaches.cc set_var.cc sql_yacc.yy sys_vars.cc \ @@ -160,8 +160,7 @@ mysqld_SOURCES = sql_lex.cc sql_handler.cc sql_partition.cc \ rpl_reporting.cc \ sql_union.cc sql_derived.cc \ sql_client.cc \ - repl_failsafe.h repl_failsafe.cc \ - sql_olap.cc sql_view.cc \ + repl_failsafe.h repl_failsafe.cc sql_view.cc \ gstream.cc spatial.cc sql_help.cc sql_cursor.cc \ tztime.cc my_decimal.cc\ sp_head.cc sp_pcontext.cc sp_rcontext.cc sp.cc \ diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7ce27f4ba4f..4c0d290f2cc 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -602,7 +602,7 @@ pthread_key(MEM_ROOT**,THR_MALLOC); pthread_key(THD*, THR_THD); mysql_mutex_t LOCK_thread_count; mysql_mutex_t LOCK_mysql_create_db, LOCK_open, - LOCK_mapped_file, LOCK_status, LOCK_global_read_lock, + LOCK_status, LOCK_global_read_lock, LOCK_error_log, LOCK_uuid_generator, LOCK_delayed_insert, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, @@ -1532,7 +1532,6 @@ static void clean_up_mutexes() mysql_rwlock_destroy(&LOCK_grant); mysql_mutex_destroy(&LOCK_open); mysql_mutex_destroy(&LOCK_thread_count); - mysql_mutex_destroy(&LOCK_mapped_file); mysql_mutex_destroy(&LOCK_status); mysql_mutex_destroy(&LOCK_delayed_insert); mysql_mutex_destroy(&LOCK_delayed_status); @@ -3512,7 +3511,6 @@ static int init_thread_environment() mysql_mutex_init(key_LOCK_lock_db, &LOCK_lock_db, MY_MUTEX_INIT_SLOW); mysql_mutex_init(key_LOCK_open, &LOCK_open, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_thread_count, &LOCK_thread_count, MY_MUTEX_INIT_FAST); - mysql_mutex_init(key_LOCK_mapped_file, &LOCK_mapped_file, MY_MUTEX_INIT_SLOW); mysql_mutex_init(key_LOCK_status, &LOCK_status, MY_MUTEX_INIT_FAST); mysql_mutex_init(key_LOCK_delayed_insert, &LOCK_delayed_insert, MY_MUTEX_INIT_FAST); @@ -7691,7 +7689,7 @@ PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids, key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create, key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log, key_LOCK_gdl, key_LOCK_global_read_lock, key_LOCK_global_system_variables, - key_LOCK_lock_db, key_LOCK_manager, key_LOCK_mapped_file, + key_LOCK_lock_db, key_LOCK_manager, key_LOCK_mysql_create_db, key_LOCK_open, key_LOCK_prepared_stmt_count, key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status, key_LOCK_system_variables_hash, key_LOCK_table_share, key_LOCK_thd_data, @@ -7732,7 +7730,6 @@ static PSI_mutex_info all_server_mutexes[]= { &key_LOCK_global_system_variables, "LOCK_global_system_variables", PSI_FLAG_GLOBAL}, { &key_LOCK_lock_db, "LOCK_lock_db", PSI_FLAG_GLOBAL}, { &key_LOCK_manager, "LOCK_manager", PSI_FLAG_GLOBAL}, - { &key_LOCK_mapped_file, "LOCK_mapped_file", PSI_FLAG_GLOBAL}, { &key_LOCK_mysql_create_db, "LOCK_mysql_create_db", PSI_FLAG_GLOBAL}, { &key_LOCK_open, "LOCK_open", PSI_FLAG_GLOBAL}, { &key_LOCK_prepared_stmt_count, "LOCK_prepared_stmt_count", PSI_FLAG_GLOBAL}, diff --git a/sql/mysqld.h b/sql/mysqld.h index 626c2d116f5..91bdc600cda 100644 --- a/sql/mysqld.h +++ b/sql/mysqld.h @@ -228,7 +228,7 @@ extern PSI_mutex_key key_BINLOG_LOCK_index, key_BINLOG_LOCK_prep_xids, key_LOCK_connection_count, key_LOCK_crypt, key_LOCK_delayed_create, key_LOCK_delayed_insert, key_LOCK_delayed_status, key_LOCK_error_log, key_LOCK_gdl, key_LOCK_global_read_lock, key_LOCK_global_system_variables, - key_LOCK_lock_db, key_LOCK_logger, key_LOCK_manager, key_LOCK_mapped_file, + key_LOCK_lock_db, key_LOCK_logger, key_LOCK_manager, key_LOCK_mysql_create_db, key_LOCK_open, key_LOCK_prepared_stmt_count, key_LOCK_rpl_status, key_LOCK_server_started, key_LOCK_status, key_LOCK_table_share, key_LOCK_thd_data, @@ -317,7 +317,7 @@ extern MYSQL_PLUGIN_IMPORT key_map key_map_full; /* Should be threaded Server mutex locks and condition variables. */ extern mysql_mutex_t LOCK_mysql_create_db, LOCK_open, LOCK_lock_db, - LOCK_mapped_file, LOCK_user_locks, LOCK_status, + LOCK_user_locks, LOCK_status, LOCK_error_log, LOCK_delayed_insert, LOCK_uuid_generator, LOCK_delayed_status, LOCK_delayed_create, LOCK_crypt, LOCK_timezone, LOCK_slave_list, LOCK_active_mi, LOCK_manager, LOCK_global_read_lock, diff --git a/sql/sql_map.cc b/sql/sql_map.cc deleted file mode 100644 index ca8a88bcbf8..00000000000 --- a/sql/sql_map.cc +++ /dev/null @@ -1,144 +0,0 @@ -/* Copyright (C) 2000-2001, 2004-2005 MySQL AB, 2008-2009 Sun Microsystems, Inc - - 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; version 2 of the License. - - 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 */ - - -#ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation // gcc: Class implementation -#endif - -#include "sql_priv.h" -#include "unireg.h" // REQUIRED: for other includes -#include "sql_map.h" // mapped_files -#include "sql_class.h" // THD - -#include <sys/stat.h> -#ifdef HAVE_SYS_MMAN_H -#include <sys/mman.h> -#endif - -mapped_files::mapped_files(const char * filename,uchar *magic,uint magic_length) -{ -#ifdef HAVE_MMAP - name=my_strdup(filename,MYF(0)); - use_count=1; - error=0; - map=0; - size=0; - if ((file= mysql_file_open(key_file_map, name, O_RDONLY, MYF(MY_WME))) >= 0) - { - struct stat stat_buf; - if (!fstat(file, &stat_buf)) - { - if (!(map=(uchar*) my_mmap(0,(size_t)(size= stat_buf.st_size),PROT_READ, - MAP_SHARED | MAP_NORESERVE,file, - 0L))) - { - error=errno; - my_error(ER_NO_FILE_MAPPING, MYF(0), (char *) name, error); - } - } - if (map && memcmp(map,magic,magic_length)) - { - my_error(ER_WRONG_MAGIC, MYF(0), name); - (void) my_munmap((char*) map,(size_t)size); - map=0; - } - if (!map) - { - (void) mysql_file_close(file, MYF(0)); - file= -1; - } - } -#endif -} - - -mapped_files::~mapped_files() -{ -#ifdef HAVE_MMAP - if (file >= 0) - { - (void) my_munmap((char*) map,(size_t)size); - (void) mysql_file_close(file, MYF(0)); - file= -1; map=0; - } - my_free(name); -#endif -} - - -static I_List<mapped_files> maps_in_use; - -/* -** Check if a file is mapped. If it is, then return pointer to old map, -** else alloc new object -*/ - -mapped_files *map_file(const char * name,uchar *magic,uint magic_length) -{ -#ifdef HAVE_MMAP - mysql_mutex_lock(&LOCK_mapped_file); - I_List_iterator<mapped_files> list(maps_in_use); - mapped_files *map; - char path[FN_REFLEN]; - sprintf(path,"%s/%s/%s.uniq",mysql_data_home,current_thd->db,name); - (void) unpack_filename(path,path); - - while ((map=list++)) - { - if (!strcmp(path,map->name)) - break; - } - if (!map) - { - map=new mapped_files(path,magic,magic_length); - maps_in_use.append(map); - } - else - { - map->use_count++; - if (!map->map) - my_error(ER_NO_FILE_MAPPING, MYF(0), path, map->error); - } - mysql_mutex_unlock(&LOCK_mapped_file); - return map; -#else - return NULL; -#endif -} - -/* -** free the map if there are no more users for it -*/ - -void unmap_file(mapped_files *map) -{ -#ifdef HAVE_MMAP - mysql_mutex_lock(&LOCK_mapped_file); - if (!map->use_count--) - delete map; - mysql_mutex_unlock(&LOCK_mapped_file); -#endif -} - -/***************************************************************************** -** Instansiate templates -*****************************************************************************/ - -#ifdef HAVE_EXPLICIT_TEMPLATE_INSTANTIATION -/* Used templates */ -template class I_List<mapped_files>; -template class I_List_iterator<mapped_files>; -#endif diff --git a/sql/sql_map.h b/sql/sql_map.h deleted file mode 100644 index be1c145df3f..00000000000 --- a/sql/sql_map.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef SQL_MAP_INCLUDED -#define SQL_MAP_INCLUDED - -/* Copyright (C) 2000-2001, 2005 MySQL 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; version 2 of the License. - - 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 */ - - -/* interface for memory mapped files */ - -#ifdef USE_PRAGMA_INTERFACE -#pragma interface /* gcc class implementation */ -#endif - -#include "my_base.h" /* ha_rows */ -#include "sql_list.h" /* ilink */ - -class mapped_files; -mapped_files *map_file(const char * name,uchar *magic,uint magic_length); -void unmap_file(mapped_files *map); - -class mapped_files :public ilink { - uchar *map; - ha_rows size; - char *name; // name of mapped file - File file; // >= 0 if open - int error; // If not mapped - uint use_count; - -public: - mapped_files(const char * name,uchar *magic,uint magic_length); - ~mapped_files(); - - friend class mapped_file; - friend mapped_files *map_file(const char * name,uchar *magic, - uint magic_length); - friend void unmap_file(mapped_files *map); -}; - - -class mapped_file -{ - mapped_files *file; -public: - mapped_file(const char * name,uchar *magic,uint magic_length) - { - file=map_file(name,magic,magic_length); /* old or new map */ - } - ~mapped_file() - { - unmap_file(file); /* free map */ - } - uchar *map() - { - return file->map; - } -}; - -#endif /* SQL_MAP_INCLUDED */ diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc deleted file mode 100644 index b957d1e9be4..00000000000 --- a/sql/sql_olap.cc +++ /dev/null @@ -1,188 +0,0 @@ -/* Copyright (C) 2000-2006 MySQL 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; version 2 of the License. - - 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 */ - - -/* - OLAP implementation by Sinisa Milivojevic <sinisa@mysql.com> - Inspired by code submitted by Srilakshmi <lakshmi@gdit.iiit.net> - - The ROLLUP code in this file has to be complitely rewritten as it's - not good enough to satisfy the goals of MySQL. - - In 4.1 we will replace this with a working, superior implementation - of ROLLUP. -*/ - -#ifdef DISABLED_UNTIL_REWRITTEN_IN_4_1 - -#ifdef USE_PRAGMA_IMPLEMENTATION -#pragma implementation // gcc: Class implementation -#endif - -#include "sql_priv.h" -#include "unireg.h" -#include "sql_select.h" - - -/**************************************************************************** - Functions that recursively actually creates new SELECT's - Returns 0 if OK, 1 if error, -1 if error already printed to client -****************************************************************************/ - - -static int make_new_olap_select(LEX *lex, SELECT_LEX *select_lex, List<Item> new_fields) -{ - THD *thd=current_thd; - Item *item, *new_item; - Item_null *constant= new Item_null("ALL"); - - SELECT_LEX *new_select = (SELECT_LEX *) thd->memdup((char*) select_lex, sizeof(*select_lex)); - if (!new_select) - return 1; - lex->last_selects->next=new_select; - new_select->linkage=OLAP_TYPE; - new_select->olap=NON_EXISTING_ONE; - new_select->group_list.elements=0; - new_select->group_list.first=(uchar *)0; - new_select->group_list.next=(uchar **)&new_select->group_list.first; - List<Item> privlist; - - List_iterator<Item> list_it(select_lex->item_list); - List_iterator<Item> new_it(new_fields); - - while ((item=list_it++)) - { - bool not_found= TRUE; - if (item->type()==Item::FIELD_ITEM) - { - Item_field *iif = (Item_field *)item; - new_it.rewind(); - while ((new_item=new_it++)) - { - if (new_item->type()==Item::FIELD_ITEM && - !strcmp(((Item_field*)new_item)->table_name,iif->table_name) && - !strcmp(((Item_field*)new_item)->field_name,iif->field_name)) - { - not_found= 0; - ((Item_field*)new_item)->db_name=iif->db_name; - Item_field *new_one=new Item_field(&select_lex->context, - iif->db_name, iif->table_name, iif->field_name); - privlist.push_back(new_one); - if (add_to_list(new_select->group_list,new_one,1)) - return 1; - break; - } - } - } - if (not_found) - { - if (item->type() == Item::FIELD_ITEM) - privlist.push_back(constant); - else - privlist.push_back((Item*)thd->memdup((char *)item,item->size_of())); - } - } - new_select->item_list=privlist; - - lex->last_selects = new_select; - return 0; -} - -/**************************************************************************** - Functions that recursively creates combinations of queries for OLAP - Returns 0 if OK, 1 if error, -1 if error already printed to client -****************************************************************************/ - -static int olap_combos(List<Item> old_fields, List<Item> new_fields, Item *item, LEX *lex, - SELECT_LEX *select_lex, int position, int selection, int num_fields, - int num_new_fields) -{ - int sl_return = 0; - if (position == num_new_fields) - { - if (item) - new_fields.push_front(item); - sl_return = make_new_olap_select(lex, select_lex, new_fields); - } - else - { - if (item) - new_fields.push_front(item); - while ((num_fields - num_new_fields >= selection - position) && !sl_return) - { - item = old_fields.pop(); - sl_return = olap_combos(old_fields, new_fields, item, lex, select_lex, position+1, ++selection, num_fields, num_new_fields); - } - } - return sl_return; -} - - -/**************************************************************************** - Top level function for converting OLAP clauses to multiple selects - This is also a place where clauses treatment depends on OLAP type - Returns 0 if OK, 1 if error, -1 if error already printed to client -****************************************************************************/ - -int handle_olaps(LEX *lex, SELECT_LEX *select_lex) -{ - List<Item> item_list_copy, new_item_list; - item_list_copy.empty(); - new_item_list.empty(); - int count=select_lex->group_list.elements; - int sl_return=0; - - - lex->last_selects=select_lex; - - for (ORDER *order= select_lex->group_list.first ; order ; order=order->next) - item_list_copy.push_back(*(order->item)); - - List<Item> all_fields(select_lex->item_list); - - - if (setup_tables(lex->thd, &select_lex->context, &select_lex->top_join_list, - select_lex->table_list.first - &select_lex->leaf_tables, FALSE) || - setup_fields(lex->thd, 0, select_lex->item_list, MARK_COLUMNS_READ, - &all_fields,1) || - setup_fields(lex->thd, 0, item_list_copy, MARK_COLUMNS_READ, - &all_fields, 1)) - return -1; - - if (select_lex->olap == CUBE_TYPE) - { - for ( int i=count-1; i>=0 && !sl_return; i--) - sl_return=olap_combos(item_list_copy, new_item_list, (Item *)0, lex, select_lex, 0, 0, count, i); - } - else if (select_lex->olap == ROLLUP_TYPE) - { - for ( int i=count-1; i>=0 && !sl_return; i--) - { - Item *item; - item_list_copy.pop(); - List_iterator<Item> it(item_list_copy); - new_item_list.empty(); - while ((item = it++)) - new_item_list.push_front(item); - sl_return=make_new_olap_select(lex, select_lex, new_item_list); - } - } - else - sl_return=1; // impossible - return sl_return; -} - -#endif /* DISABLED_UNTIL_REWRITTEN_IN_4_1 */ |