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
d2e96e49
Commit
d2e96e49
authored
May 19, 2020
by
Marko Mäkelä
Browse files
Options
Browse Files
Download
Plain Diff
Merge 10.4 into 10.5
parents
49b29e35
fa039784
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
45 deletions
+88
-45
include/my_atomic.h
include/my_atomic.h
+0
-45
include/my_atomic_wrapper.h
include/my_atomic_wrapper.h
+58
-0
mysql-test/main/table_value_constr.result
mysql-test/main/table_value_constr.result
+13
-0
mysql-test/main/table_value_constr.test
mysql-test/main/table_value_constr.test
+16
-0
storage/innobase/include/srv0mon.h
storage/innobase/include/srv0mon.h
+1
-0
No files found.
include/my_atomic.h
View file @
d2e96e49
...
...
@@ -169,49 +169,4 @@
#define my_atomic_casptr_strong_explicit(P, E, D, S, F) \
my_atomic_casptr((P), (E), (D))
#endif
#ifdef __cplusplus
#include <atomic>
/**
A wrapper for std::atomic, defaulting to std::memory_order_relaxed.
When it comes to atomic loads or stores at std::memory_order_relaxed
on IA-32 or AMD64, this wrapper is only introducing some constraints
to the C++ compiler, to prevent some optimizations of loads or
stores.
On POWER and ARM, atomic loads and stores involve different instructions
from normal loads and stores and will thus incur some overhead.
Because atomic read-modify-write operations will always incur
overhead, we intentionally do not define
operator++(), operator--(), operator+=(), operator-=(), or similar,
to make the overhead stand out in the users of this code.
*/
template
<
typename
Type
>
class
Atomic_relaxed
{
std
::
atomic
<
Type
>
m
;
public:
Atomic_relaxed
(
const
Atomic_relaxed
<
Type
>
&
rhs
)
{
m
.
store
(
rhs
,
std
::
memory_order_relaxed
);
}
Atomic_relaxed
(
Type
val
)
:
m
(
val
)
{}
Atomic_relaxed
()
{}
operator
Type
()
const
{
return
m
.
load
(
std
::
memory_order_relaxed
);
}
Type
operator
=
(
const
Type
val
)
{
m
.
store
(
val
,
std
::
memory_order_relaxed
);
return
val
;
}
Type
operator
=
(
const
Atomic_relaxed
<
Type
>
&
rhs
)
{
return
*
this
=
Type
{
rhs
};
}
Type
fetch_add
(
const
Type
i
,
std
::
memory_order
o
=
std
::
memory_order_relaxed
)
{
return
m
.
fetch_add
(
i
,
o
);
}
Type
fetch_sub
(
const
Type
i
,
std
::
memory_order
o
=
std
::
memory_order_relaxed
)
{
return
m
.
fetch_sub
(
i
,
o
);
}
bool
compare_exchange_strong
(
Type
&
i1
,
const
Type
i2
,
std
::
memory_order
o1
=
std
::
memory_order_relaxed
,
std
::
memory_order
o2
=
std
::
memory_order_relaxed
)
{
return
m
.
compare_exchange_strong
(
i1
,
i2
,
o1
,
o2
);
}
Type
exchange
(
const
Type
i
,
std
::
memory_order
o
=
std
::
memory_order_relaxed
)
{
return
m
.
exchange
(
i
,
o
);
}
};
#endif
/* __cplusplus */
#endif
/* MY_ATOMIC_INCLUDED */
include/my_atomic_wrapper.h
0 → 100644
View file @
d2e96e49
/* Copyright (c) 2020, MariaDB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA */
#ifdef __cplusplus
#include <atomic>
/**
A wrapper for std::atomic, defaulting to std::memory_order_relaxed.
When it comes to atomic loads or stores at std::memory_order_relaxed
on IA-32 or AMD64, this wrapper is only introducing some constraints
to the C++ compiler, to prevent some optimizations of loads or
stores.
On POWER and ARM, atomic loads and stores involve different instructions
from normal loads and stores and will thus incur some overhead.
Because atomic read-modify-write operations will always incur
overhead, we intentionally do not define
operator++(), operator--(), operator+=(), operator-=(), or similar,
to make the overhead stand out in the users of this code.
*/
template
<
typename
Type
>
class
Atomic_relaxed
{
std
::
atomic
<
Type
>
m
;
public:
Atomic_relaxed
(
const
Atomic_relaxed
<
Type
>
&
rhs
)
{
m
.
store
(
rhs
,
std
::
memory_order_relaxed
);
}
Atomic_relaxed
(
Type
val
)
:
m
(
val
)
{}
Atomic_relaxed
()
{}
operator
Type
()
const
{
return
m
.
load
(
std
::
memory_order_relaxed
);
}
Type
operator
=
(
const
Type
val
)
{
m
.
store
(
val
,
std
::
memory_order_relaxed
);
return
val
;
}
Type
operator
=
(
const
Atomic_relaxed
<
Type
>
&
rhs
)
{
return
*
this
=
Type
{
rhs
};
}
Type
fetch_add
(
const
Type
i
,
std
::
memory_order
o
=
std
::
memory_order_relaxed
)
{
return
m
.
fetch_add
(
i
,
o
);
}
Type
fetch_sub
(
const
Type
i
,
std
::
memory_order
o
=
std
::
memory_order_relaxed
)
{
return
m
.
fetch_sub
(
i
,
o
);
}
bool
compare_exchange_strong
(
Type
&
i1
,
const
Type
i2
,
std
::
memory_order
o1
=
std
::
memory_order_relaxed
,
std
::
memory_order
o2
=
std
::
memory_order_relaxed
)
{
return
m
.
compare_exchange_strong
(
i1
,
i2
,
o1
,
o2
);
}
Type
exchange
(
const
Type
i
,
std
::
memory_order
o
=
std
::
memory_order_relaxed
)
{
return
m
.
exchange
(
i
,
o
);
}
};
#endif
/* __cplusplus */
mysql-test/main/table_value_constr.result
View file @
d2e96e49
...
...
@@ -2621,3 +2621,16 @@ EXECUTE IMMEDIATE 'VALUES (?)' USING IGNORE;
ERROR HY000: 'ignore' is not allowed in this context
EXECUTE IMMEDIATE 'VALUES (?)' USING DEFAULT;
ERROR HY000: 'default' is not allowed in this context
#
# MDEV-22610 Crash in INSERT INTO t1 (VALUES (DEFAULT) UNION VALUES (DEFAULT))
#
VALUES (DEFAULT) UNION VALUES (DEFAULT);
ERROR HY000: 'default' is not allowed in this context
VALUES (IGNORE) UNION VALUES (IGNORE);
ERROR HY000: 'ignore' is not allowed in this context
CREATE TABLE t1 (a INT DEFAULT 10);
INSERT INTO t1 (VALUES (DEFAULT) UNION VALUES (DEFAULT));
ERROR HY000: 'default' is not allowed in this context
INSERT INTO t1 (VALUES (IGNORE) UNION VALUES (IGNORE));
ERROR HY000: 'ignore' is not allowed in this context
DROP TABLE t1;
mysql-test/main/table_value_constr.test
View file @
d2e96e49
...
...
@@ -1353,3 +1353,19 @@ VALUES (DEFAULT);
EXECUTE
IMMEDIATE
'VALUES (?)'
USING
IGNORE
;
--
error
ER_NOT_ALLOWED_IN_THIS_CONTEXT
EXECUTE
IMMEDIATE
'VALUES (?)'
USING
DEFAULT
;
--
echo
#
--
echo
# MDEV-22610 Crash in INSERT INTO t1 (VALUES (DEFAULT) UNION VALUES (DEFAULT))
--
echo
#
--
error
ER_NOT_ALLOWED_IN_THIS_CONTEXT
VALUES
(
DEFAULT
)
UNION
VALUES
(
DEFAULT
);
--
error
ER_NOT_ALLOWED_IN_THIS_CONTEXT
VALUES
(
IGNORE
)
UNION
VALUES
(
IGNORE
);
CREATE
TABLE
t1
(
a
INT
DEFAULT
10
);
--
error
ER_NOT_ALLOWED_IN_THIS_CONTEXT
INSERT
INTO
t1
(
VALUES
(
DEFAULT
)
UNION
VALUES
(
DEFAULT
));
--
error
ER_NOT_ALLOWED_IN_THIS_CONTEXT
INSERT
INTO
t1
(
VALUES
(
IGNORE
)
UNION
VALUES
(
IGNORE
));
DROP
TABLE
t1
;
storage/innobase/include/srv0mon.h
View file @
d2e96e49
...
...
@@ -38,6 +38,7 @@ Created 12/15/2009 Jimmy Yang
#include <stdint.h>
#include "my_atomic.h"
#include "my_atomic_wrapper.h"
/** Possible status values for "mon_status" in "struct monitor_value" */
enum
monitor_running_status
{
...
...
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