Commit 937d5f89 authored by unknown's avatar unknown

Merge moonbone.local:/mnt/gentoo64/work/bk-trees/mysql-5.0-opt

into  moonbone.local:/mnt/gentoo64/work/test-5.1-opt-mysql


mysql-test/r/olap.result:
  Auto merged
mysql-test/r/view.result:
  Auto merged
mysql-test/t/sp.test:
  Auto merged
sql/field.h:
  Auto merged
sql/item_cmpfunc.cc:
  Auto merged
sql/item_func.cc:
  Auto merged
sql/sql_select.cc:
  Auto merged
mysql-test/r/analyse.result:
  Manual merge
mysql-test/r/sp.result:
  Manual merge
sql/item_timefunc.cc:
  Manual merge
parents d9426a89 98b5043a
...@@ -84,4 +84,15 @@ CAST('2006-09-26' AS DATE) + INTERVAL 1 YEAR ...@@ -84,4 +84,15 @@ CAST('2006-09-26' AS DATE) + INTERVAL 1 YEAR
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 WEEK; SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 WEEK;
CAST('2006-09-26' AS DATE) + INTERVAL 1 WEEK CAST('2006-09-26' AS DATE) + INTERVAL 1 WEEK
2006-10-03 2006-10-03
create table t1 (a int, b varchar(10));
insert into t1 values (1, '2001-01-01'),(2, '2002-02-02');
select '2007-01-01' + interval a day from t1;
'2007-01-01' + interval a day
2007-01-02
2007-01-03
select b + interval a day from t1;
b + interval a day
2001-01-02
2002-02-04
drop table t1;
End of 5.0 tests End of 5.0 tests
...@@ -130,3 +130,14 @@ def v3 renamed 8 12 0 Y 32896 0 63 ...@@ -130,3 +130,14 @@ def v3 renamed 8 12 0 Y 32896 0 63
renamed renamed
drop table t1; drop table t1;
drop view v1,v2,v3; drop view v1,v2,v3;
select a.* from (select 2147483648 as v_large) a;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def a v_large v_large 8 10 10 N 32769 0 63
v_large
2147483648
select a.* from (select 214748364 as v_small) a;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def a v_small v_small 3 9 9 N 32769 0 63
v_small
214748364
End of 5.0 tests
...@@ -696,8 +696,8 @@ CREATE VIEW v1 AS ...@@ -696,8 +696,8 @@ CREATE VIEW v1 AS
SELECT a, LENGTH(a), COUNT(*) FROM t1 GROUP BY a WITH ROLLUP; SELECT a, LENGTH(a), COUNT(*) FROM t1 GROUP BY a WITH ROLLUP;
DESC v1; DESC v1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
a int(11) YES 0 a bigint(11) YES NULL
LENGTH(a) int(10) YES NULL LENGTH(a) bigint(10) YES NULL
COUNT(*) bigint(21) NO 0 COUNT(*) bigint(21) NO 0
SELECT * FROM v1; SELECT * FROM v1;
a LENGTH(a) COUNT(*) a LENGTH(a) COUNT(*)
......
...@@ -6244,3 +6244,14 @@ count(*) ...@@ -6244,3 +6244,14 @@ count(*)
3 3
drop table t1,t2; drop table t1,t2;
drop function bug27354; drop function bug27354;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE FUNCTION metered(a INT) RETURNS INT RETURN 12;
CREATE VIEW v1 AS SELECT test.metered(a) as metered FROM t1;
SHOW CREATE VIEW v1;
View Create View
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `test`.`metered`(`t1`.`a`) AS `metered` from `t1`
DROP VIEW v1;
DROP FUNCTION metered;
DROP TABLE t1;
End of 5.0 tests
...@@ -2771,7 +2771,7 @@ CREATE TABLE t1 (i int, j int); ...@@ -2771,7 +2771,7 @@ CREATE TABLE t1 (i int, j int);
CREATE VIEW v1 AS SELECT COALESCE(i,j) FROM t1; CREATE VIEW v1 AS SELECT COALESCE(i,j) FROM t1;
DESCRIBE v1; DESCRIBE v1;
Field Type Null Key Default Extra Field Type Null Key Default Extra
COALESCE(i,j) int(11) YES NULL COALESCE(i,j) bigint(11) YES NULL
CREATE TABLE t2 SELECT COALESCE(i,j) FROM t1; CREATE TABLE t2 SELECT COALESCE(i,j) FROM t1;
DESCRIBE t2; DESCRIBE t2;
Field Type Null Key Default Extra Field Type Null Key Default Extra
......
...@@ -77,4 +77,14 @@ SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 MONTH; ...@@ -77,4 +77,14 @@ SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 MONTH;
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 YEAR; SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 YEAR;
SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 WEEK; SELECT CAST('2006-09-26' AS DATE) + INTERVAL 1 WEEK;
#
# Bug#28450: The Item_date_add_interval in select list may fail the field
# type assertion.
#
create table t1 (a int, b varchar(10));
insert into t1 values (1, '2001-01-01'),(2, '2002-02-02');
select '2007-01-01' + interval a day from t1;
select b + interval a day from t1;
drop table t1;
--echo End of 5.0 tests --echo End of 5.0 tests
...@@ -81,3 +81,14 @@ drop view v1,v2,v3; ...@@ -81,3 +81,14 @@ drop view v1,v2,v3;
--disable_metadata --disable_metadata
# End of 4.1 tests # End of 4.1 tests
#
# Bug #28492: subselect returns LONG in >5.0.24a and LONGLONG in <=5.0.24a
#
--enable_metadata
select a.* from (select 2147483648 as v_large) a;
select a.* from (select 214748364 as v_small) a;
--disable_metadata
--echo End of 5.0 tests
...@@ -7204,3 +7204,23 @@ select count(*) from t1 /* must be 3 */; ...@@ -7204,3 +7204,23 @@ select count(*) from t1 /* must be 3 */;
drop table t1,t2; drop table t1,t2;
drop function bug27354; drop function bug27354;
#
# Bug #28605: SHOW CREATE VIEW with views using stored_procedures no longer
# showing SP names.
#
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1),(2);
CREATE FUNCTION metered(a INT) RETURNS INT RETURN 12;
CREATE VIEW v1 AS SELECT test.metered(a) as metered FROM t1;
SHOW CREATE VIEW v1;
DROP VIEW v1;
DROP FUNCTION metered;
DROP TABLE t1;
--echo End of 5.0 tests
...@@ -742,7 +742,7 @@ public: ...@@ -742,7 +742,7 @@ public:
void sort_string(char *buff,uint length); void sort_string(char *buff,uint length);
uint32 pack_length() const { return 4; } uint32 pack_length() const { return 4; }
void sql_type(String &str) const; void sql_type(String &str) const;
uint32 max_display_length() { return 11; } uint32 max_display_length() { return MY_INT32_NUM_DECIMAL_DIGITS; }
}; };
......
...@@ -819,7 +819,12 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, ...@@ -819,7 +819,12 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
{ {
value= item->val_int(); value= item->val_int();
*is_null= item->null_value; *is_null= item->null_value;
if (item->field_type() == MYSQL_TYPE_DATE) /*
Item_date_add_interval may return MYSQL_TYPE_STRING as the result
field type. To detect that the DATE value has been returned we
compare it with 1000000L - any DATE value should be less than it.
*/
if (item->field_type() == MYSQL_TYPE_DATE || value < 100000000L)
value*= 1000000L; value*= 1000000L;
} }
else else
......
...@@ -5185,10 +5185,11 @@ Item_func_sp::func_name() const ...@@ -5185,10 +5185,11 @@ Item_func_sp::func_name() const
{ {
THD *thd= current_thd; THD *thd= current_thd;
/* Calculate length to avoid reallocation of string for sure */ /* Calculate length to avoid reallocation of string for sure */
uint len= ((m_name->m_explicit_name ? m_name->m_db.length : 0 + uint len= (((m_name->m_explicit_name ? m_name->m_db.length : 0) +
m_name->m_name.length)*2 + //characters*quoting m_name->m_name.length)*2 + //characters*quoting
2 + // ` and ` 2 + // ` and `
1 + // . (m_name->m_explicit_name ?
3 : 0) + // '`', '`' and '.' for the db
1 + // end of string 1 + // end of string
ALIGN_SIZE(1)); // to avoid String reallocation ALIGN_SIZE(1)); // to avoid String reallocation
String qname((char *)alloc_root(thd->mem_root, len), len, String qname((char *)alloc_root(thd->mem_root, len), len,
......
...@@ -2058,27 +2058,6 @@ bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, uint fuzzy_date) ...@@ -2058,27 +2058,6 @@ bool Item_date_add_interval::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
if ((null_value= date_add_interval(ltime, int_type, interval))) if ((null_value= date_add_interval(ltime, int_type, interval)))
return 1; return 1;
/* Adjust cached_field_type according to the detected type. */
if (cached_field_type == MYSQL_TYPE_STRING)
{
switch (ltime->time_type)
{
case MYSQL_TIMESTAMP_DATE:
cached_field_type= MYSQL_TYPE_DATE;
break;
case MYSQL_TIMESTAMP_DATETIME:
cached_field_type= MYSQL_TYPE_DATETIME;
break;
case MYSQL_TIMESTAMP_TIME:
cached_field_type= MYSQL_TYPE_TIME;
break;
default:
/* Shouldn't get here. */
DBUG_ASSERT(0);
break;
}
}
return 0; return 0;
} }
......
...@@ -9090,8 +9090,13 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table, ...@@ -9090,8 +9090,13 @@ static Field *create_tmp_field_from_item(THD *thd, Item *item, TABLE *table,
item->name, item->decimals, TRUE); item->name, item->decimals, TRUE);
break; break;
case INT_RESULT: case INT_RESULT:
/* Select an integer type with the minimal fit precision */ /*
if (item->max_length > MY_INT32_NUM_DECIMAL_DIGITS) Select an integer type with the minimal fit precision.
MY_INT32_NUM_DECIMAL_DIGITS is sign inclusive, don't consider the sign.
Values with MY_INT32_NUM_DECIMAL_DIGITS digits may or may not fit into
Field_long : make them Field_longlong.
*/
if (item->max_length >= (MY_INT32_NUM_DECIMAL_DIGITS - 1))
new_field=new Field_longlong(item->max_length, maybe_null, new_field=new Field_longlong(item->max_length, maybe_null,
item->name, item->unsigned_flag); item->name, item->unsigned_flag);
else else
......
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