From c55ac34fef7dc6d71f68f5beec04c7f791e94a19 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Thu, 20 Sep 2001 20:22:43 +0300 Subject: [PATCH 01/13] Some fixes for Gemini --- acinclude.m4 | 3 +-- sql-bench/server-cfg.sh | 1 + sql/field.cc | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 8fb3e986b11..86eed5e69c7 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -1008,8 +1008,7 @@ dnl echo "DBG_GEM1: gemini='$gemini'" gemini_libs="\ ../gemini/api/libapi.a\ ../gemini/db/libdb.a\ - ../gemini/dbut/libdbut.a\ - ../gemini/vst/libvst.a" + ../gemini/dbut/libdbut.a" AC_MSG_RESULT([Using Gemini DB]) ;; esac diff --git a/sql-bench/server-cfg.sh b/sql-bench/server-cfg.sh index a8d992bfdce..b4e134cd2c1 100644 --- a/sql-bench/server-cfg.sh +++ b/sql-bench/server-cfg.sh @@ -199,6 +199,7 @@ sub new $main::opt_create_options =~ /type=gemini/i) { $limits{'working_blobs'} = 0; # Blobs not implemented yet + $limits{'max_tables'} = 500; } return $self; diff --git a/sql/field.cc b/sql/field.cc index 01178efbdb1..b34f58439db 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4122,7 +4122,7 @@ ulonglong Field_blob::get_id(const char *from) ulonglong id = 0; ulong length=get_length(from); if (length) - uint8korr(id, from+packlength); + id=uint8korr(from+packlength); return id; } From 59f9fc4fe2d503af1bfb414496f3b507a91ce31b Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Thu, 20 Sep 2001 21:04:48 +0300 Subject: [PATCH 02/13] mem0mem.ic Changes to eliminate unnecessary Purify warnings ut0mem.h Changes to eliminate unnecessary Purify warnings ut0mem.ic Changes to eliminate unnecessary Purify warnings srv0start.c Changes to eliminate unnecessary Purify warnings mem0pool.c Changes to eliminate unnecessary Purify warnings ut0mem.c Changes to eliminate unnecessary Purify warnings --- innobase/include/mem0mem.ic | 12 +++- innobase/include/ut0mem.h | 35 ++++++++-- innobase/include/ut0mem.ic | 7 -- innobase/mem/mem0pool.c | 6 +- innobase/srv/srv0start.c | 2 + innobase/ut/ut0mem.c | 132 ++++++++++++++++++++++++++++++++---- 6 files changed, 167 insertions(+), 27 deletions(-) diff --git a/innobase/include/mem0mem.ic b/innobase/include/mem0mem.ic index 8b8449469ef..edc3ab17f2a 100644 --- a/innobase/include/mem0mem.ic +++ b/innobase/include/mem0mem.ic @@ -170,7 +170,9 @@ mem_heap_alloc( buf = (byte*)buf + MEM_FIELD_HEADER_SIZE; #endif - +#ifdef UNIV_SET_MEM_TO_ZERO + memset(buf, '\0', n); +#endif return(buf); } @@ -494,8 +496,14 @@ mem_alloc_func( ) { #ifndef UNIV_MEM_DEBUG + void* buf; - return(mem_area_alloc(n, mem_comm_pool)); + buf = mem_area_alloc(n, mem_comm_pool); + +#ifdef UNIV_SET_MEM_TO_ZERO + memset(buf, '\0', n); +#endif + return(buf); #else diff --git a/innobase/include/ut0mem.h b/innobase/include/ut0mem.h index fa46514fe16..8e5a4fda0d3 100644 --- a/innobase/include/ut0mem.h +++ b/innobase/include/ut0mem.h @@ -26,12 +26,39 @@ int ut_memcmp(void* str1, void* str2, ulint n); -void* -ut_malloc(ulint n); +/************************************************************************** +Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is +defined and set_to_zero is TRUE. */ + +void* +ut_malloc_low( +/*==========*/ + /* out, own: allocated memory */ + ulint n, /* in: number of bytes to allocate */ + ibool set_to_zero); /* in: TRUE if allocated memory should be set + to zero if UNIV_SET_MEM_TO_ZERO is defined */ +/************************************************************************** +Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is +defined. */ + +void* +ut_malloc( +/*======*/ + /* out, own: allocated memory */ + ulint n); /* in: number of bytes to allocate */ +/************************************************************************** +Frees a memory bloock allocated with ut_malloc. */ -UNIV_INLINE void -ut_free(void* ptr); +ut_free( +/*====*/ + void* ptr); /* in, own: memory block */ +/************************************************************************** +Frees all allocated memory not freed yet. */ + +void +ut_free_all_mem(void); +/*=================*/ UNIV_INLINE char* diff --git a/innobase/include/ut0mem.ic b/innobase/include/ut0mem.ic index fc4b6bd8be5..7ae9bc8bd74 100644 --- a/innobase/include/ut0mem.ic +++ b/innobase/include/ut0mem.ic @@ -27,13 +27,6 @@ ut_memcmp(void* str1, void* str2, ulint n) return(memcmp(str1, str2, n)); } -UNIV_INLINE -void -ut_free(void* ptr) -{ - free(ptr); -} - UNIV_INLINE char* ut_strcpy(char* dest, char* sour) diff --git a/innobase/mem/mem0pool.c b/innobase/mem/mem0pool.c index e8c02d812c4..6c3a4adebae 100644 --- a/innobase/mem/mem0pool.c +++ b/innobase/mem/mem0pool.c @@ -170,7 +170,11 @@ mem_pool_create( pool = ut_malloc(sizeof(mem_pool_t)); - pool->buf = ut_malloc(size); + /* We do not set the memory to zero (FALSE) in the pool, + but only when allocated at a higher level in mem0mem.c. + This is to avoid masking useful Purify warnings. */ + + pool->buf = ut_malloc_low(size, FALSE); pool->size = size; mutex_create(&(pool->mutex)); diff --git a/innobase/srv/srv0start.c b/innobase/srv/srv0start.c index c4002767226..15d99ab3001 100644 --- a/innobase/srv/srv0start.c +++ b/innobase/srv/srv0start.c @@ -916,5 +916,7 @@ innobase_shutdown_for_mysql(void) logs_empty_and_mark_files_at_shutdown(); + ut_free_all_mem(); + return((int) DB_SUCCESS); } diff --git a/innobase/ut/ut0mem.c b/innobase/ut/ut0mem.c index 492f57670a9..ebeefe0c297 100644 --- a/innobase/ut/ut0mem.c +++ b/innobase/ut/ut0mem.c @@ -14,30 +14,136 @@ Created 5/11/1994 Heikki Tuuri #include "mem0mem.h" + +/* This struct is placed first in every allocated memory block */ +typedef struct ut_mem_block_struct ut_mem_block_t; + +struct ut_mem_block_struct{ + UT_LIST_NODE_T(ut_mem_block_t) mem_block_list;/* mem block list node */ +}; + + +/* List of all memory blocks allocated from the operating system +with malloc */ +UT_LIST_BASE_NODE_T(ut_mem_block_t) ut_mem_block_list; + +os_fast_mutex_t ut_list_mutex; /* this protects the list */ + +ibool ut_mem_block_list_inited = FALSE; + +/************************************************************************** +Initializes the mem block list at database startup. */ +static +void +ut_mem_block_list_init(void) +/*========================*/ +{ + os_fast_mutex_init(&ut_list_mutex); + UT_LIST_INIT(ut_mem_block_list); + ut_mem_block_list_inited = TRUE; +} + +/************************************************************************** +Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is +defined and set_to_zero is TRUE. */ + void* -ut_malloc(ulint n) +ut_malloc_low( +/*==========*/ + /* out, own: allocated memory */ + ulint n, /* in: number of bytes to allocate */ + ibool set_to_zero) /* in: TRUE if allocated memory should be set + to zero if UNIV_SET_MEM_TO_ZERO is defined */ { void* ret; - /* - ret = VirtualAlloc(NULL, n, MEM_COMMIT, PAGE_READWRITE); - */ - ret = malloc(n); + ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */ + + if (!ut_mem_block_list_inited) { + ut_mem_block_list_init(); + } + + os_fast_mutex_lock(&ut_list_mutex); + + ret = malloc(n + sizeof(ut_mem_block_t)); if (ret == NULL) { fprintf(stderr, - "Innobase: Fatal error: cannot allocate memory!\n"); - fprintf(stderr, - "Innobase: Cannot continue operation!\n"); - fprintf(stderr, - "Innobase: Check if you can increase the swap file of your\n"); - fprintf(stderr, - "Innobase: operating system.\n"); + "InnoDB: Fatal error: cannot allocate %lu bytes of\n" + "InnoDB: memory with malloc!\n" + "InnoDB: Operating system errno: %lu\n" + "InnoDB: Cannot continue operation!\n" + "InnoDB: Check if you should increase the swap file or\n" + "InnoDB: ulimits of your operating system.\n", n, errno); + + os_fast_mutex_unlock(&ut_list_mutex); exit(1); } - return(ret); + if (set_to_zero) { +#ifdef UNIV_SET_MEM_TO_ZERO + memset(ret, '\0', n + sizeof(ut_mem_block_t)); +#endif + } + + UT_LIST_ADD_FIRST(mem_block_list, ut_mem_block_list, + ((ut_mem_block_t*)ret)); + os_fast_mutex_unlock(&ut_list_mutex); + + return((void*)((byte*)ret + sizeof(ut_mem_block_t))); +} + +/************************************************************************** +Allocates memory. Sets it also to zero if UNIV_SET_MEM_TO_ZERO is +defined. */ + +void* +ut_malloc( +/*======*/ + /* out, own: allocated memory */ + ulint n) /* in: number of bytes to allocate */ +{ + return(ut_malloc_low(n, TRUE)); +} +/************************************************************************** +Frees a memory bloock allocated with ut_malloc. */ + +void +ut_free( +/*====*/ + void* ptr) /* in, own: memory block */ +{ + ut_mem_block_t* block; + + block = (ut_mem_block_t*)((byte*)ptr - sizeof(ut_mem_block_t)); + + os_fast_mutex_lock(&ut_list_mutex); + + UT_LIST_REMOVE(mem_block_list, ut_mem_block_list, block); + free(block); + + os_fast_mutex_unlock(&ut_list_mutex); +} + +/************************************************************************** +Frees all allocated memory not freed yet. */ + +void +ut_free_all_mem(void) +/*=================*/ +{ + ut_mem_block_t* block; + + os_fast_mutex_lock(&ut_list_mutex); + + while (block = UT_LIST_GET_FIRST(ut_mem_block_list)) { + + UT_LIST_REMOVE(mem_block_list, ut_mem_block_list, block); + free(block); + } + + os_fast_mutex_unlock(&ut_list_mutex); } /************************************************************************** From 0b064c3b0903ced19a97e4526e344226a42cb27f Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Thu, 20 Sep 2001 21:14:49 +0300 Subject: [PATCH 03/13] univ.i Changes to eliminate unnecessary Purify warnings (documentation of flag UNIV_SET_MEM_TO_ZERO) --- innobase/include/univ.i | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/innobase/include/univ.i b/innobase/include/univ.i index f3e3b22bb3d..9fc9f85f633 100644 --- a/innobase/include/univ.i +++ b/innobase/include/univ.i @@ -61,8 +61,12 @@ subdirectory of 'mysql'. */ /* DEBUG VERSION CONTROL ===================== */ +/* The following flag will make InnoDB to initialize +all memory it allocates to zero. It hides Purify +warnings about reading unallocated memory unless +memory is read outside the allocated blocks. */ /* -#define UNIV_SYNC_DEBUG +#define UNIV_INIT_MEM_TO_ZERO */ /* Make a non-inline debug version */ @@ -72,7 +76,7 @@ subdirectory of 'mysql'. */ #define UNIV_SEARCH_DEBUG #define UNIV_IBUF_DEBUG - +#define UNIV_SYNC_DEBUG #define UNIV_SYNC_PERF_STAT #define UNIV_SEARCH_PERF_STAT */ From e2389946dd46fb5cf0fa92532c757d683d83c61b Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Thu, 20 Sep 2001 21:38:46 +0300 Subject: [PATCH 04/13] os0sync.h Define os_fast_mutex functions also in Windows os0sync.ic Define os_fast_mutex functions also in Windows --- innobase/include/os0sync.h | 2 +- innobase/include/os0sync.ic | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/innobase/include/os0sync.h b/innobase/include/os0sync.h index 89e3f953b50..78374cf8ede 100644 --- a/innobase/include/os0sync.h +++ b/innobase/include/os0sync.h @@ -160,6 +160,7 @@ os_fast_mutex_trylock( was reserved by another thread */ os_fast_mutex_t* fast_mutex); /* in: mutex to acquire */ +#endif /************************************************************** Releases ownership of a fast mutex. */ UNIV_INLINE @@ -188,7 +189,6 @@ void os_fast_mutex_free( /*===============*/ os_fast_mutex_t* fast_mutex); /* in: mutex to free */ -#endif #ifndef UNIV_NONINL #include "os0sync.ic" diff --git a/innobase/include/os0sync.ic b/innobase/include/os0sync.ic index 8be9a783593..057ad424dee 100644 --- a/innobase/include/os0sync.ic +++ b/innobase/include/os0sync.ic @@ -38,6 +38,7 @@ os_fast_mutex_trylock( return((ulint) pthread_mutex_trylock(fast_mutex)); #endif } +#endif /************************************************************** Releases ownership of a fast mutex. */ @@ -53,4 +54,3 @@ os_fast_mutex_unlock( pthread_mutex_unlock(fast_mutex); #endif } -#endif From df1045ee3c5c25eb62fb1cb8a065fa1bf0d8b902 Mon Sep 17 00:00:00 2001 From: "heikki@donna.mysql.fi" <> Date: Thu, 20 Sep 2001 21:43:58 +0300 Subject: [PATCH 05/13] os0sync.c Define os_fast_mutex functions also in Windows --- innobase/os/os0sync.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/innobase/os/os0sync.c b/innobase/os/os0sync.c index c5dd603100d..8da142cd4a6 100644 --- a/innobase/os/os0sync.c +++ b/innobase/os/os0sync.c @@ -422,7 +422,6 @@ os_mutex_free( #endif } -#ifndef _WIN32 /************************************************************* Initializes an operating system fast mutex semaphore. */ @@ -472,4 +471,3 @@ os_fast_mutex_free( #endif } -#endif From 5a14bb2a7ee1f5461f73004833fe7439a282de35 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Fri, 21 Sep 2001 03:38:35 +0300 Subject: [PATCH 06/13] Integrated table->ref_primary_key into table->part_of_key Fixed bug in UNION --- client/mysqlbinlog.cc | 5 +- heap/hp_write.c | 1 + myisam/myisampack.c | 2 +- mysql-test/mysql-test-run.sh | 11 +-- mysql-test/r/union.result | 12 +++ mysql-test/t/union.test | 3 + sql/Makefile.am | 2 +- sql/item.cc | 10 ++- sql/log_event.cc | 143 ++++++++++++++++++----------------- sql/log_event.h | 10 ++- sql/mysql_embed.h | 26 +++++++ sql/mysql_priv.h | 3 +- sql/opt_sum.cc | 4 +- sql/slave.cc | 3 +- sql/sql_base.cc | 39 ++-------- sql/sql_union.cc | 4 +- sql/table.cc | 8 +- sql/table.h | 2 +- 18 files changed, 164 insertions(+), 124 deletions(-) create mode 100644 sql/mysql_embed.h diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index ac2f3e4efda..58a22b74282 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -321,6 +321,7 @@ static void dump_remote_log_entries(const char* logname) for(;;) { + const char *error; len = net_safe_read(mysql); if (len == packet_error) die("Error reading packet from server: %s", mysql_error(mysql)); @@ -330,8 +331,8 @@ static void dump_remote_log_entries(const char* logname) len, net->read_pos[5])); Log_event * ev = Log_event::read_log_event( (const char*) net->read_pos + 1 , - len - 1); - if(ev) + len - 1, &error); + if (ev) { ev->print(result_file, short_form, last_db); if(ev->get_type_code() == LOAD_EVENT) diff --git a/heap/hp_write.c b/heap/hp_write.c index 12b5c638f78..ec81d825080 100644 --- a/heap/hp_write.c +++ b/heap/hp_write.c @@ -62,6 +62,7 @@ int heap_write(HP_INFO *info, const byte *record) info->update|=HA_STATE_AKTIV; DBUG_RETURN(0); err: + DBUG_PRINT("info",("Duplicate key: %d",key)); info->errkey= key; do { diff --git a/myisam/myisampack.c b/myisam/myisampack.c index 9408198400f..a19c5e4d88e 100644 --- a/myisam/myisampack.c +++ b/myisam/myisampack.c @@ -284,7 +284,7 @@ static void usage(void) -?, --help Display this help and exit.\n\ -V, --version Output version information and exit."); print_defaults("my",load_default_groups); -}; +} /* reads options */ /* Initiates DEBUG - but no debugging here ! */ diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 3a925372085..3bfdbb0349a 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -269,8 +269,7 @@ DASH72=`$ECHO '----------------------------------------------------------------- # on binary, use what is installed if [ x$SOURCE_DIST = x1 ] ; then MYSQLD="$BASEDIR/sql/mysqld" - if [ -e "$BASEDIR/client/.libs/mysqltest" ] ; then - [ -e "$BASEDIR/client/.libs/lt-mysqltest" ] || $BASEDIR/client/mysqltest -V + if [ -f "$BASEDIR/client/.libs/lt-mysqltest" ] ; then MYSQL_TEST="$BASEDIR/client/.libs/lt-mysqltest" else MYSQL_TEST="$BASEDIR/client/mysqltest" @@ -502,7 +501,7 @@ start_master() #start master if [ -z "$DO_BENCH" ] then - master_args="--no-defaults --log-bin=master-bin \ + master_args="--no-defaults --log-bin=$MYSQL_TEST_DIR/var/log/master-bin \ --server-id=1 \ --basedir=$MY_BASEDIR \ --port=$MASTER_MYPORT \ @@ -519,7 +518,8 @@ start_master() $SMALL_SERVER \ $EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT" else - master_args="--no-defaults --log-bin=master-bin --server-id=1 \ + master_args="--no-defaults --log-bin=$MYSQL_TEST_DIR/var/log/master-bin \ + --server-id=1 \ --basedir=$MY_BASEDIR \ --port=$MASTER_MYPORT \ --datadir=$MASTER_MYDDIR \ @@ -576,7 +576,8 @@ start_slave() $RM -f $SLAVE_MYDDIR/log.* slave_args="--no-defaults $master_info \ --exit-info=256 \ - --log-bin=slave-bin --log-slave-updates \ + --log-bin=$MYSQL_TEST_DIR/var/log/slave-bin + --log-slave-updates \ --basedir=$MY_BASEDIR \ --datadir=$SLAVE_MYDDIR \ --pid-file=$SLAVE_MYPID \ diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 0598bfb9ca0..16cdaafc262 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -70,3 +70,15 @@ pseudo pseudo1 same joce tsestset 1 joce testtt 1 dekad joce 1 +pseudo1 +testtt +tsestset +dekad +pseudo1 +testtt +tsestset +dekad +pseudo1 +testtt +tsestset +1 diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index a4a29c76e65..4c67ec10bb3 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -62,4 +62,7 @@ INSERT INTO t1 (pseudo,pseudo1,same) VALUES ('joce', 'testtt', 1),('joce', 'tses SELECT pseudo FROM t1 WHERE pseudo1='joce' UNION SELECT pseudo FROM t1 WHERE pseudo='joce'; SELECT pseudo1 FROM t1 WHERE pseudo1='joce' UNION SELECT pseudo1 FROM t1 WHERE pseudo='joce'; SELECT * FROM t1 WHERE pseudo1='joce' UNION SELECT * FROM t1 WHERE pseudo='joce' order by pseudo desc; +SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT pseudo FROM t1 WHERE pseudo1='joce'; +SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION ALL SELECT pseudo FROM t1 WHERE pseudo1='joce'; +SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT 1; drop table t1; diff --git a/sql/Makefile.am b/sql/Makefile.am index abde8b3a738..0cd070f9ffb 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -57,7 +57,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ sql_select.h structs.h table.h sql_udf.h hash_filo.h\ lex.h lex_symbol.h sql_acl.h sql_crypt.h md5.h \ log_event.h mini_client.h sql_repl.h slave.h \ - stacktrace.h sql_sort.h + stacktrace.h sql_sort.h mysql_embed.h mysqld_SOURCES = sql_lex.cc sql_handler.cc \ item.cc item_sum.cc item_buff.cc item_func.cc \ item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \ diff --git a/sql/item.cc b/sql/item.cc index d5961fe1733..dbb9c4ec38d 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -298,13 +298,21 @@ bool Item::fix_fields(THD *thd, bool Item_field::fix_fields(THD *thd,TABLE_LIST *tables) { - if (!field) + if (!field) // If field is not checked { Field *tmp; if (!(tmp=find_field_in_tables(thd,this,tables))) return 1; set_field(tmp); } + else if (thd && thd->set_query_id && field->query_id != thd->query_id) + { + /* We only come here in unions */ + TABLE *table=field->table; + field->query_id=thd->query_id; + table->used_fields++; + table->used_keys&=field->part_of_key; + } return 0; } diff --git a/sql/log_event.cc b/sql/log_event.cc index 83fac4a7706..2627e9a3997 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -469,7 +469,7 @@ Log_event* Log_event::read_log_event(IO_CACHE* file) error = "read error"; goto err; } - if((res = read_log_event(buf, data_len))) + if ((res = read_log_event(buf, data_len, &error))) res->register_temp_buf(buf); err: UNLOCK_MUTEX; @@ -481,10 +481,11 @@ err: return res; } -Log_event* Log_event::read_log_event(const char* buf, int event_len) +Log_event* Log_event::read_log_event(const char* buf, int event_len, + const char **error) { - if(event_len < EVENT_LEN_OFFSET || - (uint)event_len != uint4korr(buf+EVENT_LEN_OFFSET)) + if (event_len < EVENT_LEN_OFFSET || + (uint)event_len != uint4korr(buf+EVENT_LEN_OFFSET)) return NULL; // general sanity check - will fail on a partial read Log_event* ev = NULL; @@ -531,6 +532,7 @@ Log_event* Log_event::read_log_event(const char* buf, int event_len) if (!ev) return 0; if (!ev->is_valid()) { + *error= "Found invalid event in binary log"; delete ev; return 0; } @@ -812,80 +814,92 @@ int Load_log_event::write_data_body(IO_CACHE* file) if (sql_ex.write_data(file)) return 1; if (num_fields && fields && field_lens) { - if(my_b_write(file, (byte*)field_lens, num_fields) || - my_b_write(file, (byte*)fields, field_block_len)) + if (my_b_write(file, (byte*)field_lens, num_fields) || + my_b_write(file, (byte*)fields, field_block_len)) return 1; } - return my_b_write(file, (byte*)table_name, table_name_len + 1) || - my_b_write(file, (byte*)db, db_len + 1) || - my_b_write(file, (byte*)fname, fname_len); + return (my_b_write(file, (byte*)table_name, table_name_len + 1) || + my_b_write(file, (byte*)db, db_len + 1) || + my_b_write(file, (byte*)fname, fname_len)); } -#define WRITE_STR(name) my_b_write(file,(byte*)&name ## _len, 1) || \ - my_b_write(file,(byte*)name,name ## _len) -#define OLD_EX_INIT(name) old_ex.##name = *name + +static bool write_str(IO_CACHE *file, char *str, byte length) +{ + return (my_b_write(file, &length, 1) || + my_b_write(file, (byte*) str, (int) length)); +} int sql_ex_info::write_data(IO_CACHE* file) { if (new_format()) { - return WRITE_STR(field_term) || WRITE_STR(enclosed) || - WRITE_STR(line_term) || WRITE_STR(line_start) || - WRITE_STR(escaped) || my_b_write(file,(byte*)&opt_flags,1); + return (write_str(file, field_term, field_term_len) || + write_str(file, enclosed, enclosed_len) || + write_str(file, line_term, line_term_len) || + write_str(file, line_start, line_start_len) || + write_str(file, escaped, escaped_len) || + my_b_write(file,(byte*) &opt_flags,1)); } else { old_sql_ex old_ex; - OLD_EX_INIT(field_term); - OLD_EX_INIT(enclosed); - OLD_EX_INIT(line_term); - OLD_EX_INIT(line_start); - OLD_EX_INIT(escaped); - old_ex.opt_flags = opt_flags; - old_ex.empty_flags = empty_flags; - return my_b_write(file,(byte*)&old_ex,sizeof(old_ex)); + old_ex.field_term= *field_term; + old_ex.enclosed= *enclosed; + old_ex.line_term= *line_term; + old_ex.line_start= *line_start; + old_ex.escaped= *escaped; + old_ex.opt_flags= opt_flags; + old_ex.empty_flags=empty_flags; + return my_b_write(file, (byte*) &old_ex, sizeof(old_ex)); } } -#define READ_STR(name) name ## _len = *buf++;\ - if (buf >= buf_end) return 0;\ - name = buf; \ - buf += name ## _len; \ - if (buf >= buf_end) return 0; - -#define READ_OLD_STR(name) name ## _len = 1; \ - name = buf++; \ - if (buf >= buf_end) return 0; - -#define FIX_OLD_LEN(name,NAME) if (empty_flags & NAME ## _EMPTY) \ - name ## _len = 0 +static inline int read_str(char * &buf, char *buf_end, char * &str, + uint8 &len) +{ + if (buf + (uint) (uchar) *buf >= buf_end) + return 1; + len = (uint8) *buf; + str= buf+1; + buf+= (uint) len+1; + return 0; +} char* sql_ex_info::init(char* buf,char* buf_end,bool use_new_format) { cached_new_format = use_new_format; if (use_new_format) { - READ_STR(field_term); - READ_STR(enclosed); - READ_STR(line_term); - READ_STR(line_start); - READ_STR(escaped); + empty_flags=0; + if (read_str(buf, buf_end, field_term, field_term_len) || + read_str(buf, buf_end, enclosed, enclosed_len) || + read_str(buf, buf_end, line_term, line_term_len) || + read_str(buf, buf_end, line_start, line_start_len) || + read_str(buf, buf_end, escaped, escaped_len)) + return 0; opt_flags = *buf++; } else { - READ_OLD_STR(field_term); - READ_OLD_STR(enclosed); - READ_OLD_STR(line_term); - READ_OLD_STR(line_start); - READ_OLD_STR(escaped); + field_term_len= enclosed_len= line_term_len= line_start_len= escaped_len=1; + *field_term=*buf++; + *enclosed= *buf++; + *line_term= *buf++; + *line_start=*buf++; + *escaped= *buf++; opt_flags = *buf++; - empty_flags = *buf++; - FIX_OLD_LEN(field_term,FIELD_TERM); - FIX_OLD_LEN(enclosed,ENCLOSED); - FIX_OLD_LEN(line_term,LINE_TERM); - FIX_OLD_LEN(line_start,LINE_START); - FIX_OLD_LEN(escaped,ESCAPED); + empty_flags=*buf++; + if (empty_flags & FIELD_TERM_EMPTY) + field_term_len=0; + if (empty_flags & ENCLOSED_EMPTY) + enclosed_len=0; + if (empty_flags & LINE_TERM_EMPTY) + line_term_len=0; + if (empty_flags & LINE_START_EMPTY) + line_start_len=0; + if (empty_flags & ESCAPED_EMPTY) + escaped_len=0; } return buf; } @@ -1271,6 +1285,8 @@ Create_file_log_event::Create_file_log_event(const char* buf, int len): block = (char*)buf + block_offset; block_len = len - block_offset; } + + #ifdef MYSQL_CLIENT void Create_file_log_event::print(FILE* file, bool short_form, char* last_db) @@ -1553,20 +1569,16 @@ int Load_log_event::exec_event(NET* net, struct st_master_info* mi) handle_dup = DUP_REPLACE; sql_exchange ex((char*)fname, sql_ex.opt_flags && DUMPFILE_FLAG ); - -#define SET_EX(name) String name(sql_ex.name,sql_ex.name ## _len);\ - ex.name = &name; - - SET_EX(field_term); - SET_EX(enclosed); - SET_EX(line_term); - SET_EX(line_start); - SET_EX(escaped); + String field_term(sql_ex.field_term,sql_ex.field_term_len); + String enclosed(sql_ex.enclosed,sql_ex.enclosed_len); + String line_term(sql_ex.line_term,sql_ex.line_term_len); + String line_start(sql_ex.line_start,sql_ex.line_start_len); + String escaped(sql_ex.escaped,sql_ex.escaped_len); ex.opt_enclosed = (sql_ex.opt_flags & OPT_ENCLOSED_FLAG); - if(sql_ex.empty_flags & FIELD_TERM_EMPTY) + if (sql_ex.empty_flags & FIELD_TERM_EMPTY) ex.field_term->length(0); - + ex.skip_lines = skip_lines; List fields; set_fields(fields); @@ -1862,10 +1874,3 @@ err: #endif - - - - - - - diff --git a/sql/log_event.h b/sql/log_event.h index d938bced742..71f0f2a8575 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -272,7 +272,8 @@ public: #else // avoid having to link mysqlbinlog against libpthread static Log_event* read_log_event(IO_CACHE* file); #endif - static Log_event* read_log_event(const char* buf, int event_len); + static Log_event* read_log_event(const char* buf, int event_len, + const char **error); const char* get_type_str(); #ifndef MYSQL_CLIENT @@ -567,9 +568,10 @@ public: uint file_id; #ifndef MYSQL_CLIENT Create_file_log_event(THD* thd, sql_exchange* ex, const char* db_arg, - const char* table_name_arg, - List& fields_arg, enum enum_duplicates handle_dup, - char* block_arg, uint block_len_arg); + const char* table_name_arg, + List& fields_arg, + enum enum_duplicates handle_dup, + char* block_arg, uint block_len_arg); #endif Create_file_log_event(const char* buf, int event_len); diff --git a/sql/mysql_embed.h b/sql/mysql_embed.h new file mode 100644 index 00000000000..4bfaca547a8 --- /dev/null +++ b/sql/mysql_embed.h @@ -0,0 +1,26 @@ +/* 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 */ + +/* Defines that are unique to the embedded version of MySQL */ + +#ifdef EMBEDDED_LIBRARY + +/* Things we don't need in the embedded version of MySQL */ + +#undef HAVE_PSTACK /* No stacktrace */ +#undef HAVE_DLOPEN /* No udf functions */ + +#endif /* EMBEDDED_LIBRARY */ diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 7151f43904f..34fae62ad56 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -18,9 +18,10 @@ #define _MYSQL_PRIV_H #include +#include "mysql_embed.h" #include #include -#include "mysql_version.h" +#include #include #include #include diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index c16c0d919d4..182fb6cf362 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -305,7 +305,7 @@ static bool find_range_key(TABLE_REF *ref, Field* field, COND *cond) key>>=1; ref->key_length=0; ref->key=idx; - if (field->part_of_key & ((table_map) 1 << idx)) + if (field->part_of_key & ((key_map) 1 << idx)) { table->key_read=1; table->file->extra(HA_EXTRA_KEYREAD); @@ -350,7 +350,7 @@ static bool find_range_key(TABLE_REF *ref, Field* field, COND *cond) { ref->key_length= (uint) (key_ptr-ref->key_buff); ref->key=idx; - if (field->part_of_key & ((table_map) 1 << idx)) + if (field->part_of_key & ((key_map) 1 << idx)) { table->key_read=1; table->file->extra(HA_EXTRA_KEYREAD); diff --git a/sql/slave.cc b/sql/slave.cc index 1a6a0910f54..a1b5045efd4 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -934,8 +934,9 @@ point. If you are sure that your master is ok, run this query manually on the\ static int exec_event(THD* thd, NET* net, MASTER_INFO* mi, int event_len) { + const char *error_msg; Log_event * ev = Log_event::read_log_event((const char*)net->read_pos + 1, - event_len); + event_len, &error_msg); if (ev) { int type_code = ev->get_type_code(); diff --git a/sql/sql_base.cc b/sql/sql_base.cc index 41093452984..89910d3745e 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -160,7 +160,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild) if (table) continue; if (!(*start_list = (OPEN_TABLE_LIST *) - sql_alloc(sizeof(OPEN_TABLE_LIST)+entry->key_length))) + sql_alloc(sizeof(*start_list)+entry->key_length))) { open_list=0; // Out of memory break; @@ -172,6 +172,7 @@ OPEN_TABLE_LIST *list_open_tables(THD *thd, const char *wild) (*start_list)->locked= entry->locked_by_name ? 1 : 0; start_list= &(*start_list)->next; } + *start_list=0; VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_RETURN(open_list); } @@ -1579,13 +1580,7 @@ Field *find_field_in_table(THD *thd,TABLE *table,const char *name,uint length, { field->query_id=thd->query_id; table->used_fields++; - if (field->part_of_key) - { - if (!(field->part_of_key & table->ref_primary_key)) - table->used_keys&=field->part_of_key; - } - else - table->used_keys=0; + table->used_keys&=field->part_of_key; } else thd->dupp_field=field; @@ -1655,7 +1650,8 @@ find_field_in_tables(THD *thd,Item_field *item,TABLE_LIST *tables) for (; tables ; tables=tables->next) { Field *field=find_field_in_table(thd,tables->table,name,length, - grant_option && !thd->master_access, allow_rowid); + grant_option && + !thd->master_access, allow_rowid); if (field) { if (field == WRONG_GRANT) @@ -1879,14 +1875,7 @@ insert_fields(THD *thd,TABLE_LIST *tables, const char *db_name, if (field->query_id == thd->query_id) thd->dupp_field=field; field->query_id=thd->query_id; - - if (field->part_of_key) - { - if (!(field->part_of_key & table->ref_primary_key)) - table->used_keys&=field->part_of_key; - } - else - table->used_keys=0; + table->used_keys&=field->part_of_key; } /* All fields are used */ table->used_fields=table->fields; @@ -1967,20 +1956,8 @@ int setup_conds(THD *thd,TABLE_LIST *tables,COND **conds) /* Mark field used for table cache */ t1->field[i]->query_id=t2->field[j]->query_id=thd->query_id; cond_and->list.push_back(tmp); - if ((tmp_map=t1->field[i]->part_of_key)) - { - if (!(tmp_map & t1->ref_primary_key)) - t1->used_keys&=tmp_map; - } - else - t1->used_keys=0; - if ((tmp_map=t2->field[j]->part_of_key)) - { - if (!(tmp_map & t2->ref_primary_key)) - t2->used_keys&=tmp_map; - } - else - t2->used_keys=0; + t1->used_keys&= t1->field[i]->part_of_key; + t2->used_keys&= t2->field[j]->part_of_key; break; } } diff --git a/sql/sql_union.cc b/sql/sql_union.cc index 5dd897ee826..c0ec6c81575 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -31,7 +31,7 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) ORDER *order; List item_list; TABLE *table; - TABLE_LIST *first_table, result_table_list; + TABLE_LIST result_table_list; TMP_TABLE_PARAM tmp_table_param; select_union *union_result; int res; @@ -75,9 +75,9 @@ int mysql_union(THD *thd, LEX *lex,select_result *result) { Item *item; List_iterator it(lex->select_lex.item_list); + TABLE_LIST *first_table= (TABLE_LIST*) lex->select_lex.table_list.first; /* Create a list of items that will be in the result set */ - first_table= (TABLE_LIST*) lex->select_lex.table_list.first; while ((item= it++)) if (item_list.push_back(item)) DBUG_RETURN(-1); diff --git a/sql/table.cc b/sql/table.cc index eed4170c14a..6c2f0e27c95 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -455,8 +455,12 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, if (key == primary_key) { field->flags|= PRI_KEY_FLAG; + /* + If this field is part of the primary key and all keys contains + the primary key, then we can use any key to find this column + */ if (ha_option & HA_PRIMARY_KEY_IN_READ_INDEX) - field->part_of_key|= ((key_map) 1 << primary_key); + field->part_of_key= outparam->keys_in_use; } if (field->key_length() != key_part->length) { @@ -480,8 +484,6 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, (outparam->keys_in_use & ((key_map) 1 << primary_key))) { outparam->primary_key=primary_key; - if (outparam->file->option_flag() & HA_PRIMARY_KEY_IN_READ_INDEX) - outparam->ref_primary_key= (key_map) 1 << primary_key; /* If we are using an integer as the primary key then allow the user to refer to it as '_rowid' diff --git a/sql/table.h b/sql/table.h index 5d50851259d..1eead0decb1 100644 --- a/sql/table.h +++ b/sql/table.h @@ -117,7 +117,7 @@ struct st_table { byte *record_pointers; /* If sorted in memory */ ha_rows found_records; /* How many records in sort */ ORDER *group; - key_map quick_keys, used_keys, ref_primary_key; + key_map quick_keys, used_keys; ha_rows quick_rows[MAX_KEY]; uint quick_key_parts[MAX_KEY]; key_part_map const_key_parts[MAX_KEY]; From ed297508c4357cba42c465cb8d2e6b8260b7bb19 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Fri, 21 Sep 2001 16:36:23 +0300 Subject: [PATCH 07/13] Fixes for distributed build Changed --do-pstack to --enable-pstack Removed pstack from default build --- client/Makefile.am | 4 ++-- configure.in | 10 ++++++---- sql/Makefile.am | 2 +- sql/mysqld.cc | 4 ++-- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/client/Makefile.am b/client/Makefile.am index d5b80ac5f4c..3239744542f 100644 --- a/client/Makefile.am +++ b/client/Makefile.am @@ -19,13 +19,13 @@ INCLUDES = -I$(srcdir)/../include $(openssl_includes) \ -I../include -I$(srcdir)/.. -I$(top_srcdir) \ -I.. -noinst_HEADERS = client_priv.h LIBS = @CLIENT_LIBS@ LDADD = @CLIENT_EXTRA_LDFLAGS@ ../libmysql/libmysqlclient.la bin_PROGRAMS = mysql mysqladmin mysqlcheck mysqlshow \ mysqldump mysqlimport mysqltest mysqlbinlog noinst_PROGRAMS = insert_test select_test thread_test -noinst_HEADERS = sql_string.h completion_hash.h my_readline.h +noinst_HEADERS = sql_string.h completion_hash.h my_readline.h \ + client_priv.h mysql_SOURCES = mysql.cc readline.cc sql_string.cc completion_hash.cc mysql_LDADD = @readline_link@ @TERMCAP_LIB@ $(LDADD) $(CXXLDFLAGS) mysql_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) diff --git a/configure.in b/configure.in index b121d641fe4..14816515e97 100644 --- a/configure.in +++ b/configure.in @@ -699,9 +699,9 @@ int main() AC_MSG_RESULT($atom_ops) AC_ARG_WITH(pstack, - [ --without-pstack Do not use the pstack backtrace library], - [USE_PSTACK=$withval], - [USE_PSTACK=yes]) + [ --with-pstack Use the pstack backtrace library], + [ USE_PSTACK=$withval ], + [ USE_PSTACK=no ]) pstack_libs= pstack_dirs= if test "$USE_PSTACK" = yes -a "$IS_LINUX" = "true" -a "$BASE_MACHINE_TYPE" = "i386" -a "$with_mit_threads" = "no" @@ -717,7 +717,9 @@ dnl I have no idea if this is a good test - can not find docs for libiberty if test x"$have_libiberty" = xyes -a x"$have_libbfd" = xyes then pstack_dirs='$(top_srcdir)'/pstack - pstack_libs="$pstack_dirs/libpstack.a -lbfd -liberty" + pstack_libs="../pstack/libpstack.a -lbfd -liberty" + # We must link staticly when using pstack + with_mysqld_ldflags="-all-static" AC_SUBST([pstack_dirs]) AC_SUBST([pstack_libs]) AC_DEFINE([USE_PSTACK]) diff --git a/sql/Makefile.am b/sql/Makefile.am index 0cd070f9ffb..f6d7888691d 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -24,7 +24,7 @@ INCLUDES = @MT_INCLUDES@ \ @bdb_includes@ @innodb_includes@ @gemini_includes@ \ -I$(srcdir)/../include \ -I$(srcdir)/../regex \ - -I$(srcdir) -I../include $(openssl_includes) + -I$(srcdir) -I../include -I. $(openssl_includes) WRAPLIBS= @WRAPLIBS@ SUBDIRS = share libexec_PROGRAMS = mysqld diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 87d42da976b..67b5ba882d2 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2642,9 +2642,8 @@ static struct option long_options[] = { {"default-table-type", required_argument, 0, (int) OPT_TABLE_TYPE}, {"delay-key-write-for-all-tables", no_argument, 0, (int) OPT_DELAY_KEY_WRITE}, - {"do-pstack", - no_argument, 0, (int) OPT_DO_PSTACK}, {"enable-locking", no_argument, 0, (int) OPT_ENABLE_LOCK}, + {"enable-pstack", no_argument, 0, (int) OPT_DO_PSTACK}, {"exit-info", optional_argument, 0, 'T'}, {"flush", no_argument, 0, (int) OPT_FLUSH}, #ifdef HAVE_GEMINI_DB @@ -3188,6 +3187,7 @@ static void usage(void) Don't flush key buffers between writes for any MyISAM\n\ table\n\ --enable-locking Enable system locking\n\ + --enable-pstack Print a symbolic stack trace on failure\n\ -T, --exit-info Used for debugging; Use at your own risk!\n\ --flush Flush tables to disk between SQL commands\n\ -?, --help Display this help and exit\n\ From 660bf8659e65a03da849c79c145a3655acd5ea30 Mon Sep 17 00:00:00 2001 From: "tfr@sarvik.tfr.cafe.ee" <> Date: Fri, 21 Sep 2001 22:35:43 +0200 Subject: [PATCH 08/13] manual.texi: Add a mirror in Mexico mexico.txt, mexico.eps, mexico.gif: new file --- Docs/Flags/mexico.eps | Bin 0 -> 13844 bytes Docs/Flags/mexico.gif | Bin 0 -> 269 bytes Docs/Flags/mexico.txt | 0 Docs/manual.texi | 6 ++++++ 4 files changed, 6 insertions(+) create mode 100755 Docs/Flags/mexico.eps create mode 100755 Docs/Flags/mexico.gif create mode 100644 Docs/Flags/mexico.txt diff --git a/Docs/Flags/mexico.eps b/Docs/Flags/mexico.eps new file mode 100755 index 0000000000000000000000000000000000000000..716851cfe7e6108d1dc5a9ae0fb908d50faa8b4d GIT binary patch literal 13844 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 Date: Sat, 22 Sep 2001 01:56:25 +0300 Subject: [PATCH 09/13] Fix when compiling with mit-pthreads --- Docs/manual.texi | 2 +- tools/Makefile.am | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Docs/manual.texi b/Docs/manual.texi index df07f391112..e22565171f5 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -46513,7 +46513,7 @@ newest version from @uref{http://civeng.com/sqldemo/, the home site}. @item @uref{http://myadmin.cheapnet.net/, MyAdmin home page} A Web-based MySQL administrator by Mike Machado. -@item @uref{http://www.mysql.com/Downloads/Contrib/phpMyAdmin_2.0.1.tar.gz,phpMyAdmin_2.0.1.tar.gz} +@item @uref{http://www.mysql.com/Downloads/Contrib/phpMyAdmin_2.2.0.tar.gz,phpMyAdmin_2.2.0.tar.gz} A set of PHP3-scripts to adminstrate MySQL over the WWW. @item @uref{http://www.phpwizard.net/projects/phpMyAdmin/, phpMyAdmin home page} diff --git a/tools/Makefile.am b/tools/Makefile.am index 3c786dc9281..e5130865a89 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -6,5 +6,15 @@ mysqlmanager_SOURCES= mysqlmanager.c mysqlmanager_DEPENDENCIES= $(LIBRARIES) $(pkglib_LTLIBRARIES) DEF= -DUNDEF_THREADS_HACK +OMIT_DEPENDENCIES = pthread.h stdio.h __stdio.h stdlib.h __stdlib.h math.h\ + __math.h time.h __time.h unistd.h __unistd.h types.h \ + xtypes.h ac-types.h posix.h string.h __string.h \ + errno.h socket.h inet.h dirent.h netdb.h \ + cleanup.h cond.h debug_out.h fd.h kernel.h mutex.h \ + prio_queue.h pthread_attr.h pthread_once.h queue.h\ + sleep.h specific.h version.h pwd.h timers.h uio.h \ + cdefs.h machdep.h signal.h __signal.h util.h lex.h \ + wait.h + # Don't update the files from bitkeeper %::SCCS/s.% From d6fb40171b3b6963cef47e2809906fff92da480c Mon Sep 17 00:00:00 2001 From: "tonu@volk.internalnet" <> Date: Sat, 22 Sep 2001 22:32:43 +0800 Subject: [PATCH 10/13] SSL parser changes to allow SSL specific GRANT commands --- BitKeeper/etc/logging_ok | 1 + Build-tools/Do-all-build-steps | 2 ++ sql/lex.h | 4 ++++ sql/sql_lex.h | 1 + sql/sql_yacc.yy | 35 ++++++++++++++++++++++++++++++---- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 81a2ba694f7..c2b351eb968 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -28,3 +28,4 @@ tim@work.mysql.com tonu@hundin.mysql.fi tonu@x153.internalnet tonu@x3.internalnet +tonu@volk.internalnet diff --git a/Build-tools/Do-all-build-steps b/Build-tools/Do-all-build-steps index cb7bb999513..e17e6acf305 100755 --- a/Build-tools/Do-all-build-steps +++ b/Build-tools/Do-all-build-steps @@ -65,6 +65,8 @@ aclocal; autoheader; aclocal; automake; autoconf --enable-thread-safe-client \ --with-berkeley-db \ --with-innodb \ + --with-openssl \ + --with-vio \ --without-pstack \ --with-extra-tools \ --with-embedded-server diff --git a/sql/lex.h b/sql/lex.h index 1d481aa7c85..b72b42f2a3d 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -83,6 +83,7 @@ static SYMBOL symbols[] = { { "CHANGED", SYM(CHANGED),0,0}, { "CHECK", SYM(CHECK_SYM),0,0}, { "CHECKSUM", SYM(CHECKSUM_SYM),0,0}, + { "CHIPHER", SYM(CHIPHER_SYM),0,0}, { "CLOSE", SYM(CLOSE_SYM),0,0}, { "COLUMN", SYM(COLUMN_SYM),0,0}, { "COLUMNS", SYM(COLUMNS),0,0}, @@ -190,6 +191,7 @@ static SYMBOL symbols[] = { { "IS", SYM(IS),0,0}, { "ISOLATION", SYM(ISOLATION),0,0}, { "ISAM", SYM(ISAM_SYM),0,0}, + { "ISSUER", SYM(ISSUER_SYM),0,0}, { "JOIN", SYM(JOIN_SYM),0,0}, { "KEY", SYM(KEY_SYM),0,0}, { "KEYS", SYM(KEYS),0,0}, @@ -277,6 +279,7 @@ static SYMBOL symbols[] = { { "REPAIR", SYM(REPAIR),0,0}, { "REPLACE", SYM(REPLACE),0,0}, { "REPEATABLE", SYM(REPEATABLE_SYM),0,0}, + { "REQUIRE", SYM(REQUIRE_SYM),0,0}, { "RESET", SYM(RESET_SYM),0,0}, { "RESTORE", SYM(RESTORE_SYM),0,0}, { "RESTRICT", SYM(RESTRICT),0,0}, @@ -322,6 +325,7 @@ static SYMBOL symbols[] = { { "STRING", SYM(STRING_SYM),0,0}, { "STOP", SYM(STOP_SYM),0,0}, { "STRIPED", SYM(RAID_STRIPED_SYM),0,0}, + { "SUBJECT", SYM(SUBJECT_SYM),0,0}, { "TABLE", SYM(TABLE_SYM),0,0}, { "TABLES", SYM(TABLES),0,0}, { "TEMPORARY", SYM(TEMPORARY),0,0}, diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 4d2441da246..ff404cce0d6 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -145,6 +145,7 @@ typedef struct st_lex { char *length,*dec,*change,*name; char *backup_dir; /* For RESTORE/BACKUP */ char* to_log; /* For PURGE MASTER LOGS TO */ + char* ssl_subject,*ssl_issuer,*ssl_chipher; String *wild; sql_exchange *exchange; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 5be1b86e8ab..c1933552f6b 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -98,7 +98,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %token MIN_SYM %token SUM_SYM %token STD_SYM - +%token ABORT_SYM %token ADD %token ALTER %token AFTER_SYM @@ -134,7 +134,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %token BINLOG_SYM %token EVENTS_SYM -%token ABORT_SYM %token ACTION %token AGGREGATE_SYM %token ALL @@ -450,6 +449,10 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %token SQL_QUOTE_SHOW_CREATE %token SQL_SLAVE_SKIP_COUNTER +%token ISSUER_SYM +%token SUBJECT_SYM +%token CIPHER_SYM + %left SET_VAR %left OR_OR_CONCAT OR %left AND @@ -2819,6 +2822,7 @@ keyword: | CHANGED {} | CHECKSUM_SYM {} | CHECK_SYM {} + | CIPHER_SYM {} | CLOSE_SYM {} | COMMENT_SYM {} | COMMIT_SYM {} @@ -2856,6 +2860,7 @@ keyword: | INDEXES {} | ISOLATION {} | ISAM_SYM {} + | ISSUER_SYM {} | INNOBASE_SYM {} | LAST_SYM {} | LEVEL_SYM {} @@ -2909,10 +2914,10 @@ keyword: | SESSION_SYM {} | SHARE_SYM {} | SHUTDOWN {} - | START_SYM {} | STATUS_SYM {} | STOP_SYM {} | STRING_SYM {} + | SUBJECT_SYM {} | TEMPORARY {} | TEXT_SYM {} | TRANSACTION_SYM {} @@ -3251,9 +3256,10 @@ grant: lex->columns.empty(); lex->grant= lex->grant_tot_col=0; lex->select->db=0; + lex->ssl_chipher=lex->ssl_subject=lex->ssl_issuer=0; } grant_privileges ON opt_table TO_SYM user_list - grant_option + grant_option require_clause grant_privileges: grant_privilege_list {} @@ -3287,6 +3293,27 @@ grant_privilege: | FILE_SYM { Lex->grant |= FILE_ACL;} | GRANT OPTION { Lex->grant |= GRANT_ACL;} +require_clause: /* empty */ + | REQUIRE_SYM require_list + + +require_list: require_list_element AND require_list +| require_list_element + + +require_list_element: SUBJECT_SYM TEXT_STRING + { + Lex->ssl_subject=$2.str; + } + | ISSUER_SYM TEXT_STRING + { + Lex->ssl_issuer=$2.str; + } + | CHIPHER_SYM TEXT_STRING + { + Lex->ssl_chipher=$2.str; + } + opt_table: '*' { From 0db1aee4546996d3b989ea7ada2f3c156e1ebd08 Mon Sep 17 00:00:00 2001 From: "tonu@volk.internalnet" <> Date: Sat, 22 Sep 2001 22:40:54 +0800 Subject: [PATCH 11/13] Typo fixes on SSL --- sql/lex.h | 2 +- sql/sql_yacc.yy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/lex.h b/sql/lex.h index b72b42f2a3d..ca797e5b894 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -83,7 +83,7 @@ static SYMBOL symbols[] = { { "CHANGED", SYM(CHANGED),0,0}, { "CHECK", SYM(CHECK_SYM),0,0}, { "CHECKSUM", SYM(CHECKSUM_SYM),0,0}, - { "CHIPHER", SYM(CHIPHER_SYM),0,0}, + { "CIPHER", SYM(CIPHER_SYM),0,0}, { "CLOSE", SYM(CLOSE_SYM),0,0}, { "COLUMN", SYM(COLUMN_SYM),0,0}, { "COLUMNS", SYM(COLUMNS),0,0}, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index c1933552f6b..6d80234082d 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -3309,7 +3309,7 @@ require_list_element: SUBJECT_SYM TEXT_STRING { Lex->ssl_issuer=$2.str; } - | CHIPHER_SYM TEXT_STRING + | CIPHER_SYM TEXT_STRING { Lex->ssl_chipher=$2.str; } From e390a995737f136c594a7c792caa12061690800f Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Sat, 22 Sep 2001 17:40:57 +0300 Subject: [PATCH 12/13] Added support of INSERT to MERGE tables Fixes for embedded libary and openssl --- BUILD/compile-pentium-debug-max | 2 +- Build-tools/Do-all-build-steps | 1 - acinclude.m4 | 8 +-- client/client_priv.h | 1 + client/mysql.cc | 33 ++++------- include/Makefile.am | 4 +- include/myisammrg.h | 15 ++++- include/mysql.h | 43 +++++++------- include/mysql_com.h | 10 ++-- {sql => include}/mysql_embed.h | 3 + include/violite.h | 102 ++++++++++++++------------------ libmysql/libmysql.c | 1 + libmysqld/examples/Makefile.am | 2 +- libmysqld/lib_sql.cc | 1 + libmysqld/lib_vio.c | 3 +- libmysqld/libmysqld.c | 38 ++---------- myisammrg/Makefile.am | 2 +- myisammrg/myrg_create.c | 10 +++- myisammrg/myrg_open.c | 52 +++++++++------- myisammrg/myrg_static.c | 4 ++ myisammrg/myrg_write.c | 30 ++++++++++ mysql-test/t/union.test | 2 +- sql/Makefile.am | 2 +- sql/gen_lex_hash.cc | 12 ++-- sql/ha_myisammrg.cc | 23 ++++++- sql/handler.h | 8 ++- sql/lex.h | 1 + sql/mini_client.cc | 2 +- sql/net_serv.cc | 1 + sql/sql_show.cc | 1 - sql/sql_yacc.yy | 11 +++- 31 files changed, 235 insertions(+), 193 deletions(-) rename {sql => include}/mysql_embed.h (94%) create mode 100644 myisammrg/myrg_write.c diff --git a/BUILD/compile-pentium-debug-max b/BUILD/compile-pentium-debug-max index 4149267811d..ccd6faa0448 100755 --- a/BUILD/compile-pentium-debug-max +++ b/BUILD/compile-pentium-debug-max @@ -8,6 +8,6 @@ c_warnings="$c_warnings $debug_extra_warnings" cxx_warnings="$cxx_warnings $debug_extra_warnings" extra_configs="$pentium_configs $debug_configs" -extra_configs="$extra_configs --with-berkeley-db --with-innodb --with-embedded-server" +extra_configs="$extra_configs --with-berkeley-db --with-innodb --with-vio --with-openssl --with-embedded-server" . "$path/FINISH.sh" diff --git a/Build-tools/Do-all-build-steps b/Build-tools/Do-all-build-steps index e17e6acf305..ad3868733fa 100755 --- a/Build-tools/Do-all-build-steps +++ b/Build-tools/Do-all-build-steps @@ -65,7 +65,6 @@ aclocal; autoheader; aclocal; automake; autoconf --enable-thread-safe-client \ --with-berkeley-db \ --with-innodb \ - --with-openssl \ --with-vio \ --without-pstack \ --with-extra-tools \ diff --git a/acinclude.m4 b/acinclude.m4 index ca711a7c641..d7e492856bb 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -690,8 +690,7 @@ fi AC_DEFUN(MYSQL_CHECK_VIO, [ AC_ARG_WITH([vio], - [\ - --with-vio Include the Virtual IO support], + [ --with-vio Include the Virtual IO support], [vio="$withval"], [vio=no]) @@ -712,8 +711,7 @@ AC_DEFUN(MYSQL_CHECK_VIO, [ AC_DEFUN(MYSQL_CHECK_OPENSSL, [ AC_MSG_CHECKING(for OpenSSL) AC_ARG_WITH([openssl], - [\ - --with-openssl Include the OpenSSL support], + [ --with-openssl Include the OpenSSL support], [openssl="$withval"], [openssl=no]) @@ -722,7 +720,7 @@ AC_MSG_CHECKING(for OpenSSL) if test -n "$vio_dir" then AC_MSG_RESULT(yes) - openssl_libs="-lssl -lcrypto -L/usr/local/ssl/lib" + openssl_libs="-L/usr/local/ssl/lib -lssl -lcrypto" openssl_includes="-I/usr/local/ssl/include" else AC_MSG_ERROR([OpenSSL requires Virtual IO support (--with-vio)]) diff --git a/client/client_priv.h b/client/client_priv.h index 64ded3ed7f3..b015e378127 100644 --- a/client/client_priv.h +++ b/client/client_priv.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include diff --git a/client/mysql.cc b/client/mysql.cc index 6c947d90d76..6382fd66f35 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -303,6 +303,7 @@ int main(int argc,char *argv[]) exit(1); glob_buffer.realloc(512); completion_hash_init(&ht,50); + bzero((char*) &mysql, sizeof(mysql)); if (sql_connect(current_host,current_db,current_user,opt_password, opt_silent)) { @@ -326,11 +327,13 @@ int main(int argc,char *argv[]) put_info((char*) glob_buffer.ptr(),INFO_INFO); #ifdef HAVE_OPENSSL - if(mysql.net.vio->ssl_ && SSL_get_cipher(mysql.net.vio->ssl_)) { + if (mysql.net.vio->ssl_ && SSL_get_cipher(mysql.net.vio->ssl_)) + { sprintf((char*) glob_buffer.ptr(), - "SSL cipher in use is %s\n", SSL_get_cipher(mysql.net.vio->ssl_)); + "SSL cipher in use is %s\n", SSL_get_cipher(mysql.net.vio->ssl_)); put_info((char*) glob_buffer.ptr(),INFO_INFO); - } else + } + else put_info("SSL is not in use\n",INFO_INFO); #endif /* HAVE_OPENSSL */ @@ -373,13 +376,7 @@ int main(int argc,char *argv[]) sig_handler mysql_end(int sig) { - if (connected) - mysql_close(&mysql); -#ifdef HAVE_OPENSSL - else - mysql_ssl_clear(&mysql); /* SSL data structres should be freed - even if connection was not made */ -#endif + mysql_close(&mysql); #ifdef HAVE_READLINE if (!status.batch && !quick && !opt_html && !opt_xml) { @@ -2208,16 +2205,8 @@ static int sql_real_connect(char *host,char *database,char *user,char *password, uint silent) { - if (connected) - { /* if old is open, close it first */ - mysql_close(&mysql); - connected= 0; - } -#ifdef HAVE_OPENSSL - else - mysql_ssl_clear(&mysql); /* SSL data structres should be freed - even if connection was not made */ -#endif + mysql_close(&mysql); + connected= 0; mysql_init(&mysql); if (opt_connect_timeout) { @@ -2569,7 +2558,7 @@ static void mysql_end_timer(ulong start_time,char *buff) strmov(strend(buff),")"); } -#ifndef EMBEDDED_SERVER +#ifndef EMBEDDED_LIBRARY /* Keep sql_string library happy */ gptr sql_alloc(unsigned int Size) @@ -2581,4 +2570,4 @@ void sql_element_free(void *ptr) { my_free((gptr) ptr,MYF(0)); } -#endif /* EMBEDDED_SERVER */ +#endif /* EMBEDDED_LIBRARY */ diff --git a/include/Makefile.am b/include/Makefile.am index 0821afeb01d..aaf11db7a50 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -16,8 +16,8 @@ # MA 02111-1307, USA BUILT_SOURCES = mysql_version.h m_ctype.h my_config.h -pkginclude_HEADERS = dbug.h m_string.h my_sys.h mysql.h mysql_com.h \ - mysqld_error.h my_list.h \ +pkginclude_HEADERS = dbug.h m_string.h my_sys.h my_list.h \ + mysql.h mysql_com.h mysqld_error.h mysql_embed.h \ my_pthread.h my_no_pthread.h raid.h errmsg.h \ my_global.h my_net.h \ sslopt-case.h sslopt-longopts.h sslopt-usage.h \ diff --git a/include/myisammrg.h b/include/myisammrg.h index a797c954614..1ae825b4b94 100644 --- a/include/myisammrg.h +++ b/include/myisammrg.h @@ -34,6 +34,13 @@ extern "C" { #define MYRG_NAME_EXT ".MRG" +/* In which table to INSERT rows */ +#define MERGE_INSERT_DISABLED 0 +#define MERGE_INSERT_TO_FIRST 1 +#define MERGE_INSERT_TO_LAST 2 + +extern TYPELIB merge_insert_method; + /* Param to/from myrg_info */ typedef struct st_mymerge_info /* Struct from h_info */ @@ -44,7 +51,7 @@ typedef struct st_mymerge_info /* Struct from h_info */ ulonglong data_file_length; uint reclength; /* Recordlength */ int errkey; /* With key was dupplicated on err */ - uint options; /* HA_OPTIONS_... used */ + uint options; /* HA_OPTION_... used */ } MYMERGE_INFO; typedef struct st_myrg_table_info @@ -56,6 +63,7 @@ typedef struct st_myrg_table_info typedef struct st_myrg_info { MYRG_TABLE *open_tables,*current_table,*end_table,*last_used_table; + uint merge_insert_method; ulonglong records; /* records in tables */ ulonglong del; /* Removed records */ ulonglong data_file_length; @@ -81,10 +89,11 @@ extern int myrg_rkey(MYRG_INFO *file,byte *buf,int inx,const byte *key, extern int myrg_rrnd(MYRG_INFO *file,byte *buf,ulonglong pos); extern int myrg_rsame(MYRG_INFO *file,byte *record,int inx); extern int myrg_update(MYRG_INFO *file,const byte *old,byte *new_rec); +extern int myrg_write(MYRG_INFO *info,byte *rec); extern int myrg_status(MYRG_INFO *file,MYMERGE_INFO *x,int flag); extern int myrg_lock_database(MYRG_INFO *file,int lock_type); -extern int myrg_create(const char *name,const char **table_names, - my_bool fix_names); +extern int myrg_create(const char *name, const char **table_names, + uint insert_method, my_bool fix_names); extern int myrg_extra(MYRG_INFO *file,enum ha_extra_function function); extern ha_rows myrg_records_in_range(MYRG_INFO *info,int inx, const byte *start_key,uint start_key_len, diff --git a/include/mysql.h b/include/mysql.h index 3e3a6f35e56..a1bd96540e8 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -48,32 +48,15 @@ typedef char my_bool; #endif typedef char * gptr; -#ifndef ST_USED_MEM_DEFINED -#define ST_USED_MEM_DEFINED -typedef struct st_used_mem { /* struct for once_alloc */ - struct st_used_mem *next; /* Next block in use */ - unsigned int left; /* memory left in block */ - unsigned int size; /* size of block */ -} USED_MEM; -typedef struct st_mem_root { - USED_MEM *free; - USED_MEM *used; - USED_MEM *pre_alloc; - unsigned int min_malloc; - unsigned int block_size; - - void (*error_handler)(void); -} MEM_ROOT; -#endif - #ifndef my_socket_defined #ifdef __WIN__ #define my_socket SOCKET #else typedef int my_socket; -#endif -#endif -#endif +#endif /* __WIN__ */ +#endif /* my_socket_defined */ +#endif /* _global_h */ + #include "mysql_com.h" #include "mysql_version.h" @@ -118,6 +101,24 @@ typedef struct st_mysql_rows { typedef MYSQL_ROWS *MYSQL_ROW_OFFSET; /* offset to current row */ +#ifndef ST_USED_MEM_DEFINED +#define ST_USED_MEM_DEFINED +typedef struct st_used_mem { /* struct for once_alloc */ + struct st_used_mem *next; /* Next block in use */ + unsigned int left; /* memory left in block */ + unsigned int size; /* size of block */ +} USED_MEM; +typedef struct st_mem_root { + USED_MEM *free; + USED_MEM *used; + USED_MEM *pre_alloc; + unsigned int min_malloc; + unsigned int block_size; + + void (*error_handler)(void); +} MEM_ROOT; +#endif + typedef struct st_mysql_data { my_ulonglong rows; unsigned int fields; diff --git a/include/mysql_com.h b/include/mysql_com.h index ce134fcab2c..63fbc05b0cb 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -113,10 +113,12 @@ typedef struct st_net { unsigned int last_errno,max_packet,timeout,pkt_nr; unsigned char error; my_bool return_errno,compress; - my_bool no_send_ok; /* needed if we are doing several - queries in one command ( as in LOAD TABLE ... FROM MASTER ), - and do not want to confuse the client with OK at the wrong time - */ + /* + The following variable is set if we are doing several queries in one + command ( as in LOAD TABLE ... FROM MASTER ), + and do not want to confuse the client with OK at the wrong time + */ + my_bool no_send_ok; unsigned long remain_in_buf,length, buf_length, where_b; unsigned int *return_status; unsigned char reading_or_writing; diff --git a/sql/mysql_embed.h b/include/mysql_embed.h similarity index 94% rename from sql/mysql_embed.h rename to include/mysql_embed.h index 4bfaca547a8..77f6f3fa32c 100644 --- a/sql/mysql_embed.h +++ b/include/mysql_embed.h @@ -22,5 +22,8 @@ #undef HAVE_PSTACK /* No stacktrace */ #undef HAVE_DLOPEN /* No udf functions */ +#undef HAVE_OPENSSL +#undef HAVE_VIO +#define DONT_USE_RAID #endif /* EMBEDDED_LIBRARY */ diff --git a/include/violite.h b/include/violite.h index 49791c6b68a..947b874c46a 100644 --- a/include/violite.h +++ b/include/violite.h @@ -33,67 +33,59 @@ extern "C" { #endif /* __cplusplus */ enum enum_vio_type { VIO_CLOSED, VIO_TYPE_TCPIP, VIO_TYPE_SOCKET, - VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL}; + VIO_TYPE_NAMEDPIPE, VIO_TYPE_SSL}; #ifndef __WIN__ #define HANDLE void * #endif -Vio* vio_new(my_socket sd, - enum enum_vio_type type, - my_bool localhost); +Vio* vio_new(my_socket sd, enum enum_vio_type type, my_bool localhost); #ifdef __WIN__ -Vio* vio_new_win32pipe(HANDLE hPipe); +Vio* vio_new_win32pipe(HANDLE hPipe); #endif -void vio_delete(Vio* vio); +void vio_delete(Vio* vio); #ifdef EMBEDDED_LIBRARY void vio_reset(Vio *vio); #else void vio_reset(Vio* vio, enum enum_vio_type type, - my_socket sd, HANDLE hPipe, - my_bool localhost); + my_socket sd, HANDLE hPipe, my_bool localhost); #endif /* * vio_read and vio_write should have the same semantics * as read(2) and write(2). */ -int vio_read( Vio* vio, - gptr buf, int size); -int vio_write( Vio* vio, - const gptr buf, - int size); +int vio_read(Vio *vio, gptr buf, int size); +int vio_write(Vio *vio, const gptr buf, int size); /* * Whenever the socket is set to blocking mode or not. */ -int vio_blocking( Vio* vio, - my_bool onoff); -my_bool vio_is_blocking( Vio* vio); +int vio_blocking(Vio *vio, my_bool onoff); +my_bool vio_is_blocking(Vio *vio); /* * setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. */ - int vio_fastsend( Vio* vio); +int vio_fastsend(Vio *vio); /* * setsockopt SO_KEEPALIVE at SOL_SOCKET level, when possible. */ -int vio_keepalive( Vio* vio, - my_bool onoff); +int vio_keepalive(Vio *vio, my_bool onoff); /* * Whenever we should retry the last read/write operation. */ -my_bool vio_should_retry( Vio* vio); +my_bool vio_should_retry(Vio *vio); /* * When the workday is over... */ -int vio_close(Vio* vio); +int vio_close(Vio* vio); /* * Short text description of the socket for those, who are curious.. */ -const char* vio_description( Vio* vio); +const char* vio_description(Vio *vio); /* Return the type of the connection */ - enum enum_vio_type vio_type(Vio* vio); +enum enum_vio_type vio_type(Vio* vio); /* Return last error number */ int vio_errno(Vio*vio); @@ -117,8 +109,8 @@ my_bool vio_poll_read(Vio *vio,uint timeout); } #endif #endif /* vio_violite_h_ */ -#ifdef HAVE_VIO -#ifndef DONT_MAP_VIO + +#if defined(HAVE_VIO) && !defined(DONT_MAP_VIO) #define vio_delete(vio) (vio)->viodelete(vio) #define vio_errno(vio) (vio)->vioerrno(vio) #define vio_read(vio, buf, size) (vio)->read(vio,buf,size) @@ -132,9 +124,7 @@ my_bool vio_poll_read(Vio *vio,uint timeout); #define vio_peer_addr(vio, buf) (vio)->peer_addr(vio, buf) #define vio_in_addr(vio, in) (vio)->in_addr(vio, in) #define vio_poll_read(vio,timeout) (vio)->poll_read(vio,timeout) -#endif /* !DONT_MAP_VIO */ -#endif /* HAVE_VIO */ - +#endif /* defined(HAVE_VIO) && !defined(DONT_MAP_VIO) */ #ifdef HAVE_OPENSSL #define HEADER_DES_LOCL_H dummy_something @@ -142,17 +132,16 @@ my_bool vio_poll_read(Vio *vio,uint timeout); #include #include "my_net.h" /* needed because of struct in_addr */ - #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -void vio_ssl_delete(Vio* vio); +void vio_ssl_delete(Vio* vio); -int vio_ssl_read(Vio* vio,gptr buf, int size); -int vio_ssl_write(Vio* vio,const gptr buf,int size); -int vio_ssl_blocking(Vio* vio,my_bool onoff); -my_bool vio_ssl_is_blocking(Vio* vio); +int vio_ssl_read(Vio* vio,gptr buf, int size); +int vio_ssl_write(Vio* vio,const gptr buf,int size); +int vio_ssl_blocking(Vio* vio,my_bool onoff); +my_bool vio_ssl_is_blocking(Vio* vio); /* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible. */ int vio_ssl_fastsend(Vio* vio); @@ -170,8 +159,6 @@ void vio_ssl_in_addr(Vio *vio, struct in_addr *in); /* Return 1 if there is data to be read */ my_bool vio_ssl_poll_read(Vio *vio,uint timeout); -#ifdef HAVE_OPENSSL - /* Single copy for server */ struct st_VioSSLAcceptorFd { @@ -200,16 +187,14 @@ struct st_VioSSLConnectorFd void sslaccept(struct st_VioSSLAcceptorFd*, Vio*); void sslconnect(struct st_VioSSLConnectorFd*, Vio*); -#else /* HAVE_OPENSSL */ -/* This dummy is required to maintain proper size of st_mysql in mysql.h */ -struct st_VioSSLConnectorFd {}; -#endif /* HAVE_OPENSSL */ -struct st_VioSSLConnectorFd *new_VioSSLConnectorFd( - const char* key_file,const char* cert_file,const char* ca_file,const char* ca_path); -struct st_VioSSLAcceptorFd *new_VioSSLAcceptorFd( - const char* key_file,const char* cert_file,const char* ca_file,const char* ca_path); +struct st_VioSSLConnectorFd +*new_VioSSLConnectorFd(const char* key_file, const char* cert_file, + const char* ca_file, const char* ca_path); +struct st_VioSSLAcceptorFd +*new_VioSSLAcceptorFd(const char* key_file, const char* cert_file, + const char* ca_file,const char* ca_path); Vio* new_VioSSL(struct st_VioSSLAcceptorFd* fd, Vio* sd,int state); - + #ifdef __cplusplus } #endif @@ -229,19 +214,19 @@ struct st_vio char desc[30]; /* String description */ #ifdef HAVE_VIO /* function pointers. They are similar for socket/SSL/whatever */ - void (*viodelete)(Vio*); - int(*vioerrno)(Vio*); - int(*read)(Vio*, gptr, int); - int(*write)(Vio*, gptr, int); - int(*vioblocking)(Vio*, my_bool); - my_bool(*is_blocking)(Vio*); - int(*viokeepalive)(Vio*, my_bool); - int(*fastsend)(Vio*); - my_bool(*peer_addr)(Vio*, gptr); - void(*in_addr)(Vio*, struct in_addr*); - my_bool(*should_retry)(Vio*); - int(*vioclose)(Vio*); - my_bool(*poll_read)(Vio*,uint); + void (*viodelete)(Vio*); + int (*vioerrno)(Vio*); + int (*read)(Vio*, gptr, int); + int (*write)(Vio*, gptr, int); + int (*vioblocking)(Vio*, my_bool); + my_bool (*is_blocking)(Vio*); + int (*viokeepalive)(Vio*, my_bool); + int (*fastsend)(Vio*); + my_bool (*peer_addr)(Vio*, gptr); + void (*in_addr)(Vio*, struct in_addr*); + my_bool (*should_retry)(Vio*); + int (*vioclose)(Vio*); + my_bool (*poll_read)(Vio*,uint); #ifdef HAVE_OPENSSL BIO* bio_; @@ -252,4 +237,3 @@ struct st_vio #endif /* HAVE_VIO */ }; #endif /* EMBEDDED_LIBRARY */ - diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index eb0e2f1820a..03162bc1dfa 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -2014,6 +2014,7 @@ mysql_close(MYSQL *mysql) mysql_close(tmp); tmp = tmp1; } + mysql->rpl_pivot=0; } if (mysql != mysql->master) mysql_close(mysql->master); diff --git a/libmysqld/examples/Makefile.am b/libmysqld/examples/Makefile.am index b687a528c6f..75487302e46 100644 --- a/libmysqld/examples/Makefile.am +++ b/libmysqld/examples/Makefile.am @@ -7,7 +7,7 @@ link_sources: @LN_CP_F@ $(srcdir)/../../client/$$f $(srcdir)/$$f; \ done; -DEFS = -DEMBEDDED_SERVER +DEFS = -DEMBEDDED_LIBRARY INCLUDES = -I$(top_srcdir)/include $(openssl_includes) \ -I$(srcdir) -I$(top_srcdir) -I$(top_srcdir)/client LIBS = @LIBS@ diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index f07150c9845..e7da577ab0c 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -13,6 +13,7 @@ * */ #include "my_global.h" +#include "mysql_embed.h" #include "my_pthread.h" #include "sys/types.h" #include "../regex/regex.h" diff --git a/libmysqld/lib_vio.c b/libmysqld/lib_vio.c index e86e6c7e8da..37f77eaaad5 100644 --- a/libmysqld/lib_vio.c +++ b/libmysqld/lib_vio.c @@ -23,12 +23,13 @@ */ #include +#include "mysql_embed.h" +#include "mysql.h" #ifndef HAVE_VIO /* is Vio suppored by the Vio lib ? */ #include #include -#include "mysql.h" #include #include #include diff --git a/libmysqld/libmysqld.c b/libmysqld/libmysqld.c index cb8b2f02773..8931bc3cd48 100644 --- a/libmysqld/libmysqld.c +++ b/libmysqld/libmysqld.c @@ -15,19 +15,19 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#define DONT_USE_RAID #include #if defined(__WIN__) || defined(_WIN32) || defined(_WIN64) #include #include #endif +#include "mysql_embed.h" +#include "mysql.h" +#include "mysql_version.h" +#include "mysqld_error.h" #include #include #include #include -#include "mysql.h" -#include "mysql_version.h" -#include "mysqld_error.h" #include "errmsg.h" #include #include @@ -88,7 +88,6 @@ static int read_one_row(MYSQL *mysql,uint fields,MYSQL_ROW row, static void end_server(MYSQL *mysql); static void read_user_name(char *name); static void append_wild(char *to,char *end,const char *wild); -static my_bool mysql_reconnect(MYSQL *mysql); static int send_file_to_server(MYSQL *mysql,const char *filename); static sig_handler pipe_sig_handler(int sig); static ulong mysql_sub_escape_string(CHARSET_INFO *charset_info, char *to, @@ -1346,35 +1345,6 @@ error: } -static my_bool mysql_reconnect(MYSQL *mysql) -{ - MYSQL tmp_mysql; - DBUG_ENTER("mysql_reconnect"); - - if (!mysql->reconnect || - (mysql->server_status & SERVER_STATUS_IN_TRANS) || !mysql->host_info) - { - /* Allov reconnect next time */ - mysql->server_status&= ~SERVER_STATUS_IN_TRANS; - DBUG_RETURN(1); - } - mysql_init(&tmp_mysql); - tmp_mysql.options=mysql->options; - if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd, - mysql->db, mysql->port, mysql->unix_socket, - mysql->client_flag)) - DBUG_RETURN(1); - tmp_mysql.free_me=mysql->free_me; - mysql->free_me=0; - bzero((char*) &mysql->options,sizeof(mysql->options)); - mysql_close(mysql); - *mysql=tmp_mysql; - net_clear(&mysql->net); - mysql->affected_rows= ~(my_ulonglong) 0; - DBUG_RETURN(0); -} - - /************************************************************************** ** Change user and database **************************************************************************/ diff --git a/myisammrg/Makefile.am b/myisammrg/Makefile.am index b09d7d70191..8b05bc5f386 100644 --- a/myisammrg/Makefile.am +++ b/myisammrg/Makefile.am @@ -21,7 +21,7 @@ libmyisammrg_a_SOURCES = myrg_open.c myrg_extra.c myrg_info.c myrg_locking.c \ myrg_rrnd.c myrg_update.c myrg_delete.c myrg_rsame.c \ myrg_panic.c myrg_close.c myrg_create.c myrg_static.c \ myrg_rkey.c myrg_rfirst.c myrg_rlast.c myrg_rnext.c \ - myrg_rprev.c myrg_queue.c + myrg_rprev.c myrg_queue.c myrg_write.c OMIT_DEPENDENCIES = pthread.h stdio.h __stdio.h stdlib.h __stdlib.h math.h\ __math.h time.h __time.h unistd.h __unistd.h types.h \ xtypes.h ac-types.h posix.h string.h __string.h \ diff --git a/myisammrg/myrg_create.c b/myisammrg/myrg_create.c index 113831b9d7f..5c6638b6ef2 100644 --- a/myisammrg/myrg_create.c +++ b/myisammrg/myrg_create.c @@ -23,7 +23,8 @@ a NULL-pointer last */ -int myrg_create(const char *name, const char **table_names, my_bool fix_names) +int myrg_create(const char *name, const char **table_names, + uint insert_method, my_bool fix_names) { int save_errno; uint errpos; @@ -50,6 +51,13 @@ int myrg_create(const char *name, const char **table_names, my_bool fix_names) goto err; } } + if (insert_method != MERGE_INSERT_DISABLED) + { + end=strxmov(buff,"#INSERT_METHOD=", + get_type(&merge_insert_method,insert_method),"\n",NullS); + if (my_write(file,buff,(uint) (end-buff),MYF(MY_WME | MY_NABP))) + goto err; + } if (my_close(file,MYF(0))) goto err; DBUG_RETURN(0); diff --git a/myisammrg/myrg_open.c b/myisammrg/myrg_open.c index 9fa89b315ff..60523c90ff4 100644 --- a/myisammrg/myrg_open.c +++ b/myisammrg/myrg_open.c @@ -14,7 +14,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* open a MYMERGE_-database */ +/* open a MyISAM MERGE table */ #include "mymrgdef.h" #include @@ -23,17 +23,14 @@ #include "mrg_static.c" #endif -/* open a MYMERGE_-database. - +/* + open a MyISAM MERGE table if handle_locking is 0 then exit with error if some database is locked if handle_locking is 1 then wait if database is locked */ -MYRG_INFO *myrg_open( -const char *name, -int mode, -int handle_locking) +MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) { int save_errno,i,errpos; uint files,dir_length,length,options; @@ -63,25 +60,34 @@ int handle_locking) { if ((end=buff+length)[-1] == '\n') end[-1]='\0'; - if (buff[0] && buff[0] != '#') /* Skipp empty lines and comments */ + if (!buff[0]) + continue; /* Skip empty lines */ + if (buff[0] == '#') { - if (!test_if_hard_path(buff)) - { - VOID(strmake(name_buff+dir_length,buff, - sizeof(name_buff)-1-dir_length)); - VOID(cleanup_dirname(buff,name_buff)); + if( !strncmp(buff+1,"INSERT_METHOD=",14)) + { /* Lookup insert method */ + int tmp=find_type(buff+15,&merge_insert_method,2); + info.merge_insert_method = (uint) (tmp >= 0 ? tmp : 0); } - if (!(isam=mi_open(buff,mode,test(handle_locking)))) - goto err; - files++; - last_isam=isam; - if (info.reclength && info.reclength != isam->s->base.reclength) - { - my_errno=HA_ERR_WRONG_IN_RECORD; - goto err; - } - info.reclength=isam->s->base.reclength; + continue; /* Skip comments */ } + + if (!test_if_hard_path(buff)) + { + VOID(strmake(name_buff+dir_length,buff, + sizeof(name_buff)-1-dir_length)); + VOID(cleanup_dirname(buff,name_buff)); + } + if (!(isam=mi_open(buff,mode,test(handle_locking)))) + goto err; + files++; + last_isam=isam; + if (info.reclength && info.reclength != isam->s->base.reclength) + { + my_errno=HA_ERR_WRONG_IN_RECORD; + goto err; + } + info.reclength=isam->s->base.reclength; } if (!(m_info= (MYRG_INFO*) my_malloc(sizeof(MYRG_INFO)+ files*sizeof(MYRG_TABLE), diff --git a/myisammrg/myrg_static.c b/myisammrg/myrg_static.c index 88eb095382b..ad57ea847d5 100644 --- a/myisammrg/myrg_static.c +++ b/myisammrg/myrg_static.c @@ -24,3 +24,7 @@ #endif LIST *myrg_open_list=0; +static const char *merge_insert_methods[] = +{ "FIRST", "LAST", NullS }; +TYPELIB merge_insert_method= { array_elements(merge_insert_methods),"", + merge_insert_methods}; diff --git a/myisammrg/myrg_write.c b/myisammrg/myrg_write.c new file mode 100644 index 00000000000..b1b0b33f73d --- /dev/null +++ b/myisammrg/myrg_write.c @@ -0,0 +1,30 @@ +/* Copyright (C) 2001 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 */ + +/* Write a row to a MyISAM MERGE table */ + +#include "mymrgdef.h" + +int myrg_write(register MYRG_INFO *info, byte *rec) +{ + /* [phi] MERGE_WRITE_DISABLED is handled by the else case */ + if (info->merge_insert_method == MERGE_INSERT_TO_FIRST) + return mi_write(info->open_tables[0].table,rec); + else if (info->merge_insert_method == MERGE_INSERT_TO_LAST) + return mi_write(info->end_table[-1].table,rec); + else /* unsupported insertion method */ + return (my_errno=HA_ERR_WRONG_COMMAND); +} diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 4c67ec10bb3..5c4a62d5c41 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -61,7 +61,7 @@ CREATE TABLE t1 ( INSERT INTO t1 (pseudo,pseudo1,same) VALUES ('joce', 'testtt', 1),('joce', 'tsestset', 1),('dekad', 'joce', 1); SELECT pseudo FROM t1 WHERE pseudo1='joce' UNION SELECT pseudo FROM t1 WHERE pseudo='joce'; SELECT pseudo1 FROM t1 WHERE pseudo1='joce' UNION SELECT pseudo1 FROM t1 WHERE pseudo='joce'; -SELECT * FROM t1 WHERE pseudo1='joce' UNION SELECT * FROM t1 WHERE pseudo='joce' order by pseudo desc; +SELECT * FROM t1 WHERE pseudo1='joce' UNION SELECT * FROM t1 WHERE pseudo='joce' order by pseudo desc,pseudo1 desc; SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT pseudo FROM t1 WHERE pseudo1='joce'; SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION ALL SELECT pseudo FROM t1 WHERE pseudo1='joce'; SELECT pseudo1 FROM t1 WHERE pseudo='joce' UNION SELECT 1; diff --git a/sql/Makefile.am b/sql/Makefile.am index f6d7888691d..ea29aa2e5a7 100644 --- a/sql/Makefile.am +++ b/sql/Makefile.am @@ -57,7 +57,7 @@ noinst_HEADERS = item.h item_func.h item_sum.h item_cmpfunc.h \ sql_select.h structs.h table.h sql_udf.h hash_filo.h\ lex.h lex_symbol.h sql_acl.h sql_crypt.h md5.h \ log_event.h mini_client.h sql_repl.h slave.h \ - stacktrace.h sql_sort.h mysql_embed.h + stacktrace.h sql_sort.h mysqld_SOURCES = sql_lex.cc sql_handler.cc \ item.cc item_sum.cc item_buff.cc item_func.cc \ item_cmpfunc.cc item_strfunc.cc item_timefunc.cc \ diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 722f5226980..cfd859acf06 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -216,7 +216,7 @@ you have to change 'main' to print out the new function\n"); return(1); } - if (opt_verbose) + if (opt_verbose > 1) fprintf (stderr,"Info: Possible add values: %d\n",found-type_count); for (prime=primes; (function_mod=*prime) ; prime++) @@ -376,7 +376,7 @@ static int get_options(int argc, char **argv) opt_search=1; break; case 'v': - opt_verbose=1; + opt_verbose++; break; case 'V': usage(1); exit(0); case 'I': @@ -473,7 +473,7 @@ int main(int argc,char **argv) MY_INIT(argv[0]); - start_value=2250933L; best_t1=2721579L; best_t2=4627039L; best_type=3; /* mode=4567 add=4 type: 0 */ + start_value=4198729L; best_t1=6245075L; best_t2=3686256L; best_type=4; /* mode=5839 add=1 type: 0 */ if (get_options(argc,(char **) argv)) exit(1); @@ -493,7 +493,7 @@ int main(int argc,char **argv) printf("start_value=%ldL; best_t1=%ldL; best_t2=%ldL; best_type=%d; /* mode=%d add=%d type: %d */\n", start_value, best_t1,best_t2,best_type,best_mod,best_add, best_functype); - + best_start_value=start_value; for (uint i=1 ; i <= opt_count ; i++) { if (i % 10 == 0) @@ -516,6 +516,10 @@ int main(int argc,char **argv) best_start_value,best_t1,best_t2,best_type,best_mod,best_add, best_functype); } + if (opt_verbose && (i % 20000) == 0) + printf("\nstart_value=%ldL; best_t1=%ldL; best_t2=%ldL; best_type=%d; /* mode=%d add=%d type: %d */\n", + best_start_value,best_t1,best_t2,best_type,best_mod,best_add, + best_functype); } } diff --git a/sql/ha_myisammrg.cc b/sql/ha_myisammrg.cc index abcf81806ad..92c1372a7a1 100644 --- a/sql/ha_myisammrg.cc +++ b/sql/ha_myisammrg.cc @@ -66,7 +66,13 @@ int ha_myisammrg::close(void) int ha_myisammrg::write_row(byte * buf) { - return (my_errno=HA_ERR_WRONG_COMMAND); + statistic_increment(ha_write_count,&LOCK_status); + if (table->time_stamp) + update_timestamp(buf+table->time_stamp-1); + if (table->next_number_field && buf == table->record[0]) + return (my_errno=HA_ERR_WRONG_COMMAND); + // update_auto_increment(); - [phi] have to check this before allowing it + return myrg_write(file,buf); } int ha_myisammrg::update_row(const byte * old_data, byte * new_data) @@ -217,6 +223,7 @@ THR_LOCK_DATA **ha_myisammrg::store_lock(THD *thd, void ha_myisammrg::update_create_info(HA_CREATE_INFO *create_info) { + // [phi] auto_increment stuff is missing (but currently not needed) DBUG_ENTER("ha_myisammrg::update_create_info"); if (!(create_info->used_fields & HA_CREATE_USED_UNION)) { @@ -241,6 +248,10 @@ void ha_myisammrg::update_create_info(HA_CREATE_INFO *create_info) } *create_info->merge_list.next=0; } + if (!(create_info->used_fields & HA_CREATE_USED_INSERT_METHOD)) + { + create_info->merge_insert_method = file->merge_insert_method; + } DBUG_VOID_RETURN; err: @@ -263,12 +274,20 @@ int ha_myisammrg::create(const char *name, register TABLE *form, *pos++= tables->real_name; *pos=0; DBUG_RETURN(myrg_create(fn_format(buff,name,"","",2+4+16), - (const char **) table_names, (my_bool) 0)); + (const char **) table_names, + create_info->merge_insert_method, + (my_bool) 0)); } void ha_myisammrg::append_create_info(String *packet) { char buff[FN_REFLEN]; + if (file->merge_insert_method != MERGE_INSERT_DISABLED) + { + packet->append(" INSERT_METHOD=",15); + const char *tmp = get_type(&merge_insert_method,file->merge_insert_method); + packet->append(tmp); + } packet->append(" UNION=(",8); MYRG_TABLE *table,*first; diff --git a/sql/handler.h b/sql/handler.h index 5cf39daeadf..dee71e8ebda 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -120,9 +120,10 @@ enum row_type { ROW_TYPE_DEFAULT, ROW_TYPE_FIXED, ROW_TYPE_DYNAMIC, /* struct to hold information about the table that should be created */ /* Bits in used_fields */ -#define HA_CREATE_USED_AUTO 1 -#define HA_CREATE_USED_RAID 2 -#define HA_CREATE_USED_UNION 4 +#define HA_CREATE_USED_AUTO 1 +#define HA_CREATE_USED_RAID 2 +#define HA_CREATE_USED_UNION 4 +#define HA_CREATE_USED_INSERT_METHOD 8 typedef struct st_thd_trans { void *bdb_tid; @@ -150,6 +151,7 @@ typedef struct st_ha_create_information bool if_not_exists; ulong used_fields; SQL_LIST merge_list; + uint merge_insert_method; } HA_CREATE_INFO; diff --git a/sql/lex.h b/sql/lex.h index ca797e5b894..5decf089e68 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -178,6 +178,7 @@ static SYMBOL symbols[] = { { "INNODB", SYM(INNOBASE_SYM),0,0}, { "INSERT", SYM(INSERT),0,0}, { "INSERT_ID", SYM(INSERT_ID),0,0}, + { "INSERT_METHOD", SYM(INSERT_METHOD),0,0}, { "INT", SYM(INT_SYM),0,0}, { "INTEGER", SYM(INT_SYM),0,0}, { "INTERVAL", SYM(INTERVAL_SYM),0,0}, diff --git a/sql/mini_client.cc b/sql/mini_client.cc index 1afe4c97b8e..d60a3bce880 100644 --- a/sql/mini_client.cc +++ b/sql/mini_client.cc @@ -22,7 +22,6 @@ in case we decide to make them external at some point */ -#define DONT_USE_RAID #if defined(__WIN__) #include #include @@ -41,6 +40,7 @@ inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __a #endif #include +#include #include #include #include diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 43650f365bb..59fee295b60 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -31,6 +31,7 @@ #include #endif #include +#include "mysql_embed.h" #include #include #include diff --git a/sql/sql_show.cc b/sql/sql_show.cc index b51e9ab5a73..67713b85720 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -17,7 +17,6 @@ /* Function with list databases, tables or fields */ -#include "my_global.h" #include "mysql_priv.h" #include "sql_select.h" // For select_describe #include "sql_acl.h" diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 6d80234082d..1995c1295f1 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -27,6 +27,7 @@ #include "sql_acl.h" #include "lex_symbol.h" #include +#include extern void yyerror(const char*); int yylex(void *yylval); @@ -390,6 +391,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %token IDENTIFIED_SYM %token IF %token INSERT_ID +%token INSERT_METHOD %token INTERVAL_SYM %token LAST_INSERT_ID %token LEFT @@ -490,7 +492,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); table_option opt_if_not_exists %type - ULONG_NUM raid_types + ULONG_NUM raid_types merge_insert_types %type ulonglong_num @@ -796,6 +798,7 @@ create_table_option: table_list->next=0; lex->create_info.used_fields|= HA_CREATE_USED_UNION; } + | INSERT_METHOD EQ merge_insert_types { Lex->create_info.merge_insert_method= $3; Lex->create_info.used_fields|= HA_CREATE_USED_INSERT_METHOD;} | DATA_SYM DIRECTORY_SYM EQ TEXT_STRING { Lex->create_info.data_file_name= $4.str; } | INDEX DIRECTORY_SYM EQ TEXT_STRING { Lex->create_info.index_file_name= $4.str; } @@ -819,6 +822,11 @@ raid_types: | RAID_0_SYM { $$= RAID_TYPE_0; } | ULONG_NUM { $$=$1;} +merge_insert_types: + NO_SYM { $$= MERGE_INSERT_DISABLED; } + | FIRST_SYM { $$= MERGE_INSERT_TO_FIRST; } + | LAST_SYM { $$= MERGE_INSERT_TO_LAST; } + opt_select_from: /* empty */ | select_from select_lock_type @@ -2862,6 +2870,7 @@ keyword: | ISAM_SYM {} | ISSUER_SYM {} | INNOBASE_SYM {} + | INSERT_METHOD {} | LAST_SYM {} | LEVEL_SYM {} | LOCAL_SYM {} From 5d9be4de24ab02436edbe2c75e96704a31c522b2 Mon Sep 17 00:00:00 2001 From: "monty@hundin.mysql.fi" <> Date: Sat, 22 Sep 2001 17:40:59 +0300 Subject: [PATCH 13/13] Portability fix --- client/mysqltest.c | 22 +++++++++------------- sql/gen_lex_hash.cc | 5 +++-- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 1361dc843ed..9a2d3e4c137 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -46,19 +46,15 @@ #define MTEST_VERSION "1.10" #include +#include #include #include #include #include +#include #include -#ifdef OS2 -#include -#else - #include -#endif #include #include -#include #include #include #include @@ -1067,18 +1063,18 @@ int close_connection(struct st_query* q) p++; *p = 0; - for(con = cons; con < next_con; con++) + for (con = cons; con < next_con; con++) { if (!strcmp(con->name, name)) { - if(q->type == Q_DIRTY_CLOSE) + if (q->type == Q_DIRTY_CLOSE) + { + if (con->mysql.net.vio) { - if(con->mysql.net.vio) - { - vio_delete(con->mysql.net.vio); - con->mysql.net.vio = 0; - } + vio_delete(con->mysql.net.vio); + con->mysql.net.vio = 0; } + } mysql_close(&con->mysql); DBUG_RETURN(0); diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index cfd859acf06..6530e5dd4cf 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -26,7 +26,8 @@ #include "mysql_version.h" #include "lex.h" -bool opt_search=0,opt_verbose=0; +bool opt_search=0; +int opt_verbose=0; ulong opt_count=100000; #define max_allowed_array 8000 // Don't generate bigger arrays than this @@ -473,7 +474,7 @@ int main(int argc,char **argv) MY_INIT(argv[0]); - start_value=4198729L; best_t1=6245075L; best_t2=3686256L; best_type=4; /* mode=5839 add=1 type: 0 */ + start_value=1060872L; best_t1=7930739L; best_t2=4311642L; best_type=3; /* mode=5333 add=6 type: 0 */ if (get_options(argc,(char **) argv)) exit(1);