summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <msvensson@neptunus.(none)>2006-04-11 09:09:21 +0200
committerunknown <msvensson@neptunus.(none)>2006-04-11 09:09:21 +0200
commit3c3928089fb52e306c414858a2d0995b65eb6033 (patch)
tree4553c690909d2189f532471ef096f534f5f4941c /sql
parentc458f5ae93e556d7a3812bb412b17bc64cb8a80e (diff)
parente70d0971df3f8199da48764782ccd2c908d81f2b (diff)
downloadmariadb-git-3c3928089fb52e306c414858a2d0995b65eb6033.tar.gz
Merge bk-internal:/home/bk/mysql-5.0
into neptunus.(none):/home/msvensson/mysql/mysql-5.0 mysql-test/mysql-test-run.pl: Auto merged sql/ha_ndbcluster.cc: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/field.cc53
-rw-r--r--sql/field.h14
-rw-r--r--sql/ha_ndbcluster.cc2
-rw-r--r--sql/item.cc9
-rw-r--r--sql/item_cmpfunc.cc4
-rw-r--r--sql/item_timefunc.cc2
-rw-r--r--sql/key.cc3
-rw-r--r--sql/log.cc6
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/sql_cache.cc5
-rw-r--r--sql/sql_class.cc4
-rw-r--r--sql/sql_cursor.cc3
-rw-r--r--sql/sql_repl.cc6
13 files changed, 63 insertions, 50 deletions
diff --git a/sql/field.cc b/sql/field.cc
index 617d34e89a8..bdf84c588e1 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -7942,9 +7942,10 @@ Field_bit::Field_bit(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg,
enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg)
- : Field(ptr_arg, len_arg >> 3, null_ptr_arg, null_bit_arg,
+ : Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg),
- bit_ptr(bit_ptr_arg), bit_ofs(bit_ofs_arg), bit_len(len_arg & 7)
+ bit_ptr(bit_ptr_arg), bit_ofs(bit_ofs_arg), bit_len(len_arg & 7),
+ bytes_in_rec(len_arg / 8)
{
/*
Ensure that Field::eq() can distinguish between two different bit fields.
@@ -7980,14 +7981,14 @@ int Field_bit::store(const char *from, uint length, CHARSET_INFO *cs)
int delta;
for (; length && !*from; from++, length--); // skip left 0's
- delta= field_length - length;
+ delta= bytes_in_rec - length;
if (delta < -1 ||
(delta == -1 && (uchar) *from > ((1 << bit_len) - 1)) ||
(!bit_len && delta < 0))
{
set_rec_bits(0xff, bit_ptr, bit_ofs, bit_len);
- memset(ptr, 0xff, field_length);
+ memset(ptr, 0xff, bytes_in_rec);
if (table->in_use->really_abort_on_warning())
set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1);
else
@@ -8015,7 +8016,7 @@ int Field_bit::store(const char *from, uint length, CHARSET_INFO *cs)
set_rec_bits((uchar) *from, bit_ptr, bit_ofs, bit_len);
from++;
}
- memcpy(ptr, from, field_length);
+ memcpy(ptr, from, bytes_in_rec);
}
return 0;
}
@@ -8056,10 +8057,10 @@ longlong Field_bit::val_int(void)
if (bit_len)
{
bits= get_rec_bits(bit_ptr, bit_ofs, bit_len);
- bits<<= (field_length * 8);
+ bits<<= (bytes_in_rec * 8);
}
- switch (field_length) {
+ switch (bytes_in_rec) {
case 0: return bits;
case 1: return bits | (ulonglong) (uchar) ptr[0];
case 2: return bits | mi_uint2korr(ptr);
@@ -8068,7 +8069,7 @@ longlong Field_bit::val_int(void)
case 5: return bits | mi_uint5korr(ptr);
case 6: return bits | mi_uint6korr(ptr);
case 7: return bits | mi_uint7korr(ptr);
- default: return mi_uint8korr(ptr + field_length - sizeof(longlong));
+ default: return mi_uint8korr(ptr + bytes_in_rec - sizeof(longlong));
}
}
@@ -8121,7 +8122,7 @@ int Field_bit::cmp_offset(uint row_offset)
if ((flag= (int) (bits_a - bits_b)))
return flag;
}
- return memcmp(ptr, ptr + row_offset, field_length);
+ return memcmp(ptr, ptr + row_offset, bytes_in_rec);
}
@@ -8133,7 +8134,7 @@ void Field_bit::get_key_image(char *buff, uint length, imagetype type)
*buff++= bits;
length--;
}
- memcpy(buff, ptr, min(length, field_length));
+ memcpy(buff, ptr, min(length, bytes_in_rec));
}
@@ -8141,22 +8142,22 @@ void Field_bit::sql_type(String &res) const
{
CHARSET_INFO *cs= res.charset();
ulong length= cs->cset->snprintf(cs, (char*) res.ptr(), res.alloced_length(),
- "bit(%d)",
- (int) field_length * 8 + bit_len);
+ "bit(%d)", (int) field_length);
res.length((uint) length);
}
char *Field_bit::pack(char *to, const char *from, uint max_length)
{
- uint length= min(field_length + (bit_len > 0), max_length);
+ DBUG_ASSERT(max_length);
+ uint length;
if (bit_len)
{
uchar bits= get_rec_bits(bit_ptr, bit_ofs, bit_len);
*to++= bits;
- length--;
}
- memcpy(to, from, length);
+ length= min(bytes_in_rec, max_length - (bit_len > 0));
+ memcpy(to, from, length);
return to + length;
}
@@ -8168,8 +8169,8 @@ const char *Field_bit::unpack(char *to, const char *from)
set_rec_bits(*from, bit_ptr, bit_ofs, bit_len);
from++;
}
- memcpy(to, from, field_length);
- return from + field_length;
+ memcpy(to, from, bytes_in_rec);
+ return from + bytes_in_rec;
}
@@ -8183,26 +8184,25 @@ Field_bit_as_char::Field_bit_as_char(char *ptr_arg, uint32 len_arg,
const char *field_name_arg,
struct st_table *table_arg)
: Field_bit(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, 0,
- 0, unireg_check_arg, field_name_arg, table_arg),
- create_length(len_arg)
+ 0, unireg_check_arg, field_name_arg, table_arg)
{
bit_len= 0;
- field_length= ((len_arg + 7) & ~7) / 8;
+ bytes_in_rec= (len_arg + 7) / 8;
}
int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs)
{
int delta;
- uchar bits= create_length & 7;
+ uchar bits= field_length & 7;
for (; length && !*from; from++, length--); // skip left 0's
- delta= field_length - length;
+ delta= bytes_in_rec - length;
if (delta < 0 ||
(delta == 0 && bits && (uint) (uchar) *from >= (uint) (1 << bits)))
{
- memset(ptr, 0xff, field_length);
+ memset(ptr, 0xff, bytes_in_rec);
if (bits)
*ptr&= ((1 << bits) - 1); /* set first byte */
if (table->in_use->really_abort_on_warning())
@@ -8221,7 +8221,7 @@ void Field_bit_as_char::sql_type(String &res) const
{
CHARSET_INFO *cs= res.charset();
ulong length= cs->cset->snprintf(cs, (char*) res.ptr(), res.alloced_length(),
- "bit(%d)", (int) create_length);
+ "bit(%d)", (int) field_length);
res.length((uint) length);
}
@@ -8947,11 +8947,6 @@ create_field::create_field(Field *old_field,Field *orig_field)
geom_type= ((Field_geom*)old_field)->geom_type;
break;
#endif
- case FIELD_TYPE_BIT:
- length= (old_field->key_type() == HA_KEYTYPE_BIT) ?
- ((Field_bit *) old_field)->bit_len + length * 8 :
- ((Field_bit_as_char *) old_field)->create_length;
- break;
default:
break;
}
diff --git a/sql/field.h b/sql/field.h
index a4bdcc4da02..f4d27e46877 100644
--- a/sql/field.h
+++ b/sql/field.h
@@ -1312,17 +1312,18 @@ public:
uchar *bit_ptr; // position in record where 'uneven' bits store
uchar bit_ofs; // offset to 'uneven' high bits
uint bit_len; // number of 'uneven' high bits
+ uint bytes_in_rec;
Field_bit(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg,
enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg);
enum_field_types type() const { return FIELD_TYPE_BIT; }
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BIT; }
- uint32 key_length() const { return (uint32) field_length + (bit_len > 0); }
- uint32 max_length() { return (uint32) field_length * 8 + bit_len; }
+ uint32 key_length() const { return (uint32) (field_length + 7) / 8; }
+ uint32 max_length() { return field_length; }
uint size_of() const { return sizeof(*this); }
Item_result result_type () const { return INT_RESULT; }
- void reset(void) { bzero(ptr, field_length); }
+ void reset(void) { bzero(ptr, bytes_in_rec); }
int store(const char *to, uint length, CHARSET_INFO *charset);
int store(double nr);
int store(longlong nr, bool unsigned_val);
@@ -1344,9 +1345,8 @@ public:
{ Field_bit::store(buff, length, &my_charset_bin); }
void sort_string(char *buff, uint length)
{ get_key_image(buff, length, itRAW); }
- uint32 pack_length() const
- { return (uint32) field_length + (bit_len > 0); }
- uint32 pack_length_in_rec() const { return field_length; }
+ uint32 pack_length() const { return (uint32) (field_length + 7) / 8; }
+ uint32 pack_length_in_rec() const { return bytes_in_rec; }
void sql_type(String &str) const;
char *pack(char *to, const char *from, uint max_length=~(uint) 0);
const char *unpack(char* to, const char *from);
@@ -1363,13 +1363,11 @@ public:
class Field_bit_as_char: public Field_bit {
public:
- uchar create_length;
Field_bit_as_char(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg,
uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg);
enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; }
- uint32 max_length() { return (uint32) create_length; }
uint size_of() const { return sizeof(*this); }
int store(const char *to, uint length, CHARSET_INFO *charset);
int store(double nr) { return Field_bit::store(nr); }
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index 3dea2d82779..feb54272f4b 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -3959,7 +3959,7 @@ static int create_ndb_column(NDBCOL &col,
break;
case MYSQL_TYPE_BIT:
{
- int no_of_bits= field->field_length*8 + ((Field_bit *) field)->bit_len;
+ int no_of_bits= field->field_length;
col.setType(NDBCOL::Bit);
if (!no_of_bits)
col.setLength(1);
diff --git a/sql/item.cc b/sql/item.cc
index e1bde85e200..e3da950ceef 100644
--- a/sql/item.cc
+++ b/sql/item.cc
@@ -3054,6 +3054,7 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
int found_match_degree= 0;
Item_ident *cur_field;
int cur_match_degree= 0;
+ char name_buff[NAME_LEN+1];
if (find_item->type() == Item::FIELD_ITEM ||
find_item->type() == Item::REF_ITEM)
@@ -3065,6 +3066,14 @@ static Item** find_field_in_group_list(Item *find_item, ORDER *group_list)
else
return NULL;
+ if (db_name && lower_case_table_names)
+ {
+ /* Convert database to lower case for comparison */
+ strmake(name_buff, db_name, sizeof(name_buff)-1);
+ my_casedn_str(files_charset_info, name_buff);
+ db_name= name_buff;
+ }
+
DBUG_ASSERT(field_name != 0);
for (ORDER *cur_group= group_list ; cur_group ; cur_group= cur_group->next)
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 24075ac838d..6e1afd4ef09 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -55,8 +55,8 @@ static void agg_cmp_type(THD *thd, Item_result *type, Item **items, uint nitems)
bool all_constant= TRUE;
/* If the first argument is a FIELD_ITEM, pull out the field. */
- if (items[0]->type() == Item::FIELD_ITEM)
- field=((Item_field *)items[0])->field;
+ if (items[0]->real_item()->type() == Item::FIELD_ITEM)
+ field=((Item_field *)(items[0]->real_item()))->field;
/* But if it can't be compared as a longlong, we don't really care. */
if (field && !field->can_be_compared_as_longlong())
field= NULL;
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 63a7f1f130b..e139eba385e 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -2213,7 +2213,7 @@ longlong Item_extract::val_int()
switch (int_type) {
case INTERVAL_YEAR: return ltime.year;
case INTERVAL_YEAR_MONTH: return ltime.year*100L+ltime.month;
- case INTERVAL_QUARTER: return ltime.month/3 + 1;
+ case INTERVAL_QUARTER: return (ltime.month+2)/3;
case INTERVAL_MONTH: return ltime.month;
case INTERVAL_WEEK:
{
diff --git a/sql/key.cc b/sql/key.cc
index 9d86095f33e..75161e4f616 100644
--- a/sql/key.cc
+++ b/sql/key.cc
@@ -192,7 +192,8 @@ void key_restore(byte *to_record, byte *from_key, KEY *key_info,
Field_bit *field= (Field_bit *) (key_part->field);
if (field->bit_len)
{
- uchar bits= *(from_key + key_part->length - field->field_length -1);
+ uchar bits= *(from_key + key_part->length -
+ field->pack_length_in_rec() - 1);
set_rec_bits(bits, to_record + key_part->null_offset +
(key_part->null_bit == 128),
field->bit_ofs, field->bit_len);
diff --git a/sql/log.cc b/sql/log.cc
index 85e8c4dae2f..ba02c9ba082 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -1882,7 +1882,11 @@ DBUG_skip_commit:
rotate binlog, if necessary.
*/
if (commit_event->get_type_code() == XID_EVENT)
- thread_safe_increment(prepared_xids, &LOCK_prep_xids);
+ {
+ pthread_mutex_lock(&LOCK_prep_xids);
+ prepared_xids++;
+ pthread_mutex_unlock(&LOCK_prep_xids);
+ }
else
rotate_and_purge(RP_LOCK_LOG_IS_ALREADY_LOCKED);
}
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index e9ff220a6a1..9dd37bbebc9 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -5531,7 +5531,7 @@ log and this option does nothing anymore.",
"Sets the maximum number of threads allowed inside InnoDB. Value 0"
" will disable the thread throttling.",
(gptr*) &srv_thread_concurrency, (gptr*) &srv_thread_concurrency,
- 0, GET_LONG, REQUIRED_ARG, 0, 0, 1000, 0, 1, 0},
+ 0, GET_LONG, REQUIRED_ARG, 8, 0, 1000, 0, 1, 0},
{"innodb_thread_sleep_delay", OPT_INNODB_THREAD_SLEEP_DELAY,
"Time of innodb thread sleeping before joining InnoDB queue (usec). Value 0"
" disable a sleep",
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index cf3ba9c8c40..31201474c05 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -830,6 +830,11 @@ sql mode: 0x%lx, sort len: %lu, conncat len: %lu",
flags.sql_mode,
flags.max_sort_length,
flags.group_concat_max_len));
+ /*
+ Make InnoDB to release the adaptive hash index latch before
+ acquiring the query cache mutex.
+ */
+ ha_release_temporary_latches(thd);
STRUCT_LOCK(&structure_guard_mutex);
if (query_cache_size == 0)
diff --git a/sql/sql_class.cc b/sql/sql_class.cc
index 59391a333c3..5a6bbe01183 100644
--- a/sql/sql_class.cc
+++ b/sql/sql_class.cc
@@ -919,14 +919,12 @@ bool select_send::send_data(List<Item> &items)
return 0;
}
-#ifdef HAVE_INNOBASE_DB
/*
We may be passing the control from mysqld to the client: release the
InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
by thd
*/
ha_release_temporary_latches(thd);
-#endif
List_iterator_fast<Item> li(items);
Protocol *protocol= thd->protocol;
@@ -956,12 +954,10 @@ bool select_send::send_data(List<Item> &items)
bool select_send::send_eof()
{
-#ifdef HAVE_INNOBASE_DB
/* We may be passing the control from mysqld to the client: release the
InnoDB adaptive hash S-latch to avoid thread deadlocks if it was reserved
by thd */
ha_release_temporary_latches(thd);
-#endif
/* Unlock tables before sending packet to gain some speed */
if (thd->lock)
diff --git a/sql/sql_cursor.cc b/sql/sql_cursor.cc
index 33ad27b9d14..2784e71ccae 100644
--- a/sql/sql_cursor.cc
+++ b/sql/sql_cursor.cc
@@ -445,9 +445,8 @@ Sensitive_cursor::fetch(ulong num_rows)
if (error == NESTED_LOOP_CURSOR_LIMIT)
join->resume_nested_loop= TRUE;
-#ifdef USING_TRANSACTIONS
ha_release_temporary_latches(thd);
-#endif
+
/* Grab free_list here to correctly free it in close */
thd->restore_active_arena(this, &backup_arena);
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 07678d97800..85d93767486 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -466,6 +466,12 @@ impossible position";
(rli->group_master_log_pos)
*/
int4store((char*) packet->ptr()+LOG_POS_OFFSET+1, 0);
+ /*
+ if reconnect master sends FD event with `created' as 0
+ to avoid destroying temp tables.
+ */
+ int4store((char*) packet->ptr()+LOG_EVENT_MINIMAL_HEADER_LEN+
+ ST_CREATED_OFFSET+1, (ulong) 0);
/* send it */
if (my_net_write(net, (char*)packet->ptr(), packet->length()))
{