Commit a0cac19e authored by joerg@mysql.com's avatar joerg@mysql.com

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

into mysql.com:/M50/mysql-5.0
parents 15231190 5624641c
......@@ -44,7 +44,7 @@
#include <locale.h>
#endif
const char *VER= "14.9";
const char *VER= "14.10";
/* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024
......@@ -235,7 +235,7 @@ static COMMANDS commands[] = {
{ "connect",'r', com_connect,1,
"Reconnect to the server. Optional arguments are db and host." },
{ "delimiter", 'd', com_delimiter, 1,
"Set query delimiter. " },
"Set statement delimiter. NOTE: Takes the rest of the line as new delimiter." },
#ifdef USE_POPEN
{ "edit", 'e', com_edit, 0, "Edit command with $EDITOR."},
#endif
......
......@@ -255,6 +255,9 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key)
if (*pos) /* Found null */
{
nr^= (nr << 1) | 1;
/* Add key pack length (2) to key for VARCHAR segments */
if (seg->type == HA_KEYTYPE_VARTEXT1)
key+= 2;
continue;
}
pos++;
......@@ -390,6 +393,9 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key)
if (*pos)
{
nr^= (nr << 1) | 1;
/* Add key pack length (2) to key for VARCHAR segments */
if (seg->type == HA_KEYTYPE_VARTEXT1)
key+= 2;
continue;
}
pos++;
......@@ -584,7 +590,12 @@ int hp_key_cmp(HP_KEYDEF *keydef, const byte *rec, const byte *key)
if (found_null != (int) *key++)
return 1;
if (found_null)
{
/* Add key pack length (2) to key for VARCHAR segments */
if (seg->type == HA_KEYTYPE_VARTEXT1)
key+= 2;
continue;
}
}
if (seg->type == HA_KEYTYPE_TEXT)
{
......
......@@ -242,7 +242,10 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old,
{
k_length-=length;
if (keyseg->flag & (HA_VAR_LENGTH_PART | HA_BLOB_PART))
{
k_length-=2; /* Skip length */
old+= 2;
}
continue; /* Found NULL */
}
}
......
......@@ -226,3 +226,13 @@ create table t1 (v varchar(65530), key(v(10)));
insert into t1 values(repeat('a',65530));
select length(v) from t1 where v=repeat('a',65530);
drop table t1;
#
# Bug #9489: problem with hash indexes
#
create table t1(a int, b varchar(12), key ba(b, a));
insert into t1 values (1, 'A'), (20, NULL);
explain select * from t1 where a=20 and b is null;
select * from t1 where a=20 and b is null;
drop table t1;
......@@ -1858,6 +1858,15 @@ select length(v) from t1 where v=repeat('a',65530);
length(v)
65530
drop table t1;
create table t1(a int, b varchar(12), key ba(b, a));
insert into t1 values (1, 'A'), (20, NULL);
explain select * from t1 where a=20 and b is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref ba ba 20 const,const 1 Using where
select * from t1 where a=20 and b is null;
a b
20 NULL
drop table t1;
create table t1 (v varchar(65530), key(v));
Warnings:
Warning 1071 Specified key was too long; max key length is 255 bytes
......
......@@ -83,4 +83,43 @@ Full-text indexes are called collections
Only MyISAM tables support collections
select * from t1 where MATCH(a,b) AGAINST ("only");
a b
drop table if exists t1,t2;
reset master;
drop table t1,t2;
create table t1 (a int) engine=blackhole;
delete from t1 where a=10;
update t1 set a=11 where a=15;
insert into t1 values(1);
insert ignore into t1 values(1);
replace into t1 values(100);
create table t2 (a varchar(200)) engine=blackhole;
load data infile '../../std_data/words.dat' into table t2;
alter table t1 add b int;
alter table t1 drop b;
create table t3 like t1;
insert into t1 select * from t3;
replace into t1 select * from t3;
select * from t1;
a
select * from t2;
a
select * from t3;
a
show binlog events;
Log_name Pos Event_type Server_id Orig_log_pos Info
master-bin.000001 # Start 1 # Server ver: VERSION, Binlog ver: 3
master-bin.000001 # Query 1 # use `test`; drop table t1,t2
master-bin.000001 # Query 1 # use `test`; create table t1 (a int) engine=blackhole
master-bin.000001 # Query 1 # use `test`; delete from t1 where a=10
master-bin.000001 # Query 1 # use `test`; update t1 set a=11 where a=15
master-bin.000001 # Query 1 # use `test`; insert into t1 values(1)
master-bin.000001 # Query 1 # use `test`; insert ignore into t1 values(1)
master-bin.000001 # Query 1 # use `test`; replace into t1 values(100)
master-bin.000001 # Query 1 # use `test`; create table t2 (a varchar(200)) engine=blackhole
master-bin.000001 # Create_file 1 # db=test;table=t2;file_id=1;block_len=581
master-bin.000001 # Exec_load 1 # ;file_id=1
master-bin.000001 # Query 1 # use `test`; alter table t1 add b int
master-bin.000001 # Query 1 # use `test`; alter table t1 drop b
master-bin.000001 # Query 1 # use `test`; create table t3 like t1
master-bin.000001 # Query 1 # use `test`; insert into t1 select * from t3
master-bin.000001 # Query 1 # use `test`; replace into t1 select * from t3
drop table t1,t2,t3;
......@@ -2359,6 +2359,15 @@ select length(v) from t1 where v=repeat('a',65530);
length(v)
65530
drop table t1;
create table t1(a int, b varchar(12), key ba(b, a));
insert into t1 values (1, 'A'), (20, NULL);
explain select * from t1 where a=20 and b is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref ba ba 20 const,const 1 Using where; Using index
select * from t1 where a=20 and b is null;
a b
20 NULL
drop table t1;
create table t1 (v varchar(65530), key(v));
ERROR HY000: Can't create table './test/t1' (errno: 139)
create table t1 (v varchar(65536));
......
......@@ -1157,6 +1157,15 @@ select length(v) from t1 where v=repeat('a',65530);
length(v)
65530
drop table t1;
create table t1(a int, b varchar(12), key ba(b, a));
insert into t1 values (1, 'A'), (20, NULL);
explain select * from t1 where a=20 and b is null;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ref ba ba 20 const,const 1 Using where; Using index
select * from t1 where a=20 and b is null;
a b
20 NULL
drop table t1;
create table t1 (v varchar(65530), key(v));
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
......
......@@ -599,3 +599,35 @@ UNLOCK TABLES;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
DROP TABLE t1;
CREATE TABLE t1 (a char(10));
INSERT INTO t1 VALUES ('\'');
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
DROP TABLE IF EXISTS `t1`;
CREATE TABLE `t1` (
`a` char(10) default NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
/*!40000 ALTER TABLE `t1` DISABLE KEYS */;
LOCK TABLES `t1` WRITE;
INSERT INTO `t1` VALUES ('\'');
UNLOCK TABLES;
/*!40000 ALTER TABLE `t1` ENABLE KEYS */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
DROP TABLE t1;
drop table if exists t1;
drop table if exists t1, t2;
create table t1 (v varchar(30), c char(3), e enum('abc','def','ghi'), t text);
truncate table vchar;
show create table t1;
......@@ -383,3 +383,12 @@ select * from t1;
pkcol othercol
test somethingelse
drop table t1;
create table t1 (a int, b varchar(12));
insert into t1 values (1, 'A'), (22, NULL);
create table t2 (a int);
insert into t2 values (22), (22);
select t1.a, t1.b, min(t1.b) from t1 inner join t2 ON t2.a = t1.a
group by t1.b, t1.a;
a b min(t1.b)
22 NULL NULL
drop table t1, t2;
......@@ -96,4 +96,32 @@ select * from t1 where MATCH(a,b) AGAINST ("indexes");
select * from t1 where MATCH(a,b) AGAINST ("indexes collections");
select * from t1 where MATCH(a,b) AGAINST ("only");
drop table if exists t1,t2;
# Test that every DML (except SELECT) and DDL gets into binlog
# so that blackhole can be used as "binlog propagator"
reset master;
drop table t1,t2;
create table t1 (a int) engine=blackhole;
delete from t1 where a=10;
update t1 set a=11 where a=15;
insert into t1 values(1);
insert ignore into t1 values(1);
replace into t1 values(100);
create table t2 (a varchar(200)) engine=blackhole;
load data infile '../../std_data/words.dat' into table t2;
alter table t1 add b int;
alter table t1 drop b;
create table t3 like t1;
insert into t1 select * from t3;
replace into t1 select * from t3;
# Just to verify
select * from t1;
select * from t2;
select * from t3;
let $VERSION=`select version()`;
--replace_result $VERSION VERSION
--replace_column 2 # 5 #
show binlog events;
drop table t1,t2,t3;
......@@ -196,3 +196,11 @@ INSERT INTO `t1` VALUES (0x602010000280100005E71A);
--exec $MYSQL_DUMP --skip-extended-insert --hex-blob test --skip-comments t1
DROP TABLE t1;
#
# Bug #9756
#
CREATE TABLE t1 (a char(10));
INSERT INTO t1 VALUES ('\'');
--exec $MYSQL_DUMP --skip-comments test t1
DROP TABLE t1;
--disable_warnings
drop table if exists t1;
drop table if exists t1, t2;
--enable_warnings
create table t1 (v varchar(30), c char(3), e enum('abc','def','ghi'), t text);
......@@ -106,3 +106,15 @@ insert into t1 values ('test', 'something');
update t1 set othercol='somethingelse' where pkcol='test';
select * from t1;
drop table t1;
#
# Bug #9489: problems with key handling
#
create table t1 (a int, b varchar(12));
insert into t1 values (1, 'A'), (22, NULL);
create table t2 (a int);
insert into t2 values (22), (22);
select t1.a, t1.b, min(t1.b) from t1 inner join t2 ON t2.a = t1.a
group by t1.b, t1.a;
drop table t1, t2;
......@@ -581,15 +581,15 @@ ulong escape_string_for_mysql(CHARSET_INFO *charset_info,
{
char escape=0;
#ifdef USE_MB
int l;
if (use_mb_flag && (l= my_ismbchar(charset_info, from, end)))
int tmp_length;
if (use_mb_flag && (tmp_length= my_ismbchar(charset_info, from, end)))
{
if (to + l >= to_end)
if (to + tmp_length > to_end)
{
overflow=1;
break;
}
while (l--)
while (tmp_length--)
*to++= *from++;
from--;
continue;
......@@ -605,7 +605,7 @@ ulong escape_string_for_mysql(CHARSET_INFO *charset_info,
multi-byte character into a valid one. For example, 0xbf27 is not
a valid GBK character, but 0xbf5c is. (0x27 = ', 0x5c = \)
*/
if (use_mb_flag && (l= my_mbcharlen(charset_info, *from)) > 1)
if (use_mb_flag && (tmp_length= my_mbcharlen(charset_info, *from)) > 1)
escape= *from;
else
#endif
......@@ -634,7 +634,7 @@ ulong escape_string_for_mysql(CHARSET_INFO *charset_info,
}
if (escape)
{
if (to + 2 >= to_end)
if (to + 2 > to_end)
{
overflow=1;
break;
......@@ -644,7 +644,7 @@ ulong escape_string_for_mysql(CHARSET_INFO *charset_info,
}
else
{
if (to + 1 >= to_end)
if (to + 1 > to_end)
{
overflow=1;
break;
......
......@@ -4,7 +4,7 @@ use Getopt::Long;
use POSIX qw(strftime);
$|=1;
$VER="2.12";
$VER="2.14";
$opt_config_file = undef();
$opt_example = 0;
......@@ -37,13 +37,13 @@ main();
sub main
{
my ($flag_exit);
my $flag_exit= 0;
if (!defined(my_which(my_print_defaults)))
{
# We can't throw out yet, since --version, --help, or --example may
# have been given
print "WARNING! my_print_defaults command not found!\n";
print "WARNING: my_print_defaults command not found.\n";
print "Please make sure you have this command available and\n";
print "in your path. The command is available from the latest\n";
print "MySQL distribution.\n";
......@@ -66,6 +66,11 @@ sub main
else
{
$opt_config_file= $1;
if (!($opt_config_file =~ m/\//))
{
# No path. Use current working directory
$opt_config_file= "./" . $opt_config_file;
}
}
}
}
......@@ -76,10 +81,18 @@ sub main
chop @defops;
splice @ARGV, 0, 0, @defops;
}
GetOptions("help","example","version","mysqld=s","mysqladmin=s",
"config-file=s","user=s","password=s","log=s","no-log","tcp-ip",
"silent","verbose")
|| die "Wrong option! See $my_progname --help for detailed information!\n";
if (!GetOptions("help","example","version","mysqld=s","mysqladmin=s",
"config-file=s","user=s","password=s","log=s","no-log",
"tcp-ip", "silent","verbose"))
{
$flag_exit= 1;
}
if (defined($opt_config_file) && !($opt_config_file =~ m/\//))
{
# No path. Use current working directory
$opt_config_file= "./" . $opt_config_file;
}
usage() if ($opt_help);
if ($opt_verbose && $opt_silent)
{
......@@ -95,15 +108,14 @@ sub main
exit(0);
}
example() if ($opt_example);
usage() if ($opt_help);
if ($flag_exit)
{
print "Error with an option, see $my_progname --help for more info!\n";
print "Error with an option, see $my_progname --help for more info.\n";
exit(1);
}
if (!defined(my_which(my_print_defaults)))
{
print "ABORT: Can't find command 'my_print_defaults'!\n";
print "ABORT: Can't find command 'my_print_defaults'.\n";
print "This command is available from the latest MySQL\n";
print "distribution. Please make sure you have the command\n";
print "in your PATH.\n";
......@@ -156,6 +168,31 @@ sub main
}
}
####
#### Quote option argument. Add double quotes around the argument
#### and escape the following: $, \, "
#### This function is needed, because my_print_defaults drops possible
#### quotes, single or double, from in front of an argument and from
#### the end.
####
sub quote_opt_arg
{
my ($option)= @_;
if ($option =~ m/(\-\-[a-zA-Z0-9\_\-]+)=(.*)/)
{
$option= $1;
$arg= $2;
$arg=~ s/\\/\\\\/g; # Escape escape character first to avoid doubling.
$arg=~ s/\$/\\\$/g;
$arg=~ s/\"/\\\"/g;
$arg= "\"" . $arg . "\"";
$option= $option . "=" . $arg;
}
return $option;
}
####
#### Init log file. Check for appropriate place for log file, in the following
#### order my_print_defaults mysqld datadir, @datadir@, /var/log, /tmp
......@@ -290,6 +327,7 @@ sub start_mysqlds()
else
{
$options[$j]=~ s/;/\\;/g;
$options[$j]= quote_opt_arg($options[$j]);
$tmp.= " $options[$j]";
}
}
......
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