List:Commits« Previous MessageNext Message »
From:Tor Didriksen Date:February 10 2011 9:28am
Subject:Re: bzr commit into mysql-trunk branch (jorgen.loland:3625) Bug#59793
View as plain text  
>> === modified file 'mysql-test/t/negation_elimination.test'
>> --- mysql-test/t/negation_elimination.test    2005-07-28 00:22:47 +0000
>> +++ mysql-test/t/negation_elimination.test    2011-02-10 08:02:14 +0000
>> @@ -65,10 +65,40 @@
>>  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)));
>>
>> +--echo
>> +--echo # XOR (Note: XOR is negated by negating one of the operands)
>> +
>> +--echo # Should return 6,7
>> +SELECT * FROM t1 WHERE ((a > 5) XOR (a > 7));
>> +
>> +--echo # Should return 0..5,8..19
>> +SELECT * FROM t1 WHERE ((NOT (a > 5)) XOR (a > 7));
>> +SELECT * FROM t1 WHERE ((a > 5) XOR (NOT (a > 7)));
>> +SELECT * FROM t1 WHERE NOT ((a > 5) XOR (a > 7));
>> +
>> +--echo # Should return 6,7
>> +SELECT * FROM t1 WHERE NOT ((NOT (a > 5)) XOR (a > 7));
>> +SELECT * FROM t1 WHERE NOT ((a > 5) XOR (NOT (a > 7)));
>> +
>> +--echo # Should return 0..5,8..19
>> +SELECT * FROM t1 WHERE NOT (NOT (a > 5) XOR (NOT (a > 7)));
>> +

please add
--echo # Should have empty result

>> +SELECT * FROM t1 WHERE (NULL XOR (a > 7));
>> +SELECT * FROM t1 WHERE NOT (NULL XOR (a > 7));
>> +
>> +--echo # Should be simplified to "...WHERE (a XOR a)
>> +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NOT ((NOT a) XOR (a));
>> +
>> +--echo # Should be simplified to "...WHERE (a XOR a)
>> +EXPLAIN EXTENDED SELECT * FROM t1 WHERE NOT (a XOR (NOT a));
>> +
>> +--echo # XOR End
>> +--echo
>> +
>>
>> === modified file 'sql/item_cmpfunc.cc'
>> --- sql/item_cmpfunc.cc    2011-02-08 15:54:12 +0000
>> +++ sql/item_cmpfunc.cc    2011-02-10 08:02:14 +0000
>> @@ -5333,17 +5333,15 @@
>>      very fast to use.
>>  */
>>
>> -longlong Item_cond_xor::val_int()
>> +longlong Item_func_xor::val_int()
>>  {
>>    DBUG_ASSERT(fixed == 1);
>> -  List_iterator<Item> li(list);
>> -  Item *item;
>> -  int result=0;
>> +  int result=0;
>>    null_value=0;

int result= 0;
null_value= false;

>> -  while ((item=li++))
>> +  for (uint i= 0; i < arg_count; i++)
>>    {
>> -    result^= (item->val_int() != 0);
>> -    if (item->null_value)
>> +    result^= (args[i]->val_int() != 0);
>> +    if (args[i]->null_value)
>>      {
>>        null_value=1;

null_value= true;

>>        return 0;
>>        return 0;
>>      }
>>    }
>>    return (longlong) result;

No need for the C-style cast here,
int will be safely promoted to longlong.

>>  }
>> === modified file 'unittest/gunit/item-t.cc'
>> --- unittest/gunit/item-t.cc    2011-02-07 13:03:47 +0000
>> +++ unittest/gunit/item-t.cc    2011-02-10 08:02:14 +0000
>> @@ -183,4 +183,40 @@
>>    EXPECT_LE(item_decrypt->max_length, length);
>>  }
>>
>> +
>> +TEST_F(ItemTest, ItemFuncXor)
>> +{
>> +  const uint length= 1U;
>> +  Item_int *item_one= new Item_int(0, length);
>> +  Item_int *item_two= new Item_int(1, length);
>> +
>> +  Item_func_xor *item_xor=
>> +    new Item_func_xor(item_one, item_two);
>> +
>> +  EXPECT_FALSE(item_xor->fix_fields(m_thd, NULL));
>> +  EXPECT_EQ(1, item_xor->val_int());
>> +
>> +  String print_buffer;
>> +  item_xor->print(&print_buffer, QT_ORDINARY);
>> +  EXPECT_STREQ("(0 xor 1)", print_buffer.c_ptr());
>> +
>> +  Item *neg_xor= item_xor->neg_transformer(m_thd);
>> +  EXPECT_FALSE(neg_xor->fix_fields(m_thd, NULL));
>> +  EXPECT_EQ(0, neg_xor->val_int());
>> +  EXPECT_DOUBLE_EQ(0.0, neg_xor->val_real());
>> +  EXPECT_FALSE(neg_xor->val_bool());
>> +  EXPECT_EQ(0, neg_xor->is_null());

EXPECT_FALSE


>> +
>> +  print_buffer= String();
>> +  neg_xor->print(&print_buffer, QT_ORDINARY);
>> +  EXPECT_STREQ("((not(0)) xor 1)", print_buffer.c_ptr());
>> +
>> +  Item_func_xor *item_xor_null=
>> +    new Item_func_xor(item_one, new Item_null());
>> +  EXPECT_FALSE(item_xor_null->fix_fields(m_thd, NULL));
>> +
>> +  EXPECT_EQ(0, item_xor_null->val_int());
>> +  EXPECT_TRUE(item_xor_null->is_null());
>> +}
>> +
>>  }
>>




> --
> MySQL Code Commits Mailing List
> For list archives: http://lists.mysql.com/commits
> To unsubscribe:
> http://lists.mysql.com/commits?unsub=1
>

Thread
bzr commit into mysql-trunk branch (jorgen.loland:3625) Bug#59793Jorgen Loland9 Feb
  • Re: bzr commit into mysql-trunk branch (jorgen.loland:3625) Bug#59793Tor Didriksen10 Feb
  • Re: bzr commit into mysql-trunk branch (jorgen.loland:3625) Bug#59793Øystein Grøvlen17 Feb