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
244ff3e5
Commit
244ff3e5
authored
Mar 17, 2020
by
Nikita Malyavin
Committed by
Sergei Golubchik
Mar 31, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forbid REPLACE/ODKU on tables containing WITHOUT OVERLAPS
parent
62e7ad2b
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
85 additions
and
0 deletions
+85
-0
mysql-test/suite/period/r/overlaps.result
mysql-test/suite/period/r/overlaps.result
+22
-0
mysql-test/suite/period/t/overlaps.test
mysql-test/suite/period/t/overlaps.test
+28
-0
sql/sql_insert.cc
sql/sql_insert.cc
+30
-0
sql/sql_insert.h
sql/sql_insert.h
+2
-0
sql/sql_load.cc
sql/sql_load.cc
+3
-0
No files found.
mysql-test/suite/period/r/overlaps.result
View file @
244ff3e5
...
...
@@ -204,4 +204,26 @@ ERROR 23000: Duplicate entry 'test' for key 'b'
insert into t values (1, '2020-03-05', '2020-03-10', 'test2');
insert into t values (1, '2020-03-03', '2020-03-10', 'test3');
ERROR 23000: Duplicate entry '1-2020-03-10-2020-03-03' for key 'x'
create or replace table t (x int, s date, e date, period for apptime(s,e),
unique(x, apptime without overlaps));
replace into t values (1, '2020-03-03', '2020-03-10');
ERROR 42000: This version of MariaDB doesn't yet support 'WITHOUT OVERLAPS'
insert into t values (1, '2020-03-03', '2020-03-10')
on duplicate key update x = 2;
ERROR 42000: This version of MariaDB doesn't yet support 'WITHOUT OVERLAPS'
select * from t;
x s e
select * into outfile 'tmp_t.txt' from t;
load data infile 'tmp_t.txt' into table t;
load data infile 'tmp_t.txt' replace into table t;
ERROR 42000: This version of MariaDB doesn't yet support 'WITHOUT OVERLAPS'
insert into t values (1, '2020-03-01', '2020-03-05');
select * into outfile 'tmp_t.txt' from t;
load data infile 'tmp_t.txt' into table t;
ERROR 23000: Duplicate entry '1-2020-03-05-2020-03-01' for key 'x'
load data infile 'tmp_t.txt' ignore into table t;
Warnings:
Warning 1062 Duplicate entry '1-2020-03-05-2020-03-01' for key 'x'
load data infile 'tmp_t.txt' replace into table t;
ERROR 42000: This version of MariaDB doesn't yet support 'WITHOUT OVERLAPS'
create or replace database test;
mysql-test/suite/period/t/overlaps.test
View file @
244ff3e5
...
...
@@ -201,4 +201,32 @@ insert into t values (1, '2020-03-05', '2020-03-10', 'test2');
--
error
ER_DUP_ENTRY
insert
into
t
values
(
1
,
'2020-03-03'
,
'2020-03-10'
,
'test3'
);
let
$MYSQLD_DATADIR
=
`select @@datadir`
;
create
or
replace
table
t
(
x
int
,
s
date
,
e
date
,
period
for
apptime
(
s
,
e
),
unique
(
x
,
apptime
without
overlaps
));
--
error
ER_NOT_SUPPORTED_YET
replace
into
t
values
(
1
,
'2020-03-03'
,
'2020-03-10'
);
--
error
ER_NOT_SUPPORTED_YET
insert
into
t
values
(
1
,
'2020-03-03'
,
'2020-03-10'
)
on
duplicate
key
update
x
=
2
;
select
*
from
t
;
select
*
into
outfile
'tmp_t.txt'
from
t
;
load
data
infile
'tmp_t.txt'
into
table
t
;
--
error
ER_NOT_SUPPORTED_YET
load
data
infile
'tmp_t.txt'
replace
into
table
t
;
remove_file
$MYSQLD_DATADIR
/
test
/
tmp_t
.
txt
;
insert
into
t
values
(
1
,
'2020-03-01'
,
'2020-03-05'
);
select
*
into
outfile
'tmp_t.txt'
from
t
;
--
error
ER_DUP_ENTRY
load
data
infile
'tmp_t.txt'
into
table
t
;
load
data
infile
'tmp_t.txt'
ignore
into
table
t
;
--
error
ER_NOT_SUPPORTED_YET
load
data
infile
'tmp_t.txt'
replace
into
table
t
;
remove_file
$MYSQLD_DATADIR
/
test
/
tmp_t
.
txt
;
create
or
replace
database
test
;
sql/sql_insert.cc
View file @
244ff3e5
...
...
@@ -1410,6 +1410,33 @@ static bool check_view_insertability(THD * thd, TABLE_LIST *view)
}
/**
TODO remove when MDEV-17395 will be closed
Checks if REPLACE or ON DUPLICATE UPDATE was executed on table containing
WITHOUT OVERLAPS key.
@return
0 if no error
ER_NOT_SUPPORTED_YET if the above condidion was met
*/
int
check_duplic_insert_without_overlaps
(
THD
*
thd
,
TABLE
*
table
,
enum_duplicates
duplic
)
{
if
(
duplic
==
DUP_REPLACE
||
duplic
==
DUP_UPDATE
)
{
for
(
uint
k
=
0
;
k
<
table
->
s
->
keys
;
k
++
)
{
if
(
table
->
key_info
[
k
].
without_overlaps
)
{
my_error
(
ER_NOT_SUPPORTED_YET
,
MYF
(
0
),
"WITHOUT OVERLAPS"
);
return
ER_NOT_SUPPORTED_YET
;
}
}
}
return
0
;
}
/*
Check if table can be updated
...
...
@@ -1607,6 +1634,9 @@ bool mysql_prepare_insert(THD *thd, TABLE_LIST *table_list,
if
(
!
table
)
table
=
table_list
->
table
;
if
(
check_duplic_insert_without_overlaps
(
thd
,
table
,
duplic
)
!=
0
)
DBUG_RETURN
(
true
);
if
(
table
->
versioned
(
VERS_TIMESTAMP
)
&&
duplic
==
DUP_REPLACE
)
{
// Additional memory may be required to create historical items.
...
...
sql/sql_insert.h
View file @
244ff3e5
...
...
@@ -38,6 +38,8 @@ void upgrade_lock_type_for_insert(THD *thd, thr_lock_type *lock_type,
int
check_that_all_fields_are_given_values
(
THD
*
thd
,
TABLE
*
entry
,
TABLE_LIST
*
table_list
);
int
vers_insert_history_row
(
TABLE
*
table
);
int
check_duplic_insert_without_overlaps
(
THD
*
thd
,
TABLE
*
table
,
enum_duplicates
duplic
);
int
write_record
(
THD
*
thd
,
TABLE
*
table
,
COPY_INFO
*
info
,
select_result
*
returning
=
NULL
);
void
kill_delayed_threads
(
void
);
...
...
sql/sql_load.cc
View file @
244ff3e5
...
...
@@ -441,6 +441,9 @@ int mysql_load(THD *thd, const sql_exchange *ex, TABLE_LIST *table_list,
is_concurrent
=
(
table_list
->
lock_type
==
TL_WRITE_CONCURRENT_INSERT
);
#endif
if
(
check_duplic_insert_without_overlaps
(
thd
,
table
,
handle_duplicates
)
!=
0
)
DBUG_RETURN
(
true
);
if
(
!
fields_vars
.
elements
)
{
Field_iterator_table_ref
field_iterator
;
...
...
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