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
b1ae4e7e
Commit
b1ae4e7e
authored
Jul 31, 2018
by
Alexander Barkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MDEV-16864 Implement class Item_func_timestamp
parent
2bbee0e1
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
50 additions
and
40 deletions
+50
-40
mysql-test/main/gis.result
mysql-test/main/gis.result
+6
-6
sql/item_create.cc
sql/item_create.cc
+2
-2
sql/item_timefunc.cc
sql/item_timefunc.cc
+1
-23
sql/item_timefunc.h
sql/item_timefunc.h
+39
-7
sql/sql_yacc.yy
sql/sql_yacc.yy
+1
-1
sql/sql_yacc_ora.yy
sql/sql_yacc_ora.yy
+1
-1
No files found.
mysql-test/main/gis.result
View file @
b1ae4e7e
...
...
@@ -4128,17 +4128,17 @@ ERROR HY000: Illegal parameter data types geometry and interval for operation 'd
SELECT INTERVAL 10 DAY + POINT(1,1);
ERROR HY000: Illegal parameter data types geometry and interval for operation 'date_add_interval'
SELECT ADDTIME(POINT(1,1), '10:10:10');
ERROR HY000: Illegal parameter data types geometry and varchar for operation 'add
_
time'
ERROR HY000: Illegal parameter data types geometry and varchar for operation 'addtime'
SELECT ADDTIME('10:10:10', POINT(1,1));
ERROR HY000: Illegal parameter data types varchar and geometry for operation 'add
_
time'
ERROR HY000: Illegal parameter data types varchar and geometry for operation 'addtime'
SELECT ADDTIME(POINT(1,1), TIME'10:10:10');
ERROR HY000: Illegal parameter data types geometry and time for operation 'add
_
time'
ERROR HY000: Illegal parameter data types geometry and time for operation 'addtime'
SELECT ADDTIME(TIME'10:10:10', POINT(1,1));
ERROR HY000: Illegal parameter data types time and geometry for operation 'add
_
time'
ERROR HY000: Illegal parameter data types time and geometry for operation 'addtime'
SELECT ADDTIME(POINT(1,1), TIMESTAMP'2001-01-01 10:10:10');
ERROR HY000: Illegal parameter data types geometry and datetime for operation 'add
_
time'
ERROR HY000: Illegal parameter data types geometry and datetime for operation 'addtime'
SELECT ADDTIME(TIMESTAMP'2001-01-01 10:10:10', POINT(1,1));
ERROR HY000: Illegal parameter data types datetime and geometry for operation 'add
_
time'
ERROR HY000: Illegal parameter data types datetime and geometry for operation 'addtime'
SELECT STR_TO_DATE(POINT(1,1),'%M %d,%Y');
ERROR HY000: Illegal parameter data types geometry and varchar for operation 'str_to_date'
SELECT STR_TO_DATE('2001-01-01', POINT(1,1));
...
...
sql/item_create.cc
View file @
b1ae4e7e
...
...
@@ -3636,7 +3636,7 @@ Create_func_addtime Create_func_addtime::s_singleton;
Item
*
Create_func_addtime
::
create_2_arg
(
THD
*
thd
,
Item
*
arg1
,
Item
*
arg2
)
{
return
new
(
thd
->
mem_root
)
Item_func_add_time
(
thd
,
arg1
,
arg2
,
0
,
0
);
return
new
(
thd
->
mem_root
)
Item_func_add_time
(
thd
,
arg1
,
arg2
,
false
);
}
...
...
@@ -6657,7 +6657,7 @@ Create_func_subtime Create_func_subtime::s_singleton;
Item
*
Create_func_subtime
::
create_2_arg
(
THD
*
thd
,
Item
*
arg1
,
Item
*
arg2
)
{
return
new
(
thd
->
mem_root
)
Item_func_add_time
(
thd
,
arg1
,
arg2
,
0
,
1
);
return
new
(
thd
->
mem_root
)
Item_func_add_time
(
thd
,
arg1
,
arg2
,
true
);
}
...
...
sql/item_timefunc.cc
View file @
b1ae4e7e
...
...
@@ -2698,8 +2698,7 @@ bool Item_func_add_time::fix_length_and_dec()
arg0_field_type
=
args
[
0
]
->
field_type
();
if
(
arg0_field_type
==
MYSQL_TYPE_DATE
||
arg0_field_type
==
MYSQL_TYPE_DATETIME
||
arg0_field_type
==
MYSQL_TYPE_TIMESTAMP
||
is_date
)
arg0_field_type
==
MYSQL_TYPE_TIMESTAMP
)
{
uint
dec
=
MY_MAX
(
args
[
0
]
->
datetime_precision
(),
args
[
1
]
->
time_precision
());
set_handler
(
&
type_handler_datetime2
);
...
...
@@ -2767,27 +2766,6 @@ bool Item_func_add_time::get_date(MYSQL_TIME *ltime, ulonglong fuzzy_date)
}
void
Item_func_add_time
::
print
(
String
*
str
,
enum_query_type
query_type
)
{
if
(
is_date
)
{
DBUG_ASSERT
(
sign
>
0
);
str
->
append
(
STRING_WITH_LEN
(
"timestamp("
));
}
else
{
if
(
sign
>
0
)
str
->
append
(
STRING_WITH_LEN
(
"addtime("
));
else
str
->
append
(
STRING_WITH_LEN
(
"subtime("
));
}
args
[
0
]
->
print
(
str
,
query_type
);
str
->
append
(
','
);
args
[
1
]
->
print
(
str
,
query_type
);
str
->
append
(
')'
);
}
/**
TIMEDIFF(t,s) is a time function that calculates the
time value between a start and end time.
...
...
sql/item_timefunc.h
View file @
b1ae4e7e
...
...
@@ -667,6 +667,8 @@ class Item_datetimefunc :public Item_temporal_func
public:
Item_datetimefunc
(
THD
*
thd
)
:
Item_temporal_func
(
thd
)
{}
Item_datetimefunc
(
THD
*
thd
,
Item
*
a
)
:
Item_temporal_func
(
thd
,
a
)
{}
Item_datetimefunc
(
THD
*
thd
,
Item
*
a
,
Item
*
b
)
:
Item_temporal_func
(
thd
,
a
,
b
)
{}
Item_datetimefunc
(
THD
*
thd
,
Item
*
a
,
Item
*
b
,
Item
*
c
)
:
Item_temporal_func
(
thd
,
a
,
b
,
c
)
{}
const
Type_handler
*
type_handler
()
const
{
return
&
type_handler_datetime2
;
}
...
...
@@ -1229,19 +1231,49 @@ class Item_func_makedate :public Item_datefunc
};
class
Item_func_timestamp
:
public
Item_datetimefunc
{
bool
check_arguments
()
const
{
return
args
[
0
]
->
check_type_can_return_date
(
func_name
())
||
args
[
1
]
->
check_type_can_return_time
(
func_name
());
}
public:
Item_func_timestamp
(
THD
*
thd
,
Item
*
a
,
Item
*
b
)
:
Item_datetimefunc
(
thd
,
a
,
b
)
{
}
const
char
*
func_name
()
const
{
return
"timestamp"
;
}
bool
fix_length_and_dec
()
{
uint
dec
=
MY_MAX
(
args
[
0
]
->
datetime_precision
(),
args
[
1
]
->
time_precision
());
fix_attributes_datetime
(
dec
);
maybe_null
=
true
;
return
false
;
}
bool
get_date
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzy_date
)
{
Datetime
dt
(
current_thd
,
args
[
0
],
0
);
MYSQL_TIME
ltime2
;
return
(
null_value
=
(
!
dt
.
is_valid_datetime
()
||
args
[
1
]
->
get_time
(
&
ltime2
)
||
Sec6_add
(
dt
.
get_mysql_time
(),
&
ltime2
,
1
).
to_datetime
(
ltime
)));
}
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_func_timestamp
>
(
thd
,
this
);
}
};
class
Item_func_add_time
:
public
Item_temporal_hybrid_func
{
const
bool
is_date
;
int
sign
;
public:
Item_func_add_time
(
THD
*
thd
,
Item
*
a
,
Item
*
b
,
bool
type_arg
,
bool
neg_arg
)
:
Item_temporal_hybrid_func
(
thd
,
a
,
b
),
is_date
(
type_arg
)
{
sign
=
neg_arg
?
-
1
:
1
;
}
Item_func_add_time
(
THD
*
thd
,
Item
*
a
,
Item
*
b
,
bool
neg_arg
)
:
Item_temporal_hybrid_func
(
thd
,
a
,
b
),
sign
(
neg_arg
?
-
1
:
1
)
{
}
bool
fix_length_and_dec
();
bool
get_date
(
MYSQL_TIME
*
ltime
,
ulonglong
fuzzy_date
);
void
print
(
String
*
str
,
enum_query_type
query_type
);
const
char
*
func_name
()
const
{
return
"add_time"
;
}
const
char
*
func_name
()
const
{
return
sign
>
0
?
"addtime"
:
"subtime"
;
}
Item
*
get_copy
(
THD
*
thd
)
{
return
get_item_copy
<
Item_func_add_time
>
(
thd
,
this
);
}
};
...
...
sql/sql_yacc.yy
View file @
b1ae4e7e
...
...
@@ -10216,7 +10216,7 @@ function_call_keyword_timestamp:
}
| TIMESTAMP '(' expr ',' expr ')'
{
$$= new (thd->mem_root) Item_func_
add_time(thd, $3, $5, 1, 0
);
$$= new (thd->mem_root) Item_func_
timestamp(thd, $3, $5
);
if (unlikely($$ == NULL))
MYSQL_YYABORT;
}
...
...
sql/sql_yacc_ora.yy
View file @
b1ae4e7e
...
...
@@ -10413,7 +10413,7 @@ function_call_keyword_timestamp:
}
| TIMESTAMP '(' expr ',' expr ')'
{
$$= new (thd->mem_root) Item_func_
add_time(thd, $3, $5, 1, 0
);
$$= new (thd->mem_root) Item_func_
timestamp(thd, $3, $5
);
if (unlikely($$ == NULL))
MYSQL_YYABORT;
}
...
...
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