Commit a12b0b28 authored by unknown's avatar unknown

Merge abarkov@bk-internal.mysql.com:/home/bk/mysql-5.0

into mysql.com:/home/bar/mysql-5.0

parents 52740354 e7eac027
......@@ -71,6 +71,7 @@ hf@deer.(none)
hf@deer.mysql.r18.ru
hf@genie.(none)
igor@hundin.mysql.fi
igor@linux.local
igor@rurik.mysql.com
ingo@mysql.com
jan@hundin.mysql.fi
......
......@@ -262,6 +262,20 @@ trx_free(
putc('\n', stderr);
}
if (trx->n_mysql_tables_in_use != 0
|| trx->mysql_n_tables_locked != 0) {
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Error: MySQL is freeing a thd\n"
"InnoDB: though trx->n_mysql_tables_in_use is %lu\n"
"InnoDB: and trx->mysql_n_tables_locked is %lu.\n",
(ulong)trx->n_mysql_tables_in_use,
(ulong)trx->mysql_n_tables_locked);
trx_print(stderr, trx);
}
ut_a(trx->magic_n == TRX_MAGIC_N);
trx->magic_n = 11112222;
......@@ -272,9 +286,6 @@ trx_free(
ut_a(trx->insert_undo == NULL);
ut_a(trx->update_undo == NULL);
ut_a(trx->n_mysql_tables_in_use == 0);
ut_a(trx->mysql_n_tables_locked == 0);
if (trx->undo_no_arr) {
trx_undo_arr_free(trx->undo_no_arr);
......
......@@ -14,6 +14,7 @@ Created 5/11/1994 Heikki Tuuri
#include "mem0mem.h"
#include "os0sync.h"
#include "os0thread.h"
/* This struct is placed first in every allocated memory block */
typedef struct ut_mem_block_struct ut_mem_block_t;
......@@ -66,6 +67,7 @@ ut_malloc_low(
ibool assert_on_error) /* in: if TRUE, we crash mysqld if the memory
cannot be allocated */
{
ulint retry_count = 0;
void* ret;
ut_ad((sizeof(ut_mem_block_t) % 8) == 0); /* check alignment ok */
......@@ -73,24 +75,26 @@ ut_malloc_low(
if (!ut_mem_block_list_inited) {
ut_mem_block_list_init();
}
retry:
os_fast_mutex_lock(&ut_list_mutex);
ret = malloc(n + sizeof(ut_mem_block_t));
if (ret == NULL) {
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Fatal error: cannot allocate %lu bytes of\n"
if (ret == NULL && retry_count < 60) {
if (retry_count == 0) {
ut_print_timestamp(stderr);
fprintf(stderr,
" InnoDB: Error: cannot allocate %lu bytes of\n"
"InnoDB: memory with malloc! Total allocated memory\n"
"InnoDB: by InnoDB %lu bytes. 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"
"InnoDB: On FreeBSD check you have compiled the OS with\n"
"InnoDB: a big enough maximum process size.\n"
"InnoDB: Note that in most 32-bit computers the process\n"
"InnoDB: memory space is limited to 2 GB or 4 GB.\n",
"InnoDB: We keep retrying the allocation for 60 seconds...\n",
(ulong) n, (ulong) ut_total_allocated_memory,
#ifdef __WIN__
(ulong) GetLastError()
......@@ -98,7 +102,21 @@ ut_malloc_low(
(ulong) errno
#endif
);
}
os_fast_mutex_unlock(&ut_list_mutex);
/* Sleep for a second and retry the allocation; maybe this is
just a temporary shortage of memory */
os_thread_sleep(1000000);
retry_count++;
goto retry;
}
if (ret == NULL) {
/* Flush stderr to make more probable that the error
message gets in the error file before we generate a seg
fault */
......@@ -113,8 +131,10 @@ ut_malloc_low(
by graceful exit handling in ut_a(). */
#if (!defined __NETWARE__)
if (assert_on_error) {
ut_print_timestamp(stderr);
fprintf(stderr,
"InnoDB: We now intentionally generate a seg fault so that\n"
" InnoDB: We now intentionally generate a seg fault so that\n"
"InnoDB: on Linux we get a stack trace.\n");
if (*ut_mem_null_ptr) ut_mem_null_ptr = 0;
......
......@@ -514,7 +514,7 @@ Variable_name Value
character_set_client latin1
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 3 1
latin1 latin1_swedish_ci 4 1
explain extended SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE NULL NULL NULL NULL NULL NULL NULL No tables used
......@@ -525,7 +525,7 @@ SHOW VARIABLES LIKE 'collation_client';
Variable_name Value
SELECT charset('a'),collation('a'),coercibility('a'),'a'='A';
charset('a') collation('a') coercibility('a') 'a'='A'
latin1 latin1_swedish_ci 3 1
latin1 latin1_swedish_ci 4 1
SET CHARACTER SET 'DEFAULT';
ERROR 42000: Unknown character set: 'DEFAULT'
DROP TABLE t1;
......
......@@ -831,4 +831,29 @@ select id, stddev_pop(value1), var_pop(value1), stddev_samp(value1), var_samp(va
id stddev_pop(value1) var_pop(value1) stddev_samp(value1) var_samp(value1)
1 0.816497 0.666667 1.000000 1.000000
2 1.118034 1.250000 1.290994 1.666667
CREATE TABLE t1(
id int PRIMARY KEY,
a int,
b int,
INDEX i_b_id(a,b,id),
INDEX i_id(a,id)
);
INSERT INTO t1 VALUES
(1,1,4), (2,2,1), (3,1,3), (4,2,1), (5,1,1);
SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6;
MAX(id)
NULL
DROP TABLE t1;
CREATE TABLE t1(
id int PRIMARY KEY,
a int,
b int,
INDEX i_id(a,id),
INDEX i_b_id(a,b,id)
);
INSERT INTO t1 VALUES
(1,1,4), (2,2,1), (3,1,3), (4,2,1), (5,1,1);
SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6;
MAX(id)
NULL
DROP TABLE t1;
This diff is collapsed.
......@@ -68,3 +68,11 @@ drop table t1;
select TRUE,FALSE,NULL;
TRUE FALSE NULL
1 0 NULL
create table t1 (a char(10)) character set latin1;
select * from t1 where a=version();
a
select * from t1 where a=database();
a
select * from t1 where a=user();
a
drop table t1;
......@@ -509,7 +509,7 @@ charset(load_file('../../std_data/words.dat')),
collation(load_file('../../std_data/words.dat')),
coercibility(load_file('../../std_data/words.dat'));
charset(load_file('../../std_data/words.dat')) collation(load_file('../../std_data/words.dat')) coercibility(load_file('../../std_data/words.dat'))
binary binary 3
binary binary 4
explain extended select
charset(load_file('../../std_data/words.dat')),
collation(load_file('../../std_data/words.dat')),
......
......@@ -536,4 +536,32 @@ drop table t1, t2, t3;
CREATE TABLE t1 (id int(11),value1 float(10,2));
INSERT INTO t1 VALUES (1,0.00),(1,1.00), (1,2.00), (2,10.00), (2,11.00), (2,12.00), (2,13.00);
select id, stddev_pop(value1), var_pop(value1), stddev_samp(value1), var_samp(value1) from t1 group by id;
#
# Bug 8893: wrong result for min/max optimization with 2 indexes
#
CREATE TABLE t1(
id int PRIMARY KEY,
a int,
b int,
INDEX i_b_id(a,b,id),
INDEX i_id(a,id)
);
INSERT INTO t1 VALUES
(1,1,4), (2,2,1), (3,1,3), (4,2,1), (5,1,1);
SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6;
DROP TABLE t1;
# change the order of the last two index definitions
CREATE TABLE t1(
id int PRIMARY KEY,
a int,
b int,
INDEX i_id(a,id),
INDEX i_b_id(a,b,id)
);
INSERT INTO t1 VALUES
(1,1,4), (2,2,1), (3,1,3), (4,2,1), (5,1,1);
SELECT MAX(id) FROM t1 WHERE id < 3 AND a=2 AND b=6;
DROP TABLE t1;
......@@ -30,3 +30,12 @@ show create table t1;
drop table t1;
select TRUE,FALSE,NULL;
#
# Bug#8291 Illegal collation mix with USER() function
#
create table t1 (a char(10)) character set latin1;
select * from t1 where a=version();
select * from t1 where a=database();
select * from t1 where a=user();
drop table t1;
......@@ -2632,6 +2632,7 @@ ha_innobase::write_row(
table->timestamp_field->set_time();
if ((user_thd->lex->sql_command == SQLCOM_ALTER_TABLE
|| user_thd->lex->sql_command == SQLCOM_OPTIMIZE
|| user_thd->lex->sql_command == SQLCOM_CREATE_INDEX
|| user_thd->lex->sql_command == SQLCOM_DROP_INDEX)
&& num_write_row >= 10000) {
......
......@@ -724,7 +724,6 @@ void Item::split_sum_func2(THD *thd, Item **ref_pointer_array,
*/
bool DTCollation::aggregate(DTCollation &dt, uint flags)
{
nagg++;
if (!my_charset_same(collation, dt.collation))
{
/*
......@@ -740,7 +739,6 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags)
else
{
set(dt);
strong= nagg;
}
}
else if (dt.collation == &my_charset_bin)
......@@ -748,7 +746,6 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags)
if (dt.derivation <= derivation)
{
set(dt);
strong= nagg;
}
else
; // Do nothing
......@@ -764,20 +761,18 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags)
dt.collation->state & MY_CS_UNICODE)
{
set(dt);
strong= nagg;
}
else if ((flags & MY_COLL_ALLOW_COERCIBLE_CONV) &&
derivation < dt.derivation &&
dt.derivation >= DERIVATION_COERCIBLE)
dt.derivation >= DERIVATION_SYSCONST)
{
// Do nothing;
}
else if ((flags & MY_COLL_ALLOW_COERCIBLE_CONV) &&
dt.derivation < derivation &&
derivation >= DERIVATION_COERCIBLE)
derivation >= DERIVATION_SYSCONST)
{
set(dt);
strong= nagg;
}
else
{
......@@ -793,7 +788,6 @@ bool DTCollation::aggregate(DTCollation &dt, uint flags)
else if (dt.derivation < derivation)
{
set(dt);
strong= nagg;
}
else
{
......
......@@ -32,8 +32,9 @@ class Item_field;
enum Derivation
{
DERIVATION_IGNORABLE= 4,
DERIVATION_COERCIBLE= 3,
DERIVATION_IGNORABLE= 5,
DERIVATION_COERCIBLE= 4,
DERIVATION_SYSCONST= 3,
DERIVATION_IMPLICIT= 2,
DERIVATION_NONE= 1,
DERIVATION_EXPLICIT= 0
......@@ -62,22 +63,16 @@ class DTCollation {
public:
CHARSET_INFO *collation;
enum Derivation derivation;
uint nagg; // Total number of aggregated collations.
uint strong; // Number of the strongest collation.
DTCollation()
{
collation= &my_charset_bin;
derivation= DERIVATION_NONE;
nagg= 0;
strong= 0;
}
DTCollation(CHARSET_INFO *collation_arg, Derivation derivation_arg)
{
collation= collation_arg;
derivation= derivation_arg;
nagg= 0;
strong= 0;
}
void set(DTCollation &dt)
{
......@@ -103,6 +98,7 @@ public:
case DERIVATION_IGNORABLE: return "IGNORABLE";
case DERIVATION_COERCIBLE: return "COERCIBLE";
case DERIVATION_IMPLICIT: return "IMPLICIT";
case DERIVATION_SYSCONST: return "SYSCONST";
case DERIVATION_EXPLICIT: return "EXPLICIT";
case DERIVATION_NONE: return "NONE";
default: return "UNKNOWN";
......
......@@ -434,7 +434,7 @@ Item *create_func_version(void)
{
return new Item_static_string_func("version()", server_version,
(uint) strlen(server_version),
system_charset_info, DERIVATION_IMPLICIT);
system_charset_info, DERIVATION_SYSCONST);
}
Item *create_func_weekday(Item* a)
......
......@@ -82,8 +82,6 @@ bool Item_func::agg_arg_collations(DTCollation &c, Item **av, uint count,
uint flags)
{
uint i;
c.nagg= 0;
c.strong= 0;
c.set(av[0]->collation);
for (i= 1; i < count; i++)
{
......
......@@ -1515,6 +1515,23 @@ String *Item_func_decode::val_str(String *str)
}
Item *Item_func_sysconst::safe_charset_converter(CHARSET_INFO *tocs)
{
Item_string *conv;
uint conv_errors;
String tmp, cstr, *ostr= val_str(&tmp);
cstr.copy(ostr->ptr(), ostr->length(), ostr->charset(), tocs, &conv_errors);
if (conv_errors || !(conv= new Item_string(cstr.ptr(), cstr.length(),
cstr.charset(),
collation.derivation)))
{
return NULL;
}
conv->str_value.copy();
return conv;
}
String *Item_func_database::val_str(String *str)
{
DBUG_ASSERT(fixed == 1);
......
......@@ -337,10 +337,18 @@ public:
};
class Item_func_database :public Item_str_func
class Item_func_sysconst :public Item_str_func
{
public:
Item_func_database() { collation.set(system_charset_info,DERIVATION_IMPLICIT); }
Item_func_sysconst()
{ collation.set(system_charset_info,DERIVATION_SYSCONST); }
Item *safe_charset_converter(CHARSET_INFO *tocs);
};
class Item_func_database :public Item_func_sysconst
{
public:
Item_func_database() :Item_func_sysconst() {}
String *val_str(String *);
void fix_length_and_dec()
{
......@@ -350,10 +358,10 @@ public:
const char *func_name() const { return "database"; }
};
class Item_func_user :public Item_str_func
class Item_func_user :public Item_func_sysconst
{
public:
Item_func_user() { collation.set(system_charset_info, DERIVATION_IMPLICIT); }
Item_func_user() :Item_func_sysconst() {}
String *val_str(String *);
void fix_length_and_dec()
{
......
......@@ -638,7 +638,6 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
{
if (!(field->flags & PART_KEY_FLAG))
return 0; // Not key field
*prefix_len= 0;
TABLE *table= field->table;
uint idx= 0;
......@@ -651,6 +650,7 @@ static bool find_key_for_maxmin(bool max_fl, TABLE_REF *ref,
KEY_PART_INFO *part,*part_end;
key_part_map key_part_to_use= 0;
uint jdx= 0;
*prefix_len= 0;
for (part= keyinfo->key_part, part_end= part+keyinfo->key_parts ;
part != part_end ;
part++, jdx++, key_part_to_use= (key_part_to_use << 1) | 1)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment