Commit eb7c18d6 authored by unknown's avatar unknown

Merge gweir@bk-internal.mysql.com:/home/bk/mysql-4.0

into mysql.com:/bk/mysql-4.0

parents 945c2c1c 17d4afc6
......@@ -38,7 +38,11 @@ COPYING.LIB
Docs/#manual.texi#
Docs/INSTALL-BINARY
Docs/include.texi
Docs/internals.html
Docs/internals.info
Docs/internals.pdf
Docs/internals.txt
Docs/internals_toc.html
Docs/manual.aux
Docs/manual.cp
Docs/manual.cps
......@@ -221,6 +225,7 @@ extra/replace
extra/resolve_stack_dump
extra/resolveip
gmon.out
hardcopy.0
heap/hp_test1
heap/hp_test2
include/my_config.h
......@@ -251,11 +256,13 @@ libmysql/conf_to_src
libmysql/my_static.h
libmysql/mysys_priv.h
libmysql/net.c
libmysql/vio_priv.h
libmysql_r/*.c
libmysql_r/acconfig.h
libmysql_r/conf_to_src
libmysql_r/my_static.h
libmysql_r/mysys_priv.h
libmysql_r/vio_priv.h
libmysqld/backup_dir
libmysqld/convert.cc
libmysqld/derror.cc
......@@ -363,6 +370,7 @@ linked_libmysqldex_sources
linked_server_sources
linked_tools_sources
locked
man/*.1
mit-pthreads/config.flags
mit-pthreads/include/bits
mit-pthreads/include/pthread/machdep.h
......@@ -382,6 +390,7 @@ myisam/mi_test2
myisam/mi_test3
myisam/mi_test_all
myisam/myisam.log
myisam/myisam_ftdump
myisam/myisamchk
myisam/myisamlog
myisam/myisampack
......@@ -429,6 +438,8 @@ repl-tests/test-repl/sum-wlen-slave.master.
repl-tests/test-repl/sum-wlen-slave.master.re
repl-tests/test-repl/sum-wlen-slave.master.reje
scripts/make_binary_distribution
scripts/make_sharedlib_distribution
scripts/make_win_src_distribution
scripts/msql2mysql
scripts/mysql_config
scripts/mysql_convert_table_format
......@@ -496,6 +507,7 @@ sql/share/norwegian/errmsg.sys
sql/sql_select.cc.orig
sql/sql_yacc.cc
sql/sql_yacc.h
sql/udf_example.so
stamp-h
stamp-h.in
stamp-h1
......@@ -504,6 +516,7 @@ strings/ctype_autoconf.c
strings/ctype_extra_sources.c
support-files/MacOSX/Description.plist
support-files/MacOSX/Info.plist
support-files/MacOSX/ReadMe.txt
support-files/MacOSX/StartupParameters.plist
support-files/MacOSX/postinstall
support-files/MacOSX/preinstall
......@@ -530,16 +543,3 @@ vio/test-ssl
vio/test-sslclient
vio/test-sslserver
vio/viotest-ssl
support-files/MacOSX/ReadMe.txt
Docs/internals.html
Docs/internals.pdf
Docs/internals.txt
Docs/internals_toc.html
scripts/make_win_src_distribution
libmysql/vio_priv.h
libmysql_r/vio_priv.h
hardcopy.0
scripts/make_sharedlib_distribution
sql/udf_example.so
man/*.1
myisam/myisam_ftdump
......@@ -9,6 +9,6 @@ strip=yes
extra_configs="$extra_configs --with-innodb --with-berkeley-db \
--with-embedded-server --enable-thread-safe-client \
--with-openssl --with-vio"
--with-openssl --with-vio --with-raid"
. "$path/FINISH.sh"
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
......@@ -1815,7 +1815,7 @@ AC_CHECK_FUNCS(alarm bmove \
sigset sigthreadmask pthread_sigmask pthread_setprio pthread_setprio_np \
pthread_setschedparam pthread_attr_setprio pthread_attr_setschedparam \
pthread_attr_create pthread_getsequence_np pthread_attr_setstacksize \
pthread_attr_getstacksize \
pthread_attr_getstacksize pthread_key_delete \
pthread_condattr_create rwlock_init pthread_rwlock_rdlock \
fsync fdatasync fchmod getpass getpassphrase initgroups mlockall)
......
......@@ -273,7 +273,9 @@ C_MODE_END
#ifndef CONFIG_SMP
#define CONFIG_SMP
#endif
C_MODE_START
#include <asm/atomic.h>
C_MODE_END
#endif
#include <errno.h> /* Recommended by debian */
/* We need the following to go around a problem with openssl on solaris */
......
......@@ -384,6 +384,11 @@ struct tm *localtime_r(const time_t *clock, struct tm *res);
#define pthread_condattr_destroy pthread_condattr_delete
#endif
/* FSU THREADS */
#if !defined(HAVE_PTHREAD_KEY_DELETE) && !defined(pthread_key_delete)
#define pthread_key_delete(A) pthread_dummy(0)
#endif
#ifdef HAVE_CTHREADS_WRAPPER /* For MacOSX */
#define pthread_cond_destroy(A) pthread_dummy(0)
#define pthread_mutex_destroy(A) pthread_dummy(0)
......
......@@ -1171,23 +1171,36 @@ dict_create_or_check_foreign_constraint_tables(void)
}
/************************************************************************
Adds foreign key definitions to data dictionary tables in the database. */
Adds foreign key definitions to data dictionary tables in the database. We
look at table->foreign_list, and also generate names to constraints that were
not named by the user. A generated constraint has a name of the format
databasename/tablename_ibfk_<number>, where the numbers start from 1, and are
given locally for this table, that is, the number is not global, as in the
old format constraints < 4.0.18 it used to be. */
ulint
dict_create_add_foreigns_to_dictionary(
/*===================================*/
/* out: error code or DB_SUCCESS */
ulint start_id,/* in: if we are actually doing ALTER TABLE
ADD CONSTRAINT, we want to generate constraint
numbers which are bigger than in the table so
far; we number the constraints from
start_id + 1 up; start_id should be set to 0 if
we are creating a new table, or if the table
so far has no constraints for which the name
was generated here */
dict_table_t* table, /* in: table */
trx_t* trx) /* in: transaction */
{
dict_foreign_t* foreign;
que_thr_t* thr;
que_t* graph;
dulint id;
ulint number = start_id + 1;
ulint len;
ulint error;
char* ebuf = dict_foreign_err_buf;
ulint i;
char buf2[50];
char buf[10000];
ut_ad(mutex_own(&(dict_sys->mutex)));
......@@ -1215,18 +1228,18 @@ dict_create_add_foreigns_to_dictionary(
"PROCEDURE ADD_FOREIGN_DEFS_PROC () IS\n"
"BEGIN\n");
/* We allocate the new id from the sequence of table id's */
id = dict_hdr_get_new_id(DICT_HDR_TABLE_ID);
if (foreign->id == NULL) {
/* Generate a new constraint id */
foreign->id = mem_heap_alloc(foreign->heap,
ut_strlen(table->name)
+ 20);
sprintf(foreign->id, "%s_ibfk_%lu", table->name, number);
number++;
}
sprintf(buf2, "%lu_%lu", ut_dulint_get_high(id),
ut_dulint_get_low(id));
foreign->id = mem_heap_alloc(foreign->heap, ut_strlen(buf2) + 1);
ut_memcpy(foreign->id, buf2, ut_strlen(buf2) + 1);
len += sprintf(buf + len,
"INSERT INTO SYS_FOREIGN VALUES('%lu_%lu', '%s', '%s', %lu);\n",
ut_dulint_get_high(id),
ut_dulint_get_low(id),
"INSERT INTO SYS_FOREIGN VALUES('%s', '%s', '%s', %lu);\n",
foreign->id,
table->name,
foreign->referenced_table_name,
foreign->n_fields
......@@ -1235,9 +1248,8 @@ dict_create_add_foreigns_to_dictionary(
for (i = 0; i < foreign->n_fields; i++) {
len += sprintf(buf + len,
"INSERT INTO SYS_FOREIGN_COLS VALUES('%lu_%lu', %lu, '%s', '%s');\n",
ut_dulint_get_high(id),
ut_dulint_get_low(id),
"INSERT INTO SYS_FOREIGN_COLS VALUES('%s', %lu, '%s', '%s');\n",
foreign->id,
i,
foreign->foreign_col_names[i],
foreign->referenced_col_names[i]);
......@@ -1262,29 +1274,30 @@ dict_create_add_foreigns_to_dictionary(
que_graph_free(graph);
if (error == DB_DUPLICATE_KEY) {
mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(dict_foreign_err_buf);
sprintf(ebuf + strlen(ebuf),
" Error in foreign key constraint creation for table %.500s.\n"
"A foreign key constraint of name %.500s\n"
"already exists (note that internally InnoDB adds 'databasename/'\n"
"in front of the user-defined constraint name).\n", table->name, foreign->id);
ut_a(strlen(ebuf) < DICT_FOREIGN_ERR_BUF_LEN);
mutex_exit(&dict_foreign_err_mutex);
return(error);
}
if (error != DB_SUCCESS) {
fprintf(stderr,
"InnoDB: Foreign key constraint creation failed:\n"
"InnoDB: internal error number %lu\n", error);
if (error == DB_DUPLICATE_KEY) {
fprintf(stderr,
"InnoDB: Duplicate key error in system table %s index %s\n",
((dict_index_t*)trx->error_info)->table_name,
((dict_index_t*)trx->error_info)->name);
fprintf(stderr, "%s\n", buf);
fprintf(stderr,
"InnoDB: Maybe the internal data dictionary of InnoDB is\n"
"InnoDB: out-of-sync from the .frm files of your tables.\n"
"InnoDB: See section 15.1 Troubleshooting data dictionary operations\n"
"InnoDB: at http://www.innodb.com/ibman.html\n");
}
mutex_enter(&dict_foreign_err_mutex);
ut_sprintf_timestamp(buf);
sprintf(buf + strlen(buf),
ut_sprintf_timestamp(ebuf);
sprintf(ebuf + strlen(ebuf),
" Internal error in foreign key constraint creation for table %.500s.\n"
"See the MySQL .err log in the datadir for more information.\n", table->name);
mutex_exit(&dict_foreign_err_mutex);
......
This diff is collapsed.
......@@ -430,4 +430,4 @@ dtuple_contains_null(
}
return(FALSE);
}
\ No newline at end of file
}
......@@ -81,12 +81,25 @@ dict_create_or_check_foreign_constraint_tables(void);
/*================================================*/
/* out: DB_SUCCESS or error code */
/************************************************************************
Adds foreign key definitions to data dictionary tables in the database. */
Adds foreign key definitions to data dictionary tables in the database. We
look at table->foreign_list, and also generate names to constraints that were
not named by the user. A generated constraint has a name of the format
databasename/tablename_ibfk_<number>, where the numbers start from 1, and are
given locally for this table, that is, the number is not global, as in the
old format constraints < 4.0.18 it used to be. */
ulint
dict_create_add_foreigns_to_dictionary(
/*===================================*/
/* out: error code or DB_SUCCESS */
ulint start_id,/* in: if we are actually doing ALTER TABLE
ADD CONSTRAINT, we want to generate constraint
numbers which are bigger than in the table so
far; we number the constraints from
start_id + 1 up; start_id should be set to 0 if
we are creating a new table, or if the table
so far has no constraints for which the name
was generated here */
dict_table_t* table, /* in: table */
trx_t* trx); /* in: transaction */
......
......@@ -26,6 +26,14 @@ Created 1/8/1996 Heikki Tuuri
#include "ut0byte.h"
#include "trx0types.h"
/************************************************************************
Get the database name length in a table name. */
ulint
dict_get_db_name_len(
/*=================*/
/* out: database name length */
char* name); /* in: table name in the form dbname '/' tablename */
/*************************************************************************
Accepts a specified string. Comparisons are case-insensitive. */
......
......@@ -85,10 +85,17 @@ ut_str_catenate(
/* out, own: catenated null-terminated string */
char* str1, /* in: null-terminated string */
char* str2); /* in: null-terminated string */
/**************************************************************************
Checks if a null-terminated string contains a certain character. */
ibool
ut_str_contains(
/*============*/
char* str, /* in: null-terminated string */
char c); /* in: character */
#ifndef UNIV_NONINL
#include "ut0mem.ic"
#endif
#endif
......@@ -2185,7 +2185,7 @@ row_is_mysql_tmp_table_name(
{
ulint i;
for (i = 0; i <= ut_strlen(name) - 5; i++) {
for (i = 0; i + 5 <= ut_strlen(name); i++) {
if (ut_memcmp(name + i, (char*)"/#sql", 5) == 0) {
return(TRUE);
......@@ -2221,6 +2221,7 @@ row_rename_table_for_mysql(
ulint keywordlen;
ulint len;
ulint i;
char* db_name;
char buf[10000];
ut_ad(trx->mysql_thread_id == os_thread_get_curr_id());
......@@ -2285,6 +2286,15 @@ row_rename_table_for_mysql(
"PROCEDURE RENAME_TABLE_PROC () IS\n"
"new_table_name CHAR;\n"
"old_table_name CHAR;\n"
"gen_constr_prefix CHAR;\n"
"new_db_name CHAR;\n"
"foreign_id CHAR;\n"
"new_foreign_id CHAR;\n"
"old_db_name_len INT;\n"
"old_t_name_len INT;\n"
"new_db_name_len INT;\n"
"id_len INT;\n"
"found INT;\n"
"BEGIN\n"
"new_table_name :='";
......@@ -2311,32 +2321,94 @@ row_rename_table_for_mysql(
}
str3 = mem_heap_alloc(heap,
1000 + 500 * n_constraints_to_drop);
1000 + 1000 * n_constraints_to_drop);
*str3 = '\0';
sprintf(str3,
"';\n"
"UPDATE SYS_TABLES SET NAME = new_table_name\n"
"WHERE NAME = old_table_name;\n");
db_name = mem_heap_alloc(heap, 1 + dict_get_db_name_len(
old_name));
ut_memcpy(db_name, old_name, dict_get_db_name_len(old_name));
db_name[dict_get_db_name_len(old_name)] = '\0';
/* Internally, old format < 4.0.18 constraints have as the
constraint id <number>_<number>, while new format constraints
have <databasename>/<constraintname>. */
for (i = 0; i < n_constraints_to_drop; i++) {
sprintf(str3 + strlen(str3),
"DELETE FROM SYS_FOREIGN_COLS WHERE ID = '%s';\n"
"DELETE FROM SYS_FOREIGN WHERE ID = '%s';\n",
"DELETE FROM SYS_FOREIGN_COLS WHERE ID = '%s/%s';\n"
"DELETE FROM SYS_FOREIGN WHERE ID = '%s/%s';\n",
db_name, constraints_to_drop[i],
db_name, constraints_to_drop[i]);
if (!ut_str_contains(constraints_to_drop[i], '/')) {
/* If this happens to be an old format
constraint, let us delete it. Since all new
format constraints contain '/', it does no
harm to run these DELETEs anyway. */
sprintf(str3 + strlen(str3),
"DELETE FROM SYS_FOREIGN_COLS WHERE ID = '%s';\n"
"DELETE FROM SYS_FOREIGN WHERE ID = '%s';\n",
constraints_to_drop[i],
constraints_to_drop[i]);
}
}
sprintf(str3 + strlen(str3),
"END;\n");
ut_a(strlen(str3) < 1000 + 500 * n_constraints_to_drop);
ut_a(strlen(str3) < 1000 + 1000 * n_constraints_to_drop);
} else {
str3 = (char*)
"';\n"
"UPDATE SYS_TABLES SET NAME = new_table_name\n"
"WHERE NAME = old_table_name;\n"
"UPDATE SYS_FOREIGN SET FOR_NAME = new_table_name\n"
"WHERE FOR_NAME = old_table_name;\n"
"found := 1;\n"
"old_db_name_len := INSTR(old_table_name, '/') - 1;\n"
"new_db_name_len := INSTR(new_table_name, '/') - 1;\n"
"new_db_name := SUBSTR(new_table_name, 0, new_db_name_len);\n"
"old_t_name_len := LENGTH(old_table_name);\n"
"gen_constr_prefix := CONCAT(old_table_name, '_ibfk_');\n"
"WHILE found = 1 LOOP\n"
" SELECT ID INTO foreign_id\n"
" FROM SYS_FOREIGN\n"
" WHERE FOR_NAME = old_table_name;\n"
" IF (SQL % NOTFOUND) THEN\n"
" found := 0;\n"
" ELSE\n"
" UPDATE SYS_FOREIGN\n"
" SET FOR_NAME = new_table_name\n"
" WHERE ID = foreign_id;\n"
" id_len := LENGTH(foreign_id);\n"
" IF (INSTR(foreign_id, '/') > 0) THEN\n"
" IF (INSTR(foreign_id,\n"
" gen_constr_prefix) > 0)\n"
" THEN\n"
" new_foreign_id :=\n"
" CONCAT(new_table_name,\n"
" SUBSTR(foreign_id, old_t_name_len,\n"
" id_len - old_t_name_len));\n"
" ELSE\n"
" new_foreign_id :=\n"
" CONCAT(new_db_name,\n"
" SUBSTR(foreign_id,\n"
" old_db_name_len,\n"
" id_len - old_db_name_len));\n"
" END IF;\n"
" UPDATE SYS_FOREIGN\n"
" SET ID = new_foreign_id\n"
" WHERE ID = foreign_id;\n"
" UPDATE SYS_FOREIGN_COLS\n"
" SET ID = new_foreign_id\n"
" WHERE ID = foreign_id;\n"
" END IF;\n"
" END IF;\n"
"END LOOP;\n"
"UPDATE SYS_FOREIGN SET REF_NAME = new_table_name\n"
"WHERE REF_NAME = old_table_name;\n"
"END;\n";
......
......@@ -159,7 +159,7 @@ struct sync_thread_struct{
};
/* Number of slots reserved for each OS thread in the sync level array */
#define SYNC_THREAD_N_LEVELS 250
#define SYNC_THREAD_N_LEVELS 10000
struct sync_level_struct{
void* latch; /* pointer to a mutex or an rw-lock; NULL means that
......
......@@ -221,3 +221,27 @@ ut_str_catenate(
return(str);
}
/**************************************************************************
Checks if a null-terminated string contains a certain character. */
ibool
ut_str_contains(
/*============*/
char* str, /* in: null-terminated string */
char c) /* in: character */
{
ulint len;
ulint i;
len = ut_strlen(str);
for (i = 0; i < len; i++) {
if (str[i] == c) {
return(TRUE);
}
}
return(FALSE);
}
\ No newline at end of file
This diff is collapsed.
......@@ -350,3 +350,24 @@ t1 0 PRIMARY 1 Host A NULL NULL NULL BTREE
t1 0 PRIMARY 2 User A 0 NULL NULL BTREE
t1 1 Host 1 Host A NULL NULL NULL BTREE disabled
DROP TABLE t1;
create table t1 (name char(15));
insert into t1 (name) values ("current");
create database mysqltest;
create table mysqltest.t1 (name char(15));
insert into mysqltest.t1 (name) values ("mysqltest");
select * from t1;
name
current
select * from mysqltest.t1;
name
mysqltest
alter table t1 rename mysqltest.t1;
Table 't1' already exists
select * from t1;
name
current
select * from mysqltest.t1;
name
mysqltest
drop table t1;
drop database mysqltest;
......@@ -41,3 +41,21 @@ pi() sin(pi()/2) cos(pi()/2) abs(tan(pi())) cot(1) asin(1) acos(0) atan(1)
select degrees(pi()),radians(360);
degrees(pi()) radians(360)
180 6.2831853071796
SELECT ACOS(1.0);
ACOS(1.0)
0.000000
SELECT ASIN(1.0);
ASIN(1.0)
1.570796
SELECT ACOS(0.2*5.0);
ACOS(0.2*5.0)
0.000000
SELECT ACOS(0.5*2.0);
ACOS(0.5*2.0)
0.000000
SELECT ASIN(0.8+0.2);
ASIN(0.8+0.2)
1.570796
SELECT ASIN(1.2-0.2);
ASIN(1.2-0.2)
1.570796
......@@ -592,3 +592,34 @@ CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNE
INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121);
INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1;
drop table t1,t2;
CREATE TABLE t1(
Month date NOT NULL,
Type tinyint(3) unsigned NOT NULL auto_increment,
Field int(10) unsigned NOT NULL,
Count int(10) unsigned NOT NULL,
UNIQUE KEY Month (Month,Type,Field)
);
insert into t1 Values
(20030901, 1, 1, 100),
(20030901, 1, 2, 100),
(20030901, 2, 1, 100),
(20030901, 2, 2, 100),
(20030901, 3, 1, 100);
select * from t1;
Month Type Field Count
2003-09-01 1 1 100
2003-09-01 1 2 100
2003-09-01 2 1 100
2003-09-01 2 2 100
2003-09-01 3 1 100
Select null, Field, Count From t1 Where Month=20030901 and Type=2;
NULL Field Count
NULL 1 100
NULL 2 100
create table t2(No int not null, Field int not null, Count int not null);
insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2;
select * from t2;
No Field Count
0 1 100
0 2 100
drop table t1, t2;
......@@ -54,6 +54,12 @@ insert into t1 values ("abirvalg");
SET INSERT_ID=1;
SET TIMESTAMP=1000000000;
insert into t2 values ();
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-1-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-2-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-3-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-4-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-5-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
LOAD DATA LOCAL INFILE 'MYSQL_TEST_DIR/var/tmp/words.dat-6-1' INTO TABLE t1 FIELDS TERMINATED BY '\t' ENCLOSED BY '' ESCAPED BY '\\' LINES TERMINATED BY '\n' STARTING BY '' (word);
SET TIMESTAMP=1000000000;
insert into t1 values ("Alas");
......@@ -63,18 +69,7 @@ SET TIMESTAMP=1000000000;
insert into t1 values ("Alas");
--- --database --
use test;
SET TIMESTAMP=1000000000;
create table t1 (word varchar(20));
SET TIMESTAMP=1000000000;
create table t2 (id int auto_increment not null primary key);
SET TIMESTAMP=1000000000;
insert into t1 values ("abirvalg");
SET INSERT_ID=1;
SET TIMESTAMP=1000000000;
insert into t2 values ();
SET TIMESTAMP=1000000000;
insert into t1 values ("Alas");
--- --position --
use test;
......
create database test_raid;
create table test_raid.r1 (i int) raid_type=1;
create table test_raid.r2 (i int) raid_type=1 raid_chunks=32;
drop database test_raid;
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (
......
select * from mysql.user as t1, mysql.user as t2, mysql.user as t3, mysql.user as t4, mysql.user as t5, mysql.user as t6, mysql.user as t7, mysql.user as t8;
\ No newline at end of file
......@@ -204,3 +204,20 @@ LOCK TABLES t1 WRITE;
ALTER TABLE t1 DISABLE KEYS;
SHOW INDEX FROM t1;
DROP TABLE t1;
#
# Bug #2628: 'alter table t1 rename mysqltest.t1' silently drops mysqltest.t1
# if it exists
#
create table t1 (name char(15));
insert into t1 (name) values ("current");
create database mysqltest;
create table mysqltest.t1 (name char(15));
insert into mysqltest.t1 (name) values ("mysqltest");
select * from t1;
select * from mysqltest.t1;
--error 1050
alter table t1 rename mysqltest.t1;
select * from t1;
select * from mysqltest.t1;
drop table t1;
drop database mysqltest;
......@@ -17,3 +17,14 @@ set @@rand_seed1=10000000,@@rand_seed2=1000000;
select rand(999999),rand();
select pi(),sin(pi()/2),cos(pi()/2),abs(tan(pi())),cot(1),asin(1),acos(0),atan(1);
select degrees(pi()),radians(360);
#
# Bug #2338 Trignometric arithmatic problems
#
SELECT ACOS(1.0);
SELECT ASIN(1.0);
SELECT ACOS(0.2*5.0);
SELECT ACOS(0.5*2.0);
SELECT ASIN(0.8+0.2);
SELECT ASIN(1.2-0.2);
--init-file=$MYSQL_TEST_DIR/std_data/init_file.dat
#
# This is a regression test for bug #2526 "--init-file crashes MySQL if it
# contains a large select"
#
# See mysql-test/std_data/init_file.dat and
# mysql-test/t/init_file-master.opt for the actual test
#
......@@ -132,3 +132,34 @@ CREATE TABLE t2 ( USID INTEGER UNSIGNED AUTO_INCREMENT, ServerID TINYINT UNSIGNE
INSERT INTO t1 VALUES (39,42,'Access-Granted','46','491721000045',2130706433,17690,NULL,NULL,'Localnet','491721000045','49172200000',754974766,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'2003-07-18 00:11:21',NULL,NULL,20030718001121);
INSERT INTO t2 SELECT USID, ServerID, State, SessionID, User, NASAddr, NASPort, NASPortType, ConnectSpeed, CarrierType, CallingStationID, CalledStationID, AssignedAddr, SessionTime, PacketsIn, OctetsIn, PacketsOut, OctetsOut, TerminateCause, UnauthTime, AccessRequestTime, AcctStartTime, AcctLastTime, LastModification from t1 LIMIT 1;
drop table t1,t2;
#
# Another problem from Bug #2012
#
CREATE TABLE t1(
Month date NOT NULL,
Type tinyint(3) unsigned NOT NULL auto_increment,
Field int(10) unsigned NOT NULL,
Count int(10) unsigned NOT NULL,
UNIQUE KEY Month (Month,Type,Field)
);
insert into t1 Values
(20030901, 1, 1, 100),
(20030901, 1, 2, 100),
(20030901, 2, 1, 100),
(20030901, 2, 2, 100),
(20030901, 3, 1, 100);
select * from t1;
Select null, Field, Count From t1 Where Month=20030901 and Type=2;
create table t2(No int not null, Field int not null, Count int not null);
insert into t2 Select null, Field, Count From t1 Where Month=20030901 and Type=2;
select * from t2;
drop table t1, t2;
......@@ -64,10 +64,6 @@ select "--- --position --" as "";
# These are tests for remote binlog.
# They should return the same as previous test.
# But now they are not. V. Vagin should fix this.
# We test all the same options second time since code for remote case is
# essentially different. If code for both cases will be unified we'll be
# able to throw out most of this.
--disable_query_log
select "--- Remote --" as "";
......
......@@ -9,6 +9,7 @@ enable_query_log;
create database test_raid;
create table test_raid.r1 (i int) raid_type=1;
create table test_raid.r2 (i int) raid_type=1 raid_chunks=32;
drop database test_raid;
DROP TABLE IF EXISTS t1,t2;
CREATE TABLE t1 (
......
This diff is collapsed.
......@@ -539,7 +539,7 @@ innobase_query_caching_of_table_permitted(
if (thd->variables.tx_isolation == ISO_SERIALIZABLE) {
/* In the SERIALIZABLE mode we add LOCK IN SHARE MODE to every
plain SELECT */
plain SELECT if AUTOCOMMIT is not on. */
return((my_bool)FALSE);
}
......@@ -4483,11 +4483,17 @@ ha_innobase::external_lock(
}
if (trx->isolation_level == TRX_ISO_SERIALIZABLE
&& prebuilt->select_lock_type == LOCK_NONE) {
&& prebuilt->select_lock_type == LOCK_NONE
&& (thd->options
& (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN))) {
/* To get serializable execution we let InnoDB
/* To get serializable execution, we let InnoDB
conceptually add 'LOCK IN SHARE MODE' to all SELECTs
which otherwise would have been consistent reads */
which otherwise would have been consistent reads. An
exception is consistent reads in the AUTOCOMMIT=1 mode:
we know that they are read-only transactions, and they
can be serialized also if performed as consistent
reads. */
prebuilt->select_lock_type = LOCK_S;
}
......
......@@ -551,7 +551,8 @@ double Item_func_pow::val()
double Item_func_acos::val()
{
double value=args[0]->val();
// the volatile's for BUG #2338 to calm optimizer down (because of gcc's bug)
volatile double value=args[0]->val();
if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0))))
return 0.0;
return fix_result(acos(value));
......@@ -559,7 +560,8 @@ double Item_func_acos::val()
double Item_func_asin::val()
{
double value=args[0]->val();
// the volatile's for BUG #2338 to calm optimizer down (because of gcc's bug)
volatile double value=args[0]->val();
if ((null_value=(args[0]->null_value || (value < -1.0 || value > 1.0))))
return 0.0;
return fix_result(asin(value));
......
......@@ -1189,7 +1189,7 @@ Load_log_event::Load_log_event(THD* thd_arg, sql_exchange* ex,
num_fields(0),fields(0),
field_lens(0),field_block_len(0),
table_name(table_name_arg ? table_name_arg : ""),
db(db_arg), fname(ex->file_name)
db(db_arg), fname(ex->file_name), local_fname(FALSE)
{
time_t end_time;
time(&end_time);
......@@ -1265,7 +1265,7 @@ Load_log_event::Load_log_event(const char* buf, int event_len,
bool old_format)
:Log_event(buf, old_format),num_fields(0),fields(0),
field_lens(0),field_block_len(0),
table_name(0),db(0),fname(0)
table_name(0),db(0),fname(0),local_fname(FALSE)
{
if (!event_len) // derived class, will call copy_log_event() itself
return;
......
......@@ -411,17 +411,19 @@ class Load_log_event: public Log_event
const char* fname;
uint32 skip_lines;
sql_ex_info sql_ex;
bool local_fname;
/* fname doesn't point to memory inside Log_event::temp_buf */
void set_fname_outside_temp_buf(const char *afname, uint alen)
{
fname= afname;
fname_len= alen;
local_fname= true;
}
/* fname doesn't point to memory inside Log_event::temp_buf */
int check_fname_outside_temp_buf()
{
return fname < temp_buf || fname > temp_buf+ cached_event_len;
return local_fname;
}
#ifndef MYSQL_CLIENT
......
......@@ -495,6 +495,8 @@ bool select_send::send_data(List<Item> &items)
}
}
thd->sent_row_count++;
if (!thd->net.vio)
DBUG_RETURN(0);
bool error=my_net_write(&thd->net,(char*) packet->ptr(),packet->length());
DBUG_RETURN(error);
}
......
......@@ -219,7 +219,7 @@ int mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent)
/*
Removes files with known extensions plus all found subdirectories that
are 2 digits (raid directories).
are 2 hex digits (raid directories).
thd MUST be set when calling this function!
*/
......@@ -245,7 +245,10 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db,
DBUG_PRINT("info",("Examining: %s", file->name));
/* Check if file is a raid directory */
if (isdigit(file->name[0]) && isdigit(file->name[1]) &&
if ((isdigit(file->name[0]) ||
(file->name[0] >= 'a' && file->name[0] <= 'f')) &&
(isdigit(file->name[1]) ||
(file->name[1] >= 'a' && file->name[1] <= 'f')) &&
!file->name[2] && !level)
{
char newpath[FN_REFLEN];
......
......@@ -2596,9 +2596,15 @@ store_val_in_field(Field *field,Item *item)
bool error;
THD *thd=current_thd;
ha_rows cuted_fields=thd->cuted_fields;
/*
we should restore old value of count_cuted_fields because
store_val_in_field can be called from mysql_insert
with select_insert, which make count_cuted_fields= 1
*/
bool old_count_cuted_fields= thd->count_cuted_fields;
thd->count_cuted_fields=1;
error= item->save_in_field(field, 1);
thd->count_cuted_fields=0;
thd->count_cuted_fields= old_count_cuted_fields;
return error || cuted_fields != thd->cuted_fields;
}
......@@ -2823,6 +2829,8 @@ make_join_readinfo(JOIN *join,uint options)
{
uint i;
SELECT_LEX *select_lex = &(join->thd->lex.select_lex);
bool statistics= test(!(join->select_options & SELECT_DESCRIBE));
DBUG_ENTER("make_join_readinfo");
for (i=join->const_tables ; i < join->tables ; i++)
......@@ -2907,7 +2915,8 @@ make_join_readinfo(JOIN *join,uint options)
{
select_lex->options|=QUERY_NO_GOOD_INDEX_USED;
tab->read_first_record= join_init_quick_read_record;
statistic_increment(select_range_check_count, &LOCK_status);
if (statistics)
statistic_increment(select_range_check_count, &LOCK_status);
}
else
{
......@@ -2916,24 +2925,28 @@ make_join_readinfo(JOIN *join,uint options)
{
if (tab->select && tab->select->quick)
{
statistic_increment(select_range_count, &LOCK_status);
if (statistics)
statistic_increment(select_range_count, &LOCK_status);
}
else
{
select_lex->options|=QUERY_NO_INDEX_USED;
statistic_increment(select_scan_count, &LOCK_status);
if (statistics)
statistic_increment(select_scan_count, &LOCK_status);
}
}
else
{
if (tab->select && tab->select->quick)
{
statistic_increment(select_full_range_join_count, &LOCK_status);
if (statistics)
statistic_increment(select_full_range_join_count, &LOCK_status);
}
else
{
select_lex->options|=QUERY_NO_INDEX_USED;
statistic_increment(select_full_join_count, &LOCK_status);
if (statistics)
statistic_increment(select_full_join_count, &LOCK_status);
}
}
if (!table->no_keyread)
......
......@@ -1478,8 +1478,12 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
alias= (lower_case_table_names == 2) ? table_list->alias : table_name;
db=table_list->db;
if (!new_db || !strcmp(new_db,db))
new_db=db;
if (!new_db ||
lower_case_table_names && !my_strcasecmp(new_db, db) ||
!lower_case_table_names && !strcmp(new_db, db))
{
new_db= db;
}
used_fields=create_info->used_fields;
mysql_ha_closeall(thd, table_list);
......@@ -1491,7 +1495,6 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
{
strmov(new_name_buff,new_name);
strmov(new_alias= new_alias_buff, new_name);
fn_same(new_name_buff,table_name,3);
if (lower_case_table_names)
{
if (lower_case_table_names != 2)
......@@ -1501,11 +1504,18 @@ int mysql_alter_table(THD *thd,char *new_db, char *new_name,
}
casedn_str(new_name);
}
if ((lower_case_table_names &&
!my_strcasecmp(new_name_buff,table_name)) ||
(!lower_case_table_names &&
if (new_db == db &&
(lower_case_table_names &&
!my_strcasecmp(new_name_buff,table_name) ||
!lower_case_table_names &&
!strcmp(new_name_buff,table_name)))
new_alias= new_name= table_name; // No change. Make later check easier
{
/*
Source and destination table names are equal: make later check
easier.
*/
new_alias= new_name= table_name;
}
else
{
if (table->tmp_table)
......
......@@ -116,6 +116,7 @@ void udf_init()
udf_func *tmp;
TABLE_LIST tables;
READ_RECORD read_record_info;
TABLE *table;
int error;
DBUG_ENTER("ufd_init");
......@@ -148,13 +149,11 @@ void udf_init()
if (open_and_lock_tables(new_thd, &tables))
{
DBUG_PRINT("error",("Can't open udf table"));
sql_print_error("Can't open mysql/func table");
close_thread_tables(new_thd);
delete new_thd;
DBUG_VOID_RETURN;
sql_print_error("Can't open the mysql/func table. Please run the mysql_install_db script to create it.");
goto end;
}
TABLE *table = tables.table;
table= tables.table;
init_read_record(&read_record_info, new_thd, table, NULL,1,0);
while (!(error = read_record_info.read_record(&read_record_info)))
{
......@@ -200,6 +199,8 @@ void udf_init()
sql_print_error(ER(ER_GET_ERRNO), my_errno);
end_read_record(&read_record_info);
new_thd->version--; // Force close to free memory
end:
close_thread_tables(new_thd);
delete new_thd;
/* Remember that we don't have a THD */
......
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