Commit 4000b036 authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi
Browse files

Fixes for new getopt

Bug fix when using --no-deaults
Sets ref_length to right value (faster rnd_pos() handling in InnoDB).
Fixed problem with multi-table-delete and InnoDB
Fixed problem with truncate table, which required a COMMIT before.
Fixed multi-table-delete bug with InnoDB.
Remove not used index from EXPLAIN
parent 79796e98
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -48374,9 +48374,20 @@ Our TODO section contains what we plan to have in 4.0. @xref{TODO MySQL 4.0}.
@itemize @bullet
@item
Fixed some problems with @code{USE KEYS} / @code{IGNORE KEYS} when using
many keys with the same start column.
@item
Don't use table scan with BerkeleyDB and InnoDB tables when we can use
an index that covers the whole row.
@item
Optimized InnoDB sort-buffer handling to take less memory.
@item
Fixed bug in multi-table-delete and InnoDB tables.
@item
Fixed problem with @code{TRUNCATE} and InnoDB that gave the error
@code{Can't execute the given command because you have active locked
tables or an active transaction}.
@item
Added sql-mode flag @code{NO_UNSIGNED_SUBTRACTION} to disable unsigned
arithmetic rules when it comes to subtraction. (This will make MySQL 4.0
behave more closely to 3.23 with @code{UNSIGNED} columns).
+5 −0
Original line number Diff line number Diff line
@@ -45,3 +45,8 @@ struct my_option
  my_bool    opt_is_var;                /* If true, the option is a variable */
};

extern int handle_options (int *argc, char ***argv, 
			   const struct my_option *longopts, 
			   my_bool (*get_one_option)(int,
						     const struct my_option *,
						     char *));
+16 −17
Original line number Diff line number Diff line
@@ -155,7 +155,7 @@ static struct my_option my_long_options[] =
  {"analyze", "", 0, 0, 0, GET_NO_ARG, NO_ARG, 'a', 0, 0, 0, 0, 0, 0, 0},
  {"block-search", "", 0, 0, 0, GET_LONG, REQUIRED_ARG, 'b', 0, 0, 0, 0, 0, 0, 0},
  {"backup", "", 0, 0, 0, GET_NO_ARG, NO_ARG, 'B', 0, 0, 0, 0, 0, 0, 0},
  {"character-sets-dir", "", 0, 0, 0, GET_STR, REQUIRED_ARG, OPT_CHARSETS_DIR, 0, 0, 0, 0, 0, 0, 0},
  {"character-sets-dir", "", (gptr*) &set_charset_name, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0, 0, 1},

  {"check", "", 0, 0, 0, GET_NO_ARG, NO_ARG, 'c', 0, 0, 0, 0, 0, 0, 0},
  {"check-only-changed", "", 0, 0, 0, GET_NO_ARG, NO_ARG, 'C', 0, 0, 0, 0, 0, 0, 0},
@@ -191,6 +191,7 @@ static struct my_option my_long_options[] =
  {"verbose", "", 0, 0, 0, GET_NO_ARG, NO_ARG, 'v', 0, 0, 0, 0, 0, 0, 0},
  {"version", "", 0, 0, 0, GET_NO_ARG, NO_ARG, 'V', 0, 0, 0, 0, 0, 0, 0},
  {"wait", "", 0, 0, 0, GET_NO_ARG, NO_ARG, 'w', 0, 0, 0, 0, 0, 0, 0},

  /* variables begin here */
  { "key_buffer_size", "", (gptr*) &check_param.use_buffers, (gptr*) &check_param.use_buffers, 0, GET_LONG, REQUIRED_ARG, OPT_KEY_BUFFER_SIZE, (long) USE_BUFFER_INIT, (long) MALLOC_OVERHEAD, (long) ~0L, (long) MALLOC_OVERHEAD, (long) IO_SIZE, 0, 1}, 
  { "myisam_block_size", "", (gptr*) &opt_myisam_block_size, (gptr*) &opt_myisam_block_size, 0, GET_LONG, REQUIRED_ARG, OPT_MYISAM_BLOCK_SIZE, MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH, 0, MI_MIN_KEY_BLOCK_LENGTH, 0, 1}, 
@@ -202,7 +203,7 @@ static struct my_option my_long_options[] =
  { "ft_min_word_len", "", (gptr*) &ft_min_word_len, (gptr*) &ft_min_word_len, 0, GET_LONG, REQUIRED_ARG, OPT_FT_MIN_WORD_LEN, 4, 1, HA_FT_MAXLEN, 0, 1, 0, 1},
  { "ft_max_word_len", "", (gptr*) &ft_max_word_len, (gptr*) &ft_max_word_len, 0, GET_LONG, REQUIRED_ARG, OPT_FT_MAX_WORD_LEN, HA_FT_MAXLEN, 10, HA_FT_MAXLEN, 0, 1, 0, 1},
  { "ft_max_word_len_for_sort", "", (gptr*) &ft_max_word_len_for_sort, (gptr*) &ft_max_word_len_for_sort, 0, GET_LONG, REQUIRED_ARG, OPT_FT_MAX_WORD_LEN_FOR_SORT, 20, 4, HA_FT_MAXLEN, 0, 1, 0, 1},
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
};


