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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nexedi
MariaDB
Commits
aa582ded
Commit
aa582ded
authored
Sep 30, 2017
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-13966 Parameter data type control for Item_temporal_func
parent
ca38b93e
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
210 additions
and
0 deletions
+210
-0
mysql-test/r/func_time.result
mysql-test/r/func_time.result
+31
-0
mysql-test/r/gis.result
mysql-test/r/gis.result
+31
-0
mysql-test/t/func_time.test
mysql-test/t/func_time.test
+41
-0
mysql-test/t/gis.test
mysql-test/t/gis.test
+41
-0
sql/item.cc
sql/item.cc
+22
-0
sql/item.h
sql/item.h
+2
-0
sql/item_func.cc
sql/item_func.cc
+13
-0
sql/item_func.h
sql/item_func.h
+1
-0
sql/item_timefunc.h
sql/item_timefunc.h
+22
-0
sql/sql_type.h
sql/sql_type.h
+6
-0
No files found.
mysql-test/r/func_time.result
View file @
aa582ded
...
...
@@ -3294,3 +3294,34 @@ t1 CREATE TABLE `t1` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
DROP TABLE t1;
SET sql_mode=DEFAULT;
#
# MDEV-13966 Parameter data type control for Item_temporal_func
#
SELECT FROM_DAYS(ROW(1,1));
ERROR HY000: Illegal parameter data type row for operation 'from_days'
SELECT MAKEDATE(ROW(1,1),1);
ERROR HY000: Illegal parameter data type row for operation 'makedate'
SELECT MAKEDATE(1, ROW(1,1));
ERROR HY000: Illegal parameter data type row for operation 'makedate'
SELECT LAST_DAY(ROW(1,1));
ERROR HY000: Illegal parameter data type row for operation 'last_day'
SELECT SEC_TO_TIME(ROW(1,1));
ERROR HY000: Illegal parameter data type row for operation 'sec_to_time'
SELECT TIMEDIFF(ROW(1,1),1);
ERROR HY000: Illegal parameter data type row for operation 'timediff'
SELECT TIMEDIFF(1, ROW(1,1));
ERROR HY000: Illegal parameter data type row for operation 'timediff'
SELECT MAKETIME(ROW(1,1),1,1);
ERROR HY000: Illegal parameter data type row for operation 'maketime'
SELECT MAKETIME(1, ROW(1,1), 1);
ERROR HY000: Illegal parameter data type row for operation 'maketime'
SELECT MAKETIME(1, 1, ROW(1,1));
ERROR HY000: Illegal parameter data type row for operation 'maketime'
SELECT FROM_UNIXTIME(ROW(1,1));
ERROR HY000: Illegal parameter data type row for operation 'from_unixtime'
SELECT CONVERT_TZ(ROW(1,1),1,1);
ERROR HY000: Illegal parameter data type row for operation 'convert_tz'
SELECT CONVERT_TZ(1, ROW(1,1), 1);
ERROR HY000: Illegal parameter data type row for operation 'convert_tz'
SELECT CONVERT_TZ(1, 1, ROW(1,1));
ERROR HY000: Illegal parameter data type row for operation 'convert_tz'
mysql-test/r/gis.result
View file @
aa582ded
...
...
@@ -4786,5 +4786,36 @@ ERROR HY000: Illegal parameter data type geometry for operation 'inet_aton'
SELECT LAST_INSERT_ID(POINT(1,1));
ERROR HY000: Illegal parameter data type geometry for operation 'last_insert_id'
#
# MDEV-13966 Parameter data type control for Item_temporal_func
#
SELECT FROM_DAYS(POINT(1,1));
ERROR HY000: Illegal parameter data type geometry for operation 'from_days'
SELECT MAKEDATE(POINT(1,1),1);
ERROR HY000: Illegal parameter data type geometry for operation 'makedate'
SELECT MAKEDATE(1, POINT(1,1));
ERROR HY000: Illegal parameter data type geometry for operation 'makedate'
SELECT LAST_DAY(POINT(1,1));
ERROR HY000: Illegal parameter data type geometry for operation 'last_day'
SELECT SEC_TO_TIME(POINT(1,1));
ERROR HY000: Illegal parameter data type geometry for operation 'sec_to_time'
SELECT TIMEDIFF(POINT(1,1),1);
ERROR HY000: Illegal parameter data type geometry for operation 'timediff'
SELECT TIMEDIFF(1, POINT(1,1));
ERROR HY000: Illegal parameter data type geometry for operation 'timediff'
SELECT MAKETIME(POINT(1,1),1,1);
ERROR HY000: Illegal parameter data type geometry for operation 'maketime'
SELECT MAKETIME(1, POINT(1,1), 1);
ERROR HY000: Illegal parameter data type geometry for operation 'maketime'
SELECT MAKETIME(1, 1, POINT(1,1));
ERROR HY000: Illegal parameter data type geometry for operation 'maketime'
SELECT FROM_UNIXTIME(POINT(1,1));
ERROR HY000: Illegal parameter data type geometry for operation 'from_unixtime'
SELECT CONVERT_TZ(POINT(1,1),1,1);
ERROR HY000: Illegal parameter data type geometry for operation 'convert_tz'
SELECT CONVERT_TZ(1, POINT(1,1), 1);
ERROR HY000: Illegal parameter data type geometry for operation 'convert_tz'
SELECT CONVERT_TZ(1, 1, POINT(1,1));
ERROR HY000: Illegal parameter data type geometry for operation 'convert_tz'
#
# End of 10.3 tests
#
mysql-test/t/func_time.test
View file @
aa582ded
...
...
@@ -1880,3 +1880,44 @@ CREATE TABLE t1 AS SELECT TO_SECONDS('9999-12-31 23:59:59');
SHOW
CREATE
TABLE
t1
;
DROP
TABLE
t1
;
SET
sql_mode
=
DEFAULT
;
--
echo
#
--
echo
# MDEV-13966 Parameter data type control for Item_temporal_func
--
echo
#
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
FROM_DAYS
(
ROW
(
1
,
1
));
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
MAKEDATE
(
ROW
(
1
,
1
),
1
);
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
MAKEDATE
(
1
,
ROW
(
1
,
1
));
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
LAST_DAY
(
ROW
(
1
,
1
));
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
SEC_TO_TIME
(
ROW
(
1
,
1
));
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
TIMEDIFF
(
ROW
(
1
,
1
),
1
);
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
TIMEDIFF
(
1
,
ROW
(
1
,
1
));
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
MAKETIME
(
ROW
(
1
,
1
),
1
,
1
);
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
MAKETIME
(
1
,
ROW
(
1
,
1
),
1
);
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
MAKETIME
(
1
,
1
,
ROW
(
1
,
1
));
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
FROM_UNIXTIME
(
ROW
(
1
,
1
));
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
CONVERT_TZ
(
ROW
(
1
,
1
),
1
,
1
);
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
CONVERT_TZ
(
1
,
ROW
(
1
,
1
),
1
);
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
CONVERT_TZ
(
1
,
1
,
ROW
(
1
,
1
));
mysql-test/t/gis.test
View file @
aa582ded
...
...
@@ -2836,6 +2836,47 @@ SELECT INET_ATON(POINT(1,1));
SELECT
LAST_INSERT_ID
(
POINT
(
1
,
1
));
--
echo
#
--
echo
# MDEV-13966 Parameter data type control for Item_temporal_func
--
echo
#
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
FROM_DAYS
(
POINT
(
1
,
1
));
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
MAKEDATE
(
POINT
(
1
,
1
),
1
);
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
MAKEDATE
(
1
,
POINT
(
1
,
1
));
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
LAST_DAY
(
POINT
(
1
,
1
));
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
SEC_TO_TIME
(
POINT
(
1
,
1
));
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
TIMEDIFF
(
POINT
(
1
,
1
),
1
);
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
TIMEDIFF
(
1
,
POINT
(
1
,
1
));
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
MAKETIME
(
POINT
(
1
,
1
),
1
,
1
);
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
MAKETIME
(
1
,
POINT
(
1
,
1
),
1
);
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
MAKETIME
(
1
,
1
,
POINT
(
1
,
1
));
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
FROM_UNIXTIME
(
POINT
(
1
,
1
));
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
CONVERT_TZ
(
POINT
(
1
,
1
),
1
,
1
);
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
CONVERT_TZ
(
1
,
POINT
(
1
,
1
),
1
);
--
error
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
SELECT
CONVERT_TZ
(
1
,
1
,
POINT
(
1
,
1
));
--
echo
#
--
echo
# End of 10.3 tests
--
echo
#
sql/item.cc
View file @
aa582ded
...
...
@@ -1069,6 +1069,17 @@ bool Item::check_type_can_return_int(const char *opname) const
}
bool
Item
::
check_type_can_return_decimal
(
const
char
*
opname
)
const
{
const
Type_handler
*
handler
=
type_handler
();
if
(
handler
->
can_return_decimal
())
return
false
;
my_error
(
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
,
MYF
(
0
),
handler
->
name
().
ptr
(),
opname
);
return
true
;
}
bool
Item
::
check_type_can_return_real
(
const
char
*
opname
)
const
{
const
Type_handler
*
handler
=
type_handler
();
...
...
@@ -1091,6 +1102,17 @@ bool Item::check_type_can_return_date(const char *opname) const
}
bool
Item
::
check_type_can_return_time
(
const
char
*
opname
)
const
{
const
Type_handler
*
handler
=
type_handler
();
if
(
handler
->
can_return_time
())
return
false
;
my_error
(
ER_ILLEGAL_PARAMETER_DATA_TYPE_FOR_OPERATION
,
MYF
(
0
),
handler
->
name
().
ptr
(),
opname
);
return
true
;
}
bool
Item
::
check_type_can_return_str_ascii
(
const
char
*
opname
)
const
{
const
Type_handler
*
handler
=
type_handler
();
...
...
sql/item.h
View file @
aa582ded
...
...
@@ -1710,9 +1710,11 @@ class Item: public Value_source,
bool
check_type_or_binary
(
const
char
*
opname
,
const
Type_handler
*
handler
)
const
;
bool
check_type_general_purpose_string
(
const
char
*
opname
)
const
;
bool
check_type_can_return_int
(
const
char
*
opname
)
const
;
bool
check_type_can_return_decimal
(
const
char
*
opname
)
const
;
bool
check_type_can_return_real
(
const
char
*
opname
)
const
;
bool
check_type_can_return_str_ascii
(
const
char
*
opname
)
const
;
bool
check_type_can_return_date
(
const
char
*
opname
)
const
;
bool
check_type_can_return_time
(
const
char
*
opname
)
const
;
// It is not row => null inside is impossible
virtual
bool
null_inside
()
{
return
0
;
}
// used in row subselects to get value of elements
...
...
sql/item_func.cc
View file @
aa582ded
...
...
@@ -244,6 +244,19 @@ bool Item_func::check_argument_types_can_return_date(uint start,
}
bool
Item_func
::
check_argument_types_can_return_time
(
uint
start
,
uint
end
)
const
{
for
(
uint
i
=
start
;
i
<
end
;
i
++
)
{
DBUG_ASSERT
(
i
<
arg_count
);
if
(
args
[
i
]
->
check_type_can_return_time
(
func_name
()))
return
true
;
}
return
false
;
}
bool
Item_func
::
check_argument_types_scalar
(
uint
start
,
uint
end
)
const
{
for
(
uint
i
=
start
;
i
<
end
;
i
++
)
...
...
sql/item_func.h
View file @
aa582ded
...
...
@@ -50,6 +50,7 @@ class Item_func :public Item_func_or_sum
bool
check_argument_types_can_return_real
(
uint
start
,
uint
end
)
const
;
bool
check_argument_types_can_return_str_ascii
(
uint
start
,
uint
end
)
const
;
bool
check_argument_types_can_return_date
(
uint
start
,
uint
end
)
const
;
bool
check_argument_types_can_return_time
(
uint
start
,
uint
end
)
const
;
public:
table_map
not_null_tables_cache
;
...
...
sql/item_timefunc.h
View file @
aa582ded
...
...
@@ -782,6 +782,8 @@ class Item_func_sysdate_local :public Item_func_now
class
Item_func_from_days
:
public
Item_datefunc
{
bool
check_arguments
()
const
{
return
args
[
0
]
->
check_type_can_return_int
(
func_name
());
}
public:
Item_func_from_days
(
THD
*
thd
,
Item
*
a
)
:
Item_datefunc
(
thd
,
a
)
{}
const
char
*
func_name
()
const
{
return
"from_days"
;
}
...
...
@@ -838,6 +840,8 @@ class Item_func_time_format: public Item_func_date_format
class
Item_func_from_unixtime
:
public
Item_datetimefunc
{
bool
check_arguments
()
const
{
return
args
[
0
]
->
check_type_can_return_decimal
(
func_name
());
}
Time_zone
*
tz
;
public:
Item_func_from_unixtime
(
THD
*
thd
,
Item
*
a
)
:
Item_datetimefunc
(
thd
,
a
)
{}
...
...
@@ -865,6 +869,11 @@ class Time_zone;
*/
class
Item_func_convert_tz
:
public
Item_datetimefunc
{
bool
check_arguments
()
const
{
return
args
[
0
]
->
check_type_can_return_date
(
func_name
())
||
check_argument_types_can_return_str_ascii
(
1
,
arg_count
);
}
/*
If time zone parameters are constants we are caching objects that
represent them (we use separate from_tz_cached/to_tz_cached members
...
...
@@ -891,6 +900,8 @@ class Item_func_convert_tz :public Item_datetimefunc
class
Item_func_sec_to_time
:
public
Item_timefunc
{
bool
check_arguments
()
const
{
return
args
[
0
]
->
check_type_can_return_decimal
(
func_name
());
}
public:
Item_func_sec_to_time
(
THD
*
thd
,
Item
*
item
)
:
Item_timefunc
(
thd
,
item
)
{}
bool
get_date
(
MYSQL_TIME
*
res
,
ulonglong
fuzzy_date
);
...
...
@@ -1130,6 +1141,8 @@ class Item_datetime_typecast :public Item_temporal_typecast
class
Item_func_makedate
:
public
Item_datefunc
{
bool
check_arguments
()
const
{
return
check_argument_types_can_return_int
(
0
,
arg_count
);
}
public:
Item_func_makedate
(
THD
*
thd
,
Item
*
a
,
Item
*
b
)
:
Item_datefunc
(
thd
,
a
,
b
)
{}
...
...
@@ -1159,6 +1172,8 @@ class Item_func_add_time :public Item_temporal_hybrid_func
class
Item_func_timediff
:
public
Item_timefunc
{
bool
check_arguments
()
const
{
return
check_argument_types_can_return_time
(
0
,
arg_count
);
}
public:
Item_func_timediff
(
THD
*
thd
,
Item
*
a
,
Item
*
b
)
:
Item_timefunc
(
thd
,
a
,
b
)
{}
const
char
*
func_name
()
const
{
return
"timediff"
;
}
...
...
@@ -1175,6 +1190,11 @@ class Item_func_timediff :public Item_timefunc
class
Item_func_maketime
:
public
Item_timefunc
{
bool
check_arguments
()
const
{
return
check_argument_types_can_return_int
(
0
,
2
)
||
args
[
2
]
->
check_type_can_return_decimal
(
func_name
());
}
public:
Item_func_maketime
(
THD
*
thd
,
Item
*
a
,
Item
*
b
,
Item
*
c
)
:
Item_timefunc
(
thd
,
a
,
b
,
c
)
...
...
@@ -1283,6 +1303,8 @@ class Item_func_str_to_date :public Item_temporal_hybrid_func
class
Item_func_last_day
:
public
Item_datefunc
{
bool
check_arguments
()
const
{
return
args
[
0
]
->
check_type_can_return_date
(
func_name
());
}
public:
Item_func_last_day
(
THD
*
thd
,
Item
*
a
)
:
Item_datefunc
(
thd
,
a
)
{}
const
char
*
func_name
()
const
{
return
"last_day"
;
}
...
...
sql/sql_type.h
View file @
aa582ded
...
...
@@ -704,9 +704,11 @@ class Type_handler
}
virtual
bool
is_scalar_type
()
const
{
return
true
;
}
virtual
bool
can_return_int
()
const
{
return
true
;
}
virtual
bool
can_return_decimal
()
const
{
return
true
;
}
virtual
bool
can_return_real
()
const
{
return
true
;
}
virtual
bool
can_return_str_ascii
()
const
{
return
true
;
}
virtual
bool
can_return_date
()
const
{
return
true
;
}
virtual
bool
can_return_time
()
const
{
return
true
;
}
virtual
bool
is_general_purpose_string_type
()
const
{
return
false
;
}
virtual
uint
Item_time_precision
(
Item
*
item
)
const
;
virtual
uint
Item_datetime_precision
(
Item
*
item
)
const
;
...
...
@@ -1003,9 +1005,11 @@ class Type_handler_row: public Type_handler
const
Name
name
()
const
{
return
m_name_row
;
}
bool
is_scalar_type
()
const
{
return
false
;
}
bool
can_return_int
()
const
{
return
false
;
}
bool
can_return_decimal
()
const
{
return
false
;
}
bool
can_return_real
()
const
{
return
false
;
}
bool
can_return_str_ascii
()
const
{
return
false
;
}
bool
can_return_date
()
const
{
return
false
;
}
bool
can_return_time
()
const
{
return
false
;
}
enum_field_types
field_type
()
const
{
DBUG_ASSERT
(
0
);
...
...
@@ -2677,9 +2681,11 @@ class Type_handler_geometry: public Type_handler_string_result
TABLE
*
table
)
const
;
bool
can_return_int
()
const
{
return
false
;
}
bool
can_return_decimal
()
const
{
return
false
;
}
bool
can_return_real
()
const
{
return
false
;
}
bool
can_return_str_ascii
()
const
{
return
false
;
}
bool
can_return_date
()
const
{
return
false
;
}
bool
can_return_time
()
const
{
return
false
;
}
bool
is_traditional_type
()
const
{
return
false
;
...
...
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