Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
b4ed58bf
Commit
b4ed58bf
authored
Jun 02, 2005
by
unknown
Browse files
Options
Browse Files
Download
Plain Diff
Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0
into igor-inspiron.creware.com:/home/igor/mysql-5.0
parents
e9799ba6
79dd7767
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
93 additions
and
29 deletions
+93
-29
BitKeeper/etc/logging_ok
BitKeeper/etc/logging_ok
+1
-0
mysql-test/r/case.result
mysql-test/r/case.result
+17
-0
mysql-test/t/case.test
mysql-test/t/case.test
+19
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+12
-12
sql/item_cmpfunc.h
sql/item_cmpfunc.h
+13
-17
sql/item_func.cc
sql/item_func.cc
+25
-0
sql/item_func.h
sql/item_func.h
+6
-0
No files found.
BitKeeper/etc/logging_ok
View file @
b4ed58bf
...
...
@@ -87,6 +87,7 @@ hf@deer.mysql.r18.ru
hf@genie.(none)
holyfoot@mysql.com
igor@hundin.mysql.fi
igor@igor-inspiron.creware.com
igor@linux.local
igor@rurik.mysql.com
ingo@mysql.com
...
...
mysql-test/r/case.result
View file @
b4ed58bf
...
...
@@ -160,3 +160,20 @@ t1 CREATE TABLE `t1` (
`COALESCE('a' COLLATE latin1_bin,'b')` varchar(1) character set latin1 collate latin1_bin NOT NULL default ''
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
CREATE TABLE t1 (EMPNUM INT);
INSERT INTO t1 VALUES (0), (2);
CREATE TABLE t2 (EMPNUM DECIMAL (4, 2));
INSERT INTO t2 VALUES (0.0), (9.0);
SELECT COALESCE(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2
FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
CEMPNUM EMPMUM1 EMPNUM2
0.00 0 0.00
2.00 2 NULL
SELECT IFNULL(t2.EMPNUM,t1.EMPNUM) AS CEMPNUM,
t1.EMPNUM AS EMPMUM1, t2.EMPNUM AS EMPNUM2
FROM t1 LEFT JOIN t2 ON t1.EMPNUM=t2.EMPNUM;
CEMPNUM EMPMUM1 EMPNUM2
0.00 0 0.00
2.00 2 NULL
DROP TABLE t1,t2;
mysql-test/t/case.test
View file @
b4ed58bf
...
...
@@ -110,3 +110,22 @@ explain extended SELECT
COALESCE
(
'a'
COLLATE
latin1_bin
,
'b'
);
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
#
# Tests for bug #9939: conversion of the arguments for COALESCE and IFNULL
#
CREATE
TABLE
t1
(
EMPNUM
INT
);
INSERT
INTO
t1
VALUES
(
0
),
(
2
);
CREATE
TABLE
t2
(
EMPNUM
DECIMAL
(
4
,
2
));
INSERT
INTO
t2
VALUES
(
0.0
),
(
9.0
);
SELECT
COALESCE
(
t2
.
EMPNUM
,
t1
.
EMPNUM
)
AS
CEMPNUM
,
t1
.
EMPNUM
AS
EMPMUM1
,
t2
.
EMPNUM
AS
EMPNUM2
FROM
t1
LEFT
JOIN
t2
ON
t1
.
EMPNUM
=
t2
.
EMPNUM
;
SELECT
IFNULL
(
t2
.
EMPNUM
,
t1
.
EMPNUM
)
AS
CEMPNUM
,
t1
.
EMPNUM
AS
EMPMUM1
,
t2
.
EMPNUM
AS
EMPNUM2
FROM
t1
LEFT
JOIN
t2
ON
t1
.
EMPNUM
=
t2
.
EMPNUM
;
DROP
TABLE
t1
,
t2
;
sql/item_cmpfunc.cc
View file @
b4ed58bf
...
...
@@ -1116,8 +1116,8 @@ Item_func_ifnull::fix_length_and_dec()
max_length
=
(
max
(
args
[
0
]
->
max_length
-
args
[
0
]
->
decimals
,
args
[
1
]
->
max_length
-
args
[
1
]
->
decimals
)
+
decimals
);
agg_result_type
(
&
cached_result
_type
,
args
,
2
);
switch
(
cached_result
_type
)
{
agg_result_type
(
&
hybrid
_type
,
args
,
2
);
switch
(
hybrid
_type
)
{
case
STRING_RESULT
:
agg_arg_charsets
(
collation
,
args
,
arg_count
,
MY_COLL_CMP_CONV
);
break
;
...
...
@@ -1155,7 +1155,7 @@ Field *Item_func_ifnull::tmp_table_field(TABLE *table)
}
double
Item_func_ifnull
::
val_real
()
Item_func_ifnull
::
real_op
()
{
DBUG_ASSERT
(
fixed
==
1
);
double
value
=
args
[
0
]
->
val_real
();
...
...
@@ -1171,7 +1171,7 @@ Item_func_ifnull::val_real()
}
longlong
Item_func_ifnull
::
val_int
()
Item_func_ifnull
::
int_op
()
{
DBUG_ASSERT
(
fixed
==
1
);
longlong
value
=
args
[
0
]
->
val_int
();
...
...
@@ -1187,7 +1187,7 @@ Item_func_ifnull::val_int()
}
my_decimal
*
Item_func_ifnull
::
val_decimal
(
my_decimal
*
decimal_value
)
my_decimal
*
Item_func_ifnull
::
decimal_op
(
my_decimal
*
decimal_value
)
{
DBUG_ASSERT
(
fixed
==
1
);
my_decimal
*
value
=
args
[
0
]
->
val_decimal
(
decimal_value
);
...
...
@@ -1204,7 +1204,7 @@ my_decimal *Item_func_ifnull::val_decimal(my_decimal *decimal_value)
String
*
Item_func_ifnull
::
val_str
(
String
*
str
)
Item_func_ifnull
::
str_op
(
String
*
str
)
{
DBUG_ASSERT
(
fixed
==
1
);
String
*
res
=
args
[
0
]
->
val_str
(
str
);
...
...
@@ -1685,7 +1685,7 @@ void Item_func_case::print(String *str)
Coalesce - return first not NULL argument.
*/
String
*
Item_func_coalesce
::
val_str
(
String
*
str
)
String
*
Item_func_coalesce
::
str_op
(
String
*
str
)
{
DBUG_ASSERT
(
fixed
==
1
);
null_value
=
0
;
...
...
@@ -1699,7 +1699,7 @@ String *Item_func_coalesce::val_str(String *str)
return
0
;
}
longlong
Item_func_coalesce
::
val_int
()
longlong
Item_func_coalesce
::
int_op
()
{
DBUG_ASSERT
(
fixed
==
1
);
null_value
=
0
;
...
...
@@ -1713,7 +1713,7 @@ longlong Item_func_coalesce::val_int()
return
0
;
}
double
Item_func_coalesce
::
val_real
()
double
Item_func_coalesce
::
real_op
()
{
DBUG_ASSERT
(
fixed
==
1
);
null_value
=
0
;
...
...
@@ -1728,7 +1728,7 @@ double Item_func_coalesce::val_real()
}
my_decimal
*
Item_func_coalesce
::
val_decimal
(
my_decimal
*
decimal_value
)
my_decimal
*
Item_func_coalesce
::
decimal_op
(
my_decimal
*
decimal_value
)
{
DBUG_ASSERT
(
fixed
==
1
);
null_value
=
0
;
...
...
@@ -1745,8 +1745,8 @@ my_decimal *Item_func_coalesce::val_decimal(my_decimal *decimal_value)
void
Item_func_coalesce
::
fix_length_and_dec
()
{
agg_result_type
(
&
cached_result
_type
,
args
,
arg_count
);
switch
(
cached_result
_type
)
{
agg_result_type
(
&
hybrid
_type
,
args
,
arg_count
);
switch
(
hybrid
_type
)
{
case
STRING_RESULT
:
count_only_length
();
decimals
=
NOT_FIXED_DEC
;
...
...
sql/item_cmpfunc.h
View file @
b4ed58bf
...
...
@@ -453,23 +453,19 @@ public:
};
class
Item_func_coalesce
:
public
Item_func
class
Item_func_coalesce
:
public
Item_func
_numhybrid
{
protected:
enum
Item_result
cached_result_type
;
Item_func_coalesce
(
Item
*
a
,
Item
*
b
)
:
Item_func
(
a
,
b
),
cached_result_type
(
INT_RESULT
)
{}
Item_func_coalesce
(
Item
*
a
,
Item
*
b
)
:
Item_func_numhybrid
(
a
,
b
)
{}
public:
Item_func_coalesce
(
List
<
Item
>
&
list
)
:
Item_func
(
list
),
cached_result_type
(
INT_RESULT
)
{}
double
val_real
();
longlong
val_int
();
String
*
val_str
(
String
*
);
my_decimal
*
val_decimal
(
my_decimal
*
);
Item_func_coalesce
(
List
<
Item
>
&
list
)
:
Item_func_numhybrid
(
list
)
{}
double
real_op
();
longlong
int_op
();
String
*
str_op
(
String
*
);
my_decimal
*
decimal_op
(
my_decimal
*
);
void
fix_length_and_dec
();
enum
Item_result
result_type
()
const
{
return
cached_result_type
;
}
void
find_num_type
()
{}
enum
Item_result
result_type
()
const
{
return
hybrid_type
;
}
const
char
*
func_name
()
const
{
return
"coalesce"
;
}
table_map
not_null_tables
()
const
{
return
0
;
}
};
...
...
@@ -482,10 +478,10 @@ protected:
bool
field_type_defined
;
public:
Item_func_ifnull
(
Item
*
a
,
Item
*
b
)
:
Item_func_coalesce
(
a
,
b
)
{}
double
val_real
();
longlong
val_int
();
String
*
val_str
(
String
*
str
);
my_decimal
*
val_decimal
(
my_decimal
*
);
double
real_op
();
longlong
int_op
();
String
*
str_op
(
String
*
str
);
my_decimal
*
decimal_op
(
my_decimal
*
);
enum_field_types
field_type
()
const
;
void
fix_length_and_dec
();
const
char
*
func_name
()
const
{
return
"ifnull"
;
}
...
...
sql/item_func.cc
View file @
b4ed58bf
...
...
@@ -817,6 +817,8 @@ String *Item_func_numhybrid::val_str(String *str)
str
->
set
(
nr
,
decimals
,
&
my_charset_bin
);
break
;
}
case
STRING_RESULT
:
return
str_op
(
&
str_value
);
default:
DBUG_ASSERT
(
0
);
}
...
...
@@ -841,6 +843,14 @@ double Item_func_numhybrid::val_real()
return
(
double
)
int_op
();
case
REAL_RESULT
:
return
real_op
();
case
STRING_RESULT
:
{
char
*
end_not_used
;
int
err_not_used
;
String
*
res
=
str_op
(
&
str_value
);
return
(
res
?
my_strntod
(
res
->
charset
(),
(
char
*
)
res
->
ptr
(),
res
->
length
(),
&
end_not_used
,
&
err_not_used
)
:
0.0
);
}
default:
DBUG_ASSERT
(
0
);
}
...
...
@@ -865,6 +875,15 @@ longlong Item_func_numhybrid::val_int()
return
int_op
();
case
REAL_RESULT
:
return
(
longlong
)
real_op
();
case
STRING_RESULT
:
{
char
*
end_not_used
;
int
err_not_used
;
String
*
res
=
str_op
(
&
str_value
);
CHARSET_INFO
*
cs
=
str_value
.
charset
();
return
(
res
?
(
*
(
cs
->
cset
->
strtoll10
))(
cs
,
res
->
ptr
(),
&
end_not_used
,
&
err_not_used
)
:
0
);
}
default:
DBUG_ASSERT
(
0
);
}
...
...
@@ -893,6 +912,12 @@ my_decimal *Item_func_numhybrid::val_decimal(my_decimal *decimal_value)
break
;
}
case
STRING_RESULT
:
{
String
*
res
=
str_op
(
&
str_value
);
str2my_decimal
(
E_DEC_FATAL_ERROR
,
(
char
*
)
res
->
ptr
(),
res
->
length
(),
res
->
charset
(),
decimal_value
);
break
;
}
case
ROW_RESULT
:
default:
DBUG_ASSERT
(
0
);
...
...
sql/item_func.h
View file @
b4ed58bf
...
...
@@ -194,6 +194,9 @@ public:
Item_func_numhybrid
(
Item
*
a
,
Item
*
b
)
:
Item_func
(
a
,
b
),
hybrid_type
(
REAL_RESULT
)
{}
Item_func_numhybrid
(
List
<
Item
>
&
list
)
:
Item_func
(
list
),
hybrid_type
(
REAL_RESULT
)
{}
enum
Item_result
result_type
()
const
{
return
hybrid_type
;
}
void
fix_length_and_dec
();
...
...
@@ -208,6 +211,7 @@ public:
virtual
longlong
int_op
()
=
0
;
virtual
double
real_op
()
=
0
;
virtual
my_decimal
*
decimal_op
(
my_decimal
*
)
=
0
;
virtual
String
*
str_op
(
String
*
)
=
0
;
bool
is_null
()
{
(
void
)
val_real
();
return
null_value
;
}
};
...
...
@@ -220,6 +224,7 @@ public:
void
fix_num_length_and_dec
();
void
find_num_type
();
String
*
str_op
(
String
*
str
)
{
DBUG_ASSERT
(
0
);
return
0
;
}
};
...
...
@@ -231,6 +236,7 @@ class Item_num_op :public Item_func_numhybrid
virtual
void
result_precision
()
=
0
;
void
print
(
String
*
str
)
{
print_op
(
str
);
}
void
find_num_type
();
String
*
str_op
(
String
*
str
)
{
DBUG_ASSERT
(
0
);
return
0
;
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment