From 059ec5e3861c8b888f1276ac46787c21f9a74c99 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Feb 2005 15:20:38 +0100 Subject: use EXTRA_DIST instead of noinst_HEADERS --- ndb/test/run-test/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ndb/test/run-test/Makefile.am b/ndb/test/run-test/Makefile.am index 127ef22f37c..6b3ba0bff09 100644 --- a/ndb/test/run-test/Makefile.am +++ b/ndb/test/run-test/Makefile.am @@ -10,7 +10,7 @@ test_DATA=daily-basic-tests.txt daily-devel-tests.txt test_SCRIPTS=atrt-analyze-result.sh atrt-gather-result.sh atrt-setup.sh \ atrt-clear-result.sh make-config.sh make-index.sh make-html-reports.sh -atrt_SOURCES = main.cpp +atrt_SOURCES = main.cpp run-test.hpp INCLUDES_LOC = -I$(top_srcdir)/ndb/test/include LDADD_LOC = $(top_builddir)/ndb/test/src/libNDBT.a \ $(top_builddir)/ndb/src/libndbclient.la \ @@ -21,7 +21,7 @@ LDADD_LOC = $(top_builddir)/ndb/test/src/libNDBT.a \ wrappersdir=$(prefix)/bin wrappers_SCRIPTS=atrt-testBackup atrt-mysql-test-run -noinst_HEADERS = run-test.hpp $(test_DATA) $(test_SCRIPTS) $(wrappers_SCRIPTS) README.ATRT +EXTRA_DIST = $(test_DATA) $(test_SCRIPTS) $(wrappers_SCRIPTS) README.ATRT # Don't update the files from bitkeeper %::SCCS/s.% -- cgit v1.2.1 From 1a369b50772ab9e495612aad5259f0b6fc81686e Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Feb 2005 23:42:30 +0100 Subject: remove obsolete substitution --- configure.in | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/configure.in b/configure.in index e6ae8f8f70b..a09823e723a 100644 --- a/configure.in +++ b/configure.in @@ -56,28 +56,6 @@ czech danish dutch english estonian french german greek hungarian \ italian japanese korean norwegian norwegian-ny polish portuguese \ romanian russian serbian slovak spanish swedish ukrainian" - -# Generate make rules for all error messages -AVAILABLE_LANGUAGES_ERRORS= -AVAILABLE_LANGUAGES_ERRORS_RULES=$srcdir/ac_available_languages_fragment -rm -f $AVAILABLE_LANGUAGES_ERRORS_RULES -for i in $AVAILABLE_LANGUAGES -do - AVAILABLE_LANGUAGES_ERRORS="$AVAILABLE_LANGUAGES_ERRORS $i/errmsg.sys" - case $host_os in - netware*) - echo "$i/errmsg.sys: $i/errmsg.txt - \$(top_builddir)/extra/comp_err.linux -C\$(srcdir)/charsets/ $i/errmsg.txt $i/errmsg.sys" \ - >> $AVAILABLE_LANGUAGES_ERRORS_RULES - ;; - *) - echo "$i/errmsg.sys: $i/errmsg.txt - \$(top_builddir)/extra/comp_err -C\$(srcdir)/charsets/ $i/errmsg.txt $i/errmsg.sys" \ - >> $AVAILABLE_LANGUAGES_ERRORS_RULES - ;; - esac -done - ##### ##### @@ -93,7 +71,6 @@ AC_DEFINE_UNQUOTED([DOT_FRM_VERSION], [$DOT_FRM_VERSION], AC_SUBST(SHARED_LIB_VERSION) AC_SUBST(AVAILABLE_LANGUAGES) AC_SUBST(AVAILABLE_LANGUAGES_ERRORS) -AC_SUBST_FILE(AVAILABLE_LANGUAGES_ERRORS_RULES) AC_SUBST([NDB_VERSION_MAJOR]) AC_SUBST([NDB_VERSION_MINOR]) -- cgit v1.2.1 From 4485e15c5fe423beb927fe3cb5a6009d53d93123 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Feb 2005 21:57:37 +0200 Subject: Fixed mistyping (thnx to Konstantin) sql/sql_cache.cc: Fixed mistyping --- sql/sql_cache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index f503a63e752..d729a6cc301 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -1337,7 +1337,7 @@ ulong Query_cache::init_cache() init(); approx_additional_data_size = (sizeof(Query_cache) + sizeof(gptr)*(def_query_hash_size+ - def_query_hash_size)); + def_table_hash_size)); if (query_cache_size < approx_additional_data_size) goto err; -- cgit v1.2.1 From a3dc4deb9971ee41b8c317272d848bfd98754a1d Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 12 Feb 2005 00:05:13 +0100 Subject: make LOAD INDEX to work --- myisam/mi_preload.c | 8 ++++---- mysql-test/r/preload.result | 28 ++++++++++++++-------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/myisam/mi_preload.c b/myisam/mi_preload.c index 5e03d489efe..317ab4ad7fe 100644 --- a/myisam/mi_preload.c +++ b/myisam/mi_preload.c @@ -71,15 +71,15 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) if (flush_key_blocks(share->key_cache,share->kfile, FLUSH_RELEASE)) goto err; - + do { /* Read the next block of index file into the preload buffer */ if ((my_off_t) length > (key_file_length-pos)) length= (ulong) (key_file_length-pos); - if (my_pread(share->kfile, (byte*) buff, length, pos, MYF(MY_FAE))) + if (my_pread(share->kfile, (byte*) buff, length, pos, MYF(MY_FAE|MY_FNABP))) goto err; - + if (ignore_leaves) { uchar *end= buff+length; @@ -88,7 +88,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) if (mi_test_if_nod(buff)) { if (key_cache_insert(share->key_cache, - share->kfile, pos, DFLT_INIT_HITS, + share->kfile, pos, DFLT_INIT_HITS, (byte*) buff, block_length)) goto err; } diff --git a/mysql-test/r/preload.result b/mysql-test/r/preload.result index f0b99a8d6f1..7237a0da7e0 100644 --- a/mysql-test/r/preload.result +++ b/mysql-test/r/preload.result @@ -74,15 +74,15 @@ Table Op Msg_type Msg_text test.t1 preload_keys status OK show status like "key_read%"; Variable_name Value -Key_read_requests 0 -Key_reads 0 +Key_read_requests 581 +Key_reads 581 select count(*) from t1 where b = 'test1'; count(*) 4181 show status like "key_read%"; Variable_name Value -Key_read_requests 217 -Key_reads 45 +Key_read_requests 798 +Key_reads 581 flush tables; flush status; show status like "key_read%"; @@ -98,15 +98,15 @@ Table Op Msg_type Msg_text test.t1 preload_keys status OK show status like "key_read%"; Variable_name Value -Key_read_requests 0 -Key_reads 0 +Key_read_requests 10 +Key_reads 10 select count(*) from t1 where b = 'test1'; count(*) 4181 show status like "key_read%"; Variable_name Value -Key_read_requests 217 -Key_reads 45 +Key_read_requests 227 +Key_reads 52 flush tables; flush status; show status like "key_read%"; @@ -123,8 +123,8 @@ test.t1 preload_keys status OK test.t2 preload_keys status OK show status like "key_read%"; Variable_name Value -Key_read_requests 0 -Key_reads 0 +Key_read_requests 587 +Key_reads 587 select count(*) from t1 where b = 'test1'; count(*) 4181 @@ -133,8 +133,8 @@ count(*) 2584 show status like "key_read%"; Variable_name Value -Key_read_requests 351 -Key_reads 73 +Key_read_requests 938 +Key_reads 613 flush tables; flush status; show status like "key_read%"; @@ -147,8 +147,8 @@ test.t3 preload_keys error Table 'test.t3' doesn't exist test.t2 preload_keys status OK show status like "key_read%"; Variable_name Value -Key_read_requests 0 -Key_reads 0 +Key_read_requests 355 +Key_reads 355 flush tables; flush status; show status like "key_read%"; -- cgit v1.2.1 From 36a1d4e1dc2ac205e3abdf33f54bbd5c640f9514 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 12 Feb 2005 16:27:22 +0400 Subject: Bug#8235 Connection collation change & table create with default result in crash mysql-test/r/ctype_ucs.result: Test case mysql-test/t/ctype_ucs.test: Test case sql/field.cc: Fixed minus check to be UCS2-compatible strings/ctype-ucs2.c: Missing my_scan_ucs2() was added. --- mysql-test/r/ctype_ucs.result | 14 ++++++++++++++ mysql-test/t/ctype_ucs.test | 21 +++++++++++++++++++++ sql/field.cc | 12 ++++++++++-- strings/ctype-ucs2.c | 25 ++++++++++++++++++++++++- 4 files changed, 69 insertions(+), 3 deletions(-) diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 3f50d9dfa1b..0807cfabf2a 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -613,3 +613,17 @@ ucs2_bin 00610009 ucs2_bin 0061 ucs2_bin 00610020 drop table t1; +SET NAMES latin1; +SET collation_connection='ucs2_swedish_ci'; +CREATE TABLE t1 (Field1 int(10) default '0'); +INSERT INTO t1 VALUES ('-1'); +SELECT * FROM t1; +Field1 +-1 +DROP TABLE t1; +CREATE TABLE t1 (Field1 int(10) unsigned default '0'); +INSERT INTO t1 VALUES ('-1'); +Warnings: +Warning 1265 Data truncated for column 'Field1' at row 1 +DROP TABLE t1; +SET NAMES latin1; diff --git a/mysql-test/t/ctype_ucs.test b/mysql-test/t/ctype_ucs.test index 1a0ba82d6ff..38956e12a3b 100644 --- a/mysql-test/t/ctype_ucs.test +++ b/mysql-test/t/ctype_ucs.test @@ -390,3 +390,24 @@ SET collation_connection='ucs2_general_ci'; SET NAMES latin1; SET collation_connection='ucs2_bin'; -- source include/ctype_filesort.inc + +SET NAMES latin1; +# +# Bug#8235 +# +# This bug also helped to find another problem that +# INSERT of a UCS2 string containing a negative number +# into a unsigned int column didn't produce warnings. +# This test covers both problems. +# +SET collation_connection='ucs2_swedish_ci'; +CREATE TABLE t1 (Field1 int(10) default '0'); +# no warnings, negative numbers are allowed +INSERT INTO t1 VALUES ('-1'); +SELECT * FROM t1; +DROP TABLE t1; +CREATE TABLE t1 (Field1 int(10) unsigned default '0'); +# this should generate a "Data truncated" warning +INSERT INTO t1 VALUES ('-1'); +DROP TABLE t1; +SET NAMES latin1; diff --git a/sql/field.cc b/sql/field.cc index e2f75034e52..fa0e202d513 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1777,6 +1777,14 @@ void Field_medium::sql_type(String &res) const ****************************************************************************/ +static bool test_if_minus(CHARSET_INFO *cs, + const char *s, const char *e) +{ + my_wc_t wc; + return cs->cset->mb_wc(cs, &wc, (uchar*) s, (uchar*) e) > 0 && wc == '-'; +} + + int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) { long tmp; @@ -1790,7 +1798,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) if (unsigned_flag) { - if (!len || *from == '-') + if (!len || test_if_minus(cs, from, from + len)) { tmp=0; // Set negative to 0 my_errno=ERANGE; @@ -2086,7 +2094,7 @@ int Field_longlong::store(const char *from,uint len,CHARSET_INFO *cs) my_errno=0; if (unsigned_flag) { - if (!len || *from == '-') + if (!len || test_if_minus(cs, from, from + len)) { tmp=0; // Set negative to 0 my_errno= ERANGE; diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index ea11f8816a5..e92704b83d7 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -1480,6 +1480,29 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs, return 0; } + +ulong my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *str, const char *end, int sequence_type) +{ + const char *str0= str; + end--; /* for easier loop condition, because of two bytes per character */ + + switch (sequence_type) + { + case MY_SEQ_SPACES: + for ( ; str < end; str+= 2) + { + if (str[0] != '\0' || str[1] != ' ') + break; + } + return str - str0; + default: + return 0; + } +} + + + static MY_COLLATION_HANDLER my_collation_ucs2_general_ci_handler = { NULL, /* init */ @@ -1534,7 +1557,7 @@ MY_CHARSET_HANDLER my_charset_ucs2_handler= my_strntoull_ucs2, my_strntod_ucs2, my_strtoll10_ucs2, - my_scan_8bit + my_scan_ucs2 }; -- cgit v1.2.1 From b1951b7449f27e826392f6feb7cec73ec78990c2 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 12 Feb 2005 20:09:40 +0400 Subject: Fix for bug #8477 (Embedded query_cache test crashes) libmysqld/emb_qcache.cc: Querycahce data transition fixed --- libmysqld/emb_qcache.cc | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/libmysqld/emb_qcache.cc b/libmysqld/emb_qcache.cc index 7d83023abd5..2d3d82b7952 100644 --- a/libmysqld/emb_qcache.cc +++ b/libmysqld/emb_qcache.cc @@ -71,9 +71,11 @@ void Querycache_stream::store_int(uint i) cur_data+= 4; return; } - memcpy(cur_data, &i, rest_len); + char buf[4]; + int4store(buf, i); + memcpy(cur_data, buf, rest_len); use_next_block(); - memcpy(cur_data, ((byte*)&i)+rest_len, 4-rest_len); + memcpy(cur_data, buf+rest_len, 4-rest_len); cur_data+= 4-rest_len; } @@ -186,10 +188,12 @@ uint Querycache_stream::load_int() cur_data+= 4; return result; } - memcpy(&result, cur_data, rest_len); + char buf[4]; + memcpy(buf, cur_data, rest_len); use_next_block(); - memcpy(((byte*)&result)+rest_len, cur_data, 4-rest_len); + memcpy(buf+rest_len, cur_data, 4-rest_len); cur_data+= 4-rest_len; + result= uint4korr(buf); return result; } @@ -270,10 +274,10 @@ int Querycache_stream::load_column(MEM_ROOT *alloc, char** column) return 0; } len--; - if (!(*column= (char *)alloc_root(alloc, len + 4 + 1))) + if (!(*column= (char *)alloc_root(alloc, len + sizeof(uint) + 1))) return 1; - int4store(*column, len); - (*column)+= 4; + *((uint*)*column)= len; + (*column)+= sizeof(uint); load_str_only(*column, len); return 1; } -- cgit v1.2.1 From cb214d814ae19d3b7206ff0c9f6f21479ca7daf1 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 12 Feb 2005 19:17:33 +0100 Subject: new static archive_inited variable, so that archive_db_end() will do something only if archive_db_init() was run before (protection against destroying uninited mutex in the case where mysqld fails early at startup (before archive_db_init() was called) and then calls archive_db_end() to clean up). sql/examples/ha_archive.cc: new static archive_inited variable, so that archive_db_end() will do something only if archive_db_init() was run before. --- sql/examples/ha_archive.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sql/examples/ha_archive.cc b/sql/examples/ha_archive.cc index 491056d0e59..bc4af0c7dc7 100644 --- a/sql/examples/ha_archive.cc +++ b/sql/examples/ha_archive.cc @@ -114,6 +114,8 @@ data - The data is stored in a "row +blobs" format. */ +/* If the archive storage engine has been inited */ +static bool archive_inited= 0; /* Variables for archive share methods */ pthread_mutex_t archive_mutex; static HASH archive_open_tables; @@ -157,6 +159,7 @@ static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length, bool archive_db_init() { + archive_inited= 1; VOID(pthread_mutex_init(&archive_mutex, MY_MUTEX_INIT_FAST)); return (hash_init(&archive_open_tables, system_charset_info, 32, 0, 0, (hash_get_key) archive_get_key, 0, 0)); @@ -176,8 +179,12 @@ bool archive_db_init() bool archive_db_end() { - hash_free(&archive_open_tables); - VOID(pthread_mutex_destroy(&archive_mutex)); + if (archive_inited) + { + hash_free(&archive_open_tables); + VOID(pthread_mutex_destroy(&archive_mutex)); + } + archive_inited= 0; return FALSE; } -- cgit v1.2.1 From 113078d27681c6d42ad212498c5692e7f832d1aa Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 13 Feb 2005 21:00:07 +0200 Subject: row0mysql.c: Backport the column prefix memory corruption fix from 5.0 innobase/row/row0mysql.c: Backport the column prefix memory corruption fix from 5.0 --- innobase/row/row0mysql.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 1ab7bb1deb0..a915200161f 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -399,7 +399,7 @@ row_create_prebuilt( prebuilt->sel_graph = NULL; prebuilt->search_tuple = dtuple_create(heap, - dict_table_get_n_cols(table)); + 2 * dict_table_get_n_cols(table)); clust_index = dict_table_get_first_index(table); -- cgit v1.2.1 From 0b751b4042ea671ce732b7bcc7104071865e11b3 Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 13 Feb 2005 22:35:52 +0000 Subject: Bug#2435 Alter handling for UNION syntax Tests for UNION and parentheses mysql-test/r/union.result: Bug#2435 Tests for UNION and parentheses mysql-test/t/union.test: Bug#2435 Tests for UNION and parentheses sql/sql_yacc.yy: Bug#2435 Amend handling of UNION with parentheses. --- mysql-test/r/union.result | 22 ++++++++++++++++++++++ mysql-test/t/union.test | 12 ++++++++++++ sql/sql_yacc.yy | 35 ++++++++++++++++++++++++++++------- 3 files changed, 62 insertions(+), 7 deletions(-) diff --git a/mysql-test/r/union.result b/mysql-test/r/union.result index 115ef6a47f9..f58f0f5b0ac 100644 --- a/mysql-test/r/union.result +++ b/mysql-test/r/union.result @@ -1173,3 +1173,25 @@ show columns from t4; Field Type Null Key Default Extra sdate date YES NULL drop table t1, t2, t3, t4; +create table t1 (a int not null, b char (10) not null); +insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c'); +select * from ((select * from t1 limit 1)) a; +a b +1 a +select * from ((select * from t1 limit 1) union (select * from t1 limit 1)) a; +a b +1 a +select * from ((select * from t1 limit 1) union (select * from t1 limit 1) union (select * from t1 limit 1)) a; +a b +1 a +select * from ((((select * from t1))) union (select * from t1) union (select * from t1)) a; +a b +1 a +2 b +3 c +select * from ((select * from t1) union (((select * from t1))) union (select * from t1)) a; +a b +1 a +2 b +3 c +drop table t1; diff --git a/mysql-test/t/union.test b/mysql-test/t/union.test index 90b2197603b..82f26f63254 100644 --- a/mysql-test/t/union.test +++ b/mysql-test/t/union.test @@ -699,3 +699,15 @@ union order by sdate; show columns from t4; drop table t1, t2, t3, t4; + +# +# Bug #2435 UNION with parentheses not supported +# +create table t1 (a int not null, b char (10) not null); +insert into t1 values(1,'a'),(2,'b'),(3,'c'),(3,'c'); +select * from ((select * from t1 limit 1)) a; +select * from ((select * from t1 limit 1) union (select * from t1 limit 1)) a; +select * from ((select * from t1 limit 1) union (select * from t1 limit 1) union (select * from t1 limit 1)) a; +select * from ((((select * from t1))) union (select * from t1) union (select * from t1)) a; +select * from ((select * from t1) union (((select * from t1))) union (select * from t1)) a; +drop table t1; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index e70efe14557..988323811ac 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -2389,7 +2389,10 @@ select: select_init: SELECT_SYM select_init2 | - '(' SELECT_SYM select_part2 ')' + '(' select_paren ')' union_opt; + +select_paren: + SELECT_SYM select_part2 { LEX *lex= Lex; SELECT_LEX * sel= lex->current_select; @@ -2408,7 +2411,8 @@ select_init: if (sel->master_unit()->fake_select_lex) sel->master_unit()->global_parameters= sel->master_unit()->fake_select_lex; - } union_opt; + } + | '(' select_paren ')'; select_init2: select_part2 @@ -3404,8 +3408,7 @@ when_list2: }; join_table_list: - '(' join_table_list ')' { $$=$2; } - | join_table { $$=$1; } + join_table { $$=$1; } | join_table_list ',' join_table_list { $$=$3; } | join_table_list normal_join join_table_list { $$=$3; } | join_table_list STRAIGHT_JOIN join_table_list @@ -3482,7 +3485,7 @@ join_table: } | '{' ident join_table LEFT OUTER JOIN_SYM join_table ON expr '}' { add_join_on($7,$9); $7->outer_join|=JOIN_TYPE_LEFT; $$=$7; } - | '(' SELECT_SYM select_derived ')' opt_table_alias + | '(' select_derived union_opt ')' opt_table_alias { LEX *lex=Lex; SELECT_LEX_UNIT *unit= lex->current_select->master_unit(); @@ -3493,9 +3496,27 @@ join_table: (List *)0))) YYABORT; - }; + } + | '(' join_table_list ')' { $$=$2; }; select_derived: + SELECT_SYM select_derived2 + | '(' select_derived ')' + { + LEX *lex= Lex; + SELECT_LEX * sel= lex->current_select; + if (sel->set_braces(1)) + { + yyerror(ER(ER_SYNTAX_ERROR)); + YYABORT; + } + /* select in braces, can't contain global parameters */ + if (sel->master_unit()->fake_select_lex) + sel->master_unit()->global_parameters= + sel->master_unit()->fake_select_lex; + }; + +select_derived2: { LEX *lex= Lex; lex->derived_tables= 1; @@ -3517,7 +3538,7 @@ select_derived: { Select->parsing_place= NO_MATTER; } - opt_select_from union_opt + opt_select_from ; opt_outer: -- cgit v1.2.1 From 7602fec89997c4afd6d86f13e9740e97046e7f9c Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Feb 2005 11:14:04 +0100 Subject: remove passwordless remote accounts from windows distro --- scripts/mysql_create_system_tables.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/mysql_create_system_tables.sh b/scripts/mysql_create_system_tables.sh index f524b322388..83fdc0639ce 100644 --- a/scripts/mysql_create_system_tables.sh +++ b/scripts/mysql_create_system_tables.sh @@ -163,9 +163,7 @@ then INSERT INTO user (host,user) values ('localhost','');" else i_u="$i_u - INSERT INTO user VALUES ('%','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); - INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0); - INSERT INTO user VALUES ('%','','','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','N','','','','',0,0,0);" + INSERT INTO user VALUES ('localhost','','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0);" fi fi fi -- cgit v1.2.1 From a1ba467ef8ac332967d53290ad8c25e80440b005 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Feb 2005 18:54:12 +0400 Subject: Bug#8351 Fix for crash when using a double quote in boolean fulltext query. mysql-test/r/fulltext.result: Added a test case for bug #8351. mysql-test/t/fulltext.test: Added a test case for bug #8351. BitKeeper/etc/logging_ok: Logging to logging@openlogging.org accepted --- BitKeeper/etc/logging_ok | 1 + myisam/ft_boolean_search.c | 36 ++++++++++++++---------------------- mysql-test/r/fulltext.result | 7 +++++++ mysql-test/t/fulltext.test | 8 ++++++++ 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 59882283d5d..b88eb69544d 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -203,6 +203,7 @@ serg@sergbook.mysql.com sergefp@mysql.com sinisa@rhols221.adsl.netsonic.fi stewart@mysql.com +svoj@mysql.com tfr@beta.frontier86.ee tfr@indrek.tfr.cafe.ee tfr@sarvik.tfr.cafe.ee diff --git a/myisam/ft_boolean_search.c b/myisam/ft_boolean_search.c index 4253b5ff96f..62c68322595 100644 --- a/myisam/ft_boolean_search.c +++ b/myisam/ft_boolean_search.c @@ -435,32 +435,24 @@ static int _ftb_strstr(const byte *s0, const byte *e0, const byte *s1, const byte *e1, CHARSET_INFO *cs) { - const byte *p0, *p1; - my_bool s_after, e_before; - - s_after=true_word_char(cs, s1[0]); - e_before=true_word_char(cs, e1[-1]); - p0=s0; + const byte *p0= s0; + my_bool s_after= true_word_char(cs, s1[0]); + my_bool e_before= true_word_char(cs, e1[-1]); + uint p0_len; + my_match_t m[2]; while (p0 < e0) { - while (p0 < e0 && cs->to_upper[(uint) (uchar) *p0++] != - cs->to_upper[(uint) (uchar) *s1]) - /* no-op */; - if (p0 >= e0) - return 0; - - if (s_after && p0-1 > s0 && true_word_char(cs, p0[-2])) - continue; - - p1=s1+1; - while (p0 < e0 && p1 < e1 && cs->to_upper[(uint) (uchar) *p0] == - cs->to_upper[(uint) (uchar) *p1]) - p0++, p1++; - if (p1 == e1 && (!e_before || p0 == e0 || !true_word_char(cs, p0[0]))) - return 1; + if (cs->coll->instr(cs, p0, e0 - p0, s1, e1 - s1, m, 2) != 2) + return(0); + if ((!s_after || p0 + m[1].beg == s0 || !true_word_char(cs, p0[m[1].beg-1])) && + (!e_before || p0 + m[1].end == e0 || !true_word_char(cs, p0[m[1].end]))) + return(1); + p0+= m[1].beg; + p0+= (p0_len= my_mbcharlen(cs, *(uchar *)p0)) ? p0_len : 1; } - return 0; + + return(0); } diff --git a/mysql-test/r/fulltext.result b/mysql-test/r/fulltext.result index a042248ba34..67644a68598 100644 --- a/mysql-test/r/fulltext.result +++ b/mysql-test/r/fulltext.result @@ -408,3 +408,10 @@ insert t1 values (1, "aaaa"), (2, "bbbb"); insert t2 values (10, "aaaa"), (2, "cccc"); replace t1 select * from t2; drop table t1, t2; +CREATE TABLE t1 (t VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci, FULLTEXT (t)); +SET NAMES latin1; +INSERT INTO t1 VALUES('Mit freundlichem Grüß aus Osnabrück'); +SELECT COUNT(*) FROM t1 WHERE MATCH(t) AGAINST ('"osnabrück"' IN BOOLEAN MODE); +COUNT(*) +1 +DROP TABLE t1; diff --git a/mysql-test/t/fulltext.test b/mysql-test/t/fulltext.test index 62dcecaff68..50d01da080f 100644 --- a/mysql-test/t/fulltext.test +++ b/mysql-test/t/fulltext.test @@ -322,3 +322,11 @@ insert t2 values (10, "aaaa"), (2, "cccc"); replace t1 select * from t2; drop table t1, t2; +# +# bug#8351 +# +CREATE TABLE t1 (t VARCHAR(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci, FULLTEXT (t)); +SET NAMES latin1; +INSERT INTO t1 VALUES('Mit freundlichem Grüß aus Osnabrück'); +SELECT COUNT(*) FROM t1 WHERE MATCH(t) AGAINST ('"osnabrück"' IN BOOLEAN MODE); +DROP TABLE t1; -- cgit v1.2.1 From 7f39fe22a05b6b087e3924ecd5c3c96930937968 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 14 Feb 2005 23:47:17 +0100 Subject: 1) undoing my fix for BUG#8055 "Trouble with replication from temporary tables and ignores" and fixing it another way (per Monty; a simpler solution which does not increase the number of binlog events is to always execute DROP TEMPORARY TABLE IF EXISTS on slave). A new test rpl_drop_temp. 2) fixing BUG#8436 "Multiple "stacked" SQL statements cause replication to stop" by setting thd->query_length to the length of the query being executed, not counting the next queries if this is a multi-query. Should also improve display of SHOW PROCESSLIST. A new test rpl_multi_query. mysql-test/r/drop_temp_table.result: back to one single DROP sql/sql_base.cc: undoing the fix I had made some days ago: we are back to one single DROP TEMPORARY TABLE for all temp tables. sql/sql_parse.cc: 1) set thd->query_length to the length of the query being executed, excluding the other next queries if this is a multi-query. The setting happens ASAP, ie. just after we know it's a multi-query, ie. just after yyparse(). Don't include the ';' in thd->query_length, because this is not good for storage in binlog. 2) always execute a DROP TEMPORARY TABLE IF EXISTS on slave, don't skip it even if --replicate-ignore-table --- mysql-test/r/drop_temp_table.result | 4 +-- mysql-test/r/rpl_drop_temp.result | 12 +++++++ mysql-test/r/rpl_multi_query.result | 32 +++++++++++++++++ mysql-test/t/rpl_drop_temp-slave.opt | 2 ++ mysql-test/t/rpl_drop_temp.test | 13 +++++++ mysql-test/t/rpl_multi_query.test | 26 ++++++++++++++ sql/sql_base.cc | 66 +++++++++++++++++++----------------- sql/sql_parse.cc | 26 ++++++++++++-- 8 files changed, 144 insertions(+), 37 deletions(-) create mode 100644 mysql-test/r/rpl_drop_temp.result create mode 100644 mysql-test/r/rpl_multi_query.result create mode 100644 mysql-test/t/rpl_drop_temp-slave.opt create mode 100644 mysql-test/t/rpl_drop_temp.test create mode 100644 mysql-test/t/rpl_multi_query.test diff --git a/mysql-test/r/drop_temp_table.result b/mysql-test/r/drop_temp_table.result index a486964feb2..5f1f142cde5 100644 --- a/mysql-test/r/drop_temp_table.result +++ b/mysql-test/r/drop_temp_table.result @@ -17,8 +17,6 @@ master-bin.000001 # Query 1 # create database `drop-temp+table-test` master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table shortn1 (a int) master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table `table:name` (a int) master-bin.000001 # Query 1 # use `drop-temp+table-test`; create temporary table shortn2 (a int) -master-bin.000001 # Query 1 # use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `drop-temp+table-test`.`shortn2` -master-bin.000001 # Query 1 # use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `drop-temp+table-test`.`table:name` -master-bin.000001 # Query 1 # use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `drop-temp+table-test`.`shortn1` +master-bin.000001 # Query 1 # use `drop-temp+table-test`; DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `drop-temp+table-test`.`shortn2`,`drop-temp+table-test`.`table:name`,`drop-temp+table-test`.`shortn1` master-bin.000001 # Query 1 # use `drop-temp+table-test`; DO RELEASE_LOCK("a") drop database `drop-temp+table-test`; diff --git a/mysql-test/r/rpl_drop_temp.result b/mysql-test/r/rpl_drop_temp.result new file mode 100644 index 00000000000..e00309cac8f --- /dev/null +++ b/mysql-test/r/rpl_drop_temp.result @@ -0,0 +1,12 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +create database if not exists mysqltest; +create temporary table mysqltest.t1 (n int); +create temporary table mysqltest.t2 (n int); +show status like 'Slave_open_temp_tables'; +Variable_name Value +Slave_open_temp_tables 0 diff --git a/mysql-test/r/rpl_multi_query.result b/mysql-test/r/rpl_multi_query.result new file mode 100644 index 00000000000..2521dbe1ed9 --- /dev/null +++ b/mysql-test/r/rpl_multi_query.result @@ -0,0 +1,32 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +drop database if exists mysqltest; +create database mysqltest; +create table mysqltest.t1 ( n int); +insert into mysqltest.t1 values(1)/ +insert into mysqltest.t1 values(2); +insert into mysqltest.t1 values(3); +insert into mysqltest.t1 values(4); +insert into mysqltest.t1 values(5)/ +select * from mysqltest.t1; +n +1 +2 +3 +4 +5 +show binlog events from 79; +Log_name Pos Event_type Server_id Orig_log_pos Info +master-bin.000001 # Query 1 # drop database if exists mysqltest +master-bin.000001 # Query 1 # create database mysqltest +master-bin.000001 # Query 1 # use `test`; create table mysqltest.t1 ( n int) +master-bin.000001 # Query 1 # use `test`; insert into mysqltest.t1 values(1) +master-bin.000001 # Query 1 # use `test`; insert into mysqltest.t1 values(2) +master-bin.000001 # Query 1 # use `test`; insert into mysqltest.t1 values(3) +master-bin.000001 # Query 1 # use `test`; insert into mysqltest.t1 values(4) +master-bin.000001 # Query 1 # use `test`; insert into mysqltest.t1 values(5) +drop database mysqltest; diff --git a/mysql-test/t/rpl_drop_temp-slave.opt b/mysql-test/t/rpl_drop_temp-slave.opt new file mode 100644 index 00000000000..2f9244c65ff --- /dev/null +++ b/mysql-test/t/rpl_drop_temp-slave.opt @@ -0,0 +1,2 @@ +--replicate-ignore-table=mysqltest.t2 + diff --git a/mysql-test/t/rpl_drop_temp.test b/mysql-test/t/rpl_drop_temp.test new file mode 100644 index 00000000000..73d691d9d90 --- /dev/null +++ b/mysql-test/t/rpl_drop_temp.test @@ -0,0 +1,13 @@ +source include/master-slave.inc; +--disable_warnings +create database if not exists mysqltest; +--enable_warnings + +create temporary table mysqltest.t1 (n int); +create temporary table mysqltest.t2 (n int); +sync_slave_with_master; +connection master; +disconnect master; +connection slave; +--real_sleep 3; # time for DROP to be written +show status like 'Slave_open_temp_tables'; diff --git a/mysql-test/t/rpl_multi_query.test b/mysql-test/t/rpl_multi_query.test new file mode 100644 index 00000000000..15f5d288759 --- /dev/null +++ b/mysql-test/t/rpl_multi_query.test @@ -0,0 +1,26 @@ +# Test for BUG#8436: verify that a multi-query (i.e. one query +# containing several queries (assuming client has +# CLIENT_MULTI_STATEMENTS) will be binlogged ONE-query-per-event (not +# one binlog event containing all queries) + +source include/master-slave.inc; +--disable_warnings +drop database if exists mysqltest; +--enable_warnings +create database mysqltest; + +delimiter /; +create table mysqltest.t1 ( n int); +insert into mysqltest.t1 values(1)/ +insert into mysqltest.t1 values(2); +insert into mysqltest.t1 values(3); +insert into mysqltest.t1 values(4); +insert into mysqltest.t1 values(5)/ +delimiter ;/ +sync_slave_with_master; +select * from mysqltest.t1; +connection master; +--replace_column 2 # 5 # +show binlog events from 79; +drop database mysqltest; +sync_slave_with_master; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index fe1f268e277..7434897ab90 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -485,58 +485,62 @@ void close_temporary(TABLE *table,bool delete_table) void close_temporary_tables(THD *thd) { TABLE *table,*next; - char *query, *name_in_query, *end; - uint greatest_key_length= 0; + char *query, *end; + uint query_buf_size; + bool found_user_tables = 0; if (!thd->temporary_tables) return; - /* - We write a DROP TEMPORARY TABLE for each temp table left, so that our - replication slave can clean them up. Not one multi-table DROP TABLE binlog - event: this would cause problems if slave uses --replicate-*-table. - */ LINT_INIT(end); + query_buf_size= 50; // Enough for DROP ... TABLE IF EXISTS - /* We'll re-use always same buffer so make it big enough for longest name */ for (table=thd->temporary_tables ; table ; table=table->next) - greatest_key_length= max(greatest_key_length, table->key_length); + /* + We are going to add 4 ` around the db/table names, so 1 does not look + enough; indeed it is enough, because table->key_length is greater (by 8, + because of server_id and thread_id) than db||table. + */ + query_buf_size+= table->key_length+1; - if ((query = alloc_root(thd->mem_root, greatest_key_length+50))) + if ((query = alloc_root(thd->mem_root, query_buf_size))) // Better add "if exists", in case a RESET MASTER has been done - name_in_query= strmov(query, "DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `"); + end=strmov(query, "DROP /*!40005 TEMPORARY */ TABLE IF EXISTS "); for (table=thd->temporary_tables ; table ; table=next) { - /* - In we are OOM for 'query' this is not fatal. We skip temporary tables - not created directly by the user. - */ - if (query && mysql_bin_log.is_open() && (table->real_name[0] != '#')) + if (query) // we might be out of memory, but this is not fatal { + // skip temporary tables not created directly by the user + if (table->real_name[0] != '#') + found_user_tables = 1; /* Here we assume table_cache_key always starts with \0 terminated db name */ - end = strxmov(name_in_query, table->table_cache_key, "`.`", - table->real_name, "`", NullS); - Query_log_event qinfo(thd, query, (ulong)(end-query), 0, FALSE); - /* - Imagine the thread had created a temp table, then was doing a SELECT, and - the SELECT was killed. Then it's not clever to mark the statement above as - "killed", because it's not really a statement updating data, and there - are 99.99% chances it will succeed on slave. And, if thread is - killed now, it's not clever either. - If a real update (one updating a persistent table) was killed on the - master, then this real update will be logged with error_code=killed, - rightfully causing the slave to stop. - */ - qinfo.error_code= 0; - mysql_bin_log.write(&qinfo); + end = strxmov(end,"`",table->table_cache_key,"`.`", + table->real_name,"`,", NullS); } next=table->next; close_temporary(table); } + if (query && found_user_tables && mysql_bin_log.is_open()) + { + /* The -1 is to remove last ',' */ + thd->clear_error(); + Query_log_event qinfo(thd, query, (ulong)(end-query)-1, 0, FALSE); + /* + Imagine the thread had created a temp table, then was doing a SELECT, and + the SELECT was killed. Then it's not clever to mark the statement above as + "killed", because it's not really a statement updating data, and there + are 99.99% chances it will succeed on slave. + If a real update (one updating a persistent table) was killed on the + master, then this real update will be logged with error_code=killed, + rightfully causing the slave to stop. + */ + qinfo.error_code= 0; + mysql_bin_log.write(&qinfo); + } thd->temporary_tables=0; } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index e66eeb279d2..f25255ac455 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1472,6 +1472,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, { if (alloc_query(thd, packet, packet_length)) break; // fatal error is set + char *packet_end= thd->query + thd->query_length; mysql_log.write(thd,command,"%s",thd->query); DBUG_PRINT("query",("%-.4096s",thd->query)); mysql_parse(thd,thd->query, thd->query_length); @@ -1487,7 +1488,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (thd->lock || thd->open_tables || thd->derived_tables) close_thread_tables(thd); #endif - ulong length= thd->query_length-(ulong)(packet-thd->query); + ulong length= (ulong)(packet_end-packet); /* Remove garbage at start of query */ while (my_isspace(thd->charset(), *packet) && length > 0) @@ -1924,9 +1925,14 @@ mysql_execute_command(THD *thd) } /* Skip if we are in the slave thread, some table rules have been - given and the table list says the query should not be replicated + given and the table list says the query should not be replicated. + Exception is DROP TEMPORARY TABLE IF EXISTS: we always execute it + (otherwise we have stale files on slave caused by exclusion of one tmp + table). */ - if (all_tables_not_ok(thd,tables)) + if (!(lex->sql_command == SQLCOM_DROP_TABLE && + lex->drop_temporary && lex->drop_if_exists) && + all_tables_not_ok(thd,tables)) { /* we warn the slave SQL thread */ my_error(ER_SLAVE_IGNORED_TABLE, MYF(0)); @@ -4118,6 +4124,20 @@ void mysql_parse(THD *thd, char *inBuf, uint length) send_error(thd, 0, NullS); else { + /* + Binlog logs a string starting from thd->query and having length + thd->query_length; so we set thd->query_length correctly (to not + log several statements in one event, when we executed only first). + We set it to not see the ';' (otherwise it would get into binlog + and Query_log_event::print() would give ';;' output). + This also helps display only the current query in SHOW + PROCESSLIST. + Note that we don't need LOCK_thread_count to modify query_length. + */ + if (lex->found_colon && + (thd->query_length= (ulong)(lex->found_colon - thd->query))) + thd->query_length--; + /* Actually execute the query */ mysql_execute_command(thd); query_cache_end_of_result(thd); } -- cgit v1.2.1 From 4386d89f404ddbd86e838f56dd4090781ad11127 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 03:55:44 +0300 Subject: Fix signatures of placement operator delete in places where placement delete is declared. As we don't use exceptions placement delete is never called and the fix only affects numerous warnings when compiling with MS Visual C++. For more info see http://www.gotw.ca/gotw/010.htm. sql/item.h: Fix the signature of placement operator delete for class Item. sql/sql_class.cc: Add placement delete operator to suppress a warning under Windows. sql/sql_lex.h: Fix the signature of placement operator delete for class LEX sql/sql_list.h: Fix the signature of placement operator delete for class Sql_alloc sql/sql_string.h: Fix the signature of placement operator delete for class Sql_string --- sql/item.h | 2 +- sql/sql_class.cc | 2 ++ sql/sql_lex.h | 2 +- sql/sql_list.h | 4 ++-- sql/sql_string.h | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/sql/item.h b/sql/item.h index a8b892292d3..db5010799fa 100644 --- a/sql/item.h +++ b/sql/item.h @@ -119,7 +119,7 @@ public: static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr,size_t size) {} - static void operator delete(void *ptr,size_t size, MEM_ROOT *mem_root) {} + static void operator delete(void *ptr, MEM_ROOT *mem_root) {} enum Type {FIELD_ITEM, FUNC_ITEM, SUM_FUNC_ITEM, STRING_ITEM, INT_ITEM, REAL_ITEM, NULL_ITEM, VARBIN_ITEM, diff --git a/sql/sql_class.cc b/sql/sql_class.cc index e11d8369f57..918e70fbc84 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -707,6 +707,8 @@ struct Item_change_record: public ilink Item *old_value; /* Placement new was hidden by `new' in ilink (TODO: check): */ static void *operator new(size_t size, void *mem) { return mem; } + static void operator delete(void *ptr, size_t size) {} + static void operator delete(void *ptr, void *mem) { /* never called */ } }; diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 7cb71607edf..3e2f6a3f2b5 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -241,7 +241,7 @@ public: static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr,size_t size) {} - static void operator delete(void *ptr,size_t size, MEM_ROOT *mem_root) {} + static void operator delete(void *ptr, MEM_ROOT *mem_root) {} st_select_lex_node(): linkage(UNSPECIFIED_TYPE) {} virtual ~st_select_lex_node() {} inline st_select_lex_node* get_master() { return master; } diff --git a/sql/sql_list.h b/sql/sql_list.h index a607b31d60c..be3e29b0c62 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -41,8 +41,8 @@ public: static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr, size_t size) { TRASH(ptr, size); } - static void operator delete(void *ptr, size_t size, MEM_ROOT *mem_root) - { TRASH(ptr, size); } + static void operator delete(void *ptr, MEM_ROOT *mem_root) + { /* never called */ } static void operator delete[](void *ptr, size_t size) { TRASH(ptr, size); } #ifdef HAVE_purify bool dummy; diff --git a/sql/sql_string.h b/sql/sql_string.h index 9136dddbbf2..3ad4689cf36 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -73,7 +73,7 @@ public: { return (void*) alloc_root(mem_root, (uint) size); } static void operator delete(void *ptr_arg,size_t size) {} - static void operator delete(void *ptr_arg,size_t size, MEM_ROOT *mem_root) + static void operator delete(void *ptr_arg, MEM_ROOT *mem_root) {} ~String() { free(); } -- cgit v1.2.1 From 0e159854a1c266f89a73868ffb2a76106aaa36e4 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 11:16:17 +0200 Subject: InnoDB: Create temporary files in the MySQL tmpdir instead of $TMPDIR. (Bug #5822) sql/ha_innodb.cc: innobase_mysql_tmpfile(): pass mysql_tmpdir to create_temp_file(), so that the MySQL startup option tmpdir will be honored instead of the environment variable TMPDIR. (Bug #5822) --- sql/ha_innodb.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 1a870ce3abf..81a803e36b9 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -424,7 +424,7 @@ innobase_mysql_tmpfile(void) { char filename[FN_REFLEN]; int fd2 = -1; - File fd = create_temp_file(filename, NullS, "ib", + File fd = create_temp_file(filename, mysql_tmpdir, "ib", #ifdef __WIN__ O_BINARY | O_TRUNC | O_SEQUENTIAL | O_TEMPORARY | O_SHORT_LIVED | -- cgit v1.2.1 From def54b1bae48d11f0b8f2ef3aaa9238630ec13e8 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 15:01:20 +0400 Subject: A fix. "(int) var" type cast doesn't work correctly for uint32 var on some 64-bit platforms (e.g. IRIX, non-debug build). --- sql/item_strfunc.cc | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index a92c4e94c87..bbbcadbb071 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -1645,7 +1645,8 @@ String *Item_func_format::val_str(String *str) { DBUG_ASSERT(fixed == 1); double nr =args[0]->val(); - uint32 diff,length,str_length; + int diff; + uint32 length, str_length; uint dec; if ((null_value=args[0]->null_value)) return 0; /* purecov: inspected */ @@ -1670,9 +1671,12 @@ String *Item_func_format::val_str(String *str) pos[0]= pos[-(int) diff]; while (diff) { - pos[0]=pos[-(int) diff]; pos--; - pos[0]=pos[-(int) diff]; pos--; - pos[0]=pos[-(int) diff]; pos--; + *pos= *(pos - diff); + pos--; + *pos= *(pos - diff); + pos--; + *pos= *(pos - diff); + pos--; pos[0]=','; pos--; diff--; -- cgit v1.2.1 From 653eb9a52ec8b930986179b42632ee1e35fa076f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 14:42:13 +0200 Subject: Better bug fix for #5569: "Incorrect "Access Denied" error with SAME login DIFFERENT host" This fixes also the reverse lookup bug introduced by the previous patch mysql-test/t/group_by.test: Remove empty line vio/viosocket.c: Added function comment --- mysql-test/t/group_by.test | 1 - sql/sql_parse.cc | 23 +++++++++++++---------- vio/viosocket.c | 12 ++++++++++++ 3 files changed, 25 insertions(+), 11 deletions(-) diff --git a/mysql-test/t/group_by.test b/mysql-test/t/group_by.test index 5af78b924f8..2e5446c2d92 100644 --- a/mysql-test/t/group_by.test +++ b/mysql-test/t/group_by.test @@ -455,4 +455,3 @@ select min(a) is null from t1; select min(a) is null or null from t1; select 1 and min(a) is null from t1; drop table t1; - diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index cd0abafc0c9..613484ebf50 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -504,8 +504,6 @@ check_connections(THD *thd) DBUG_PRINT("info",("New connection received on %s", vio_description(net->vio))); - vio_in_addr(net->vio,&thd->remote.sin_addr); - if (!thd->host) // If TCP/IP connection { char ip[30]; @@ -515,6 +513,7 @@ check_connections(THD *thd) if (!(thd->ip = my_strdup(ip,MYF(0)))) return (ER_OUT_OF_RESOURCES); thd->host_or_ip=thd->ip; + vio_in_addr(net->vio, &thd->remote.sin_addr); #if !defined(HAVE_SYS_UN_H) || defined(HAVE_mit_thread) /* Fast local hostname resolve for Win32 */ if (!strcmp(thd->ip,"127.0.0.1")) @@ -524,17 +523,19 @@ check_connections(THD *thd) } else #endif - if (!(specialflag & SPECIAL_NO_RESOLVE)) { - thd->host=ip_to_hostname(&thd->remote.sin_addr,&connect_errors); - /* Cut very long hostnames to avoid possible overflows */ - if (thd->host) + if (!(specialflag & SPECIAL_NO_RESOLVE)) { - thd->host[min(strlen(thd->host), HOSTNAME_LENGTH)]= 0; - thd->host_or_ip= thd->host; + thd->host=ip_to_hostname(&thd->remote.sin_addr,&connect_errors); + /* Cut very long hostnames to avoid possible overflows */ + if (thd->host) + { + thd->host[min(strlen(thd->host), HOSTNAME_LENGTH)]= 0; + thd->host_or_ip= thd->host; + } + if (connect_errors > max_connect_errors) + return(ER_HOST_IS_BLOCKED); } - if (connect_errors > max_connect_errors) - return(ER_HOST_IS_BLOCKED); } DBUG_PRINT("info",("Host: %s ip: %s", thd->host ? thd->host : "unknown host", @@ -547,6 +548,8 @@ check_connections(THD *thd) DBUG_PRINT("info",("Host: %s",thd->host)); thd->host_or_ip= thd->host; thd->ip= 0; + /* Reset sin_addr */ + bzero((char*) &thd->remote, sizeof(thd->remote)); } vio_keepalive(net->vio, TRUE); diff --git a/vio/viosocket.c b/vio/viosocket.c index 1b6f46c57cf..f45c9dd98c4 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -291,6 +291,18 @@ my_bool vio_peer_addr(Vio * vio, char *buf, uint16 *port) } +/* + Get in_addr for a TCP/IP connection + + SYNOPSIS + vio_in_addr() + vio vio handle + in put in_addr here + + NOTES + one must call vio_peer_addr() before calling this one +*/ + void vio_in_addr(Vio *vio, struct in_addr *in) { DBUG_ENTER("vio_in_addr"); -- cgit v1.2.1 From c03d3dfe8214b3dc83689df6f5475d86f0b8b85e Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 14:13:18 +0100 Subject: 1) Tag the 4.1.10 released version: bk tag -r 1.2159.8.1 "mysql-4.1.10" 2) Raise the version number to 4.1.11. configure.in: Raise the version number from 4.1.10 to 4.1.11. --- configure.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index 665029accb3..f3e93afb72e 100644 --- a/configure.in +++ b/configure.in @@ -5,7 +5,7 @@ AC_INIT(sql/mysqld.cc) AC_CANONICAL_SYSTEM # The Docs Makefile.am parses this line! # remember to also change ndb version below and update version.c in ndb -AM_INIT_AUTOMAKE(mysql, 4.1.10) +AM_INIT_AUTOMAKE(mysql, 4.1.11) AM_CONFIG_HEADER(config.h) PROTOCOL_VERSION=10 @@ -16,7 +16,7 @@ SHARED_LIB_VERSION=14:0:0 # ndb version NDB_VERSION_MAJOR=4 NDB_VERSION_MINOR=1 -NDB_VERSION_BUILD=10 +NDB_VERSION_BUILD=11 NDB_VERSION_STATUS="" # Set all version vars based on $VERSION. How do we do this more elegant ? -- cgit v1.2.1 From b0adbd5725d70803a2b26ba2dd0cb2572ee696f9 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 16:45:00 +0200 Subject: Fixed failing test cases 'row.test' when running with --ps-protocol Simple optimzations done while reviewing code client/mysqltest.c: Added options --enable-ps-warnings and --disable-ps-warnings (to fix failing test case) mysql-test/t/row.test: Disable warnings that comes from 'parse' parth sql/field.cc: Removed calls to is_null() in field functions. (Not needed as NULL handling is done on the level above fields) Indentation fixes Removed calls to alloca() as buffer needed was quite small. sql/field.h: Indentation changes and comment fixes sql/filesort.cc: Simple optimization during code review sql/item.cc: Indentation fixes Removed some unnecessary tests (added DBUG_ASSERTS() instead) sql/item_buff.cc: Indentation fixes sql/my_decimal.cc: Indentation fixes Simple optimization Fixed compiler warning sql/sql_update.cc: Removed unnessessary assignment --- client/mysqltest.c | 9 ++++++- mysql-test/t/row.test | 2 ++ sql/field.cc | 58 ++++++++++++++++++--------------------------- sql/field.h | 8 +++++-- sql/filesort.cc | 65 ++++++++++++++++++++++++++++----------------------- sql/item.cc | 55 ++++++++++++++++++++----------------------- sql/item_buff.cc | 3 +-- sql/my_decimal.cc | 28 +++++++++++----------- sql/sql_update.cc | 4 +--- 9 files changed, 116 insertions(+), 116 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 7bdcf6db3e5..4050dd7a029 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -253,6 +253,7 @@ VAR var_reg[10]; /*Perl/shell-like variable registers */ HASH var_hash; my_bool disable_query_log=0, disable_result_log=0, disable_warnings=0; +my_bool disable_ps_warnings= 0; my_bool disable_info= 1; /* By default off */ my_bool abort_on_error= 1; @@ -283,6 +284,7 @@ Q_ENABLE_RESULT_LOG, Q_DISABLE_RESULT_LOG, Q_SERVER_START, Q_SERVER_STOP,Q_REQUIRE_MANAGER, Q_WAIT_FOR_SLAVE_TO_STOP, Q_ENABLE_WARNINGS, Q_DISABLE_WARNINGS, +Q_ENABLE_PS_WARNINGS, Q_DISABLE_PS_WARNINGS, Q_ENABLE_INFO, Q_DISABLE_INFO, Q_ENABLE_METADATA, Q_DISABLE_METADATA, Q_EXEC, Q_DELIMITER, @@ -360,6 +362,8 @@ const char *command_names[]= "wait_for_slave_to_stop", "enable_warnings", "disable_warnings", + "enable_ps_warnings", + "disable_ps_warnings", "enable_info", "disable_info", "enable_metadata", @@ -3021,7 +3025,8 @@ static int run_query_stmt(MYSQL *mysql, struct st_query *q, int flags) /* We may have got warnings already, collect them if any */ /* FIXME we only want this if the statement succeeds I think */ - run_query_stmt_handle_warnings(mysql, ds); + if (!disable_ps_warnings) + run_query_stmt_handle_warnings(mysql, ds); /* No need to call mysql_stmt_bind_param() because we have no @@ -3711,6 +3716,8 @@ int main(int argc, char **argv) case Q_DISABLE_RESULT_LOG: disable_result_log=1; break; case Q_ENABLE_WARNINGS: disable_warnings=0; break; case Q_DISABLE_WARNINGS: disable_warnings=1; break; + case Q_ENABLE_PS_WARNINGS: disable_ps_warnings=0; break; + case Q_DISABLE_PS_WARNINGS: disable_ps_warnings=1; break; case Q_ENABLE_INFO: disable_info=0; break; case Q_DISABLE_INFO: disable_info=1; break; case Q_ENABLE_METADATA: display_metadata=1; break; diff --git a/mysql-test/t/row.test b/mysql-test/t/row.test index 62e8eb7991c..58b90c9a356 100644 --- a/mysql-test/t/row.test +++ b/mysql-test/t/row.test @@ -7,7 +7,9 @@ select (1,2,3) IN ((3,2,3), (1,2,3), (1,3,3)); select row(10,2,3) IN (row(3,2,3), row(1,2,3), row(1,3,3)); select row(1,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)); select row(10,2,3) IN (row(3,NULL,3), row(1,2,3), row(1,3,3)); +--disable_ps_warnings select row('a',1.5,3) IN (row(1,2,3), row('a',1.5,3), row('a','a','a')); +--enable_ps_warnings select row('a',0,3) IN (row(3,2,3), row('a','0','3'), row(1,3,3)); select row('a',0,3) IN (row(3,2,3), row('a','a','3'), row(1,3,3)); select row('a',1.5,3) IN (row(3,NULL,3), row('a',1.5,3), row(1,3,3)); diff --git a/sql/field.cc b/sql/field.cc index bc95e1dab54..f51b06028f7 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -572,8 +572,7 @@ my_decimal* Field_num::val_decimal(my_decimal *decimal_value) { DBUG_ASSERT(result_type() == INT_RESULT); longlong nr= val_int(); - if (!is_null()) - int2my_decimal(E_DEC_FATAL_ERROR, nr, unsigned_flag, decimal_value); + int2my_decimal(E_DEC_FATAL_ERROR, nr, unsigned_flag, decimal_value); return decimal_value; } @@ -605,7 +604,7 @@ void Field_num::make_field(Send_field *field) d value for storing NOTE - Field_str is the base class for fields like Field_date, and some + Field_str is the base class for fields like Field_enum, Field_date and some similar. Some dates use fraction and also string value should be converted to floating point value according our rules, so we use double to store value of decimal in string @@ -629,8 +628,7 @@ my_decimal *Field_str::val_decimal(my_decimal *decimal_value) { DBUG_ASSERT(result_type() == INT_RESULT); longlong nr= val_int(); - if (is_null()) - int2my_decimal(E_DEC_FATAL_ERROR, nr, 0, decimal_value); + int2my_decimal(E_DEC_FATAL_ERROR, nr, 0, decimal_value); return decimal_value; } @@ -733,6 +731,7 @@ Field *Field::new_key_field(MEM_ROOT *root, struct st_table *new_table, return tmp; } + /* SYNOPSIS Field::quote_data() @@ -749,44 +748,35 @@ Field *Field::new_key_field(MEM_ROOT *root, struct st_table *new_table, void Upon prepending/appending quotes on each side of variable */ + bool Field::quote_data(String *unquoted_string) { char escaped_string[IO_SIZE]; char *unquoted_string_buffer= (char *)(unquoted_string->ptr()); uint need_quotes; - DBUG_ENTER("Field::quote_data"); + // this is the same call that mysql_real_escape_string() calls escape_string_for_mysql(&my_charset_bin, (char *)escaped_string, unquoted_string->ptr(), unquoted_string->length()); - - if (is_null()) - DBUG_RETURN(0); - need_quotes= needs_quotes(); if (need_quotes == 0) - { DBUG_RETURN(0); - } - else - { - // reset string, then re-append with quotes and escaped values - unquoted_string->length(0); - if (unquoted_string->append("'")) - DBUG_RETURN(1); - if (unquoted_string->append((char *)escaped_string)) - DBUG_RETURN(1); - if (unquoted_string->append("'")) - DBUG_RETURN(1); - } - //DBUG_PRINT("Field::quote_data", - // ("FINAL quote_flag %d unquoted_string %s escaped_string %s", - //needs_quotes, unquoted_string->c_ptr_quick(), escaped_string)); + + // reset string, then re-append with quotes and escaped values + unquoted_string->length(0); + if (unquoted_string->append('\'')) + DBUG_RETURN(1); + if (unquoted_string->append((char *)escaped_string)) + DBUG_RETURN(1); + if (unquoted_string->append('\'')) + DBUG_RETURN(1); DBUG_RETURN(0); } + /* Quote a field type if needed @@ -802,6 +792,7 @@ bool Field::quote_data(String *unquoted_string) 0 if value is of type NOT needing quotes 1 if value is of type needing quotes */ + bool Field::needs_quotes(void) { DBUG_ENTER("Field::type_quote"); @@ -840,9 +831,9 @@ bool Field::needs_quotes(void) default: DBUG_RETURN(0); } DBUG_RETURN(0); - } + /**************************************************************************** Field_null, a field that always return NULL ****************************************************************************/ @@ -4646,8 +4637,6 @@ String *Field_newdate::val_str(String *val_buffer, bool Field_newdate::get_date(TIME *ltime,uint fuzzydate) { - if (is_null()) - return 1; uint32 tmp=(uint32) uint3korr(ptr); ltime->day= tmp & 31; ltime->month= (tmp >> 5) & 15; @@ -5058,17 +5047,16 @@ int Field_string::store(longlong nr) return Field_string::store(buff,(uint)l,cs); } + int Field_longstr::store_decimal(const my_decimal *d) { - uint buf_size= my_decimal_string_length(d); - char *buff= (char *)my_alloca(buf_size); - String str(buff, buf_size, &my_charset_bin); + char buff[DECIMAL_MAX_STR_LENGTH+1]; + String str(buff, sizeof(buff), &my_charset_bin); my_decimal2string(E_DEC_FATAL_ERROR, d, 0, 0, 0, &str); - int result= store(str.ptr(), str.length(), str.charset()); - my_afree(buff); - return result; + return store(str.ptr(), str.length(), str.charset()); } + double Field_string::val_real(void) { int not_used; diff --git a/sql/field.h b/sql/field.h index 327fb4c885b..cfed2eb19e1 100644 --- a/sql/field.h +++ b/sql/field.h @@ -367,7 +367,9 @@ public: my_decimal *val_decimal(my_decimal *); }; -/* base class for Item_string, Item_valstring, Item_blob */ + +/* base class for Field_string, Field_varstring and Field_blob */ + class Field_longstr :public Field_str { public: @@ -1181,7 +1183,9 @@ public: bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } field_cast_enum field_cast_type() { return FIELD_CAST_BLOB; } - uint32 max_length();}; + uint32 max_length(); +}; + #ifdef HAVE_SPATIAL class Field_geom :public Field_blob { diff --git a/sql/filesort.cc b/sql/filesort.cc index 956ac2ef61b..c05baa7cc04 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -619,20 +619,21 @@ static void make_sortkey(register SORTPARAM *param, else { // Item Item *item=sort_field->item; + maybe_null= item->maybe_null; switch (sort_field->result_type) { case STRING_RESULT: { CHARSET_INFO *cs=item->collation.collation; char fill_char= ((cs->state & MY_CS_BINSORT) ? (char) 0 : ' '); - if ((maybe_null=item->maybe_null)) + if (maybe_null) *to++=1; /* All item->str() to use some extra byte for end null.. */ String tmp((char*) to,sort_field->length+4,cs); String *res=item->val_str(&tmp); if (!res) { - if (item->maybe_null) + if (maybe_null) bzero((char*) to-1,sort_field->length+1); else { @@ -672,20 +673,22 @@ static void make_sortkey(register SORTPARAM *param, case INT_RESULT: { longlong value=item->val_int(); - if ((maybe_null=item->maybe_null)) + if (maybe_null) + { *to++=1; /* purecov: inspected */ - if (item->null_value) - { - if (item->maybe_null) - bzero((char*) to-1,sort_field->length+1); - else - { - DBUG_PRINT("warning", - ("Got null on something that shouldn't be null")); - bzero((char*) to,sort_field->length); - } - break; - } + if (item->null_value) + { + if (maybe_null) + bzero((char*) to-1,sort_field->length+1); + else + { + DBUG_PRINT("warning", + ("Got null on something that shouldn't be null")); + bzero((char*) to,sort_field->length); + } + break; + } + } #if SIZEOF_LONG_LONG > 4 to[7]= (uchar) value; to[6]= (uchar) (value >> 8); @@ -706,14 +709,16 @@ static void make_sortkey(register SORTPARAM *param, case DECIMAL_RESULT: { my_decimal dec_buf, *dec_val= item->val_decimal(&dec_buf); - if ((maybe_null=item->null_value)) - { - bzero((char*)to, sort_field->length+1); - to++; - break; - } - if ((maybe_null=item->maybe_null)) + if (maybe_null) + { + if (item->null_value) + { + bzero((char*)to, sort_field->length+1); + to++; + break; + } *to++=1; + } my_decimal2binary(E_DEC_FATAL_ERROR, dec_val, (byte*)to, item->max_length - (item->decimals ? 1:0), item->decimals); @@ -722,14 +727,16 @@ static void make_sortkey(register SORTPARAM *param, case REAL_RESULT: { double value= item->val_real(); - if ((maybe_null=item->null_value)) - { - bzero((char*) to,sort_field->length+1); - to++; - break; - } - if ((maybe_null=item->maybe_null)) + if (maybe_null) + { + if (item->null_value) + { + bzero((char*) to,sort_field->length+1); + to++; + break; + } *to++=1; + } change_double_for_sort(value,(byte*) to); break; } diff --git a/sql/item.cc b/sql/item.cc index 53d9d532b3d..4eb4e017ef2 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -48,10 +48,10 @@ void item_init(void) /* TODO: make this functions class dependent */ + bool Item::val_bool() { - switch(result_type()) - { + switch(result_type()) { case INT_RESULT: return val_int(); case DECIMAL_RESULT: @@ -68,6 +68,7 @@ bool Item::val_bool() case ROW_RESULT: default: DBUG_ASSERT(0); + return 0; // Wrong (but safe) } } @@ -991,8 +992,7 @@ bool Item_field::val_bool_result() { if ((null_value= result_field->is_null())) return FALSE; - switch (result_field->result_type()) - { + switch (result_field->result_type()) { case INT_RESULT: return result_field->val_int(); case DECIMAL_RESULT: @@ -1060,8 +1060,9 @@ Item *Item_field::get_tmp_table_item(THD *thd) /* - Create an item from a string we KNOW points to a valid longlong/ulonglong - end \0 terminated number string + Create an item from a string we KNOW points to a valid longlong + end \0 terminated number string. + This is always 'signed'. Unsigned values are created with Item_uint() */ Item_int::Item_int(const char *str_arg, uint length) @@ -1071,7 +1072,6 @@ Item_int::Item_int(const char *str_arg, uint length) value= my_strtoll10(str_arg, &end_ptr, &error); max_length= (uint) (end_ptr - str_arg); name= (char*) str_arg; - unsigned_flag= value > 0; fixed= 1; } @@ -2436,8 +2436,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) rf is Item_ref => never substitute other items (in this case) during fix_fields() => we can use rf after fix_fields() */ - if (!rf->fixed && - rf->fix_fields(thd, tables, reference) || rf->check_cols(1)) + DBUG_ASSERT(!rf->fixed); // Assured by Item_ref() + if (rf->fix_fields(thd, tables, reference) || rf->check_cols(1)) return TRUE; mark_as_dependent(thd, last, current_sel, rf); @@ -2458,8 +2458,8 @@ bool Item_field::fix_fields(THD *thd, TABLE_LIST *tables, Item **reference) rf is Item_ref => never substitute other items (in this case) during fix_fields() => we can use rf after fix_fields() */ - return (!rf->fixed && - rf->fix_fields(thd, tables, reference) || rf->check_cols(1)); + DBUG_ASSERT(!rf->fixed); // Assured by Item_ref() + return (rf->fix_fields(thd, tables, reference) || rf->check_cols(1)); } } } @@ -2706,8 +2706,7 @@ void Item_empty_string::make_field(Send_field *tmp_field) enum_field_types Item::field_type() const { - switch (result_type()) - { + switch (result_type()) { case STRING_RESULT: return MYSQL_TYPE_VARCHAR; case INT_RESULT: return FIELD_TYPE_LONGLONG; case DECIMAL_RESULT: return FIELD_TYPE_NEWDECIMAL; @@ -2715,8 +2714,8 @@ enum_field_types Item::field_type() const case ROW_RESULT: default: DBUG_ASSERT(0); - return FIELD_TYPE_VAR_STRING; - }; + return MYSQL_TYPE_VARCHAR; + } } @@ -3662,18 +3661,17 @@ bool Item_ref::val_bool_result() { if ((null_value= result_field->is_null())) return 0; - switch (result_field->result_type()) - { + switch (result_field->result_type()) { case INT_RESULT: return result_field->val_int(); case DECIMAL_RESULT: - { - my_decimal decimal_value; - my_decimal *val= result_field->val_decimal(&decimal_value); - if (val) - return !my_decimal_is_zero(val); - return 0; - } + { + my_decimal decimal_value; + my_decimal *val= result_field->val_decimal(&decimal_value); + if (val) + return !my_decimal_is_zero(val); + return 0; + } case REAL_RESULT: case STRING_RESULT: return result_field->val_real() != 0.0; @@ -4049,8 +4047,7 @@ void resolve_const_item(THD *thd, Item **ref, Item *comp_item) item->result_type()); char *name=item->name; // Alloced by sql_alloc - switch (res_type) - { + switch (res_type) { case STRING_RESULT: { char buff[MAX_FIELD_WIDTH]; @@ -4146,8 +4143,7 @@ bool field_is_equal_to_item(Field *field,Item *item) Item_cache* Item_cache::get_cache(Item_result type) { - switch (type) - { + switch (type) { case INT_RESULT: return new Item_cache_int(); case REAL_RESULT: @@ -4617,8 +4613,7 @@ uint32 Item_type_holder::real_length(Item *item) if (item->type() == Item::FIELD_ITEM) return ((Item_field *)item)->max_disp_length(); - switch (item->result_type()) - { + switch (item->result_type()) { case STRING_RESULT: case DECIMAL_RESULT: return item->max_length; diff --git a/sql/item_buff.cc b/sql/item_buff.cc index 7c77f7fa3bc..af17d377e31 100644 --- a/sql/item_buff.cc +++ b/sql/item_buff.cc @@ -28,8 +28,7 @@ Item_buff *new_Item_buff(Item *item) if (item->type() == Item::FIELD_ITEM && !(((Item_field *) item)->field->flags & BLOB_FLAG)) return new Item_field_buff((Item_field *) item); - switch (item->result_type()) - { + switch (item->result_type()) { case STRING_RESULT: return new Item_str_buff((Item_field *) item); case INT_RESULT: diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index 027b33f1d1c..f028b1fa1a1 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -23,16 +23,18 @@ decimal_operation_results() result decimal library return code (E_DEC_* see include/decimal.h) - return + TODO + Fix error messages + + RETURN result */ + int decimal_operation_results(int result) { - switch (result) - { + switch (result) { case E_DEC_OK: break; -//TODO: fix error messages case E_DEC_TRUNCATED: push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, ER(WARN_DATA_TRUNCATED), @@ -78,20 +80,18 @@ int decimal_operation_results(int result) */ int my_decimal2string(uint mask, const my_decimal *d, - int fixed_prec, int fixed_dec, - char filler, String *str) + int fixed_prec, int fixed_dec, + char filler, String *str) { int length= (fixed_prec ? (fixed_prec + 1) : my_decimal_string_length(d)); int result; if (str->alloc(length)) - return check_result(mask, E_DEC_OOM); - char *sptr= (char *)str->ptr(); - int res= decimal2string((decimal *)d, sptr, - &length, fixed_prec, fixed_dec, - filler); - result= check_result(mask, res); + return check_result(mask, E_DEC_OOM); + result= decimal2string((decimal*) d, (char*) str->ptr(), + &length, fixed_prec, fixed_dec, + filler); str->length(length); - return result; + return check_result(mask, result); } @@ -171,7 +171,7 @@ int str2my_decimal(uint mask, const char *from, uint length, } my_decimal_set_zero(decimal_value); err= string2decimal((char *)from, (decimal *)decimal_value, &end); - if ((end-from) != length && !err) + if ((uint) (end-from) != length && !err) err= E_DEC_TRUNCATED; check_result(mask, err); return err; diff --git a/sql/sql_update.cc b/sql/sql_update.cc index f9df1be2abd..17179bf9c5f 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -264,10 +264,8 @@ int mysql_update(THD *thd, else if ((used_index=table->file->key_used_on_scan) < MAX_KEY) used_key_is_modified=check_if_key_used(table, used_index, fields); else - { used_key_is_modified=0; - used_index= MAX_KEY; - } + if (used_key_is_modified || order) { /* -- cgit v1.2.1 From 5961d4a8d501a00fa82589d97867908070db2a2f Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 19:25:42 +0200 Subject: After merge fixes mysql-test/r/ctype_ucs.result: Fixed warning after merge sql/field.cc: After merge fix sql/item_cmpfunc.cc: Style & comment changes sql/sql_yacc.yy: After merge fix --- mysql-test/r/ctype_ucs.result | 2 +- sql/field.cc | 2 +- sql/item_cmpfunc.cc | 44 ++++++++++++++++++++++++++----------------- sql/sql_yacc.yy | 2 +- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/mysql-test/r/ctype_ucs.result b/mysql-test/r/ctype_ucs.result index 7302ff930ae..7a2bdc83584 100644 --- a/mysql-test/r/ctype_ucs.result +++ b/mysql-test/r/ctype_ucs.result @@ -635,6 +635,6 @@ DROP TABLE t1; CREATE TABLE t1 (Field1 int(10) unsigned default '0'); INSERT INTO t1 VALUES ('-1'); Warnings: -Warning 1265 Data truncated for column 'Field1' at row 1 +Warning 1264 Out of range value adjusted for column 'Field1' at row 1 DROP TABLE t1; SET NAMES latin1; diff --git a/sql/field.cc b/sql/field.cc index c1520653084..0be72458701 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -2452,7 +2452,7 @@ int Field_long::store(const char *from,uint len,CHARSET_INFO *cs) from+= tmp; end= (char*) from+len; - tmp= my_strtoll10(from, &end, &error); + tmp= cs->cset->my_strtoll10(cs, from, &end, &error); if (error != MY_ERRNO_EDOM) { diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index c26365e3f0e..96e91ea27ad 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -273,8 +273,7 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type) owner= item; func= comparator_matrix[type] [test(owner->functype() == Item_func::EQUAL_FUNC)]; - switch(type) - { + switch(type) { case ROW_RESULT: { uint n= (*a)->cols(); @@ -877,10 +876,20 @@ void Item_func_interval::fix_length_and_dec() /* - return -1 if null value, - 0 if lower than lowest - 1 - arg_count-1 if between args[n] and args[n+1] - arg_count if higher than biggest argument + Execute Item_func_interval() + + SYNOPSIS + Item_func_interval::val_int() + + NOTES + If we are doing a decimal comparison, we are + evaluating the first item twice. + + RETURN + -1 if null value, + 0 if lower than lowest + 1 - arg_count-1 if between args[n] and args[n+1] + arg_count if higher than biggest argument */ longlong Item_func_interval::val_int() @@ -888,11 +897,10 @@ longlong Item_func_interval::val_int() DBUG_ASSERT(fixed == 1); double value= row->el(0)->val_real(); my_decimal dec_buf, *dec= NULL; + uint i; + if (use_decimal_comparison) - { dec= row->el(0)->val_decimal(&dec_buf); - } - uint i; if (row->el(0)->null_value) return -1; // -1 if null @@ -906,6 +914,11 @@ longlong Item_func_interval::val_int() uint mid= (start + end + 1) / 2; interval_range *range= intervals + mid; my_bool cmp_result; + /* + The values in the range intervall may have different types, + Only do a decimal comparision of the first argument is a decimal + and we are comparing against a decimal + */ if (dec && range->type == DECIMAL_RESULT) cmp_result= my_decimal_cmp(&range->dec, dec) <= 0; else @@ -917,7 +930,7 @@ longlong Item_func_interval::val_int() } interval_range *range= intervals+start; return ((dec && range->type == DECIMAL_RESULT) ? - my_decimal_cmp(dec, &range->dec) < 0 : + my_decimal_cmp(dec, &range->dec) < 0 : value < range->dbl) ? 0 : start + 1; } @@ -932,13 +945,13 @@ longlong Item_func_interval::val_int() if (my_decimal_cmp(e_dec, dec) > 0) return i-1; } - else - if (row->el(i)->val_real() > value) - return i-1; + else if (row->el(i)->val_real() > value) + return i-1; } return i-1; } + void Item_func_between::fix_length_and_dec() { max_length= 1; @@ -1087,8 +1100,7 @@ Item_func_ifnull::fix_length_and_dec() args[1]->max_length - args[1]->decimals) + decimals); agg_result_type(&cached_result_type, args, 2); - switch (cached_result_type) - { + switch (cached_result_type) { case STRING_RESULT: agg_arg_charsets(collation, args, arg_count, MY_COLL_CMP_CONV); break; @@ -1166,7 +1178,6 @@ my_decimal *Item_func_ifnull::val_decimal(my_decimal *decimal_value) } - String * Item_func_ifnull::val_str(String *str) { @@ -1456,7 +1467,6 @@ Item *Item_func_case::find_item(String *str) } - String *Item_func_case::val_str(String *str) { DBUG_ASSERT(fixed == 1); diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 37e1ef70b84..b3d04333695 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -5026,7 +5026,7 @@ select_derived: } ; -select_derived: +select_derived2: { LEX *lex= Lex; lex->derived_tables|= DERIVED_SUBQUERY; -- cgit v1.2.1 From 768186700ced49a128557eba73413bac130c94f6 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 19:35:28 +0200 Subject: Safety fix sql/item_cmpfunc.cc: Safety fix Code cleanup --- sql/item_cmpfunc.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 96e91ea27ad..0fa7ffcdda8 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -2047,7 +2047,8 @@ int cmp_item_row::compare(cmp_item *c) void cmp_item_decimal::store_value(Item *item) { my_decimal *val= item->val_decimal(&value); - if (val != &value) + /* val may be zero if item is nnull */ + if (val && val != &value) my_decimal2decimal(val, &value); } @@ -2061,9 +2062,9 @@ int cmp_item_decimal::cmp(Item *arg) } -int cmp_item_decimal::compare(cmp_item *c) +int cmp_item_decimal::compare(cmp_item *arg) { - cmp_item_decimal *cmp= (cmp_item_decimal *)c; + cmp_item_decimal *cmp= (cmp_item_decimal*) arg; return my_decimal_cmp(&value, &cmp->value); } -- cgit v1.2.1 From 6de2ae8372f176817967256d0e6f5a98aad9a2d4 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 22:06:55 +0300 Subject: Fixing failing -debug build. Since placement operator delete called only if exception was thrown in constructor and we don't use exceptions in MySQL, there is no sense to do anything in String::delete(void *ptr_arg, MEM_ROOT *mem_root). --- sql/sql_string.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/sql_string.h b/sql/sql_string.h index f9f0b1b6242..2debeb61787 100644 --- a/sql/sql_string.h +++ b/sql/sql_string.h @@ -74,7 +74,7 @@ public: static void operator delete(void *ptr_arg,size_t size) { TRASH(ptr_arg, size); } static void operator delete(void *ptr_arg, MEM_ROOT *mem_root) - { TRASH(ptr_arg, size); } + { /* never called */ } ~String() { free(); } inline void set_charset(CHARSET_INFO *charset) { str_charset= charset; } -- cgit v1.2.1 From d5b3b9be5bbcf1fe88f0c97d574907f102d8a61a Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 22:17:44 +0300 Subject: Temporary disabling part of test which fails in --ps-protocol mode. --- mysql-test/t/sp.test | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index d474fb1c84e..bdc5ec0dc22 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -2811,6 +2811,12 @@ drop function getcount| # # BUG#5240: Stored procedure crash if function has cursor declaration # +# The following test case fails in --ps-protocol mode due to some bugs +# in algorithm which calculates list of tables to be locked for queries +# using Stored Functions. It is disabled until Dmitri fixes this. +# +--disable_ps_protocol + --disable_warnings drop function if exists bug5240| --enable_warnings @@ -2831,6 +2837,8 @@ insert into t1 values ("answer", 42)| select id, bug5240() from t1| drop function bug5240| +--enable_ps_protocol + # # BUG#5278: Stored procedure packets out of order if SET PASSWORD. # -- cgit v1.2.1 From 3d35d3066d624fb1b07efc33b5a560debc4f3e02 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 15 Feb 2005 18:45:42 -0800 Subject: delete.result, delete.test: Added a test case for bug #8392. sql_delete.cc: Fixed bug #8392. The bug caused a crash for a delete statement with ORDER BY that explicitly referred to the modified table. sql/sql_delete.cc: Fixed bug #8392. The bug caused a crash for a delete statement with ORDER BY that explicitly referred to the modified table. mysql-test/t/delete.test: Added a test case for bug #8392. mysql-test/r/delete.result: Added a test case for bug #8392. --- mysql-test/r/delete.result | 9 +++++++++ mysql-test/t/delete.test | 11 +++++++++++ sql/sql_delete.cc | 1 + 3 files changed, 21 insertions(+) diff --git a/mysql-test/r/delete.result b/mysql-test/r/delete.result index 7353e687ae7..378371f2982 100644 --- a/mysql-test/r/delete.result +++ b/mysql-test/r/delete.result @@ -61,3 +61,12 @@ select * from t1; a b 1 apple drop table t1; +CREATE TABLE t1 ( a int PRIMARY KEY ); +DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +INSERT INTO t1 VALUES (0),(1),(2); +DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1; +SELECT * FROM t1; +a +0 +2 +DROP TABLE t1; diff --git a/mysql-test/t/delete.test b/mysql-test/t/delete.test index 07cb9155b3f..5fcdd6263ed 100644 --- a/mysql-test/t/delete.test +++ b/mysql-test/t/delete.test @@ -71,3 +71,14 @@ select * from t1; delete t1 from t1, t1 as t2 where t1.b = t2.b and t1.a > t2.a; select * from t1; drop table t1; + +# +# Bug #8392: delete with ORDER BY containing a direct reference to the table +# + +CREATE TABLE t1 ( a int PRIMARY KEY ); +DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a; +INSERT INTO t1 VALUES (0),(1),(2); +DELETE FROM t1 WHERE t1.a > 0 ORDER BY t1.a LIMIT 1; +SELECT * FROM t1; +DROP TABLE t1; diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 92193e3abf2..475df34dc4f 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -111,6 +111,7 @@ int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, ORDER *order, bzero((char*) &tables,sizeof(tables)); tables.table = table; + tables.alias = table_list->alias; table->io_cache = (IO_CACHE *) my_malloc(sizeof(IO_CACHE), MYF(MY_FAE | MY_ZEROFILL)); -- cgit v1.2.1 From ae751df48b80d5439f461c9c642d9793d5c99a6f Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 11:19:47 +0400 Subject: Fix - to not to call val_xxx in Item_func_interval twice sql/item_cmpfunc.cc: code fixed not to call val_x twice --- sql/item_cmpfunc.cc | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 0fa7ffcdda8..3884cce8451 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -895,15 +895,24 @@ void Item_func_interval::fix_length_and_dec() longlong Item_func_interval::val_int() { DBUG_ASSERT(fixed == 1); - double value= row->el(0)->val_real(); + double value; my_decimal dec_buf, *dec= NULL; uint i; if (use_decimal_comparison) + { dec= row->el(0)->val_decimal(&dec_buf); + if (row->el(0)->null_value) + return -1; + my_decimal2double(E_DEC_FATAL_ERROR, dec, &value); + } + else + { + value= row->el(0)->val_real(); + if (row->el(0)->null_value) + return -1; + } - if (row->el(0)->null_value) - return -1; // -1 if null if (intervals) { // Use binary search to find interval uint start,end; -- cgit v1.2.1 From 7b322d676043240bca4f1143cbd924549cc80538 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 11:44:34 +0400 Subject: Fix for bug #8534 (Compile errors in Precision Math code on Windows) sql/filesort.cc: Type of the parameter changed sql/my_decimal.cc: type of the parameter changed sql/my_decimal.h: Parameter type changed --- sql/filesort.cc | 2 +- sql/my_decimal.cc | 2 +- sql/my_decimal.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/sql/filesort.cc b/sql/filesort.cc index c05baa7cc04..de14287003b 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -719,7 +719,7 @@ static void make_sortkey(register SORTPARAM *param, } *to++=1; } - my_decimal2binary(E_DEC_FATAL_ERROR, dec_val, (byte*)to, + my_decimal2binary(E_DEC_FATAL_ERROR, dec_val, (char*)to, item->max_length - (item->decimals ? 1:0), item->decimals); break; diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index f028b1fa1a1..36229d1c795 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -116,7 +116,7 @@ int my_decimal2string(uint mask, const my_decimal *d, E_DEC_OVERFLOW */ -int my_decimal2binary(uint mask, const my_decimal *d, byte *bin, int prec, +int my_decimal2binary(uint mask, const my_decimal *d, char *bin, int prec, int scale) { int err1= E_DEC_OK, err2; diff --git a/sql/my_decimal.h b/sql/my_decimal.h index 63d3fb7e2e5..f4841418074 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -150,12 +150,12 @@ void my_decimal2decimal(const my_decimal *from, my_decimal *to) } -int my_decimal2binary(uint mask, const my_decimal *d, byte *bin, int prec, +int my_decimal2binary(uint mask, const my_decimal *d, char *bin, int prec, int scale); inline -int binary2my_decimal(uint mask, const byte *bin, my_decimal *d, int prec, +int binary2my_decimal(uint mask, const char *bin, my_decimal *d, int prec, int scale) { return check_result(mask, bin2decimal((char *)bin, (decimal *)d, prec, -- cgit v1.2.1 From 9e300f460688383a3ec775183c9a591446b218df Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 10:01:05 +0100 Subject: rpl_multi_query.test: disable ps-protocol as PS don't support multi-queries mysql-test/t/rpl_multi_query.test: disable ps-protocol as PS don't support multi-queries --- mysql-test/t/rpl_multi_query.test | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mysql-test/t/rpl_multi_query.test b/mysql-test/t/rpl_multi_query.test index 15f5d288759..482a2679e7a 100644 --- a/mysql-test/t/rpl_multi_query.test +++ b/mysql-test/t/rpl_multi_query.test @@ -3,6 +3,9 @@ # CLIENT_MULTI_STATEMENTS) will be binlogged ONE-query-per-event (not # one binlog event containing all queries) +# PS doesn't support multi-statements +--disable_ps_protocol + source include/master-slave.inc; --disable_warnings drop database if exists mysqltest; -- cgit v1.2.1 From 8f5ad880e0a461ee2c69efc4ecfc7276af3c951c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 13:00:03 +0300 Subject: Fix for bug#7915: crash,JOIN VIEW, subquery, SELECT .. FROM INFORMATION_SCHEMA.COLUMNS --- mysql-test/r/information_schema.result | 6 ++++++ mysql-test/t/information_schema.test | 11 +++++++++++ sql/sql_lex.cc | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result index 9bf21e9f061..87e6062d411 100644 --- a/mysql-test/r/information_schema.result +++ b/mysql-test/r/information_schema.result @@ -604,3 +604,9 @@ Variable_name Value show global status like "Threads_running"; Variable_name Value Threads_running 1 +create table t1(f1 int); +create table t2(f2 int); +create view v1 as select * from t1, t2; +set @got_val= (select count(*) from information_schema.columns); +drop view v1; +drop table t1, t2; diff --git a/mysql-test/t/information_schema.test b/mysql-test/t/information_schema.test index c34dfc94576..baf817b7c84 100644 --- a/mysql-test/t/information_schema.test +++ b/mysql-test/t/information_schema.test @@ -352,3 +352,14 @@ show variables where variable_name like "skip_show_databas"; # Bug #7981:SHOW GLOBAL STATUS crashes server # show global status like "Threads_running"; + +# +# Bug #7915 crash,JOIN VIEW, subquery, +# SELECT .. FROM INFORMATION_SCHEMA.COLUMNS +# +create table t1(f1 int); +create table t2(f2 int); +create view v1 as select * from t1, t2; +set @got_val= (select count(*) from information_schema.columns); +drop view v1; +drop table t1, t2; diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 30c657c3b79..08cf4402b74 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1733,6 +1733,12 @@ bool st_lex::can_not_use_merged() { case SQLCOM_CREATE_VIEW: case SQLCOM_SHOW_CREATE: + /* + SQLCOM_SHOW_FIELDS is necessary to make + information schema tables working correctly with views. + see get_schema_tables_result function + */ + case SQLCOM_SHOW_FIELDS: return TRUE; default: return FALSE; -- cgit v1.2.1 From b970c31c126f95021bd653089480a91157ea76c7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 11:02:48 +0100 Subject: Fix ndb_autodiscover mysql-test/r/ndb_autodiscover.result: Added warning printout to result --- mysql-test/r/ndb_autodiscover.result | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mysql-test/r/ndb_autodiscover.result b/mysql-test/r/ndb_autodiscover.result index ba21483a9b0..1316e33c9ba 100644 --- a/mysql-test/r/ndb_autodiscover.result +++ b/mysql-test/r/ndb_autodiscover.result @@ -167,6 +167,8 @@ show status like 'handler_discover%'; Variable_name Value Handler_discover 0 drop table t4; +Warnings: +Error 1296 Got error 709 'No such table existed' from NDB flush status; create table t4( id int not null primary key, -- cgit v1.2.1 From 7a630ec0587b88ad065442789a5cfc26714692fb Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 12:45:59 +0100 Subject: ndb - fix old decimal type mysql vs ndb mysql-test/r/ndb_index_ordered.result: fix old decimal type mysql vs ndb (re-commit 3) mysql-test/t/ndb_index_ordered.test: fix old decimal type mysql vs ndb (re-commit 3) ndb/include/kernel/signaldata/DictTabInfo.hpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/include/ndbapi/NdbDictionary.hpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/include/util/NdbSqlUtil.hpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/src/common/util/NdbSqlUtil.cpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/src/ndbapi/NdbDictionary.cpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/src/ndbapi/NdbDictionaryImpl.cpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/src/ndbapi/NdbRecAttr.cpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/test/include/NdbSchemaOp.hpp: fix old decimal type mysql vs ndb (re-commit 3) ndb/tools/restore/consumer.cpp: fix old decimal type mysql vs ndb (re-commit 3) sql/ha_ndbcluster.cc: fix old decimal type mysql vs ndb (re-commit 3) --- mysql-test/r/ndb_index_ordered.result | 83 +++++++++++++++++++ mysql-test/t/ndb_index_ordered.test | 52 ++++++++++++ ndb/include/kernel/signaldata/DictTabInfo.hpp | 20 ++++- ndb/include/ndbapi/NdbDictionary.hpp | 13 +-- ndb/include/util/NdbSqlUtil.hpp | 13 ++- ndb/src/common/util/NdbSqlUtil.cpp | 114 ++++++++++++++++++-------- ndb/src/ndbapi/NdbDictionary.cpp | 7 +- ndb/src/ndbapi/NdbDictionaryImpl.cpp | 6 +- ndb/src/ndbapi/NdbRecAttr.cpp | 15 +++- ndb/test/include/NdbSchemaOp.hpp | 3 +- ndb/tools/restore/consumer.cpp | 5 +- sql/ha_ndbcluster.cc | 34 ++++++-- 12 files changed, 304 insertions(+), 61 deletions(-) diff --git a/mysql-test/r/ndb_index_ordered.result b/mysql-test/r/ndb_index_ordered.result index 12438f247c3..f5794d477f3 100644 --- a/mysql-test/r/ndb_index_ordered.result +++ b/mysql-test/r/ndb_index_ordered.result @@ -445,6 +445,89 @@ select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59'; count(*)-9 0 drop table t1; +create table t1 ( +a int primary key, +s decimal(12), +t decimal(12, 5), +u decimal(12) unsigned, +v decimal(12, 5) unsigned, +key (s), +key (t), +key (u), +key (v) +) engine=ndb; +insert into t1 values +( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), +( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), +( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), +( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), +( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), +( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), +( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), +( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), +( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), +( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); +select count(*)- 5 from t1 use index (s) where s < -000000000007; +count(*)- 5 +0 +select count(*)- 7 from t1 use index (s) where s <= -000000000007; +count(*)- 7 +0 +select count(*)- 2 from t1 use index (s) where s = -000000000007; +count(*)- 2 +0 +select count(*)- 5 from t1 use index (s) where s >= -000000000007; +count(*)- 5 +0 +select count(*)- 3 from t1 use index (s) where s > -000000000007; +count(*)- 3 +0 +select count(*)- 4 from t1 use index (t) where t < -0000061.00003; +count(*)- 4 +0 +select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; +count(*)- 5 +0 +select count(*)- 1 from t1 use index (t) where t = -0000061.00003; +count(*)- 1 +0 +select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; +count(*)- 6 +0 +select count(*)- 5 from t1 use index (t) where t > -0000061.00003; +count(*)- 5 +0 +select count(*)- 2 from t1 use index (u) where u < 000000000061; +count(*)- 2 +0 +select count(*)- 4 from t1 use index (u) where u <= 000000000061; +count(*)- 4 +0 +select count(*)- 2 from t1 use index (u) where u = 000000000061; +count(*)- 2 +0 +select count(*)- 8 from t1 use index (u) where u >= 000000000061; +count(*)- 8 +0 +select count(*)- 6 from t1 use index (u) where u > 000000000061; +count(*)- 6 +0 +select count(*)- 5 from t1 use index (v) where v < 0000965.00042; +count(*)- 5 +0 +select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; +count(*)- 6 +0 +select count(*)- 1 from t1 use index (v) where v = 0000965.00042; +count(*)- 1 +0 +select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; +count(*)- 5 +0 +select count(*)- 4 from t1 use index (v) where v > 0000965.00042; +count(*)- 4 +0 +drop table t1; create table t1(a int primary key, b int not null, index(b)); insert into t1 values (1,1), (2,2); set autocommit=0; diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index 47e6b93eb81..010060a694d 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -249,6 +249,58 @@ select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59'; drop table t1; +# decimal (not the new 5.0 thing) + +create table t1 ( + a int primary key, + s decimal(12), + t decimal(12, 5), + u decimal(12) unsigned, + v decimal(12, 5) unsigned, + key (s), + key (t), + key (u), + key (v) +) engine=ndb; +# +insert into t1 values + ( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), + ( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), + ( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), + ( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), + ( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), + ( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), + ( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), + ( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), + ( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), + ( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); +# +select count(*)- 5 from t1 use index (s) where s < -000000000007; +select count(*)- 7 from t1 use index (s) where s <= -000000000007; +select count(*)- 2 from t1 use index (s) where s = -000000000007; +select count(*)- 5 from t1 use index (s) where s >= -000000000007; +select count(*)- 3 from t1 use index (s) where s > -000000000007; +# +select count(*)- 4 from t1 use index (t) where t < -0000061.00003; +select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; +select count(*)- 1 from t1 use index (t) where t = -0000061.00003; +select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; +select count(*)- 5 from t1 use index (t) where t > -0000061.00003; +# +select count(*)- 2 from t1 use index (u) where u < 000000000061; +select count(*)- 4 from t1 use index (u) where u <= 000000000061; +select count(*)- 2 from t1 use index (u) where u = 000000000061; +select count(*)- 8 from t1 use index (u) where u >= 000000000061; +select count(*)- 6 from t1 use index (u) where u > 000000000061; +# +select count(*)- 5 from t1 use index (v) where v < 0000965.00042; +select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; +select count(*)- 1 from t1 use index (v) where v = 0000965.00042; +select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; +select count(*)- 4 from t1 use index (v) where v > 0000965.00042; + +drop table t1; + # bug#7798 create table t1(a int primary key, b int not null, index(b)); insert into t1 values (1,1), (2,2); diff --git a/ndb/include/kernel/signaldata/DictTabInfo.hpp b/ndb/include/kernel/signaldata/DictTabInfo.hpp index ade6c22a5bd..a2f9fcc9799 100644 --- a/ndb/include/kernel/signaldata/DictTabInfo.hpp +++ b/ndb/include/kernel/signaldata/DictTabInfo.hpp @@ -302,7 +302,8 @@ public: ExtBigunsigned = NdbSqlUtil::Type::Bigunsigned, ExtFloat = NdbSqlUtil::Type::Float, ExtDouble = NdbSqlUtil::Type::Double, - ExtDecimal = NdbSqlUtil::Type::Decimal, + ExtOlddecimal = NdbSqlUtil::Type::Olddecimal, + ExtOlddecimalunsigned = NdbSqlUtil::Type::Olddecimalunsigned, ExtChar = NdbSqlUtil::Type::Char, ExtVarchar = NdbSqlUtil::Type::Varchar, ExtBinary = NdbSqlUtil::Type::Binary, @@ -411,9 +412,20 @@ public: AttributeSize = DictTabInfo::a64Bit; AttributeArraySize = AttributeExtLength; return true; - case DictTabInfo::ExtDecimal: - // not yet implemented anywhere - break; + case DictTabInfo::ExtOlddecimal: + AttributeType = DictTabInfo::StringType; + AttributeSize = DictTabInfo::an8Bit; + AttributeArraySize = + (1 + AttributeExtPrecision + (int(AttributeExtScale) > 0)) * + AttributeExtLength; + return true; + case DictTabInfo::ExtOlddecimalunsigned: + AttributeType = DictTabInfo::StringType; + AttributeSize = DictTabInfo::an8Bit; + AttributeArraySize = + (0 + AttributeExtPrecision + (int(AttributeExtScale) > 0)) * + AttributeExtLength; + return true; case DictTabInfo::ExtChar: case DictTabInfo::ExtBinary: AttributeType = DictTabInfo::StringType; diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp index 49afbd695c9..6aa675a2319 100644 --- a/ndb/include/ndbapi/NdbDictionary.hpp +++ b/ndb/include/ndbapi/NdbDictionary.hpp @@ -179,7 +179,7 @@ public: Bigunsigned, ///< 64 Bit. 8 byte signed integer, can be used in array Float, ///< 32-bit float. 4 bytes float, can be used in array Double, ///< 64-bit float. 8 byte float, can be used in array - Decimal, ///< Precision, Scale are applicable + Olddecimal, ///< MySQL < 5.0 signed decimal, Precision, Scale Char, ///< Len. A fixed array of 1-byte chars Varchar, ///< Max len Binary, ///< Len @@ -190,7 +190,8 @@ public: Text, ///< Text blob Time = 25, ///< Time without date Year = 26, ///< Year 1901-2155 (1 byte) - Timestamp = 27 ///< Unix time + Timestamp = 27, ///< Unix time + Olddecimalunsigned = 28 }; /** @@ -276,25 +277,25 @@ public: /** * Set precision of column. - * @note Only applicable for builtin type Decimal + * @note Only applicable for decimal types */ void setPrecision(int); /** * Get precision of column. - * @note Only applicable for builtin type Decimal + * @note Only applicable for decimal types */ int getPrecision() const; /** * Set scale of column. - * @note Only applicable for builtin type Decimal + * @note Only applicable for decimal types */ void setScale(int); /** * Get scale of column. - * @note Only applicable for builtin type Decimal + * @note Only applicable for decimal types */ int getScale() const; diff --git a/ndb/include/util/NdbSqlUtil.hpp b/ndb/include/util/NdbSqlUtil.hpp index 3787814052a..5b27bd4e0c4 100644 --- a/ndb/include/util/NdbSqlUtil.hpp +++ b/ndb/include/util/NdbSqlUtil.hpp @@ -75,7 +75,7 @@ public: Bigunsigned, // 64 Bit Float, // 32-bit float Double, // 64-bit float - Decimal, // Precision, Scale + Olddecimal, // Precision, Scale Char, // Len Varchar, // Max len Binary, // Len @@ -86,7 +86,8 @@ public: Text, // Text blob Time = 25, // Time without date Year = 26, // Year (size 1 byte) - Timestamp = 27 // Unix seconds (uint32) + Timestamp = 27, // Unix seconds (uint32) + Olddecimalunsigned = 28 }; Enum m_typeId; Cmp* m_cmp; // comparison method @@ -109,6 +110,11 @@ public: static bool usable_in_hash_index(Uint32 typeId, const void* cs); static bool usable_in_ordered_index(Uint32 typeId, const void* cs); + /** + * Compare decimal numbers. + */ + static int cmp_olddecimal(const uchar* s1, const uchar* s2, unsigned n); + private: /** * List of all types. Must match Type::Enum. @@ -129,7 +135,7 @@ private: static Cmp cmpBigunsigned; static Cmp cmpFloat; static Cmp cmpDouble; - static Cmp cmpDecimal; + static Cmp cmpOlddecimal; static Cmp cmpChar; static Cmp cmpVarchar; static Cmp cmpBinary; @@ -141,6 +147,7 @@ private: static Cmp cmpTime; static Cmp cmpYear; static Cmp cmpTimestamp; + static Cmp cmpOlddecimalunsigned; }; #endif diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp index 53fa5d69215..c4114ad5ffa 100644 --- a/ndb/src/common/util/NdbSqlUtil.cpp +++ b/ndb/src/common/util/NdbSqlUtil.cpp @@ -76,117 +76,121 @@ NdbSqlUtil::char_like(const char* s1, unsigned n1, const NdbSqlUtil::Type NdbSqlUtil::m_typeList[] = { - { + { // 0 Type::Undefined, NULL }, - { + { // 1 Type::Tinyint, cmpTinyint }, - { + { // 2 Type::Tinyunsigned, cmpTinyunsigned }, - { + { // 3 Type::Smallint, cmpSmallint }, - { + { // 4 Type::Smallunsigned, cmpSmallunsigned }, - { + { // 5 Type::Mediumint, cmpMediumint }, - { + { // 6 Type::Mediumunsigned, cmpMediumunsigned }, - { + { // 7 Type::Int, cmpInt }, - { + { // 8 Type::Unsigned, cmpUnsigned }, - { + { // 9 Type::Bigint, cmpBigint }, - { + { // 10 Type::Bigunsigned, cmpBigunsigned }, - { + { // 11 Type::Float, cmpFloat }, - { + { // 12 Type::Double, cmpDouble }, - { - Type::Decimal, - NULL // cmpDecimal + { // 13 + Type::Olddecimal, + cmpOlddecimal }, - { + { // 14 Type::Char, cmpChar }, - { + { // 15 Type::Varchar, cmpVarchar }, - { + { // 16 Type::Binary, cmpBinary }, - { + { // 17 Type::Varbinary, cmpVarbinary }, - { + { // 18 Type::Datetime, cmpDatetime }, - { + { // 19 Type::Date, cmpDate }, - { + { // 20 Type::Blob, cmpBlob }, - { + { // 21 Type::Text, cmpText }, - { + { // 22 Type::Undefined, // 5.0 Bit NULL }, - { + { // 23 Type::Undefined, // 5.0 Longvarchar NULL }, - { + { // 24 Type::Undefined, // 5.0 Longvarbinary NULL }, - { + { // 25 Type::Time, cmpTime }, - { + { // 26 Type::Year, cmpYear }, - { + { // 27 Type::Timestamp, cmpTimestamp + }, + { // 28 + Type::Olddecimalunsigned, + cmpOlddecimalunsigned } }; @@ -411,14 +415,56 @@ NdbSqlUtil::cmpDouble(const void* info, const Uint32* p1, const Uint32* p2, Uint } int -NdbSqlUtil::cmpDecimal(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +NdbSqlUtil::cmp_olddecimal(const uchar* s1, const uchar* s2, unsigned n) { - assert(full >= size && size > 0); - // not used by MySQL or NDB - assert(false); + int sgn = +1; + unsigned i = 0; + while (i < n) { + int c1 = s1[i]; + int c2 = s2[i]; + if (c1 == c2) { + if (c1 == '-') + sgn = -1; + } else if (c1 == '-') { + return -1; + } else if (c2 == '-') { + return +1; + } else if (c1 < c2) { + return -1 * sgn; + } else { + return +1 * sgn; + } + i++; + } return 0; } +int +NdbSqlUtil::cmpOlddecimal(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +{ + assert(full >= size && size > 0); + if (full == size) { + union { const Uint32* p; const uchar* v; } u1, u2; + u1.p = p1; + u2.p = p2; + return cmp_olddecimal(u1.v, u2.v, full << 2); + } + return CmpUnknown; +} + +int +NdbSqlUtil::cmpOlddecimalunsigned(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) +{ + assert(full >= size && size > 0); + if (full == size) { + union { const Uint32* p; const uchar* v; } u1, u2; + u1.p = p1; + u2.p = p2; + return cmp_olddecimal(u1.v, u2.v, full << 2); + } + return CmpUnknown; +} + int NdbSqlUtil::cmpChar(const void* info, const Uint32* p1, const Uint32* p2, Uint32 full, Uint32 size) { diff --git a/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp index 58b35c6c306..00db5704949 100644 --- a/ndb/src/ndbapi/NdbDictionary.cpp +++ b/ndb/src/ndbapi/NdbDictionary.cpp @@ -918,8 +918,11 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col) case NdbDictionary::Column::Double: out << "Double"; break; - case NdbDictionary::Column::Decimal: - out << "Decimal(" << col.getScale() << "," << col.getPrecision() << ")"; + case NdbDictionary::Column::Olddecimal: + out << "Olddecimal(" << col.getPrecision() << "," << col.getScale() << ")"; + break; + case NdbDictionary::Column::Olddecimalunsigned: + out << "Olddecimalunsigned(" << col.getPrecision() << "," << col.getScale() << ")"; break; case NdbDictionary::Column::Char: out << "Char(" << col.getLength() << ";" << csname << ")"; diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 530f15d3a2e..b9ae13a93ec 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -114,7 +114,8 @@ NdbColumnImpl::init(Type t) m_length = 1; m_cs = NULL; break; - case Decimal: + case Olddecimal: + case Olddecimalunsigned: m_precision = 10; m_scale = 0; m_length = 1; @@ -1176,7 +1177,8 @@ columnTypeMapping[] = { { DictTabInfo::ExtBigunsigned, NdbDictionary::Column::Bigunsigned }, { DictTabInfo::ExtFloat, NdbDictionary::Column::Float }, { DictTabInfo::ExtDouble, NdbDictionary::Column::Double }, - { DictTabInfo::ExtDecimal, NdbDictionary::Column::Decimal }, + { DictTabInfo::ExtOlddecimal, NdbDictionary::Column::Olddecimal }, + { DictTabInfo::ExtOlddecimalunsigned, NdbDictionary::Column::Olddecimalunsigned }, { DictTabInfo::ExtChar, NdbDictionary::Column::Char }, { DictTabInfo::ExtVarchar, NdbDictionary::Column::Varchar }, { DictTabInfo::ExtBinary, NdbDictionary::Column::Binary }, diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index 9c9a9cea8da..db83e9c5fcf 100644 --- a/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/ndb/src/ndbapi/NdbRecAttr.cpp @@ -156,7 +156,8 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) return out; } - uint length = r.getColumn()->getLength(); + const NdbDictionary::Column* c = r.getColumn(); + uint length = c->getLength(); if (length > 1) out << "["; @@ -208,6 +209,18 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) case NdbDictionary::Column::Double: out << r.double_value(); break; + case NdbDictionary::Column::Olddecimal: + { + short len = 1 + c->getPrecision() + (c->getScale() > 0); + out.print("%.*s", len, r.aRef()); + } + break; + case NdbDictionary::Column::Olddecimalunsigned: + { + short len = 0 + c->getPrecision() + (c->getScale() > 0); + out.print("%.*s", len, r.aRef()); + } + break; // for dates cut-and-paste from field.cc case NdbDictionary::Column::Datetime: { diff --git a/ndb/test/include/NdbSchemaOp.hpp b/ndb/test/include/NdbSchemaOp.hpp index 77e704c0e5c..e8ab542b00a 100644 --- a/ndb/test/include/NdbSchemaOp.hpp +++ b/ndb/test/include/NdbSchemaOp.hpp @@ -567,7 +567,8 @@ convertColumnTypeToAttrType(NdbDictionary::Column::Type _type) case NdbDictionary::Column::Unsigned: return UnSigned; case NdbDictionary::Column::Float: - case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Olddecimal: + case NdbDictionary::Column::Olddecimalunsigned: case NdbDictionary::Column::Double: return Float; case NdbDictionary::Column::Char: diff --git a/ndb/tools/restore/consumer.cpp b/ndb/tools/restore/consumer.cpp index 4d228230423..ecbdbbf8f4e 100644 --- a/ndb/tools/restore/consumer.cpp +++ b/ndb/tools/restore/consumer.cpp @@ -44,9 +44,12 @@ BackupConsumer::create_table_string(const TableS & table, case NdbDictionary::Column::Float: pos += sprintf(buf+pos, "%s", "float"); break; - case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Olddecimal: pos += sprintf(buf+pos, "%s", "decimal"); break; + case NdbDictionary::Column::Olddecimalunsigned: + pos += sprintf(buf+pos, "%s", "decimal unsigned"); + break; case NdbDictionary::Column::Char: pos += sprintf(buf+pos, "%s", "char"); break; diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 9e34baae198..47cca937544 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -2276,10 +2276,14 @@ void ha_ndbcluster::print_results() fprintf(DBUG_FILE, "Double\t%f", value); break; } - case NdbDictionary::Column::Decimal: { + case NdbDictionary::Column::Olddecimal: { char *value= field->ptr; - - fprintf(DBUG_FILE, "Decimal\t'%-*s'", field->pack_length(), value); + fprintf(DBUG_FILE, "Olddecimal\t'%-*s'", field->pack_length(), value); + break; + } + case NdbDictionary::Column::Olddecimalunsigned: { + char *value= field->ptr; + fprintf(DBUG_FILE, "Olddecimalunsigned\t'%-*s'", field->pack_length(), value); break; } case NdbDictionary::Column::Char:{ @@ -3312,10 +3316,6 @@ static int create_ndb_column(NDBCOL &col, const enum enum_field_types mysql_type= field->real_type(); switch (mysql_type) { // Numeric types - case MYSQL_TYPE_DECIMAL: - col.setType(NDBCOL::Char); - col.setLength(field->pack_length()); - break; case MYSQL_TYPE_TINY: if (field->flags & UNSIGNED_FLAG) col.setType(NDBCOL::Tinyunsigned); @@ -3359,6 +3359,26 @@ static int create_ndb_column(NDBCOL &col, col.setType(NDBCOL::Double); col.setLength(1); break; + case MYSQL_TYPE_DECIMAL: + { + Field_decimal *f= (Field_decimal*)field; + uint precision= f->pack_length(); + uint scale= f->decimals(); + if (field->flags & UNSIGNED_FLAG) + { + col.setType(NDBCOL::Olddecimalunsigned); + precision-= (scale > 0); + } + else + { + col.setType(NDBCOL::Olddecimal); + precision-= 1 + (scale > 0); + } + col.setPrecision(precision); + col.setScale(scale); + col.setLength(1); + } + break; // Date types case MYSQL_TYPE_DATETIME: col.setType(NDBCOL::Datetime); -- cgit v1.2.1 From cbeeb4c260f25a75dff6493b57e3c33b51ed7e2b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 14:59:17 +0100 Subject: ndb - post-merge fixes ndb/include/ndb_constants.h: post-merge fixes ndb/include/ndbapi/NdbDictionary.hpp: post-merge fixes ndb/src/common/util/NdbSqlUtil.cpp: post-merge fixes ndb/test/src/HugoCalculator.cpp: post-merge fixes --- ndb/include/ndb_constants.h | 5 +++-- ndb/include/ndbapi/NdbDictionary.hpp | 3 +-- ndb/src/common/util/NdbSqlUtil.cpp | 1 + ndb/test/src/HugoCalculator.cpp | 3 ++- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/ndb/include/ndb_constants.h b/ndb/include/ndb_constants.h index da3fc2cbdd8..36d7ec95b3e 100644 --- a/ndb/include/ndb_constants.h +++ b/ndb/include/ndb_constants.h @@ -48,7 +48,7 @@ #define NDB_TYPE_BIGUNSIGNED 10 #define NDB_TYPE_FLOAT 11 #define NDB_TYPE_DOUBLE 12 -#define NDB_TYPE_DECIMAL 13 /* not used */ +#define NDB_TYPE_OLDDECIMAL 13 #define NDB_TYPE_CHAR 14 #define NDB_TYPE_VARCHAR 15 #define NDB_TYPE_BINARY 16 @@ -63,7 +63,8 @@ #define NDB_TYPE_TIME 25 #define NDB_TYPE_YEAR 26 #define NDB_TYPE_TIMESTAMP 27 +#define NDB_TYPE_OLDDECIMALUNSIGNED 28 -#define NDB_TYPE_MAX 28 +#define NDB_TYPE_MAX 29 #endif diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp index 391f0374afc..26f0e71b25c 100644 --- a/ndb/include/ndbapi/NdbDictionary.hpp +++ b/ndb/include/ndbapi/NdbDictionary.hpp @@ -184,9 +184,8 @@ public: Bigunsigned = NDB_TYPE_BIGUNSIGNED, ///< 64 Bit. 8 byte signed integer, can be used in array Float = NDB_TYPE_FLOAT, ///< 32-bit float. 4 bytes float, can be used in array Double = NDB_TYPE_DOUBLE, ///< 64-bit float. 8 byte float, can be used in array - Decimal = NDB_TYPE_DECIMAL, ///< Precision, Scale are applicable Olddecimal = NDB_TYPE_OLDDECIMAL, ///< MySQL < 5.0 signed decimal, Precision, Scale - Olddecimalunsigned = NDB_TYPE_OLDDECIMAL_UNSIGNED, + Olddecimalunsigned = NDB_TYPE_OLDDECIMALUNSIGNED, Char = NDB_TYPE_CHAR, ///< Len. A fixed array of 1-byte chars Varchar = NDB_TYPE_VARCHAR, ///< Length bytes: 1, Max: 255 Binary = NDB_TYPE_BINARY, ///< Len diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp index 08a436e13f7..2686ad5c05f 100644 --- a/ndb/src/common/util/NdbSqlUtil.cpp +++ b/ndb/src/common/util/NdbSqlUtil.cpp @@ -434,6 +434,7 @@ NdbSqlUtil::cmpDouble(const void* info, const void* p1, unsigned n1, const void* return CmpUnknown; } +int NdbSqlUtil::cmp_olddecimal(const uchar* s1, const uchar* s2, unsigned n) { int sgn = +1; diff --git a/ndb/test/src/HugoCalculator.cpp b/ndb/test/src/HugoCalculator.cpp index 44edb34295a..0a5b9c342c8 100644 --- a/ndb/test/src/HugoCalculator.cpp +++ b/ndb/test/src/HugoCalculator.cpp @@ -145,7 +145,8 @@ HugoCalculator::calcValue(int record, case NdbDictionary::Column::Bigunsigned: case NdbDictionary::Column::Float: case NdbDictionary::Column::Double: - case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Olddecimal: + case NdbDictionary::Column::Olddecimalunsigned: case NdbDictionary::Column::Binary: case NdbDictionary::Column::Datetime: case NdbDictionary::Column::Time: -- cgit v1.2.1 From df8286c23f30708c72530db0bc52e6c2d96a70f7 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 16:06:41 +0100 Subject: Fixed BUG#8540: Local variable overrides an alias. mysql-test/r/sp.result: New test case for BUG#8540. mysql-test/t/sp.test: New test case for BUG#8540. sql/item.h: Use the existing name (if any) for a SP local variable (to get the correct field name in a select in the case of an alias). --- mysql-test/r/sp.result | 10 ++++++++++ mysql-test/t/sp.test | 16 ++++++++++++++++ sql/item.h | 5 ++++- 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/sp.result b/mysql-test/r/sp.result index 0af6b821ce0..05803e57ba0 100644 --- a/mysql-test/r/sp.result +++ b/mysql-test/r/sp.result @@ -2059,6 +2059,16 @@ call bug6029()| 1136 drop procedure bug6029| drop table t3| +drop procedure if exists bug8540| +create procedure bug8540() +begin +declare x int default 1; +select x as y, x+0 as z; +end| +call bug8540()| +y z +1 1 +drop procedure bug8540| drop table if exists fac| create table fac (n int unsigned not null primary key, f bigint unsigned)| drop procedure if exists ifac| diff --git a/mysql-test/t/sp.test b/mysql-test/t/sp.test index bdc5ec0dc22..8b59af6e494 100644 --- a/mysql-test/t/sp.test +++ b/mysql-test/t/sp.test @@ -2520,6 +2520,22 @@ call bug6029()| drop procedure bug6029| drop table t3| +# +# BUG#8540: Local variable overrides an alias +# +--disable_warnings +drop procedure if exists bug8540| +--enable_warnings + +create procedure bug8540() +begin + declare x int default 1; + select x as y, x+0 as z; +end| + +call bug8540()| +drop procedure bug8540| + # # Some "real" examples diff --git a/sql/item.h b/sql/item.h index 299bc6c081b..7d9526b53a8 100644 --- a/sql/item.h +++ b/sql/item.h @@ -460,7 +460,10 @@ public: { Item *it= this_item(); - it->set_name(m_name.str, m_name.length, system_charset_info); + if (name) + it->set_name(name, strlen(name), system_charset_info); + else + it->set_name(m_name.str, m_name.length, system_charset_info); it->make_field(field); } -- cgit v1.2.1 From 7bc5e32322666a9224a2a8ee7b8c2c7c200253fa Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 16:05:18 +0000 Subject: Bug#4445 Make a more informative platform info for Windows --- include/config-win.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/include/config-win.h b/include/config-win.h index 152e85c8e68..42aa23c3afe 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -23,18 +23,25 @@ #include #include -#if defined(__NT__) -#define SYSTEM_TYPE "NT" -#elif defined(__WIN2000__) -#define SYSTEM_TYPE "WIN2000" +#if defined(_WIN64) || defined(WIN64) +#define SYSTEM_TYPE "Win64" +#elif defined(_WIN32) || defined(WIN32) +#define SYSTEM_TYPE "Win32" #else -#define SYSTEM_TYPE "Win95/Win98" +#define SYSTEM_TYPE "Windows" #endif -#if defined(_WIN64) || defined(WIN64) -#define MACHINE_TYPE "ia64" /* Define to machine type name */ +#if defined(_M_IA64) +#define MACHINE_TYPE "ia64" +#elif defined(_M_IX86) +#define MACHINE_TYPE "ia32" +#elif defined(_M_ALPHA) +#define MACHINE_TYPE "axp" #else -#define MACHINE_TYPE "i32" /* Define to machine type name */ +#define MACHINE_TYPE "unknown" /* Define to machine type name */ +#endif + +#if !(defined(_WIN64) || defined(WIN64)) #ifndef _WIN32 #define _WIN32 /* Compatible with old source */ #endif -- cgit v1.2.1 From f67d3b97d9e07fc18b39a3401323251744ca29ac Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 17:10:17 +0100 Subject: ndb - temp: comment out decimal tests t/ndb* mysql-test/r/ndb_index_ordered.result: temp: comment out decimal mysql-test/t/ndb_index_ordered.test: temp: comment out decimal --- mysql-test/r/ndb_index_ordered.result | 83 ------------------------------ mysql-test/t/ndb_index_ordered.test | 96 +++++++++++++++++------------------ 2 files changed, 48 insertions(+), 131 deletions(-) diff --git a/mysql-test/r/ndb_index_ordered.result b/mysql-test/r/ndb_index_ordered.result index 212c843cc44..9aa7559d660 100644 --- a/mysql-test/r/ndb_index_ordered.result +++ b/mysql-test/r/ndb_index_ordered.result @@ -554,89 +554,6 @@ select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59'; count(*)-9 0 drop table t1; -create table t1 ( -a int primary key, -s decimal(12), -t decimal(12, 5), -u decimal(12) unsigned, -v decimal(12, 5) unsigned, -key (s), -key (t), -key (u), -key (v) -) engine=ndb; -insert into t1 values -( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), -( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), -( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), -( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), -( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), -( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), -( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), -( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), -( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), -( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); -select count(*)- 5 from t1 use index (s) where s < -000000000007; -count(*)- 5 -0 -select count(*)- 7 from t1 use index (s) where s <= -000000000007; -count(*)- 7 -0 -select count(*)- 2 from t1 use index (s) where s = -000000000007; -count(*)- 2 -0 -select count(*)- 5 from t1 use index (s) where s >= -000000000007; -count(*)- 5 -0 -select count(*)- 3 from t1 use index (s) where s > -000000000007; -count(*)- 3 -0 -select count(*)- 4 from t1 use index (t) where t < -0000061.00003; -count(*)- 4 -0 -select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; -count(*)- 5 -0 -select count(*)- 1 from t1 use index (t) where t = -0000061.00003; -count(*)- 1 -0 -select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; -count(*)- 6 -0 -select count(*)- 5 from t1 use index (t) where t > -0000061.00003; -count(*)- 5 -0 -select count(*)- 2 from t1 use index (u) where u < 000000000061; -count(*)- 2 -0 -select count(*)- 4 from t1 use index (u) where u <= 000000000061; -count(*)- 4 -0 -select count(*)- 2 from t1 use index (u) where u = 000000000061; -count(*)- 2 -0 -select count(*)- 8 from t1 use index (u) where u >= 000000000061; -count(*)- 8 -0 -select count(*)- 6 from t1 use index (u) where u > 000000000061; -count(*)- 6 -0 -select count(*)- 5 from t1 use index (v) where v < 0000965.00042; -count(*)- 5 -0 -select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; -count(*)- 6 -0 -select count(*)- 1 from t1 use index (v) where v = 0000965.00042; -count(*)- 1 -0 -select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; -count(*)- 5 -0 -select count(*)- 4 from t1 use index (v) where v > 0000965.00042; -count(*)- 4 -0 -drop table t1; create table t1(a int primary key, b int not null, index(b)); insert into t1 values (1,1), (2,2); set autocommit=0; diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index 2ebf06b78a8..1e07ca93c30 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -282,55 +282,55 @@ drop table t1; # decimal (not the new 5.0 thing) -create table t1 ( - a int primary key, - s decimal(12), - t decimal(12, 5), - u decimal(12) unsigned, - v decimal(12, 5) unsigned, - key (s), - key (t), - key (u), - key (v) -) engine=ndb; -# -insert into t1 values - ( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), - ( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), - ( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), - ( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), - ( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), - ( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), - ( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), - ( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), - ( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), - ( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); -# -select count(*)- 5 from t1 use index (s) where s < -000000000007; -select count(*)- 7 from t1 use index (s) where s <= -000000000007; -select count(*)- 2 from t1 use index (s) where s = -000000000007; -select count(*)- 5 from t1 use index (s) where s >= -000000000007; -select count(*)- 3 from t1 use index (s) where s > -000000000007; +#create table t1 ( +# a int primary key, +# s decimal(12), +# t decimal(12, 5), +# u decimal(12) unsigned, +# v decimal(12, 5) unsigned, +# key (s), +# key (t), +# key (u), +# key (v) +#) engine=ndb; +## +#insert into t1 values +# ( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), +# ( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), +# ( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), +# ( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), +# ( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), +# ( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), +# ( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), +# ( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), +# ( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), +# ( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); +## +#select count(*)- 5 from t1 use index (s) where s < -000000000007; +#select count(*)- 7 from t1 use index (s) where s <= -000000000007; +#select count(*)- 2 from t1 use index (s) where s = -000000000007; +#select count(*)- 5 from t1 use index (s) where s >= -000000000007; +#select count(*)- 3 from t1 use index (s) where s > -000000000007; +## +#select count(*)- 4 from t1 use index (t) where t < -0000061.00003; +#select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; +#select count(*)- 1 from t1 use index (t) where t = -0000061.00003; +#select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; +#select count(*)- 5 from t1 use index (t) where t > -0000061.00003; +## +#select count(*)- 2 from t1 use index (u) where u < 000000000061; +#select count(*)- 4 from t1 use index (u) where u <= 000000000061; +#select count(*)- 2 from t1 use index (u) where u = 000000000061; +#select count(*)- 8 from t1 use index (u) where u >= 000000000061; +#select count(*)- 6 from t1 use index (u) where u > 000000000061; +## +#select count(*)- 5 from t1 use index (v) where v < 0000965.00042; +#select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; +#select count(*)- 1 from t1 use index (v) where v = 0000965.00042; +#select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; +#select count(*)- 4 from t1 use index (v) where v > 0000965.00042; # -select count(*)- 4 from t1 use index (t) where t < -0000061.00003; -select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; -select count(*)- 1 from t1 use index (t) where t = -0000061.00003; -select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; -select count(*)- 5 from t1 use index (t) where t > -0000061.00003; -# -select count(*)- 2 from t1 use index (u) where u < 000000000061; -select count(*)- 4 from t1 use index (u) where u <= 000000000061; -select count(*)- 2 from t1 use index (u) where u = 000000000061; -select count(*)- 8 from t1 use index (u) where u >= 000000000061; -select count(*)- 6 from t1 use index (u) where u > 000000000061; -# -select count(*)- 5 from t1 use index (v) where v < 0000965.00042; -select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; -select count(*)- 1 from t1 use index (v) where v = 0000965.00042; -select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; -select count(*)- 4 from t1 use index (v) where v > 0000965.00042; - -drop table t1; +#drop table t1; # bug#7798 create table t1(a int primary key, b int not null, index(b)); -- cgit v1.2.1 From 6fa487fad77dfecc83b55e4329236aa277a7283b Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 21:19:42 +0100 Subject: ndb - fix new decimal type mysql vs. ndb mysql-test/r/ndb_index_ordered.result: fix new decimal mysql vs. ndb mysql-test/t/ndb_index_ordered.test: fix new decimal mysql vs. ndb ndb/include/kernel/signaldata/DictTabInfo.hpp: fix new decimal mysql vs. ndb ndb/include/ndb_constants.h: fix new decimal mysql vs. ndb ndb/include/ndbapi/NdbDictionary.hpp: fix new decimal mysql vs. ndb ndb/include/util/NdbSqlUtil.hpp: fix new decimal mysql vs. ndb ndb/src/common/util/NdbSqlUtil.cpp: fix new decimal mysql vs. ndb ndb/src/ndbapi/NdbDictionary.cpp: fix new decimal mysql vs. ndb ndb/src/ndbapi/NdbDictionaryImpl.cpp: fix new decimal mysql vs. ndb ndb/src/ndbapi/NdbRecAttr.cpp: fix new decimal mysql vs. ndb ndb/test/include/NdbSchemaOp.hpp: fix new decimal mysql vs. ndb ndb/test/src/HugoCalculator.cpp: fix new decimal mysql vs. ndb ndb/tools/restore/consumer.cpp: fix new decimal mysql vs. ndb sql/ha_ndbcluster.cc: fix new decimal mysql vs. ndb --- mysql-test/r/ndb_index_ordered.result | 83 +++++++++++++++++++++++ mysql-test/t/ndb_index_ordered.test | 96 +++++++++++++-------------- ndb/include/kernel/signaldata/DictTabInfo.hpp | 37 +++++++++++ ndb/include/ndb_constants.h | 4 +- ndb/include/ndbapi/NdbDictionary.hpp | 2 + ndb/include/util/NdbSqlUtil.hpp | 6 +- ndb/src/common/util/NdbSqlUtil.cpp | 36 ++++++++++ ndb/src/ndbapi/NdbDictionary.cpp | 6 ++ ndb/src/ndbapi/NdbDictionaryImpl.cpp | 2 + ndb/src/ndbapi/NdbRecAttr.cpp | 5 ++ ndb/test/include/NdbSchemaOp.hpp | 2 + ndb/test/src/HugoCalculator.cpp | 2 + ndb/tools/restore/consumer.cpp | 2 + sql/ha_ndbcluster.cc | 21 +++++- 14 files changed, 253 insertions(+), 51 deletions(-) diff --git a/mysql-test/r/ndb_index_ordered.result b/mysql-test/r/ndb_index_ordered.result index 9aa7559d660..212c843cc44 100644 --- a/mysql-test/r/ndb_index_ordered.result +++ b/mysql-test/r/ndb_index_ordered.result @@ -554,6 +554,89 @@ select count(*)-9 from t1 use index (ts) where ts <= '2001-01-01 23:59:59'; count(*)-9 0 drop table t1; +create table t1 ( +a int primary key, +s decimal(12), +t decimal(12, 5), +u decimal(12) unsigned, +v decimal(12, 5) unsigned, +key (s), +key (t), +key (u), +key (v) +) engine=ndb; +insert into t1 values +( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), +( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), +( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), +( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), +( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), +( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), +( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), +( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), +( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), +( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); +select count(*)- 5 from t1 use index (s) where s < -000000000007; +count(*)- 5 +0 +select count(*)- 7 from t1 use index (s) where s <= -000000000007; +count(*)- 7 +0 +select count(*)- 2 from t1 use index (s) where s = -000000000007; +count(*)- 2 +0 +select count(*)- 5 from t1 use index (s) where s >= -000000000007; +count(*)- 5 +0 +select count(*)- 3 from t1 use index (s) where s > -000000000007; +count(*)- 3 +0 +select count(*)- 4 from t1 use index (t) where t < -0000061.00003; +count(*)- 4 +0 +select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; +count(*)- 5 +0 +select count(*)- 1 from t1 use index (t) where t = -0000061.00003; +count(*)- 1 +0 +select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; +count(*)- 6 +0 +select count(*)- 5 from t1 use index (t) where t > -0000061.00003; +count(*)- 5 +0 +select count(*)- 2 from t1 use index (u) where u < 000000000061; +count(*)- 2 +0 +select count(*)- 4 from t1 use index (u) where u <= 000000000061; +count(*)- 4 +0 +select count(*)- 2 from t1 use index (u) where u = 000000000061; +count(*)- 2 +0 +select count(*)- 8 from t1 use index (u) where u >= 000000000061; +count(*)- 8 +0 +select count(*)- 6 from t1 use index (u) where u > 000000000061; +count(*)- 6 +0 +select count(*)- 5 from t1 use index (v) where v < 0000965.00042; +count(*)- 5 +0 +select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; +count(*)- 6 +0 +select count(*)- 1 from t1 use index (v) where v = 0000965.00042; +count(*)- 1 +0 +select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; +count(*)- 5 +0 +select count(*)- 4 from t1 use index (v) where v > 0000965.00042; +count(*)- 4 +0 +drop table t1; create table t1(a int primary key, b int not null, index(b)); insert into t1 values (1,1), (2,2); set autocommit=0; diff --git a/mysql-test/t/ndb_index_ordered.test b/mysql-test/t/ndb_index_ordered.test index 1e07ca93c30..2ebf06b78a8 100644 --- a/mysql-test/t/ndb_index_ordered.test +++ b/mysql-test/t/ndb_index_ordered.test @@ -282,55 +282,55 @@ drop table t1; # decimal (not the new 5.0 thing) -#create table t1 ( -# a int primary key, -# s decimal(12), -# t decimal(12, 5), -# u decimal(12) unsigned, -# v decimal(12, 5) unsigned, -# key (s), -# key (t), -# key (u), -# key (v) -#) engine=ndb; -## -#insert into t1 values -# ( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), -# ( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), -# ( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), -# ( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), -# ( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), -# ( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), -# ( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), -# ( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), -# ( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), -# ( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); -## -#select count(*)- 5 from t1 use index (s) where s < -000000000007; -#select count(*)- 7 from t1 use index (s) where s <= -000000000007; -#select count(*)- 2 from t1 use index (s) where s = -000000000007; -#select count(*)- 5 from t1 use index (s) where s >= -000000000007; -#select count(*)- 3 from t1 use index (s) where s > -000000000007; -## -#select count(*)- 4 from t1 use index (t) where t < -0000061.00003; -#select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; -#select count(*)- 1 from t1 use index (t) where t = -0000061.00003; -#select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; -#select count(*)- 5 from t1 use index (t) where t > -0000061.00003; -## -#select count(*)- 2 from t1 use index (u) where u < 000000000061; -#select count(*)- 4 from t1 use index (u) where u <= 000000000061; -#select count(*)- 2 from t1 use index (u) where u = 000000000061; -#select count(*)- 8 from t1 use index (u) where u >= 000000000061; -#select count(*)- 6 from t1 use index (u) where u > 000000000061; -## -#select count(*)- 5 from t1 use index (v) where v < 0000965.00042; -#select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; -#select count(*)- 1 from t1 use index (v) where v = 0000965.00042; -#select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; -#select count(*)- 4 from t1 use index (v) where v > 0000965.00042; +create table t1 ( + a int primary key, + s decimal(12), + t decimal(12, 5), + u decimal(12) unsigned, + v decimal(12, 5) unsigned, + key (s), + key (t), + key (u), + key (v) +) engine=ndb; +# +insert into t1 values + ( 0, -000000000007, -0000061.00003, 000000000061, 0000965.00042), + ( 1, -000000000007, -0000061.00042, 000000000061, 0000965.00003), + ( 2, -071006035767, 4210253.00024, 000000000001, 0000001.84488), + ( 3, 000000007115, 0000000.77607, 000077350625, 0000018.00013), + ( 4, -000000068391, -0346486.00000, 000000005071, 0005334.00002), + ( 5, -521579890459, -1936874.00001, 000000000154, 0000003.00018), + ( 6, -521579890459, -1936874.00018, 000000000154, 0000003.00001), + ( 7, 000000000333, 0000051.39140, 000000907958, 0788643.08374), + ( 8, 000042731229, 0000009.00000, 000000000009, 6428667.00000), + ( 9, -000008159769, 0000918.00004, 000096951421, 7607730.00008); +# +select count(*)- 5 from t1 use index (s) where s < -000000000007; +select count(*)- 7 from t1 use index (s) where s <= -000000000007; +select count(*)- 2 from t1 use index (s) where s = -000000000007; +select count(*)- 5 from t1 use index (s) where s >= -000000000007; +select count(*)- 3 from t1 use index (s) where s > -000000000007; # -#drop table t1; +select count(*)- 4 from t1 use index (t) where t < -0000061.00003; +select count(*)- 5 from t1 use index (t) where t <= -0000061.00003; +select count(*)- 1 from t1 use index (t) where t = -0000061.00003; +select count(*)- 6 from t1 use index (t) where t >= -0000061.00003; +select count(*)- 5 from t1 use index (t) where t > -0000061.00003; +# +select count(*)- 2 from t1 use index (u) where u < 000000000061; +select count(*)- 4 from t1 use index (u) where u <= 000000000061; +select count(*)- 2 from t1 use index (u) where u = 000000000061; +select count(*)- 8 from t1 use index (u) where u >= 000000000061; +select count(*)- 6 from t1 use index (u) where u > 000000000061; +# +select count(*)- 5 from t1 use index (v) where v < 0000965.00042; +select count(*)- 6 from t1 use index (v) where v <= 0000965.00042; +select count(*)- 1 from t1 use index (v) where v = 0000965.00042; +select count(*)- 5 from t1 use index (v) where v >= 0000965.00042; +select count(*)- 4 from t1 use index (v) where v > 0000965.00042; + +drop table t1; # bug#7798 create table t1(a int primary key, b int not null, index(b)); diff --git a/ndb/include/kernel/signaldata/DictTabInfo.hpp b/ndb/include/kernel/signaldata/DictTabInfo.hpp index 23926374dd6..09b00cf8993 100644 --- a/ndb/include/kernel/signaldata/DictTabInfo.hpp +++ b/ndb/include/kernel/signaldata/DictTabInfo.hpp @@ -24,6 +24,28 @@ #include #include +#ifndef my_decimal_h + +// sql/my_decimal.h requires many more sql/*.h new to ndb +// for now, copy the bit we need TODO proper fix + +#define DECIMAL_MAX_LENGTH ((8 * 9) - 8) + +#ifndef NOT_FIXED_DEC +#define NOT_FIXED_DEC 31 +#endif + +C_MODE_START +extern int decimal_bin_size(int, int); +C_MODE_END + +inline int my_decimal_get_binary_size(uint precision, uint scale) +{ + return decimal_bin_size((int)precision, (int)scale); +} + +#endif + #define DTIMAP(x, y, z) \ { DictTabInfo::y, offsetof(x, z), SimpleProperties::Uint32Value, 0, (~0), 0 } @@ -266,6 +288,8 @@ public: ExtDouble = NdbSqlUtil::Type::Double, ExtOlddecimal = NdbSqlUtil::Type::Olddecimal, ExtOlddecimalunsigned = NdbSqlUtil::Type::Olddecimalunsigned, + ExtDecimal = NdbSqlUtil::Type::Decimal, + ExtDecimalunsigned = NdbSqlUtil::Type::Decimalunsigned, ExtChar = NdbSqlUtil::Type::Char, ExtVarchar = NdbSqlUtil::Type::Varchar, ExtBinary = NdbSqlUtil::Type::Binary, @@ -358,6 +382,19 @@ public: (0 + AttributeExtPrecision + (int(AttributeExtScale) > 0)) * AttributeExtLength; break; + case DictTabInfo::ExtDecimal: + case DictTabInfo::ExtDecimalunsigned: + { + // copy from Field_new_decimal ctor + uint precision = AttributeExtPrecision; + uint scale = AttributeExtScale; + if (precision > DECIMAL_MAX_LENGTH || scale >= NOT_FIXED_DEC) + precision = DECIMAL_MAX_LENGTH; + uint bin_size = my_decimal_get_binary_size(precision, scale); + AttributeSize = DictTabInfo::an8Bit; + AttributeArraySize = bin_size * AttributeExtLength; + } + break; case DictTabInfo::ExtChar: case DictTabInfo::ExtBinary: AttributeSize = DictTabInfo::an8Bit; diff --git a/ndb/include/ndb_constants.h b/ndb/include/ndb_constants.h index 36d7ec95b3e..c7c15063cc5 100644 --- a/ndb/include/ndb_constants.h +++ b/ndb/include/ndb_constants.h @@ -64,7 +64,9 @@ #define NDB_TYPE_YEAR 26 #define NDB_TYPE_TIMESTAMP 27 #define NDB_TYPE_OLDDECIMALUNSIGNED 28 +#define NDB_TYPE_DECIMAL 29 +#define NDB_TYPE_DECIMALUNSIGNED 30 -#define NDB_TYPE_MAX 29 +#define NDB_TYPE_MAX 31 #endif diff --git a/ndb/include/ndbapi/NdbDictionary.hpp b/ndb/include/ndbapi/NdbDictionary.hpp index 26f0e71b25c..44851b70958 100644 --- a/ndb/include/ndbapi/NdbDictionary.hpp +++ b/ndb/include/ndbapi/NdbDictionary.hpp @@ -186,6 +186,8 @@ public: Double = NDB_TYPE_DOUBLE, ///< 64-bit float. 8 byte float, can be used in array Olddecimal = NDB_TYPE_OLDDECIMAL, ///< MySQL < 5.0 signed decimal, Precision, Scale Olddecimalunsigned = NDB_TYPE_OLDDECIMALUNSIGNED, + Decimal = NDB_TYPE_DECIMAL, ///< MySQL >= 5.0 signed decimal, Precision, Scale + Decimalunsigned = NDB_TYPE_DECIMALUNSIGNED, Char = NDB_TYPE_CHAR, ///< Len. A fixed array of 1-byte chars Varchar = NDB_TYPE_VARCHAR, ///< Length bytes: 1, Max: 255 Binary = NDB_TYPE_BINARY, ///< Len diff --git a/ndb/include/util/NdbSqlUtil.hpp b/ndb/include/util/NdbSqlUtil.hpp index 8cf1d166aa9..41e4dadfd60 100644 --- a/ndb/include/util/NdbSqlUtil.hpp +++ b/ndb/include/util/NdbSqlUtil.hpp @@ -95,7 +95,9 @@ public: Time = NDB_TYPE_TIME, Year = NDB_TYPE_YEAR, Timestamp = NDB_TYPE_TIMESTAMP, - Olddecimalunsigned = NDB_TYPE_OLDDECIMALUNSIGNED + Olddecimalunsigned = NDB_TYPE_OLDDECIMALUNSIGNED, + Decimal = NDB_TYPE_DECIMAL, + Decimalunsigned = NDB_TYPE_DECIMALUNSIGNED }; Enum m_typeId; // redundant Cmp* m_cmp; // comparison method @@ -172,6 +174,8 @@ private: static Cmp cmpYear; static Cmp cmpTimestamp; static Cmp cmpOlddecimalunsigned; + static Cmp cmpDecimal; + static Cmp cmpDecimalunsigned; }; #endif diff --git a/ndb/src/common/util/NdbSqlUtil.cpp b/ndb/src/common/util/NdbSqlUtil.cpp index 2686ad5c05f..7ecfb5194b8 100644 --- a/ndb/src/common/util/NdbSqlUtil.cpp +++ b/ndb/src/common/util/NdbSqlUtil.cpp @@ -192,6 +192,14 @@ NdbSqlUtil::m_typeList[] = { { // 28 Type::Olddecimalunsigned, cmpOlddecimalunsigned + }, + { // 29 + Type::Decimal, + cmpDecimal + }, + { // 30 + Type::Decimalunsigned, + cmpDecimalunsigned } }; @@ -483,6 +491,34 @@ NdbSqlUtil::cmpOlddecimalunsigned(const void* info, const void* p1, unsigned n1, return CmpUnknown; } +int +NdbSqlUtil::cmpDecimal(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full) +{ + const uchar* v1 = (const uchar*)p1; + const uchar* v2 = (const uchar*)p2; + // compare as binary strings + unsigned n = (n1 <= n2 ? n1 : n2); + int k = memcmp(v1, v2, n); + if (k == 0) { + k = (full ? n1 : n) - n2; + } + return k < 0 ? -1 : k > 0 ? +1 : full ? 0 : CmpUnknown; +} + +int +NdbSqlUtil::cmpDecimalunsigned(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full) +{ + const uchar* v1 = (const uchar*)p1; + const uchar* v2 = (const uchar*)p2; + // compare as binary strings + unsigned n = (n1 <= n2 ? n1 : n2); + int k = memcmp(v1, v2, n); + if (k == 0) { + k = (full ? n1 : n) - n2; + } + return k < 0 ? -1 : k > 0 ? +1 : full ? 0 : CmpUnknown; +} + int NdbSqlUtil::cmpChar(const void* info, const void* p1, unsigned n1, const void* p2, unsigned n2, bool full) { diff --git a/ndb/src/ndbapi/NdbDictionary.cpp b/ndb/src/ndbapi/NdbDictionary.cpp index aee0b455b28..664d568aee0 100644 --- a/ndb/src/ndbapi/NdbDictionary.cpp +++ b/ndb/src/ndbapi/NdbDictionary.cpp @@ -954,6 +954,12 @@ operator<<(NdbOut& out, const NdbDictionary::Column& col) case NdbDictionary::Column::Olddecimalunsigned: out << "Olddecimalunsigned(" << col.getPrecision() << "," << col.getScale() << ")"; break; + case NdbDictionary::Column::Decimal: + out << "Decimal(" << col.getPrecision() << "," << col.getScale() << ")"; + break; + case NdbDictionary::Column::Decimalunsigned: + out << "Decimalunsigned(" << col.getPrecision() << "," << col.getScale() << ")"; + break; case NdbDictionary::Column::Char: out << "Char(" << col.getLength() << ";" << csname << ")"; break; diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index c50a73c1069..8c3f238404f 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -111,6 +111,8 @@ NdbColumnImpl::init(Type t) break; case Olddecimal: case Olddecimalunsigned: + case Decimal: + case Decimalunsigned: m_precision = 10; m_scale = 0; m_length = 1; diff --git a/ndb/src/ndbapi/NdbRecAttr.cpp b/ndb/src/ndbapi/NdbRecAttr.cpp index 51ae14653eb..86a777e79d2 100644 --- a/ndb/src/ndbapi/NdbRecAttr.cpp +++ b/ndb/src/ndbapi/NdbRecAttr.cpp @@ -250,6 +250,10 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) out.print("%.*s", len, r.aRef()); } break; + case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Decimalunsigned: + goto unknown; // TODO + break; // for dates cut-and-paste from field.cc case NdbDictionary::Column::Datetime: { @@ -359,6 +363,7 @@ NdbOut& operator<<(NdbOut& out, const NdbRecAttr &r) j = length; } break; + unknown: default: /* no print functions for the rest, just print type */ out << (int) r.getType(); j = length; diff --git a/ndb/test/include/NdbSchemaOp.hpp b/ndb/test/include/NdbSchemaOp.hpp index e8ab542b00a..da55f5f9aa5 100644 --- a/ndb/test/include/NdbSchemaOp.hpp +++ b/ndb/test/include/NdbSchemaOp.hpp @@ -569,6 +569,8 @@ convertColumnTypeToAttrType(NdbDictionary::Column::Type _type) case NdbDictionary::Column::Float: case NdbDictionary::Column::Olddecimal: case NdbDictionary::Column::Olddecimalunsigned: + case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Decimalunsigned: case NdbDictionary::Column::Double: return Float; case NdbDictionary::Column::Char: diff --git a/ndb/test/src/HugoCalculator.cpp b/ndb/test/src/HugoCalculator.cpp index 0a5b9c342c8..8e01f6442bb 100644 --- a/ndb/test/src/HugoCalculator.cpp +++ b/ndb/test/src/HugoCalculator.cpp @@ -147,6 +147,8 @@ HugoCalculator::calcValue(int record, case NdbDictionary::Column::Double: case NdbDictionary::Column::Olddecimal: case NdbDictionary::Column::Olddecimalunsigned: + case NdbDictionary::Column::Decimal: + case NdbDictionary::Column::Decimalunsigned: case NdbDictionary::Column::Binary: case NdbDictionary::Column::Datetime: case NdbDictionary::Column::Time: diff --git a/ndb/tools/restore/consumer.cpp b/ndb/tools/restore/consumer.cpp index ecbdbbf8f4e..b130c4998d5 100644 --- a/ndb/tools/restore/consumer.cpp +++ b/ndb/tools/restore/consumer.cpp @@ -45,9 +45,11 @@ BackupConsumer::create_table_string(const TableS & table, pos += sprintf(buf+pos, "%s", "float"); break; case NdbDictionary::Column::Olddecimal: + case NdbDictionary::Column::Decimal: pos += sprintf(buf+pos, "%s", "decimal"); break; case NdbDictionary::Column::Olddecimalunsigned: + case NdbDictionary::Column::Decimalunsigned: pos += sprintf(buf+pos, "%s", "decimal unsigned"); break; case NdbDictionary::Column::Char: diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index 58a34e21f5f..f62a65cb109 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -446,7 +446,6 @@ bool ha_ndbcluster::get_error_message(int error, static inline bool ndb_supported_type(enum_field_types type) { switch (type) { - case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_TINY: case MYSQL_TYPE_SHORT: case MYSQL_TYPE_LONG: @@ -454,6 +453,8 @@ static inline bool ndb_supported_type(enum_field_types type) case MYSQL_TYPE_LONGLONG: case MYSQL_TYPE_FLOAT: case MYSQL_TYPE_DOUBLE: + case MYSQL_TYPE_DECIMAL: + case MYSQL_TYPE_NEWDECIMAL: case MYSQL_TYPE_TIMESTAMP: case MYSQL_TYPE_DATETIME: case MYSQL_TYPE_DATE: @@ -3493,6 +3494,24 @@ static int create_ndb_column(NDBCOL &col, col.setLength(1); } break; + case MYSQL_TYPE_NEWDECIMAL: + { + Field_new_decimal *f= (Field_new_decimal*)field; + uint precision= f->field_length; + uint scale= f->decimals(); + if (field->flags & UNSIGNED_FLAG) + { + col.setType(NDBCOL::Decimalunsigned); + } + else + { + col.setType(NDBCOL::Decimal); + } + col.setPrecision(precision); + col.setScale(scale); + col.setLength(1); + } + break; // Date types case MYSQL_TYPE_DATETIME: col.setType(NDBCOL::Datetime); -- cgit v1.2.1 From e16ae96a19c224e92d355698f70763331fdd56ac Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Feb 2005 23:23:20 +0100 Subject: Fixes after 4.1->5.0 merge. mysql-test/r/rpl_multi_query.result: result update mysql-test/t/rpl_multi_query.test: binlog position changes from 4.1 to 5.0 sql/sql_base.cc: Manually putting back the old code (like I did in 4.1 already, as the 2nd fix for BUG#8055 does not need to change sql_base.cc anymore) --- mysql-test/r/rpl_multi_query.result | 4 +-- mysql-test/t/rpl_multi_query.test | 2 +- sql/sql_base.cc | 70 ++++++++++++++++++------------------- 3 files changed, 38 insertions(+), 38 deletions(-) diff --git a/mysql-test/r/rpl_multi_query.result b/mysql-test/r/rpl_multi_query.result index 2521dbe1ed9..0c80d71d271 100644 --- a/mysql-test/r/rpl_multi_query.result +++ b/mysql-test/r/rpl_multi_query.result @@ -19,8 +19,8 @@ n 3 4 5 -show binlog events from 79; -Log_name Pos Event_type Server_id Orig_log_pos Info +show binlog events from 95; +Log_name Pos Event_type Server_id End_log_pos Info master-bin.000001 # Query 1 # drop database if exists mysqltest master-bin.000001 # Query 1 # create database mysqltest master-bin.000001 # Query 1 # use `test`; create table mysqltest.t1 ( n int) diff --git a/mysql-test/t/rpl_multi_query.test b/mysql-test/t/rpl_multi_query.test index 482a2679e7a..80bdfb521eb 100644 --- a/mysql-test/t/rpl_multi_query.test +++ b/mysql-test/t/rpl_multi_query.test @@ -24,6 +24,6 @@ sync_slave_with_master; select * from mysqltest.t1; connection master; --replace_column 2 # 5 # -show binlog events from 79; +show binlog events from 95; drop database mysqltest; sync_slave_with_master; diff --git a/sql/sql_base.cc b/sql/sql_base.cc index eef86921012..83e3722072d 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -496,58 +496,58 @@ void close_temporary(TABLE *table,bool delete_table) void close_temporary_tables(THD *thd) { TABLE *table,*next; - char *query, *name_in_query, *end; - uint greatest_key_length= 0; + char *query, *end; + uint query_buf_size; + bool found_user_tables = 0; if (!thd->temporary_tables) return; - /* - We write a DROP TEMPORARY TABLE for each temp table left, so that our - replication slave can clean them up. Not one multi-table DROP TABLE binlog - event: this would cause problems if slave uses --replicate-*-table. - */ LINT_INIT(end); + query_buf_size= 50; // Enough for DROP ... TABLE IF EXISTS - /* We'll re-use always same buffer so make it big enough for longest name */ for (table=thd->temporary_tables ; table ; table=table->next) - greatest_key_length= max(greatest_key_length, table->s->key_length); + /* + We are going to add 4 ` around the db/table names, so 1 does not look + enough; indeed it is enough, because table->key_length is greater (by 8, + because of server_id and thread_id) than db||table. + */ + query_buf_size+= table->s->key_length+1; - if ((query = alloc_root(thd->mem_root, greatest_key_length+50))) + if ((query = alloc_root(thd->mem_root, query_buf_size))) // Better add "if exists", in case a RESET MASTER has been done - name_in_query= strmov(query, "DROP /*!40005 TEMPORARY */ TABLE IF EXISTS `"); + end=strmov(query, "DROP /*!40005 TEMPORARY */ TABLE IF EXISTS "); for (table=thd->temporary_tables ; table ; table=next) { - /* - In we are OOM for 'query' this is not fatal. We skip temporary tables - not created directly by the user. - */ - if (query && mysql_bin_log.is_open() && (table->s->table_name[0] != '#')) + if (query) // we might be out of memory, but this is not fatal { - /* - Here we assume table_cache_key always starts - with \0 terminated db name - */ - end = strxmov(name_in_query, table->s->db, "`.`", - table->s->table_name, "`", NullS); - Query_log_event qinfo(thd, query, (ulong)(end-query), 0, FALSE); - /* - Imagine the thread had created a temp table, then was doing a SELECT, and - the SELECT was killed. Then it's not clever to mark the statement above as - "killed", because it's not really a statement updating data, and there - are 99.99% chances it will succeed on slave. And, if thread is - killed now, it's not clever either. - If a real update (one updating a persistent table) was killed on the - master, then this real update will be logged with error_code=killed, - rightfully causing the slave to stop. - */ - qinfo.error_code= 0; - mysql_bin_log.write(&qinfo); + // skip temporary tables not created directly by the user + if (table->s->table_name[0] != '#') + found_user_tables = 1; + end = strxmov(end,"`",table->s->db,"`.`", + table->s->table_name,"`,", NullS); } next=table->next; close_temporary(table); } + if (query && found_user_tables && mysql_bin_log.is_open()) + { + /* The -1 is to remove last ',' */ + thd->clear_error(); + Query_log_event qinfo(thd, query, (ulong)(end-query)-1, 0, FALSE); + /* + Imagine the thread had created a temp table, then was doing a SELECT, and + the SELECT was killed. Then it's not clever to mark the statement above as + "killed", because it's not really a statement updating data, and there + are 99.99% chances it will succeed on slave. + If a real update (one updating a persistent table) was killed on the + master, then this real update will be logged with error_code=killed, + rightfully causing the slave to stop. + */ + qinfo.error_code= 0; + mysql_bin_log.write(&qinfo); + } thd->temporary_tables=0; } -- cgit v1.2.1 From d8ea664e9647d9b9a65d63e21979375ab4d5c8e1 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Feb 2005 04:18:49 +0300 Subject: Fix a typo caused bdb to be skipped when building with BUILD/compile-*-max Recommited, as I made a typo in the previous patch myself =) BUILD/SETUP.sh: Fix a typo caused bdb to be skipped when building with BUILD/compile-*-max --- BUILD/SETUP.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BUILD/SETUP.sh b/BUILD/SETUP.sh index b899b9a7d9b..403857f403f 100755 --- a/BUILD/SETUP.sh +++ b/BUILD/SETUP.sh @@ -48,8 +48,8 @@ global_warnings="-Wimplicit -Wreturn-type -Wswitch -Wtrigraphs -Wcomment -W -Wch c_warnings="$global_warnings -Wunused" cxx_warnings="$global_warnings -Woverloaded-virtual -Wsign-promo -Wreorder -Wctor-dtor-privacy -Wnon-virtual-dtor" -base_max_configs="--with-innodb --with-bdb --with-ndbcluster --with-archive-storage-engine --with-raid --with-openssl --with-raid --with-vio" -max_leave_isam_configs="--with-innodb --with-bdb --with-ndbcluster --with-archive-storage-engine --with-federated-storage-engine --with-raid --with-openssl --with-raid --with-vio --with-embedded-server" +base_max_configs="--with-innodb --with-berkeley-db --with-ndbcluster --with-archive-storage-engine --with-raid --with-openssl --with-raid --with-vio" +max_leave_isam_configs="--with-innodb --with-berkeley-db --with-ndbcluster --with-archive-storage-engine --with-federated-storage-engine --with-raid --with-openssl --with-raid --with-vio --with-embedded-server" max_no_es_configs="$max_leave_isam_configs --without-isam" max_configs="$max_no_es_configs --with-embedded-server" -- cgit v1.2.1