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
f385c603
Commit
f385c603
authored
May 18, 2009
by
Kristofer Pettersson
Browse files
Options
Browse Files
Download
Plain Diff
Automerge
parents
9c4eb291
9cc4cb0e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
55 additions
and
6 deletions
+55
-6
mysql-test/r/func_math.result
mysql-test/r/func_math.result
+19
-0
mysql-test/t/func_math.test
mysql-test/t/func_math.test
+18
-0
sql/item_func.cc
sql/item_func.cc
+15
-5
sql/item_func.h
sql/item_func.h
+3
-1
No files found.
mysql-test/r/func_math.result
View file @
f385c603
...
...
@@ -456,4 +456,23 @@ NULL
SELECT POW(10, 309);
POW(10, 309)
NULL
#
# Bug #44768: SIGFPE crash when selecting rand from a view
# containing null
#
CREATE OR REPLACE VIEW v1 AS SELECT NULL AS a;
SELECT RAND(a) FROM v1;
RAND(a)
0.155220427694936
DROP VIEW v1;
SELECT RAND(a) FROM (SELECT NULL AS a) b;
RAND(a)
0.155220427694936
CREATE TABLE t1 (i INT);
INSERT INTO t1 VALUES (NULL);
SELECT RAND(i) FROM t1;
RAND(i)
0.155220427694936
DROP TABLE t1;
#
End of 5.1 tests
mysql-test/t/func_math.test
View file @
f385c603
...
...
@@ -282,4 +282,22 @@ SELECT 1e300 / 1e-300;
SELECT
EXP
(
750
);
SELECT
POW
(
10
,
309
);
--
echo
#
--
echo
# Bug #44768: SIGFPE crash when selecting rand from a view
--
echo
# containing null
--
echo
#
CREATE
OR
REPLACE
VIEW
v1
AS
SELECT
NULL
AS
a
;
SELECT
RAND
(
a
)
FROM
v1
;
DROP
VIEW
v1
;
SELECT
RAND
(
a
)
FROM
(
SELECT
NULL
AS
a
)
b
;
CREATE
TABLE
t1
(
i
INT
);
INSERT
INTO
t1
VALUES
(
NULL
);
SELECT
RAND
(
i
)
FROM
t1
;
DROP
TABLE
t1
;
--
echo
#
--
echo
End
of
5.1
tests
sql/item_func.cc
View file @
f385c603
...
...
@@ -2143,9 +2143,6 @@ bool Item_func_rand::fix_fields(THD *thd,Item **ref)
if
(
!
rand
&&
!
(
rand
=
(
struct
rand_struct
*
)
thd
->
stmt_arena
->
alloc
(
sizeof
(
*
rand
))))
return
TRUE
;
if
(
args
[
0
]
->
const_item
())
seed_random
(
args
[
0
]);
}
else
{
...
...
@@ -2175,8 +2172,21 @@ void Item_func_rand::update_used_tables()
double
Item_func_rand
::
val_real
()
{
DBUG_ASSERT
(
fixed
==
1
);
if
(
arg_count
&&
!
args
[
0
]
->
const_item
())
seed_random
(
args
[
0
]);
if
(
arg_count
)
{
if
(
!
args
[
0
]
->
const_item
())
seed_random
(
args
[
0
]);
else
if
(
first_eval
)
{
/*
Constantness of args[0] may be set during JOIN::optimize(), if arg[0]
is a field item of "constant" table. Thus, we have to evaluate
seed_random() for constant arg there but not at the fix_fields method.
*/
first_eval
=
FALSE
;
seed_random
(
args
[
0
]);
}
}
return
my_rnd
(
rand
);
}
...
...
sql/item_func.h
View file @
f385c603
...
...
@@ -696,14 +696,16 @@ public:
class
Item_func_rand
:
public
Item_real_func
{
struct
rand_struct
*
rand
;
bool
first_eval
;
// TRUE if val_real() is called 1st time
public:
Item_func_rand
(
Item
*
a
)
:
Item_real_func
(
a
),
rand
(
0
)
{}
Item_func_rand
(
Item
*
a
)
:
Item_real_func
(
a
),
rand
(
0
)
,
first_eval
(
TRUE
)
{}
Item_func_rand
()
:
Item_real_func
()
{}
double
val_real
();
const
char
*
func_name
()
const
{
return
"rand"
;
}
bool
const_item
()
const
{
return
0
;
}
void
update_used_tables
();
bool
fix_fields
(
THD
*
thd
,
Item
**
ref
);
void
cleanup
()
{
first_eval
=
TRUE
;
Item_real_func
::
cleanup
();
}
private:
void
seed_random
(
Item
*
val
);
};
...
...
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