diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/Makefile.am | 2 | ||||
-rw-r--r-- | sql/field.cc | 2 | ||||
-rw-r--r-- | sql/gen_lex_hash.cc | 15 | ||||
-rw-r--r-- | sql/ha_myisammrg.cc | 23 | ||||
-rw-r--r-- | sql/handler.h | 8 | ||||
-rw-r--r-- | sql/item.cc | 10 | ||||
-rw-r--r-- | sql/lex.h | 3 | ||||
-rw-r--r-- | sql/log_event.cc | 143 | ||||
-rw-r--r-- | sql/log_event.h | 10 | ||||
-rw-r--r-- | sql/mini_client.cc | 2 | ||||
-rw-r--r-- | sql/mysql_priv.h | 3 | ||||
-rw-r--r-- | sql/mysqld.cc | 4 | ||||
-rw-r--r-- | sql/net_serv.cc | 1 | ||||
-rw-r--r-- | sql/opt_sum.cc | 4 | ||||
-rw-r--r-- | sql/slave.cc | 3 | ||||
-rw-r--r-- | sql/sql_base.cc | 39 | ||||
-rw-r--r-- | sql/sql_show.cc | 1 | ||||
-rw-r--r-- | sql/sql_union.cc | 4 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 17 | ||||
-rw-r--r-- | sql/table.cc | 8 | ||||
-rw-r--r-- | sql/table.h | 2 |
21 files changed, 168 insertions, 136 deletions
diff --git a/sql/Makefile.am b/sql/Makefile.am index 04806248cae..050abfb02b6 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/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; } diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 722f5226980..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 @@ -216,7 +217,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 +377,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 +474,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=1060872L; best_t1=7930739L; best_t2=4311642L; best_type=3; /* mode=5333 add=6 type: 0 */ if (get_options(argc,(char **) argv)) exit(1); @@ -493,7 +494,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 +517,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/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/lex.h b/sql/lex.h index b72b42f2a3d..5decf089e68 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}, @@ -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/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<Item> 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<Item>& fields_arg, enum enum_duplicates handle_dup, - char* block_arg, uint block_len_arg); + const char* table_name_arg, + List<Item>& 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/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 <winsock.h> #include <odbcinst.h> @@ -41,6 +40,7 @@ inline int local_thr_alarm(my_bool *A,int B __attribute__((unused)),ALARM *C __a #endif #include <my_global.h> +#include <mysql_embed.h> #include <mysql_com.h> #include <violite.h> #include <my_sys.h> 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 <my_global.h> +#include "mysql_embed.h" #include <my_sys.h> #include <m_string.h> -#include "mysql_version.h" +#include <mysql_version.h> #include <hash.h> #include <signal.h> #include <thr_lock.h> 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\ 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 <winsock.h> #endif #include <my_global.h> +#include "mysql_embed.h" #include <mysql_com.h> #include <violite.h> #include <my_sys.h> 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_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_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> 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<Item> 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/sql_yacc.yy b/sql/sql_yacc.yy index 34cdd317e99..baef95dbcbb 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -27,6 +27,7 @@ #include "sql_acl.h" #include "lex_symbol.h" #include <myisam.h> +#include <myisammrg.h> 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 @@ -451,7 +453,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); %token ISSUER_SYM %token SUBJECT_SYM -%token CHIPHER_SYM +%token CIPHER_SYM %left SET_VAR %left OR_OR_CONCAT OR @@ -490,7 +492,7 @@ bool my_yyoverflow(short **a, YYSTYPE **b,int *yystacksize); table_option opt_if_not_exists %type <ulong_num> - ULONG_NUM raid_types + ULONG_NUM raid_types merge_insert_types %type <ulonglong_number> 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 @@ -2822,7 +2830,7 @@ keyword: | CHANGED {} | CHECKSUM_SYM {} | CHECK_SYM {} - | CHIPHER_SYM {} + | CIPHER_SYM {} | CLOSE_SYM {} | COMMENT_SYM {} | COMMIT_SYM {} @@ -2862,6 +2870,7 @@ keyword: | ISAM_SYM {} | ISSUER_SYM {} | INNOBASE_SYM {} + | INSERT_METHOD {} | LAST_SYM {} | LEVEL_SYM {} | LOCAL_SYM {} @@ -3312,7 +3321,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; } 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]; |