Commit 015f5bd5 authored by unknown's avatar unknown

Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-5.0

into deer.(none):/home/hf/work/mysql-5.0.12267


sql/sql_yacc.yy:
  Auto merged
parents 54d1558c e579fe3e
...@@ -170,3 +170,30 @@ insert into t1 values (1); ...@@ -170,3 +170,30 @@ insert into t1 values (1);
select rand(i) from t1; select rand(i) from t1;
ERROR HY000: Incorrect arguments to RAND ERROR HY000: Incorrect arguments to RAND
drop table t1; drop table t1;
set sql_mode='traditional';
select ln(-1);
ln(-1)
NULL
Warnings:
Error 1365 Division by 0
select log10(-1);
log10(-1)
NULL
Warnings:
Error 1365 Division by 0
select log2(-1);
log2(-1)
NULL
Warnings:
Error 1365 Division by 0
select log(2,-1);
log(2,-1)
NULL
Warnings:
Error 1365 Division by 0
select log(-2,1);
log(-2,1)
NULL
Warnings:
Error 1365 Division by 0
set sql_mode='';
...@@ -680,3 +680,11 @@ select astext(fn3()); ...@@ -680,3 +680,11 @@ select astext(fn3());
astext(fn3()) astext(fn3())
POINT(1 1) POINT(1 1)
drop function fn3; drop function fn3;
create table t1(pt POINT);
alter table t1 add primary key pti(pt);
drop table t1;
create table t1(pt GEOMETRY);
alter table t1 add primary key pti(pt);
ERROR 42000: BLOB/TEXT column 'pt' used in key specification without a key length
alter table t1 add primary key pti(pt(20));
drop table t1;
...@@ -1019,3 +1019,5 @@ drop procedure wg2; ...@@ -1019,3 +1019,5 @@ drop procedure wg2;
select cast(@non_existing_user_var/2 as DECIMAL); select cast(@non_existing_user_var/2 as DECIMAL);
cast(@non_existing_user_var/2 as DECIMAL) cast(@non_existing_user_var/2 as DECIMAL)
NULL NULL
create table t (d decimal(0,10));
ERROR 42000: For float(M,D), double(M,D) or decimal(M,D), M must be >= D (column 'd').
...@@ -117,3 +117,15 @@ select rand(i) from t1; ...@@ -117,3 +117,15 @@ select rand(i) from t1;
drop table t1; drop table t1;
# End of 4.1 tests # End of 4.1 tests
#
# Bug #13820 (No warning on log(negative)
#
set sql_mode='traditional';
select ln(-1);
select log10(-1);
select log2(-1);
select log(2,-1);
select log(-2,1);
set sql_mode='';
...@@ -395,3 +395,14 @@ show create function fn3; ...@@ -395,3 +395,14 @@ show create function fn3;
select astext(fn3()); select astext(fn3());
drop function fn3; drop function fn3;
#
# Bug #12267 (primary key over GIS)
#
create table t1(pt POINT);
alter table t1 add primary key pti(pt);
drop table t1;
create table t1(pt GEOMETRY);
--error 1170
alter table t1 add primary key pti(pt);
alter table t1 add primary key pti(pt(20));
drop table t1;
...@@ -1044,3 +1044,9 @@ drop procedure wg2; ...@@ -1044,3 +1044,9 @@ drop procedure wg2;
# #
select cast(@non_existing_user_var/2 as DECIMAL); select cast(@non_existing_user_var/2 as DECIMAL);
#
# Bug #13667 (Inconsistency for decimal(m,d) specification
#
--error 1427
create table t (d decimal(0,10));
...@@ -1386,8 +1386,13 @@ double Item_func_ln::val_real() ...@@ -1386,8 +1386,13 @@ double Item_func_ln::val_real()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
double value= args[0]->val_real(); double value= args[0]->val_real();
if ((null_value=(args[0]->null_value || value <= 0.0))) if ((null_value=args[0]->null_value))
return 0.0;
if ((null_value= value <=0.0))
{
signal_divide_by_null();
return 0.0; return 0.0;
}
return log(value); return log(value);
} }
...@@ -1400,13 +1405,23 @@ double Item_func_log::val_real() ...@@ -1400,13 +1405,23 @@ double Item_func_log::val_real()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
double value= args[0]->val_real(); double value= args[0]->val_real();
if ((null_value=(args[0]->null_value || value <= 0.0))) if ((null_value=args[0]->null_value))
return 0.0;
if ((null_value= value <=0.0))
{
signal_divide_by_null();
return 0.0; return 0.0;
}
if (arg_count == 2) if (arg_count == 2)
{ {
double value2= args[1]->val_real(); double value2= args[1]->val_real();
if ((null_value=(args[1]->null_value || value2 <= 0.0 || value == 1.0))) if ((null_value=args[1]->null_value))
return 0.0;
if ((null_value= value2 <=0.0) || (value == 1.0))
{
signal_divide_by_null();
return 0.0; return 0.0;
}
return log(value2) / log(value); return log(value2) / log(value);
} }
return log(value); return log(value);
...@@ -1416,8 +1431,14 @@ double Item_func_log2::val_real() ...@@ -1416,8 +1431,14 @@ double Item_func_log2::val_real()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
double value= args[0]->val_real(); double value= args[0]->val_real();
if ((null_value=(args[0]->null_value || value <= 0.0)))
if ((null_value=args[0]->null_value))
return 0.0; return 0.0;
if ((null_value= value <=0.0))
{
signal_divide_by_null();
return 0.0;
}
return log(value) / M_LN2; return log(value) / M_LN2;
} }
...@@ -1425,8 +1446,13 @@ double Item_func_log10::val_real() ...@@ -1425,8 +1446,13 @@ double Item_func_log10::val_real()
{ {
DBUG_ASSERT(fixed == 1); DBUG_ASSERT(fixed == 1);
double value= args[0]->val_real(); double value= args[0]->val_real();
if ((null_value=(args[0]->null_value || value <= 0.0))) if ((null_value=args[0]->null_value))
return 0.0; /* purecov: inspected */ return 0.0;
if ((null_value= value <=0.0))
{
signal_divide_by_null();
return 0.0;
}
return log10(value); return log10(value);
} }
......
...@@ -5791,7 +5791,7 @@ new_create_field(THD *thd, char *field_name, enum_field_types type, ...@@ -5791,7 +5791,7 @@ new_create_field(THD *thd, char *field_name, enum_field_types type,
case FIELD_TYPE_NULL: case FIELD_TYPE_NULL:
break; break;
case FIELD_TYPE_NEWDECIMAL: case FIELD_TYPE_NEWDECIMAL:
if (!length) if (!length && !new_field->decimals)
new_field->length= 10; new_field->length= 10;
if (new_field->length > DECIMAL_MAX_PRECISION) if (new_field->length > DECIMAL_MAX_PRECISION)
{ {
......
...@@ -1149,13 +1149,17 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, ...@@ -1149,13 +1149,17 @@ static int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info,
{ {
column->length*= sql_field->charset->mbmaxlen; column->length*= sql_field->charset->mbmaxlen;
if (f_is_blob(sql_field->pack_flag)) if (f_is_blob(sql_field->pack_flag) ||
(f_is_geom(sql_field->pack_flag) && key->type != Key::SPATIAL))
{ {
if (!(file->table_flags() & HA_CAN_INDEX_BLOBS)) if (!(file->table_flags() & HA_CAN_INDEX_BLOBS))
{ {
my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->field_name); my_error(ER_BLOB_USED_AS_KEY, MYF(0), column->field_name);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
if (f_is_geom(sql_field->pack_flag) && sql_field->geom_type ==
Field::GEOM_POINT)
column->length= 21;
if (!column->length) if (!column->length)
{ {
my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name); my_error(ER_BLOB_KEY_WITHOUT_LENGTH, MYF(0), column->field_name);
......
...@@ -2982,7 +2982,9 @@ type: ...@@ -2982,7 +2982,9 @@ type:
spatial_type: spatial_type:
GEOMETRY_SYM { $$= Field::GEOM_GEOMETRY; } GEOMETRY_SYM { $$= Field::GEOM_GEOMETRY; }
| GEOMETRYCOLLECTION { $$= Field::GEOM_GEOMETRYCOLLECTION; } | GEOMETRYCOLLECTION { $$= Field::GEOM_GEOMETRYCOLLECTION; }
| POINT_SYM { $$= Field::GEOM_POINT; } | POINT_SYM { Lex->length= (char*)"21";
$$= Field::GEOM_POINT;
}
| MULTIPOINT { $$= Field::GEOM_MULTIPOINT; } | MULTIPOINT { $$= Field::GEOM_MULTIPOINT; }
| LINESTRING { $$= Field::GEOM_LINESTRING; } | LINESTRING { $$= Field::GEOM_LINESTRING; }
| MULTILINESTRING { $$= Field::GEOM_MULTILINESTRING; } | MULTILINESTRING { $$= Field::GEOM_MULTILINESTRING; }
......
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