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
9fead4bd
Commit
9fead4bd
authored
Sep 05, 2007
by
dkatz@damien-katzs-computer.local
Browse files
Options
Browse Files
Download
Plain Diff
Merge damien-katzs-computer.local:/Users/dkatz/mysql50
into damien-katzs-computer.local:/Users/dkatz/50_udf_const
parents
f672f5dc
d8e67d45
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
1 deletion
+99
-1
mysql-test/r/udf.result
mysql-test/r/udf.result
+24
-0
mysql-test/t/udf.test
mysql-test/t/udf.test
+36
-0
sql/item_func.cc
sql/item_func.cc
+2
-1
sql/udf_example.c
sql/udf_example.c
+35
-0
sql/udf_example.def
sql/udf_example.def
+2
-0
No files found.
mysql-test/r/udf.result
View file @
9fead4bd
...
@@ -296,4 +296,28 @@ Qcache_queries_in_cache 0
...
@@ -296,4 +296,28 @@ Qcache_queries_in_cache 0
drop table t1;
drop table t1;
drop function metaphon;
drop function metaphon;
set GLOBAL query_cache_size=default;
set GLOBAL query_cache_size=default;
CREATE TABLE const_len_bug (
str_const varchar(4000),
result1 varchar(4000),
result2 varchar(4000)
);
CREATE TRIGGER check_const_len_trigger BEFORE INSERT ON const_len_bug FOR EACH ROW BEGIN
set NEW.str_const = 'bar';
set NEW.result2 = check_const_len(NEW.str_const);
END |
CREATE PROCEDURE check_const_len_sp (IN str_const VARCHAR(4000))
BEGIN
DECLARE result VARCHAR(4000);
SET result = check_const_len(str_const);
insert into const_len_bug values(str_const, result, "");
END |
CREATE FUNCTION check_const_len RETURNS string SONAME "UDF_EXAMPLE_LIB";
CALL check_const_len_sp("foo");
SELECT * from const_len_bug;
str_const result1 result2
bar Correct length Correct length
DROP FUNCTION check_const_len;
DROP PROCEDURE check_const_len_sp;
DROP TRIGGER check_const_len_trigger;
DROP TABLE const_len_bug;
End of 5.0 tests.
End of 5.0 tests.
mysql-test/t/udf.test
View file @
9fead4bd
...
@@ -312,4 +312,40 @@ drop function metaphon;
...
@@ -312,4 +312,40 @@ drop function metaphon;
set
GLOBAL
query_cache_size
=
default
;
set
GLOBAL
query_cache_size
=
default
;
#
# Bug #29804 UDF parameters don't contain correct string length
#
CREATE
TABLE
const_len_bug
(
str_const
varchar
(
4000
),
result1
varchar
(
4000
),
result2
varchar
(
4000
)
);
DELIMITER
|
;
CREATE
TRIGGER
check_const_len_trigger
BEFORE
INSERT
ON
const_len_bug
FOR
EACH
ROW
BEGIN
set
NEW
.
str_const
=
'bar'
;
set
NEW
.
result2
=
check_const_len
(
NEW
.
str_const
);
END
|
CREATE
PROCEDURE
check_const_len_sp
(
IN
str_const
VARCHAR
(
4000
))
BEGIN
DECLARE
result
VARCHAR
(
4000
);
SET
result
=
check_const_len
(
str_const
);
insert
into
const_len_bug
values
(
str_const
,
result
,
""
);
END
|
DELIMITER
;
|
--
replace_result
$UDF_EXAMPLE_LIB
UDF_EXAMPLE_LIB
eval
CREATE
FUNCTION
check_const_len
RETURNS
string
SONAME
"
$UDF_EXAMPLE_LIB
"
;
CALL
check_const_len_sp
(
"foo"
);
SELECT
*
from
const_len_bug
;
DROP
FUNCTION
check_const_len
;
DROP
PROCEDURE
check_const_len_sp
;
DROP
TRIGGER
check_const_len_trigger
;
DROP
TABLE
const_len_bug
;
--
echo
End
of
5.0
tests
.
--
echo
End
of
5.0
tests
.
sql/item_func.cc
View file @
9fead4bd
...
@@ -2924,7 +2924,8 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func,
...
@@ -2924,7 +2924,8 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func,
String
*
res
=
arguments
[
i
]
->
val_str
(
&
buffers
[
i
]);
String
*
res
=
arguments
[
i
]
->
val_str
(
&
buffers
[
i
]);
if
(
arguments
[
i
]
->
null_value
)
if
(
arguments
[
i
]
->
null_value
)
continue
;
continue
;
f_args
.
args
[
i
]
=
(
char
*
)
res
->
ptr
();
f_args
.
args
[
i
]
=
(
char
*
)
res
->
c_ptr
();
f_args
.
lengths
[
i
]
=
res
->
length
();
break
;
break
;
}
}
case
INT_RESULT
:
case
INT_RESULT
:
...
...
sql/udf_example.c
View file @
9fead4bd
...
@@ -1106,4 +1106,39 @@ char * is_const(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)),
...
@@ -1106,4 +1106,39 @@ char * is_const(UDF_INIT *initid, UDF_ARGS *args __attribute__((unused)),
}
}
my_bool
check_const_len_init
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
,
char
*
message
)
{
if
(
args
->
arg_count
!=
1
)
{
strmov
(
message
,
"CHECK_CONST_LEN accepts only one argument"
);
return
1
;
}
if
(
args
->
args
[
0
]
==
0
)
{
initid
->
ptr
=
(
char
*
)
"Not constant"
;
}
else
if
(
strlen
(
args
->
args
[
0
])
==
args
->
lengths
[
0
])
{
initid
->
ptr
=
(
char
*
)
"Correct length"
;
}
else
{
initid
->
ptr
=
(
char
*
)
"Wrong length"
;
}
initid
->
max_length
=
100
;
return
0
;
}
char
*
check_const_len
(
UDF_INIT
*
initid
,
UDF_ARGS
*
args
__attribute__
((
unused
)),
char
*
result
,
unsigned
long
*
length
,
char
*
is_null
,
char
*
error
__attribute__
((
unused
)))
{
strmov
(
result
,
initid
->
ptr
);
*
length
=
strlen
(
result
);
*
is_null
=
0
;
return
result
;
}
#endif
/* HAVE_DLOPEN */
#endif
/* HAVE_DLOPEN */
sql/udf_example.def
View file @
9fead4bd
...
@@ -23,3 +23,5 @@ EXPORTS
...
@@ -23,3 +23,5 @@ EXPORTS
avgcost
avgcost
is_const
is_const
is_const_init
is_const_init
check_const_len
check_const_len_init
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