Commit 049ded30 authored by unknown's avatar unknown

Merge sinisa@work.mysql.com:/home/bk/mysql-4.0

into sinisa.nasamreza.org:/mnt/hdc/Sinisa/mysql-4.0

parents 05a88fd7 38d4712e
......@@ -76,4 +76,14 @@ x varchar(50) YES NULL
describe t2;
Field Type Null Key Default Extra
x char(50) YES NULL
drop table t2;
create table t2 select now() as a , curtime() as b, curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f;
describe t2;
Field Type Null Key Default Extra
a datetime 0000-00-00 00:00:00
b time 00:00:00
c date 0000-00-00
d bigint(17) 0
e double(18,1) 0.0
f bigint(17) 0
drop table t1,t2;
......@@ -74,4 +74,7 @@ create table t1(x varchar(50) );
create table t2 select x from t1 where 1=2;
describe t1;
describe t2;
drop table t2;
create table t2 select now() as a , curtime() as b, curdate() as c , 1+1 as d , 1.0 + 1 as e , 33333333333333333 + 3 as f;
describe t2;
drop table t1,t2;
......@@ -593,6 +593,10 @@ class Field_date :public Field_str {
:Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg)
{}
Field_date(bool maybe_null_arg, const char *field_name_arg,
struct st_table *table_arg)
:Field_str((char*) 0,10, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, table_arg) {}
enum_field_types type() const { return FIELD_TYPE_DATE;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; }
enum Item_result cmp_type () const { return INT_RESULT; }
......@@ -650,6 +654,10 @@ class Field_time :public Field_str {
:Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg)
{}
Field_time(bool maybe_null_arg, const char *field_name_arg,
struct st_table *table_arg)
:Field_str((char*) 0,8, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, table_arg) {}
enum_field_types type() const { return FIELD_TYPE_TIME;}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; }
enum Item_result cmp_type () const { return INT_RESULT; }
......@@ -678,6 +686,10 @@ class Field_datetime :public Field_str {
:Field_str(ptr_arg, 19, null_ptr_arg, null_bit_arg,
unireg_check_arg, field_name_arg, table_arg)
{}
Field_datetime(bool maybe_null_arg, const char *field_name_arg,
struct st_table *table_arg)
:Field_str((char*) 0,19, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, table_arg) {}
enum_field_types type() const { return FIELD_TYPE_DATETIME;}
#ifdef HAVE_LONG_LONG
enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONGLONG; }
......
......@@ -64,7 +64,7 @@ class Item {
virtual longlong val_int()=0;
virtual String *val_str(String*)=0;
virtual void make_field(Send_field *field)=0;
virtual Field *tmp_table_field() { return 0; }
virtual Field *tmp_table_field(TABLE *t_arg=(TABLE *)0) { return 0; }
virtual const char *full_name() const { return name ? name : "???"; }
virtual double val_result() { return val(); }
virtual longlong val_int_result() { return val_int(); }
......@@ -128,7 +128,7 @@ class Item_field :public Item_ident
{
return field->result_type();
}
Field *tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg=(TABLE *)0) { return result_field; }
bool get_date(TIME *ltime,bool fuzzydate);
bool get_time(TIME *ltime);
bool is_null() { return field->is_null(); }
......@@ -308,7 +308,7 @@ class Item_result_field :public Item /* Item with result field */
Field *result_field; /* Save result here */
Item_result_field() :result_field(0) {}
~Item_result_field() {} /* Required with gcc 2.95 */
Field *tmp_table_field() { return result_field; }
Field *tmp_table_field(TABLE *t_arg=(TABLE *)0) { return result_field; }
table_map used_tables() const { return 1; }
virtual void fix_length_and_dec()=0;
};
......
......@@ -135,6 +135,11 @@ class Item_real_func :public Item_func
longlong val_int() { return (longlong) val(); }
enum Item_result result_type () const { return REAL_RESULT; }
void fix_length_and_dec() { decimals=NOT_FIXED_DEC; max_length=float_length(decimals); }
Field *tmp_table_field(TABLE *t_arg)
{
if (!t_arg) return result_field;
return new Field_double(max_length, maybe_null, name,t_arg,decimals);
}
};
class Item_num_func :public Item_func
......@@ -164,6 +169,11 @@ class Item_num_op :public Item_func
void fix_length_and_dec() { fix_num_length_and_dec(); find_num_type(); }
void find_num_type(void);
bool is_null() { (void) val(); return null_value; }
Field *tmp_table_field(TABLE *t_arg)
{
if (!t_arg) return result_field;
return args[0]->result_type() == INT_RESULT ? ((max_length > 11) ? (Field *)new Field_longlong(max_length,maybe_null,name, t_arg,unsigned_flag) : (Field *)new Field_long(max_length,maybe_null,name, t_arg,unsigned_flag)) : (Field *) new Field_double(max_length, maybe_null, name,t_arg,decimals);
}
};
......@@ -179,6 +189,11 @@ class Item_int_func :public Item_func
String *val_str(String*str);
enum Item_result result_type () const { return INT_RESULT; }
void fix_length_and_dec() { decimals=0; max_length=21; }
Field *tmp_table_field(TABLE *t_arg)
{
if (!t_arg) return result_field;
return (max_length > 11) ? (Field *)new Field_longlong(max_length,maybe_null,name, t_arg,unsigned_flag) : (Field *)new Field_long(max_length,maybe_null,name, t_arg,unsigned_flag);
}
};
class Item_func_plus :public Item_num_op
......
......@@ -35,6 +35,11 @@ class Item_str_func :public Item_func
double val();
enum Item_result result_type () const { return STRING_RESULT; }
void left_right_max_length();
Field *tmp_table_field(TABLE *t_arg)
{
if (!t_arg) return result_field;
return (max_length > 255) ? (Field *)new Field_blob(max_length,maybe_null, name,t_arg, binary) : (Field *) new Field_string(max_length,maybe_null, name,t_arg, binary);
}
};
class Item_func_md5 :public Item_str_func
......
......@@ -233,6 +233,11 @@ class Item_date :public Item_func
{
init_make_field(tmp_field,FIELD_TYPE_DATE);
}
Field *tmp_table_field(TABLE *t_arg)
{
if (!t_arg) return result_field;
return new Field_date(maybe_null, name, t_arg);
}
};
......@@ -246,6 +251,11 @@ class Item_date_func :public Item_str_func
{
init_make_field(tmp_field,FIELD_TYPE_DATETIME);
}
Field *tmp_table_field(TABLE *t_arg)
{
if (!t_arg) return result_field;
return new Field_datetime(maybe_null, name, t_arg);
}
};
......@@ -268,6 +278,11 @@ class Item_func_curtime :public Item_func
{
init_make_field(tmp_field,FIELD_TYPE_TIME);
}
Field *tmp_table_field(TABLE *t_arg)
{
if (!t_arg) return result_field;
return new Field_time(maybe_null, name, t_arg);
}
};
......@@ -355,6 +370,12 @@ class Item_func_sec_to_time :public Item_str_func
{
init_make_field(tmp_field,FIELD_TYPE_TIME);
}
Field *tmp_table_field(TABLE *t_arg)
{
if (!t_arg) return result_field;
return new Field_time(maybe_null, name, t_arg);
}
};
enum interval_type { INTERVAL_YEAR, INTERVAL_MONTH, INTERVAL_DAY,
......
......@@ -704,8 +704,11 @@ TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info,
my_error(ER_WRONG_COLUMN_NAME,MYF(0),item->name);
DBUG_RETURN(0);
}
Field *field=create_tmp_field(thd, &tmp_table, item, item->type(),
Field *field;
if (item->type() == Item::FUNC_ITEM)
field=item->tmp_table_field(&tmp_table);
else
field=create_tmp_field(thd, &tmp_table, item, item->type(),
(Item_result_field***) 0, &tmp_field,0,0);
if (!field ||
!(cr_field=new create_field(field,(item->type() == Item::FIELD_ITEM ?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment