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
0a84eb5f
Commit
0a84eb5f
authored
Jul 26, 2006
by
evgen@moonbone.local
Browse files
Options
Browse Files
Download
Plain Diff
Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt
into moonbone.local:/work/19862-bug-5.0-opt-mysql
parents
88e6b910
4ee2e07c
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
81 additions
and
1 deletion
+81
-1
mysql-test/r/sp.result
mysql-test/r/sp.result
+19
-0
mysql-test/r/udf.result
mysql-test/r/udf.result
+6
-0
mysql-test/t/sp.test
mysql-test/t/sp.test
+18
-0
mysql-test/t/udf.test
mysql-test/t/udf.test
+7
-0
sql/item.h
sql/item.h
+1
-0
sql/item_func.cc
sql/item_func.cc
+7
-0
sql/item_func.h
sql/item_func.h
+3
-1
sql/sql_select.cc
sql/sql_select.cc
+20
-0
No files found.
mysql-test/r/sp.result
View file @
0a84eb5f
...
...
@@ -5057,4 +5057,23 @@ concat('data was: /', var1, '/')
data was: /1/
drop table t3|
drop procedure bug15217|
drop procedure if exists bug19862|
CREATE TABLE t11 (a INT)|
CREATE TABLE t12 (a INT)|
CREATE FUNCTION bug19862(x INT) RETURNS INT
BEGIN
INSERT INTO t11 VALUES (x);
RETURN x+1;
END|
INSERT INTO t12 VALUES (1), (2)|
SELECT bug19862(a) FROM t12 ORDER BY 1|
bug19862(a)
2
3
SELECT * FROM t11|
a
1
2
DROP TABLE t11, t12|
DROP FUNCTION bug19862|
drop table t1,t2;
mysql-test/r/udf.result
View file @
0a84eb5f
...
...
@@ -93,6 +93,12 @@ NULL
0R
FR
DROP TABLE bug19904;
create table t1(f1 int);
insert into t1 values(1),(2);
explain select myfunc_int(f1) from t1 order by 1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 2 Using temporary; Using filesort
drop table t1;
End of 5.0 tests.
DROP FUNCTION metaphon;
DROP FUNCTION myfunc_double;
...
...
mysql-test/t/sp.test
View file @
0a84eb5f
...
...
@@ -5962,6 +5962,24 @@ call bug15217()|
drop
table
t3
|
drop
procedure
bug15217
|
#
# BUG#19862: Sort with filesort by function evaluates function twice
#
--
disable_warnings
drop
procedure
if
exists
bug19862
|
--
enable_warnings
CREATE
TABLE
t11
(
a
INT
)
|
CREATE
TABLE
t12
(
a
INT
)
|
CREATE
FUNCTION
bug19862
(
x
INT
)
RETURNS
INT
BEGIN
INSERT
INTO
t11
VALUES
(
x
);
RETURN
x
+
1
;
END
|
INSERT
INTO
t12
VALUES
(
1
),
(
2
)
|
SELECT
bug19862
(
a
)
FROM
t12
ORDER
BY
1
|
SELECT
*
FROM
t11
|
DROP
TABLE
t11
,
t12
|
DROP
FUNCTION
bug19862
|
#
# BUG#NNNN: New bug synopsis
#
...
...
mysql-test/t/udf.test
View file @
0a84eb5f
...
...
@@ -109,6 +109,13 @@ SELECT myfunc_double(n) AS f FROM bug19904;
SELECT
metaphon
(
v
)
AS
f
FROM
bug19904
;
DROP
TABLE
bug19904
;
#
# Bug#19862: Sort with filesort by function evaluates function twice
#
create
table
t1
(
f1
int
);
insert
into
t1
values
(
1
),(
2
);
explain
select
myfunc_int
(
f1
)
from
t1
order
by
1
;
drop
table
t1
;
--
echo
End
of
5.0
tests
.
#
...
...
sql/item.h
View file @
0a84eb5f
...
...
@@ -752,6 +752,7 @@ public:
virtual
bool
find_item_in_field_list_processor
(
byte
*
arg
)
{
return
0
;
}
virtual
bool
change_context_processor
(
byte
*
context
)
{
return
0
;
}
virtual
bool
reset_query_id_processor
(
byte
*
query_id
)
{
return
0
;
}
virtual
bool
func_type_checker_processor
(
byte
*
arg
)
{
return
0
;
}
virtual
Item
*
equal_fields_propagator
(
byte
*
arg
)
{
return
this
;
}
virtual
Item
*
set_no_const_sub
(
byte
*
arg
)
{
return
this
;
}
...
...
sql/item_func.cc
View file @
0a84eb5f
...
...
@@ -398,6 +398,13 @@ Field *Item_func::tmp_table_field(TABLE *t_arg)
return
res
;
}
bool
Item_func
::
func_type_checker_processor
(
byte
*
arg
)
{
return
*
((
Functype
*
)
arg
)
==
functype
();
}
my_decimal
*
Item_func
::
val_decimal
(
my_decimal
*
decimal_value
)
{
DBUG_ASSERT
(
fixed
);
...
...
sql/item_func.h
View file @
0a84eb5f
...
...
@@ -55,7 +55,7 @@ public:
NOT_FUNC
,
NOT_ALL_FUNC
,
NOW_FUNC
,
TRIG_COND_FUNC
,
GUSERVAR_FUNC
,
COLLATE_FUNC
,
EXTRACT_FUNC
,
CHAR_TYPECAST_FUNC
,
FUNC_SP
};
EXTRACT_FUNC
,
CHAR_TYPECAST_FUNC
,
FUNC_SP
,
UDF_FUNC
};
enum
optimize_type
{
OPTIMIZE_NONE
,
OPTIMIZE_KEY
,
OPTIMIZE_OP
,
OPTIMIZE_NULL
,
OPTIMIZE_EQUAL
};
enum
Type
type
()
const
{
return
FUNC_ITEM
;
}
...
...
@@ -189,6 +189,7 @@ public:
Item
*
transform
(
Item_transformer
transformer
,
byte
*
arg
);
void
traverse_cond
(
Cond_traverser
traverser
,
void
*
arg
,
traverse_order
order
);
bool
func_type_checker_processor
(
byte
*
arg
);
};
...
...
@@ -933,6 +934,7 @@ public:
Item_udf_func
(
udf_func
*
udf_arg
,
List
<
Item
>
&
list
)
:
Item_func
(
list
),
udf
(
udf_arg
)
{}
const
char
*
func_name
()
const
{
return
udf
.
name
();
}
enum
Functype
functype
()
const
{
return
UDF_FUNC
;
}
bool
fix_fields
(
THD
*
thd
,
Item
**
ref
)
{
DBUG_ASSERT
(
fixed
==
0
);
...
...
sql/sql_select.cc
View file @
0a84eb5f
...
...
@@ -1064,6 +1064,26 @@ JOIN::optimize()
{
need_tmp
=
1
;
simple_order
=
simple_group
=
0
;
// Force tmp table without sort
}
if
(
order
)
{
/*
Force using of tmp table if sorting by a SP or UDF function due to
their expensive and probably non-deterministic nature.
*/
for
(
ORDER
*
tmp_order
=
order
;
tmp_order
;
tmp_order
=
tmp_order
->
next
)
{
Item
*
item
=
*
tmp_order
->
item
;
Item_func
::
Functype
type
=
Item_func
::
FUNC_SP
;
Item_func
::
Functype
type1
=
Item_func
::
UDF_FUNC
;
if
(
item
->
walk
(
&
Item
::
func_type_checker_processor
,(
byte
*
)
&
type
)
||
item
->
walk
(
&
Item
::
func_type_checker_processor
,(
byte
*
)
&
type1
))
{
/* Force tmp table without sort */
need_tmp
=
1
;
simple_order
=
simple_group
=
0
;
break
;
}
}
}
}
tmp_having
=
having
;
...
...
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