From a811b06b30b6ad3c8ac286f389a50e4f71f6a909 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Feb 2003 17:33:15 +0200 Subject: [PATCH 1/4] ha_innodb.cc: Clarify the meaning of HA_READ_PREFIX_LAST as a search flag. InnoDB assumed the meaning wrong. sql/ha_innodb.cc: Clarify the meaning of HA_READ_PREFIX_LAST as a search flag. InnoDB assumed the meaning wrong. --- sql/ha_innodb.cc | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc index 52aeefc5cfe..fce9500a47c 100644 --- a/sql/ha_innodb.cc +++ b/sql/ha_innodb.cc @@ -2256,17 +2256,14 @@ convert_search_mode_to_innobase( case HA_READ_BEFORE_KEY: return(PAGE_CUR_L); case HA_READ_PREFIX: return(PAGE_CUR_GE); case HA_READ_PREFIX_LAST: return(PAGE_CUR_LE); - /* TODO: 1) this should really be - return(PAGE_CUR_LE_OR_EXTENDS); but since MySQL uses - a wrong flag in search, we convert this to PAGE_CUR_LE; - 2) if the character set is not latin1, then InnoDB - uses a MySQL function innobase_mysql_cmp() to - compare CHAR and VARCHAR strings; since that function - does not return the number of matched bytes, - PAGE_CUR_LE_OR_EXTENDS does not currently work: we - should probably write my_sortncmp_with_n_matcehd_bytes() - to determine if a field 'extends' another; - see dev-public discussion on Feb 7th, 2003 */ + /* In MySQL HA_READ_PREFIX and HA_READ_PREFIX_LAST always + use a complete-field-prefix of a kay value as the search + tuple. I.e., it is not allowed that the last field would + just contain n first bytes of the full field value. + MySQL uses a 'padding' trick to convert LIKE 'abc%' + type queries so that it can use as a search tuple + a complete-field-prefix of a key value. Thus, the InnoDB + search mode PAGE_CUR_LE_OR_EXTENDS is never used. */ default: assert(0); } From c161bbdbe472a8711b2e8168de5fccc54fe674b9 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Feb 2003 17:44:09 +0200 Subject: [PATCH 2/4] page0cur.c: Disable PAGE_CUR_LE_OR_EXTENDS because it does not work for non-latin1 char sets now innobase/page/page0cur.c: Disable PAGE_CUR_LE_OR_EXTENDS because it does not work for non-latin1 char sets now --- innobase/page/page0cur.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/innobase/page/page0cur.c b/innobase/page/page0cur.c index 2042db80529..0e65dc8b1de 100644 --- a/innobase/page/page0cur.c +++ b/innobase/page/page0cur.c @@ -193,6 +193,11 @@ page_cur_search_with_match( } /*#endif */ #endif + + /* The following flag does not work for non-latin1 char sets because + cmp_full_field does not tell how many bytes matched */ + ut_a(mode != PAGE_CUR_LE_OR_EXTENDS); + /* If mode PAGE_CUR_G is specified, we are trying to position the cursor to answer a query of the form "tuple < X", where tuple is the input parameter, and X denotes an arbitrary physical record on From 5db7246f78d62f07433b3e623e20002536ff20b2 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Feb 2003 17:57:07 +0200 Subject: [PATCH 3/4] Fix problem in MIN/MAX optimisation (from last patch) Don't make OLD_PASSWORD() a reserved word mysql-test/r/explain.result: Test select count(*) mysql-test/r/func_crypt.result: Test old_password() mysql-test/t/explain.test: Test select count(*) mysql-test/t/func_crypt.test: Test old_password() sql/item_create.cc: Don't make OLD_PASSWORD() a reserved word sql/item_create.h: Don't make OLD_PASSWORD() a reserved word sql/lex.h: Don't make OLD_PASSWORD() a reserved word sql/opt_range.cc: Remove blank space sql/opt_sum.cc: Fix problem in MIN/MAX optimisation --- mysql-test/r/explain.result | 13 +++++++++++++ mysql-test/r/func_crypt.result | 9 ++++++--- mysql-test/t/explain.test | 8 ++++++++ mysql-test/t/func_crypt.test | 3 ++- sql/item_create.cc | 5 +++++ sql/item_create.h | 1 + sql/lex.h | 2 +- sql/opt_range.cc | 2 -- sql/opt_sum.cc | 11 +++++++++-- 9 files changed, 45 insertions(+), 9 deletions(-) diff --git a/mysql-test/r/explain.result b/mysql-test/r/explain.result index fa15165722d..d433078a251 100644 --- a/mysql-test/r/explain.result +++ b/mysql-test/r/explain.result @@ -31,3 +31,16 @@ drop table t1; explain select 1; Comment No tables used +create table t1 (a int not null); +explain select count(*) from t1; +Comment +Select tables optimized away +insert into t1 values(1); +explain select count(*) from t1; +Comment +Select tables optimized away +insert into t1 values(1); +explain select count(*) from t1; +Comment +Select tables optimized away +drop table t1; diff --git a/mysql-test/r/func_crypt.result b/mysql-test/r/func_crypt.result index cf464ec21b2..742de833bf7 100644 --- a/mysql-test/r/func_crypt.result +++ b/mysql-test/r/func_crypt.result @@ -1,6 +1,9 @@ select length(encrypt('foo', 'ff')) <> 0; length(encrypt('foo', 'ff')) <> 0 1 -select password('test'),length(encrypt('test')),encrypt('test','aa'); -password('test') length(encrypt('test')) encrypt('test','aa') -378b243e220ca493 13 aaqPiZY5xR5l. +select old_password('test'), password('test'); +old_password('test') password('test') +378b243e220ca493 378b243e220ca493 +select length(encrypt('test')), encrypt('test','aa'); +length(encrypt('test')) encrypt('test','aa') +13 aaqPiZY5xR5l. diff --git a/mysql-test/t/explain.test b/mysql-test/t/explain.test index 8a41ebe5b4f..045598e97df 100644 --- a/mysql-test/t/explain.test +++ b/mysql-test/t/explain.test @@ -20,3 +20,11 @@ explain select * from t1 ignore key (str,str,foo) where str="foo"; drop table t1; explain select 1; + +create table t1 (a int not null); +explain select count(*) from t1; +insert into t1 values(1); +explain select count(*) from t1; +insert into t1 values(1); +explain select count(*) from t1; +drop table t1; diff --git a/mysql-test/t/func_crypt.test b/mysql-test/t/func_crypt.test index 55c0d6d3b9d..f403d96e885 100644 --- a/mysql-test/t/func_crypt.test +++ b/mysql-test/t/func_crypt.test @@ -2,4 +2,5 @@ select length(encrypt('foo', 'ff')) <> 0; --replace_result $1$aa$4OSUA5cjdx0RUQ08opV27/ aaqPiZY5xR5l. -select password('test'),length(encrypt('test')),encrypt('test','aa'); +select old_password('test'), password('test'); +select length(encrypt('test')), encrypt('test','aa'); diff --git a/sql/item_create.cc b/sql/item_create.cc index a4486a0b1c7..7e082bc174c 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -307,6 +307,11 @@ Item *create_func_quarter(Item* a) return new Item_func_quarter(a); } +Item *create_func_password(Item* a) +{ + return new Item_func_password(a); +} + Item *create_func_radians(Item *a) { return new Item_func_units((char*) "radians",a,M_PI/180,0.0); diff --git a/sql/item_create.h b/sql/item_create.h index 10b404ec2fd..5381ad946ae 100644 --- a/sql/item_create.h +++ b/sql/item_create.h @@ -70,6 +70,7 @@ Item *create_func_pi(void); Item *create_func_pow(Item* a, Item *b); Item *create_func_current_user(void); Item *create_func_quarter(Item* a); +Item *create_func_password(Item* a); Item *create_func_radians(Item *a); Item *create_func_release_lock(Item* a); Item *create_func_repeat(Item* a, Item *b); diff --git a/sql/lex.h b/sql/lex.h index 64ba98b5e35..a9e44e034d0 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -260,7 +260,6 @@ static SYMBOL symbols[] = { { "NULL", SYM(NULL_SYM),0,0}, { "NUMERIC", SYM(NUMERIC_SYM),0,0}, { "OFFSET", SYM(OFFSET_SYM),0,0}, - { "OLD_PASSWORD", SYM(PASSWORD),0,0}, { "ON", SYM(ON),0,0}, { "OPEN", SYM(OPEN_SYM),0,0}, { "OPTIMIZE", SYM(OPTIMIZE),0,0}, @@ -475,6 +474,7 @@ static SYMBOL sql_functions[] = { { "NULLIF", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_nullif)}, { "OCTET_LENGTH", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_length)}, { "OCT", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_oct)}, + { "OLD_PASSWORD", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_password)}, { "ORD", SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_ord)}, { "PERIOD_ADD", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_period_add)}, { "PERIOD_DIFF", SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_period_diff)}, diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 768344ab702..0407aabc327 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -23,8 +23,6 @@ */ - - #ifdef __GNUC__ #pragma implementation // gcc: Class implementation #endif diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index d5a4149f243..41771646082 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -245,8 +245,15 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) const_result=0; } } - if (used_tables != removed_tables) - const_result=0; // We didn't remove all tables + /* + If we have a where clause, we can only ignore searching in the + tables if MIN/MAX optimisation replaced all used tables + This is to not to use replaced values in case of: + SELECT MIN(key) FROM table_1, empty_table + removed_tables is != 0 if we have used MIN() or MAX(). + */ + if (removed_tables && used_tables != removed_tables) + const_result= 0; // We didn't remove all tables return const_result; } From 133ed0bf6ffde95d02ea35b6c02b5a042d73ecc0 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 7 Feb 2003 18:47:13 +0200 Subject: [PATCH 4/4] Fixed problem that caused automake to fail --- configure.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure.in b/configure.in index d2469f1fffd..d4f749d5de7 100644 --- a/configure.in +++ b/configure.in @@ -1067,7 +1067,7 @@ dnl Is this the right match for DEC OSF on alpha? *netware*) # No need for curses library so set it to null with_named_curses="" - + PLATFORM_NETWARE=yes # # Edit Makefile.in files. # @@ -1167,6 +1167,7 @@ EOF ;; esac +AM_CONDITIONAL(PLATFORM_NETWARE, test "$PLATFORM_NETWARE" = "yes") #---START: Used in for client configure # Check if we threads are in libc or if we should use