summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorunknown <sanja@askmonty.org>2011-07-21 13:15:09 +0300
committerunknown <sanja@askmonty.org>2011-07-21 13:15:09 +0300
commitf675536aa48fd314ade0ee1ed56a44d4558642b4 (patch)
tree3fd031f88ec93de785a134844a5d1233713fd8e0 /sql
parent30370ee2f040d76fd4122fdb34de807a5b82f2c8 (diff)
parentee06e4d65e42d303389605f3d30cbf0892be96af (diff)
downloadmariadb-git-f675536aa48fd314ade0ee1ed56a44d4558642b4.tar.gz
Merge 5.1->5.2
Diffstat (limited to 'sql')
-rw-r--r--sql/mysql_priv.h1
-rw-r--r--sql/opt_range.h3
-rw-r--r--sql/records.cc9
-rw-r--r--sql/sql_parse.cc23
-rw-r--r--sql/sql_yacc.yy6
5 files changed, 27 insertions, 15 deletions
diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h
index bd2f31fbe1d..38a29686906 100644
--- a/sql/mysql_priv.h
+++ b/sql/mysql_priv.h
@@ -1504,6 +1504,7 @@ bool add_to_list(THD *thd, SQL_I_List<ORDER> &list, Item *group,bool asc);
bool push_new_name_resolution_context(THD *thd,
TABLE_LIST *left_op,
TABLE_LIST *right_op);
+Item *normalize_cond(Item *cond);
void add_join_on(TABLE_LIST *b,Item *expr);
void add_join_natural(TABLE_LIST *a,TABLE_LIST *b,List<String> *using_fields,
SELECT_LEX *lex);
diff --git a/sql/opt_range.h b/sql/opt_range.h
index 1321b3886ee..29df043cb69 100644
--- a/sql/opt_range.h
+++ b/sql/opt_range.h
@@ -271,7 +271,6 @@ public:
virtual bool reverse_sorted() = 0;
virtual bool unique_key_range() { return false; }
- virtual bool clustered_pk_range() { return false; }
enum {
QS_TYPE_RANGE = 0,
@@ -542,8 +541,6 @@ public:
THD *thd;
int read_keys_and_merge();
- bool clustered_pk_range() { return test(pk_quick_select); }
-
/* used to get rows collected in Unique */
READ_RECORD read_record;
};
diff --git a/sql/records.cc b/sql/records.cc
index 6bb7c7cffa1..bdb27322a28 100644
--- a/sql/records.cc
+++ b/sql/records.cc
@@ -195,15 +195,6 @@ bool init_read_record(READ_RECORD *info,THD *thd, TABLE *table,
if (select && my_b_inited(&select->file))
tempfile= &select->file;
- else if (select && select->quick && select->quick->clustered_pk_range())
- {
- /*
- In case of QUICK_INDEX_MERGE_SELECT with clustered pk range we have to
- use its own access method(i.e QUICK_INDEX_MERGE_SELECT::get_next()) as
- sort file does not contain rowids which satisfy clustered pk range.
- */
- tempfile= 0;
- }
else
tempfile= table->sort.io_cache;
if (tempfile && my_b_inited(tempfile) &&
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index e4169b1da62..c930eb0824a 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -6856,6 +6856,28 @@ push_new_name_resolution_context(THD *thd,
/**
+ Fix condition which contains only field (f turns to f <> 0 )
+
+ @param cond The condition to fix
+
+ @return fixed condition
+*/
+
+Item *normalize_cond(Item *cond)
+{
+ if (cond)
+ {
+ Item::Type type= cond->type();
+ if (type == Item::FIELD_ITEM || type == Item::REF_ITEM)
+ {
+ cond= new Item_func_ne(cond, new Item_int(0));
+ }
+ }
+ return cond;
+}
+
+
+/**
Add an ON condition to the second operand of a JOIN ... ON.
Add an ON condition to the right operand of a JOIN ... ON clause.
@@ -6873,6 +6895,7 @@ void add_join_on(TABLE_LIST *b, Item *expr)
{
if (expr)
{
+ expr= normalize_cond(expr);
if (!b->on_expr)
b->on_expr= expr;
else
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index bf213b19bb9..2f0595bbcfb 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -9223,7 +9223,7 @@ where_clause:
expr
{
SELECT_LEX *select= Select;
- select->where= $3;
+ select->where= normalize_cond($3);
select->parsing_place= NO_MATTER;
if ($3)
$3->top_level_item();
@@ -9239,7 +9239,7 @@ having_clause:
expr
{
SELECT_LEX *sel= Select;
- sel->having= $3;
+ sel->having= normalize_cond($3);
sel->parsing_place= NO_MATTER;
if ($3)
$3->top_level_item();
@@ -10706,7 +10706,7 @@ wild_and_where:
}
| WHERE expr
{
- Select->where= $2;
+ Select->where= normalize_cond($2);
if ($2)
$2->top_level_item();
}