summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <monty@mashka.mysql.fi>2003-09-11 20:24:14 +0300
committerunknown <monty@mashka.mysql.fi>2003-09-11 20:24:14 +0300
commitd32bdcb1bfc274476cdd945e66e00f3ec31253c3 (patch)
tree20f0ccc7be8e0d205ea5a00d6ec5f57a14d85d3f /sql
parentdd0d199ebeab47facb4d01269cda97c258491c22 (diff)
parent3f6d78f6c7ad5eb00c4d24b0f0b839a1fb1ead25 (diff)
downloadmariadb-git-d32bdcb1bfc274476cdd945e66e00f3ec31253c3.tar.gz
merge with 4.0.15
BitKeeper/etc/logging_ok: auto-union BitKeeper/deleted/.del-mysql_fix_privilege_tables.sql: Delete: scripts/mysql_fix_privilege_tables.sql include/mysql.h: Auto merged myisam/mi_open.c: Auto merged myisam/mi_update.c: Auto merged myisam/myisampack.c: Auto merged mysql-test/r/bdb.result: Auto merged mysql-test/r/grant.result: Auto merged mysql-test/t/bdb.test: Auto merged mysql-test/t/grant.test: Auto merged mysql-test/t/range.test: Auto merged scripts/make_win_src_distribution.sh: Auto merged sql/ha_berkeley.cc: Auto merged sql/mysqld.cc: Auto merged sql/opt_range.cc: Auto merged support-files/mysql.spec.sh: Auto merged
Diffstat (limited to 'sql')
-rw-r--r--sql/ha_berkeley.cc3
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/opt_range.cc4
-rw-r--r--sql/sql_acl.cc20
-rw-r--r--sql/sql_parse.cc17
-rw-r--r--sql/sql_select.cc22
6 files changed, 45 insertions, 23 deletions
diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc
index dbed955c0a9..ee1b54e5745 100644
--- a/sql/ha_berkeley.cc
+++ b/sql/ha_berkeley.cc
@@ -1433,6 +1433,8 @@ int ha_berkeley::index_read(byte * buf, const byte * key,
}
if (key_len == key_info->key_length)
{
+ if (find_flag == HA_READ_AFTER_KEY)
+ key_info->handler.bdb_return_if_eq= 1;
error=read_row(cursor->c_get(cursor, pack_key(&last_key,
active_index,
key_buff,
@@ -1441,6 +1443,7 @@ int ha_berkeley::index_read(byte * buf, const byte * key,
(find_flag == HA_READ_KEY_EXACT ?
DB_SET : DB_SET_RANGE)),
(char*) buf, active_index, &row, (DBT*) 0, 0);
+ key_info->handler.bdb_return_if_eq= 0;
}
else
{
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index ef4966405bf..99e59ab3d63 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -3821,7 +3821,7 @@ master-ssl",
(gptr*) &master_ssl_cipher, (gptr*) &master_ssl_capath, 0, GET_STR, OPT_ARG,
0, 0, 0, 0, 0, 0},
{"myisam-recover", OPT_MYISAM_RECOVER,
- "Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP or FORCE.",
+ "Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP, FORCE or QUICK.",
(gptr*) &myisam_recover_options_str, (gptr*) &myisam_recover_options_str, 0,
GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
{"memlock", OPT_MEMLOCK, "Lock mysqld in memory.", (gptr*) &locked_in_memory,
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index 5a883ce8b2c..5b1e2c98001 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -692,7 +692,7 @@ int SQL_SELECT::test_quick_select(key_map keys_to_use, table_map prev_tables,
uint keynr= param.real_keynr[idx];
if ((*key)->type == SEL_ARG::MAYBE_KEY ||
(*key)->maybe_flag)
- needed_reg|= (key_map) 1 << keynr;
+ needed_reg|= (key_map) 1 << keynr;
found_records=check_quick_select(&param, idx, *key);
if (found_records != HA_POS_ERROR && found_records > 2 &&
@@ -716,7 +716,7 @@ int SQL_SELECT::test_quick_select(key_map keys_to_use, table_map prev_tables,
param.range_count,
found_records)+
(double) found_records / TIME_FOR_COMPARE);
- if (read_time > found_read_time)
+ if (read_time > found_read_time && found_records != HA_POS_ERROR)
{
read_time=found_read_time;
records=found_records;
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 6f588427ede..7889a583fde 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1690,6 +1690,7 @@ class GRANT_TABLE :public Sql_alloc
public:
char *host,*db,*user,*tname, *hash_key;
ulong privs, cols;
+ ulong sort;
uint key_length;
HASH hash_columns;
GRANT_TABLE (const char *h, const char *d,const char *u, const char *t,
@@ -1699,6 +1700,7 @@ public:
host = strdup_root(&memex,h);
db = strdup_root(&memex,d);
user = strdup_root(&memex,u);
+ sort= get_sort(3,host,db,user);
tname= strdup_root(&memex,t);
if (lower_case_table_names)
{
@@ -1721,7 +1723,8 @@ public:
user = get_field(&memex,form->field[2]);
if (!user)
user=(char*) "";
- tname = get_field(&memex,form->field[3]);
+ sort= get_sort(3,host,db,user);
+ tname= get_field(&memex,form->field[3]);
if (!host || !db || !tname)
{
/* Wrong table row; Ignore it */
@@ -1830,10 +1833,11 @@ static GRANT_TABLE *table_hash_search(const char *host,const char* ip,
}
else
{
- if ((host && !wild_case_compare(&my_charset_latin1,
- host,grant_table->host)) ||
- (ip && !wild_case_compare(&my_charset_latin1,
- ip,grant_table->host)))
+ if (((host && !wild_case_compare(&my_charset_latin1,
+ host,grant_table->host)) ||
+ (ip && !wild_case_compare(&my_charset_latin1,
+ ip,grant_table->host))) &&
+ (!found || found->sort < grant_table->sort))
found=grant_table; // Host ok
}
}
@@ -3174,17 +3178,19 @@ int mysql_show_grants(THD *thd,LEX_USER *lex_user)
if ((table_access | grant_table->cols) != 0)
{
String global(buff,sizeof(buff),&my_charset_latin1);
+ ulong test_access= (table_access | grant_table->cols) & ~GRANT_ACL;
+
global.length(0);
global.append("GRANT ",6);
if (test_all_bits(table_access, (TABLE_ACLS & ~GRANT_ACL)))
global.append("ALL PRIVILEGES",14);
- else if (!(table_access & ~GRANT_ACL))
+ else if (!test_access)
global.append("USAGE",5);
else
{
int found= 0;
- ulong j,test_access= (table_access | grant_table->cols) & ~GRANT_ACL;
+ ulong j;
for (counter= 0, j= SELECT_ACL; j <= TABLE_ACLS; counter++, j<<= 1)
{
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index ad650202dd9..62abef41dde 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -623,7 +623,6 @@ check_connection(THD *thd)
thd->ip= 0;
bzero((char*) &thd->remote, sizeof(struct sockaddr));
}
- /* Ensure that wrong hostnames doesn't cause buffer overflows */
vio_keepalive(net->vio, TRUE);
ulong pkt_len= 0;
@@ -1882,9 +1881,7 @@ mysql_execute_command(THD *thd)
res = mysql_preload_keys(thd, tables);
break;
}
-
-
-#ifndef EMBEDDED_LIBRARY
+#ifdef HAVE_REPLICATION
case SQLCOM_CHANGE_MASTER:
{
if (check_global_access(thd, SUPER_ACL))
@@ -1921,8 +1918,7 @@ mysql_execute_command(THD *thd)
else
res = load_master_data(thd);
break;
-#endif /* EMBEDDED_LIBRARY */
-
+#endif /* HAVE_REPLICATION */
#ifdef HAVE_INNOBASE_DB
case SQLCOM_SHOW_INNODB_STATUS:
{
@@ -1932,8 +1928,7 @@ mysql_execute_command(THD *thd)
break;
}
#endif
-
-#ifndef EMBEDDED_LIBRARY
+#ifdef HAVE_REPLICATION
case SQLCOM_LOAD_MASTER_TABLE:
{
if (!tables->db)
@@ -1965,7 +1960,7 @@ mysql_execute_command(THD *thd)
UNLOCK_ACTIVE_MI;
break;
}
-#endif /* EMBEDDED_LIBRARY */
+#endif /* HAVE_REPLICATION */
case SQLCOM_CREATE_TABLE:
{
@@ -2082,7 +2077,7 @@ mysql_execute_command(THD *thd)
res = mysql_create_index(thd, tables, lex->key_list);
break;
-#ifndef EMBEDDED_LIBRARY
+#ifdef HAVE_REPLICATION
case SQLCOM_SLAVE_START:
{
LOCK_ACTIVE_MI;
@@ -2115,7 +2110,7 @@ mysql_execute_command(THD *thd)
UNLOCK_ACTIVE_MI;
break;
}
-#endif
+#endif /* HAVE_REPLICATION */
case SQLCOM_ALTER_TABLE:
#if defined(DONT_ALLOW_SHOW_COMMANDS)
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index eac4007d9fc..47ee4784aa0 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -158,7 +158,7 @@ static void copy_sum_funcs(Item_sum **func_ptr);
static bool add_ref_to_table_cond(THD *thd, JOIN_TAB *join_tab);
static bool init_sum_functions(Item_sum **func, Item_sum **end);
static bool update_sum_func(Item_sum **func);
-static void select_describe(JOIN *join, bool need_tmp_table, bool need_order,
+static void select_describe(JOIN *join, bool need_tmp_table,bool need_order,
bool distinct, const char *message=NullS);
@@ -2178,6 +2178,7 @@ add_key_fields(JOIN_TAB *stat,KEY_FIELD **key_fields,uint *and_level,
add_key_field(key_fields,*and_level,
((Item_field*) (cond_func->key_item()->real_item()))->field, 0,
cond_func->arguments()+1, cond_func->argument_count()-1,
+#endif
usable_tables);
break;
case Item_func::OPTIMIZE_OP:
@@ -3337,13 +3338,30 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond)
join->best_positions[i].records_read &&
!(join->select_options & OPTION_FOUND_ROWS)))
{
+ /* Join with outer join condition */
+ COND *orig_cond=sel->cond;
+ sel->cond=and_conds(sel->cond,tab->on_expr);
if (sel->test_quick_select(tab->keys,
used_tables & ~ current_map,
(join->select_options &
OPTION_FOUND_ROWS ?
HA_POS_ERROR :
join->unit->select_limit_cnt)) < 0)
- DBUG_RETURN(1); // Impossible range
+ { /* before reporting "Impossible WHERE" for the whole query
+ we have to check isn't it only "impossible ON" instead */
+ sel->cond=orig_cond;
+ if (!tab->on_expr ||
+ sel->test_quick_select(tab->keys,
+ used_tables & ~ current_map,
+ (join->select_options &
+ OPTION_FOUND_ROWS ?
+ HA_POS_ERROR :
+ join->thd->select_limit)) < 0)
+ DBUG_RETURN(1); // Impossible WHERE
+ }
+ else
+ sel->cond=orig_cond;
+
/* Fix for EXPLAIN */
if (sel->quick)
join->best_positions[i].records_read= sel->quick->records;