Commit 7e8ca7fd authored by unknown's avatar unknown
Browse files

Merge sanja.is.com.ua:/home/bell/mysql/bk/mysql-4.1

into sanja.is.com.ua:/home/bell/mysql/bk/work-not-4.1


sql/mysql_priv.h:
  Auto merged
sql/sql_yacc.yy:
  Auto merged
parents 775c057e 1dc52f07
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -375,4 +375,17 @@ a
13
14
15
delete from t1 where a > 3;
select a, not(not(a)) from t1;
a	not(not(a))
NULL	NULL
0	0
1	1
2	1
3	1
explain extended select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "1"), not (a not in (1,2)), not(a != 2) from t1 where not(not(a)) having not(not(a));
id	select_type	table	type	possible_keys	key	key_len	ref	rows	Extra
1	SIMPLE	t1	index	NULL	a	5	NULL	5	Using where; Using index
Warnings:
Note	1003	select test.t1.a AS `a`,(test.t1.a <> 0) AS `not(not(a))`,((test.t1.a > 2) or test.t1.a) AS `not(a <= 2 and not(a))`,(test.t1.a like _latin1'1') AS `not(a not like "1")`,(test.t1.a in (1,2)) AS `not (a not in (1,2))`,(test.t1.a = 2) AS `not(a != 2)` from test.t1 where test.t1.a having test.t1.a
drop table t1;
+4 −0
Original line number Diff line number Diff line
@@ -65,4 +65,8 @@ select * from t1 where not((a < 5 and a < 10) and (not(a > 16) or a > 17));
explain select * from t1 where ((a between 5 and 15) and (not(a like 10)));
select * from t1 where ((a between 5 and 15) and (not(a like 10)));

delete from t1 where a > 3;
select a, not(not(a)) from t1;
explain extended select a, not(not(a)), not(a <= 2 and not(a)), not(a not like "1"), not (a not in (1,2)), not(a != 2) from t1 where not(not(a)) having not(not(a));

drop table t1;
+2 −2
Original line number Diff line number Diff line
@@ -239,6 +239,7 @@ class Item {
  virtual void top_level_item() {}
  virtual void set_result_field(Field *field) {}
  virtual bool is_result_field() { return 0; }
  virtual bool is_bool_func() { return 0; }
  virtual void save_in_result_field(bool no_conversions) {}
  virtual void no_rows_in_result() {}
  virtual Item *copy_or_same(THD *thd) { return this; }
@@ -269,7 +270,6 @@ class Item {

  Field *tmp_table_field_from_field_type(TABLE *table);

  /* Used in sql_select.cc:eliminate_not_funcs() */
  virtual Item *neg_transformer(THD *thd) { return NULL; }
  void delete_self()
  {
+1 −37
Original line number Diff line number Diff line
@@ -2030,15 +2030,6 @@ void Item_cond::neg_arguments(THD *thd)
    {
      if (!(new_item= new Item_func_not(item)))
	return;					// Fatal OEM error
      /*
	We can use 0 as tables list because Item_func_not do not use it
	on fix_fields and its arguments are already fixed.

	We do not check results of fix_fields, because there are not way
	to return error in this functions interface, thd->net.report_error
	will be checked on upper level call.
      */
      new_item->fix_fields(thd, 0, &new_item);
    }
    VOID(li.replace(new_item));
  }
@@ -2716,9 +2707,6 @@ longlong Item_cond_xor::val_int()
       IS NULL(a)         -> IS NOT NULL(a)
       IS NOT NULL(a)     -> IS NULL(a)

  NOTE
    This method is used in the eliminate_not_funcs() function.

  RETURN
    New item or
    NULL if we cannot apply NOT transformation (see Item::neg_transformer()).
@@ -2727,25 +2715,13 @@ longlong Item_cond_xor::val_int()
Item *Item_func_not::neg_transformer(THD *thd)	/* NOT(x)  ->  x */
{
  // We should apply negation elimination to the argument of the NOT function
  return eliminate_not_funcs(thd, args[0]);
  return args[0];
}


Item *Item_bool_rowready_func2::neg_transformer(THD *thd)
{
  Item *item= negated_item();
  if (item)
  {
    /*
      We can use 0 as tables list because Item_func* family do not use it
      on fix_fields and its arguments are already fixed.
      
      We do not check results of fix_fields, because there are not way
      to return error in this functions interface, thd->net.report_error
      will be checked on upper level call.
    */
    item->fix_fields(thd, 0, &item);
  }
  return item;
}

@@ -2754,9 +2730,6 @@ Item *Item_bool_rowready_func2::neg_transformer(THD *thd)
Item *Item_func_isnull::neg_transformer(THD *thd)
{
  Item *item= new Item_func_isnotnull(args[0]);
  // see comment before fix_fields in Item_bool_rowready_func2::neg_transformer
  if (item)
    item->fix_fields(thd, 0, &item);
  return item;
}

@@ -2765,9 +2738,6 @@ Item *Item_func_isnull::neg_transformer(THD *thd)
Item *Item_func_isnotnull::neg_transformer(THD *thd)
{
  Item *item= new Item_func_isnull(args[0]);
  // see comment before fix_fields in Item_bool_rowready_func2::neg_transformer
  if (item)
    item->fix_fields(thd, 0, &item);
  return item;
}

@@ -2777,9 +2747,6 @@ Item *Item_cond_and::neg_transformer(THD *thd) /* NOT(a AND b AND ...) -> */
{
  neg_arguments(thd);
  Item *item= new Item_cond_or(list);
  // see comment before fix_fields in Item_bool_rowready_func2::neg_transformer
  if (item)
    item->fix_fields(thd, 0, &item);
  return item;
}

@@ -2789,9 +2756,6 @@ Item *Item_cond_or::neg_transformer(THD *thd) /* NOT(a OR b OR ...) -> */
{
  neg_arguments(thd);
  Item *item= new Item_cond_and(list);
  // see comment before fix_fields in Item_bool_rowready_func2::neg_transformer
  if (item)
    item->fix_fields(thd, 0, &item);
  return item;
}

+4 −1
Original line number Diff line number Diff line
@@ -89,6 +89,7 @@ class Item_bool_func :public Item_int_func
  Item_bool_func(Item *a) :Item_int_func(a) {}
  Item_bool_func(Item *a,Item *b) :Item_int_func(a,b) {}
  Item_bool_func(THD *thd, Item_bool_func *item) :Item_int_func(thd, item) {}
  bool is_bool_func() { return 1; }
  void fix_length_and_dec() { decimals=0; max_length=1; }
};

@@ -201,6 +202,7 @@ class Item_bool_func2 :public Item_int_func
  bool have_rev_func() const { return rev_functype() != UNKNOWN_FUNC; }
  void print(String *str) { Item_func::print_op(str); }
  bool is_null() { return test(args[0]->is_null() || args[1]->is_null()); }
  bool is_bool_func() { return 1; }
  CHARSET_INFO *compare_collation() { return cmp.cmp_collation.collation; }

  friend class  Arg_comparator;
@@ -748,6 +750,7 @@ class Item_func_in :public Item_int_func
  enum Functype functype() const { return IN_FUNC; }
  const char *func_name() const { return " IN "; }
  bool nulls_in_row();
  bool is_bool_func() { return 1; }
  CHARSET_INFO *compare_collation() { return cmp_collation.collation; }
};

Loading