diff options
author | unknown <istruewing@stella.local> | 2008-03-26 17:36:12 +0100 |
---|---|---|
committer | unknown <istruewing@stella.local> | 2008-03-26 17:36:12 +0100 |
commit | 98b776605302196a74a7e6cfe153abeebc879388 (patch) | |
tree | bb8ca53b834b814a1c251b21904822d448b7b791 /storage | |
parent | 27c0540bd8e785499accbd4777bdb5067911cce9 (diff) | |
parent | 10d9d68d7cbe1bbf9cf37fee71473b097a89f239 (diff) | |
download | mariadb-git-98b776605302196a74a7e6cfe153abeebc879388.tar.gz |
Merge stella.local:/home2/mydev/mysql-5.1-amain
into stella.local:/home2/mydev/mysql-5.1-axmrg
mysql-test/t/query_cache.test:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/sql_delete.cc:
Auto merged
mysql-test/r/query_cache.result:
SCCS merged
Diffstat (limited to 'storage')
-rw-r--r-- | storage/archive/azio.c | 10 | ||||
-rw-r--r-- | storage/csv/ha_tina.cc | 47 | ||||
-rw-r--r-- | storage/csv/ha_tina.h | 1 | ||||
-rw-r--r-- | storage/federated/ha_federated.cc | 42 | ||||
-rw-r--r-- | storage/myisam/ft_static.c | 1 | ||||
-rw-r--r-- | storage/myisam/ha_myisam.cc | 86 | ||||
-rw-r--r-- | storage/myisam/mi_dynrec.c | 32 | ||||
-rw-r--r-- | storage/myisam/mi_open.c | 14 | ||||
-rw-r--r-- | storage/myisammrg/ha_myisammrg.cc | 6 |
9 files changed, 177 insertions, 62 deletions
diff --git a/storage/archive/azio.c b/storage/archive/azio.c index cada6c57918..59fbe2182ee 100644 --- a/storage/archive/azio.c +++ b/storage/archive/azio.c @@ -225,11 +225,17 @@ int get_byte(s) if (s->stream.avail_in == 0) { errno = 0; - s->stream.avail_in = my_read(s->file, (uchar *)s->inbuf, AZ_BUFSIZE_READ, MYF(0)); + s->stream.avail_in= (uInt) my_read(s->file, (uchar *)s->inbuf, + AZ_BUFSIZE_READ, MYF(0)); if (s->stream.avail_in == 0) { s->z_eof = 1; - /* if (ferror(s->file)) s->z_err = Z_ERRNO; */ + return EOF; + } + else if (s->stream.avail_in == (uInt) -1) + { + s->z_eof= 1; + s->z_err= Z_ERRNO; return EOF; } s->stream.next_in = s->inbuf; diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index c9fab79a4c5..f8dd778045f 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -56,6 +56,7 @@ TODO: #define META_BUFFER_SIZE sizeof(uchar) + sizeof(uchar) + sizeof(ulonglong) \ + sizeof(ulonglong) + sizeof(ulonglong) + sizeof(ulonglong) + sizeof(uchar) #define TINA_CHECK_HEADER 254 // The number we use to determine corruption +#define BLOB_MEMROOT_ALLOC_SIZE 8192 /* The file extension */ #define CSV_EXT ".CSV" // The data file @@ -597,6 +598,8 @@ int ha_tina::find_current_row(uchar *buf) bool read_all; DBUG_ENTER("ha_tina::find_current_row"); + free_root(&blobroot, MYF(MY_MARK_BLOCKS_FREE)); + /* We do not read further then local_saved_data_file_length in order not to conflict with undergoing concurrent insert. @@ -684,6 +687,22 @@ int ha_tina::find_current_row(uchar *buf) if ((*field)->store(buffer.ptr(), buffer.length(), buffer.charset(), CHECK_FIELD_WARN)) goto err; + if ((*field)->flags & BLOB_FLAG) + { + Field_blob *blob= *(Field_blob**) field; + uchar *src, *tgt; + uint length, packlength; + + packlength= blob->pack_length_no_ptr(); + length= blob->get_length(blob->ptr); + memcpy_fixed(&src, blob->ptr + packlength, sizeof(char*)); + if (src) + { + tgt= (uchar*) alloc_root(&blobroot, length); + bmove(tgt, src, length); + memcpy_fixed(blob->ptr + packlength, &tgt, sizeof(char*)); + } + } } } next_position= end_offset + eoln_len; @@ -914,9 +933,10 @@ int ha_tina::open_update_temp_file_if_needed() int ha_tina::update_row(const uchar * old_data, uchar * new_data) { int size; + int rc= -1; DBUG_ENTER("ha_tina::update_row"); - ha_statistic_increment(&SSV::ha_read_rnd_next_count); + ha_statistic_increment(&SSV::ha_update_count); if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE) table->timestamp_field->set_time(); @@ -931,20 +951,23 @@ int ha_tina::update_row(const uchar * old_data, uchar * new_data) The temp_file_length is used to calculate new data file length. */ if (chain_append()) - DBUG_RETURN(-1); + goto err; if (open_update_temp_file_if_needed()) - DBUG_RETURN(-1); + goto err; if (my_write(update_temp_file, (uchar*)buffer.ptr(), size, MYF(MY_WME | MY_NABP))) - DBUG_RETURN(-1); + goto err; temp_file_length+= size; + rc= 0; /* UPDATE should never happen on the log tables */ DBUG_ASSERT(!share->is_log_table); - DBUG_RETURN(0); +err: + DBUG_PRINT("info",("rc = %d", rc)); + DBUG_RETURN(rc); } @@ -1050,6 +1073,8 @@ int ha_tina::rnd_init(bool scan) records_is_known= 0; chain_ptr= chain; + init_alloc_root(&blobroot, BLOB_MEMROOT_ALLOC_SIZE, 0); + DBUG_RETURN(0); } @@ -1115,7 +1140,7 @@ void ha_tina::position(const uchar *record) int ha_tina::rnd_pos(uchar * buf, uchar *pos) { DBUG_ENTER("ha_tina::rnd_pos"); - ha_statistic_increment(&SSV::ha_read_rnd_next_count); + ha_statistic_increment(&SSV::ha_read_rnd_count); current_position= (off_t)my_get_ptr(pos,ref_length); DBUG_RETURN(find_current_row(buf)); } @@ -1179,6 +1204,7 @@ int ha_tina::rnd_end() off_t file_buffer_start= 0; DBUG_ENTER("ha_tina::rnd_end"); + free_root(&blobroot, MYF(0)); records_is_known= 1; if ((chain_ptr - chain) > 0) @@ -1350,6 +1376,8 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt) /* set current position to the beginning of the file */ current_position= next_position= 0; + init_alloc_root(&blobroot, BLOB_MEMROOT_ALLOC_SIZE, 0); + /* Read the file row-by-row. If everything is ok, repair is not needed. */ while (!(rc= find_current_row(buf))) { @@ -1358,6 +1386,8 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt) current_position= next_position; } + free_root(&blobroot, MYF(0)); + my_free((char*)buf, MYF(0)); if (rc == HA_ERR_END_OF_FILE) @@ -1535,6 +1565,9 @@ int ha_tina::check(THD* thd, HA_CHECK_OPT* check_opt) local_saved_data_file_length= share->saved_data_file_length; /* set current position to the beginning of the file */ current_position= next_position= 0; + + init_alloc_root(&blobroot, BLOB_MEMROOT_ALLOC_SIZE, 0); + /* Read the file row-by-row. If everything is ok, repair is not needed. */ while (!(rc= find_current_row(buf))) { @@ -1542,6 +1575,8 @@ int ha_tina::check(THD* thd, HA_CHECK_OPT* check_opt) count--; current_position= next_position; } + + free_root(&blobroot, MYF(0)); my_free((char*)buf, MYF(0)); thd_proc_info(thd, old_proc_info); diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h index 5ce09783b9b..5b4381396fc 100644 --- a/storage/csv/ha_tina.h +++ b/storage/csv/ha_tina.h @@ -82,6 +82,7 @@ class ha_tina: public handler uint32 chain_size; uint local_data_file_version; /* Saved version of the data file used */ bool records_is_known; + MEM_ROOT blobroot; private: bool get_write_pos(off_t *end_pos, tina_set *closest_hole); diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index 091a26f6f36..5702b2f3514 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -794,9 +794,9 @@ static int parse_url(MEM_ROOT *mem_root, FEDERATED_SHARE *share, TABLE *table, goto error; /* Found that if the string is: -user:@hostname:port/db/table -Then password is a null string, so set to NULL - */ + user:@hostname:port/db/table + Then password is a null string, so set to NULL + */ if ((share->password[0] == '\0')) share->password= NULL; } @@ -833,14 +833,21 @@ Then password is a null string, so set to NULL if ((strchr(share->table_name, '/'))) goto error; + /* + If hostname is omitted, we set it to NULL. According to + mysql_real_connect() manual: + The value of host may be either a hostname or an IP address. + If host is NULL or the string "localhost", a connection to the + local host is assumed. + */ if (share->hostname[0] == '\0') share->hostname= NULL; - } + if (!share->port) { - if (strcmp(share->hostname, my_localhost) == 0) - share->socket= (char *) MYSQL_UNIX_ADDR; + if (!share->hostname || strcmp(share->hostname, my_localhost) == 0) + share->socket= (char*) MYSQL_UNIX_ADDR; else share->port= MYSQL_PORT; } @@ -1292,10 +1299,21 @@ bool ha_federated::create_where_from_key(String *to, { if (*ptr++) { + /* + We got "IS [NOT] NULL" condition against nullable column. We + distinguish between "IS NOT NULL" and "IS NULL" by flag. For + "IS NULL", flag is set to HA_READ_KEY_EXACT. + */ if (emit_key_part_name(&tmp, key_part) || - tmp.append(STRING_WITH_LEN(" IS NULL "))) + (ranges[i]->flag == HA_READ_KEY_EXACT ? + tmp.append(STRING_WITH_LEN(" IS NULL ")) : + tmp.append(STRING_WITH_LEN(" IS NOT NULL ")))) goto err; - continue; + /* + We need to adjust pointer and length to be prepared for next + key part. As well as check if this was last key part. + */ + goto prepare_for_next_key_part; } } @@ -1403,12 +1421,18 @@ bool ha_federated::create_where_from_key(String *to, if (tmp.append(STRING_WITH_LEN(") "))) goto err; +prepare_for_next_key_part: if (store_length >= length) break; DBUG_PRINT("info", ("remainder %d", remainder)); DBUG_ASSERT(remainder > 1); length-= store_length; - ptr+= store_length; + /* + For nullable columns, null-byte is already skipped before, that is + ptr was incremented by 1. Since store_length still counts null-byte, + we need to subtract 1 from store_length. + */ + ptr+= store_length - test(key_part->null_bit); if (tmp.append(STRING_WITH_LEN(" AND "))) goto err; diff --git a/storage/myisam/ft_static.c b/storage/myisam/ft_static.c index 610c20eede6..1b6c7458fd7 100644 --- a/storage/myisam/ft_static.c +++ b/storage/myisam/ft_static.c @@ -608,7 +608,6 @@ const char *ft_precompiled_stopwords[] = { "won't", "wonder", "would", - "would", "wouldn't", "yes", "yet", diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index e74464a1834..c7584f801de 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -397,7 +397,26 @@ int check_definition(MI_KEYDEF *t1_keyinfo, MI_COLUMNDEF *t1_recinfo, } for (j= t1_keyinfo[i].keysegs; j--;) { - if (t1_keysegs[j].type != t2_keysegs[j].type || + uint8 t1_keysegs_j__type= t1_keysegs[j].type; + + /* + Table migration from 4.1 to 5.1. In 5.1 a *TEXT key part is + always HA_KEYTYPE_VARTEXT2. In 4.1 we had only the equivalent of + HA_KEYTYPE_VARTEXT1. Since we treat both the same on MyISAM + level, we can ignore a mismatch between these types. + */ + if ((t1_keysegs[j].flag & HA_BLOB_PART) && + (t2_keysegs[j].flag & HA_BLOB_PART)) + { + if ((t1_keysegs_j__type == HA_KEYTYPE_VARTEXT2) && + (t2_keysegs[j].type == HA_KEYTYPE_VARTEXT1)) + t1_keysegs_j__type= HA_KEYTYPE_VARTEXT1; /* purecov: tested */ + else if ((t1_keysegs_j__type == HA_KEYTYPE_VARBINARY2) && + (t2_keysegs[j].type == HA_KEYTYPE_VARBINARY1)) + t1_keysegs_j__type= HA_KEYTYPE_VARBINARY1; /* purecov: inspected */ + } + + if (t1_keysegs_j__type != t2_keysegs[j].type || t1_keysegs[j].language != t2_keysegs[j].language || t1_keysegs[j].null_bit != t2_keysegs[j].null_bit || t1_keysegs[j].length != t2_keysegs[j].length) @@ -1859,6 +1878,7 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, share->avg_row_length); create_info.data_file_name= ha_create_info->data_file_name; create_info.index_file_name= ha_create_info->index_file_name; + create_info.language= share->table_charset->number; if (ha_create_info->options & HA_LEX_CREATE_TMP_TABLE) create_flags|= HA_CREATE_TMP_TABLE; @@ -2078,6 +2098,7 @@ my_bool ha_myisam::register_query_cache_table(THD *thd, char *table_name, *engine_callback, ulonglong *engine_data) { + DBUG_ENTER("ha_myisam::register_query_cache_table"); /* No call back function is needed to determine if a cached statement is valid or not. @@ -2089,39 +2110,48 @@ my_bool ha_myisam::register_query_cache_table(THD *thd, char *table_name, */ *engine_data= 0; - /* - If a concurrent INSERT has happened just before the currently processed - SELECT statement, the total size of the table is unknown. + if (file->s->concurrent_insert) + { + /* + If a concurrent INSERT has happened just before the currently + processed SELECT statement, the total size of the table is + unknown. - To determine if the table size is known, the current thread's snap shot of - the table size with the actual table size are compared. + To determine if the table size is known, the current thread's snap + shot of the table size with the actual table size are compared. - If the table size is unknown the SELECT statement can't be cached. - */ - ulonglong actual_data_file_length; - ulonglong current_data_file_length; + If the table size is unknown the SELECT statement can't be cached. - /* - POSIX visibility rules specify that "2. Whatever memory values a - thread can see when it unlocks a mutex <...> can also be seen by any - thread that later locks the same mutex". In this particular case, - concurrent insert thread had modified the data_file_length in - MYISAM_SHARE before it has unlocked (or even locked) - structure_guard_mutex. So, here we're guaranteed to see at least that - value after we've locked the same mutex. We can see a later value - (modified by some other thread) though, but it's ok, as we only want - to know if the variable was changed, the actual new value doesn't matter - */ - actual_data_file_length= file->s->state.state.data_file_length; - current_data_file_length= file->save_state.data_file_length; + When concurrent inserts are disabled at table open, mi_open() + does not assign a get_status() function. In this case the local + ("current") status is never updated. We would wrongly think that + we cannot cache the statement. + */ + ulonglong actual_data_file_length; + ulonglong current_data_file_length; - if (current_data_file_length != actual_data_file_length) - { - /* Don't cache current statement. */ - return FALSE; + /* + POSIX visibility rules specify that "2. Whatever memory values a + thread can see when it unlocks a mutex <...> can also be seen by any + thread that later locks the same mutex". In this particular case, + concurrent insert thread had modified the data_file_length in + MYISAM_SHARE before it has unlocked (or even locked) + structure_guard_mutex. So, here we're guaranteed to see at least that + value after we've locked the same mutex. We can see a later value + (modified by some other thread) though, but it's ok, as we only want + to know if the variable was changed, the actual new value doesn't matter + */ + actual_data_file_length= file->s->state.state.data_file_length; + current_data_file_length= file->save_state.data_file_length; + + if (current_data_file_length != actual_data_file_length) + { + /* Don't cache current statement. */ + DBUG_RETURN(FALSE); + } } /* It is ok to try to cache current statement. */ - return TRUE; + DBUG_RETURN(TRUE); } #endif diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index 7e5f710c02c..8b9fa445a96 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -1006,12 +1006,12 @@ uint _mi_rec_pack(MI_INFO *info, register uchar *to, { if (rec->length > 255 && new_length > 127) { - to[0]=(char) ((new_length & 127)+128); - to[1]=(char) (new_length >> 7); - to+=2; - } - else - *to++= (char) new_length; + to[0]= (uchar) ((new_length & 127) + 128); + to[1]= (uchar) (new_length >> 7); + to+=2; + } + else + *to++= (uchar) new_length; memcpy((uchar*) to,pos,(size_t) new_length); to+=new_length; flag|=bit; } @@ -1045,7 +1045,7 @@ uint _mi_rec_pack(MI_INFO *info, register uchar *to, } if ((bit= bit << 1) >= 256) { - *packpos++ = (char) (uchar) flag; + *packpos++= (uchar) flag; bit=1; flag=0; } } @@ -1055,9 +1055,9 @@ uint _mi_rec_pack(MI_INFO *info, register uchar *to, } } if (bit != 1) - *packpos= (char) (uchar) flag; + *packpos= (uchar) flag; if (info->s->calc_checksum) - *to++=(char) info->checksum; + *to++= (uchar) info->checksum; DBUG_PRINT("exit",("packed length: %d",(int) (to-startpos))); DBUG_RETURN((uint) (to-startpos)); } /* _mi_rec_pack */ @@ -1128,12 +1128,14 @@ my_bool _mi_rec_check(MI_INFO *info,const uchar *record, uchar *rec_buff, goto err; if (rec->length > 255 && new_length > 127) { - if (to[0] != (char) ((new_length & 127)+128) || - to[1] != (char) (new_length >> 7)) - goto err; - to+=2; - } - else if (*to++ != (char) new_length) + /* purecov: begin inspected */ + if (to[0] != (uchar) ((new_length & 127) + 128) || + to[1] != (uchar) (new_length >> 7)) + goto err; + to+=2; + /* purecov: end */ + } + else if (*to++ != (uchar) new_length) goto err; to+=new_length; } diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index a4f6e1291db..d4e513a1c5d 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -281,6 +281,9 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) if (share->options & HA_OPTION_COMPRESS_RECORD) share->base.max_key_length+=2; /* For safety */ + /* Add space for node pointer */ + share->base.max_key_length+= share->base.key_reflength; + if (!my_multi_malloc(MY_WME, &share,sizeof(*share), &share->state.rec_per_key_part,sizeof(long)*key_parts, @@ -815,8 +818,17 @@ static void setup_key_functions(register MI_KEYDEF *keyinfo) keyinfo->get_key= _mi_get_pack_key; if (keyinfo->seg[0].flag & HA_PACK_KEY) { /* Prefix compression */ + /* + _mi_prefix_search() compares end-space against ASCII blank (' '). + It cannot be used for character sets, that do not encode the + blank character like ASCII does. UCS2 is an example. All + character sets with a fixed width > 1 or a mimimum width > 1 + cannot represent blank like ASCII does. In these cases we have + to use _mi_seq_search() for the search. + */ if (!keyinfo->seg->charset || use_strnxfrm(keyinfo->seg->charset) || - (keyinfo->seg->flag & HA_NULL_PART)) + (keyinfo->seg->flag & HA_NULL_PART) || + (keyinfo->seg->charset->mbminlen > 1)) keyinfo->bin_search=_mi_seq_search; else keyinfo->bin_search=_mi_prefix_search; diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index 3fccb91e9b5..7f305061b41 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -1102,6 +1102,12 @@ void ha_myisammrg::append_create_info(String *packet) packet->append(STRING_WITH_LEN(" INSERT_METHOD=")); packet->append(get_type(&merge_insert_method,file->merge_insert_method-1)); } + /* + There is no sence adding UNION clause in case there is no underlying + tables specified. + */ + if (file->open_tables == file->end_table) + return; packet->append(STRING_WITH_LEN(" UNION=(")); current_db= table->s->db.str; |