summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@hundin.mysql.fi>2001-06-25 11:35:22 +0300
committerunknown <monty@hundin.mysql.fi>2001-06-25 11:35:22 +0300
commit4d5dcac35ea0fc25632d17657b3f42af41bd2c7d (patch)
treec5dedde5af42a65776a3a0d1d3b949cad43a0d59
parent157c1bc5f948995697ca96fb100ea1657c7952c9 (diff)
downloadmariadb-git-4d5dcac35ea0fc25632d17657b3f42af41bd2c7d.tar.gz
Fixed bug when sorting big files (introduced with multi-table-delete)
Changed mysql-test to use --language Cleaned up parameters to filesort() configure.in: Fixed typo mysql-test/install_test_db.sh: Changed test case to use --language mysql-test/mysql-test-run.sh: Changed test case to use --language Fixed that test names are not 'cut'-ed. mysql-test/r/select_found.result: Fixed test case to make it repeatable mysql-test/t/insert.test: Added test of unique key handling mysql-test/t/order_fill_sortbuf.test: Cleaned up test mysql-test/t/select_found.test: Fixed test case to make it repeatable sql/filesort.cc: Fixed bug when sorting big files (introduced with multi-table-delete) cleaned up parameters. sql/mysql_priv.h: Cleaned up parameters to filesort() sql/mysqld.cc: Fixed typo on enum sql/sql_delete.cc: Cleanup sql/sql_select.cc: Cleanup sql/sql_table.cc: Cleanup sql/sql_test.cc: Cleanup sql/sql_update.cc: Cleanup
-rw-r--r--configure.in2
-rw-r--r--mysql-test/install_test_db.sh8
-rw-r--r--mysql-test/mysql-test-run.sh21
-rw-r--r--mysql-test/r/big_test.require2
-rw-r--r--mysql-test/r/select_found.result2
-rw-r--r--mysql-test/t/insert.test12
-rw-r--r--mysql-test/t/order_fill_sortbuf.test15
-rw-r--r--mysql-test/t/select_found.test2
-rw-r--r--sql/filesort.cc32
-rw-r--r--sql/mysql_priv.h5
-rw-r--r--sql/mysqld.cc6
-rw-r--r--sql/sql_delete.cc2
-rw-r--r--sql/sql_select.cc4
-rw-r--r--sql/sql_table.cc4
-rw-r--r--sql/sql_test.cc3
-rw-r--r--sql/sql_update.cc2
16 files changed, 74 insertions, 48 deletions
diff --git a/configure.in b/configure.in
index 26b74804d43..1c9501ddd46 100644
--- a/configure.in
+++ b/configure.in
@@ -403,7 +403,7 @@ AM_PROG_CC_STDC
if test "$am_cv_prog_cc_stdc" = "no"
then
- AC_MSG_ERROR([MySQL requiers a ANSI C compiler (and a C++ compiler). Try gcc. See the Installation chapter in the Reference Manual.])
+ AC_MSG_ERROR([MySQL requires a ANSI C compiler (and a C++ compiler). Try gcc. See the Installation chapter in the Reference Manual.])
fi
NOINST_LDFLAGS=
diff --git a/mysql-test/install_test_db.sh b/mysql-test/install_test_db.sh
index 049ac6b1cd7..34df311e683 100644
--- a/mysql-test/install_test_db.sh
+++ b/mysql-test/install_test_db.sh
@@ -30,7 +30,7 @@ else
fi
mdata=$data/mysql
-
+EXTRA_ARG=""
if test ! -x $execdir/mysqld
then
@@ -57,9 +57,7 @@ if [ x$BINARY_DIST = x1 ] ; then
basedir=..
else
basedir=.
-rm -rf share
-mkdir share
-ln -sf ../../sql/share share/mysql
+EXTRA_ARG="--language=../sql/share/english/"
fi
# Initialize variables
@@ -193,7 +191,7 @@ then
fi
if $execdir/mysqld --no-defaults --bootstrap --skip-grant-tables \
- --basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb --skip-gemini << END_OF_DATA
+ --basedir=$basedir --datadir=$ldata --skip-innodb --skip-bdb --skip-gemini $EXTRA_ARG << END_OF_DATA
use mysql;
$c_d
$i_d
diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh
index 3e10297b487..c1f00f00fc2 100644
--- a/mysql-test/mysql-test-run.sh
+++ b/mysql-test/mysql-test-run.sh
@@ -260,6 +260,7 @@ if [ x$SOURCE_DIST = x1 ] ; then
MYSQL_TEST="$BASEDIR/client/mysqltest"
MYSQLADMIN="$BASEDIR/client/mysqladmin"
MYSQL="$BASEDIR/client/mysql"
+ LANGUAGE="$BASEDIR/sql/share/english/"
INSTALL_DB="./install_test_db"
else
MYSQLD="$BASEDIR/bin/mysqld"
@@ -267,6 +268,12 @@ else
MYSQLADMIN="$BASEDIR/bin/mysqladmin"
MYSQL="$BASEDIR/bin/mysql"
INSTALL_DB="./install_test_db -bin"
+ if test -d "$BASEDIR/share/mysql/english"
+ then
+ LANGUAGE="$BASEDIR/share/mysql/english/"
+ else
+ LANGUAGE="$BASEDIR/share/english/"
+ fi
fi
# If we should run all tests cases, we will use a local server for that
@@ -478,7 +485,7 @@ start_master()
--socket=$MASTER_MYSOCK \
--log=$MASTER_MYLOG --default-character-set=latin1 \
--tmpdir=$MYSQL_TMP_DIR \
- --language=english \
+ --language=$LANGUAGE \
--innodb_data_file_path=ibdata1:50M \
$SMALL_SERVER \
$EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT"
@@ -492,7 +499,7 @@ start_master()
--default-character-set=latin1 \
--core \
--tmpdir=$MYSQL_TMP_DIR \
- --language=english \
+ --language=$LANGUAGE \
--innodb_data_file_path=ibdata1:50M \
$SMALL_SERVER \
$EXTRA_MASTER_OPT $EXTRA_MASTER_MYSQLD_OPT"
@@ -548,7 +555,7 @@ start_slave()
--log=$SLAVE_MYLOG --default-character-set=latin1 \
--core \
--tmpdir=$MYSQL_TMP_DIR \
- --language=english \
+ --language=$LANGUAGE \
--skip-innodb --skip-slave-start \
--report-host=127.0.0.1 --report-user=root \
--report-port=$SLAVE_MYPORT \
@@ -674,8 +681,8 @@ run_testcase ()
SYST=" ...."
REALT=" ...."
timestr="$USERT $SYST $REALT"
- pname=`$ECHO "$tname "|$CUT -c 1-16`
- RES="$pname $timestr"
+ pname=`$ECHO "$tname "|$CUT -c 1-24`
+ RES="$pname $timestr"
skip_inc
$ECHO "$RES$RES_SPACE [ skipped ]"
return
@@ -755,8 +762,8 @@ run_testcase ()
fi
timestr="$USERT $SYST $REALT"
- pname=`$ECHO "$tname "|$CUT -c 1-16`
- RES="$pname $timestr"
+ pname=`$ECHO "$tname "|$CUT -c 1-24`
+ RES="$pname $timestr"
if [ $res = 0 ]; then
total_inc
diff --git a/mysql-test/r/big_test.require b/mysql-test/r/big_test.require
new file mode 100644
index 00000000000..001b903496b
--- /dev/null
+++ b/mysql-test/r/big_test.require
@@ -0,0 +1,2 @@
+using_big_test
+1
diff --git a/mysql-test/r/select_found.result b/mysql-test/r/select_found.result
index fcbe8958748..b3fa281e76d 100644
--- a/mysql-test/r/select_found.result
+++ b/mysql-test/r/select_found.result
@@ -22,7 +22,7 @@ b
FOUND_ROWS()
6
b c
-2 1
+5 3
FOUND_ROWS()
6
a b a b
diff --git a/mysql-test/t/insert.test b/mysql-test/t/insert.test
index cf6f41d454d..270b1cd4c79 100644
--- a/mysql-test/t/insert.test
+++ b/mysql-test/t/insert.test
@@ -10,3 +10,15 @@ insert into t1 values (a+3);
insert into t1 values (4),(a+5);
select * from t1;
drop table t1;
+
+#
+# Test of duplicate key values with packed keys
+#
+
+create table t1 (id int not null auto_increment primary key, username varchar(32) not null, unique (username));
+insert into t1 values (0,"mysql");
+insert into t1 values (0,"mysql ab");
+insert into t1 values (0,"mysql a");
+insert into t1 values (0,"r1manic");
+insert into t1 values (0,"r1man");
+drop table t1;
diff --git a/mysql-test/t/order_fill_sortbuf.test b/mysql-test/t/order_fill_sortbuf.test
index 5556834d516..a64ffce08e3 100644
--- a/mysql-test/t/order_fill_sortbuf.test
+++ b/mysql-test/t/order_fill_sortbuf.test
@@ -1,19 +1,20 @@
+#
+# This test does a create-select with ORDER BY, where there is so many
+# rows MySQL needs to use a merge during the sort phase.
+#
+
drop table if exists t1,t2;
CREATE TABLE `t1` (
`id` int(11) NOT NULL default '0',
`id2` int(11) NOT NULL default '0',
- `id3` int(11) NOT NULL default '0',
- `dummy1` char(30) default NULL,
- PRIMARY KEY (`id`,`id2`),
- KEY `index_id3` (`id3`));
+ `id3` int(11) NOT NULL default '0');
let $1=4000;
while ($1)
{
- eval insert into t1 (id,id2,id3,dummy1) values ($1,$1,$1,'foobar');
+ eval insert into t1 (id,id2,id3) values ($1,$1,$1);
dec $1;
}
-create table t2 (n int);
-insert into t2 select id2 from t1 order by id3;
+create table t2 select id2 from t1 order by id3;
select count(*) from t2;
drop table t1,t2;
diff --git a/mysql-test/t/select_found.test b/mysql-test/t/select_found.test
index d86ef1e0907..52c8039b2f5 100644
--- a/mysql-test/t/select_found.test
+++ b/mysql-test/t/select_found.test
@@ -13,7 +13,7 @@ select SQL_CALC_FOUND_ROWS * from t1 order by b desc limit 1;
select found_rows();
select SQL_CALC_FOUND_ROWS distinct b from t1 limit 1;
select found_rows();
-select SQL_CALC_FOUND_ROWS b,count(*) as c from t1 group by b order by c limit 1;
+select SQL_CALC_FOUND_ROWS b,count(*) as c from t1 group by b order by c desc limit 1;
select found_rows();
select SQL_CALC_FOUND_ROWS * from t1 left join t1 as t2 on (t1.b=t2.a) limit 2,1;
select found_rows();
diff --git a/sql/filesort.cc b/sql/filesort.cc
index 18bdc8e86d8..fe06d3eb9b6 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -53,11 +53,19 @@ static int merge_index(SORTPARAM *param,uchar *sort_buffer,
static bool save_index(SORTPARAM *param,uchar **sort_keys, uint count);
static uint sortlength(SORT_FIELD *sortorder,uint length);
- /* Makes a indexfil of recordnumbers of a sorted database */
- /* outfile is reset before data is written to it, if it wasn't
- open a new file is opened */
+ /*
+ Creates a set of pointers that can be used to read the rows
+ in sorted order. This should be done with the functions
+ in records.cc
-ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
+ Before calling filesort, one must have done
+ table->file->info(HA_STATUS_VARIABLE)
+
+ The result set is stored in table->io_cache or
+ table->record_pointers
+ */
+
+ha_rows filesort(TABLE *table, SORT_FIELD *sortorder, uint s_length,
SQL_SELECT *select, ha_rows special, ha_rows max_rows,
ha_rows *examined_rows)
{
@@ -69,19 +77,20 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
IO_CACHE tempfile,*selected_records_file,*outfile;
SORTPARAM param;
DBUG_ENTER("filesort");
- DBUG_EXECUTE("info",TEST_filesort(table,sortorder,s_length,special););
+ DBUG_EXECUTE("info",TEST_filesort(sortorder,s_length,special););
#ifdef SKIPP_DBUG_IN_FILESORT
DBUG_PUSH(""); /* No DBUG here */
#endif
- outfile= table[0]->io_cache;
+ outfile= table->io_cache;
my_b_clear(&tempfile);
buffpek= (BUFFPEK *) NULL; sort_keys= (uchar **) NULL; error= 1;
maxbuffer=1;
- param.ref_length= table[0]->file->ref_length;
+ param.ref_length= table->file->ref_length;
param.sort_length=sortlength(sortorder,s_length)+ param.ref_length;
param.max_rows= max_rows;
param.examined_rows=0;
+ param.unique_buff=0;
if (select && select->quick)
{
@@ -106,17 +115,14 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
#ifdef CAN_TRUST_RANGE
else if (select && select->quick && select->quick->records > 0L)
{
- /* Get record-count */
- table[0]->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);
records=min((ha_rows) (select->quick->records*2+EXTRA_RECORDS*2),
- table[0]->file->records)+EXTRA_RECORDS;
+ table->file->records)+EXTRA_RECORDS;
selected_records_file=0;
}
#endif
else
{
- table[0]->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK);/* Get record-count */
- records=table[0]->file->estimate_number_of_rows();
+ records=table->file->estimate_number_of_rows();
selected_records_file= 0;
}
if (param.sort_length == param.ref_length && records > param.max_rows)
@@ -170,7 +176,7 @@ ha_rows filesort(TABLE **table, SORT_FIELD *sortorder, uint s_length,
my_error(ER_OUTOFMEMORY,MYF(ME_ERROR+ME_WAITTANG),sortbuff_size);
goto err;
}
- param.sort_form= table[0];
+ param.sort_form= table;
param.end=(param.local_sortorder=sortorder)+s_length;
if ((records=find_all_keys(&param,select,sort_keys,buffpek,&maxbuffer,
&tempfile, selected_records_file)) ==
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index 07c73aa37a9..63c9478d236 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -475,8 +475,7 @@ pthread_handler_decl(handle_manager, arg);
#ifndef DBUG_OFF
void print_where(COND *cond,const char *info);
void print_cached_tables(void);
-void TEST_filesort(TABLE **form,SORT_FIELD *sortorder,uint s_length,
- ha_rows special);
+void TEST_filesort(SORT_FIELD *sortorder,uint s_length, ha_rows special);
#endif
void mysql_print_status(THD *thd);
/* key.cc */
@@ -618,7 +617,7 @@ void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form,
SQL_SELECT *select,
int use_record_cache, bool print_errors);
void end_read_record(READ_RECORD *info);
-ha_rows filesort(TABLE **form,struct st_sort_field *sortorder, uint s_length,
+ha_rows filesort(TABLE *form,struct st_sort_field *sortorder, uint s_length,
SQL_SELECT *select, ha_rows special,ha_rows max_rows,
ha_rows *examined_rows);
void change_double_for_sort(double nr,byte *to);
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index c86ed19092c..7c40b5f15ef 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -2479,7 +2479,7 @@ enum options {
OPT_INNODB_LOG_ARCH_DIR,
OPT_INNODB_LOG_ARCHIVE,
OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT,
- OPT_innodb_flush_method,
+ OPT_INNODB_FLUSH_METHOD,
OPT_SAFE_SHOW_DB,
OPT_GEMINI_SKIP, OPT_INNODB_SKIP,
OPT_TEMP_POOL, OPT_DO_PSTACK, OPT_TX_ISOLATION,
@@ -2545,7 +2545,7 @@ static struct option long_options[] = {
{"innodb_flush_log_at_trx_commit", optional_argument, 0,
OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT},
{"innodb_flush_method", required_argument, 0,
- OPT_INNODB_UNIX_FILE_FLUSH_METHOD},
+ OPT_INNODB_FLUSH_METHOD},
#endif
{"help", no_argument, 0, '?'},
{"init-file", required_argument, 0, (int) OPT_INIT_FILE},
@@ -3703,7 +3703,7 @@ static void get_options(int argc,char **argv)
case OPT_INNODB_FLUSH_LOG_AT_TRX_COMMIT:
innobase_flush_log_at_trx_commit= optarg ? test(atoi(optarg)) : 1;
break;
- case OPT_INNODB_UNIX_FILE_FLUSH_METHOD:
+ case OPT_INNODB_FLUSH_METHOD:
innobase_unix_file_flush_method=optarg;
break;
#endif /* HAVE_INNOBASE_DB */
diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc
index dc07d81f8f2..b690ef4b327 100644
--- a/sql/sql_delete.cc
+++ b/sql/sql_delete.cc
@@ -214,7 +214,7 @@ int mysql_delete(THD *thd,
MYF(MY_FAE | MY_ZEROFILL));
if (setup_order(thd, &tables, fields, all_fields, order) ||
!(sortorder=make_unireg_sortorder(order, &length)) ||
- (table->found_records = filesort(&table, sortorder, length,
+ (table->found_records = filesort(table, sortorder, length,
(SQL_SELECT *) 0, 0L, HA_POS_ERROR,
&examined_rows))
== HA_POS_ERROR)
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 4a033f3e6ad..bb1e72d943f 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -5334,7 +5334,9 @@ create_sort_index(JOIN_TAB *tab,ORDER *order,ha_rows select_limit)
goto err;
}
}
- table->found_records=filesort(&table,sortorder,length,
+ if (table->tmp_table)
+ table->file->info(HA_STATUS_VARIABLE); // Get record count
+ table->found_records=filesort(table,sortorder,length,
select, 0L, select_limit, &examined_rows);
delete select; // filesort did select
tab->select=0;
diff --git a/sql/sql_table.cc b/sql/sql_table.cc
index 3988a823e83..b755a4d6327 100644
--- a/sql/sql_table.cc
+++ b/sql/sql_table.cc
@@ -1755,8 +1755,8 @@ copy_data_between_tables(TABLE *from,TABLE *to,
if (setup_order(thd, &tables, fields, all_fields, order) ||
!(sortorder=make_unireg_sortorder(order, &length)) ||
- (from->found_records = filesort(&from, sortorder, length,
- (SQL_SELECT *) 0, 0L, HA_POS_ERROR,
+ (from->found_records = filesort(from, sortorder, length,
+ (SQL_SELECT *) 0, 0L, HA_POS_ERROR,
&examined_rows))
== HA_POS_ERROR)
goto err;
diff --git a/sql/sql_test.cc b/sql/sql_test.cc
index 3edfdd3d5ef..d20bc74ecb2 100644
--- a/sql/sql_test.cc
+++ b/sql/sql_test.cc
@@ -96,8 +96,7 @@ void print_cached_tables(void)
}
-void TEST_filesort(TABLE **table,SORT_FIELD *sortorder,uint s_length,
- ha_rows special)
+void TEST_filesort(SORT_FIELD *sortorder,uint s_length, ha_rows special)
{
char buff[256],buff2[256];
String str(buff,sizeof(buff)),out(buff2,sizeof(buff2));
diff --git a/sql/sql_update.cc b/sql/sql_update.cc
index bdcc6c00b19..a6ded7cef9c 100644
--- a/sql/sql_update.cc
+++ b/sql/sql_update.cc
@@ -184,7 +184,7 @@ int mysql_update(THD *thd,
MYF(MY_FAE | MY_ZEROFILL));
if (setup_order(thd, &tables, fields, all_fields, order) ||
!(sortorder=make_unireg_sortorder(order, &length)) ||
- (table->found_records = filesort(&table, sortorder, length,
+ (table->found_records = filesort(table, sortorder, length,
(SQL_SELECT *) 0, 0L,
HA_POS_ERROR, &examined_rows))
== HA_POS_ERROR)