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
c29da10e
Commit
c29da10e
authored
Sep 09, 2008
by
Ramil Kalimullin
Browse files
Options
Browse Files
Download
Plain Diff
Merge
parents
4fa5cd08
835f3528
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
7 deletions
+52
-7
mysql-test/r/type_datetime.result
mysql-test/r/type_datetime.result
+23
-0
mysql-test/t/type_datetime.test
mysql-test/t/type_datetime.test
+16
-0
sql/item_cmpfunc.cc
sql/item_cmpfunc.cc
+13
-7
No files found.
mysql-test/r/type_datetime.result
View file @
c29da10e
...
...
@@ -560,6 +560,29 @@ select * from t2
where id in (select id from t2 as x1 where (t2.cur_date is null));
id cur_date
drop table t1,t2;
SELECT
CAST('NULL' AS DATE) <=> CAST('2008-01-01' AS DATE) n1,
CAST('2008-01-01' AS DATE) <=> CAST('NULL' AS DATE) n2,
CAST('NULL' AS DATE) <=> CAST('NULL' AS DATE) n3,
CAST('NULL' AS DATE) <> CAST('2008-01-01' AS DATE) n4,
CAST('2008-01-01' AS DATE) <> CAST('NULL' AS DATE) n5,
CAST('NULL' AS DATE) <> CAST('NULL' AS DATE) n6,
CAST('NULL' AS DATE) < CAST('2008-01-01' AS DATE) n7,
CAST('2008-01-01' AS DATE) < CAST('NULL' AS DATE) n8,
CAST('NULL' AS DATE) < CAST('NULL' AS DATE) n9;
n1 n2 n3 n4 n5 n6 n7 n8 n9
0 0 1 NULL NULL NULL NULL NULL NULL
Warnings:
Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
Warning 1292 Incorrect datetime value: 'NULL'
End of 5.0 tests
set @org_mode=@@sql_mode;
create table t1 (da date default '1962-03-03 23:33:34', dt datetime default '1962-03-03');
...
...
mysql-test/t/type_datetime.test
View file @
c29da10e
...
...
@@ -388,6 +388,22 @@ where id in (select id from t2 as x1 where (t2.cur_date is null));
drop
table
t1
,
t2
;
#
# Bug #37526: asymertic operator <=> in trigger
#
SELECT
CAST
(
'NULL'
AS
DATE
)
<=>
CAST
(
'2008-01-01'
AS
DATE
)
n1
,
CAST
(
'2008-01-01'
AS
DATE
)
<=>
CAST
(
'NULL'
AS
DATE
)
n2
,
CAST
(
'NULL'
AS
DATE
)
<=>
CAST
(
'NULL'
AS
DATE
)
n3
,
CAST
(
'NULL'
AS
DATE
)
<>
CAST
(
'2008-01-01'
AS
DATE
)
n4
,
CAST
(
'2008-01-01'
AS
DATE
)
<>
CAST
(
'NULL'
AS
DATE
)
n5
,
CAST
(
'NULL'
AS
DATE
)
<>
CAST
(
'NULL'
AS
DATE
)
n6
,
CAST
(
'NULL'
AS
DATE
)
<
CAST
(
'2008-01-01'
AS
DATE
)
n7
,
CAST
(
'2008-01-01'
AS
DATE
)
<
CAST
(
'NULL'
AS
DATE
)
n8
,
CAST
(
'NULL'
AS
DATE
)
<
CAST
(
'NULL'
AS
DATE
)
n9
;
--
echo
End
of
5.0
tests
#
# Test of storing datetime into date fields
...
...
sql/item_cmpfunc.cc
View file @
c29da10e
...
...
@@ -1029,19 +1029,24 @@ get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg,
1 if items are equal or both are null
0 otherwise
If is_nulls_eq is FALSE:
-1 a < b or
one of items
is null
-1 a < b or
at least one item
is null
0 a == b
1 a > b
See the table:
is_nulls_eq | 1 | 1 | 1 | 1 | 0 | 0 | 0 | 0 |
a_is_null | 1 | 0 | 1 | 0 | 1 | 0 | 1 | 0 |
b_is_null | 1 | 1 | 0 | 0 | 1 | 1 | 0 | 0 |
result | 1 | 0 | 0 |0/1|-1 |-1 |-1 |-1/0/1|
*/
int
Arg_comparator
::
compare_datetime
()
{
bool
is_null
=
FALSE
;
bool
a_is_null
,
b_is_null
;
ulonglong
a_value
,
b_value
;
/* Get DATE/DATETIME/TIME value of the 'a' item. */
a_value
=
(
*
get_value_func
)(
thd
,
&
a
,
&
a_cache
,
*
b
,
&
is_null
);
if
(
!
is_nulls_eq
&&
is_null
)
a_value
=
(
*
get_value_func
)(
thd
,
&
a
,
&
a_cache
,
*
b
,
&
a_
is_null
);
if
(
!
is_nulls_eq
&&
a_
is_null
)
{
if
(
owner
)
owner
->
null_value
=
1
;
...
...
@@ -1049,14 +1054,15 @@ int Arg_comparator::compare_datetime()
}
/* Get DATE/DATETIME/TIME value of the 'b' item. */
b_value
=
(
*
get_value_func
)(
thd
,
&
b
,
&
b_cache
,
*
a
,
&
is_null
);
if
(
is_null
)
b_value
=
(
*
get_value_func
)(
thd
,
&
b
,
&
b_cache
,
*
a
,
&
b_
is_null
);
if
(
a_is_null
||
b_
is_null
)
{
if
(
owner
)
owner
->
null_value
=
is_nulls_eq
?
0
:
1
;
return
is_nulls_eq
?
1
:
-
1
;
return
is_nulls_eq
?
(
a_is_null
==
b_is_null
)
:
-
1
;
}
/* Here we have two not-NULL values. */
if
(
owner
)
owner
->
null_value
=
0
;
...
...
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