Commit 9a1d80e9 authored by unknown's avatar unknown

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

into  shellback.(none):/home/msvensson/mysql/mysql-5.0

parents 0e97b724 a0f7e755
...@@ -1386,35 +1386,6 @@ mysql_get_server_info(MYSQL *mysql) ...@@ -1386,35 +1386,6 @@ mysql_get_server_info(MYSQL *mysql)
} }
/*
Get version number for server in a form easy to test on
SYNOPSIS
mysql_get_server_version()
mysql Connection
EXAMPLE
4.1.0-alfa -> 40100
NOTES
We will ensure that a newer server always has a bigger number.
RETURN
Signed number > 323000
*/
ulong STDCALL
mysql_get_server_version(MYSQL *mysql)
{
uint major, minor, version;
char *pos= mysql->server_version, *end_pos;
major= (uint) strtoul(pos, &end_pos, 10); pos=end_pos+1;
minor= (uint) strtoul(pos, &end_pos, 10); pos=end_pos+1;
version= (uint) strtoul(pos, &end_pos, 10);
return (ulong) major*10000L+(ulong) (minor*100+version);
}
const char * STDCALL const char * STDCALL
mysql_get_host_info(MYSQL *mysql) mysql_get_host_info(MYSQL *mysql)
{ {
......
...@@ -369,3 +369,25 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp ...@@ -369,3 +369,25 @@ ERROR 42000: You have an error in your SQL syntax; check the manual that corresp
SELECT 'a' as str; SELECT 'a' as str;
str str
a a
set @str= _latin1 'ABC ߲~ @ abc';
SELECT convert(@str collate latin1_bin using utf8);
convert(@str collate latin1_bin using utf8)
ABC ߲~ @ abc
SELECT convert(@str collate latin1_general_ci using utf8);
convert(@str collate latin1_general_ci using utf8)
ABC ߲~ @ abc
SELECT convert(@str collate latin1_german1_ci using utf8);
convert(@str collate latin1_german1_ci using utf8)
ABC ߲~ @ abc
SELECT convert(@str collate latin1_danish_ci using utf8);
convert(@str collate latin1_danish_ci using utf8)
ABC ߲~ @ abc
SELECT convert(@str collate latin1_spanish_ci using utf8);
convert(@str collate latin1_spanish_ci using utf8)
ABC ߲~ @ abc
SELECT convert(@str collate latin1_german2_ci using utf8);
convert(@str collate latin1_german2_ci using utf8)
ABC ߲~ @ abc
SELECT convert(@str collate latin1_swedish_ci using utf8);
convert(@str collate latin1_swedish_ci using utf8)
ABC ߲~ @ abc
...@@ -2562,3 +2562,20 @@ my_sqrt ...@@ -2562,3 +2562,20 @@ my_sqrt
1.4142135623731 1.4142135623731
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
CREATE TABLE t1 (id int PRIMARY KEY);
CREATE TABLE t2 (id int PRIMARY KEY);
INSERT INTO t1 VALUES (1), (3);
INSERT INTO t2 VALUES (1), (2), (3);
CREATE VIEW v2 AS SELECT * FROM t2;
SELECT COUNT(*) FROM t1 LEFT JOIN t2 ON t1.id=t2.id;
COUNT(*)
2
SELECT * FROM t1 LEFT JOIN t2 ON t1.id=t2.id;
id id
1 1
3 3
SELECT COUNT(*) FROM t1 LEFT JOIN v2 ON t1.id=v2.id;
COUNT(*)
2
DROP VIEW v2;
DROP TABLE t1, t2;
...@@ -95,4 +95,18 @@ SET collation_connection='latin1_bin'; ...@@ -95,4 +95,18 @@ SET collation_connection='latin1_bin';
CREATE TABLE a (a int); CREATE TABLE a (a int);
SELECT 'a' as str; SELECT 'a' as str;
#
# Bug#18321: Can't store EuroSign with latin1_german1_ci and latin1_general_ci
# The problem was in latin1->utf8->latin1 round trip.
#
set @str= _latin1 'ABC ߲~ @ abc';
SELECT convert(@str collate latin1_bin using utf8);
SELECT convert(@str collate latin1_general_ci using utf8);
SELECT convert(@str collate latin1_german1_ci using utf8);
SELECT convert(@str collate latin1_danish_ci using utf8);
SELECT convert(@str collate latin1_spanish_ci using utf8);
SELECT convert(@str collate latin1_german2_ci using utf8);
SELECT convert(@str collate latin1_swedish_ci using utf8);
# End of 4.1 tests # End of 4.1 tests
...@@ -2413,3 +2413,24 @@ SELECT my_sqrt FROM v1 ORDER BY my_sqrt; ...@@ -2413,3 +2413,24 @@ SELECT my_sqrt FROM v1 ORDER BY my_sqrt;
DROP VIEW v1; DROP VIEW v1;
DROP TABLE t1; DROP TABLE t1;
#
# Bug #18237: invalid count optimization applied to an outer join with a view
#
CREATE TABLE t1 (id int PRIMARY KEY);
CREATE TABLE t2 (id int PRIMARY KEY);
INSERT INTO t1 VALUES (1), (3);
INSERT INTO t2 VALUES (1), (2), (3);
CREATE VIEW v2 AS SELECT * FROM t2;
SELECT COUNT(*) FROM t1 LEFT JOIN t2 ON t1.id=t2.id;
SELECT * FROM t1 LEFT JOIN t2 ON t1.id=t2.id;
SELECT COUNT(*) FROM t1 LEFT JOIN v2 ON t1.id=v2.id;
DROP VIEW v2;
DROP TABLE t1, t2;
...@@ -2817,6 +2817,36 @@ const char * STDCALL mysql_error(MYSQL *mysql) ...@@ -2817,6 +2817,36 @@ const char * STDCALL mysql_error(MYSQL *mysql)
return mysql->net.last_error; return mysql->net.last_error;
} }
/*
Get version number for server in a form easy to test on
SYNOPSIS
mysql_get_server_version()
mysql Connection
EXAMPLE
4.1.0-alfa -> 40100
NOTES
We will ensure that a newer server always has a bigger number.
RETURN
Signed number > 323000
*/
ulong STDCALL
mysql_get_server_version(MYSQL *mysql)
{
uint major, minor, version;
char *pos= mysql->server_version, *end_pos;
major= (uint) strtoul(pos, &end_pos, 10); pos=end_pos+1;
minor= (uint) strtoul(pos, &end_pos, 10); pos=end_pos+1;
version= (uint) strtoul(pos, &end_pos, 10);
return (ulong) major*10000L+(ulong) (minor*100+version);
}
/* /*
mysql_set_character_set function sends SET NAMES cs_name to mysql_set_character_set function sends SET NAMES cs_name to
the server (which changes character_set_client, character_set_result the server (which changes character_set_client, character_set_result
...@@ -2836,6 +2866,9 @@ int STDCALL mysql_set_character_set(MYSQL *mysql, const char *cs_name) ...@@ -2836,6 +2866,9 @@ int STDCALL mysql_set_character_set(MYSQL *mysql, const char *cs_name)
{ {
char buff[MY_CS_NAME_SIZE + 10]; char buff[MY_CS_NAME_SIZE + 10];
charsets_dir= save_csdir; charsets_dir= save_csdir;
/* Skip execution of "SET NAMES" for pre-4.1 servers */
if (mysql_get_server_version(mysql) < 40100)
return 0;
sprintf(buff, "SET NAMES %s", cs_name); sprintf(buff, "SET NAMES %s", cs_name);
if (!mysql_real_query(mysql, buff, strlen(buff))) if (!mysql_real_query(mysql, buff, strlen(buff)))
{ {
......
...@@ -986,20 +986,23 @@ public: ...@@ -986,20 +986,23 @@ public:
class Field_string :public Field_longstr { class Field_string :public Field_longstr {
public: public:
bool can_alter_field_type;
Field_string(char *ptr_arg, uint32 len_arg,uchar *null_ptr_arg, Field_string(char *ptr_arg, uint32 len_arg,uchar *null_ptr_arg,
uchar null_bit_arg, uchar null_bit_arg,
enum utype unireg_check_arg, const char *field_name_arg, enum utype unireg_check_arg, const char *field_name_arg,
struct st_table *table_arg, CHARSET_INFO *cs) struct st_table *table_arg, CHARSET_INFO *cs)
:Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, :Field_longstr(ptr_arg, len_arg, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg, cs) {}; unireg_check_arg, field_name_arg, table_arg, cs),
can_alter_field_type(1) {};
Field_string(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, Field_string(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg,
struct st_table *table_arg, CHARSET_INFO *cs) struct st_table *table_arg, CHARSET_INFO *cs)
:Field_longstr((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0, :Field_longstr((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0,
NONE, field_name_arg, table_arg, cs) {}; NONE, field_name_arg, table_arg, cs),
can_alter_field_type(1) {};
enum_field_types type() const enum_field_types type() const
{ {
return ((orig_table && return ((can_alter_field_type && orig_table &&
orig_table->s->db_create_options & HA_OPTION_PACK_RECORD && orig_table->s->db_create_options & HA_OPTION_PACK_RECORD &&
field_length >= 4) && field_length >= 4) &&
orig_table->s->frm_version < FRM_VER_TRUE_VARCHAR ? orig_table->s->frm_version < FRM_VER_TRUE_VARCHAR ?
......
...@@ -96,8 +96,14 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) ...@@ -96,8 +96,14 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds)
*/ */
for (TABLE_LIST *tl= tables; tl; tl= tl->next_leaf) for (TABLE_LIST *tl= tables; tl; tl= tl->next_leaf)
{ {
TABLE_LIST *embedded;
for (embedded= tl ; embedded; embedded= embedded->embedding)
{
if (embedded->on_expr)
break;
}
if (embedded)
/* Don't replace expression on a table that is part of an outer join */ /* Don't replace expression on a table that is part of an outer join */
if (tl->on_expr)
{ {
outer_tables|= tl->table->map; outer_tables|= tl->table->map;
......
...@@ -1093,6 +1093,11 @@ multi_update::initialize_tables(JOIN *join) ...@@ -1093,6 +1093,11 @@ multi_update::initialize_tables(JOIN *join)
/* ok to be on stack as this is not referenced outside of this func */ /* ok to be on stack as this is not referenced outside of this func */
Field_string offset(table->file->ref_length, 0, "offset", Field_string offset(table->file->ref_length, 0, "offset",
table, &my_charset_bin); table, &my_charset_bin);
/*
The field will be converted to varstring when creating tmp table if
table to be updated was created by mysql 4.1. Deny this.
*/
offset.can_alter_field_type= 0;
if (!(ifield= new Item_field(((Field *) &offset)))) if (!(ifield= new Item_field(((Field *) &offset))))
DBUG_RETURN(1); DBUG_RETURN(1);
ifield->maybe_null= 0; ifield->maybe_null= 0;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#define ROW_LEN 16 #define ROW_LEN 16
#define ROW16_LEN 8 #define ROW16_LEN 8
#define MAX_BUF 16*1024 #define MAX_BUF 64*1024
static CHARSET_INFO all_charsets[256]; static CHARSET_INFO all_charsets[256];
...@@ -156,6 +156,7 @@ static int my_read_charset_file(const char *filename) ...@@ -156,6 +156,7 @@ static int my_read_charset_file(const char *filename)
} }
len=read(fd,buf,MAX_BUF); len=read(fd,buf,MAX_BUF);
DBUG_ASSERT(len < MAX_BUF);
close(fd); close(fd);
if (my_parse_charset_xml(buf,len,add_collation)) if (my_parse_charset_xml(buf,len,add_collation))
......
This diff is collapsed.
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