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
2f932e0b
Commit
2f932e0b
authored
Nov 25, 2019
by
Nikita Malyavin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add overlaps_error_key -- fixes innodb combination run
parent
e040bdf0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
30 deletions
+42
-30
mysql-test/suite/period/r/overlaps.result
mysql-test/suite/period/r/overlaps.result
+14
-14
mysql-test/suite/period/t/overlaps.test
mysql-test/suite/period/t/overlaps.test
+16
-15
sql/handler.cc
sql/handler.cc
+10
-1
sql/handler.h
sql/handler.h
+2
-0
No files found.
mysql-test/suite/period/r/overlaps.result
View file @
2f932e0b
...
...
@@ -13,13 +13,13 @@ t CREATE TABLE `t` (
insert into t values (1, '2003-01-01', '2003-03-01'),
(1, '2003-05-01', '2003-07-01');
insert into t values (1, '2003-02-01', '2003-04-01');
ERROR 23000:
Can't write; duplicate key in table 't
'
ERROR 23000:
Duplicate entry '1-2003-02-01-2003-04-01' for key 'PRIMARY
'
insert into t values (1, '2003-04-01', '2003-06-01');
ERROR 23000:
Can't write; duplicate key in table 't
'
ERROR 23000:
Duplicate entry '1-2003-04-01-2003-06-01' for key 'PRIMARY
'
insert into t values (1, '2003-05-15', '2003-06-15');
ERROR 23000:
Can't write; duplicate key in table 't
'
ERROR 23000:
Duplicate entry '1-2003-05-15-2003-06-15' for key 'PRIMARY
'
insert into t values (1, '2003-04-01', '2003-08-01');
ERROR 23000:
Can't write; duplicate key in table 't
'
ERROR 23000:
Duplicate entry '1-2003-04-01-2003-08-01' for key 'PRIMARY
'
insert into t values (1, '2003-03-01', '2003-05-01');
# expand/shrink period
update t set s= '2002-12-01' where s = '2003-01-01';
...
...
@@ -34,22 +34,22 @@ update t set s= '2003-01-10', e= '2003-01-20' where s = '2003-01-01';
update t set s= '2003-01-01', e= '2003-02-01' where s = '2003-01-10';
# intersect left/right, strict inclusion/containment
update t set e= '2003-04-01' where s = '2003-01-01';
ERROR 23000:
Can't write; duplicate key in table 't
'
ERROR 23000:
Duplicate entry '1-2003-01-01-2003-04-01' for key 'PRIMARY
'
update t set s= '2003-04-01' where s = '2003-05-01';
ERROR 23000:
Can't write; duplicate key in table 't
'
ERROR 23000:
Duplicate entry '1-2003-04-01-2003-07-01' for key 'PRIMARY
'
update t set s= '2003-03-10', e= '2003-03-20' where s = '2003-01-01';
ERROR 23000:
Can't write; duplicate key in table 't
'
ERROR 23000:
Duplicate entry '1-2003-03-10-2003-03-20' for key 'PRIMARY
'
update t set s= '2003-04-01', e= '2003-08-01' where s = '2003-03-01';
ERROR 23000:
Can't write; duplicate key in table 't
'
ERROR 23000:
Duplicate entry '1-2003-04-01-2003-08-01' for key 'PRIMARY
'
# inclusion/containment with partial match
update t set s= '2003-03-01', e= '2003-04-01' where s = '2003-01-01';
ERROR 23000:
Can't write; duplicate key in table 't
'
ERROR 23000:
Duplicate entry '1-2003-03-01-2003-04-01' for key 'PRIMARY
'
update t set s= '2003-04-01', e= '2003-05-01' where s = '2003-01-01';
ERROR 23000:
Can't write; duplicate key in table 't
'
ERROR 23000:
Duplicate entry '1-2003-04-01-2003-05-01' for key 'PRIMARY
'
update t set s= '2003-03-01' where s = '2003-05-01';
ERROR 23000:
Can't write; duplicate key in table 't
'
ERROR 23000:
Duplicate entry '1-2003-03-01-2003-07-01' for key 'PRIMARY
'
update t set e= '2003-05-01' where s = '2003-01-01';
ERROR 23000:
Can't write; duplicate key in table 't
'
ERROR 23000:
Duplicate entry '1-2003-01-01-2003-05-01' for key 'PRIMARY
'
select * from t where year(s) = 2003;
id s e
1 2003-01-01 2003-02-01
...
...
@@ -90,7 +90,7 @@ t CREATE TABLE `t` (
insert into t values (1, 1, '2003-03-01', '2003-05-01');
insert into t values (1, 2, '2003-05-01', '2003-07-01');
insert into t values (1, 3, '2003-04-01', '2003-05-01');
ERROR 23000:
Can't write; duplicate key in table 't
'
ERROR 23000:
Duplicate entry '1-2003-04-01-2003-05-01' for key 'PRIMARY
'
create or replace table t(id int, u int, s date, e date,
period for p(s,e),
primary key(id, p without overlaps),
...
...
@@ -115,7 +115,7 @@ insert into t values (1, '2003-01-01', '2003-03-01'),
(1, '2003-05-01', '2003-07-01'),
(1, '2003-02-01', '2003-04-01');
alter table t add primary key(id, p without overlaps);
ERROR 23000:
Can't write; duplicate key in table 't
'
ERROR 23000:
Duplicate entry '1-2003-02-01-2003-04-01' for key 'PRIMARY
'
# Historical rows are not checked against constraints
set @@system_versioning_alter_history= keep;
alter table t add system versioning;
...
...
mysql-test/suite/period/t/overlaps.test
View file @
2f932e0b
...
...
@@ -5,7 +5,7 @@
let
$default_engine
=
`select @@default_storage_engine`
;
create
or
replace
table
t
(
id
int
NULL
,
s
date
,
e
date
,
create
or
replace
table
t
(
id
int
,
s
date
,
e
date
,
period
for
p
(
s
,
e
),
primary
key
(
id
,
p
without
overlaps
));
...
...
@@ -16,13 +16,13 @@ show create table t;
insert
into
t
values
(
1
,
'2003-01-01'
,
'2003-03-01'
),
(
1
,
'2003-05-01'
,
'2003-07-01'
);
--
error
ER_DUP_
KE
Y
--
error
ER_DUP_
ENTR
Y
insert
into
t
values
(
1
,
'2003-02-01'
,
'2003-04-01'
);
--
error
ER_DUP_
KE
Y
--
error
ER_DUP_
ENTR
Y
insert
into
t
values
(
1
,
'2003-04-01'
,
'2003-06-01'
);
--
error
ER_DUP_
KE
Y
--
error
ER_DUP_
ENTR
Y
insert
into
t
values
(
1
,
'2003-05-15'
,
'2003-06-15'
);
--
error
ER_DUP_
KE
Y
--
error
ER_DUP_
ENTR
Y
insert
into
t
values
(
1
,
'2003-04-01'
,
'2003-08-01'
);
insert
into
t
values
(
1
,
'2003-03-01'
,
'2003-05-01'
);
...
...
@@ -43,23 +43,23 @@ update t set s= '2003-01-10', e= '2003-01-20' where s = '2003-01-01';
update
t
set
s
=
'2003-01-01'
,
e
=
'2003-02-01'
where
s
=
'2003-01-10'
;
--
echo
# intersect left/right, strict inclusion/containment
--
error
ER_DUP_
KE
Y
--
error
ER_DUP_
ENTR
Y
update
t
set
e
=
'2003-04-01'
where
s
=
'2003-01-01'
;
--
error
ER_DUP_
KE
Y
--
error
ER_DUP_
ENTR
Y
update
t
set
s
=
'2003-04-01'
where
s
=
'2003-05-01'
;
--
error
ER_DUP_
KE
Y
--
error
ER_DUP_
ENTR
Y
update
t
set
s
=
'2003-03-10'
,
e
=
'2003-03-20'
where
s
=
'2003-01-01'
;
--
error
ER_DUP_
KE
Y
--
error
ER_DUP_
ENTR
Y
update
t
set
s
=
'2003-04-01'
,
e
=
'2003-08-01'
where
s
=
'2003-03-01'
;
--
echo
# inclusion/containment with partial match
--
error
ER_DUP_
KE
Y
--
error
ER_DUP_
ENTR
Y
update
t
set
s
=
'2003-03-01'
,
e
=
'2003-04-01'
where
s
=
'2003-01-01'
;
--
error
ER_DUP_
KE
Y
--
error
ER_DUP_
ENTR
Y
update
t
set
s
=
'2003-04-01'
,
e
=
'2003-05-01'
where
s
=
'2003-01-01'
;
--
error
ER_DUP_
KE
Y
--
error
ER_DUP_
ENTR
Y
update
t
set
s
=
'2003-03-01'
where
s
=
'2003-05-01'
;
--
error
ER_DUP_
KE
Y
--
error
ER_DUP_
ENTR
Y
update
t
set
e
=
'2003-05-01'
where
s
=
'2003-01-01'
;
select
*
from
t
where
year
(
s
)
=
2003
;
...
...
@@ -93,7 +93,7 @@ create or replace table t(id int, u int, s date, e date,
show
create
table
t
;
insert
into
t
values
(
1
,
1
,
'2003-03-01'
,
'2003-05-01'
);
insert
into
t
values
(
1
,
2
,
'2003-05-01'
,
'2003-07-01'
);
--
error
ER_DUP_
KE
Y
--
error
ER_DUP_
ENTR
Y
insert
into
t
values
(
1
,
3
,
'2003-04-01'
,
'2003-05-01'
);
create
or
replace
table
t
(
id
int
,
u
int
,
s
date
,
e
date
,
...
...
@@ -113,7 +113,8 @@ insert into t values (1, '2003-01-01', '2003-03-01'),
(
1
,
'2003-05-01'
,
'2003-07-01'
),
(
1
,
'2003-02-01'
,
'2003-04-01'
);
--
error
ER_DUP_KEY
--
replace_regex
/
#sql-\w+/#sql-temp/
--
error
ER_DUP_ENTRY
alter
table
t
add
primary
key
(
id
,
p
without
overlaps
);
--
echo
# Historical rows are not checked against constraints
...
...
sql/handler.cc
View file @
2f932e0b
...
...
@@ -4173,6 +4173,11 @@ uint handler::get_dup_key(int error)
if
(
table
->
s
->
long_unique_table
&&
table
->
file
->
errkey
<
table
->
s
->
keys
)
DBUG_RETURN
(
table
->
file
->
errkey
);
table
->
file
->
errkey
=
(
uint
)
-
1
;
if
(
overlaps_error_key
!=
-
1
)
{
table
->
file
->
errkey
=
(
uint
)
overlaps_error_key
;
DBUG_RETURN
(
table
->
file
->
errkey
);
}
if
(
error
==
HA_ERR_FOUND_DUPP_KEY
||
error
==
HA_ERR_FOREIGN_DUPLICATE_KEY
||
error
==
HA_ERR_FOUND_DUPP_UNIQUE
||
error
==
HA_ERR_NULL_IN_SPATIAL
||
...
...
@@ -6407,6 +6412,7 @@ int handler::ha_external_lock(THD *thd, int lock_type)
check_overlaps_handler
->
ha_external_lock
(
table
->
in_use
,
F_UNLCK
);
check_overlaps_handler
->
close
();
check_overlaps_handler
=
NULL
;
overlaps_error_key
=
-
1
;
}
if
(
MYSQL_HANDLER_RDLOCK_DONE_ENABLED
()
||
...
...
@@ -7017,7 +7023,7 @@ int handler::ha_check_overlaps(const uchar *old_data, const uchar* new_data)
HA_READ_KEY_OR_PREV
);
if
(
!
error
&&
!
old_row_found
()
&&
table
->
check_period_overlaps
(
key_info
,
key_info
,
&&
table
->
check_period_overlaps
(
key_info
,
key_info
,
new_data
,
record_buffer
)
==
0
)
error
=
HA_ERR_FOUND_DUPP_KEY
;
...
...
@@ -7032,6 +7038,9 @@ int handler::ha_check_overlaps(const uchar *old_data, const uchar* new_data)
if
(
error
==
HA_ERR_END_OF_FILE
)
error
=
0
;
if
(
error
==
HA_ERR_FOUND_DUPP_KEY
)
overlaps_error_key
=
key_nr
;
int
end_error
=
handler
->
ha_index_end
();
if
(
error
||
end_error
)
return
error
?
error
:
end_error
;
...
...
sql/handler.h
View file @
2f932e0b
...
...
@@ -3004,6 +3004,7 @@ class handler :public Sql_alloc
ha_rows
estimation_rows_to_insert
;
uchar
*
check_overlaps_buffer
;
handler
*
check_overlaps_handler
;
int
overlaps_error_key
;
public:
handlerton
*
ht
;
/* storage engine of this handler */
uchar
*
ref
;
/* Pointer to current row */
...
...
@@ -3151,6 +3152,7 @@ class handler :public Sql_alloc
:
table_share
(
share_arg
),
table
(
0
),
estimation_rows_to_insert
(
0
),
check_overlaps_buffer
(
NULL
),
check_overlaps_handler
(
NULL
),
overlaps_error_key
(
-
1
),
ht
(
ht_arg
),
ref
(
0
),
end_range
(
NULL
),
implicit_emptied
(
0
),
mark_trx_read_write_done
(
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