Commit 1a3a4ee3 authored by unknown's avatar unknown
Browse files

Merge sgluhov@bk-internal.mysql.com:/home/bk/mysql-4.1

into gluh.mysql.r18.ru:/home/gluh/MySQL/mysql-4.1

parents d3694db6 d716cb94
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -733,3 +733,15 @@ one 2
two	2
three	1
drop table t1;
create table t1(f1 datetime);
insert into t1 values (now());
create table t2 select f2 from (select max(now()) f2 from t1) a;
show columns from t2;
Field	Type	Null	Key	Default	Extra
f2	datetime			0000-00-00 00:00:00	
drop table t2;
create table t2 select f2 from (select now() f2 from t1) a;
show columns from t2;
Field	Type	Null	Key	Default	Extra
f2	datetime			0000-00-00 00:00:00	
drop table t2, t1;
+36 −0
Original line number Diff line number Diff line
@@ -1137,3 +1137,39 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
drop table t1;
drop table t2;
create table t1(a1 int, f1 char(10));
create table t2
select f2,a1 from (select a1, CAST('2004-12-31' AS DATE) f2 from t1) a
union
select f2,a1 from (select a1, CAST('2004-12-31' AS DATE) f2 from t1) a
order by f2, a1;
show columns from t2;
Field	Type	Null	Key	Default	Extra
f2	date	YES		NULL	
a1	int(11)	YES		NULL	
drop table t1, t2;
create table t1 (f1 int);
create table t2 (f1 int, f2 int ,f3 date);
create table t3 (f1 int, f2 char(10));
create table t4
(
select t2.f3 as sdate
from t1
left outer join t2 on (t1.f1 = t2.f1)
inner join t3 on (t2.f2 = t3.f1)
order by t1.f1, t3.f1, t2.f3
)
union
(
select cast('2004-12-31' as date) as sdate
from t1
left outer join t2 on (t1.f1 = t2.f1)
inner join t3 on (t2.f2 = t3.f1)
group by t1.f1
order by t1.f1, t3.f1, t2.f3
)
order by sdate;
show columns from t4;
Field	Type	Null	Key	Default	Extra
sdate	date	YES		NULL	
drop table t1, t2, t3, t4;
+14 −0
Original line number Diff line number Diff line
@@ -473,3 +473,17 @@ INSERT INTO t1 VALUES

select val, count(*) from t1 group by val;
drop table t1;


#
# Bug 7833:  Wrong datatype of aggregate column is returned
#

create table t1(f1 datetime);
insert into t1 values (now());
create table t2 select f2 from (select max(now()) f2 from t1) a;
show columns from t2;
drop table t2;
create table t2 select f2 from (select now() f2 from t1) a;
show columns from t2;
drop table t2, t1;
+35 −0
Original line number Diff line number Diff line
@@ -664,3 +664,38 @@ show create table t1;
drop table t1;
drop table t2;

#
# Bug 6931: Date Type column problem when using UNION-Table.
#
create table t1(a1 int, f1 char(10));
create table t2
select f2,a1 from (select a1, CAST('2004-12-31' AS DATE) f2 from t1) a
union
select f2,a1 from (select a1, CAST('2004-12-31' AS DATE) f2 from t1) a
order by f2, a1;
show columns from t2;
drop table t1, t2;

create table t1 (f1 int);
create table t2 (f1 int, f2 int ,f3 date);
create table t3 (f1 int, f2 char(10));
create table t4
(
  select t2.f3 as sdate
  from t1
  left outer join t2 on (t1.f1 = t2.f1)
  inner join t3 on (t2.f2 = t3.f1)
  order by t1.f1, t3.f1, t2.f3
)
union
(
  select cast('2004-12-31' as date) as sdate
  from t1
  left outer join t2 on (t1.f1 = t2.f1)
  inner join t3 on (t2.f2 = t3.f1)
  group by t1.f1
  order by t1.f1, t3.f1, t2.f3
)
order by sdate;
show columns from t4;
drop table t1, t2, t3, t4;
+35 −0
Original line number Diff line number Diff line
@@ -245,6 +245,7 @@ static Field::field_cast_enum field_cast_date[]=
 Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
static Field::field_cast_enum field_cast_newdate[]=
{Field::FIELD_CAST_NEWDATE,
 Field::FIELD_CAST_DATE,
 Field::FIELD_CAST_DATETIME,
 Field::FIELD_CAST_STRING, Field::FIELD_CAST_VARSTRING,
 Field::FIELD_CAST_BLOB, Field::FIELD_CAST_STOP};
@@ -6024,6 +6025,40 @@ Field *make_field(char *ptr, uint32 field_length,
}


/*
  Check if field_type is appropriate field type
  to create field for tmp table using
  item->tmp_table_field() method

  SYNOPSIS
    field_types_to_be_kept()
    field_type     - field type

  NOTE
    it is used in function get_holder_example_field()
    from item.cc

  RETURN
    1 - can use item->tmp_table_field() method
    0 - can not use item->tmp_table_field() method

*/

bool field_types_to_be_kept(enum_field_types field_type)
{
  switch (field_type)
  {
    case FIELD_TYPE_DATE:
    case FIELD_TYPE_NEWDATE:
    case FIELD_TYPE_TIME:
    case FIELD_TYPE_DATETIME:
      return 1;
    default:
      return 0;
  }
}


/* Create a field suitable for create of table */

create_field::create_field(Field *old_field,Field *orig_field)
Loading