summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormarko@hundin.mysql.fi <>2005-03-15 14:48:09 +0200
committermarko@hundin.mysql.fi <>2005-03-15 14:48:09 +0200
commitcedaeb4b7ce4f8df56abf947f28837c2e497fde9 (patch)
treed1b447e4dac76038a0be86428308f274f19cb614
parentdd20809e32926a8ee2ba1f9634f19a09c1d82f44 (diff)
parent50a6dc4e714da4a9a9d50ad007b779b119895755 (diff)
downloadmariadb-git-cedaeb4b7ce4f8df56abf947f28837c2e497fde9.tar.gz
Merge marko@bk-internal.mysql.com:/home/bk/mysql-4.1
into hundin.mysql.fi:/home/marko/mysql-4.1
-rw-r--r--Build-tools/Do-solaris-pkg2
-rw-r--r--heap/hp_create.c3
-rw-r--r--include/heap.h2
-rw-r--r--mysql-test/r/heap.result42
-rw-r--r--mysql-test/t/heap.test29
-rw-r--r--sql/filesort.cc7
-rw-r--r--sql/ha_heap.cc12
-rw-r--r--support-files/mysql.server.sh61
8 files changed, 132 insertions, 26 deletions
diff --git a/Build-tools/Do-solaris-pkg b/Build-tools/Do-solaris-pkg
index 8815033146c..22d68793808 100644
--- a/Build-tools/Do-solaris-pkg
+++ b/Build-tools/Do-solaris-pkg
@@ -57,7 +57,7 @@ unlink $temp or warn "Unable to remove tempfile ($!)\n";
# First get some info
$fullname =~ s,/+$,,; # Remove ending slash if any
-$fullname =~ /^((mysql)-\w+-?\w+?)-([\d\.]+\w?)-.+$/
+$fullname =~ /^((mysql)(?:-\w+){1,3})-([\d\.]+\w?)-.+$/
or die "This name is not what I expected - \"$fullname\"";
$default{"name"}= $2;
diff --git a/heap/hp_create.c b/heap/hp_create.c
index af32fefea1b..b1b132a16fb 100644
--- a/heap/hp_create.c
+++ b/heap/hp_create.c
@@ -137,6 +137,8 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
keyinfo->write_key= hp_write_key;
keyinfo->hash_buckets= 0;
}
+ if ((keyinfo->flag & HA_AUTO_KEY) && create_info->with_auto_increment)
+ share->auto_key= i + 1;
}
share->min_records= min_records;
share->max_records= max_records;
@@ -147,7 +149,6 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef,
share->keys= keys;
share->max_key_length= max_length;
share->changed= 0;
- share->auto_key= create_info->auto_key;
share->auto_key_type= create_info->auto_key_type;
share->auto_increment= create_info->auto_increment;
/* Must be allocated separately for rename to work */
diff --git a/include/heap.h b/include/heap.h
index ac2b38d1f2d..51f7b0cfa6a 100644
--- a/include/heap.h
+++ b/include/heap.h
@@ -183,10 +183,10 @@ typedef struct st_heap_info
typedef struct st_heap_create_info
{
- uint auto_key;
uint auto_key_type;
ulong max_table_size;
ulonglong auto_increment;
+ my_bool with_auto_increment;
} HP_CREATE_INFO;
/* Prototypes for heap-functions */
diff --git a/mysql-test/r/heap.result b/mysql-test/r/heap.result
index b1cd17b444c..29207a4ae98 100644
--- a/mysql-test/r/heap.result
+++ b/mysql-test/r/heap.result
@@ -249,3 +249,45 @@ a
3
2
drop table t1;
+create table t1 (a bigint unsigned auto_increment primary key, b int,
+key (b, a)) engine=heap;
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+select * from t1;
+a b
+1 1
+2 1
+3 1
+4 1
+5 1
+6 1
+7 1
+8 1
+drop table t1;
+create table t1 (a int not null, b int not null auto_increment,
+primary key(a, b), key(b)) engine=heap;
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+select * from t1;
+a b
+1 1
+1 2
+1 3
+1 4
+1 5
+1 6
+1 7
+1 8
+drop table t1;
diff --git a/mysql-test/t/heap.test b/mysql-test/t/heap.test
index bc0b28370ec..e082993a58e 100644
--- a/mysql-test/t/heap.test
+++ b/mysql-test/t/heap.test
@@ -195,3 +195,32 @@ delete from t1 where a is null;
insert into t1 values ('2'), ('3');
select * from t1;
drop table t1;
+
+#
+# Bug #8489: Strange auto_increment behaviour
+#
+
+create table t1 (a bigint unsigned auto_increment primary key, b int,
+ key (b, a)) engine=heap;
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+insert t1 (b) values (1);
+select * from t1;
+drop table t1;
+create table t1 (a int not null, b int not null auto_increment,
+ primary key(a, b), key(b)) engine=heap;
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+insert t1 (a) values (1);
+select * from t1;
+drop table t1;
diff --git a/sql/filesort.cc b/sql/filesort.cc
index c6af8cfc1b7..75b114fc140 100644
--- a/sql/filesort.cc
+++ b/sql/filesort.cc
@@ -452,8 +452,11 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
if (*killed)
{
DBUG_PRINT("info",("Sort killed by user"));
- (void) file->extra(HA_EXTRA_NO_CACHE);
- file->ha_rnd_end();
+ if (!indexfile && !quick_select)
+ {
+ (void) file->extra(HA_EXTRA_NO_CACHE);
+ file->ha_rnd_end();
+ }
DBUG_RETURN(HA_POS_ERROR); /* purecov: inspected */
}
if (error == 0)
diff --git a/sql/ha_heap.cc b/sql/ha_heap.cc
index 3c2249ce281..c483ab8fffa 100644
--- a/sql/ha_heap.cc
+++ b/sql/ha_heap.cc
@@ -446,6 +446,7 @@ int ha_heap::create(const char *name, TABLE *table_arg,
HA_KEYSEG *seg;
char buff[FN_REFLEN];
int error;
+ bool found_real_auto_increment= 0;
for (key= parts= 0; key < table_arg->keys; key++)
parts+= table_arg->key_info[key].key_parts;
@@ -506,17 +507,20 @@ int ha_heap::create(const char *name, TABLE *table_arg,
seg->null_bit= 0;
seg->null_pos= 0;
}
+ // We have to store field->key_type() as seg->type can differ from it
if (field->flags & AUTO_INCREMENT_FLAG)
- {
- auto_key= key + 1;
auto_key_type= field->key_type();
- }
}
}
+ if (table_arg->found_next_number_field)
+ {
+ keydef[table_arg->next_number_index].flag|= HA_AUTO_KEY;
+ found_real_auto_increment= table_arg->next_number_key_offset == 0;
+ }
mem_per_row+= MY_ALIGN(table_arg->reclength + 1, sizeof(char*));
HP_CREATE_INFO hp_create_info;
- hp_create_info.auto_key= auto_key;
hp_create_info.auto_key_type= auto_key_type;
+ hp_create_info.with_auto_increment= found_real_auto_increment;
hp_create_info.auto_increment= (create_info->auto_increment_value ?
create_info->auto_increment_value - 1 : 0);
hp_create_info.max_table_size=current_thd->variables.max_heap_table_size;
diff --git a/support-files/mysql.server.sh b/support-files/mysql.server.sh
index 849f913bf6c..4283af919a5 100644
--- a/support-files/mysql.server.sh
+++ b/support-files/mysql.server.sh
@@ -54,6 +54,17 @@ else
bindir="$basedir/bin"
fi
+#
+# Use LSB init script functions for printing messages, if possible
+#
+lsb_functions="/lib/lsb/init-functions"
+if test -f $lsb_functions ; then
+ source $lsb_functions
+else
+ alias log_success_msg="echo \ SUCCESS! "
+ alias log_failure_msg="echo \ ERROR! "
+fi
+
PATH=/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin
export PATH
@@ -75,6 +86,20 @@ parse_arguments() {
done
}
+wait_for_pid () {
+ for((i=0; i<35; i++)); do
+ sleep 1
+ test -s $pid_file && i='' && break
+ echo $echo_n ".$echo_c"
+ done
+
+ if test -z "$i" ; then
+ log_success_msg
+ else
+ log_failure_msg
+ fi
+}
+
# Get arguments from the my.cnf file,
# groups [mysqld] [mysql_server] and [mysql.server]
if test -x ./bin/my_print_defaults
@@ -151,14 +176,17 @@ case "$mode" in
then
# Give extra arguments to mysqld with the my.cnf file. This script may
# be overwritten at next upgrade.
+ echo $echo_n "Starting MySQL"
$bindir/mysqld_safe --datadir=$datadir --pid-file=$pid_file >/dev/null 2>&1 &
+ wait_for_pid
+
# Make lock for RedHat / SuSE
if test -w /var/lock/subsys
then
touch /var/lock/subsys/mysql
fi
else
- echo "Can't execute $bindir/mysqld_safe from dir $basedir"
+ log_failure_msg "Can't execute $bindir/mysqld_safe"
fi
;;
@@ -168,29 +196,18 @@ case "$mode" in
if test -s "$pid_file"
then
mysqld_pid=`cat $pid_file`
- echo "Killing mysqld with pid $mysqld_pid"
+ echo $echo_n "Shutting down MySQL"
kill $mysqld_pid
# mysqld should remove the pid_file when it exits, so wait for it.
+ wait_for_pid
- sleep 1
- while [ -s $pid_file -a "$flags" != aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa ]
- do
- [ -z "$flags" ] && echo $echo_n "Wait for mysqld to exit$echo_c" || echo $echo_n ".$echo_c"
- flags=a$flags
- sleep 1
- done
- if [ -s $pid_file ]
- then echo " gave up waiting!"
- elif [ -n "$flags" ]
- then echo " done"
- fi
# delete lock for RedHat / SuSE
if test -f /var/lock/subsys/mysql
then
rm -f /var/lock/subsys/mysql
fi
else
- echo "No mysqld pid file found. Looked for $pid_file."
+ log_failure_msg "MySQL PID file could not be found!"
fi
;;
@@ -199,11 +216,21 @@ case "$mode" in
# running or not, start it again.
$0 stop
$0 start
- ;;
+ ;;
+
+ 'reload')
+ if test -s "$pid_file" ; then
+ mysqld_pid=`cat $pid_file`
+ kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL"
+ touch $pid_file
+ else
+ log_failure_msg "MySQL PID file could not be found!"
+ fi
+ ;;
*)
# usage
- echo "Usage: $0 start|stop|restart"
+ echo "Usage: $0 start|stop|restart|reload"
exit 1
;;
esac