dbTalk Databases Forums  

bk commit into 5.0 tree (konstantin:1.1911)

mailing.database.mysql-internals mailing.database.mysql-internals


Discuss bk commit into 5.0 tree (konstantin:1.1911) in the mailing.database.mysql-internals forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
konstantin@mysql.com
 
Posts: n/a

Default bk commit into 5.0 tree (konstantin:1.1911) - 05-04-2005 , 07:55 AM






Below is the list of changes that have just been committed into a local
5.0 repository of kostja. When kostja does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/in...urce-tree.html

ChangeSet
1.1911 05/05/04 16:54:36 konstantin (AT) mysql (DOT) com +2 -0
Merge bk-internal.mysql.com:/home/bk/mysql-5.0
into mysql.com:/opt/local/work/mysql-5.0-root

sql/item.h
1.119 05/05/04 16:54:34 konstantin (AT) mysql (DOT) com +0 -0
Auto merged

sql/item.cc
1.115 05/05/04 16:54:34 konstantin (AT) mysql (DOT) com +0 -0
Auto merged

# This is a BitKeeper patch. What follows are the unified diffs for the
# set of deltas contained in the patch. The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User: konstantin
# Host: dragonfly.local
# Root: /opt/local/work/mysql-5.0-root/RESYNC

--- 1.114/sql/item.cc 2005-04-30 20:27:18 +04:00
+++ 1.115/sql/item.cc 2005-05-04 16:54:34 +04:00
@@ -558,6 +558,11 @@

bool Item::eq(const Item *item, bool binary_cmp) const
{
+ /*
+ Note, that this is never TRUE if item is a Item_param:
+ for all basic constants we have special checks, and Item_param's
+ type() can be only among basic constant types.
+ */
return type() == item->type() && name && item->name &&
!my_strcasecmp(system_charset_info,name,item->name);
}
@@ -602,7 +607,7 @@

bool Item_string::eq(const Item *item, bool binary_cmp) const
{
- if (type() == item->type())
+ if (type() == item->type() && item->basic_const_item())
{
if (binary_cmp)
return !stringcmp(&str_value, &item->str_value);
@@ -1444,6 +1449,24 @@
}


+bool Item_decimal::eq(const Item *item, bool binary_cmp) const
+{
+ if (type() == item->type() && item->basic_const_item())
+ {
+ /*
+ We need to cast off const to call val_decimal(). This should
+ be OK for a basic constant. Additionally, we can pass 0 as
+ a true decimal constant will return its internal decimal
+ storage and ignore the argument.
+ */
+ Item *arg= (Item*) item;
+ my_decimal *value= arg->val_decimal(0);
+ return !my_decimal_cmp(&decimal_value, value);
+ }
+ return 0;
+}
+
+
String *Item_float::val_str(String *str)
{
// following assert is redundant, because fixed=1 assigned in constructor
@@ -2195,6 +2218,72 @@
}


+bool Item_param::basic_const_item() const
+{
+ if (state == NO_VALUE || state == TIME_VALUE)
+ return FALSE;
+ return TRUE;
+}
+
+
+Item *
+Item_param::new_item()
+{
+ /* see comments in the header file */
+ switch (state) {
+ case NULL_VALUE:
+ return new Item_null(name);
+ case INT_VALUE:
+ return new Item_int(name, value.integer, max_length);
+ case REAL_VALUE:
+ return new Item_float(name, value.real, decimals, max_length);
+ case STRING_VALUE:
+ case LONG_DATA_VALUE:
+ return new Item_string(name, str_value.c_ptr_quick(), str_value.length(),
+ str_value.charset());
+ case TIME_VALUE:
+ break;
+ case NO_VALUE:
+ default:
+ DBUG_ASSERT(0);
+ };
+ return 0;
+}
+
+
+bool
+Item_param::eq(const Item *arg, bool binary_cmp) const
+{
+ Item *item;
+ if (!basic_const_item() || !arg->basic_const_item() || arg->type() != type())
+ return FALSE;
+ /*
+ We need to cast off const to call val_int(). This should be OK for
+ a basic constant.
+ */
+ item= (Item*) arg;
+
+ switch (state) {
+ case NULL_VALUE:
+ return TRUE;
+ case INT_VALUE:
+ return value.integer == item->val_int() &&
+ unsigned_flag == item->unsigned_flag;
+ case REAL_VALUE:
+ return value.real == item->val_real();
+ case STRING_VALUE:
+ case LONG_DATA_VALUE:
+ if (binary_cmp)
+ return !stringcmp(&str_value, &item->str_value);
+ return !sortcmp(&str_value, &item->str_value, collation.collation);
+ default:
+ break;
+ }
+ return FALSE;
+}
+
+/* End of Item_param related */
+
void Item_param:rint(String *str)
{
if (state == NO_VALUE)
@@ -3412,6 +3501,22 @@
}


+bool Item_int::eq(const Item *arg, bool binary_cmp) const
+{
+ /* No need to check for null value as basic constant can't be NULL */
+ if (arg->basic_const_item() && arg->type() == type())
+ {
+ /*
+ We need to cast off const to call val_int(). This should be OK for
+ a basic constant.
+ */
+ Item *item= (Item*) arg;
+ return item->val_int() == value && item->unsigned_flag == unsigned_flag;
+ }
+ return FALSE;
+}
+
+
Item_num *Item_uint::neg()
{
Item_decimal *item= new Item_decimal(value, 0);
@@ -3499,6 +3604,21 @@
In number context this is a longlong value.
*/

+bool Item_float::eq(const Item *arg, bool binary_cmp) const
+{
+ if (arg->basic_const_item() && arg->type() == type())
+ {
+ /*
+ We need to cast off const to call val_int(). This should be OK for
+ a basic constant.
+ */
+ Item *item= (Item*) arg;
+ return item->val_real() == value;
+ }
+ return FALSE;
+}
+
+
inline uint char_val(char X)
{
return (uint) (X >= '0' && X <= '9' ? X-'0' :
@@ -3568,6 +3688,17 @@
return error;
}

+
+bool Item_hex_string::eq(const Item *arg, bool binary_cmp) const
+{
+ if (arg->basic_const_item() && arg->type() == type())
+ {
+ if (binary_cmp)
+ return !stringcmp(&str_value, &arg->str_value);
+ return !sortcmp(&str_value, &arg->str_value, collation.collation);
+ }
+ return FALSE;
+}

/*
bin item.

--- 1.118/sql/item.h 2005-04-30 20:32:41 +04:00
+++ 1.119/sql/item.h 2005-05-04 16:54:34 +04:00
@@ -434,7 +434,7 @@
virtual table_map not_null_tables() const { return used_tables(); }
/*
Returns true if this is a simple constant item like an integer, not
- a constant expression
+ a constant expression. Used in the optimizer to propagate basic constants.
*/
virtual bool basic_const_item() const { return 0; }
/* cloning of constant items (0 if it is not const) */
@@ -914,7 +914,6 @@

bool convert_str_value(THD *thd);

- Item *new_item() { return new Item_param(pos_in_query); }
/*
If value for parameter was not set we treat it as non-const
so noone will use parameters value in fix_fields still
@@ -923,12 +922,29 @@
virtual table_map used_tables() const
{ return state != NO_VALUE ? (table_map)0 : PARAM_TABLE_BIT; }
void print(String *str);
- /* parameter never equal to other parameter of other item */
- bool eq(const Item *item, bool binary_cmp) const { return 0; }
bool is_null()
{ DBUG_ASSERT(state != NO_VALUE); return state == NULL_VALUE; }
+ bool basic_const_item() const;
+ /*
+ This method is used to make a copy of a basic constant item when
+ propagating constants in the optimizer. The reason to create a new
+ item and not use the existing one is not precisely known (2005/04/16).
+ Probably we are trying to preserve tree structure of items, in other
+ words, avoid pointing at one item from two different nodes of the tree.
+ Return a new basic constant item if parameter value is a basic
+ constant, assert otherwise. This method is called only if
+ basic_const_item returned TRUE.
+ */
+ Item *new_item();
+ /*
+ Implement by-value equality evaluation if parameter value
+ is set and is a basic constant (integer, real or string).
+ Otherwise return FALSE.
+ */
+ bool eq(const Item *item, bool binary_cmp) const;
};

+
class Item_int ublic Item_num
{
public:
@@ -956,6 +972,7 @@
void cleanup() {}
void print(String *str);
Item_num *neg() { value= -value; return this; }
+ bool eq(const Item *, bool binary_cmp) const;
};


@@ -1022,8 +1039,10 @@
unsigned_flag= !decimal_value.sign();
return this;
}
+ bool eq(const Item *, bool binary_cmp) const;
};

+
class Item_float ublic Item_num
{
char *presentation;
@@ -1059,6 +1078,7 @@
{ return new Item_float(name, value, decimals, max_length); }
Item_num *neg() { value= -value; return this; }
void print(String *str);
+ bool eq(const Item *, bool binary_cmp) const;
};


@@ -1198,6 +1218,7 @@
enum_field_types field_type() const { return MYSQL_TYPE_VARCHAR; }
// to prevent drop fixed flag (no need parent cleanup call)
void cleanup() {}
+ bool eq(const Item *item, bool binary_cmp) const;
};



--
MySQL Internals Mailing List
For list archives: http://lists.mysql.com/internals
To unsubscribe: http://lists.mysql.com/internals?uns...ie.nctu.edu.tw


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.