@@ -297,25 +298,27 @@ static void usage(void)
		      (It may be VERY slow to do a sort the first time!)");

  print_defaults("my",load_default_groups);
  printf("\nPossible variables for option --set-variable (-O) are:\n");
  printf("\nThe variables you can set are:\n");
  for (i=0; my_long_options[i].name ; i++)
  {
    if (!my_long_options[i].opt_is_var)
      continue;
#ifdef TO_BE_FIXED
    printf("%-20s  current value: %lu\n", my_long_options[i].name, 
	   *my_long_options[i].value);
#endif
  }

}


	 /* Read options */

static my_bool get_one_option(int optid, const struct my_option *opt,
static my_bool
get_one_option(int optid,
	       const struct my_option *opt __attribute__((unused)),
	       char *argument)
{
  uint old_testflag;
  char buff[255], *end;

  switch (optid) {
  case 'a':
@@ -428,14 +431,11 @@ static my_bool get_one_option(int optid, const struct my_option *opt,
    print_version();
    exit(0);
  case OPT_CORRECT_CHECKSUM:
    if (*argument && *argument == '0')
      check_param.testflag&= ~T_CALC_CHECKSUM;
    else
      check_param.testflag|=T_CALC_CHECKSUM;
    break;
  case OPT_CHARSETS_DIR:
    charsets_dir= argument;
    break;
  case OPT_SET_CHARSET:
    set_charset_name= argument;
    break;
#ifdef DEBUG					/* Only useful if debugging */
  case OPT_START_CHECK_POS:
    check_param.start_check_pos=strtoull(argument, NULL, 0);
@@ -445,13 +445,12 @@ static my_bool get_one_option(int optid, const struct my_option *opt,
    usage();
    exit(0);
  }
  return 0;
}


static void get_options(register int *argc,register char ***argv)
{
  int c, option_index=0;

  load_defaults("my", load_default_groups, argc, argv);
  default_argv= *argv;
  if (isatty(fileno(stdout)))
+1 −1
Original line number Diff line number Diff line
@@ -16,7 +16,7 @@ table type possible_keys key key_len ref rows Extra
t1	const	str	str	11	const	1	
explain select * from t1 ignore key (str) where str="foo";
table	type	possible_keys	key	key_len	ref	rows	Extra
t1	ALL	str	NULL	NULL	NULL	4	where used
t1	ALL	NULL	NULL	NULL	NULL	4	where used
explain select * from t1 use key (str,str) where str="foo";
table	type	possible_keys	key	key_len	ref	rows	Extra
t1	const	str	str	11	const	1	
+83 −5
Original line number Diff line number Diff line
@@ -168,9 +168,9 @@ Table Op Msg_type Msg_text
test.t1	optimize	error	The handler for the table doesn't support check/repair
show keys from t1;
Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
t1	0	PRIMARY	1	id	A	87	NULL	NULL		BTREE	
t1	1	parent_id	1	parent_id	A	21	NULL	NULL		BTREE	
t1	1	level	1	level	A	4	NULL	NULL		BTREE	
t1	0	PRIMARY	1	id	A	NULL	NULL	NULL		BTREE	
t1	1	parent_id	1	parent_id	A	NULL	NULL	NULL		BTREE	
t1	1	level	1	level	A	NULL	NULL	NULL		BTREE	
drop table t1;
CREATE TABLE t1 (
gesuchnr int(11) DEFAULT '0' NOT NULL,
@@ -211,7 +211,7 @@ Table Op Msg_type Msg_text
test.t1	analyze	error	The handler for the table doesn't support check/repair
show keys from t1;
Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
t1	1	skr	1	a	A	1	NULL	NULL	YES	BTREE	
t1	1	skr	1	a	A	NULL	NULL	NULL	YES	BTREE	
drop table t1;
create table t1 (a int,b varchar(20),key(a)) type=innodb;
insert into t1 values (1,""), (2,"testing");
@@ -727,7 +727,7 @@ Table Op Msg_type Msg_text
test.t1	optimize	error	The handler for the table doesn't support check/repair
show keys from t1;
Table	Non_unique	Key_name	Seq_in_index	Column_name	Collation	Cardinality	Sub_part	Packed	Null	Index_type	Comment
t1	0	PRIMARY	1	a	A	1	NULL	NULL		BTREE	
t1	0	PRIMARY	1	a	A	NULL	NULL	NULL		BTREE	
drop table t1;
create table t1 (i int, j int ) TYPE=innodb;
insert into t1 values (1,2);
@@ -859,6 +859,7 @@ commit;
drop database mysqltest;
show tables from mysqltest;
Got one of the listed errors
set autocommit=0;
create table t1 (a int not null) type= innodb;
insert into t1 values(1),(2);
truncate table t1;
@@ -873,6 +874,21 @@ select * from t1;
a
commit;
drop table t1;
set autocommit=1;
create table t1 (a int not null) type= innodb;
insert into t1 values(1),(2);
truncate table t1;
insert into t1 values(1),(2);
select * from t1;
a
1
2
truncate table t1;
insert into t1 values(1),(2);
delete from t1;
select * from t1;
a
drop table t1;
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) type=innodb;
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
explain select * from t1 order by a;
@@ -911,3 +927,65 @@ Unknown table 't1' in HANDLER
handler t1 close;
Unknown table 't1' in HANDLER
drop table t1;
CREATE TABLE t1 (
number bigint(20) NOT NULL default '0',
cname char(15) NOT NULL default '',
carrier_id smallint(6) NOT NULL default '0',
privacy tinyint(4) NOT NULL default '0',
last_mod_date timestamp(14) NOT NULL,
last_mod_id smallint(6) NOT NULL default '0',
last_app_date timestamp(14) NOT NULL,
last_app_id smallint(6) default '-1',
version smallint(6) NOT NULL default '0',
assigned_scps int(11) default '0',
status tinyint(4) default '0'
) TYPE=InnoDB;
INSERT INTO t1 VALUES (4077711111,'SeanWheeler',90,2,20020111112846,500,00000000000000,-1,2,3,1);
INSERT INTO t1 VALUES (9197722223,'berry',90,3,20020111112809,500,20020102114532,501,4,10,0);
INSERT INTO t1 VALUES (650,'San Francisco',0,0,20011227111336,342,00000000000000,-1,1,24,1);
INSERT INTO t1 VALUES (302467,'Sue\'s Subshop',90,3,20020109113241,500,20020102115111,501,7,24,0);
INSERT INTO t1 VALUES (6014911113,'SudzCarwash',520,1,20020102115234,500,20020102115259,501,33,32768,0);
INSERT INTO t1 VALUES (333,'tubs',99,2,20020109113440,501,20020109113440,500,3,10,0);
CREATE TABLE t2 (
number bigint(20) NOT NULL default '0',
cname char(15) NOT NULL default '',
carrier_id smallint(6) NOT NULL default '0',
privacy tinyint(4) NOT NULL default '0',
last_mod_date timestamp(14) NOT NULL,
last_mod_id smallint(6) NOT NULL default '0',
last_app_date timestamp(14) NOT NULL,
last_app_id smallint(6) default '-1',
version smallint(6) NOT NULL default '0',
assigned_scps int(11) default '0',
status tinyint(4) default '0'
) TYPE=InnoDB;
INSERT INTO t2 VALUES (4077711111,'SeanWheeler',0,2,20020111112853,500,00000000000000,-1,2,3,1);
INSERT INTO t2 VALUES (9197722223,'berry',90,3,20020111112818,500,20020102114532,501,4,10,0);
INSERT INTO t2 VALUES (650,'San Francisco',90,0,20020109113158,342,00000000000000,-1,1,24,1);
INSERT INTO t2 VALUES (333,'tubs',99,2,20020109113453,501,20020109113453,500,3,10,0);
select * from t1;
number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
4077711111	SeanWheeler	90	2	20020111112846	500	00000000000000	-1	2	3	1
9197722223	berry	90	3	20020111112809	500	20020102114532	501	4	10	0
650	San Francisco	0	0	20011227111336	342	00000000000000	-1	1	24	1
302467	Sue's Subshop	90	3	20020109113241	500	20020102115111	501	7	24	0
6014911113	SudzCarwash	520	1	20020102115234	500	20020102115259	501	33	32768	0
333	tubs	99	2	20020109113440	501	20020109113440	500	3	10	0
select * from t2;
number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
4077711111	SeanWheeler	0	2	20020111112853	500	00000000000000	-1	2	3	1
9197722223	berry	90	3	20020111112818	500	20020102114532	501	4	10	0
650	San Francisco	90	0	20020109113158	342	00000000000000	-1	1	24	1
333	tubs	99	2	20020109113453	501	20020109113453	500	3	10	0
delete t1, t2 from t1 left join t2 on t1.number=t2.number where (t1.carrier_id=90 and t1.number=t2.number) or (t2.carrier_id=90 and t1.number=t2.number) or  (t1.carrier_id=90 and t2.number is null);
select * from t1;
number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
6014911113	SudzCarwash	520	1	20020102115234	500	20020102115259	501	33	32768	0
333	tubs	99	2	20020109113440	501	20020109113440	500	3	10	0
select * from t2;
number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
333	tubs	99	2	20020109113453	501	20020109113453	500	3	10	0
select * from t2;
number	cname	carrier_id	privacy	last_mod_date	last_mod_id	last_app_date	last_app_id	version	assigned_scps	status
333	tubs	99	2	20020109113453	501	20020109113453	500	3	10	0
drop table t1,t2;
Loading