url
stringlengths 45
122
| content
stringlengths 380
3.07M
|
---|---|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-component-scheduler-tasks-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="performance-schema-component-scheduler-tasks-table">
</a>
29.12.22.1 The component_scheduler_tasks Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045067780000">
</a>
<a class="indexterm" name="idm46045067778496">
</a>
<p>
The
<code class="literal">
component_scheduler_tasks
</code>
table
contains a row for each scheduled task. Each row contains
information about the ongoing progress of a task that
applications, components, and plugins can implement,
optionally, using the
<code class="literal">
scheduler
</code>
component
(see
<a class="xref" href="scheduler-component.html" title="7.5.5 Scheduler Component">
Section 7.5.5, “Scheduler Component”
</a>
). For example, the
<code class="literal">
audit_log
</code>
server plugin utilizes the
<code class="literal">
scheduler
</code>
component to run a regular,
recurring flush of its memory cache:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa86686497"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">select</span> <span class="token operator">*</span> <span class="token keyword">from</span> performance_schema<span class="token punctuation">.</span>component_scheduler_tasks\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
NAME<span class="token punctuation">:</span> plugin_audit_log_flush_scheduler
STATUS<span class="token punctuation">:</span> WAITING
COMMENT<span class="token punctuation">:</span> Registered by the audit log plugin. Does a periodic refresh of the audit log
in-memory rules cache by calling audit_log_flush
INTERVAL_SECONDS<span class="token punctuation">:</span> 100
TIMES_RUN<span class="token punctuation">:</span> 5
TIMES_FAILED<span class="token punctuation">:</span> 0
</span><span class="token output">1 row in set (0.02 sec)</span></code></pre>
</div>
<p>
The
<code class="literal">
component_scheduler_tasks
</code>
table has the
following columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
NAME
</code>
</p>
<p>
The name supplied during the registration.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STATUS
</code>
</p>
<p>
The values are:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
RUNNING
</code>
if the task is active and
being executed.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WAITING
</code>
if the task is idle and
waiting for the background thread to pick it up or
waiting for the next time it needs to be run to
arrive.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
COMMENT
</code>
</p>
<p>
A compile-time comment provided by an application,
component, or plugin. In the previous example, MySQL Enterprise Audit
provides the comment using a server plugin named
<code class="literal">
audit_log
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INTERVAL_SECONDS
</code>
</p>
<p>
The time in seconds to run a task, which an application,
component, or plugin provides. MySQL Enterprise Audit enables you to
specify this value using the
<a class="link" href="audit-log-reference.html#sysvar_audit_log_flush_interval_seconds">
<code class="literal">
audit_log_flush_interval_seconds
</code>
</a>
system variable.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIMES_RUN
</code>
</p>
<p>
A counter that increments by one every time the task runs
successfully. It wraps around.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIMES_FAILED
</code>
</p>
<p>
A counter that increments by one every time the execution
of the task fails. It wraps around.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/stored-routines-metadata.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="stored-routines-metadata">
</a>
27.2.3 Stored Routine Metadata
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045082465264">
</a>
<a class="indexterm" name="idm46045082463776">
</a>
<p>
To obtain metadata about stored routines:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Query the
<a class="link" href="information-schema-routines-table.html" title="28.3.30 The INFORMATION_SCHEMA ROUTINES Table">
<code class="literal">
ROUTINES
</code>
</a>
table of the
<code class="literal">
INFORMATION_SCHEMA
</code>
database. See
<a class="xref" href="information-schema-routines-table.html" title="28.3.30 The INFORMATION_SCHEMA ROUTINES Table">
Section 28.3.30, “The INFORMATION_SCHEMA ROUTINES Table”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Use the
<a class="link" href="show-create-procedure.html" title="15.7.7.10 SHOW CREATE PROCEDURE Statement">
<code class="literal">
SHOW CREATE PROCEDURE
</code>
</a>
and
<a class="link" href="show-create-function.html" title="15.7.7.9 SHOW CREATE FUNCTION Statement">
<code class="literal">
SHOW CREATE FUNCTION
</code>
</a>
statements to see routine definitions. See
<a class="xref" href="show-create-procedure.html" title="15.7.7.10 SHOW CREATE PROCEDURE Statement">
Section 15.7.7.10, “SHOW CREATE PROCEDURE Statement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Use the
<a class="link" href="show-procedure-status.html" title="15.7.7.30 SHOW PROCEDURE STATUS Statement">
<code class="literal">
SHOW PROCEDURE STATUS
</code>
</a>
and
<a class="link" href="show-function-status.html" title="15.7.7.21 SHOW FUNCTION STATUS Statement">
<code class="literal">
SHOW FUNCTION STATUS
</code>
</a>
statements to see routine characteristics. See
<a class="xref" href="show-procedure-status.html" title="15.7.7.30 SHOW PROCEDURE STATUS Statement">
Section 15.7.7.30, “SHOW PROCEDURE STATUS Statement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Use the
<a class="link" href="show-procedure-code.html" title="15.7.7.29 SHOW PROCEDURE CODE Statement">
<code class="literal">
SHOW PROCEDURE CODE
</code>
</a>
and
<a class="link" href="show-function-code.html" title="15.7.7.20 SHOW FUNCTION CODE Statement">
<code class="literal">
SHOW FUNCTION CODE
</code>
</a>
statements
to see a representation of the internal implementation of the
routine. See
<a class="xref" href="show-procedure-code.html" title="15.7.7.29 SHOW PROCEDURE CODE Statement">
Section 15.7.7.29, “SHOW PROCEDURE CODE Statement”
</a>
.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/optimizing-innodb-queries.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="optimizing-innodb-queries">
</a>
10.5.6 Optimizing InnoDB Queries
</h3>
</div>
</div>
</div>
<p>
To tune queries for
<code class="literal">
InnoDB
</code>
tables, create an
appropriate set of indexes on each table. See
<a class="xref" href="mysql-indexes.html" title="10.3.1 How MySQL Uses Indexes">
Section 10.3.1, “How MySQL Uses Indexes”
</a>
for details. Follow these
guidelines for
<code class="literal">
InnoDB
</code>
indexes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Because each
<code class="literal">
InnoDB
</code>
table has a
<a class="link" href="glossary.html#glos_primary_key" title="primary key">
primary key
</a>
(whether
you request one or not), specify a set of primary key
columns for each table, columns that are used in the most
important and time-critical queries.
</p>
</li>
<li class="listitem">
<p>
Do not specify too many or too long columns in the primary
key, because these column values are duplicated in each
secondary index. When an index contains unnecessary data,
the I/O to read this data and memory to cache it reduce the
performance and scalability of the server.
</p>
</li>
<li class="listitem">
<p>
Do not create a separate
<a class="link" href="glossary.html#glos_secondary_index" title="secondary index">
secondary index
</a>
for each column, because each query can only make use of one
index. Indexes on rarely tested columns or columns with only
a few different values might not be helpful for any queries.
If you have many queries for the same table, testing
different combinations of columns, try to create a small
number of
<a class="link" href="glossary.html#glos_concatenated_index" title="concatenated index">
concatenated
indexes
</a>
rather than a large number of single-column
indexes. If an index contains all the columns needed for the
result set (known as a
<a class="link" href="glossary.html#glos_covering_index" title="covering index">
covering index
</a>
),
the query might be able to avoid reading the table data at
all.
</p>
</li>
<li class="listitem">
<p>
If an indexed column cannot contain any
<code class="literal">
NULL
</code>
values, declare it as
<code class="literal">
NOT
NULL
</code>
when you create the table. The optimizer can
better determine which index is most effective to use for a
query, when it knows whether each column contains
<code class="literal">
NULL
</code>
values.
</p>
</li>
<li class="listitem">
<p>
You can optimize single-query transactions for
<code class="literal">
InnoDB
</code>
tables, using the technique in
<a class="xref" href="innodb-performance-ro-txn.html" title="10.5.3 Optimizing InnoDB Read-Only Transactions">
Section 10.5.3, “Optimizing InnoDB Read-Only Transactions”
</a>
.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/alter-tablespace.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="alter-tablespace">
</a>
15.1.10 ALTER TABLESPACE Statement
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045188454400">
</a>
<a class="indexterm" name="idm46045188452944">
</a>
<a class="indexterm" name="idm46045188451456">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa67950580"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">ALTER</span> <span class="token punctuation">[</span><span class="token keyword">UNDO</span><span class="token punctuation">]</span> <span class="token keyword">TABLESPACE</span> <em class="replaceable">tablespace_name</em>
<span class="token keyword"></span><em><span class="token keyword">NDB</span> <span class="token keyword">only</span>:</em>
{<span class="token keyword">ADD</span> <span class="token operator">|</span> <span class="token keyword">DROP</span>} <span class="token keyword">DATAFILE</span> <span class="token string">'<em class="replaceable">file_name</em>'</span>
<span class="token punctuation">[</span><span class="token keyword">INITIAL_SIZE</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> size<span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">WAIT</span><span class="token punctuation">]</span>
<em>InnoDB <span class="token operator">and</span> <span class="token keyword">NDB</span>:</em>
<span class="token punctuation">[</span><span class="token keyword">RENAME</span> <span class="token keyword">TO</span> <em class="replaceable">tablespace_name</em><span class="token punctuation">]</span>
<em>InnoDB <span class="token keyword">only</span>:</em>
<span class="token punctuation">[</span><span class="token keyword">AUTOEXTEND_SIZE</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <span class="token string">'<em class="replaceable">value</em>'</span><span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">SET</span> {<span class="token keyword">ACTIVE</span> <span class="token operator">|</span> <span class="token keyword">INACTIVE</span>}<span class="token punctuation">]</span>
<span class="token punctuation">[</span><span class="token keyword">ENCRYPTION</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> {<span class="token string">'Y'</span> <span class="token operator">|</span> <span class="token string">'N'</span>}<span class="token punctuation">]</span>
<em>InnoDB <span class="token operator">and</span> <span class="token keyword">NDB</span>:</em>
<span class="token punctuation">[</span><span class="token keyword">ENGINE</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <em class="replaceable">engine_name</em><span class="token punctuation">]</span>
<em>Reserved <span class="token keyword">for</span> future <span class="token keyword">use</span>:</em>
<span class="token punctuation">[</span><span class="token keyword">ENGINE_ATTRIBUTE</span> <span class="token punctuation">[</span><span class="token operator">=</span><span class="token punctuation">]</span> <span class="token string">'<em class="replaceable">string</em>'</span><span class="token punctuation">]</span></code></pre>
</div>
<p>
This statement is used with
<code class="literal">
NDB
</code>
and
<code class="literal">
InnoDB
</code>
tablespaces. It can be used to add a new
data file to, or to drop a data file from an
<code class="literal">
NDB
</code>
tablespace. It can also be used to rename
an NDB Cluster Disk Data tablespace, rename an
<code class="literal">
InnoDB
</code>
general tablespace, encrypt an
<code class="literal">
InnoDB
</code>
general tablespace, or mark an
<code class="literal">
InnoDB
</code>
undo tablespace as active or inactive.
</p>
<p>
The
<code class="literal">
UNDO
</code>
keyword is used with the
<code class="literal">
SET
{ACTIVE | INACTIVE}
</code>
clause to mark an
<code class="literal">
InnoDB
</code>
undo tablespace as active or inactive.
For more information, see
<a class="xref" href="innodb-undo-tablespaces.html" title="17.6.3.4 Undo Tablespaces">
Section 17.6.3.4, “Undo Tablespaces”
</a>
.
</p>
<p>
The
<code class="literal">
ADD DATAFILE
</code>
variant enables you to specify
an initial size for an
<code class="literal">
NDB
</code>
Disk Data tablespace
using an
<code class="literal">
INITIAL_SIZE
</code>
clause, where
<em class="replaceable">
<code>
size
</code>
</em>
is measured in bytes; the default
value is 134217728 (128 MB). You may optionally follow
<em class="replaceable">
<code>
size
</code>
</em>
with a one-letter abbreviation for
an order of magnitude, similar to those used in
<code class="filename">
my.cnf
</code>
. Generally, this is one of the letters
<code class="literal">
M
</code>
(megabytes) or
<code class="literal">
G
</code>
(gigabytes).
</p>
<p>
On 32-bit systems, the maximum supported value for
<code class="literal">
INITIAL_SIZE
</code>
is 4294967296 (4 GB). (Bug #29186)
</p>
<p>
<code class="literal">
INITIAL_SIZE
</code>
is rounded, explicitly, as for
<a class="link" href="create-tablespace.html" title="15.1.21 CREATE TABLESPACE Statement">
<code class="literal">
CREATE TABLESPACE
</code>
</a>
.
</p>
<p>
Once a data file has been created, its size cannot be changed;
however, you can add more data files to an
<code class="literal">
NDB
</code>
tablespace using additional
<code class="literal">
ALTER TABLESPACE ... ADD
DATAFILE
</code>
statements.
</p>
<p>
When
<code class="literal">
ALTER TABLESPACE ... ADD DATAFILE
</code>
is used
with
<code class="literal">
ENGINE = NDB
</code>
, a data file is created on
each Cluster data node, but only one row is generated in the
Information Schema
<a class="link" href="information-schema-files-table.html" title="28.3.15 The INFORMATION_SCHEMA FILES Table">
<code class="literal">
FILES
</code>
</a>
table. See
the description of this table, as well as
<a class="xref" href="mysql-cluster-disk-data-objects.html" title="25.6.11.1 NDB Cluster Disk Data Objects">
Section 25.6.11.1, “NDB Cluster Disk Data Objects”
</a>
, for more
information.
<code class="literal">
ADD DATAFILE
</code>
is not supported with
<code class="literal">
InnoDB
</code>
tablespaces.
</p>
<p>
Using
<code class="literal">
DROP DATAFILE
</code>
with
<a class="link" href="alter-tablespace.html" title="15.1.10 ALTER TABLESPACE Statement">
<code class="literal">
ALTER TABLESPACE
</code>
</a>
drops the data
file '
<em class="replaceable">
<code>
file_name
</code>
</em>
' from an
<code class="literal">
NDB
</code>
tablespace. You cannot drop a data file
from a tablespace which is in use by any table; in other words,
the data file must be empty (no extents used). See
<a class="xref" href="mysql-cluster-disk-data-objects.html" title="25.6.11.1 NDB Cluster Disk Data Objects">
Section 25.6.11.1, “NDB Cluster Disk Data Objects”
</a>
. In addition,
any data file to be dropped must previously have been added to the
tablespace with
<a class="link" href="create-tablespace.html" title="15.1.21 CREATE TABLESPACE Statement">
<code class="literal">
CREATE TABLESPACE
</code>
</a>
or
<a class="link" href="alter-tablespace.html" title="15.1.10 ALTER TABLESPACE Statement">
<code class="literal">
ALTER TABLESPACE
</code>
</a>
.
<code class="literal">
DROP
DATAFILE
</code>
is not supported with
<code class="literal">
InnoDB
</code>
tablespaces.
</p>
<p>
<code class="literal">
WAIT
</code>
is parsed but otherwise ignored. It is
intended for future expansion.
</p>
<p>
The
<code class="literal">
ENGINE
</code>
clause, which specifies the storage
engine used by the tablespace, is deprecated, since the tablespace
storage engine is known by the data dictionary, making the
<code class="literal">
ENGINE
</code>
clause obsolete. In MySQL
8.4, it is supported in the following two cases only:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa46514406"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">ALTER</span> <span class="token keyword">TABLESPACE</span> <em class="replaceable">tablespace_name</em> <span class="token keyword">ADD</span> <span class="token keyword">DATAFILE</span> <span class="token string">'<em class="replaceable">file_name</em>'</span>
<span class="token keyword">ENGINE</span><span class="token operator">=</span>{<span class="token keyword">NDB</span><span class="token operator">|</span><span class="token keyword">NDBCLUSTER</span>}</code></pre>
</div>
</li>
<li class="listitem">
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa30279608"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">ALTER</span> <span class="token keyword">UNDO</span> <span class="token keyword">TABLESPACE</span> <em class="replaceable">tablespace_name</em> <span class="token keyword">SET</span> {<span class="token keyword">ACTIVE</span><span class="token operator">|</span><span class="token keyword">INACTIVE</span>}
<span class="token keyword">ENGINE</span><span class="token operator">=</span>INNODB</code></pre>
</div>
</li>
</ul>
</div>
<p>
You should expect the eventual removal of
<code class="literal">
ENGINE
</code>
from these statements as well, in a
future version of MySQL.
</p>
<p>
<code class="literal">
RENAME TO
</code>
operations are implicitly performed
in autocommit mode, regardless of the value of
<a class="link" href="server-system-variables.html#sysvar_autocommit">
<code class="literal">
autocommit
</code>
</a>
.
</p>
<p>
A
<code class="literal">
RENAME TO
</code>
operation cannot be performed while
<a class="link" href="lock-tables.html" title="15.3.6 LOCK TABLES and UNLOCK TABLES Statements">
<code class="literal">
LOCK TABLES
</code>
</a>
or
<a class="link" href="flush.html" title="15.7.8.3 FLUSH Statement">
<code class="literal">
FLUSH TABLES WITH READ
LOCK
</code>
</a>
is in effect for tables that reside in the
tablespace.
</p>
<p>
Exclusive
<a class="link" href="glossary.html#glos_metadata_lock" title="metadata lock">
metadata locks
</a>
are taken on tables that reside in a general tablespace while the
tablespace is renamed, which prevents concurrent DDL. Concurrent
DML is supported.
</p>
<p>
The
<a class="link" href="privileges-provided.html#priv_create-tablespace">
<code class="literal">
CREATE TABLESPACE
</code>
</a>
privilege is
required to rename an
<code class="literal">
InnoDB
</code>
general
tablespace.
</p>
<p>
The
<code class="literal">
AUTOEXTEND_SIZE
</code>
option defines the amount
by which
<code class="literal">
InnoDB
</code>
extends the size of a
tablespace when it becomes full. The setting must be a multiple of
4MB. The default setting is 0, which causes the tablespace to be
extended according to the implicit default behavior. For more
information, see
<a class="xref" href="innodb-tablespace-autoextend-size.html" title="17.6.3.9 Tablespace AUTOEXTEND_SIZE Configuration">
Section 17.6.3.9, “Tablespace AUTOEXTEND_SIZE Configuration”
</a>
.
</p>
<p>
The
<code class="literal">
ENCRYPTION
</code>
clause enables or disables
page-level data encryption for an
<code class="literal">
InnoDB
</code>
general tablespace or the
<code class="literal">
mysql
</code>
system
tablespace.
</p>
<p>
A keyring plugin must be installed and configured before
encryption can be enabled.
</p>
<p>
If the
<a class="link" href="server-system-variables.html#sysvar_table_encryption_privilege_check">
<code class="literal">
table_encryption_privilege_check
</code>
</a>
variable is enabled, the
<a class="link" href="privileges-provided.html#priv_table-encryption-admin">
<code class="literal">
TABLE_ENCRYPTION_ADMIN
</code>
</a>
privilege is
required to alter a general tablespace with an
<code class="literal">
ENCRYPTION
</code>
clause setting that differs from the
<a class="link" href="server-system-variables.html#sysvar_default_table_encryption">
<code class="literal">
default_table_encryption
</code>
</a>
setting.
</p>
<p>
Enabling encryption for a general tablespace fails if any table in
the tablespace belongs to a schema defined with
<code class="literal">
DEFAULT
ENCRYPTION='N'
</code>
. Similarly, disabling encryption fails if
any table in the general tablespace belongs to a schema defined
with
<code class="literal">
DEFAULT ENCRYPTION='Y'
</code>
.
</p>
<p>
If an
<a class="link" href="alter-tablespace.html" title="15.1.10 ALTER TABLESPACE Statement">
<code class="literal">
ALTER TABLESPACE
</code>
</a>
statement
executed on a general tablespace does not include an
<code class="literal">
ENCRYPTION
</code>
clause, the tablespace retains its
current encryption status, regardless of the
<a class="link" href="server-system-variables.html#sysvar_default_table_encryption">
<code class="literal">
default_table_encryption
</code>
</a>
setting.
</p>
<p>
When a general tablespace or the
<code class="literal">
mysql
</code>
system
tablespace is encrypted, all tables residing in the tablespace are
encrypted. Likewise, a table created in an encrypted tablespace is
encrypted.
</p>
<p>
The
<code class="literal">
INPLACE
</code>
algorithm is used when altering the
<code class="literal">
ENCRYPTION
</code>
attribute of a general tablespace or
the
<code class="literal">
mysql
</code>
system tablespace. The
<code class="literal">
INPLACE
</code>
algorithm permits concurrent DML on
tables that reside in the tablespace. Concurrent DDL is blocked.
</p>
<p>
For more information, see
<a class="xref" href="innodb-data-encryption.html" title="17.13 InnoDB Data-at-Rest Encryption">
Section 17.13, “InnoDB Data-at-Rest Encryption”
</a>
.
</p>
<p>
The
<code class="literal">
ENGINE_ATTRIBUTE
</code>
option is used to specify
tablespace attributes for primary storage engines. The option is
reserved for future use.
</p>
<p>
The value assigned to this option is a string literal containing a
valid JSON document or an empty string (''). Invalid JSON is
rejected.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa91544638"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">ALTER</span> <span class="token keyword">TABLESPACE</span> ts1 <span class="token keyword">ENGINE_ATTRIBUTE</span><span class="token operator">=</span><span class="token string">'{"<em class="replaceable">key</em>":"<em class="replaceable">value</em>"}'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
<code class="literal">
ENGINE_ATTRIBUTE
</code>
values can be repeated without
error. In this case, the last specified value is used.
</p>
<p>
<code class="literal">
ENGINE_ATTRIBUTE
</code>
values are not checked by the
server, nor are they cleared when the table's storage engine
is changed.
</p>
<p>
It is not permitted to alter an individual element of a JSON
attribute value. You can only add or replace an attribute.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-table-characteristics.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="performance-schema-table-characteristics">
</a>
29.11 Performance Schema General Table Characteristics
</h2>
</div>
</div>
</div>
<p>
The name of the
<code class="literal">
performance_schema
</code>
database is
lowercase, as are the names of tables within it. Queries should
specify the names in lowercase.
</p>
<a class="indexterm" name="idm46045074401328">
</a>
<a class="indexterm" name="idm46045074399824">
</a>
<p>
Many tables in the
<code class="literal">
performance_schema
</code>
database
are read only and cannot be modified:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa43342474"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">TRUNCATE</span> <span class="token keyword">TABLE</span> performance_schema<span class="token punctuation">.</span>setup_instruments<span class="token punctuation">;</span>
<span class="token output">ERROR 1683 (HY000)<span class="token punctuation">:</span> Invalid performance_schema usage.</span></code></pre>
</div>
<p>
Some of the setup tables have columns that can be modified to
affect Performance Schema operation; some also permit rows to be
inserted or deleted. Truncation is permitted to clear collected
events, so
<a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
<code class="literal">
TRUNCATE TABLE
</code>
</a>
can be
used on tables containing those kinds of information, such as
tables named with a prefix of
<code class="literal">
events_waits_
</code>
.
</p>
<p>
Summary tables can be truncated with
<a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
<code class="literal">
TRUNCATE
TABLE
</code>
</a>
. Generally, the effect is to reset the summary
columns to 0 or
<code class="literal">
NULL
</code>
, not to remove rows. This
enables you to clear collected values and restart aggregation.
That might be useful, for example, after you have made a runtime
configuration change. Exceptions to this truncation behavior are
noted in individual summary table sections.
</p>
<p>
Privileges are as for other databases and tables:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
To retrieve from
<code class="literal">
performance_schema
</code>
tables,
you must have the
<a class="link" href="privileges-provided.html#priv_select">
<code class="literal">
SELECT
</code>
</a>
privilege.
</p>
</li>
<li class="listitem">
<p>
To change those columns that can be modified, you must have
the
<a class="link" href="privileges-provided.html#priv_update">
<code class="literal">
UPDATE
</code>
</a>
privilege.
</p>
</li>
<li class="listitem">
<p>
To truncate tables that can be truncated, you must have the
<a class="link" href="privileges-provided.html#priv_drop">
<code class="literal">
DROP
</code>
</a>
privilege.
</p>
</li>
</ul>
</div>
<p>
Because only a limited set of privileges apply to Performance
Schema tables, attempts to use
<code class="literal">
GRANT ALL
</code>
as
shorthand for granting privileges at the database or table level
fail with an error:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa73405343"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">GRANT</span> <span class="token keyword">ALL</span> <span class="token keyword">ON</span> performance_schema<span class="token punctuation">.</span><span class="token operator">*</span>
<span class="token keyword">TO</span> <span class="token string">'u1'</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1044 (42000)<span class="token punctuation">:</span> Access denied for user 'root'@'localhost'
to database 'performance_schema'</span>
<span class="token prompt">mysql></span> <span class="token keyword">GRANT</span> <span class="token keyword">ALL</span> <span class="token keyword">ON</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">TO</span> <span class="token string">'u2'</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1044 (42000)<span class="token punctuation">:</span> Access denied for user 'root'@'localhost'
to database 'performance_schema'</span></code></pre>
</div>
<p>
Instead, grant exactly the desired privileges:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa3700637"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span> <span class="token keyword">ON</span> performance_schema<span class="token punctuation">.</span><span class="token operator">*</span>
<span class="token keyword">TO</span> <span class="token string">'u1'</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.03 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">GRANT</span> <span class="token keyword">SELECT</span><span class="token punctuation">,</span> <span class="token keyword">UPDATE</span> <span class="token keyword">ON</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">TO</span> <span class="token string">'u2'</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.02 sec)</span></code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/changing-mysql-user.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="changing-mysql-user">
</a>
8.1.5 How to Run MySQL as a Normal User
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045252618832">
</a>
<a class="indexterm" name="idm46045252617376">
</a>
<p>
On Windows, you can run the server as a Windows service using a
normal user account.
</p>
<p>
On Linux, for installations performed using a MySQL repository or
RPM packages, the MySQL server
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
should be
started by the local
<code class="literal">
mysql
</code>
operating system
user. Starting by another operating system user is not supported
by the init scripts that are included as part of the MySQL
repositories.
</p>
<p>
On Unix (or Linux for installations performed using
<code class="filename">
tar.gz
</code>
packages) , the MySQL server
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
can be started and run by any user.
However, you should avoid running the server as the Unix
<code class="literal">
root
</code>
user for security reasons. To change
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
to run as a normal unprivileged Unix
user
<em class="replaceable">
<code>
user_name
</code>
</em>
, you must do the
following:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Stop the server if it is running (use
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin
shutdown
</strong>
</span>
</a>
).
</p>
</li>
<li class="listitem">
<p>
Change the database directories and files so that
<em class="replaceable">
<code>
user_name
</code>
</em>
has privileges to read
and write files in them (you might need to do this as the Unix
<code class="literal">
root
</code>
user):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa10721238"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">chown</span> <span class="token property">-R</span> <em class="replaceable">user_name</em> <em class="replaceable">/path/to/mysql/datadir</em></code></pre>
</div>
<p>
If you do not do this, the server cannot access databases or
tables when it runs as
<em class="replaceable">
<code>
user_name
</code>
</em>
.
</p>
<p>
If directories or files within the MySQL data directory are
symbolic links,
<code class="literal">
chown -R
</code>
might not follow
symbolic links for you. If it does not, you must also follow
those links and change the directories and files they point
to.
</p>
</li>
<li class="listitem">
<p>
Start the server as user
<em class="replaceable">
<code>
user_name
</code>
</em>
.
Another alternative is to start
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
as
the Unix
<code class="literal">
root
</code>
user and use the
<a class="link" href="server-options.html#option_mysqld_user">
<code class="option">
--user=
<em class="replaceable">
<code>
user_name
</code>
</em>
</code>
</a>
option.
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
starts, then switches to run
as the Unix user
<em class="replaceable">
<code>
user_name
</code>
</em>
before
accepting any connections.
</p>
</li>
<li class="listitem">
<p>
To start the server as the given user automatically at system
startup time, specify the user name by adding a
<code class="literal">
user
</code>
option to the
<code class="literal">
[mysqld]
</code>
group of the
<code class="filename">
/etc/my.cnf
</code>
option file or the
<code class="filename">
my.cnf
</code>
option file in the server's data
directory. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa14263860"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">user</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">user_name</em></span></code></pre>
</div>
</li>
</ol>
</div>
<p>
If your Unix machine itself is not secured, you should assign
passwords to the MySQL
<code class="literal">
root
</code>
account in the
grant tables. Otherwise, any user with a login account on that
machine can run the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client with a
<a class="link" href="mysql-command-options.html#option_mysql_user">
<code class="option">
--user=root
</code>
</a>
option and perform any
operation. (It is a good idea to assign passwords to MySQL
accounts in any case, but especially so when other login accounts
exist on the server host.) See
<a class="xref" href="default-privileges.html" title="2.9.4 Securing the Initial MySQL Account">
Section 2.9.4, “Securing the Initial MySQL Account”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/all-subqueries.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="all-subqueries">
</a>
15.2.15.4 Subqueries with ALL
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045179970096">
</a>
<a class="indexterm" name="idm46045179968608">
</a>
<p>
Syntax:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa14529206"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><em class="replaceable">operand</em> <em class="replaceable">comparison_operator</em> <span class="token keyword">ALL</span> <span class="token punctuation">(</span><em class="replaceable">subquery</em><span class="token punctuation">)</span></code></pre>
</div>
<p>
The word
<code class="literal">
ALL
</code>
, which must follow a comparison
operator, means
<span class="quote">
“
<span class="quote">
return
<code class="literal">
TRUE
</code>
if the
comparison is
<code class="literal">
TRUE
</code>
for
<code class="literal">
ALL
</code>
of the values in the column that the subquery returns.
</span>
”
</span>
For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa74113763"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> s1 <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> s1 <span class="token operator">></span> <span class="token keyword">ALL</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> s1 <span class="token keyword">FROM</span> t2<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Suppose that there is a row in table
<code class="literal">
t1
</code>
containing
<code class="literal">
(10)
</code>
. The expression is
<code class="literal">
TRUE
</code>
if table
<code class="literal">
t2
</code>
contains
<code class="literal">
(-5,0,+5)
</code>
because
<code class="literal">
10
</code>
is
greater than all three values in
<code class="literal">
t2
</code>
. The
expression is
<code class="literal">
FALSE
</code>
if table
<code class="literal">
t2
</code>
contains
<code class="literal">
(12,6,NULL,-100)
</code>
because there is a single
value
<code class="literal">
12
</code>
in table
<code class="literal">
t2
</code>
that
is greater than
<code class="literal">
10
</code>
. The expression is
<span class="emphasis">
<em>
unknown
</em>
</span>
(that is,
<code class="literal">
NULL
</code>
)
if table
<code class="literal">
t2
</code>
contains
<code class="literal">
(0,NULL,1)
</code>
.
</p>
<p>
Finally, the expression is
<code class="literal">
TRUE
</code>
if table
<code class="literal">
t2
</code>
is empty. So, the following expression is
<code class="literal">
TRUE
</code>
when table
<code class="literal">
t2
</code>
is
empty:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa80536358"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> <span class="token number">1</span> <span class="token operator">></span> <span class="token keyword">ALL</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> s1 <span class="token keyword">FROM</span> t2<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
But this expression is
<code class="literal">
NULL
</code>
when table
<code class="literal">
t2
</code>
is empty:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa72418902"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> <span class="token number">1</span> <span class="token operator">></span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> s1 <span class="token keyword">FROM</span> t2<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
In addition, the following expression is
<code class="literal">
NULL
</code>
when table
<code class="literal">
t2
</code>
is empty:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa32112493"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> <span class="token number">1</span> <span class="token operator">></span> <span class="token keyword">ALL</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token function">MAX</span><span class="token punctuation">(</span>s1<span class="token punctuation">)</span> <span class="token keyword">FROM</span> t2<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
In general,
<span class="emphasis">
<em>
tables containing
<code class="literal">
NULL
</code>
values
</em>
</span>
and
<span class="emphasis">
<em>
empty tables
</em>
</span>
are
<span class="quote">
“
<span class="quote">
edge cases.
</span>
”
</span>
When writing subqueries, always
consider whether you have taken those two possibilities into
account.
</p>
<p>
<code class="literal">
NOT IN
</code>
is an alias for
<code class="literal">
<>
ALL
</code>
. Thus, these two statements are the same:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa26925716"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> s1 <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> s1 <span class="token operator"><></span> <span class="token keyword">ALL</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> s1 <span class="token keyword">FROM</span> t2<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> s1 <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> s1 <span class="token operator">NOT</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> s1 <span class="token keyword">FROM</span> t2<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
As with
<code class="literal">
IN
</code>
,
<code class="literal">
ANY
</code>
, and
<code class="literal">
SOME
</code>
, you can use
<a class="link" href="table.html" title="15.2.16 TABLE Statement">
<code class="literal">
TABLE
</code>
</a>
with
<code class="literal">
ALL
</code>
and
<code class="literal">
NOT IN
</code>
provided that the following two
conditions are met:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The table in the subquery contains only one column
</p>
</li>
<li class="listitem">
<p>
The subquery does not depend on a column expression
</p>
</li>
</ul>
</div>
<p>
For example, assuming that table
<code class="literal">
t2
</code>
consists
of a single column, the last two statements shown previously can
be written using
<code class="literal">
TABLE t2
</code>
like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa44416707"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> s1 <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> s1 <span class="token operator"><></span> <span class="token keyword">ALL</span> <span class="token punctuation">(</span><span class="token keyword">TABLE</span> t2<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> s1 <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> s1 <span class="token operator">NOT</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token keyword">TABLE</span> t2<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
A query such as
<code class="literal">
SELECT * FROM t1 WHERE 1 > ALL
(SELECT MAX(s1) FROM t2);
</code>
cannot be written using
<code class="literal">
TABLE t2
</code>
because the subquery depends on a
column expression.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/optimize-multi-tables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="optimize-multi-tables">
</a>
10.4.3 Optimizing for Many Tables
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="table-cache.html">
10.4.3.1 How MySQL Opens and Closes Tables
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="creating-many-tables.html">
10.4.3.2 Disadvantages of Creating Many Tables in the Same Database
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045226732304">
</a>
<p>
Some techniques for keeping individual queries fast involve
splitting data across many tables. When the number of tables
runs into the thousands or even millions, the overhead of
dealing with all these tables becomes a new performance
consideration.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-change-buffer.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="innodb-change-buffer">
</a>
17.5.2 Change Buffer
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045167013264">
</a>
<a class="indexterm" name="idm46045167011776">
</a>
<p>
The change buffer is a special data structure that caches changes to
<a class="link" href="glossary.html#glos_secondary_index" title="secondary index">
secondary index
</a>
pages
when those pages are not in the
<a class="link" href="glossary.html#glos_buffer_pool" title="buffer pool">
buffer pool
</a>
. The buffered
changes, which may result from
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
,
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
, or
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
operations (DML), are merged
later when the pages are loaded into the buffer pool by other read
operations.
</p>
<div class="figure">
<a name="innodb-change-buffer-diagram">
</a>
<p class="title">
<b>
Figure 17.3 Change Buffer
</b>
</p>
<div class="figure-contents">
<div class="mediaobject">
<img alt="Content is described in the surrounding text." src="images/innodb-change-buffer.png" style="width: 100%; max-width: 581px;"/>
</div>
</div>
</div>
<br class="figure-break"/>
<p>
Unlike
<a class="link" href="glossary.html#glos_clustered_index" title="clustered index">
clustered
indexes
</a>
, secondary indexes are usually nonunique, and inserts
into secondary indexes happen in a relatively random order.
Similarly, deletes and updates may affect secondary index pages that
are not adjacently located in an index tree. Merging cached changes
at a later time, when affected pages are read into the buffer pool
by other operations, avoids substantial random access I/O that would
be required to read secondary index pages into the buffer pool from
disk.
</p>
<p>
Periodically, the purge operation that runs when the system is
mostly idle, or during a slow shutdown, writes the updated index
pages to disk. The purge operation can write disk blocks for a
series of index values more efficiently than if each value were
written to disk immediately.
</p>
<p>
Change buffer merging may take several hours when there are many
affected rows and numerous secondary indexes to update. During this
time, disk I/O is increased, which can cause a significant slowdown
for disk-bound queries. Change buffer merging may also continue to
occur after a transaction is committed, and even after a server
shutdown and restart (see
<a class="xref" href="forcing-innodb-recovery.html" title="17.20.3 Forcing InnoDB Recovery">
Section 17.20.3, “Forcing InnoDB Recovery”
</a>
for more information).
</p>
<p>
In memory, the change buffer occupies part of the buffer pool. On
disk, the change buffer is part of the system tablespace, where
index changes are buffered when the database server is shut down.
</p>
<p>
The type of data cached in the change buffer is governed by the
<a class="link" href="innodb-parameters.html#sysvar_innodb_change_buffering">
<code class="literal">
innodb_change_buffering
</code>
</a>
variable.
For more information, see
<a class="xref" href="innodb-change-buffer.html#innodb-change-buffer-configuration" title="Configuring Change Buffering">
Configuring Change Buffering
</a>
. You can also
configure the maximum change buffer size. For more information, see
<a class="xref" href="innodb-change-buffer.html#innodb-change-buffer-maximum-size" title="Configuring the Change Buffer Maximum Size">
Configuring the Change Buffer Maximum Size
</a>
.
</p>
<p>
Change buffering is not supported for a secondary index if the index
contains a descending index column or if the primary key includes a
descending index column.
</p>
<p>
For answers to frequently asked questions about the change buffer,
see
<a class="xref" href="faqs-innodb-change-buffer.html" title="A.16 MySQL 8.4 FAQ: InnoDB Change Buffer">
Section A.16, “MySQL 8.4 FAQ: InnoDB Change Buffer”
</a>
.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="innodb-change-buffer-configuration">
</a>
Configuring Change Buffering
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045166986640">
</a>
<a class="indexterm" name="idm46045166985568">
</a>
<a class="indexterm" name="idm46045166984080">
</a>
<p>
When
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
,
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
, and
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
operations are performed on
a table, the values of indexed columns (particularly the values of
secondary keys) are often in an unsorted order, requiring
substantial I/O to bring secondary indexes up to date. The
<a class="link" href="glossary.html#glos_change_buffer" title="change buffer">
change buffer
</a>
caches
changes to secondary index entries when the relevant
<a class="link" href="glossary.html#glos_page" title="page">
page
</a>
is not in the
<a class="link" href="glossary.html#glos_buffer_pool" title="buffer pool">
buffer pool
</a>
, thus avoiding
expensive I/O operations by not immediately reading in the page
from disk. The buffered changes are merged when the page is loaded
into the buffer pool, and the updated page is later flushed to
disk. The
<code class="literal">
InnoDB
</code>
main thread merges buffered
changes when the server is nearly idle, and during a
<a class="link" href="glossary.html#glos_slow_shutdown" title="slow shutdown">
slow shutdown
</a>
.
</p>
<p>
Because it can result in fewer disk reads and writes, change
buffering is most valuable for workloads that are I/O-bound; for
example, applications with a high volume of DML operations such as
bulk inserts benefit from change buffering.
</p>
<p>
However, the change buffer occupies a part of the buffer pool,
reducing the memory available to cache data pages. If the working
set almost fits in the buffer pool, or if your tables have
relatively few secondary indexes, it may be useful to disable
change buffering. If the working data set fits entirely within the
buffer pool, change buffering does not impose extra overhead,
because it only applies to pages that are not in the buffer pool.
</p>
<p>
The
<a class="link" href="innodb-parameters.html#sysvar_innodb_change_buffering">
<code class="literal">
innodb_change_buffering
</code>
</a>
variable controls the extent to which
<code class="literal">
InnoDB
</code>
performs change buffering. You can enable or disable buffering for
inserts, delete operations (when index records are initially
marked for deletion) and purge operations (when index records are
physically deleted). An update operation is a combination of an
insert and a delete. The default
<a class="link" href="innodb-parameters.html#sysvar_innodb_change_buffering">
<code class="literal">
innodb_change_buffering
</code>
</a>
value is
<code class="literal">
none
</code>
, and permitted values are described within
the
<a class="link" href="innodb-parameters.html#sysvar_innodb_change_buffering">
<code class="literal">
innodb_change_buffering
</code>
</a>
documentation.
</p>
<p>
You can set the
<a class="link" href="innodb-parameters.html#sysvar_innodb_change_buffering">
<code class="literal">
innodb_change_buffering
</code>
</a>
variable
in the MySQL option file (
<code class="literal">
my.cnf
</code>
or
<code class="literal">
my.ini
</code>
) or change it dynamically with the
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET GLOBAL
</code>
</a>
statement, which requires privileges sufficient to set global
system variables. See
<a class="xref" href="system-variable-privileges.html" title="7.1.9.1 System Variable Privileges">
Section 7.1.9.1, “System Variable Privileges”
</a>
. Changing the setting
affects the buffering of new operations; the merging of existing
buffered entries is not affected.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="innodb-change-buffer-maximum-size">
</a>
Configuring the Change Buffer Maximum Size
</h4>
</div>
</div>
</div>
<p>
The
<a class="link" href="innodb-parameters.html#sysvar_innodb_change_buffer_max_size">
<code class="literal">
innodb_change_buffer_max_size
</code>
</a>
variable permits configuring the maximum size of the change buffer
as a percentage of the total size of the buffer pool. By default,
<a class="link" href="innodb-parameters.html#sysvar_innodb_change_buffer_max_size">
<code class="literal">
innodb_change_buffer_max_size
</code>
</a>
is
set to 25. The maximum setting is 50.
</p>
<p>
Consider increasing
<a class="link" href="innodb-parameters.html#sysvar_innodb_change_buffer_max_size">
<code class="literal">
innodb_change_buffer_max_size
</code>
</a>
on
a MySQL server with heavy insert, update, and delete activity,
where change buffer merging does not keep pace with new change
buffer entries, causing the change buffer to reach its maximum
size limit.
</p>
<p>
Consider decreasing
<a class="link" href="innodb-parameters.html#sysvar_innodb_change_buffer_max_size">
<code class="literal">
innodb_change_buffer_max_size
</code>
</a>
on
a MySQL server with static data used for reporting, or if the
change buffer consumes too much of the memory space shared with
the buffer pool, causing pages to age out of the buffer pool
sooner than desired.
</p>
<p>
Test different settings with a representative workload to
determine an optimal configuration. The
<a class="link" href="innodb-parameters.html#sysvar_innodb_change_buffer_max_size">
<code class="literal">
innodb_change_buffer_max_size
</code>
</a>
variable is dynamic, which permits modifying the setting without
restarting the server.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="innodb-change-buffer-monitoring">
</a>
Monitoring the Change Buffer
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045166949168">
</a>
<a class="indexterm" name="idm46045166947680">
</a>
<p>
The following options are available for change buffer monitoring:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
InnoDB
</code>
Standard Monitor output includes
change buffer status information. To view monitor data, issue
the
<code class="literal">
SHOW ENGINE INNODB STATUS
</code>
statement.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa39265303"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">ENGINE</span> INNODB <span class="token keyword">STATUS</span>\G</code></pre>
</div>
<p>
Change buffer status information is located under the
<code class="literal">
INSERT BUFFER AND ADAPTIVE HASH INDEX
</code>
heading and appears similar to the following:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa81429649"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token comment" spellcheck="true">-------------------------------------</span>
<span class="token keyword">INSERT</span> BUFFER <span class="token operator">AND</span> ADAPTIVE <span class="token keyword">HASH</span> <span class="token keyword">INDEX</span>
<span class="token comment" spellcheck="true">-------------------------------------</span>
Ibuf: size <span class="token number">1</span><span class="token punctuation">,</span> free <span class="token keyword">list</span> len <span class="token number">0</span><span class="token punctuation">,</span> seg size <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">0</span> merges
merged operations:
<span class="token keyword">insert</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token keyword">delete</span> mark <span class="token number">0</span><span class="token punctuation">,</span> <span class="token keyword">delete</span> <span class="token number">0</span>
discarded operations:
<span class="token keyword">insert</span> <span class="token number">0</span><span class="token punctuation">,</span> <span class="token keyword">delete</span> mark <span class="token number">0</span><span class="token punctuation">,</span> <span class="token keyword">delete</span> <span class="token number">0</span>
<span class="token keyword">Hash</span> <span class="token keyword">table</span> size <span class="token number">4425293</span><span class="token punctuation">,</span> used cells <span class="token number">32</span><span class="token punctuation">,</span> node heap has <span class="token number">1</span> <span class="token function">buffer</span><span class="token punctuation">(</span>s<span class="token punctuation">)</span>
<span class="token number">13577.57</span> <span class="token keyword">hash</span> searches<span class="token operator">/</span>s<span class="token punctuation">,</span> <span class="token number">202.47</span> non<span class="token operator">-</span><span class="token keyword">hash</span> searches<span class="token operator">/</span>s</code></pre>
</div>
<p>
For more information, see
<a class="xref" href="innodb-standard-monitor.html" title="17.17.3 InnoDB Standard Monitor and Lock Monitor Output">
Section 17.17.3, “InnoDB Standard Monitor and Lock Monitor Output”
</a>
.
</p>
</li>
<li class="listitem">
<p>
The Information Schema
<a class="link" href="information-schema-innodb-metrics-table.html" title="28.4.21 The INFORMATION_SCHEMA INNODB_METRICS Table">
<code class="literal">
INNODB_METRICS
</code>
</a>
table provides
most of the data points found in
<code class="literal">
InnoDB
</code>
Standard Monitor output plus other data points. To view change
buffer metrics and a description of each, issue the following
query:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa40790151"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token keyword">NAME</span><span class="token punctuation">,</span> <span class="token keyword">COMMENT</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_METRICS <span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'%ibuf%'</span>\G</code></pre>
</div>
<p>
See
<a class="xref" href="innodb-information-schema-metrics-table.html" title="17.15.6 InnoDB INFORMATION_SCHEMA Metrics Table">
Section 17.15.6, “InnoDB INFORMATION_SCHEMA Metrics Table”
</a>
.
</p>
</li>
<li class="listitem">
<p>
The Information Schema
<a class="link" href="information-schema-innodb-buffer-page-table.html" title="28.4.2 The INFORMATION_SCHEMA INNODB_BUFFER_PAGE Table">
<code class="literal">
INNODB_BUFFER_PAGE
</code>
</a>
table provides
metadata about each page in the buffer pool, including change
buffer index and change buffer bitmap pages. Change buffer
pages are identified by
<code class="literal">
PAGE_TYPE
</code>
.
<code class="literal">
IBUF_INDEX
</code>
is the page type for change
buffer index pages, and
<code class="literal">
IBUF_BITMAP
</code>
is the
page type for change buffer bitmap pages.
</p>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
Querying the
<a class="link" href="information-schema-innodb-buffer-page-table.html" title="28.4.2 The INFORMATION_SCHEMA INNODB_BUFFER_PAGE Table">
<code class="literal">
INNODB_BUFFER_PAGE
</code>
</a>
table can introduce significant performance overhead. To
avoid impacting performance, reproduce the issue you want to
investigate on a test instance and run your queries on the
test instance.
</p>
</div>
<p>
For example, you can query the
<a class="link" href="information-schema-innodb-buffer-page-table.html" title="28.4.2 The INFORMATION_SCHEMA INNODB_BUFFER_PAGE Table">
<code class="literal">
INNODB_BUFFER_PAGE
</code>
</a>
table to
determine the approximate number of
<code class="literal">
IBUF_INDEX
</code>
and
<code class="literal">
IBUF_BITMAP
</code>
pages as a percentage of total
buffer pool pages.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa49071310"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_BUFFER_PAGE
<span class="token keyword">WHERE</span> PAGE_TYPE <span class="token operator">LIKE</span> <span class="token string">'IBUF%'</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> change_buffer_pages<span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token operator">*</span><span class="token punctuation">)</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_BUFFER_PAGE<span class="token punctuation">)</span> <span class="token keyword">AS</span> total_pages<span class="token punctuation">,</span>
<span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token punctuation">(</span><span class="token punctuation">(</span>change_buffer_pages<span class="token operator">/</span>total_pages<span class="token punctuation">)</span><span class="token operator">*</span><span class="token number">100</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token keyword">AS</span> change_buffer_page_percentage<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> change_buffer_pages <span class="token punctuation">|</span> total_pages <span class="token punctuation">|</span> change_buffer_page_percentage <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 25 <span class="token punctuation">|</span> 8192 <span class="token punctuation">|</span> 0.3052 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
For information about other data provided by the
<a class="link" href="information-schema-innodb-buffer-page-table.html" title="28.4.2 The INFORMATION_SCHEMA INNODB_BUFFER_PAGE Table">
<code class="literal">
INNODB_BUFFER_PAGE
</code>
</a>
table, see
<a class="xref" href="information-schema-innodb-buffer-page-table.html" title="28.4.2 The INFORMATION_SCHEMA INNODB_BUFFER_PAGE Table">
Section 28.4.2, “The INFORMATION_SCHEMA INNODB_BUFFER_PAGE Table”
</a>
.
For related usage information, see
<a class="xref" href="innodb-information-schema-buffer-pool-tables.html" title="17.15.5 InnoDB INFORMATION_SCHEMA Buffer Pool Tables">
Section 17.15.5, “InnoDB INFORMATION_SCHEMA Buffer Pool Tables”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema.html" title="Chapter 29 MySQL Performance Schema">
Performance Schema
</a>
provides change buffer mutex wait instrumentation for advanced
performance monitoring. To view change buffer instrumentation,
issue the following query:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa74676904"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>setup_instruments
<span class="token keyword">WHERE</span> <span class="token keyword">NAME</span> <span class="token operator">LIKE</span> <span class="token string">'%wait/synch/mutex/innodb/ibuf%'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NAME <span class="token punctuation">|</span> ENABLED <span class="token punctuation">|</span> TIMED <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> wait/synch/mutex/innodb/ibuf_bitmap_mutex <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> wait/synch/mutex/innodb/ibuf_mutex <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> wait/synch/mutex/innodb/ibuf_pessimistic_insert_mutex <span class="token punctuation">|</span> YES <span class="token punctuation">|</span> YES <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
For information about monitoring
<code class="literal">
InnoDB
</code>
mutex waits, see
<a class="xref" href="monitor-innodb-mutex-waits-performance-schema.html" title="17.16.2 Monitoring InnoDB Mutex Waits Using Performance Schema">
Section 17.16.2, “Monitoring InnoDB Mutex Waits Using Performance Schema”
</a>
.
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-physical-structure.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="innodb-physical-structure">
</a>
17.6.2.2 The Physical Structure of an InnoDB Index
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045165840144">
</a>
<a class="indexterm" name="idm46045165838688">
</a>
<a class="indexterm" name="idm46045165837200">
</a>
<a class="indexterm" name="idm46045165835712">
</a>
<a class="indexterm" name="idm46045165834640">
</a>
<p>
With the exception of spatial indexes,
<code class="literal">
InnoDB
</code>
indexes are
<a class="link" href="glossary.html#glos_b_tree" title="B-tree">
B-tree
</a>
data
structures. Spatial indexes use
<a class="link" href="glossary.html#glos_r_tree" title="R-tree">
R-trees
</a>
, which are
specialized data structures for indexing multi-dimensional data.
Index records are stored in the leaf pages of their B-tree or
R-tree data structure. The default size of an index page is 16KB.
The page size is determined by the
<a class="link" href="innodb-parameters.html#sysvar_innodb_page_size">
<code class="literal">
innodb_page_size
</code>
</a>
setting when the
MySQL instance is initialized. See
<a class="xref" href="innodb-init-startup-configuration.html" title="17.8.1 InnoDB Startup Configuration">
Section 17.8.1, “InnoDB Startup Configuration”
</a>
.
</p>
<p>
When new records are inserted into an
<code class="literal">
InnoDB
</code>
<a class="link" href="glossary.html#glos_clustered_index" title="clustered index">
clustered index
</a>
,
<code class="literal">
InnoDB
</code>
tries to leave 1/16 of the page free for
future insertions and updates of the index records. If index
records are inserted in a sequential order (ascending or
descending), the resulting index pages are about 15/16 full. If
records are inserted in a random order, the pages are from 1/2 to
15/16 full.
</p>
<p>
<code class="literal">
InnoDB
</code>
performs a bulk load when creating or
rebuilding B-tree indexes. This method of index creation is known
as a sorted index build. The
<a class="link" href="innodb-parameters.html#sysvar_innodb_fill_factor">
<code class="literal">
innodb_fill_factor
</code>
</a>
variable
defines the percentage of space on each B-tree page that is filled
during a sorted index build, with the remaining space reserved for
future index growth. Sorted index builds are not supported for
spatial indexes. For more information, see
<a class="xref" href="sorted-index-builds.html" title="17.6.2.3 Sorted Index Builds">
Section 17.6.2.3, “Sorted Index Builds”
</a>
. An
<a class="link" href="innodb-parameters.html#sysvar_innodb_fill_factor">
<code class="literal">
innodb_fill_factor
</code>
</a>
setting of 100
leaves 1/16 of the space in clustered index pages free for future
index growth.
</p>
<p>
If the fill factor of an
<code class="literal">
InnoDB
</code>
index page
drops below the
<code class="literal">
MERGE_THRESHOLD
</code>
, which is 50%
by default if not specified,
<code class="literal">
InnoDB
</code>
tries to
contract the index tree to free the page. The
<code class="literal">
MERGE_THRESHOLD
</code>
setting applies to both B-tree
and R-tree indexes. For more information, see
<a class="xref" href="index-page-merge-threshold.html" title="17.8.11 Configuring the Merge Threshold for Index Pages">
Section 17.8.11, “Configuring the Merge Threshold for Index Pages”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-replication-group-communication-information-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="performance-schema-replication-group-communication-information-table">
</a>
29.12.11.10 The replication_group_communication_information Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045071146480">
</a>
<a class="indexterm" name="idm46045071144960">
</a>
<p>
This table shows group configuration options for the whole
replication group. The table is available only when Group
Replication is installed.
</p>
<p>
The
<code class="literal">
replication_group_communication_information
</code>
table has these columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
WRITE_CONCURRENCY
</code>
</p>
<p>
The maximum number of consensus instances that the group
can execute in parallel. The default value is 10. See
<a class="xref" href="group-replication-group-write-consensus.html" title="20.5.1.3 Using Group Replication Group Write Consensus">
Section 20.5.1.3, “Using Group Replication Group Write Consensus”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PROTOCOL_VERSION
</code>
</p>
<p>
The Group Replication communication protocol version,
which determines what messaging capabilities are used.
This is set to accommodate the oldest MySQL Server version
that you want the group to support. See
<a class="xref" href="group-replication-communication-protocol.html" title="20.5.1.4 Setting a Group's Communication Protocol Version">
Section 20.5.1.4, “Setting a Group's Communication Protocol Version”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WRITE_CONSENSUS_LEADERS_PREFERRED
</code>
</p>
<p>
The leader or leaders that Group Replication has
instructed the group communication engine to use to drive
consensus. For a group in single-primary mode with the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_paxos_single_leader">
<code class="literal">
group_replication_paxos_single_leader
</code>
</a>
system variable set to
<code class="literal">
ON
</code>
and the
communication protocol version set to 8.0.27 or later, the
single consensus leader is the group's primary.
Otherwise, all group members are used as leaders, so they
are all shown here. See
<a class="xref" href="group-replication-single-consensus-leader.html" title="20.7.3 Single Consensus Leader">
Section 20.7.3, “Single Consensus Leader”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WRITE_CONSENSUS_LEADERS_ACTUAL
</code>
</p>
<p>
The actual leader or leader that the group communication
engine is using to drive consensus. If a single consensus
leader is in use for the group, and the primary is
currently unhealthy, the group communication selects an
alternative consensus leader. In this situation, the group
member specified here can differ from the preferred group
member.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WRITE_CONSENSUS_SINGLE_LEADER_CAPABLE
</code>
</p>
<p>
Whether the replication group is capable of using a single
consensus leader. 1 means that the group was started with
the use of a single leader enabled
(
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_paxos_single_leader">
<code class="literal">
group_replication_paxos_single_leader
= ON
</code>
</a>
), and this is still shown if the value of
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_paxos_single_leader">
<code class="literal">
group_replication_paxos_single_leader
</code>
</a>
has since been changed on this group member. 0 means that
the group was started with single leader mode disabled
(
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_paxos_single_leader">
<code class="literal">
group_replication_paxos_single_leader
= OFF
</code>
</a>
), or has a Group Replication communication
protocol version that does not support the use of a single
consensus leader (prior to 8.0.27). This information is
only returned for group members in
<code class="literal">
ONLINE
</code>
or
<code class="literal">
RECOVERING
</code>
state.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MEMBER_FAILURE_SUSPICIONS_COUNT
</code>
</p>
<p>
The address of each group member paired with the number of
times this member has been seen as suspect by the local
node. This information is displayed in JSON format. For a
group with three members, the value of this column should
appear similar to what is shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-js"><div class="docs-select-all right" id="sa89961252"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-js"><span class="token punctuation">{</span>
<span class="token string">"d57da302-e404-4395-83b5-ff7cf9b7e055"</span><span class="token punctuation">:</span> <span class="token number">0</span><span class="token punctuation">,</span>
<span class="token string">"6ace9d39-a093-4fe0-b24d-bacbaa34c339"</span><span class="token punctuation">:</span> <span class="token number">10</span><span class="token punctuation">,</span>
<span class="token string">"9689c7c5-c71c-402a-a3a1-2f57bfc2ca62"</span><span class="token punctuation">:</span> <span class="token number">0</span>
<span class="token punctuation">}</span></code></pre>
</div>
</li>
</ul>
</div>
<p>
The
<code class="literal">
replication_group_communication_information
</code>
table has no indexes.
</p>
<p>
<a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
<code class="literal">
TRUNCATE TABLE
</code>
</a>
is not permitted
for the
<code class="literal">
replication_group_communication_information
</code>
table.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-ndbinfo-memoryusage.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-ndbinfo-memoryusage">
</a>
25.6.17.46 The ndbinfo memoryusage Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045088880272">
</a>
<p>
Querying this table provides information similar to that
provided by the
<a class="link" href="mysql-cluster-mgm-client-commands.html#ndbclient-report">
<code class="literal">
ALL REPORT
MemoryUsage
</code>
</a>
command in the
<a class="link" href="mysql-cluster-programs-ndb-mgm.html" title="25.5.5 ndb_mgm — The NDB Cluster Management Client">
<span class="command">
<strong>
ndb_mgm
</strong>
</span>
</a>
client, or logged by
<a class="ulink" href="/doc/ndb-internals/en/dump-command-1000.html" target="_top">
<code class="literal">
ALL DUMP
1000
</code>
</a>
.
</p>
<p>
The
<code class="literal">
memoryusage
</code>
table contains the following
columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
node_id
</code>
</p>
<p>
The node ID of this data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
memory_type
</code>
</p>
<p>
One of
<code class="literal">
Data memory
</code>
,
<code class="literal">
Index
memory
</code>
, or
<code class="literal">
Long message buffer
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
used
</code>
</p>
<p>
Number of bytes currently used for data memory or index
memory by this data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
used_pages
</code>
</p>
<p>
Number of pages currently used for data memory or index
memory by this data node; see text.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total
</code>
</p>
<p>
Total number of bytes of data memory or index memory
available for this data node; see text.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total_pages
</code>
</p>
<p>
Total number of memory pages available for data memory or
index memory on this data node; see text.
</p>
</li>
</ul>
</div>
<h5>
<a name="idm46045088859200">
</a>
Notes
</h5>
<p>
The
<code class="literal">
total
</code>
column represents the total amount
of memory in bytes available for the given resource (data memory
or index memory) on a particular data node. This number should
be approximately equal to the setting of the corresponding
configuration parameter in the
<code class="filename">
config.ini
</code>
file.
</p>
<p>
Suppose that the cluster has 2 data nodes having node IDs
<code class="literal">
5
</code>
and
<code class="literal">
6
</code>
, and the
<code class="filename">
config.ini
</code>
file contains the following:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa79085299"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[ndbd default]</span>
<span class="token constant">DataMemory</span> <span class="token attr-value"><span class="token punctuation">=</span> 1G</span>
<span class="token constant">IndexMemory</span> <span class="token attr-value"><span class="token punctuation">=</span> 1G</span></code></pre>
</div>
<p>
Suppose also that the value of the
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-longmessagebuffer">
<code class="literal">
LongMessageBuffer
</code>
</a>
configuration parameter is allowed to assume its default (64
MB).
</p>
<p>
The following query shows approximately the same values:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa24489953"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> node_id<span class="token punctuation">,</span> memory_type<span class="token punctuation">,</span> total
<span class="token operator">></span> <span class="token keyword">FROM</span> ndbinfo<span class="token punctuation">.</span>memoryusage<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> node_id <span class="token punctuation">|</span> memory_type <span class="token punctuation">|</span> total <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 5 <span class="token punctuation">|</span> Data memory <span class="token punctuation">|</span> 1073741824 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 5 <span class="token punctuation">|</span> Index memory <span class="token punctuation">|</span> 1074003968 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 5 <span class="token punctuation">|</span> Long message buffer <span class="token punctuation">|</span> 67108864 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 6 <span class="token punctuation">|</span> Data memory <span class="token punctuation">|</span> 1073741824 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 6 <span class="token punctuation">|</span> Index memory <span class="token punctuation">|</span> 1074003968 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 6 <span class="token punctuation">|</span> Long message buffer <span class="token punctuation">|</span> 67108864 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">6 rows in set (0.00 sec)</span></code></pre>
</div>
<p>
In this case, the
<code class="literal">
total
</code>
column values for
index memory are slightly higher than the value set of
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-indexmemory">
<code class="literal">
IndexMemory
</code>
</a>
due to
internal rounding.
</p>
<p>
For the
<code class="literal">
used_pages
</code>
and
<code class="literal">
total_pages
</code>
columns, resources are measured
in pages, which are 32K in size for
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-datamemory">
<code class="literal">
DataMemory
</code>
</a>
and 8K for
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-indexmemory">
<code class="literal">
IndexMemory
</code>
</a>
. For long
message buffer memory, the page size is 256 bytes.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/problems.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="problems">
</a>
B.3 Problems and Common Errors
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="what-is-crashing.html">
B.3.1 How to Determine What Is Causing a Problem
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="common-errors.html">
B.3.2 Common Errors When Using MySQL Programs
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="administration-issues.html">
B.3.3 Administration-Related Issues
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="query-issues.html">
B.3.4 Query-Related Issues
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="optimizer-issues.html">
B.3.5 Optimizer-Related Issues
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="table-definition-issues.html">
B.3.6 Table Definition-Related Issues
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="known-issues.html">
B.3.7 Known Issues in MySQL
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045054632400">
</a>
<a class="indexterm" name="idm46045054630944">
</a>
<p>
This section lists some common problems and error messages that
you may encounter. It describes how to determine the causes of the
problems and what to do to solve them.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-semisync-interface.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="replication-semisync-interface">
</a>
19.4.10.2 Configuring Semisynchronous Replication
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045136179920">
</a>
<p>
When you install the source and replica plugins for
semisynchronous replication (see
<a class="xref" href="replication-semisync-installation.html" title="19.4.10.1 Installing Semisynchronous Replication">
Section 19.4.10.1, “Installing Semisynchronous Replication”
</a>
), system
variables become available to control plugin behavior.
</p>
<p>
To check the current values of the status variables for
semisynchronous replication, use
<a class="link" href="show-variables.html" title="15.7.7.41 SHOW VARIABLES Statement">
<code class="literal">
SHOW
VARIABLES
</code>
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa29034999"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">VARIABLES</span> <span class="token operator">LIKE</span> <span class="token string">'rpl_semi_sync%'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
All the
<code class="literal">
rpl_semi_sync_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
system variables are described at
<a class="xref" href="replication-options-source.html" title="19.1.6.2 Replication Source Options and Variables">
Section 19.1.6.2, “Replication Source Options and Variables”
</a>
and
<a class="xref" href="replication-options-replica.html" title="19.1.6.3 Replica Server Options and Variables">
Section 19.1.6.3, “Replica Server Options and Variables”
</a>
. Some key system
variables are:
</p>
<div class="variablelist">
<dl class="variablelist">
<dt>
<span class="term">
<a class="link" href="replication-options-source.html#sysvar_rpl_semi_sync_source_enabled">
<code class="literal">
rpl_semi_sync_source_enabled
</code>
</a>
</span>
</dt>
<dd>
<p>
Controls whether semisynchronous replication is enabled on
the source server. To enable or disable the plugin, set
this variable to 1 or 0, respectively. The default is 0
(off).
</p>
</dd>
<dt>
<span class="term">
<a class="link" href="replication-options-replica.html#sysvar_rpl_semi_sync_replica_enabled">
<code class="literal">
rpl_semi_sync_replica_enabled
</code>
</a>
</span>
</dt>
<dd>
<p>
Controls whether semisynchronous replication is enabled on
the replica.
</p>
</dd>
<dt>
<span class="term">
<a class="link" href="replication-options-source.html#sysvar_rpl_semi_sync_source_timeout">
<code class="literal">
rpl_semi_sync_source_timeout
</code>
</a>
</span>
</dt>
<dd>
<p>
A value in milliseconds that controls how long the source
waits on a commit for acknowledgment from a replica before
timing out and reverting to asynchronous replication. The
default value is 10000 (10 seconds).
</p>
</dd>
<dt>
<span class="term">
<a class="link" href="replication-options-source.html#sysvar_rpl_semi_sync_source_wait_for_replica_count">
<code class="literal">
rpl_semi_sync_source_wait_for_replica_count
</code>
</a>
</span>
</dt>
<dd>
<p>
Controls the number of replica acknowledgments the source
must receive per transaction before returning to the
session. The default is 1, meaning that the source only
waits for one replica to acknowledge receipt of the
transaction's events.
</p>
</dd>
</dl>
</div>
<p>
The
<a class="link" href="replication-options-source.html#sysvar_rpl_semi_sync_source_wait_point">
<code class="literal">
rpl_semi_sync_source_wait_point
</code>
</a>
system variable controls the point at which a semisynchronous
source server waits for replica acknowledgment of transaction
receipt before returning a status to the client that committed
the transaction. These values are permitted:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
AFTER_SYNC
</code>
(the default): The source
writes each transaction to its binary log and the replica,
and syncs the binary log to disk. The source waits for
replica acknowledgment of transaction receipt after the
sync. Upon receiving acknowledgment, the source commits the
transaction to the storage engine and returns a result to
the client, which then can proceed.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AFTER_COMMIT
</code>
: The source writes each
transaction to its binary log and the replica, syncs the
binary log, and commits the transaction to the storage
engine. The source waits for replica acknowledgment of
transaction receipt after the commit. Upon receiving
acknowledgment, the source returns a result to the client,
which then can proceed.
</p>
</li>
</ul>
</div>
<p>
The replication characteristics of these settings differ as
follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
With
<code class="literal">
AFTER_SYNC
</code>
, all clients see the
committed transaction at the same time, which is after it
has been acknowledged by the replica and committed to the
storage engine on the source. Thus, all clients see the same
data on the source.
</p>
<p>
In the event of source failure, all transactions committed
on the source have been replicated to the replica (saved to
its relay log). An unexpected exit of the source and
failover to the replica is lossless because the replica is
up to date. As noted above, the source should not be reused
after the failover.
</p>
</li>
<li class="listitem">
<p>
With
<code class="literal">
AFTER_COMMIT
</code>
, the client issuing the
transaction gets a return status only after the server
commits to the storage engine and receives replica
acknowledgment. After the commit and before replica
acknowledgment, other clients can see the committed
transaction before the committing client.
</p>
<p>
If something goes wrong such that the replica does not
process the transaction, then in the event of an unexpected
source exit and failover to the replica, it is possible for
such clients to see a loss of data relative to what they saw
on the source.
</p>
</li>
</ul>
</div>
<p>
You can improve the performance of semisynchronous replication
by enabling the system variables
<a class="link" href="replication-options-replica.html#sysvar_replication_sender_observe_commit_only">
<code class="literal">
replication_sender_observe_commit_only
</code>
</a>
,
which limits callbacks, and
<a class="link" href="replication-options-replica.html#sysvar_replication_optimize_for_static_plugin_config">
<code class="literal">
replication_optimize_for_static_plugin_config
</code>
</a>
,
which adds shared locks and avoids unnecessary lock
acquisitions. These settings help as the number of replicas
increases, because contention for locks can slow down
performance. Semisynchronous replication source servers can also
get performance benefits from enabling these system variables,
because they use the same locking mechanisms as the replicas.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-asynchronous-connection-failover-source.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="replication-asynchronous-connection-failover-source">
</a>
19.4.9.1 Asynchronous Connection Failover for Sources
</h4>
</div>
</div>
</div>
<p>
To activate asynchronous connection failover for a replication
channel set
<code class="literal">
SOURCE_CONNECTION_AUTO_FAILOVER=1
</code>
in a
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
</a>
statement for this channel. GTID auto-positioning must be in use
for the channel (
<code class="literal">
SOURCE_AUTO_POSITION = 1
</code>
).
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
When the existing connection to a source fails, the replica
first retries the same connection the number of times
specified by the
<code class="literal">
SOURCE_RETRY_COUNT
</code>
option
of the
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION SOURCE
TO
</code>
</a>
. The interval between attempts is set by the
<code class="literal">
SOURCE_CONNECT_RETRY
</code>
option. When these
attempts are exhausted, the asynchronous connection failover
mechanism takes over. Note that the defaults for these
options, which were designed for a connection to a single
source, make the replica retry the same connection for 60
days. To ensure that the asynchronous connection failover
mechanism can be activated promptly, set
<code class="literal">
SOURCE_RETRY_COUNT
</code>
and
<code class="literal">
SOURCE_CONNECT_RETRY
</code>
to minimal numbers
that just allow a few retry attempts with the same source, in
case the connection failure is caused by a transient network
outage. Suitable values are
<code class="literal">
SOURCE_RETRY_COUNT=3
</code>
and
<code class="literal">
SOURCE_CONNECT_RETRY=10
</code>
, which make the
replica retry the connection 3 times with 10-second intervals
between.
</p>
</div>
<p>
You also need to set the source list for the replication
channel, to specify the sources that are available for failover.
You set and manage source lists using the
<a class="link" href="replication-functions-async-failover.html#function_asynchronous-connection-failover-add-source">
<code class="literal">
asynchronous_connection_failover_add_source
</code>
</a>
and
<a class="link" href="replication-functions-async-failover.html#function_asynchronous-connection-failover-delete-source">
<code class="literal">
asynchronous_connection_failover_delete_source
</code>
</a>
functions to add and remove single replication source servers.
To add and remove managed groups of servers, use the
<a class="link" href="replication-functions-async-failover.html#function_asynchronous-connection-failover-add-managed">
<code class="literal">
asynchronous_connection_failover_add_managed
</code>
</a>
and
<a class="link" href="replication-functions-async-failover.html#function_asynchronous-connection-failover-delete-managed">
<code class="literal">
asynchronous_connection_failover_delete_managed
</code>
</a>
functions instead.
</p>
<p>
The functions name the relevant replication channel and specify
the host name, port number, network namespace, and weighted
priority (1-100, with 100 being the highest priority) of a MySQL
instance to add to or delete from the channel's source list. For
a managed group, you also specify the type of managed service
(currently only Group Replication is available), and the
identifier of the managed group (for Group Replication, this is
the value of the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_group_name">
<code class="literal">
group_replication_group_name
</code>
</a>
system variable). When you add a managed group, you only need to
add one group member, and the replica automatically adds the
rest from the current group membership. When you delete a
managed group, you delete the entire group together.
</p>
<p>
The asynchronous connection failover mechanism also fails over
the connection if another available server on the source list
has a higher priority (weight) setting. This feature ensures
that the replica stays connected to the most suitable source
server at all times, and it applies to both managed groups and
single (non-managed) servers. For a managed group, a source’s
weight is assigned depending on whether it is a primary or a
secondary server. So assuming that you set up the managed group
to give a higher weight to a primary and a lower weight to a
secondary, when the primary changes, the higher weight is
assigned to the new primary, so the replica changes over the
connection to it. The asynchronous connection failover mechanism
additionally changes connection if the currently connected
managed source server leaves the managed group, or is no longer
in the majority in the managed group.
</p>
<p>
When failing over a connection, the source with the highest
priority (weight) setting among the alternative sources listed
in the source list for the channel is chosen for the first
connection attempt.
The replica checks first that it can connect to the source
server, or in the case of a managed group, that the source
server has
<code class="literal">
ONLINE
</code>
status in the group (not
<code class="literal">
RECOVERING
</code>
or unavailable). If the highest
weighted source is not available, the replica tries with all the
listed sources in descending order of weight, then starts again
from the highest weighted source. If multiple sources have the
same weight, the replica orders them randomly. If the replica
needs to start working through the list again, it includes and
retries the source to which the original connection failure
occurred.
</p>
<p>
The source lists are stored in the
<code class="literal">
mysql.replication_asynchronous_connection_failover
</code>
and
<code class="literal">
mysql.replication_asynchronous_connection_failover_managed
</code>
tables, and can be viewed in the Performance Schema
<a class="link" href="performance-schema-replication-asynchronous-connection-failover-table.html" title="29.12.11.8 The replication_asynchronous_connection_failover Table">
<code class="literal">
replication_asynchronous_connection_failover
</code>
</a>
and
<a class="link" href="performance-schema-replication-asynchronous-connection-failover-managed-table.html" title="29.12.11.9 The replication_asynchronous_connection_failover_managed Table">
<code class="literal">
replication_asynchronous_connection_failover_managed
</code>
</a>
tables. The replica uses a monitor thread to track the
membership of managed groups and update the source list
(
<code class="literal">
thread/sql/replica_monitor
</code>
). The setting for
the
<a class="link" href="change-replication-source-to.html#crs-opt-source_connection_auto_failover">
<code class="literal">
SOURCE_CONNECTION_AUTO_FAILOVER
</code>
</a>
option of the
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION SOURCE
TO
</code>
</a>
statement, and the source list, are transferred to
a clone of the replica during a remote cloning operation.
</p>
<p>
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/is-null-optimization.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="is-null-optimization">
</a>
10.2.1.15 IS NULL Optimization
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045229028336">
</a>
<a class="indexterm" name="idm46045229027264">
</a>
<p>
MySQL can perform the same optimization on
<em class="replaceable">
<code>
col_name
</code>
</em>
<a class="link" href="comparison-operators.html#operator_is-null">
<code class="literal">
IS
NULL
</code>
</a>
that it can use for
<em class="replaceable">
<code>
col_name
</code>
</em>
<code class="literal">
=
</code>
<em class="replaceable">
<code>
constant_value
</code>
</em>
. For example, MySQL
can use indexes and ranges to search for
<code class="literal">
NULL
</code>
with
<a class="link" href="comparison-operators.html#operator_is-null">
<code class="literal">
IS
NULL
</code>
</a>
.
</p>
<p>
Examples:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa49889266"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em> <span class="token keyword">WHERE</span> <em class="replaceable">key_col</em> <span class="token operator">IS</span> <span class="token boolean">NULL</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em> <span class="token keyword">WHERE</span> <em class="replaceable">key_col</em> <span class="token operator"><=></span> <span class="token boolean">NULL</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <em class="replaceable">tbl_name</em>
<span class="token keyword">WHERE</span> <em class="replaceable">key_col</em><span class="token operator">=</span><em class="replaceable">const1</em> <span class="token operator">OR</span> <em class="replaceable">key_col</em><span class="token operator">=</span><em class="replaceable">const2</em> <span class="token operator">OR</span> <em class="replaceable">key_col</em> <span class="token operator">IS</span> <span class="token boolean">NULL</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
If a
<code class="literal">
WHERE
</code>
clause includes a
<em class="replaceable">
<code>
col_name
</code>
</em>
<a class="link" href="comparison-operators.html#operator_is-null">
<code class="literal">
IS
NULL
</code>
</a>
condition for a column that is declared as
<code class="literal">
NOT NULL
</code>
, that expression is optimized
away. This optimization does not occur in cases when the
column might produce
<code class="literal">
NULL
</code>
anyway (for
example, if it comes from a table on the right side of a
<code class="literal">
LEFT JOIN
</code>
).
</p>
<p>
MySQL can also optimize the combination
<code class="literal">
<em class="replaceable">
<code>
col_name
</code>
</em>
=
<em class="replaceable">
<code>
expr
</code>
</em>
OR
<em class="replaceable">
<code>
col_name
</code>
</em>
IS NULL
</code>
, a form
that is common in resolved subqueries.
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
shows
<a class="link" href="explain-output.html#jointype_ref_or_null">
<code class="literal">
ref_or_null
</code>
</a>
when this
optimization is used.
</p>
<p>
This optimization can handle one
<a class="link" href="comparison-operators.html#operator_is-null">
<code class="literal">
IS
NULL
</code>
</a>
for any key part.
</p>
<p>
Some examples of queries that are optimized, assuming that
there is an index on columns
<code class="literal">
a
</code>
and
<code class="literal">
b
</code>
of table
<code class="literal">
t2
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa47747358"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> t1<span class="token punctuation">.</span>a<span class="token operator">=</span><em class="replaceable">expr</em> <span class="token operator">OR</span> t1<span class="token punctuation">.</span>a <span class="token operator">IS</span> <span class="token boolean">NULL</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1<span class="token punctuation">,</span> t2 <span class="token keyword">WHERE</span> t1<span class="token punctuation">.</span>a<span class="token operator">=</span>t2<span class="token punctuation">.</span>a <span class="token operator">OR</span> t2<span class="token punctuation">.</span>a <span class="token operator">IS</span> <span class="token boolean">NULL</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1<span class="token punctuation">,</span> t2
<span class="token keyword">WHERE</span> <span class="token punctuation">(</span>t1<span class="token punctuation">.</span>a<span class="token operator">=</span>t2<span class="token punctuation">.</span>a <span class="token operator">OR</span> t2<span class="token punctuation">.</span>a <span class="token operator">IS</span> <span class="token boolean">NULL</span><span class="token punctuation">)</span> <span class="token operator">AND</span> t2<span class="token punctuation">.</span>b<span class="token operator">=</span>t1<span class="token punctuation">.</span>b<span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1<span class="token punctuation">,</span> t2
<span class="token keyword">WHERE</span> t1<span class="token punctuation">.</span>a<span class="token operator">=</span>t2<span class="token punctuation">.</span>a <span class="token operator">AND</span> <span class="token punctuation">(</span>t2<span class="token punctuation">.</span>b<span class="token operator">=</span>t1<span class="token punctuation">.</span>b <span class="token operator">OR</span> t2<span class="token punctuation">.</span>b <span class="token operator">IS</span> <span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1<span class="token punctuation">,</span> t2
<span class="token keyword">WHERE</span> <span class="token punctuation">(</span>t1<span class="token punctuation">.</span>a<span class="token operator">=</span>t2<span class="token punctuation">.</span>a <span class="token operator">AND</span> t2<span class="token punctuation">.</span>a <span class="token operator">IS</span> <span class="token boolean">NULL</span> <span class="token operator">AND</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span>
<span class="token operator">OR</span> <span class="token punctuation">(</span>t1<span class="token punctuation">.</span>a<span class="token operator">=</span>t2<span class="token punctuation">.</span>a <span class="token operator">AND</span> t2<span class="token punctuation">.</span>a <span class="token operator">IS</span> <span class="token boolean">NULL</span> <span class="token operator">AND</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
<a class="link" href="explain-output.html#jointype_ref_or_null">
<code class="literal">
ref_or_null
</code>
</a>
works by first
doing a read on the reference key, and then a separate search
for rows with a
<code class="literal">
NULL
</code>
key value.
</p>
<p>
The optimization can handle only one
<a class="link" href="comparison-operators.html#operator_is-null">
<code class="literal">
IS
NULL
</code>
</a>
level. In the following query, MySQL uses key
lookups only on the expression
<code class="literal">
(t1.a=t2.a AND t2.a IS
NULL)
</code>
and is not able to use the key part on
<code class="literal">
b
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa50482137"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1<span class="token punctuation">,</span> t2
<span class="token keyword">WHERE</span> <span class="token punctuation">(</span>t1<span class="token punctuation">.</span>a<span class="token operator">=</span>t2<span class="token punctuation">.</span>a <span class="token operator">AND</span> t2<span class="token punctuation">.</span>a <span class="token operator">IS</span> <span class="token boolean">NULL</span><span class="token punctuation">)</span>
<span class="token operator">OR</span> <span class="token punctuation">(</span>t1<span class="token punctuation">.</span>b<span class="token operator">=</span>t2<span class="token punctuation">.</span>b <span class="token operator">AND</span> t2<span class="token punctuation">.</span>b <span class="token operator">IS</span> <span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/rewriter-query-rewrite-plugin-usage.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="rewriter-query-rewrite-plugin-usage">
</a>
7.6.4.2 Using the Rewriter Query Rewrite Plugin
</h4>
</div>
</div>
</div>
<p>
To enable or disable the plugin, enable or disable the
<a class="link" href="rewriter-query-rewrite-plugin-reference.html#sysvar_rewriter_enabled">
<code class="literal">
rewriter_enabled
</code>
</a>
system
variable. By default, the
<code class="literal">
Rewriter
</code>
plugin is
enabled when you install it (see
<a class="xref" href="rewriter-query-rewrite-plugin-installation.html" title="7.6.4.1 Installing or Uninstalling the Rewriter Query Rewrite Plugin">
Section 7.6.4.1, “Installing or Uninstalling the Rewriter Query Rewrite Plugin”
</a>
).
To set the initial plugin state explicitly, you can set the
variable at server startup. For example, to enable the plugin in
an option file, use these lines:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa54808730"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">rewriter_enabled</span><span class="token attr-value"><span class="token punctuation">=</span>ON</span></code></pre>
</div>
<p>
It is also possible to enable or disable the plugin at runtime:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa61373254"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> rewriter_enabled <span class="token operator">=</span> <span class="token keyword">ON</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> rewriter_enabled <span class="token operator">=</span> <span class="token keyword">OFF</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Assuming that the
<code class="literal">
Rewriter
</code>
plugin is enabled,
it examines and possibly modifies each rewritable statement
received by the server. The plugin determines whether to rewrite
statements based on its in-memory cache of rewriting rules,
which are loaded from the
<code class="literal">
rewrite_rules
</code>
table
in the
<code class="literal">
query_rewrite
</code>
database.
</p>
<p>
These statements are subject to rewriting:
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
,
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
,
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
,
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
, and
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
.
</p>
<p>
Standalone statements and prepared statements are subject to
rewriting. Statements occurring within view definitions or
stored programs are not subject to rewriting.
</p>
<p>
Statements run by users with the
<a class="link" href="privileges-provided.html#priv_skip-query-rewrite">
<code class="literal">
SKIP_QUERY_REWRITE
</code>
</a>
privilege are
not subject to rewriting, provided that the
<a class="link" href="rewriter-query-rewrite-plugin-reference.html#sysvar_rewriter_enabled_for_threads_without_privilege_checks">
<code class="literal">
rewriter_enabled_for_threads_without_privilege_checks
</code>
</a>
system variable is set to
<code class="literal">
OFF
</code>
(default
<code class="literal">
ON
</code>
). This can be used for control statements
and statements that should be replicated unchanged, such as
those from the
<code class="literal">
SOURCE_USER
</code>
specified by
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
</a>
.
This is also true for statements executed by MySQL client
programs including
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
,
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin
</strong>
</span>
</a>
, and
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
;
for this reason, you should grant
<code class="literal">
SKIP_QUERY_REWRITE
</code>
to the user account or
accounts used by these utilities to connect to MySQL.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="rewriter-query-rewrite-plugin-usage.html#rewriter-query-rewrite-plugin-adding-rewrite-rules" title="Adding Rewrite Rules">
Adding Rewrite Rules
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="rewriter-query-rewrite-plugin-usage.html#rewriter-query-rewrite-plugin-how-statement-matching-works" title="How Statement Matching Works">
How Statement Matching Works
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="rewriter-query-rewrite-plugin-usage.html#rewriter-query-rewrite-plugin-rewriting-prepared-statements" title="Rewriting Prepared Statements">
Rewriting Prepared Statements
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="rewriter-query-rewrite-plugin-usage.html#rewriter-query-rewrite-plugin-operational-information" title="Rewriter Plugin Operational Information">
Rewriter Plugin Operational Information
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="rewriter-query-rewrite-plugin-usage.html#rewriter-query-rewrite-plugin-use-of-character-sets" title="Rewriter Plugin Use of Character Sets">
Rewriter Plugin Use of Character Sets
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="rewriter-query-rewrite-plugin-adding-rewrite-rules">
</a>
Adding Rewrite Rules
</h5>
</div>
</div>
</div>
<p>
To add rules for the
<code class="literal">
Rewriter
</code>
plugin, add
rows to the
<code class="literal">
rewrite_rules
</code>
table, then
invoke the
<code class="literal">
flush_rewrite_rules()
</code>
stored
procedure to load the rules from the table into the plugin.
The following example creates a simple rule to match
statements that select a single literal value:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa3812899"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> query_rewrite<span class="token punctuation">.</span>rewrite_rules <span class="token punctuation">(</span>pattern<span class="token punctuation">,</span> replacement<span class="token punctuation">)</span>
<span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token string">'SELECT ?'</span><span class="token punctuation">,</span> <span class="token string">'SELECT ? + 1'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The resulting table contents look like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa42413294"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> query_rewrite<span class="token punctuation">.</span>rewrite_rules\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
id<span class="token punctuation">:</span> 1
pattern<span class="token punctuation">:</span> SELECT ?
pattern_database<span class="token punctuation">:</span> NULL
replacement<span class="token punctuation">:</span> SELECT ? + 1
enabled<span class="token punctuation">:</span> YES
message<span class="token punctuation">:</span> NULL
pattern_digest<span class="token punctuation">:</span> NULL
normalized_pattern<span class="token punctuation">:</span> NULL</span></code></pre>
</div>
<p>
The rule specifies a pattern template indicating which
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements to match, and
a replacement template indicating how to rewrite matching
statements. However, adding the rule to the
<code class="literal">
rewrite_rules
</code>
table is not sufficient to
cause the
<code class="literal">
Rewriter
</code>
plugin to use the rule.
You must invoke
<code class="literal">
flush_rewrite_rules()
</code>
to
load the table contents into the plugin in-memory cache:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa96933289"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CALL</span> query_rewrite<span class="token punctuation">.</span>flush_rewrite_rules<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<div class="tip" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Tip
</div>
<p>
If your rewrite rules seem not to be working properly, make
sure that you have reloaded the rules table by calling
<code class="literal">
flush_rewrite_rules()
</code>
.
</p>
</div>
<p>
When the plugin reads each rule from the rules table, it
computes a normalized (statement digest) form from the pattern
and a digest hash value, and uses them to update the
<code class="literal">
normalized_pattern
</code>
and
<code class="literal">
pattern_digest
</code>
columns:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa47603929"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> query_rewrite<span class="token punctuation">.</span>rewrite_rules\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
id<span class="token punctuation">:</span> 1
pattern<span class="token punctuation">:</span> SELECT ?
pattern_database<span class="token punctuation">:</span> NULL
replacement<span class="token punctuation">:</span> SELECT ? + 1
enabled<span class="token punctuation">:</span> YES
message<span class="token punctuation">:</span> NULL
pattern_digest<span class="token punctuation">:</span> d1b44b0c19af710b5a679907e284acd2ddc285201794bc69a2389d77baedddae
normalized_pattern<span class="token punctuation">:</span> select ?</span></code></pre>
</div>
<p>
For information about statement digesting, normalized
statements, and digest hash values, see
<a class="xref" href="performance-schema-statement-digests.html" title="29.10 Performance Schema Statement Digests and Sampling">
Section 29.10, “Performance Schema Statement Digests and Sampling”
</a>
.
</p>
<p>
If a rule cannot be loaded due to some error, calling
<code class="literal">
flush_rewrite_rules()
</code>
produces an error:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa21291253"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CALL</span> query_rewrite<span class="token punctuation">.</span>flush_rewrite_rules<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1644 (45000)<span class="token punctuation">:</span> Loading of some rule(s) failed.</span></code></pre>
</div>
<p>
When this occurs, the plugin writes an error message to the
<code class="literal">
message
</code>
column of the rule row to
communicate the problem. Check the
<code class="literal">
rewrite_rules
</code>
table for rows with
non-
<code class="literal">
NULL
</code>
<code class="literal">
message
</code>
column
values to see what problems exist.
</p>
<p>
Patterns use the same syntax as prepared statements (see
<a class="xref" href="prepare.html" title="15.5.1 PREPARE Statement">
Section 15.5.1, “PREPARE Statement”
</a>
). Within a pattern template,
<code class="literal">
?
</code>
characters act as parameter markers that
match data values. The
<code class="literal">
?
</code>
characters should
not be enclosed within quotation marks. Parameter markers can
be used only where data values should appear, and they cannot
be used for SQL keywords, identifiers, functions, and so on.
The plugin parses a statement to identify the literal values
(as defined in
<a class="xref" href="literals.html" title="11.1 Literal Values">
Section 11.1, “Literal Values”
</a>
), so you can put a
parameter marker in place of any literal value.
</p>
<p>
Like the pattern, the replacement can contain
<code class="literal">
?
</code>
characters. For a statement that matches
a pattern template, the plugin rewrites it, replacing
<code class="literal">
?
</code>
parameter markers in the replacement
using data values matched by the corresponding markers in the
pattern. The result is a complete statement string. The plugin
asks the server to parse it, and returns the result to the
server as the representation of the rewritten statement.
</p>
<p>
After adding and loading the rule, check whether rewriting
occurs according to whether statements match the rule pattern:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa75652750"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">PI</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> PI() <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 3.141593 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.01 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token number">10</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 10 <span class="token punctuation">+</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 11 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set, 1 warning (0.00 sec)</span></code></pre>
</div>
<p>
No rewriting occurs for the first
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement, but does for
the second. The second statement illustrates that when the
<code class="literal">
Rewriter
</code>
plugin rewrites a statement, it
produces a warning message. To view the message, use
<a class="link" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
<code class="literal">
SHOW WARNINGS
</code>
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa99112774"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">WARNINGS</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
Level<span class="token punctuation">:</span> Note
Code<span class="token punctuation">:</span> 1105
Message<span class="token punctuation">:</span> Query 'SELECT 10' rewritten to 'SELECT 10 + 1' by a query rewrite plugin</span></code></pre>
</div>
<p>
A statement need not be rewritten to a statement of the same
type. The following example loads a rule that rewrites
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
statements to
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa40598111"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> query_rewrite<span class="token punctuation">.</span>rewrite_rules <span class="token punctuation">(</span>pattern<span class="token punctuation">,</span> replacement<span class="token punctuation">)</span>
<span class="token keyword">VALUES</span><span class="token punctuation">(</span><span class="token string">'DELETE FROM db1.t1 WHERE col = ?'</span><span class="token punctuation">,</span>
<span class="token string">'UPDATE db1.t1 SET col = NULL WHERE col = ?'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CALL</span> query_rewrite<span class="token punctuation">.</span>flush_rewrite_rules<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
To enable or disable an existing rule, modify its
<code class="literal">
enabled
</code>
column and reload the table into
the plugin. To disable rule 1:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa32335112"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> query_rewrite<span class="token punctuation">.</span>rewrite_rules <span class="token keyword">SET</span> enabled <span class="token operator">=</span> <span class="token string">'NO'</span> <span class="token keyword">WHERE</span> id <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token keyword">CALL</span> query_rewrite<span class="token punctuation">.</span>flush_rewrite_rules<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
This enables you to deactivate a rule without removing it from
the table.
</p>
<p>
To re-enable rule 1:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa76374328"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UPDATE</span> query_rewrite<span class="token punctuation">.</span>rewrite_rules <span class="token keyword">SET</span> enabled <span class="token operator">=</span> <span class="token string">'YES'</span> <span class="token keyword">WHERE</span> id <span class="token operator">=</span> <span class="token number">1</span><span class="token punctuation">;</span>
<span class="token keyword">CALL</span> query_rewrite<span class="token punctuation">.</span>flush_rewrite_rules<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The
<code class="literal">
rewrite_rules
</code>
table contains a
<code class="literal">
pattern_database
</code>
column that
<code class="literal">
Rewriter
</code>
uses for matching table names that
are not qualified with a database name:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Qualified table names in statements match qualified names
in the pattern if corresponding database and table names
are identical.
</p>
</li>
<li class="listitem">
<p>
Unqualified table names in statements match unqualified
names in the pattern only if the default database is the
same as
<code class="literal">
pattern_database
</code>
and the table
names are identical.
</p>
</li>
</ul>
</div>
<p>
Suppose that a table named
<code class="literal">
appdb.users
</code>
has
a column named
<code class="literal">
id
</code>
and that applications are
expected to select rows from the table using a query of one of
these forms, where the second can be used when
<code class="literal">
appdb
</code>
is the default database:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa69960966"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> users <span class="token keyword">WHERE</span> appdb<span class="token punctuation">.</span>id <span class="token operator">=</span> <em class="replaceable">id_value</em><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> users <span class="token keyword">WHERE</span> id <span class="token operator">=</span> <em class="replaceable">id_value</em><span class="token punctuation">;</span></code></pre>
</div>
<p>
Suppose also that the
<code class="literal">
id
</code>
column is renamed
to
<code class="literal">
user_id
</code>
(perhaps the table must be
modified to add another type of ID and it is necessary to
indicate more specifically what type of ID the
<code class="literal">
id
</code>
column represents).
</p>
<p>
The change means that applications must refer to
<code class="literal">
user_id
</code>
rather than
<code class="literal">
id
</code>
in the
<code class="literal">
WHERE
</code>
clause, but old applications
that cannot be updated no longer work properly. The
<code class="literal">
Rewriter
</code>
plugin can solve this problem by
matching and rewriting problematic statements. To match the
statement
<code class="literal">
SELECT * FROM appdb.users WHERE id =
<em class="replaceable">
<code>
value
</code>
</em>
</code>
and rewrite it as
<code class="literal">
SELECT * FROM appdb.users WHERE user_id =
<em class="replaceable">
<code>
value
</code>
</em>
</code>
, you can insert a
row representing a replacement rule into the rewrite rules
table. If you also want to match this
<code class="literal">
SELECT
</code>
using the unqualified table name, it
is also necessary to add an explicit rule. Using
<code class="literal">
?
</code>
as a value placeholder, the two
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements needed look
like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa45974196"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> query_rewrite<span class="token punctuation">.</span>rewrite_rules
<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span> replacement<span class="token punctuation">)</span> <span class="token keyword">VALUES</span><span class="token punctuation">(</span>
<span class="token string">'SELECT * FROM appdb.users WHERE id = ?'</span><span class="token punctuation">,</span>
<span class="token string">'SELECT * FROM appdb.users WHERE user_id = ?'</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> query_rewrite<span class="token punctuation">.</span>rewrite_rules
<span class="token punctuation">(</span>pattern<span class="token punctuation">,</span> replacement<span class="token punctuation">,</span> pattern_database<span class="token punctuation">)</span> <span class="token keyword">VALUES</span><span class="token punctuation">(</span>
<span class="token string">'SELECT * FROM users WHERE id = ?'</span><span class="token punctuation">,</span>
<span class="token string">'SELECT * FROM users WHERE user_id = ?'</span><span class="token punctuation">,</span>
<span class="token string">'appdb'</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
After adding the two new rules, execute the following
statement to cause them to take effect:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa39166423"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CALL</span> query_rewrite<span class="token punctuation">.</span>flush_rewrite_rules<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
<code class="literal">
Rewriter
</code>
uses the first rule to match
statements that use the qualified table name, and the second
to match statements that use the unqualified name. The second
rule works only when
<code class="literal">
appdb
</code>
is the default
database.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="rewriter-query-rewrite-plugin-how-statement-matching-works">
</a>
How Statement Matching Works
</h5>
</div>
</div>
</div>
<p>
The
<code class="literal">
Rewriter
</code>
plugin uses statement digests
and digest hash values to match incoming statements against
rewrite rules in stages. The
<code class="literal">
max_digest_length
</code>
system variable
determines the size of the buffer used for computing statement
digests. Larger values enable computation of digests that
distinguish longer statements. Smaller values use less memory
but increase the likelihood of longer statements colliding
with the same digest value.
</p>
<p>
The plugin matches each statement to the rewrite rules as
follows:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Compute the statement digest hash value and compare it to
the rule digest hash values. This is subject to false
positives, but serves as a quick rejection test.
</p>
</li>
<li class="listitem">
<p>
If the statement digest hash value matches any pattern
digest hash values, match the normalized (statement
digest) form of the statement to the normalized form of
the matching rule patterns.
</p>
</li>
<li class="listitem">
<p>
If the normalized statement matches a rule, compare the
literal values in the statement and the pattern. A
<code class="literal">
?
</code>
character in the pattern matches any
literal value in the statement. If the statement prepares
a statement,
<code class="literal">
?
</code>
in the pattern also
matches
<code class="literal">
?
</code>
in the statement. Otherwise,
corresponding literals must be the same.
</p>
</li>
</ol>
</div>
<p>
If multiple rules match a statement, it is nondeterministic
which one the plugin uses to rewrite the statement.
</p>
<p>
If a pattern contains more markers than the replacement, the
plugin discards excess data values. If a pattern contains
fewer markers than the replacement, it is an error. The plugin
notices this when the rules table is loaded, writes an error
message to the
<code class="literal">
message
</code>
column of the rule
row to communicate the problem, and sets the
<a class="link" href="rewriter-query-rewrite-plugin-reference.html#statvar_Rewriter_reload_error">
<code class="literal">
Rewriter_reload_error
</code>
</a>
status
variable to
<code class="literal">
ON
</code>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="rewriter-query-rewrite-plugin-rewriting-prepared-statements">
</a>
Rewriting Prepared Statements
</h5>
</div>
</div>
</div>
<p>
Prepared statements are rewritten at parse time (that is, when
they are prepared), not when they are executed later.
</p>
<p>
Prepared statements differ from nonprepared statements in that
they may contain
<code class="literal">
?
</code>
characters as parameter
markers. To match a
<code class="literal">
?
</code>
in a prepared
statement, a
<code class="literal">
Rewriter
</code>
pattern must contain
<code class="literal">
?
</code>
in the same location. Suppose that a
rewrite rule has this pattern:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa23066619"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> ?<span class="token punctuation">,</span> <span class="token number">3</span></code></pre>
</div>
<p>
The following table shows several prepared
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements and whether
the rule pattern matches them.
</p>
<div class="informaltable">
<table summary="How the Rewriter plugin matches prepared statements against the pattern SELECT ?,3.">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<thead>
<tr>
<th>
Prepared Statement
</th>
<th>
Whether Pattern Matches Statement
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
PREPARE s AS 'SELECT 3, 3'
</code>
</td>
<td>
Yes
</td>
</tr>
<tr>
<td>
<code class="literal">
PREPARE s AS 'SELECT ?, 3'
</code>
</td>
<td>
Yes
</td>
</tr>
<tr>
<td>
<code class="literal">
PREPARE s AS 'SELECT 3, ?'
</code>
</td>
<td>
No
</td>
</tr>
<tr>
<td>
<code class="literal">
PREPARE s AS 'SELECT ?, ?'
</code>
</td>
<td>
No
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="rewriter-query-rewrite-plugin-operational-information">
</a>
Rewriter Plugin Operational Information
</h5>
</div>
</div>
</div>
<p>
The
<code class="literal">
Rewriter
</code>
plugin makes information
available about its operation by means of several status
variables:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa54628287"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">GLOBAL</span> <span class="token keyword">STATUS</span> <span class="token operator">LIKE</span> <span class="token string">'Rewriter%'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Variable_name <span class="token punctuation">|</span> Value <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Rewriter_number_loaded_rules <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> Rewriter_number_reloads <span class="token punctuation">|</span> 5 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> Rewriter_number_rewritten_queries <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> Rewriter_reload_error <span class="token punctuation">|</span> ON <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
For descriptions of these variables, see
<a class="xref" href="rewriter-query-rewrite-plugin-reference.html#rewriter-query-rewrite-plugin-status-variables" title="7.6.4.3.4 Rewriter Query Rewrite Plugin Status Variables">
Section 7.6.4.3.4, “Rewriter Query Rewrite Plugin Status Variables”
</a>
.
</p>
<p>
When you load the rules table by calling the
<code class="literal">
flush_rewrite_rules()
</code>
stored procedure, if
an error occurs for some rule, the
<code class="literal">
CALL
</code>
statement produces an error, and the plugin sets the
<code class="literal">
Rewriter_reload_error
</code>
status variable to
<code class="literal">
ON
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa59479728"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CALL</span> query_rewrite<span class="token punctuation">.</span>flush_rewrite_rules<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1644 (45000)<span class="token punctuation">:</span> Loading of some rule(s) failed.
</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">GLOBAL</span> <span class="token keyword">STATUS</span> <span class="token operator">LIKE</span> <span class="token string">'Rewriter_reload_error'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Variable_name <span class="token punctuation">|</span> Value <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Rewriter_reload_error <span class="token punctuation">|</span> ON <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
In this case, check the
<code class="literal">
rewrite_rules
</code>
table
for rows with non-
<code class="literal">
NULL
</code>
<code class="literal">
message
</code>
column values to see what problems
exist.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="rewriter-query-rewrite-plugin-use-of-character-sets">
</a>
Rewriter Plugin Use of Character Sets
</h5>
</div>
</div>
</div>
<p>
When the
<code class="literal">
rewrite_rules
</code>
table is loaded into
the
<code class="literal">
Rewriter
</code>
plugin, the plugin interprets
statements using the current global value of the
<a class="link" href="server-system-variables.html#sysvar_character_set_client">
<code class="literal">
character_set_client
</code>
</a>
system
variable. If the global
<a class="link" href="server-system-variables.html#sysvar_character_set_client">
<code class="literal">
character_set_client
</code>
</a>
value is
changed subsequently, the rules table must be reloaded.
</p>
<p>
A client must have a session
<a class="link" href="server-system-variables.html#sysvar_character_set_client">
<code class="literal">
character_set_client
</code>
</a>
value
identical to what the global value was when the rules table
was loaded or rule matching does not work for that client.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/windows-installation.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="windows-installation">
</a>
2.3 Installing MySQL on Microsoft Windows
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="windows-choosing-package.html">
2.3.1 Choosing an Installation Package
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-configurator.html">
2.3.2 Configuration: Using MySQL Configurator
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="windows-install-archive.html">
2.3.3 Configuration: Manually
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="windows-troubleshooting.html">
2.3.4 Troubleshooting a Microsoft Windows MySQL Server Installation
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="windows-postinstallation.html">
2.3.5 Windows Postinstallation Procedures
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="windows-restrictions.html">
2.3.6 Windows Platform Restrictions
</a>
</span>
</dt>
</dl>
</div>
<p>
MySQL is available for Microsoft Windows 64-bit operating systems
only. For supported Windows platform information, see
<a class="ulink" href="https://www.mysql.com/support/supportedplatforms/database.html" target="_blank">
https://www.mysql.com/support/supportedplatforms/database.html
</a>
.
</p>
<p>
There are different methods to install MySQL on Microsoft Windows:
the MSI, the standard binary distribution (packaged as a compressed
file) containing all of the necessary files that you unpack, and
source files to compile MySQL yourself. For related information, see
<a class="xref" href="windows-choosing-package.html" title="2.3.1 Choosing an Installation Package">
Section 2.3.1, “Choosing an Installation Package”
</a>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
MySQL 8.4 Server requires the Microsoft Visual C++
2019 Redistributable Package to run on Windows platforms. Users
should make sure the package has been installed on the system
before installing the server. The package is available at the
<a class="ulink" href="http://www.microsoft.com/en-us/download/default.aspx" target="_blank">
Microsoft
Download Center
</a>
. Additionally, MySQL debug binaries
require Visual Studio 2019.
</p>
</div>
<h3>
<a name="idm46045332497120">
</a>
Recommended MSI Installation Method
</h3>
<p>
The simplest and recommended method is to download the MSI and let
it install MySQL Server, and then use the MySQL Configurator it installs to
configure MySQL:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Download the MSI from
<a class="ulink" href="https://dev.mysql.com/downloads/" target="_top">
https://dev.mysql.com/downloads/
</a>
and
execute it. This installs the MySQL server, an associated
MySQL Configurator application, and it adds related MySQL items to the
Microsoft Windows Start menu under the
<code class="literal">
MySQL
</code>
group.
</p>
</li>
<li class="listitem">
<p>
Upon completion, the installation wizard prompts to execute
<a class="link" href="mysql-configurator.html" title="2.3.2 Configuration: Using MySQL Configurator">
MySQL Configurator
</a>
. Execute it
now (recommended) or later, or instead choose to manually
configure MySQL.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The MySQL server won't start until it's configured; it's
recommended to execute the bundled MySQL Configurator immediately after
the MSI.
</p>
</div>
</li>
</ol>
</div>
<p>
MySQL is now installed. If you used MySQL Configurator to configure MySQL as
a Windows service, then Windows automatically starts the MySQL
server every time you restart the system. Also, the MSI installs the
MySQL Configurator application on the local host, which you can use later to
reconfigure MySQL server. It and other MySQL start up menu items
were added by the MSI.
</p>
<h3>
<a name="idm46045332488928">
</a>
MySQL Installation Layout on Microsoft Windows
</h3>
<p>
For MySQL 8.4 on Windows, the default installation
directory is
<code class="filename">
C:\Program Files\MySQL\MySQL Server
8.4
</code>
for installations using the MSI,
although the MSI
<span class="guilabel">
Custom
</span>
setup type allows using
a different location. If you use the ZIP archive method to install
MySQL, install it there are elsewhere, such as
<code class="filename">
C:\mysql
</code>
. Regardless, the layout of the
subdirectories remains the same.
</p>
<p>
All of the files are located within this parent directory using the
structure shown in the following table.
</p>
<div class="table">
<a name="idm46045332484784">
</a>
<p class="title">
<b>
Table 2.4 Default MySQL Installation Layout for Microsoft Windows
</b>
</p>
<div class="table-contents">
<table>
<colgroup>
<col style="width: 30%"/>
<col style="width: 40%"/>
<col style="width: 30%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Directory
</th>
<th scope="col">
Contents of Directory
</th>
<th scope="col">
Notes
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<code class="filename">
bin
</code>
</th>
<td>
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
server, client, and utility programs
</td>
<td>
</td>
</tr>
<tr>
<th scope="row">
<code class="filename">
%PROGRAMDATA%\MySQL\MySQL Server 8.4\
</code>
</th>
<td>
Log files, databases
</td>
<td>
The Windows system variable
<code class="varname">
%PROGRAMDATA%
</code>
defaults to
<code class="filename">
C:\ProgramData
</code>
.
</td>
</tr>
<tr>
<th scope="row">
<code class="filename">
docs
</code>
</th>
<td>
Release documentation
</td>
<td>
With the MSI, use the
<code class="literal">
Custom
</code>
type to include this
optional component.
</td>
</tr>
<tr>
<th scope="row">
<code class="filename">
include
</code>
</th>
<td>
Include (header) files
</td>
<td>
</td>
</tr>
<tr>
<th scope="row">
<code class="filename">
lib
</code>
</th>
<td>
Libraries
</td>
<td>
</td>
</tr>
<tr>
<th scope="row">
<code class="filename">
share
</code>
</th>
<td>
Miscellaneous support files, including error messages, character set
files, sample configuration files, SQL for database
installation
</td>
<td>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<h3>
<a name="idm46045332452368">
</a>
Silent Installation Methods
</h3>
<p>
Use the standard
<a class="ulink" href="https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/msiexec#install-options" target="_blank">
msiexec
</a>
options for a silent installation. This example includes
<code class="literal">
/i
</code>
for a normal installation,
<code class="literal">
/qn
</code>
to not show a GUI and to avoid user
interaction, and
<code class="literal">
/lv
</code>
to write verbose
installation output to a new log file target. Execute the
installation as Administrator from the command-line, for example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa79196620"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">msiexec</span> /i <span class="token atrule"></span><em class="replaceable"><span class="token atrule">"C:\mysql\mysql-8.4.3-winx64.msi"</span> /qn /lv <span class="token atrule">"C:\mysql\install.log"</span></em><span class="token atrule"></span></code></pre>
</div>
<p>
The MSI also supports
<code class="literal">
INSTALLDIR
</code>
to optionally
override the default installation directory path to a non-default
location. The following example installs MySQL to
<code class="filename">
C:\mysql\
</code>
instead of
<code class="filename">
C:\Program
Files\MySQL\MySQL Server 8.4\
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa55667658"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">msiexec</span> <em class="replaceable"> /i <span class="token atrule">"C:\mysql\mysql-8.4-winx64.msi"</span> /qn /lv <span class="token atrule">"C:\mysql\install.log"</span> INSTALLDIR=<span class="token atrule">"C:\mysql"</span></em><span class="token atrule"></span></code></pre>
</div>
<h3>
<a name="idm46045332442272">
</a>
Additional Installation Information
</h3>
<p>
By default, MySQL Configurator sets up the MySQL server as a Windows service.
By using a service, you can monitor and control the operation of the
server through the standard Windows service management tools. For
related information about manually setting up the Windows service,
see
<a class="xref" href="windows-start-service.html" title="2.3.3.8 Starting MySQL as a Windows Service">
Section 2.3.3.8, “Starting MySQL as a Windows Service”
</a>
.
</p>
<p>
To accommodate the
<a class="link" href="restart.html" title="15.7.8.8 RESTART Statement">
<code class="literal">
RESTART
</code>
</a>
statement,
the MySQL server forks when run as a service or standalone, to
enable a monitor process to supervise the server process. In this
case, there are two
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
processes. If
<a class="link" href="restart.html" title="15.7.8.8 RESTART Statement">
<code class="literal">
RESTART
</code>
</a>
capability is not required,
the server can be started with the
<a class="link" href="server-options.html#option_mysqld_no-monitor">
<code class="option">
--no-monitor
</code>
</a>
option. See
<a class="xref" href="restart.html" title="15.7.8.8 RESTART Statement">
Section 15.7.8.8, “RESTART Statement”
</a>
.
</p>
<p>
Generally, you should install MySQL on Windows using an account that
has administrator rights. Otherwise, you may encounter problems with
certain operations such as editing the
<code class="literal">
PATH
</code>
environment variable or accessing the
<span class="command">
<strong>
Service Control
Manager
</strong>
</span>
. When installed, MySQL does not need to be
executed using a user with Administrator privileges.
</p>
<p>
For a list of limitations on the use of MySQL on the Windows
platform, see
<a class="xref" href="windows-restrictions.html" title="2.3.6 Windows Platform Restrictions">
Section 2.3.6, “Windows Platform Restrictions”
</a>
.
</p>
<p>
In addition to the MySQL Server package, you may need or want
additional components to use MySQL with your application or
development environment. These include, but are not limited to:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
To connect to the MySQL server using ODBC, you must have a
Connector/ODBC driver. For more information, including
installation and configuration instructions, see
<a class="ulink" href="/doc/connector-odbc/en/" target="_top">
MySQL Connector/ODBC Developer Guide
</a>
.
</p>
</li>
<li class="listitem">
<p>
To use MySQL server with .NET applications, you must have the
Connector/NET driver. For more information, including installation and
configuration instructions, see
<a class="ulink" href="/doc/connector-net/en/" target="_top">
MySQL Connector/NET Developer Guide
</a>
.
</p>
</li>
</ul>
</div>
<p>
MySQL distributions for Windows can be downloaded from
<a class="ulink" href="https://dev.mysql.com/downloads/" target="_top">
https://dev.mysql.com/downloads/
</a>
. See
<a class="xref" href="getting-mysql.html" title="2.1.3 How to Get MySQL">
Section 2.1.3, “How to Get MySQL”
</a>
.
</p>
<p>
MySQL for Windows is available in several distribution formats,
detailed here. Generally speaking, you should use the MSI to install
MySQL server and MySQL Configurator to configure it. The MSI is simpler to
use than the compressed file, and you need no additional tools to
get MySQL up and running. MySQL Configurator automatically configures MySQL
Server, creates an options file, starts the server, enables you to
create default user accounts, and more. For more information on
choosing a package, see
<a class="xref" href="windows-choosing-package.html" title="2.3.1 Choosing an Installation Package">
Section 2.3.1, “Choosing an Installation Package”
</a>
.
</p>
<h3>
<a name="idm46045332422480">
</a>
MySQL on Windows Considerations
</h3>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<span class="bold">
<strong>
Large Table Support
</strong>
</span>
</p>
<p>
If you need tables with a size larger than 4GB, install MySQL on
an NTFS or newer file system. Do not forget to use
<code class="literal">
MAX_ROWS
</code>
and
<code class="literal">
AVG_ROW_LENGTH
</code>
when you create tables. See
<a class="xref" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
Section 15.1.20, “CREATE TABLE Statement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<span class="bold">
<strong>
MySQL and Virus Checking
Software
</strong>
</span>
</p>
<p>
Virus-scanning software such as Norton/Symantec Anti-Virus on
directories containing MySQL data and temporary tables can cause
issues, both in terms of the performance of MySQL and the
virus-scanning software misidentifying the contents of the files
as containing spam. This is due to the fingerprinting mechanism
used by the virus-scanning software, and the way in which MySQL
rapidly updates different files, which may be identified as a
potential security risk.
</p>
<p>
After installing MySQL Server, it is recommended that you
disable virus scanning on the main directory
(
<a class="link" href="server-system-variables.html#sysvar_datadir">
<code class="literal">
datadir
</code>
</a>
) used to store your
MySQL table data. There is usually a system built into the
virus-scanning software to enable specific directories to be
ignored.
</p>
<p>
In addition, by default, MySQL creates temporary files in the
standard Windows temporary directory. To prevent the temporary
files also being scanned, configure a separate temporary
directory for MySQL temporary files and add this directory to
the virus scanning exclusion list. To do this, add a
configuration option for the
<a class="link" href="server-options.html#option_mysqld_tmpdir">
<code class="option">
tmpdir
</code>
</a>
parameter to your
<code class="filename">
my.ini
</code>
configuration file. For more
information, see
<a class="xref" href="windows-create-option-file.html" title="2.3.3.2 Creating an Option File">
Section 2.3.3.2, “Creating an Option File”
</a>
.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/set-operations.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="set-operations">
</a>
15.2.14 Set Operations with UNION, INTERSECT, and EXCEPT
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045180321968">
</a>
<a class="indexterm" name="idm46045180320544">
</a>
<a class="indexterm" name="idm46045180319056">
</a>
<a class="indexterm" name="idm46045180317568">
</a>
<a class="indexterm" name="idm46045180316080">
</a>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="set-operations.html#set-operations-result-set-columns" title="Result Set Column Names and Data Types">
Result Set Column Names and Data Types
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="set-operations.html#set-operations-table-values" title="Set Operations with TABLE and VALUES Statements">
Set Operations with TABLE and VALUES Statements
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="set-operations.html#set-operations-distinct-all" title="Set Operations using DISTINCT and ALL">
Set Operations using DISTINCT and ALL
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="set-operations.html#set-operations-order-by-limit" title="Set Operations with ORDER BY and LIMIT">
Set Operations with ORDER BY and LIMIT
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="set-operations.html#set-operations-limitations" title="Limitations of Set Operations">
Limitations of Set Operations
</a>
</p>
</li>
</ul>
</div>
<p>
SQL set operations combine the results of multiple query blocks
into a single result. A
<span class="emphasis">
<em>
query block
</em>
</span>
,
sometimes also known as a
<span class="emphasis">
<em>
simple table
</em>
</span>
, is
any SQL statement that returns a result set, such as
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
. MySQL 8.4 also
supports
<a class="link" href="table.html" title="15.2.16 TABLE Statement">
<code class="literal">
TABLE
</code>
</a>
and
<a class="link" href="values.html" title="15.2.19 VALUES Statement">
<code class="literal">
VALUES
</code>
</a>
statements. See the
individual descriptions of these statements elsewhere in this
chapter for additional information.
</p>
<p>
The SQL standard defines the following three set operations:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="union.html" title="15.2.18 UNION Clause">
<code class="literal">
UNION
</code>
</a>
: Combine all results from
two query blocks into a single result, omitting any
duplicates.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="intersect.html" title="15.2.8 INTERSECT Clause">
<code class="literal">
INTERSECT
</code>
</a>
: Combine only those
rows which the results of two query blocks have in common,
omitting any duplicates.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="except.html" title="15.2.4 EXCEPT Clause">
<code class="literal">
EXCEPT
</code>
</a>
: For two query blocks
<em class="replaceable">
<code>
A
</code>
</em>
and
<em class="replaceable">
<code>
B
</code>
</em>
,
return all results from
<em class="replaceable">
<code>
A
</code>
</em>
which are
not also present in
<em class="replaceable">
<code>
B
</code>
</em>
, omitting any
duplicates.
</p>
<p>
(Some database systems, such as Oracle, use
<code class="literal">
MINUS
</code>
for the name of this operator. This
is not supported in MySQL.)
</p>
</li>
</ul>
</div>
<p>
MySQL supports
<code class="literal">
UNION
</code>
,
<code class="literal">
INTERSECT
</code>
, and
<code class="literal">
EXCEPT
</code>
.
</p>
<p>
Each of these set operators supports an
<code class="literal">
ALL
</code>
modifier. When the
<code class="literal">
ALL
</code>
keyword follows a set
operator, this causes duplicates to be included in the result. See
the following sections covering the individual operators for more
information and examples.
</p>
<p>
All three set operators also support a
<code class="literal">
DISTINCT
</code>
keyword, which suppresses duplicates in the result. Since this is
the default behavior for set operators, it is usually not
necessary to specify
<code class="literal">
DISTINCT
</code>
explicitly.
</p>
<p>
In general, query blocks and set operations can be combined in any
number and order. A greatly simplified representation is shown
here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa8004692"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><em class="replaceable">query_block</em> <span class="token punctuation">[</span><em class="replaceable">set_op</em> <em class="replaceable">query_block</em><span class="token punctuation">]</span> <span class="token punctuation">[</span><em class="replaceable">set_op</em> <em class="replaceable">query_block</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<em class="replaceable">query_block</em>:
<span class="token keyword">SELECT</span> <span class="token operator">|</span> <span class="token keyword">TABLE</span> <span class="token operator">|</span> <span class="token keyword">VALUES</span>
<em class="replaceable">set_op</em>:
<span class="token keyword">UNION</span> <span class="token operator">|</span> <span class="token keyword">INTERSECT</span> <span class="token operator">|</span> <span class="token keyword">EXCEPT</span></code></pre>
</div>
<p>
This can be represented more accurately, and in greater detail,
like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa94868057"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><em class="replaceable">query_expression</em>:
<span class="token punctuation">[</span><em class="replaceable">with_clause</em><span class="token punctuation">]</span> <span class="token comment" spellcheck="true">/* WITH clause */</span>
<em class="replaceable">query_expression_body</em>
<span class="token punctuation">[</span><em class="replaceable">order_by_clause</em><span class="token punctuation">]</span> <span class="token punctuation">[</span><em class="replaceable">limit_clause</em><span class="token punctuation">]</span> <span class="token punctuation">[</span><em class="replaceable">into_clause</em><span class="token punctuation">]</span>
<em class="replaceable">query_expression_body</em>:
<em class="replaceable">query_term</em>
<span class="token operator">|</span> <em class="replaceable">query_expression_body</em> <span class="token keyword">UNION</span> <span class="token punctuation">[</span><span class="token keyword">ALL</span> <span class="token operator">|</span> <span class="token keyword">DISTINCT</span><span class="token punctuation">]</span> <em class="replaceable">query_term</em>
<span class="token operator">|</span> <em class="replaceable">query_expression_body</em> <span class="token keyword">EXCEPT</span> <span class="token punctuation">[</span><span class="token keyword">ALL</span> <span class="token operator">|</span> <span class="token keyword">DISTINCT</span><span class="token punctuation">]</span> <em class="replaceable">query_term</em>
<em class="replaceable">query_term</em>:
<em class="replaceable">query_primary</em>
<span class="token operator">|</span> <em class="replaceable">query_term</em> <span class="token keyword">INTERSECT</span> <span class="token punctuation">[</span><span class="token keyword">ALL</span> <span class="token operator">|</span> <span class="token keyword">DISTINCT</span><span class="token punctuation">]</span> <em class="replaceable">query_primary</em>
<em class="replaceable">query_primary</em>:
<em class="replaceable">query_block</em>
<span class="token operator">|</span> <span class="token string">'('</span> <em class="replaceable">query_expression_body</em> <span class="token punctuation">[</span><em class="replaceable">order_by_clause</em><span class="token punctuation">]</span> <span class="token punctuation">[</span><em class="replaceable">limit_clause</em><span class="token punctuation">]</span> <span class="token punctuation">[</span><em class="replaceable">into_clause</em><span class="token punctuation">]</span> <span class="token string">')'</span>
<em class="replaceable">query_block</em>: <span class="token comment" spellcheck="true">/* also known as a simple table */</span>
<em class="replaceable">query_specification</em> <span class="token comment" spellcheck="true">/* SELECT statement */</span>
<span class="token operator">|</span> <em class="replaceable">table_value_constructor</em> <span class="token comment" spellcheck="true">/* VALUES statement */</span>
<span class="token operator">|</span> <em class="replaceable">explicit_table</em> <span class="token comment" spellcheck="true">/* TABLE statement */</span></code></pre>
</div>
<p>
You should be aware that
<code class="literal">
INTERSECT
</code>
is evaluated
before
<code class="literal">
UNION
</code>
or
<code class="literal">
EXCEPT
</code>
. This
means that, for example,
<code class="literal">
TABLE x UNION TABLE y INTERSECT
TABLE z
</code>
is always evaluated as
<code class="literal">
TABLE x UNION
(TABLE y INTERSECT TABLE z)
</code>
. See
<a class="xref" href="intersect.html" title="15.2.8 INTERSECT Clause">
Section 15.2.8, “INTERSECT Clause”
</a>
, for more information.
</p>
<p>
In addition, you should keep in mind that, while the
<code class="literal">
UNION
</code>
and
<code class="literal">
INTERSECT
</code>
set
operators are commutative (ordering is not significant),
<code class="literal">
EXCEPT
</code>
is not (order of operands affects the
outcome). In other words, all of the following statements are
true:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
TABLE x UNION TABLE y
</code>
and
<code class="literal">
TABLE y
UNION TABLE x
</code>
produce the same result, although the
ordering of the rows may differ. You can force them to be the
same using
<code class="literal">
ORDER BY
</code>
; see
<a class="xref" href="set-operations.html#set-operations-order-by-limit" title="Set Operations with ORDER BY and LIMIT">
Set Operations with ORDER BY and LIMIT
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLE x INTERSECT TABLE y
</code>
and
<code class="literal">
TABLE y INTERSECT TABLE x
</code>
return the same
result.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLE x EXCEPT TABLE y
</code>
and
<code class="literal">
TABLE y
EXCEPT TABLE x
</code>
do
<span class="emphasis">
<em>
not
</em>
</span>
yield the
same result. See
<a class="xref" href="except.html" title="15.2.4 EXCEPT Clause">
Section 15.2.4, “EXCEPT Clause”
</a>
, for an example.
</p>
</li>
</ul>
</div>
<p>
More information and examples can be found in the sections that
follow.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="set-operations-result-set-columns">
</a>
Result Set Column Names and Data Types
</h4>
</div>
</div>
</div>
<p>
The column names for the result of a set operation are taken
from the column names of the first query block. Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa12046445"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t1 <span class="token punctuation">(</span>x <span class="token datatype">INT</span><span class="token punctuation">,</span> y <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.04 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t1 <span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 2 rows affected (0.00 sec)</span>
<span class="token output">Records: 2 Duplicates: 0 Warnings: 0</span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t2 <span class="token punctuation">(</span>a <span class="token datatype">INT</span><span class="token punctuation">,</span> b <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.04 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t2 <span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">Query OK, 2 rows affected (0.01 sec)</span>
<span class="token output">Records: 2 Duplicates: 0 Warnings: 0</span>
<span class="token prompt">mysql></span> <span class="token keyword">TABLE</span> t1 <span class="token keyword">UNION</span> <span class="token keyword">TABLE</span> t2<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> x <span class="token punctuation">|</span> y <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 4 <span class="token punctuation">|</span> <span class="token punctuation">-</span>2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 5 <span class="token punctuation">|</span> 9 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3 <span class="token punctuation">|</span> 4 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">4 rows in set (0.00 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">TABLE</span> t2 <span class="token keyword">UNION</span> <span class="token keyword">TABLE</span> t1<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a <span class="token punctuation">|</span> b <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3 <span class="token punctuation">|</span> 4 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 4 <span class="token punctuation">|</span> <span class="token punctuation">-</span>2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 5 <span class="token punctuation">|</span> 9 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">4 rows in set (0.00 sec)</span></code></pre>
</div>
<p>
This is true for
<code class="literal">
UNION
</code>
,
<code class="literal">
EXCEPT
</code>
, and
<code class="literal">
INTERSECT
</code>
queries.
</p>
<p>
Selected columns listed in corresponding positions of each query
block should have the same data type. For example, the first
column selected by the first statement should have the same type
as the first column selected by the other statements. If the
data types of corresponding result columns do not match, the
types and lengths of the columns in the result take into account
the values retrieved by all of the query blocks. For example,
the column length in the result set is not constrained to the
length of the value from the first statement, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa74849681"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">REPEAT</span><span class="token punctuation">(</span><span class="token string">'a'</span><span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token keyword">UNION</span> <span class="token keyword">SELECT</span> <span class="token function">REPEAT</span><span class="token punctuation">(</span><span class="token string">'b'</span><span class="token punctuation">,</span><span class="token number">20</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> REPEAT('a',1) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> bbbbbbbbbbbbbbbbbbbb <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="set-operations-table-values">
</a>
Set Operations with TABLE and VALUES Statements
</h4>
</div>
</div>
</div>
<p>
You can also use a
<a class="link" href="table.html" title="15.2.16 TABLE Statement">
<code class="literal">
TABLE
</code>
</a>
statement or
<a class="link" href="values.html" title="15.2.19 VALUES Statement">
<code class="literal">
VALUES
</code>
</a>
statement
wherever you can employ the equivalent
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement. Assume that
tables
<code class="literal">
t1
</code>
and
<code class="literal">
t2
</code>
are
created and populated as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa88529161"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t1 <span class="token punctuation">(</span>x <span class="token datatype">INT</span><span class="token punctuation">,</span> y <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t1 <span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t2 <span class="token punctuation">(</span>a <span class="token datatype">INT</span><span class="token punctuation">,</span> b <span class="token datatype">INT</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t2 <span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The preceding being the case, and disregarding the column names
in the output of the queries beginning with
<a class="link" href="values.html" title="15.2.19 VALUES Statement">
<code class="literal">
VALUES
</code>
</a>
, all of the following
<code class="literal">
UNION
</code>
queries yield the same result:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa668531"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">UNION</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t2<span class="token punctuation">;</span>
<span class="token keyword">TABLE</span> t1 <span class="token keyword">UNION</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t2<span class="token punctuation">;</span>
<span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">)</span> <span class="token keyword">UNION</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t2<span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">UNION</span> <span class="token keyword">TABLE</span> t2<span class="token punctuation">;</span>
<span class="token keyword">TABLE</span> t1 <span class="token keyword">UNION</span> <span class="token keyword">TABLE</span> t2<span class="token punctuation">;</span>
<span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">)</span> <span class="token keyword">UNION</span> <span class="token keyword">TABLE</span> t2<span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">UNION</span> <span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">TABLE</span> t1 <span class="token keyword">UNION</span> <span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">)</span> <span class="token keyword">UNION</span> <span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span><span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
To force the column names to be the same, wrap the query block
on the left-hand side in a
<code class="literal">
SELECT
</code>
statement,
and use aliases, like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa9271812"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <span class="token punctuation">(</span><span class="token keyword">TABLE</span> t2<span class="token punctuation">)</span> <span class="token keyword">AS</span> t<span class="token punctuation">(</span>x<span class="token punctuation">,</span>y<span class="token punctuation">)</span> <span class="token keyword">UNION</span> <span class="token keyword">TABLE</span> t1<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> x <span class="token punctuation">|</span> y <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3 <span class="token punctuation">|</span> 4 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 4 <span class="token punctuation">|</span> <span class="token punctuation">-</span>2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 5 <span class="token punctuation">|</span> 9 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">4 rows in set (0.00 sec)</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="set-operations-distinct-all">
</a>
Set Operations using DISTINCT and ALL
</h4>
</div>
</div>
</div>
<p>
By default, duplicate rows are removed from results of set
operations. The optional
<code class="literal">
DISTINCT
</code>
keyword has
the same effect but makes it explicit. With the optional
<code class="literal">
ALL
</code>
keyword, duplicate-row removal does not
occur and the result includes all matching rows from all queries
in the union.
</p>
<p>
You can mix
<code class="literal">
ALL
</code>
and
<code class="literal">
DISTINCT
</code>
in the same query. Mixed types are
treated such that a set operation using
<code class="literal">
DISTINCT
</code>
overrides any such operation using
<code class="literal">
ALL
</code>
to its left. A
<code class="literal">
DISTINCT
</code>
set can be produced explicitly by
using
<code class="literal">
DISTINCT
</code>
with
<a class="link" href="union.html" title="15.2.18 UNION Clause">
<code class="literal">
UNION
</code>
</a>
,
<a class="link" href="intersect.html" title="15.2.8 INTERSECT Clause">
<code class="literal">
INTERSECT
</code>
</a>
, or
<a class="link" href="except.html" title="15.2.4 EXCEPT Clause">
<code class="literal">
EXCEPT
</code>
</a>
, or implicitly by using
the set operations with no following
<code class="literal">
DISTINCT
</code>
or
<code class="literal">
ALL
</code>
keyword.
</p>
<p>
Set operations work the same way when one or more
<a class="link" href="table.html" title="15.2.16 TABLE Statement">
<code class="literal">
TABLE
</code>
</a>
statements,
<a class="link" href="values.html" title="15.2.19 VALUES Statement">
<code class="literal">
VALUES
</code>
</a>
statements, or both, are
used to generate the set.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="set-operations-order-by-limit">
</a>
Set Operations with ORDER BY and LIMIT
</h4>
</div>
</div>
</div>
<p>
To apply an
<code class="literal">
ORDER BY
</code>
or
<code class="literal">
LIMIT
</code>
clause to an individual query block
used as part of a union, intersection, or other set operation,
parenthesize the query block, placing the clause inside the
parentheses, like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa88942099"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token punctuation">(</span><span class="token keyword">SELECT</span> a <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> a<span class="token operator">=</span><span class="token number">10</span> <span class="token operator">AND</span> b<span class="token operator">=</span><span class="token number">1</span> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> a <span class="token keyword">LIMIT</span> <span class="token number">10</span><span class="token punctuation">)</span>
<span class="token keyword">UNION</span>
<span class="token punctuation">(</span><span class="token keyword">SELECT</span> a <span class="token keyword">FROM</span> t2 <span class="token keyword">WHERE</span> a<span class="token operator">=</span><span class="token number">11</span> <span class="token operator">AND</span> b<span class="token operator">=</span><span class="token number">2</span> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> a <span class="token keyword">LIMIT</span> <span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">(</span><span class="token keyword">TABLE</span> t1 <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> x <span class="token keyword">LIMIT</span> <span class="token number">10</span><span class="token punctuation">)</span>
<span class="token keyword">INTERSECT</span>
<span class="token punctuation">(</span><span class="token keyword">TABLE</span> t2 <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> a <span class="token keyword">LIMIT</span> <span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Use of
<code class="literal">
ORDER BY
</code>
for individual query blocks
or statements implies nothing about the order in which the rows
appear in the final result because the rows produced by a set
operation are by default unordered. Therefore,
<code class="literal">
ORDER
BY
</code>
in this context typically is used in conjunction
with
<code class="literal">
LIMIT
</code>
, to determine the subset of the
selected rows to retrieve, even though it does not necessarily
affect the order of those rows in the final result. If
<code class="literal">
ORDER BY
</code>
appears without
<code class="literal">
LIMIT
</code>
within a query block, it is optimized
away because it has no effect in any case.
</p>
<p>
To use an
<code class="literal">
ORDER BY
</code>
or
<code class="literal">
LIMIT
</code>
clause to sort or limit the entire
result of a set operation, place the
<code class="literal">
ORDER BY
</code>
or
<code class="literal">
LIMIT
</code>
after the last statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa92958130"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> a <span class="token keyword">FROM</span> t1
<span class="token keyword">EXCEPT</span>
<span class="token keyword">SELECT</span> a <span class="token keyword">FROM</span> t2 <span class="token keyword">WHERE</span> a<span class="token operator">=</span><span class="token number">11</span> <span class="token operator">AND</span> b<span class="token operator">=</span><span class="token number">2</span>
<span class="token keyword">ORDER</span> <span class="token keyword">BY</span> a <span class="token keyword">LIMIT</span> <span class="token number">10</span><span class="token punctuation">;</span>
<span class="token keyword">TABLE</span> t1
<span class="token keyword">UNION</span>
<span class="token keyword">TABLE</span> t2
<span class="token keyword">ORDER</span> <span class="token keyword">BY</span> a <span class="token keyword">LIMIT</span> <span class="token number">10</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
If one or more individual statements make use of
<code class="literal">
ORDER
BY
</code>
,
<code class="literal">
LIMIT
</code>
, or both, and, in
addition, you wish to apply an ORDER BY, LIMIT, or both to the
entire result, then each such individual statement must be
enclosed in parentheses.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa91063797"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token punctuation">(</span><span class="token keyword">SELECT</span> a <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> a<span class="token operator">=</span><span class="token number">10</span> <span class="token operator">AND</span> b<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">)</span>
<span class="token keyword">EXCEPT</span>
<span class="token punctuation">(</span><span class="token keyword">SELECT</span> a <span class="token keyword">FROM</span> t2 <span class="token keyword">WHERE</span> a<span class="token operator">=</span><span class="token number">11</span> <span class="token operator">AND</span> b<span class="token operator">=</span><span class="token number">2</span><span class="token punctuation">)</span>
<span class="token keyword">ORDER</span> <span class="token keyword">BY</span> a <span class="token keyword">LIMIT</span> <span class="token number">10</span><span class="token punctuation">;</span>
<span class="token punctuation">(</span><span class="token keyword">TABLE</span> t1 <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> a <span class="token keyword">LIMIT</span> <span class="token number">10</span><span class="token punctuation">)</span>
<span class="token keyword">UNION</span>
<span class="token keyword">TABLE</span> t2
<span class="token keyword">ORDER</span> <span class="token keyword">BY</span> a <span class="token keyword">LIMIT</span> <span class="token number">10</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
A statement with no
<code class="literal">
ORDER BY
</code>
or
<code class="literal">
LIMIT
</code>
clause does need to be parenthesized;
replacing
<code class="literal">
TABLE t2
</code>
with
<code class="literal">
(TABLE
t2)
</code>
in the second statement of the two just shown does
not alter the result of the
<code class="literal">
UNION
</code>
.
</p>
<p>
You can also use
<code class="literal">
ORDER BY
</code>
and
<code class="literal">
LIMIT
</code>
with
<a class="link" href="values.html" title="15.2.19 VALUES Statement">
<code class="literal">
VALUES
</code>
</a>
statements in set
operations, as shown in this example using the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa78463302"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token operator">-</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">5</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">UNION</span>
<span class="token prompt"> -></span> <span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> column_0 <span class="token keyword">DESC</span> <span class="token keyword">LIMIT</span> <span class="token number">3</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> column_0 <span class="token punctuation">|</span> column_1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 5 <span class="token punctuation">|</span> 9 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 4 <span class="token punctuation">|</span> <span class="token punctuation">-</span>2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 3 <span class="token punctuation">|</span> 4 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">3 rows in set (0.00 sec)</span></code></pre>
</div>
<p>
(You should keep in mind that neither
<code class="literal">
TABLE
</code>
statements nor
<code class="literal">
VALUES
</code>
statements accept a
<code class="literal">
WHERE
</code>
clause.)
</p>
<p>
This kind of
<code class="literal">
ORDER BY
</code>
cannot use column
references that include a table name (that is, names in
<em class="replaceable">
<code>
tbl_name
</code>
</em>
.
<em class="replaceable">
<code>
col_name
</code>
</em>
format). Instead, provide a column alias in the first query
block, and refer to the alias in the
<code class="literal">
ORDER BY
</code>
clause. (You can also refer to the column in the
<code class="literal">
ORDER
BY
</code>
clause using its column position, but such use of
column positions is deprecated, and thus subject to eventual
removal in a future MySQL release.)
</p>
<p>
If a column to be sorted is aliased, the
<code class="literal">
ORDER
BY
</code>
clause
<span class="emphasis">
<em>
must
</em>
</span>
refer to the
alias, not the column name. The first of the following
statements is permitted, but the second fails with an
<code class="literal">
Unknown column 'a' in 'order clause'
</code>
error:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa8811978"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token punctuation">(</span><span class="token keyword">SELECT</span> a <span class="token keyword">AS</span> b <span class="token keyword">FROM</span> t<span class="token punctuation">)</span> <span class="token keyword">UNION</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> b<span class="token punctuation">;</span>
<span class="token punctuation">(</span><span class="token keyword">SELECT</span> a <span class="token keyword">AS</span> b <span class="token keyword">FROM</span> t<span class="token punctuation">)</span> <span class="token keyword">UNION</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> a<span class="token punctuation">;</span></code></pre>
</div>
<p>
To cause rows in a
<a class="link" href="union.html" title="15.2.18 UNION Clause">
<code class="literal">
UNION
</code>
</a>
result
to consist of the sets of rows retrieved by each query block one
after the other, select an additional column in each query block
to use as a sort column and add an
<code class="literal">
ORDER BY
</code>
clause that sorts on that column following the last query block:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa82061125"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token number">1</span> <span class="token keyword">AS</span> sort_col<span class="token punctuation">,</span> col1a<span class="token punctuation">,</span> col1b<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">FROM</span> t1<span class="token punctuation">)</span>
<span class="token keyword">UNION</span>
<span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token number">2</span><span class="token punctuation">,</span> col2a<span class="token punctuation">,</span> col2b<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">FROM</span> t2<span class="token punctuation">)</span> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> sort_col<span class="token punctuation">;</span></code></pre>
</div>
<p>
To maintain sort order within individual results, add a
secondary column to the
<code class="literal">
ORDER BY
</code>
clause:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa4349862"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token number">1</span> <span class="token keyword">AS</span> sort_col<span class="token punctuation">,</span> col1a<span class="token punctuation">,</span> col1b<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">FROM</span> t1<span class="token punctuation">)</span>
<span class="token keyword">UNION</span>
<span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token number">2</span><span class="token punctuation">,</span> col2a<span class="token punctuation">,</span> col2b<span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">FROM</span> t2<span class="token punctuation">)</span> <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> sort_col<span class="token punctuation">,</span> col1a<span class="token punctuation">;</span></code></pre>
</div>
<p>
Use of an additional column also enables you to determine which
query block each row comes from. Extra columns can provide other
identifying information as well, such as a string that indicates
a table name.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="set-operations-limitations">
</a>
Limitations of Set Operations
</h4>
</div>
</div>
</div>
<p>
Set operations in MySQL are subject to some limitations, which
are described in the next few paragraphs.
</p>
<p>
Set operations including
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements have the following limitations:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
HIGH_PRIORITY
</code>
in the first
<code class="literal">
SELECT
</code>
has no effect.
<code class="literal">
HIGH_PRIORITY
</code>
in any subsequent
<code class="literal">
SELECT
</code>
produces a syntax error.
</p>
</li>
<li class="listitem">
<p>
Only the last
<code class="literal">
SELECT
</code>
statement can use an
<code class="literal">
INTO
</code>
clause. However, the entire
<code class="literal">
UNION
</code>
result is written to the
<code class="literal">
INTO
</code>
output destination.
</p>
</li>
</ul>
</div>
<p>
These two
<code class="literal">
UNION
</code>
variants containing
<code class="literal">
INTO
</code>
are deprecated; you should expect
support for them to be removed in a future version of MySQL:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
In the trailing query block of a query expression, use of
<code class="literal">
INTO
</code>
before
<code class="literal">
FROM
</code>
produces a warning. Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa82940770"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">UNION</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">INTO</span> <span class="token keyword">OUTFILE</span> <span class="token string">'<em class="replaceable">file_name</em>'</span> <span class="token keyword">FROM</span> <span class="token keyword"><em class="replaceable">table_name</em></span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
In a parenthesized trailing block of a query expression, use
of
<code class="literal">
INTO
</code>
(regardless of its position
relative to
<code class="literal">
FROM
</code>
) produces a warning.
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa91159609"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">UNION</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">INTO</span> <span class="token keyword">OUTFILE</span> <span class="token string">'<em class="replaceable">file_name</em>'</span> <span class="token keyword">FROM</span> <span class="token keyword"><em class="replaceable">table_name</em></span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Those variants are deprecated because they are confusing, as
if they collect information from the named table rather than
the entire query expression (the
<code class="literal">
UNION
</code>
).
</p>
</li>
</ul>
</div>
<p>
Set operations with an aggregate function in an
<code class="literal">
ORDER
BY
</code>
clause are rejected with
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_aggregate_order_for_union" target="_top">
<code class="literal">
ER_AGGREGATE_ORDER_FOR_UNION
</code>
</a>
.
Although the error name might suggest that this is exclusive to
<code class="literal">
UNION
</code>
queries, the preceding is also true for
<code class="literal">
EXCEPT
</code>
and
<code class="literal">
INTERSECT
</code>
queries, as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa7799723"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">TABLE</span> t1 <span class="token keyword">INTERSECT</span> <span class="token keyword">TABLE</span> t2 <span class="token keyword">ORDER</span> <span class="token keyword">BY</span> <span class="token function">MAX</span><span class="token punctuation">(</span>x<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">ERROR 3028 (HY000)<span class="token punctuation">:</span> Expression #1 of ORDER BY contains aggregate function and applies to a UNION, EXCEPT or INTERSECT</span></code></pre>
</div>
<p>
A locking clause (such as
<code class="literal">
FOR UPDATE
</code>
or
<code class="literal">
LOCK IN SHARE MODE
</code>
) applies to the query
block it follows. This means that, in a
<code class="literal">
SELECT
</code>
statement used with set operations, a
locking clause can be used only if the query block and locking
clause are enclosed in parentheses.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/concurrent-inserts.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="concurrent-inserts">
</a>
10.11.3 Concurrent Inserts
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045222745136">
</a>
<a class="indexterm" name="idm46045222744064">
</a>
<p>
The
<code class="literal">
MyISAM
</code>
storage engine supports concurrent
inserts to reduce contention between readers and writers for a
given table: If a
<code class="literal">
MyISAM
</code>
table has no holes
in the data file (deleted rows in the middle), an
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statement can be executed
to add rows to the end of the table at the same time that
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements are reading
rows from the table. If there are multiple
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements, they are
queued and performed in sequence, concurrently with the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements. The results of
a concurrent
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
may not be
visible immediately.
</p>
<p>
The
<a class="link" href="server-system-variables.html#sysvar_concurrent_insert">
<code class="literal">
concurrent_insert
</code>
</a>
system
variable can be set to modify the concurrent-insert processing.
By default, the variable is set to
<code class="literal">
AUTO
</code>
(or
1) and concurrent inserts are handled as just described. If
<a class="link" href="server-system-variables.html#sysvar_concurrent_insert">
<code class="literal">
concurrent_insert
</code>
</a>
is set to
<code class="literal">
NEVER
</code>
(or 0), concurrent inserts are
disabled. If the variable is set to
<code class="literal">
ALWAYS
</code>
(or 2), concurrent inserts at the end of the table are permitted
even for tables that have deleted rows. See also the description
of the
<a class="link" href="server-system-variables.html#sysvar_concurrent_insert">
<code class="literal">
concurrent_insert
</code>
</a>
system
variable.
</p>
<p>
If you are using the binary log, concurrent inserts are
converted to normal inserts for
<code class="literal">
CREATE ...
SELECT
</code>
or
<a class="link" href="insert-select.html" title="15.2.7.1 INSERT ... SELECT Statement">
<code class="literal">
INSERT ...
SELECT
</code>
</a>
statements. This is done to ensure that you can
re-create an exact copy of your tables by applying the log
during a backup operation. See
<a class="xref" href="binary-log.html" title="7.4.4 The Binary Log">
Section 7.4.4, “The Binary Log”
</a>
. In
addition, for those statements a read lock is placed on the
selected-from table such that inserts into that table are
blocked. The effect is that concurrent inserts for that table
must wait as well.
</p>
<p>
With
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD DATA
</code>
</a>
, if you specify
<code class="literal">
CONCURRENT
</code>
with a
<code class="literal">
MyISAM
</code>
table that satisfies the condition for concurrent inserts (that
is, it contains no free blocks in the middle), other sessions
can retrieve data from the table while
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD
DATA
</code>
</a>
is executing. Use of the
<code class="literal">
CONCURRENT
</code>
option affects the performance of
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD DATA
</code>
</a>
a bit, even if no other
session is using the table at the same time.
</p>
<p>
If you specify
<code class="literal">
HIGH_PRIORITY
</code>
, it overrides
the effect of the
<a class="link" href="server-system-variables.html#sysvar_low_priority_updates">
<code class="option">
--low-priority-updates
</code>
</a>
option if
the server was started with that option. It also causes
concurrent inserts not to be used.
</p>
<p>
For
<a class="link" href="lock-tables.html" title="15.3.6 LOCK TABLES and UNLOCK TABLES Statements">
<code class="literal">
LOCK
TABLE
</code>
</a>
, the difference between
<code class="literal">
READ
LOCAL
</code>
and
<code class="literal">
READ
</code>
is that
<code class="literal">
READ LOCAL
</code>
permits nonconflicting
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements (concurrent
inserts) to execute while the lock is held. However, this cannot
be used if you are going to manipulate the database using
processes external to the server while you hold the lock.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-ndbinfo-restart-info.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-ndbinfo-restart-info">
</a>
25.6.17.53 The ndbinfo restart_info Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045088145008">
</a>
<p>
The
<code class="literal">
restart_info
</code>
table contains information
about node restart operations. Each entry in the table
corresponds to a node restart status report in real time from a
data node with the given node ID. Only the most recent report
for any given node is shown.
</p>
<p>
The
<code class="literal">
restart_info
</code>
table contains the following
columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
node_id
</code>
</p>
<p>
Node ID in the cluster
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
node_restart_status
</code>
</p>
<p>
Node status; see text for values. Each of these corresponds
to a possible value of
<code class="literal">
node_restart_status_int
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
node_restart_status_int
</code>
</p>
<p>
Node status code; see text for values.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_to_complete_node_failure
</code>
</p>
<p>
Time in seconds to complete node failure handling
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_to_allocate_node_id
</code>
</p>
<p>
Time in seconds from node failure completion to allocation
of node ID
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_to_include_in_heartbeat_protocol
</code>
</p>
<p>
Time in seconds from allocation of node ID to inclusion in
heartbeat protocol
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_until_wait_for_ndbcntr_master
</code>
</p>
<p>
Time in seconds from being included in heartbeat protocol
until waiting for
<a class="ulink" href="/doc/ndb-internals/en/ndb-internals-kernel-blocks-ndbcntr.html" target="_top">
<code class="literal">
NDBCNTR
</code>
</a>
master began
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_wait_for_ndbcntr_master
</code>
</p>
<p>
Time in seconds spent waiting to be accepted by
<a class="ulink" href="/doc/ndb-internals/en/ndb-internals-kernel-blocks-ndbcntr.html" target="_top">
<code class="literal">
NDBCNTR
</code>
</a>
master for
starting
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_to_get_start_permitted
</code>
</p>
<p>
Time in seconds elapsed from receiving of permission for
start from master until all nodes have accepted start of
this node
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_to_wait_for_lcp_for_copy_meta_data
</code>
</p>
<p>
Time in seconds spent waiting for LCP completion before
copying metadata
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_to_copy_meta_data
</code>
</p>
<p>
Time in seconds required to copy metadata from master to
newly starting node
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_to_include_node
</code>
</p>
<p>
Time in seconds waited for GCP and inclusion of all nodes
into protocols
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_starting_node_to_request_local_recovery
</code>
</p>
<p>
Time in seconds that the node just starting spent waiting to
request local recovery
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_for_local_recovery
</code>
</p>
<p>
Time in seconds required for local recovery by node just
starting
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_restore_fragments
</code>
</p>
<p>
Time in seconds required to restore fragments from LCP files
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_undo_disk_data
</code>
</p>
<p>
Time in seconds required to execute undo log on disk data
part of records
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_exec_redo_log
</code>
</p>
<p>
Time in seconds required to execute redo log on all restored
fragments
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_index_rebuild
</code>
</p>
<p>
Time in seconds required to rebuild indexes on restored
fragments
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_to_synchronize_starting_node
</code>
</p>
<p>
Time in seconds required to synchronize starting node from
live nodes
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_wait_lcp_for_restart
</code>
</p>
<p>
Time in seconds required for LCP start and completion before
restart was completed
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
secs_wait_subscription_handover
</code>
</p>
<p>
Time in seconds spent waiting for handover of replication
subscriptions
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total_restart_secs
</code>
</p>
<p>
Total number of seconds from node failure until node is
started again
</p>
</li>
</ul>
</div>
<h5>
<a name="idm46045088094112">
</a>
Notes
</h5>
<p>
The following list contains values defined for the
<code class="literal">
node_restart_status_int
</code>
column with their
internal status names (in parentheses), and the corresponding
messages shown in the
<code class="literal">
node_restart_status
</code>
column:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
0
</code>
(
<code class="literal">
ALLOCATED_NODE_ID
</code>
)
</p>
<p>
<code class="literal">
Allocated node id
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
1
</code>
(
<code class="literal">
INCLUDED_IN_HB_PROTOCOL
</code>
)
</p>
<p>
<code class="literal">
Included in heartbeat protocol
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
2
</code>
(
<code class="literal">
NDBCNTR_START_WAIT
</code>
)
</p>
<p>
<code class="literal">
Wait for NDBCNTR master to permit us to
start
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
3
</code>
(
<code class="literal">
NDBCNTR_STARTED
</code>
)
</p>
<p>
<code class="literal">
NDBCNTR master permitted us to start
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
4
</code>
(
<code class="literal">
START_PERMITTED
</code>
)
</p>
<p>
<code class="literal">
All nodes permitted us to start
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
5
</code>
(
<code class="literal">
WAIT_LCP_TO_COPY_DICT
</code>
)
</p>
<p>
<code class="literal">
Wait for LCP completion to start copying
metadata
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
6
</code>
(
<code class="literal">
COPY_DICT_TO_STARTING_NODE
</code>
)
</p>
<p>
<code class="literal">
Copying metadata to starting node
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
7
</code>
(
<code class="literal">
INCLUDE_NODE_IN_LCP_AND_GCP
</code>
)
</p>
<p>
<code class="literal">
Include node in LCP and GCP protocols
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
8
</code>
(
<code class="literal">
LOCAL_RECOVERY_STARTED
</code>
)
</p>
<p>
<code class="literal">
Restore fragments ongoing
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
9
</code>
(
<code class="literal">
COPY_FRAGMENTS_STARTED
</code>
)
</p>
<p>
<code class="literal">
Synchronizing starting node with live
nodes
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
10
</code>
(
<code class="literal">
WAIT_LCP_FOR_RESTART
</code>
)
</p>
<p>
<code class="literal">
Wait for LCP to ensure durability
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
11
</code>
(
<code class="literal">
WAIT_SUMA_HANDOVER
</code>
)
</p>
<p>
<code class="literal">
Wait for handover of subscriptions
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
12
</code>
(
<code class="literal">
RESTART_COMPLETED
</code>
)
</p>
<p>
<code class="literal">
Restart completed
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
13
</code>
(
<code class="literal">
NODE_FAILED
</code>
)
</p>
<p>
<code class="literal">
Node failed, failure handling in progress
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
14
</code>
(
<code class="literal">
NODE_FAILURE_COMPLETED
</code>
)
</p>
<p>
<code class="literal">
Node failure handling completed
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
15
</code>
(
<code class="literal">
NODE_GETTING_PERMIT
</code>
)
</p>
<p>
<code class="literal">
All nodes permitted us to start
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
16
</code>
(
<code class="literal">
NODE_GETTING_INCLUDED
</code>
)
</p>
<p>
<code class="literal">
Include node in LCP and GCP protocols
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
17
</code>
(
<code class="literal">
NODE_GETTING_SYNCHED
</code>
)
</p>
<p>
<code class="literal">
Synchronizing starting node with live
nodes
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
18
</code>
(
<code class="literal">
NODE_GETTING_LCP_WAITED
</code>
)
</p>
<p>
[none]
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
19
</code>
(
<code class="literal">
NODE_ACTIVE
</code>
)
</p>
<p>
<code class="literal">
Restart completed
</code>
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
20
</code>
(
<code class="literal">
NOT_DEFINED_IN_CLUSTER
</code>
)
</p>
<p>
[none]
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
21
</code>
(
<code class="literal">
NODE_NOT_RESTARTED_YET
</code>
)
</p>
<p>
<code class="literal">
Initial state
</code>
</p>
</li>
</ul>
</div>
<p>
Status numbers 0 through 12 apply on master nodes only; the
remainder of those shown in the table apply to all restarting
data nodes. Status numbers 13 and 14 define node failure states;
20 and 21 occur when no information about the restart of a given
node is available.
</p>
<p>
See also
<a class="xref" href="mysql-cluster-start-phases.html" title="25.6.4 Summary of NDB Cluster Start Phases">
Section 25.6.4, “Summary of NDB Cluster Start Phases”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/extensions-to-ansi.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="extensions-to-ansi">
</a>
1.7.1 MySQL Extensions to Standard SQL
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045333531200">
</a>
<a class="indexterm" name="idm46045333529744">
</a>
<p>
MySQL Server supports some extensions that you are not likely to
find in other SQL DBMSs. Be warned that if you use them, your
code is most likely not portable to other SQL servers. In some
cases, you can write code that includes MySQL extensions, but is
still portable, by using comments of the following form:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa56279089"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token comment" spellcheck="true">/*! <em class="replaceable">MySQL-specific code</em> */</span></code></pre>
</div>
<p>
In this case, MySQL Server parses and executes the code within
the comment as it would any other SQL statement, but other SQL
servers should ignore the extensions. For example, MySQL Server
recognizes the
<code class="literal">
STRAIGHT_JOIN
</code>
keyword in the
following statement, but other servers should not:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa60416901"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token comment" spellcheck="true">/*! STRAIGHT_JOIN */</span> col1 <span class="token keyword">FROM</span> table1<span class="token punctuation">,</span>table2 <span class="token keyword">WHERE</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
</div>
<p>
If you add a version number after the
<code class="literal">
!
</code>
character, the syntax within the comment is executed only if the
MySQL version is greater than or equal to the specified version
number. The
<code class="literal">
KEY_BLOCK_SIZE
</code>
clause in the
following comment is executed only by servers from MySQL 5.1.10
or higher:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa89650678"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t1<span class="token punctuation">(</span>a <span class="token datatype">INT</span><span class="token punctuation">,</span> <span class="token keyword">KEY</span> <span class="token punctuation">(</span>a<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token comment" spellcheck="true">/*!50110 KEY_BLOCK_SIZE=1024 */</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The following descriptions list MySQL extensions, organized by
category.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Organization of data on disk
</p>
<a class="indexterm" name="idm46045333519568">
</a>
<a class="indexterm" name="idm46045333518080">
</a>
<a class="indexterm" name="idm46045333516592">
</a>
<a class="indexterm" name="idm46045333515104">
</a>
<p>
MySQL Server maps each database to a directory under the
MySQL data directory, and maps tables within a database to
file names in the database directory. Consequently, database
and table names are case-sensitive in MySQL Server on
operating systems that have case-sensitive file names (such
as most Unix systems). See
<a class="xref" href="identifier-case-sensitivity.html" title="11.2.3 Identifier Case Sensitivity">
Section 11.2.3, “Identifier Case Sensitivity”
</a>
.
</p>
</li>
<li class="listitem">
<p>
General language syntax
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
By default, strings can be enclosed by
<code class="literal">
"
</code>
as well as
<code class="literal">
'
</code>
. If
the
<a class="link" href="sql-mode.html#sqlmode_ansi_quotes">
<code class="literal">
ANSI_QUOTES
</code>
</a>
SQL
mode is enabled, strings can be enclosed only by
<code class="literal">
'
</code>
and the server interprets strings
enclosed by
<code class="literal">
"
</code>
as identifiers.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
\
</code>
is the escape character in strings.
</p>
</li>
<li class="listitem">
<p>
In SQL statements, you can access tables from different
databases with the
<em class="replaceable">
<code>
db_name.tbl_name
</code>
</em>
syntax. Some
SQL servers provide the same functionality but call this
<code class="literal">
User space
</code>
. MySQL Server doesn't
support tablespaces such as used in statements like
this:
<code class="literal">
CREATE TABLE ralph.my_table ... IN
my_tablespace
</code>
.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
SQL statement syntax
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
The
<a class="link" href="analyze-table.html" title="15.7.3.1 ANALYZE TABLE Statement">
<code class="literal">
ANALYZE TABLE
</code>
</a>
,
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE
</code>
</a>
,
<a class="link" href="optimize-table.html" title="15.7.3.4 OPTIMIZE TABLE Statement">
<code class="literal">
OPTIMIZE TABLE
</code>
</a>
, and
<a class="link" href="repair-table.html" title="15.7.3.5 REPAIR TABLE Statement">
<code class="literal">
REPAIR TABLE
</code>
</a>
statements.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="create-database.html" title="15.1.12 CREATE DATABASE Statement">
<code class="literal">
CREATE DATABASE
</code>
</a>
,
<a class="link" href="drop-database.html" title="15.1.24 DROP DATABASE Statement">
<code class="literal">
DROP DATABASE
</code>
</a>
, and
<a class="link" href="alter-database.html" title="15.1.2 ALTER DATABASE Statement">
<code class="literal">
ALTER DATABASE
</code>
</a>
statements. See
<a class="xref" href="create-database.html" title="15.1.12 CREATE DATABASE Statement">
Section 15.1.12, “CREATE DATABASE Statement”
</a>
,
<a class="xref" href="drop-database.html" title="15.1.24 DROP DATABASE Statement">
Section 15.1.24, “DROP DATABASE Statement”
</a>
, and
<a class="xref" href="alter-database.html" title="15.1.2 ALTER DATABASE Statement">
Section 15.1.2, “ALTER DATABASE Statement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="do.html" title="15.2.3 DO Statement">
<code class="literal">
DO
</code>
</a>
statement.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
SELECT
</code>
</a>
to obtain a description of how tables
are processed by the query optimizer.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="flush.html" title="15.7.8.3 FLUSH Statement">
<code class="literal">
FLUSH
</code>
</a>
and
<a class="link" href="reset.html" title="15.7.8.6 RESET Statement">
<code class="literal">
RESET
</code>
</a>
statements.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
</code>
</a>
statement. See
<a class="xref" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
Section 15.7.6.1, “SET Syntax for Variable Assignment”
</a>
.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="show.html" title="15.7.7 SHOW Statements">
<code class="literal">
SHOW
</code>
</a>
statement. See
<a class="xref" href="show.html" title="15.7.7 SHOW Statements">
Section 15.7.7, “SHOW Statements”
</a>
. The information produced by many
of the MySQL-specific
<a class="link" href="show.html" title="15.7.7 SHOW Statements">
<code class="literal">
SHOW
</code>
</a>
statements can be
obtained in more standard fashion by using
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
to query
<code class="literal">
INFORMATION_SCHEMA
</code>
. See
<a class="xref" href="information-schema.html" title="Chapter 28 INFORMATION_SCHEMA Tables">
Chapter 28,
<i>
INFORMATION_SCHEMA Tables
</i>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045333470464">
</a>
<a class="indexterm" name="idm46045333469392">
</a>
Use of
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD DATA
</code>
</a>
. In many
cases, this syntax is compatible with Oracle
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD DATA
</code>
</a>
. See
<a class="xref" href="load-data.html" title="15.2.9 LOAD DATA Statement">
Section 15.2.9, “LOAD DATA Statement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Use of
<a class="link" href="rename-table.html" title="15.1.36 RENAME TABLE Statement">
<code class="literal">
RENAME TABLE
</code>
</a>
. See
<a class="xref" href="rename-table.html" title="15.1.36 RENAME TABLE Statement">
Section 15.1.36, “RENAME TABLE Statement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Use of
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
instead of
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
plus
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
. See
<a class="xref" href="replace.html" title="15.2.12 REPLACE Statement">
Section 15.2.12, “REPLACE Statement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Use of
<code class="literal">
CHANGE
<em class="replaceable">
<code>
col_name
</code>
</em>
</code>
,
<code class="literal">
DROP
<em class="replaceable">
<code>
col_name
</code>
</em>
</code>
, or
<a class="link" href="drop-index.html" title="15.1.27 DROP INDEX Statement">
<code class="literal">
DROP INDEX
</code>
</a>
,
<code class="literal">
IGNORE
</code>
or
<code class="literal">
RENAME
</code>
in
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
statements. Use of multiple
<code class="literal">
ADD
</code>
,
<code class="literal">
ALTER
</code>
,
<code class="literal">
DROP
</code>
, or
<code class="literal">
CHANGE
</code>
clauses in an
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
statement.
See
<a class="xref" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
Section 15.1.9, “ALTER TABLE Statement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Use of index names, indexes on a prefix of a column, and
use of
<code class="literal">
INDEX
</code>
or
<code class="literal">
KEY
</code>
in
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE
TABLE
</code>
</a>
statements. See
<a class="xref" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
Section 15.1.20, “CREATE TABLE Statement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Use of
<code class="literal">
TEMPORARY
</code>
or
<code class="literal">
IF NOT
EXISTS
</code>
with
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE
TABLE
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
Use of
<code class="literal">
IF EXISTS
</code>
with
<a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
<code class="literal">
DROP TABLE
</code>
</a>
and
<a class="link" href="drop-database.html" title="15.1.24 DROP DATABASE Statement">
<code class="literal">
DROP DATABASE
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
The capability of dropping multiple tables with a single
<a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
<code class="literal">
DROP TABLE
</code>
</a>
statement.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
ORDER BY
</code>
and
<code class="literal">
LIMIT
</code>
clauses of the
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
and
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
statements.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INSERT INTO
<em class="replaceable">
<code>
tbl_name
</code>
</em>
SET
<em class="replaceable">
<code>
col_name
</code>
</em>
= ...
</code>
syntax.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
DELAYED
</code>
clause of the
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
and
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
statements.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
LOW_PRIORITY
</code>
clause of the
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
,
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
,
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
, and
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
statements.
</p>
</li>
<li class="listitem">
<p>
Use of
<code class="literal">
INTO OUTFILE
</code>
or
<code class="literal">
INTO
DUMPFILE
</code>
in
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements. See
<a class="xref" href="select.html" title="15.2.13 SELECT Statement">
Section 15.2.13, “SELECT Statement”
</a>
.
</p>
</li>
<li class="listitem">
<p>
Options such as
<code class="literal">
STRAIGHT_JOIN
</code>
or
<code class="literal">
SQL_SMALL_RESULT
</code>
in
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements.
</p>
</li>
<li class="listitem">
<p>
You don't need to name all selected columns in the
<code class="literal">
GROUP BY
</code>
clause. This gives better
performance for some very specific, but quite normal
queries. See
<a class="xref" href="aggregate-functions-and-modifiers.html" title="14.19 Aggregate Functions">
Section 14.19, “Aggregate Functions”
</a>
.
</p>
</li>
<li class="listitem">
<p>
You can specify
<code class="literal">
ASC
</code>
and
<code class="literal">
DESC
</code>
with
<code class="literal">
GROUP
BY
</code>
, not just with
<code class="literal">
ORDER BY
</code>
.
</p>
</li>
<li class="listitem">
<p>
The ability to set variables in a statement with the
<code class="literal">
:=
</code>
assignment operator. See
<a class="xref" href="user-variables.html" title="11.4 User-Defined Variables">
Section 11.4, “User-Defined Variables”
</a>
.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
Data types
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
The
<a class="link" href="integer-types.html" title="13.1.2 Integer Types (Exact Value) - INTEGER, INT, SMALLINT, TINYINT, MEDIUMINT, BIGINT">
<code class="literal">
MEDIUMINT
</code>
</a>
,
<a class="link" href="set.html" title="13.3.6 The SET Type">
<code class="literal">
SET
</code>
</a>
, and
<a class="link" href="enum.html" title="13.3.5 The ENUM Type">
<code class="literal">
ENUM
</code>
</a>
data types, and the
various
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
and
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
TEXT
</code>
</a>
data types.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
AUTO_INCREMENT
</code>
,
<code class="literal">
BINARY
</code>
,
<code class="literal">
NULL
</code>
,
<code class="literal">
UNSIGNED
</code>
, and
<code class="literal">
ZEROFILL
</code>
data type attributes.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
Functions and operators
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
To make it easier for users who migrate from other SQL
environments, MySQL Server supports aliases for many
functions. For example, all string functions support
both standard SQL syntax and ODBC syntax.
</p>
</li>
<li class="listitem">
<p>
MySQL Server understands the
<a class="link" href="logical-operators.html#operator_or">
<code class="literal">
||
</code>
</a>
and
<a class="link" href="logical-operators.html#operator_and">
<code class="literal">
&&
</code>
</a>
operators to mean logical OR and AND, as in the C
programming language. In MySQL Server,
<a class="link" href="logical-operators.html#operator_or">
<code class="literal">
||
</code>
</a>
and
<a class="link" href="logical-operators.html#operator_or">
<code class="literal">
OR
</code>
</a>
are
synonyms, as are
<a class="link" href="logical-operators.html#operator_and">
<code class="literal">
&&
</code>
</a>
and
<a class="link" href="logical-operators.html#operator_and">
<code class="literal">
AND
</code>
</a>
.
Because of this nice syntax, MySQL Server doesn't
support the standard SQL
<a class="link" href="logical-operators.html#operator_or">
<code class="literal">
||
</code>
</a>
operator
for string concatenation; use
<a class="link" href="string-functions.html#function_concat">
<code class="literal">
CONCAT()
</code>
</a>
instead. Because
<a class="link" href="string-functions.html#function_concat">
<code class="literal">
CONCAT()
</code>
</a>
takes any number
of arguments, it is easy to convert use of the
<a class="link" href="logical-operators.html#operator_or">
<code class="literal">
||
</code>
</a>
operator
to MySQL Server.
</p>
</li>
<li class="listitem">
<p>
Use of
<a class="link" href="aggregate-functions.html#function_count">
<code class="literal">
COUNT(DISTINCT
<em class="replaceable">
<code>
value_list
</code>
</em>
)
</code>
</a>
where
<em class="replaceable">
<code>
value_list
</code>
</em>
has more than one
element.
</p>
</li>
<li class="listitem">
<p>
String comparisons are case-insensitive by default, with
sort ordering determined by the collation of the current
character set, which is
<code class="literal">
utf8mb4
</code>
by
default. To perform case-sensitive comparisons instead,
you should declare your columns with the
<code class="literal">
BINARY
</code>
attribute or use the
<code class="literal">
BINARY
</code>
cast, which causes comparisons
to be done using the underlying character code values
rather than a lexical ordering.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045333360672">
</a>
<a class="indexterm" name="idm46045333359584">
</a>
The
<a class="link" href="mathematical-functions.html#function_mod">
<code class="literal">
%
</code>
</a>
operator is a synonym for
<a class="link" href="mathematical-functions.html#function_mod">
<code class="literal">
MOD()
</code>
</a>
. That is,
<code class="literal">
<em class="replaceable">
<code>
N
</code>
</em>
%
<em class="replaceable">
<code>
M
</code>
</em>
</code>
is equivalent to
<a class="link" href="mathematical-functions.html#function_mod">
<code class="literal">
MOD(
<em class="replaceable">
<code>
N
</code>
</em>
,
<em class="replaceable">
<code>
M
</code>
</em>
)
</code>
</a>
.
<a class="link" href="mathematical-functions.html#function_mod">
<code class="literal">
%
</code>
</a>
is
supported for C programmers and for compatibility with
PostgreSQL.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="comparison-operators.html#operator_equal">
<code class="literal">
=
</code>
</a>
,
<a class="link" href="comparison-operators.html#operator_not-equal">
<code class="literal">
<>
</code>
</a>
,
<a class="link" href="comparison-operators.html#operator_less-than-or-equal">
<code class="literal">
<=
</code>
</a>
,
<a class="link" href="comparison-operators.html#operator_less-than">
<code class="literal">
<
</code>
</a>
,
<a class="link" href="comparison-operators.html#operator_greater-than-or-equal">
<code class="literal">
>=
</code>
</a>
,
<a class="link" href="comparison-operators.html#operator_greater-than">
<code class="literal">
>
</code>
</a>
,
<a class="link" href="bit-functions.html#operator_left-shift">
<code class="literal">
<<
</code>
</a>
,
<a class="link" href="bit-functions.html#operator_right-shift">
<code class="literal">
>>
</code>
</a>
,
<a class="link" href="comparison-operators.html#operator_equal-to">
<code class="literal">
<=>
</code>
</a>
,
<a class="link" href="logical-operators.html#operator_and">
<code class="literal">
AND
</code>
</a>
,
<a class="link" href="logical-operators.html#operator_or">
<code class="literal">
OR
</code>
</a>
, or
<a class="link" href="string-comparison-functions.html#operator_like">
<code class="literal">
LIKE
</code>
</a>
operators may be used in expressions in the output
column list (to the left of the
<code class="literal">
FROM
</code>
)
in
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements. For
example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa28409603"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> col1<span class="token operator">=</span><span class="token number">1</span> <span class="token operator">AND</span> col2<span class="token operator">=</span><span class="token number">2</span> <span class="token keyword">FROM</span> my_table<span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
The
<a class="link" href="information-functions.html#function_last-insert-id">
<code class="literal">
LAST_INSERT_ID()
</code>
</a>
function returns the most recent
<code class="literal">
AUTO_INCREMENT
</code>
value. See
<a class="xref" href="information-functions.html" title="14.15 Information Functions">
Section 14.15, “Information Functions”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="string-comparison-functions.html#operator_like">
<code class="literal">
LIKE
</code>
</a>
is permitted on
numeric values.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="regexp.html#operator_regexp">
<code class="literal">
REGEXP
</code>
</a>
and
<a class="link" href="regexp.html#operator_not-regexp">
<code class="literal">
NOT REGEXP
</code>
</a>
extended regular
expression operators.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="string-functions.html#function_concat">
<code class="literal">
CONCAT()
</code>
</a>
or
<a class="link" href="string-functions.html#function_char">
<code class="literal">
CHAR()
</code>
</a>
with one argument
or more than two arguments. (In MySQL Server, these
functions can take a variable number of arguments.)
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="bit-functions.html#function_bit-count">
<code class="literal">
BIT_COUNT()
</code>
</a>
,
<a class="link" href="flow-control-functions.html#operator_case">
<code class="literal">
CASE
</code>
</a>
,
<a class="link" href="string-functions.html#function_elt">
<code class="literal">
ELT()
</code>
</a>
,
<a class="link" href="date-and-time-functions.html#function_from-days">
<code class="literal">
FROM_DAYS()
</code>
</a>
,
<a class="link" href="string-functions.html#function_format">
<code class="literal">
FORMAT()
</code>
</a>
,
<a class="link" href="flow-control-functions.html#function_if">
<code class="literal">
IF()
</code>
</a>
,
<a class="link" href="encryption-functions.html#function_md5">
<code class="literal">
MD5()
</code>
</a>
,
<a class="link" href="date-and-time-functions.html#function_period-add">
<code class="literal">
PERIOD_ADD()
</code>
</a>
,
<a class="link" href="date-and-time-functions.html#function_period-diff">
<code class="literal">
PERIOD_DIFF()
</code>
</a>
,
<a class="link" href="date-and-time-functions.html#function_to-days">
<code class="literal">
TO_DAYS()
</code>
</a>
, and
<a class="link" href="date-and-time-functions.html#function_weekday">
<code class="literal">
WEEKDAY()
</code>
</a>
functions.
</p>
</li>
<li class="listitem">
<p>
Use of
<a class="link" href="string-functions.html#function_trim">
<code class="literal">
TRIM()
</code>
</a>
to trim
substrings. Standard SQL supports removal of single
characters only.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
GROUP BY
</code>
functions
<a class="link" href="aggregate-functions.html#function_std">
<code class="literal">
STD()
</code>
</a>
,
<a class="link" href="aggregate-functions.html#function_bit-or">
<code class="literal">
BIT_OR()
</code>
</a>
,
<a class="link" href="aggregate-functions.html#function_bit-and">
<code class="literal">
BIT_AND()
</code>
</a>
,
<a class="link" href="aggregate-functions.html#function_bit-xor">
<code class="literal">
BIT_XOR()
</code>
</a>
, and
<a class="link" href="aggregate-functions.html#function_group-concat">
<code class="literal">
GROUP_CONCAT()
</code>
</a>
. See
<a class="xref" href="aggregate-functions-and-modifiers.html" title="14.19 Aggregate Functions">
Section 14.19, “Aggregate Functions”
</a>
.
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-shell-tutorial-python-documents-remove.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-shell-tutorial-python-documents-remove">
</a>
22.4.3.5 Remove Documents
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127025552">
</a>
<p>
You can use the
<code class="literal">
remove()
</code>
method to delete
some or all documents from a collection in a schema. The
X DevAPI provides additional methods for use with the
<code class="literal">
remove()
</code>
method to filter and sort the
documents to be removed.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-shell-tutorial-python-remove-documents-by-condition">
</a>
Remove Documents Using Conditions
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127020768">
</a>
<p>
The following example passes a search condition to the
<code class="literal">
remove()
</code>
method. All documents matching the
condition are removed from the
<code class="literal">
countryinfo
</code>
collection. In this example, one document matches the
condition.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-mysqlsh"><div class="docs-select-all right" id="sa73207124"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-mysqlsh"><span class="token prompt">mysql-py></span> db<span class="token punctuation">.</span>countryinfo<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span><span class="token string">"Code = 'SEA'"</span><span class="token punctuation">)</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-shell-tutorial-python-remove-first-document">
</a>
Remove the First Document
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127014144">
</a>
<p>
To remove the first document in the
<code class="literal">
countryinfo
</code>
collection, use the
<code class="literal">
limit()
</code>
method with a value of 1.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-mysqlsh"><div class="docs-select-all right" id="sa24981317"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-mysqlsh"><span class="token prompt">mysql-py></span> db<span class="token punctuation">.</span>countryinfo<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span><span class="token string">"true"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">limit</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-shell-tutorial-python-remove-last-document">
</a>
Remove the Last Document in an Order
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127007824">
</a>
<p>
The following example removes the last document in the
<code class="literal">
countryinfo
</code>
collection by country name.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-mysqlsh"><div class="docs-select-all right" id="sa9625025"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-mysqlsh"><span class="token prompt">mysql-py></span> db<span class="token punctuation">.</span>countryinfo<span class="token punctuation">.</span><span class="token function">remove</span><span class="token punctuation">(</span><span class="token string">"true"</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">sort</span><span class="token punctuation">(</span><span class="token punctuation">[</span><span class="token string">"Name desc"</span><span class="token punctuation">]</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">limit</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="mysql-shell-tutorial-python-remove-all-documents">
</a>
Remove All Documents in a Collection
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127002112">
</a>
<p>
You can remove all documents in a collection. To do so, use
the
<code class="literal">
remove("true")
</code>
method without
specifying a search condition.
</p>
<div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Caution
</div>
<p>
Use care when you remove documents without specifying a
search condition. This action deletes all documents from the
collection.
</p>
</div>
<p>
Alternatively, use the
<code class="literal">
db.drop_collection('countryinfo')
</code>
operation
to delete the
<code class="literal">
countryinfo
</code>
collection.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="idm46045126996416">
</a>
Related Information
</h5>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
See
<a class="ulink" href="/doc/x-devapi-userguide/en/crud-ebnf-collection-crud-functions.html#crud-ebnf-collectionremovefunction" target="_top">
CollectionRemoveFunction
</a>
for the full syntax definition.
</p>
</li>
<li class="listitem">
<p>
See
<a class="xref" href="mysql-shell-tutorial-python-download.html" title="22.4.2 Download and Import world_x Database">
Section 22.4.2, “Download and Import world_x Database”
</a>
for instructions to recreate the
<code class="literal">
world_x
</code>
schema.
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/spatial-operator-functions.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="spatial-operator-functions">
</a>
14.16.8 Spatial Operator Functions
</h3>
</div>
</div>
</div>
<p>
OpenGIS proposes a number of functions that can produce
geometries. They are designed to implement spatial operators.
These functions support all argument type combinations except
those that are inapplicable according to the
<a class="ulink" href="http://www.opengeospatial.org" target="_blank">
Open Geospatial
Consortium
</a>
specification.
</p>
<p>
MySQL also implements certain functions that are extensions to
OpenGIS, as noted in the function descriptions. In addition,
<a class="xref" href="gis-property-functions.html" title="14.16.7 Geometry Property Functions">
Section 14.16.7, “Geometry Property Functions”
</a>
, discusses several
functions that construct new geometries from existing ones. See
that section for descriptions of these functions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="gis-general-property-functions.html#function_st-envelope">
<code class="literal">
ST_Envelope(
<em class="replaceable">
<code>
g
</code>
</em>
)
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="gis-linestring-property-functions.html#function_st-startpoint">
<code class="literal">
ST_StartPoint(
<em class="replaceable">
<code>
ls
</code>
</em>
)
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="gis-linestring-property-functions.html#function_st-endpoint">
<code class="literal">
ST_EndPoint(
<em class="replaceable">
<code>
ls
</code>
</em>
)
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="gis-linestring-property-functions.html#function_st-pointn">
<code class="literal">
ST_PointN(
<em class="replaceable">
<code>
ls
</code>
</em>
,
<em class="replaceable">
<code>
N
</code>
</em>
)
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="gis-polygon-property-functions.html#function_st-exteriorring">
<code class="literal">
ST_ExteriorRing(
<em class="replaceable">
<code>
poly
</code>
</em>
)
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="gis-polygon-property-functions.html#function_st-interiorringn">
<code class="literal">
ST_InteriorRingN(
<em class="replaceable">
<code>
poly
</code>
</em>
,
<em class="replaceable">
<code>
N
</code>
</em>
)
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="gis-geometrycollection-property-functions.html#function_st-geometryn">
<code class="literal">
ST_GeometryN(
<em class="replaceable">
<code>
gc
</code>
</em>
,
<em class="replaceable">
<code>
N
</code>
</em>
)
</code>
</a>
</p>
</li>
</ul>
</div>
<p>
Unless otherwise specified, functions in this section handle their
geometry arguments as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If any argument is
<code class="literal">
NULL
</code>
, the return value
is
<code class="literal">
NULL
</code>
.
</p>
</li>
<li class="listitem">
<p>
If any geometry argument is not a syntactically well-formed
geometry, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_gis_invalid_data" target="_top">
<code class="literal">
ER_GIS_INVALID_DATA
</code>
</a>
error
occurs.
</p>
</li>
<li class="listitem">
<p>
If any geometry argument is a syntactically well-formed
geometry in an undefined spatial reference system (SRS), an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_srs_not_found" target="_top">
<code class="literal">
ER_SRS_NOT_FOUND
</code>
</a>
error occurs.
</p>
</li>
<li class="listitem">
<p>
For functions that take multiple geometry arguments, if those
arguments are not in the same SRS, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_gis_different_srids" target="_top">
<code class="literal">
ER_GIS_DIFFERENT_SRIDS
</code>
</a>
error
occurs.
</p>
</li>
<li class="listitem">
<p>
If any geometry argument has an SRID value for a geographic
SRS and the function does not handle geographic geometries, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_not_implemented_for_geographic_srs" target="_top">
<code class="literal">
ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
</code>
</a>
error occurs.
</p>
</li>
<li class="listitem">
<p>
For geographic SRS geometry arguments, if any argument has a
longitude or latitude that is out of range, an error occurs:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
If a longitude value is not in the range (−180,
180], an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_geometry_param_longitude_out_of_range" target="_top">
<code class="literal">
ER_GEOMETRY_PARAM_LONGITUDE_OUT_OF_RANGE
</code>
</a>
error occurs.
</p>
</li>
<li class="listitem">
<p>
If a latitude value is not in the range [−90, 90],
an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_geometry_param_latitude_out_of_range" target="_top">
<code class="literal">
ER_GEOMETRY_PARAM_LATITUDE_OUT_OF_RANGE
</code>
</a>
error occurs.
</p>
</li>
</ul>
</div>
<p>
Ranges shown are in degrees. If an SRS uses another unit, the
range uses the corresponding values in its unit. The exact
range limits deviate slightly due to floating-point
arithmetic.
</p>
</li>
<li class="listitem">
<p>
Otherwise, the return value is non-
<code class="literal">
NULL
</code>
.
</p>
</li>
</ul>
</div>
<p>
These spatial operator functions are available:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<a name="function_st-buffer">
</a>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-buffer">
<code class="literal">
ST_Buffer(
<em class="replaceable">
<code>
g
</code>
</em>
,
<em class="replaceable">
<code>
d
</code>
</em>
[,
<em class="replaceable">
<code>
strategy1
</code>
</em>
[,
<em class="replaceable">
<code>
strategy2
</code>
</em>
[,
<em class="replaceable">
<code>
strategy3
</code>
</em>
]]])
</code>
</a>
</p>
<a class="indexterm" name="idm46045196949904">
</a>
<p>
Returns a geometry that represents all points whose distance
from the geometry value
<em class="replaceable">
<code>
g
</code>
</em>
is less
than or equal to a distance of
<em class="replaceable">
<code>
d
</code>
</em>
.
The result is in the same SRS as the geometry argument.
</p>
<p>
If the geometry argument is empty,
<a class="link" href="spatial-operator-functions.html#function_st-buffer">
<code class="literal">
ST_Buffer()
</code>
</a>
returns an empty
geometry.
</p>
<p>
If the distance is 0,
<a class="link" href="spatial-operator-functions.html#function_st-buffer">
<code class="literal">
ST_Buffer()
</code>
</a>
returns the
geometry argument unchanged:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa39700893"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@pt</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'POINT(0 0)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span><span class="token function">ST_Buffer</span><span class="token punctuation">(</span><span class="token variable">@pt</span><span class="token punctuation">,</span> <span class="token number">0</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(ST_Buffer(@pt, 0)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> POINT(0 0) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
If the geometry argument is in a Cartesian SRS:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<a class="link" href="spatial-operator-functions.html#function_st-buffer">
<code class="literal">
ST_Buffer()
</code>
</a>
supports
negative distances for
<code class="literal">
Polygon
</code>
and
<code class="literal">
MultiPolygon
</code>
values, and for geometry
collections containing
<code class="literal">
Polygon
</code>
or
<code class="literal">
MultiPolygon
</code>
values.
</p>
</li>
<li class="listitem">
<p>
If the result is reduced so much that it disappears, the
result is an empty geometry.
</p>
</li>
<li class="listitem">
<p>
An
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_wrong_arguments" target="_top">
<code class="literal">
ER_WRONG_ARGUMENTS
</code>
</a>
error occurs for
<a class="link" href="spatial-operator-functions.html#function_st-buffer">
<code class="literal">
ST_Buffer()
</code>
</a>
with a negative
distance for
<code class="literal">
Point
</code>
,
<code class="literal">
MultiPoint
</code>
,
<code class="literal">
LineString
</code>
, and
<code class="literal">
MultiLineString
</code>
values, and for
geometry collections not containing any
<code class="literal">
Polygon
</code>
or
<code class="literal">
MultiPolygon
</code>
values.
</p>
</li>
</ul>
</div>
<p>
<code class="literal">
Point
</code>
geometries in a geographic SRS are
permitted, subject to the following conditions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
If the distance is not negative and no strategies are
specified, the function returns the geographic buffer of
the
<code class="literal">
Point
</code>
in its SRS. The distance
argument must be in the SRS distance unit (currently
always meters).
</p>
</li>
<li class="listitem">
<p>
If the distance is negative or any strategy (except
<code class="literal">
NULL
</code>
) is specified, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_wrong_arguments" target="_top">
<code class="literal">
ER_WRONG_ARGUMENTS
</code>
</a>
error
occurs.
</p>
</li>
</ul>
</div>
<p>
For non-
<code class="literal">
Point
</code>
geometries, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_not_implemented_for_geographic_srs" target="_top">
<code class="literal">
ER_NOT_IMPLEMENTED_FOR_GEOGRAPHIC_SRS
</code>
</a>
error occurs.
</p>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-buffer">
<code class="literal">
ST_Buffer()
</code>
</a>
permits up to three
optional strategy arguments following the distance argument.
Strategies influence buffer computation. These arguments are
byte string values produced by the
<a class="link" href="spatial-operator-functions.html#function_st-buffer-strategy">
<code class="literal">
ST_Buffer_Strategy()
</code>
</a>
function,
to be used for point, join, and end strategies:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Point strategies apply to
<code class="literal">
Point
</code>
and
<code class="literal">
MultiPoint
</code>
geometries. If no point
strategy is specified, the default is
<a class="link" href="spatial-operator-functions.html#function_st-buffer-strategy">
<code class="literal">
ST_Buffer_Strategy('point_circle',
32)
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
Join strategies apply to
<code class="literal">
LineString
</code>
,
<code class="literal">
MultiLineString
</code>
,
<code class="literal">
Polygon
</code>
, and
<code class="literal">
MultiPolygon
</code>
geometries. If no join
strategy is specified, the default is
<a class="link" href="spatial-operator-functions.html#function_st-buffer-strategy">
<code class="literal">
ST_Buffer_Strategy('join_round',
32)
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
End strategies apply to
<code class="literal">
LineString
</code>
and
<code class="literal">
MultiLineString
</code>
geometries. If no end
strategy is specified, the default is
<a class="link" href="spatial-operator-functions.html#function_st-buffer-strategy">
<code class="literal">
ST_Buffer_Strategy('end_round',
32)
</code>
</a>
.
</p>
</li>
</ul>
</div>
<p>
Up to one strategy of each type may be specified, and they may
be given in any order.
</p>
<p>
If the buffer strategies are invalid, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_wrong_arguments" target="_top">
<code class="literal">
ER_WRONG_ARGUMENTS
</code>
</a>
error
occurs. Strategies are invalid under any of these
circumstances:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Multiple strategies of a given type (point, join, or end)
are specified.
</p>
</li>
<li class="listitem">
<p>
A value that is not a strategy (such as an arbitrary
binary string or a number) is passed as a strategy.
</p>
</li>
<li class="listitem">
<p>
A
<code class="literal">
Point
</code>
strategy is passed and the
geometry contains no
<code class="literal">
Point
</code>
or
<code class="literal">
MultiPoint
</code>
values.
</p>
</li>
<li class="listitem">
<p>
An end or join strategy is passed and the geometry
contains no
<code class="literal">
LineString
</code>
,
<code class="literal">
Polygon
</code>
,
<code class="literal">
MultiLinestring
</code>
or
<code class="literal">
MultiPolygon
</code>
values.
</p>
</li>
</ul>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa42430992"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@pt</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'POINT(0 0)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@pt_strategy</span> <span class="token operator">=</span> <span class="token function">ST_Buffer_Strategy</span><span class="token punctuation">(</span><span class="token string">'point_square'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span><span class="token function">ST_Buffer</span><span class="token punctuation">(</span><span class="token variable">@pt</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token variable">@pt_strategy</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(ST_Buffer(@pt, 2, @pt_strategy)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> POLYGON((<span class="token punctuation">-</span>2 <span class="token punctuation">-</span>2,2 <span class="token punctuation">-</span>2,2 2,<span class="token punctuation">-</span>2 2,<span class="token punctuation">-</span>2 <span class="token punctuation">-</span>2)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa80736909"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@ls</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'LINESTRING(0 0,0 5,5 5)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@end_strategy</span> <span class="token operator">=</span> <span class="token function">ST_Buffer_Strategy</span><span class="token punctuation">(</span><span class="token string">'end_flat'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@join_strategy</span> <span class="token operator">=</span> <span class="token function">ST_Buffer_Strategy</span><span class="token punctuation">(</span><span class="token string">'join_round'</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span><span class="token function">ST_Buffer</span><span class="token punctuation">(</span><span class="token variable">@ls</span><span class="token punctuation">,</span> <span class="token number">5</span><span class="token punctuation">,</span> <span class="token variable">@end_strategy</span><span class="token punctuation">,</span> <span class="token variable">@join_strategy</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(ST_Buffer(@ls, 5, @end_strategy, @join_strategy)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> POLYGON((5 5,5 10,0 10,<span class="token punctuation">-</span>3.5355339059327373 8.535533905932738, <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> <span class="token punctuation">-</span>5 5,<span class="token punctuation">-</span>5 0,0 0,5 0,5 5)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
<li class="listitem">
<a name="function_st-buffer-strategy">
</a>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-buffer-strategy">
<code class="literal">
ST_Buffer_Strategy(
<em class="replaceable">
<code>
strategy
</code>
</em>
[,
<em class="replaceable">
<code>
points_per_circle
</code>
</em>
])
</code>
</a>
</p>
<a class="indexterm" name="idm46045196875776">
</a>
<p>
This function returns a strategy byte string for use with
<a class="link" href="spatial-operator-functions.html#function_st-buffer">
<code class="literal">
ST_Buffer()
</code>
</a>
to influence buffer
computation.
</p>
<p>
Information about strategies is available at
<a class="ulink" href="http://www.boost.org" target="_blank">
Boost.org
</a>
.
</p>
<p>
The first argument must be a string indicating a strategy
option:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
For point strategies, permitted values are
<code class="literal">
'point_circle'
</code>
and
<code class="literal">
'point_square'
</code>
.
</p>
</li>
<li class="listitem">
<p>
For join strategies, permitted values are
<code class="literal">
'join_round'
</code>
and
<code class="literal">
'join_miter'
</code>
.
</p>
</li>
<li class="listitem">
<p>
For end strategies, permitted values are
<code class="literal">
'end_round'
</code>
and
<code class="literal">
'end_flat'
</code>
.
</p>
</li>
</ul>
</div>
<p>
If the first argument is
<code class="literal">
'point_circle'
</code>
,
<code class="literal">
'join_round'
</code>
,
<code class="literal">
'join_miter'
</code>
, or
<code class="literal">
'end_round'
</code>
, the
<em class="replaceable">
<code>
points_per_circle
</code>
</em>
argument must be
given as a positive numeric value. The maximum
<em class="replaceable">
<code>
points_per_circle
</code>
</em>
value is the
value of the
<a class="link" href="server-system-variables.html#sysvar_max_points_in_geometry">
<code class="literal">
max_points_in_geometry
</code>
</a>
system
variable.
</p>
<p>
For examples, see the description of
<a class="link" href="spatial-operator-functions.html#function_st-buffer">
<code class="literal">
ST_Buffer()
</code>
</a>
.
</p>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-buffer-strategy">
<code class="literal">
ST_Buffer_Strategy()
</code>
</a>
handles
its arguments as described in the introduction to this
section, with these exceptions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
If any argument is invalid, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_wrong_arguments" target="_top">
<code class="literal">
ER_WRONG_ARGUMENTS
</code>
</a>
error
occurs.
</p>
</li>
<li class="listitem">
<p>
If the first argument is
<code class="literal">
'point_square'
</code>
or
<code class="literal">
'end_flat'
</code>
, the
<em class="replaceable">
<code>
points_per_circle
</code>
</em>
argument must
not be given or an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_wrong_arguments" target="_top">
<code class="literal">
ER_WRONG_ARGUMENTS
</code>
</a>
error
occurs.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<a name="function_st-convexhull">
</a>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-convexhull">
<code class="literal">
ST_ConvexHull(
<em class="replaceable">
<code>
g
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045196843216">
</a>
<p>
Returns a geometry that represents the convex hull of the
geometry value
<em class="replaceable">
<code>
g
</code>
</em>
.
</p>
<p>
This function computes a geometry's convex hull by first
checking whether its vertex points are colinear. The function
returns a linear hull if so, a polygon hull otherwise. This
function processes geometry collections by extracting all
vertex points of all components of the collection, creating a
<code class="literal">
MultiPoint
</code>
value from them, and computing
its convex hull.
</p>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-convexhull">
<code class="literal">
ST_ConvexHull()
</code>
</a>
handles its
arguments as described in the introduction to this section,
with this exception:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
The return value is
<code class="literal">
NULL
</code>
for the
additional condition that the argument is an empty
geometry collection.
</p>
</li>
</ul>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa77755492"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@g</span> <span class="token operator">=</span> <span class="token string">'MULTIPOINT(5 0,25 0,15 10,15 25)'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span><span class="token function">ST_ConvexHull</span><span class="token punctuation">(</span><span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token variable">@g</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(ST_ConvexHull(ST_GeomFromText(@g))) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> POLYGON((5 0,25 0,15 25,5 0)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
<li class="listitem">
<a name="function_st-difference">
</a>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-difference">
<code class="literal">
ST_Difference(
<em class="replaceable">
<code>
g1
</code>
</em>
,
<em class="replaceable">
<code>
g2
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045196826352">
</a>
<p>
Returns a geometry that represents the point set difference of
the geometry values
<em class="replaceable">
<code>
g1
</code>
</em>
and
<em class="replaceable">
<code>
g2
</code>
</em>
. The result is in the same SRS
as the geometry arguments.
</p>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-difference">
<code class="literal">
ST_Difference()
</code>
</a>
permits
arguments in either a Cartesian or a geographic SRS, and
handles its arguments as described in the introduction to this
section.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa51870913"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@g1</span> <span class="token operator">=</span> <span class="token function">Point</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token variable">@g2</span> <span class="token operator">=</span> <span class="token function">Point</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span><span class="token function">ST_Difference</span><span class="token punctuation">(</span><span class="token variable">@g1</span><span class="token punctuation">,</span> <span class="token variable">@g2</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(ST_Difference(@g1, @g2)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> POINT(1 1) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
<li class="listitem">
<a name="function_st-intersection">
</a>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-intersection">
<code class="literal">
ST_Intersection(
<em class="replaceable">
<code>
g1
</code>
</em>
,
<em class="replaceable">
<code>
g2
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045196812576">
</a>
<p>
Returns a geometry that represents the point set intersection
of the geometry values
<em class="replaceable">
<code>
g1
</code>
</em>
and
<em class="replaceable">
<code>
g2
</code>
</em>
. The result is in the same SRS
as the geometry arguments.
</p>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-intersection">
<code class="literal">
ST_Intersection()
</code>
</a>
permits
arguments in either a Cartesian or a geographic SRS, and
handles its arguments as described in the introduction to this
section.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa11054557"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@g1</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'LineString(1 1, 3 3)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@g2</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'LineString(1 3, 3 1)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span><span class="token function">ST_Intersection</span><span class="token punctuation">(</span><span class="token variable">@g1</span><span class="token punctuation">,</span> <span class="token variable">@g2</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(ST_Intersection(@g1, @g2)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> POINT(2 2) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
<li class="listitem">
<a name="function_st-lineinterpolatepoint">
</a>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-lineinterpolatepoint">
<code class="literal">
ST_LineInterpolatePoint(
<em class="replaceable">
<code>
ls
</code>
</em>
,
<em class="replaceable">
<code>
fractional_distance
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045196798016">
</a>
<p>
This function takes a
<code class="literal">
LineString
</code>
geometry
and a fractional distance in the range [0.0, 1.0] and returns
the
<code class="literal">
Point
</code>
along the
<code class="literal">
LineString
</code>
at the given fraction of the
distance from its start point to its endpoint. It can be used
to answer questions such as which
<code class="literal">
Point
</code>
lies halfway along the road described by the geometry
argument.
</p>
<p>
The function is implemented for
<code class="literal">
LineString
</code>
geometries in all spatial reference systems, both Cartesian
and geographic.
</p>
<p>
If the
<em class="replaceable">
<code>
fractional_distance
</code>
</em>
argument
is 1.0, the result may not be exactly the last point of the
<code class="literal">
LineString
</code>
argument but a point close to it
due to numerical inaccuracies in approximate-value
computations.
</p>
<p>
A related function,
<a class="link" href="spatial-operator-functions.html#function_st-lineinterpolatepoints">
<code class="literal">
ST_LineInterpolatePoints()
</code>
</a>
,
takes similar arguments but returns a
<code class="literal">
MultiPoint
</code>
consisting of
<code class="literal">
Point
</code>
values along the
<code class="literal">
LineString
</code>
at each fraction of the distance
from its start point to its endpoint. For examples of both
functions, see the
<a class="link" href="spatial-operator-functions.html#function_st-lineinterpolatepoints">
<code class="literal">
ST_LineInterpolatePoints()
</code>
</a>
description.
</p>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-lineinterpolatepoint">
<code class="literal">
ST_LineInterpolatePoint()
</code>
</a>
handles its arguments as described in the introduction to this
section, with these exceptions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
If the geometry argument is not a
<code class="literal">
LineString
</code>
, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_unexpected_geometry_type" target="_top">
<code class="literal">
ER_UNEXPECTED_GEOMETRY_TYPE
</code>
</a>
error occurs.
</p>
</li>
<li class="listitem">
<p>
If the fractional distance argument is outside the range
[0.0, 1.0], an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_data_out_of_range" target="_top">
<code class="literal">
ER_DATA_OUT_OF_RANGE
</code>
</a>
error
occurs.
</p>
</li>
</ul>
</div>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-lineinterpolatepoint">
<code class="literal">
ST_LineInterpolatePoint()
</code>
</a>
is a
MySQL extension to OpenGIS.
</p>
</li>
<li class="listitem">
<a name="function_st-lineinterpolatepoints">
</a>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-lineinterpolatepoints">
<code class="literal">
ST_LineInterpolatePoints(
<em class="replaceable">
<code>
ls
</code>
</em>
,
<em class="replaceable">
<code>
fractional_distance
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045196769456">
</a>
<p>
This function takes a
<code class="literal">
LineString
</code>
geometry
and a fractional distance in the range (0.0, 1.0] and returns
the
<code class="literal">
MultiPoint
</code>
consisting of the
<code class="literal">
LineString
</code>
start point, plus
<code class="literal">
Point
</code>
values along the
<code class="literal">
LineString
</code>
at each fraction of the distance
from its start point to its endpoint. It can be used to answer
questions such as which
<code class="literal">
Point
</code>
values lie
every 10% of the way along the road described by the geometry
argument.
</p>
<p>
The function is implemented for
<code class="literal">
LineString
</code>
geometries in all spatial reference systems, both Cartesian
and geographic.
</p>
<p>
If the
<em class="replaceable">
<code>
fractional_distance
</code>
</em>
argument
divides 1.0 with zero remainder the result may not contain the
last point of the
<code class="literal">
LineString
</code>
argument but a
point close to it due to numerical inaccuracies in
approximate-value computations.
</p>
<p>
A related function,
<a class="link" href="spatial-operator-functions.html#function_st-lineinterpolatepoint">
<code class="literal">
ST_LineInterpolatePoint()
</code>
</a>
,
takes similar arguments but returns the
<code class="literal">
Point
</code>
along the
<code class="literal">
LineString
</code>
at the given fraction of the
distance from its start point to its endpoint.
</p>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-lineinterpolatepoints">
<code class="literal">
ST_LineInterpolatePoints()
</code>
</a>
handles its arguments as described in the introduction to this
section, with these exceptions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
If the geometry argument is not a
<code class="literal">
LineString
</code>
, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_unexpected_geometry_type" target="_top">
<code class="literal">
ER_UNEXPECTED_GEOMETRY_TYPE
</code>
</a>
error occurs.
</p>
</li>
<li class="listitem">
<p>
If the fractional distance argument is outside the range
[0.0, 1.0], an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_data_out_of_range" target="_top">
<code class="literal">
ER_DATA_OUT_OF_RANGE
</code>
</a>
error
occurs.
</p>
</li>
</ul>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa24347528"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@ls1</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'LINESTRING(0 0,0 5,5 5)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span>ST_LineInterpolatePoint<span class="token punctuation">(</span><span class="token variable">@ls1</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(ST_LineInterpolatePoint(@ls1, .5)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> POINT(0 5) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span>ST_LineInterpolatePoint<span class="token punctuation">(</span><span class="token variable">@ls1</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token number">75</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(ST_LineInterpolatePoint(@ls1, .75)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> POINT(2.5 5) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span>ST_LineInterpolatePoint<span class="token punctuation">(</span><span class="token variable">@ls1</span><span class="token punctuation">,</span> <span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(ST_LineInterpolatePoint(@ls1, 1)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> POINT(5 5) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span>ST_LineInterpolatePoints<span class="token punctuation">(</span><span class="token variable">@ls1</span><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token number">25</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(ST_LineInterpolatePoints(@ls1, .25)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> MULTIPOINT((0 2.5),(0 5),(2.5 5),(5 5)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-lineinterpolatepoints">
<code class="literal">
ST_LineInterpolatePoints()
</code>
</a>
is a
MySQL extension to OpenGIS.
</p>
</li>
<li class="listitem">
<a name="function_st-pointatdistance">
</a>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-pointatdistance">
<code class="literal">
ST_PointAtDistance(
<em class="replaceable">
<code>
ls
</code>
</em>
,
<em class="replaceable">
<code>
distance
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045196734736">
</a>
<p>
This function takes a
<code class="literal">
LineString
</code>
geometry
and a distance in the range [0.0,
<a class="link" href="gis-linestring-property-functions.html#function_st-length">
<code class="literal">
ST_Length(
<em class="replaceable">
<code>
ls
</code>
</em>
)
</code>
</a>
]
measured in the unit of the spatial reference system (SRS) of
the
<code class="literal">
LineString
</code>
, and returns the
<code class="literal">
Point
</code>
along the
<code class="literal">
LineString
</code>
at that distance from its start
point. It can be used to answer questions such as which
<code class="literal">
Point
</code>
value is 400 meters from the start of
the road described by the geometry argument.
</p>
<p>
The function is implemented for
<code class="literal">
LineString
</code>
geometries in all spatial reference systems, both Cartesian
and geographic.
</p>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-pointatdistance">
<code class="literal">
ST_PointAtDistance()
</code>
</a>
handles
its arguments as described in the introduction to this
section, with these exceptions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
If the geometry argument is not a
<code class="literal">
LineString
</code>
, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_unexpected_geometry_type" target="_top">
<code class="literal">
ER_UNEXPECTED_GEOMETRY_TYPE
</code>
</a>
error occurs.
</p>
</li>
<li class="listitem">
<p>
If the fractional distance argument is outside the range
[0.0,
<a class="link" href="gis-linestring-property-functions.html#function_st-length">
<code class="literal">
ST_Length(
<em class="replaceable">
<code>
ls
</code>
</em>
)
</code>
</a>
],
an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_data_out_of_range" target="_top">
<code class="literal">
ER_DATA_OUT_OF_RANGE
</code>
</a>
error occurs.
</p>
</li>
</ul>
</div>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-pointatdistance">
<code class="literal">
ST_PointAtDistance()
</code>
</a>
is a MySQL
extension to OpenGIS.
</p>
</li>
<li class="listitem">
<a name="function_st-symdifference">
</a>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-symdifference">
<code class="literal">
ST_SymDifference(
<em class="replaceable">
<code>
g1
</code>
</em>
,
<em class="replaceable">
<code>
g2
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045196710256">
</a>
<p>
Returns a geometry that represents the point set symmetric
difference of the geometry values
<em class="replaceable">
<code>
g1
</code>
</em>
and
<em class="replaceable">
<code>
g2
</code>
</em>
, which is defined as:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-clike"><div class="docs-select-all right" id="sa14902378"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-clike"><em class="replaceable">g1</em> symdifference <em class="replaceable">g2</em> <span class="token punctuation">:</span><span class="token operator">=</span> <span class="token punctuation">(</span><em class="replaceable">g1</em> union <em class="replaceable">g2</em><span class="token punctuation">)</span> difference <span class="token punctuation">(</span><em class="replaceable">g1</em> intersection <em class="replaceable">g2</em><span class="token punctuation">)</span></code></pre>
</div>
<p>
Or, in function call notation:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-clike"><div class="docs-select-all right" id="sa88549781"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-clike"><span class="token function">ST_SymDifference</span><span class="token punctuation">(</span><em class="replaceable">g1</em><span class="token punctuation">,</span> <em class="replaceable">g2</em><span class="token punctuation">)</span> <span class="token operator">=</span> <span class="token function">ST_Difference</span><span class="token punctuation">(</span><span class="token function">ST_Union</span><span class="token punctuation">(</span><em class="replaceable">g1</em><span class="token punctuation">,</span> <em class="replaceable">g2</em><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token function">ST_Intersection</span><span class="token punctuation">(</span><em class="replaceable">g1</em><span class="token punctuation">,</span> <em class="replaceable">g2</em><span class="token punctuation">)</span><span class="token punctuation">)</span></code></pre>
</div>
<p>
The result is in the same SRS as the geometry arguments.
</p>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-symdifference">
<code class="literal">
ST_SymDifference()
</code>
</a>
permits
arguments in either a Cartesian or a geographic SRS, and
handles its arguments as described in the introduction to this
section.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa70708436"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@g1</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'MULTIPOINT(5 0,15 10,15 25)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@g2</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'MULTIPOINT(1 1,15 10,15 25)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span><span class="token function">ST_SymDifference</span><span class="token punctuation">(</span><span class="token variable">@g1</span><span class="token punctuation">,</span> <span class="token variable">@g2</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(ST_SymDifference(@g1, @g2)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> MULTIPOINT((1 1),(5 0)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
<li class="listitem">
<a name="function_st-transform">
</a>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-transform">
<code class="literal">
ST_Transform(
<em class="replaceable">
<code>
g
</code>
</em>
,
<em class="replaceable">
<code>
target_srid
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045196688256">
</a>
<p>
Transforms a geometry from one spatial reference system (SRS)
to another. The return value is a geometry of the same type as
the input geometry with all coordinates transformed to the
target SRID,
<em class="replaceable">
<code>
target_srid
</code>
</em>
. MySQL
supports all SRSs defined by EPSG except for those listed
here:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
EPSG 1042 Krovak Modified
</p>
</li>
<li class="listitem">
<p>
EPSG 1043 Krovak Modified (North Orientated)
</p>
</li>
<li class="listitem">
<p>
EPSG 9816 Tunisia Mining Grid
</p>
</li>
<li class="listitem">
<p>
EPSG 9826 Lambert Conic Conformal (West Orientated)
</p>
</li>
</ul>
</div>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-transform">
<code class="literal">
ST_Transform()
</code>
</a>
handles its
arguments as described in the introduction to this section,
with these exceptions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Geometry arguments that have an SRID value for a
geographic SRS do not produce an error.
</p>
</li>
<li class="listitem">
<p>
If the geometry or target SRID argument has an SRID value
that refers to an undefined spatial reference system
(SRS), an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_srs_not_found" target="_top">
<code class="literal">
ER_SRS_NOT_FOUND
</code>
</a>
error occurs.
</p>
</li>
<li class="listitem">
<p>
If the geometry is in an SRS that
<a class="link" href="spatial-operator-functions.html#function_st-transform">
<code class="literal">
ST_Transform()
</code>
</a>
cannot
transform from, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_transform_source_srs_not_supported" target="_top">
<code class="literal">
ER_TRANSFORM_SOURCE_SRS_NOT_SUPPORTED
</code>
</a>
error occurs.
</p>
</li>
<li class="listitem">
<p>
If the target SRID is in an SRS that
<a class="link" href="spatial-operator-functions.html#function_st-transform">
<code class="literal">
ST_Transform()
</code>
</a>
cannot
transform to, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_transform_target_srs_not_supported" target="_top">
<code class="literal">
ER_TRANSFORM_TARGET_SRS_NOT_SUPPORTED
</code>
</a>
error occurs.
</p>
</li>
<li class="listitem">
<p>
If the geometry is in an SRS that is not WGS 84 and has no
TOWGS84 clause, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_transform_source_srs_missing_towgs84" target="_top">
<code class="literal">
ER_TRANSFORM_SOURCE_SRS_MISSING_TOWGS84
</code>
</a>
error occurs.
</p>
</li>
<li class="listitem">
<p>
If the target SRID is in an SRS that is not WGS 84 and has
no TOWGS84 clause, an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_transform_target_srs_missing_towgs84" target="_top">
<code class="literal">
ER_TRANSFORM_TARGET_SRS_MISSING_TOWGS84
</code>
</a>
error occurs.
</p>
</li>
</ul>
</div>
<p>
<a class="link" href="gis-general-property-functions.html#function_st-srid">
<code class="literal">
ST_SRID(
<em class="replaceable">
<code>
g
</code>
</em>
,
<em class="replaceable">
<code>
target_srid
</code>
</em>
)
</code>
</a>
and
<a class="link" href="spatial-operator-functions.html#function_st-transform">
<code class="literal">
ST_Transform(
<em class="replaceable">
<code>
g
</code>
</em>
,
<em class="replaceable">
<code>
target_srid
</code>
</em>
)
</code>
</a>
differ as
follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<a class="link" href="gis-general-property-functions.html#function_st-srid">
<code class="literal">
ST_SRID()
</code>
</a>
changes the
geometry SRID value without transforming its coordinates.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="spatial-operator-functions.html#function_st-transform">
<code class="literal">
ST_Transform()
</code>
</a>
transforms
the geometry coordinates in addition to changing its SRID
value.
</p>
</li>
</ul>
</div>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa78558441"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@p</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'POINT(52.381389 13.064444)'</span><span class="token punctuation">,</span> <span class="token number">4326</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span><span class="token variable">@p</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(@p) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> POINT(52.381389 13.064444) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@p</span> <span class="token operator">=</span> ST_Transform<span class="token punctuation">(</span><span class="token variable">@p</span><span class="token punctuation">,</span> <span class="token number">4230</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span><span class="token variable">@p</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(@p) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> POINT(52.38208611407426 13.065520672345304) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
<li class="listitem">
<a name="function_st-union">
</a>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-union">
<code class="literal">
ST_Union(
<em class="replaceable">
<code>
g1
</code>
</em>
,
<em class="replaceable">
<code>
g2
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045196645616">
</a>
<p>
Returns a geometry that represents the point set union of the
geometry values
<em class="replaceable">
<code>
g1
</code>
</em>
and
<em class="replaceable">
<code>
g2
</code>
</em>
. The result is in the same SRS
as the geometry arguments.
</p>
<p>
<a class="link" href="spatial-operator-functions.html#function_st-union">
<code class="literal">
ST_Union()
</code>
</a>
permits arguments in
either a Cartesian or a geographic SRS, and handles its
arguments as described in the introduction to this section.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa33585503"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@g1</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'LineString(1 1, 3 3)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token variable">@g2</span> <span class="token operator">=</span> <span class="token function">ST_GeomFromText</span><span class="token punctuation">(</span><span class="token string">'LineString(1 3, 3 1)'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">ST_AsText</span><span class="token punctuation">(</span><span class="token function">ST_Union</span><span class="token punctuation">(</span><span class="token variable">@g1</span><span class="token punctuation">,</span> <span class="token variable">@g2</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> ST_AsText(ST_Union(@g1, @g2)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> MULTILINESTRING((1 1,3 3),(1 3,3 1)) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-consistent-read.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="innodb-consistent-read">
</a>
17.7.2.3 Consistent Nonlocking Reads
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045164206624">
</a>
<a class="indexterm" name="idm46045164205168">
</a>
<p>
A
<a class="link" href="glossary.html#glos_consistent_read" title="consistent read">
consistent read
</a>
means that
<code class="literal">
InnoDB
</code>
uses multi-versioning to
present to a query a snapshot of the database at a point in
time. The query sees the changes made by transactions that
committed before that point in time, and no changes made by
later or uncommitted transactions. The exception to this rule is
that the query sees the changes made by earlier statements
within the same transaction. This exception causes the following
anomaly: If you update some rows in a table, a
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
sees the latest version of
the updated rows, but it might also see older versions of any
rows. If other sessions simultaneously update the same table,
the anomaly means that you might see the table in a state that
never existed in the database.
</p>
<p>
If the transaction
<a class="link" href="glossary.html#glos_isolation_level" title="isolation level">
isolation level
</a>
is
<a class="link" href="innodb-transaction-isolation-levels.html#isolevel_repeatable-read">
<code class="literal">
REPEATABLE READ
</code>
</a>
(the default
level), all consistent reads within the same transaction read
the snapshot established by the first such read in that
transaction. You can get a fresher snapshot for your queries by
committing the current transaction and after that issuing new
queries.
</p>
<p>
With
<a class="link" href="innodb-transaction-isolation-levels.html#isolevel_read-committed">
<code class="literal">
READ COMMITTED
</code>
</a>
isolation
level, each consistent read within a transaction sets and reads
its own fresh snapshot.
</p>
<p>
Consistent read is the default mode in which
<code class="literal">
InnoDB
</code>
processes
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements in
<a class="link" href="innodb-transaction-isolation-levels.html#isolevel_read-committed">
<code class="literal">
READ COMMITTED
</code>
</a>
and
<a class="link" href="innodb-transaction-isolation-levels.html#isolevel_repeatable-read">
<code class="literal">
REPEATABLE READ
</code>
</a>
isolation
levels. A consistent read does not set any locks on the tables
it accesses, and therefore other sessions are free to modify
those tables at the same time a consistent read is being
performed on the table.
</p>
<p>
Suppose that you are running in the default
<a class="link" href="innodb-transaction-isolation-levels.html#isolevel_repeatable-read">
<code class="literal">
REPEATABLE READ
</code>
</a>
isolation
level. When you issue a consistent read (that is, an ordinary
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement),
<code class="literal">
InnoDB
</code>
gives your transaction a timepoint
according to which your query sees the database. If another
transaction deletes a row and commits after your timepoint was
assigned, you do not see the row as having been deleted. Inserts
and updates are treated similarly.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The snapshot of the database state applies to
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements within a
transaction, not necessarily to
<a class="link" href="glossary.html#glos_dml" title="DML">
DML
</a>
statements. If you insert
or modify some rows and then commit that transaction, a
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
or
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
statement issued from
another concurrent
<code class="literal">
REPEATABLE READ
</code>
transaction could affect those just-committed rows, even
though the session could not query them. If a transaction does
update or delete rows committed by a different transaction,
those changes do become visible to the current transaction.
For example, you might encounter a situation like the
following:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa51297438"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span>c1<span class="token punctuation">)</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> c1 <span class="token operator">=</span> <span class="token string">'xyz'</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">-- Returns 0: no rows match.</span>
<span class="token keyword">DELETE</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> c1 <span class="token operator">=</span> <span class="token string">'xyz'</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">-- Deletes several rows recently committed by other transaction.</span>
<span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span>c2<span class="token punctuation">)</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> c2 <span class="token operator">=</span> <span class="token string">'abc'</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">-- Returns 0: no rows match.</span>
<span class="token keyword">UPDATE</span> t1 <span class="token keyword">SET</span> c2 <span class="token operator">=</span> <span class="token string">'cba'</span> <span class="token keyword">WHERE</span> c2 <span class="token operator">=</span> <span class="token string">'abc'</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">-- Affects 10 rows: another txn just committed 10 rows with 'abc' values.</span>
<span class="token keyword">SELECT</span> <span class="token function">COUNT</span><span class="token punctuation">(</span>c2<span class="token punctuation">)</span> <span class="token keyword">FROM</span> t1 <span class="token keyword">WHERE</span> c2 <span class="token operator">=</span> <span class="token string">'cba'</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">-- Returns 10: this txn can now see the rows it just updated.</span></code></pre>
</div>
</div>
<p>
You can advance your timepoint by committing your transaction
and then doing another
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
or
<a class="link" href="commit.html" title="15.3.1 START TRANSACTION, COMMIT, and ROLLBACK Statements">
<code class="literal">
START TRANSACTION WITH
CONSISTENT SNAPSHOT
</code>
</a>
.
</p>
<p>
This is called
<span class="firstterm">
multi-versioned
concurrency control
</span>
.
</p>
<p>
In the following example, session A sees the row inserted by B
only when B has committed the insert and A has committed as
well, so that the timepoint is advanced past the commit of B.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa90885946"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"> <span class="token keyword">Session</span> A <span class="token keyword">Session</span> B
<span class="token keyword">SET</span> autocommit<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span> <span class="token keyword">SET</span> autocommit<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>
<span class="token datatype">time</span>
<span class="token operator">|</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t<span class="token punctuation">;</span>
<span class="token operator">|</span> <span class="token keyword">empty</span> <span class="token keyword">set</span>
<span class="token operator">|</span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t <span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token operator">|</span>
v <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t<span class="token punctuation">;</span>
<span class="token keyword">empty</span> <span class="token keyword">set</span>
<span class="token keyword">COMMIT</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t<span class="token punctuation">;</span>
<span class="token keyword">empty</span> <span class="token keyword">set</span>
<span class="token keyword">COMMIT</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t<span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">---------------------</span>
<span class="token output"> <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 2 <span class="token punctuation">|</span></span>
<span class="token comment" spellcheck="true">---------------------</span></code></pre>
</div>
<p>
If you want to see the
<span class="quote">
“
<span class="quote">
freshest
</span>
”
</span>
state of the
database, use either the
<a class="link" href="innodb-transaction-isolation-levels.html#isolevel_read-committed">
<code class="literal">
READ
COMMITTED
</code>
</a>
isolation level or a
<a class="link" href="glossary.html#glos_locking_read" title="locking read">
locking read
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa95818468"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t <span class="token keyword">FOR</span> <span class="token keyword">SHARE</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
With
<a class="link" href="innodb-transaction-isolation-levels.html#isolevel_read-committed">
<code class="literal">
READ COMMITTED
</code>
</a>
isolation
level, each consistent read within a transaction sets and reads
its own fresh snapshot. With
<code class="literal">
FOR SHARE
</code>
, a
locking read occurs instead: A
<code class="literal">
SELECT
</code>
blocks
until the transaction containing the freshest rows ends (see
<a class="xref" href="innodb-locking-reads.html" title="17.7.2.4 Locking Reads">
Section 17.7.2.4, “Locking Reads”
</a>
).
</p>
<p>
Consistent read does not work over certain DDL statements:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Consistent read does not work over
<a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
<code class="literal">
DROP
TABLE
</code>
</a>
, because MySQL cannot use a table that has
been dropped and
<code class="literal">
InnoDB
</code>
destroys the
table.
</p>
</li>
<li class="listitem">
<p>
Consistent read does not work over
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
operations that
make a temporary copy of the original table and delete the
original table when the temporary copy is built. When you
reissue a consistent read within a transaction, rows in the
new table are not visible because those rows did not exist
when the transaction's snapshot was taken. In this case, the
transaction returns an error:
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_table_def_changed" target="_top">
<code class="literal">
ER_TABLE_DEF_CHANGED
</code>
</a>
,
<span class="quote">
“
<span class="quote">
Table definition has changed, please retry
transaction
</span>
”
</span>
.
</p>
</li>
</ul>
</div>
<p>
The type of read varies for selects in clauses like
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT INTO ...
SELECT
</code>
</a>
,
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
... (SELECT)
</code>
</a>
, and
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE ...
SELECT
</code>
</a>
that do not specify
<code class="literal">
FOR
UPDATE
</code>
or
<code class="literal">
FOR SHARE
</code>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
By default,
<code class="literal">
InnoDB
</code>
uses stronger locks
for those statements and the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
part acts like
<a class="link" href="innodb-transaction-isolation-levels.html#isolevel_read-committed">
<code class="literal">
READ COMMITTED
</code>
</a>
, where
each consistent read, even within the same transaction, sets
and reads its own fresh snapshot.
</p>
</li>
<li class="listitem">
<p>
To perform a nonlocking read in such cases, set the
isolation level of the transaction to
<a class="link" href="innodb-transaction-isolation-levels.html#isolevel_read-uncommitted">
<code class="literal">
READ UNCOMMITTED
</code>
</a>
or
<a class="link" href="innodb-transaction-isolation-levels.html#isolevel_read-committed">
<code class="literal">
READ COMMITTED
</code>
</a>
to avoid
setting locks on rows read from the selected table.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/information-schema-innodb-metrics-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="information-schema-innodb-metrics-table">
</a>
28.4.21 The INFORMATION_SCHEMA INNODB_METRICS Table
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045076632400">
</a>
<p>
The
<a class="link" href="information-schema-innodb-metrics-table.html" title="28.4.21 The INFORMATION_SCHEMA INNODB_METRICS Table">
<code class="literal">
INNODB_METRICS
</code>
</a>
table provides a
wide variety of
<code class="literal">
InnoDB
</code>
performance information,
complementing the specific focus areas of the Performance Schema
tables for
<code class="literal">
InnoDB
</code>
. With simple queries, you can
check the overall health of the system. With more detailed
queries, you can diagnose issues such as performance bottlenecks,
resource shortages, and application issues.
</p>
<p>
Each monitor represents a point within the
<code class="literal">
InnoDB
</code>
source code that is instrumented to
gather counter information. Each counter can be started, stopped,
and reset. You can also perform these actions for a group of
counters using their common module name.
</p>
<p>
By default, relatively little data is collected. To start, stop,
and reset counters, set one of the system variables
<a class="link" href="innodb-parameters.html#sysvar_innodb_monitor_enable">
<code class="literal">
innodb_monitor_enable
</code>
</a>
,
<a class="link" href="innodb-parameters.html#sysvar_innodb_monitor_disable">
<code class="literal">
innodb_monitor_disable
</code>
</a>
,
<a class="link" href="innodb-parameters.html#sysvar_innodb_monitor_reset">
<code class="literal">
innodb_monitor_reset
</code>
</a>
, or
<a class="link" href="innodb-parameters.html#sysvar_innodb_monitor_reset_all">
<code class="literal">
innodb_monitor_reset_all
</code>
</a>
, using
the name of the counter, the name of the module, a wildcard match
for such a name using the
<span class="quote">
“
<span class="quote">
%
</span>
”
</span>
character, or the
special keyword
<code class="literal">
all
</code>
.
</p>
<p>
For usage information, see
<a class="xref" href="innodb-information-schema-metrics-table.html" title="17.15.6 InnoDB INFORMATION_SCHEMA Metrics Table">
Section 17.15.6, “InnoDB INFORMATION_SCHEMA Metrics Table”
</a>
.
</p>
<p>
The
<a class="link" href="information-schema-innodb-metrics-table.html" title="28.4.21 The INFORMATION_SCHEMA INNODB_METRICS Table">
<code class="literal">
INNODB_METRICS
</code>
</a>
table has these
columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
NAME
</code>
</p>
<p>
A unique name for the counter.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SUBSYSTEM
</code>
</p>
<p>
The aspect of
<code class="literal">
InnoDB
</code>
that the metric
applies to.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COUNT
</code>
</p>
<p>
The value since the counter was enabled.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MAX_COUNT
</code>
</p>
<p>
The maximum value since the counter was enabled.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MIN_COUNT
</code>
</p>
<p>
The minimum value since the counter was enabled.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AVG_COUNT
</code>
</p>
<p>
The average value since the counter was enabled.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COUNT_RESET
</code>
</p>
<p>
The counter value since it was last reset. (The
<code class="literal">
_RESET
</code>
columns act like the lap counter on
a stopwatch: you can measure the activity during some time
interval, while the cumulative figures are still available in
<code class="literal">
COUNT
</code>
,
<code class="literal">
MAX_COUNT
</code>
, and so
on.)
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MAX_COUNT_RESET
</code>
</p>
<p>
The maximum counter value since it was last reset.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MIN_COUNT_RESET
</code>
</p>
<p>
The minimum counter value since it was last reset.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
AVG_COUNT_RESET
</code>
</p>
<p>
The average counter value since it was last reset.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIME_ENABLED
</code>
</p>
<p>
The timestamp of the last start.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIME_DISABLED
</code>
</p>
<p>
The timestamp of the last stop.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIME_ELAPSED
</code>
</p>
<p>
The elapsed time in seconds since the counter started.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIME_RESET
</code>
</p>
<p>
The timestamp of the last reset.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STATUS
</code>
</p>
<p>
Whether the counter is still running
(
<code class="literal">
enabled
</code>
) or stopped
(
<code class="literal">
disabled
</code>
).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TYPE
</code>
</p>
<p>
Whether the item is a cumulative counter, or measures the
current value of some resource.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COMMENT
</code>
</p>
<p>
The counter description.
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045076578896">
</a>
Example
</h4>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa82574513"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_METRICS <span class="token keyword">WHERE</span> <span class="token keyword">NAME</span><span class="token operator">=</span><span class="token string">'dml_inserts'</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
NAME<span class="token punctuation">:</span> dml_inserts
SUBSYSTEM<span class="token punctuation">:</span> dml
COUNT<span class="token punctuation">:</span> 3
MAX_COUNT<span class="token punctuation">:</span> 3
MIN_COUNT<span class="token punctuation">:</span> NULL
AVG_COUNT<span class="token punctuation">:</span> 0.046153846153846156
COUNT_RESET<span class="token punctuation">:</span> 3
MAX_COUNT_RESET<span class="token punctuation">:</span> 3
MIN_COUNT_RESET<span class="token punctuation">:</span> NULL
AVG_COUNT_RESET<span class="token punctuation">:</span> NULL
TIME_ENABLED<span class="token punctuation">:</span> 2014-12-04 14<span class="token punctuation">:</span>18<span class="token punctuation">:</span>28
TIME_DISABLED<span class="token punctuation">:</span> NULL
TIME_ELAPSED<span class="token punctuation">:</span> 65
TIME_RESET<span class="token punctuation">:</span> NULL
STATUS<span class="token punctuation">:</span> enabled
TYPE<span class="token punctuation">:</span> status_counter
COMMENT<span class="token punctuation">:</span> Number of rows inserted</span></code></pre>
</div>
<h4>
<a name="idm46045076576016">
</a>
Notes
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
You must have the
<a class="link" href="privileges-provided.html#priv_process">
<code class="literal">
PROCESS
</code>
</a>
privilege to query this table.
</p>
</li>
<li class="listitem">
<p>
Use the
<code class="literal">
INFORMATION_SCHEMA
</code>
<a class="link" href="information-schema-columns-table.html" title="28.3.8 The INFORMATION_SCHEMA COLUMNS Table">
<code class="literal">
COLUMNS
</code>
</a>
table or the
<a class="link" href="show-columns.html" title="15.7.7.6 SHOW COLUMNS Statement">
<code class="literal">
SHOW COLUMNS
</code>
</a>
statement to view
additional information about the columns of this table,
including data types and default values.
</p>
</li>
<li class="listitem">
<p>
Transaction counter
<code class="literal">
COUNT
</code>
values may differ
from the number of transaction events reported in Performance
Schema
<code class="literal">
EVENTS_TRANSACTIONS_SUMMARY
</code>
tables.
<code class="literal">
InnoDB
</code>
counts only those transactions that
it executes, whereas Performance Schema collects events for
all non-aborted transactions initiated by the server,
including empty transactions.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/cannot-create.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="cannot-create">
</a>
B.3.2.11 Can't create/write to file
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045054253104">
</a>
<p>
If you get an error of the following type for some queries, it
means that MySQL cannot create a temporary file for the result
set in the temporary directory:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa90116259"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">Can't create/write to file '\\sqla3fe_0.ism'.</code></pre>
</div>
<p>
The preceding error is a typical message for Windows; the Unix
message is similar.
</p>
<p>
One fix is to start
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
with the
<a class="link" href="server-options.html#option_mysqld_tmpdir">
<code class="option">
--tmpdir
</code>
</a>
option or to add the
option to the
<code class="literal">
[mysqld]
</code>
section of your
option file. For example, to specify a directory of
<code class="filename">
C:\temp
</code>
, use these lines:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa52634924"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">tmpdir</span><span class="token attr-value"><span class="token punctuation">=</span>C:/temp</span></code></pre>
</div>
<p>
The
<code class="filename">
C:\temp
</code>
directory must exist and have
sufficient space for the MySQL server to write to. See
<a class="xref" href="option-files.html" title="6.2.2.2 Using Option Files">
Section 6.2.2.2, “Using Option Files”
</a>
.
</p>
<p>
Another cause of this error can be permissions issues. Make
sure that the MySQL server can write to the
<a class="link" href="server-system-variables.html#sysvar_tmpdir">
<code class="literal">
tmpdir
</code>
</a>
directory.
</p>
<p>
Check also the error code that you get with
<a class="link" href="perror.html" title="6.8.1 perror — Display MySQL Error Message Information">
<span class="command">
<strong>
perror
</strong>
</span>
</a>
. One reason the server cannot write
to a table is that the file system is full:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa27776411"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">perror</span> 28
OS error code 28<span class="token punctuation">:</span> No space left on device</code></pre>
</div>
<p>
If you get an error of the following type during startup, it
indicates that the file system or directory used for storing
data files is write protected. Provided that the write error
is to a test file, the error is not serious and can be safely
ignored.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa88151815"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">Can't create test file /usr/local/mysql/data/master.lower-test</code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/automatic-start.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="automatic-start">
</a>
2.9.5 Starting and Stopping MySQL Automatically
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045326593440">
</a>
<a class="indexterm" name="idm46045326591968">
</a>
<a class="indexterm" name="idm46045326590480">
</a>
<p>
This section discusses methods for starting and stopping the MySQL
server.
</p>
<p>
Generally, you start the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
server in one
of these ways:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Invoke
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
directly. This works on any
platform.
</p>
</li>
<li class="listitem">
<p>
On Windows, you can set up a MySQL service that runs
automatically when Windows starts. See
<a class="xref" href="windows-start-service.html" title="2.3.3.8 Starting MySQL as a Windows Service">
Section 2.3.3.8, “Starting MySQL as a Windows Service”
</a>
.
</p>
</li>
<li class="listitem">
<p>
On Unix and Unix-like systems, you can invoke
<a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
<span class="command">
<strong>
mysqld_safe
</strong>
</span>
</a>
, which tries to determine the
proper options for
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
and then runs it
with those options. See
<a class="xref" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
Section 6.3.2, “mysqld_safe — MySQL Server Startup Script”
</a>
.
</p>
</li>
<li class="listitem">
<p>
On Linux systems that support systemd, you can use it to
control the server. See
<a class="xref" href="using-systemd.html" title="2.5.9 Managing MySQL Server with systemd">
Section 2.5.9, “Managing MySQL Server with systemd”
</a>
.
</p>
</li>
<li class="listitem">
<p>
On systems that use System V-style run directories (that is,
<code class="filename">
/etc/init.d
</code>
and run-level specific
directories), invoke
<a class="link" href="mysql-server.html" title="6.3.3 mysql.server — MySQL Server Startup Script">
<span class="command">
<strong>
mysql.server
</strong>
</span>
</a>
. This
script is used primarily at system startup and shutdown. It
usually is installed under the name
<code class="literal">
mysql
</code>
.
The
<a class="link" href="mysql-server.html" title="6.3.3 mysql.server — MySQL Server Startup Script">
<span class="command">
<strong>
mysql.server
</strong>
</span>
</a>
script starts the server
by invoking
<a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
<span class="command">
<strong>
mysqld_safe
</strong>
</span>
</a>
. See
<a class="xref" href="mysql-server.html" title="6.3.3 mysql.server — MySQL Server Startup Script">
Section 6.3.3, “mysql.server — MySQL Server Startup Script”
</a>
.
</p>
</li>
<li class="listitem">
<p>
On macOS, install a launchd daemon to enable automatic MySQL
startup at system startup. The daemon starts the server by
invoking
<a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
<span class="command">
<strong>
mysqld_safe
</strong>
</span>
</a>
. For details, see
<a class="xref" href="macos-installation-launchd.html" title="2.4.3 Installing and Using the MySQL Launch Daemon">
Section 2.4.3, “Installing and Using the MySQL Launch Daemon”
</a>
. A MySQL
Preference Pane also provides control for starting and
stopping MySQL through the System Preferences. See
<a class="xref" href="macos-installation-prefpane.html" title="2.4.4 Installing and Using the MySQL Preference Pane">
Section 2.4.4, “Installing and Using the MySQL Preference Pane”
</a>
.
</p>
</li>
<li class="listitem">
<p>
On Solaris, use the service management framework (SMF) system
to initiate and control MySQL startup.
</p>
</li>
</ul>
</div>
<p>
systemd, the
<a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
<span class="command">
<strong>
mysqld_safe
</strong>
</span>
</a>
and
<a class="link" href="mysql-server.html" title="6.3.3 mysql.server — MySQL Server Startup Script">
<span class="command">
<strong>
mysql.server
</strong>
</span>
</a>
scripts, Solaris SMF, and the
macOS Startup Item (or MySQL Preference Pane) can be used to start
the server manually, or automatically at system startup time.
systemd,
<a class="link" href="mysql-server.html" title="6.3.3 mysql.server — MySQL Server Startup Script">
<span class="command">
<strong>
mysql.server
</strong>
</span>
</a>
, and the Startup Item
also can be used to stop the server.
</p>
<p>
The following table shows which option groups the server and
startup scripts read from option files.
</p>
<div class="table">
<a name="startup-scripts-server-option-groups">
</a>
<p class="title">
<b>
Table 2.14 MySQL Startup Scripts and Supported Server Option Groups
</b>
</p>
<div class="table-contents">
<table summary="MySQL startup scripts and the server option groups they support.">
<colgroup>
<col style="width: 20%"/>
<col style="width: 80%"/>
</colgroup>
<thead>
<tr>
<th>
Script
</th>
<th>
Option Groups
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
</td>
<td>
<code class="literal">
[mysqld]
</code>
,
<code class="literal">
[server]
</code>
,
<code class="literal">
[mysqld-
<em class="replaceable">
<code>
major_version
</code>
</em>
]
</code>
</td>
</tr>
<tr>
<td>
<a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
<span class="command">
<strong>
mysqld_safe
</strong>
</span>
</a>
</td>
<td>
<code class="literal">
[mysqld]
</code>
,
<code class="literal">
[server]
</code>
,
<code class="literal">
[mysqld_safe]
</code>
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-server.html" title="6.3.3 mysql.server — MySQL Server Startup Script">
<span class="command">
<strong>
mysql.server
</strong>
</span>
</a>
</td>
<td>
<code class="literal">
[mysqld]
</code>
,
<code class="literal">
[mysql.server]
</code>
,
<code class="literal">
[server]
</code>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<p>
<code class="literal">
[mysqld-
<em class="replaceable">
<code>
major_version
</code>
</em>
]
</code>
means that groups with names like
<code class="literal">
[mysqld-8.3]
</code>
and
<code class="literal">
[mysqld-8.4]
</code>
are read by servers
having versions 8.3.x, 8.4.x, and so
forth. This feature can be used to specify options that can be
read only by servers within a given release series.
</p>
<p>
For backward compatibility,
<a class="link" href="mysql-server.html" title="6.3.3 mysql.server — MySQL Server Startup Script">
<span class="command">
<strong>
mysql.server
</strong>
</span>
</a>
also
reads the
<code class="literal">
[mysql_server]
</code>
group and
<a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
<span class="command">
<strong>
mysqld_safe
</strong>
</span>
</a>
also reads the
<code class="literal">
[safe_mysqld]
</code>
group. To be current, you should
update your option files to use the
<code class="literal">
[mysql.server]
</code>
and
<code class="literal">
[mysqld_safe]
</code>
groups instead.
</p>
<p>
For more information on MySQL configuration files and their
structure and contents, see
<a class="xref" href="option-files.html" title="6.2.2.2 Using Option Files">
Section 6.2.2.2, “Using Option Files”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/functions.html | <div id="docs-body">
<div class="chapter">
<div class="titlepage">
<div>
<div>
<h1 class="title">
<a name="functions">
</a>
Chapter 14 Functions and Operators
</h1>
</div>
</div>
</div>
<div class="toc">
<p>
<b>
Table of Contents
</b>
</p>
<dl class="toc">
<dt>
<span class="section">
<a href="built-in-function-reference.html">
14.1 Built-In Function and Operator Reference
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="loadable-function-reference.html">
14.2 Loadable Function Reference
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="type-conversion.html">
14.3 Type Conversion in Expression Evaluation
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="non-typed-operators.html">
14.4 Operators
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="operator-precedence.html">
14.4.1 Operator Precedence
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="comparison-operators.html">
14.4.2 Comparison Functions and Operators
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="logical-operators.html">
14.4.3 Logical Operators
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="assignment-operators.html">
14.4.4 Assignment Operators
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="flow-control-functions.html">
14.5 Flow Control Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="numeric-functions.html">
14.6 Numeric Functions and Operators
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="arithmetic-functions.html">
14.6.1 Arithmetic Operators
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mathematical-functions.html">
14.6.2 Mathematical Functions
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="date-and-time-functions.html">
14.7 Date and Time Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="string-functions.html">
14.8 String Functions and Operators
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="string-comparison-functions.html">
14.8.1 String Comparison Functions and Operators
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="regexp.html">
14.8.2 Regular Expressions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="string-functions-charset.html">
14.8.3 Character Set and Collation of Function Results
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="fulltext-search.html">
14.9 Full-Text Search Functions
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="fulltext-natural-language.html">
14.9.1 Natural Language Full-Text Searches
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="fulltext-boolean.html">
14.9.2 Boolean Full-Text Searches
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="fulltext-query-expansion.html">
14.9.3 Full-Text Searches with Query Expansion
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="fulltext-stopwords.html">
14.9.4 Full-Text Stopwords
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="fulltext-restrictions.html">
14.9.5 Full-Text Restrictions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="fulltext-fine-tuning.html">
14.9.6 Fine-Tuning MySQL Full-Text Search
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="full-text-adding-collation.html">
14.9.7 Adding a User-Defined Collation for Full-Text Indexing
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="fulltext-search-ngram.html">
14.9.8 ngram Full-Text Parser
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="fulltext-search-mecab.html">
14.9.9 MeCab Full-Text Parser Plugin
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="cast-functions.html">
14.10 Cast Functions and Operators
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="xml-functions.html">
14.11 XML Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="bit-functions.html">
14.12 Bit Functions and Operators
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="encryption-functions.html">
14.13 Encryption and Compression Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="locking-functions.html">
14.14 Locking Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="information-functions.html">
14.15 Information Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="spatial-analysis-functions.html">
14.16 Spatial Analysis Functions
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="spatial-function-reference.html">
14.16.1 Spatial Function Reference
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="spatial-function-argument-handling.html">
14.16.2 Argument Handling by Spatial Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="gis-wkt-functions.html">
14.16.3 Functions That Create Geometry Values from WKT Values
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="gis-wkb-functions.html">
14.16.4 Functions That Create Geometry Values from WKB Values
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="gis-mysql-specific-functions.html">
14.16.5 MySQL-Specific Functions That Create Geometry Values
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="gis-format-conversion-functions.html">
14.16.6 Geometry Format Conversion Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="gis-property-functions.html">
14.16.7 Geometry Property Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="spatial-operator-functions.html">
14.16.8 Spatial Operator Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="spatial-relation-functions.html">
14.16.9 Functions That Test Spatial Relations Between Geometry Objects
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="spatial-geohash-functions.html">
14.16.10 Spatial Geohash Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="spatial-geojson-functions.html">
14.16.11 Spatial GeoJSON Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="spatial-aggregate-functions.html">
14.16.12 Spatial Aggregate Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="spatial-convenience-functions.html">
14.16.13 Spatial Convenience Functions
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="json-functions.html">
14.17 JSON Functions
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="json-function-reference.html">
14.17.1 JSON Function Reference
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="json-creation-functions.html">
14.17.2 Functions That Create JSON Values
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="json-search-functions.html">
14.17.3 Functions That Search JSON Values
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="json-modification-functions.html">
14.17.4 Functions That Modify JSON Values
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="json-attribute-functions.html">
14.17.5 Functions That Return JSON Value Attributes
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="json-table-functions.html">
14.17.6 JSON Table Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="json-validation-functions.html">
14.17.7 JSON Schema Validation Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="json-utility-functions.html">
14.17.8 JSON Utility Functions
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="replication-functions.html">
14.18 Replication Functions
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="group-replication-functions.html">
14.18.1 Group Replication Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="gtid-functions.html">
14.18.2 Functions Used with Global Transaction Identifiers (GTIDs)
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-functions-async-failover.html">
14.18.3 Asynchronous Replication Channel Failover Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-functions-synchronization.html">
14.18.4 Position-Based Synchronization Functions
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="aggregate-functions-and-modifiers.html">
14.19 Aggregate Functions
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="aggregate-functions.html">
14.19.1 Aggregate Function Descriptions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="group-by-modifiers.html">
14.19.2 GROUP BY Modifiers
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="group-by-handling.html">
14.19.3 MySQL Handling of GROUP BY
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="group-by-functional-dependence.html">
14.19.4 Detection of Functional Dependence
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="window-functions.html">
14.20 Window Functions
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="window-function-descriptions.html">
14.20.1 Window Function Descriptions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="window-functions-usage.html">
14.20.2 Window Function Concepts and Syntax
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="window-functions-frames.html">
14.20.3 Window Function Frame Specification
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="window-functions-named-windows.html">
14.20.4 Named Windows
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="window-function-restrictions.html">
14.20.5 Window Function Restrictions
</a>
</span>
</dt>
</dl>
</dd>
<dt>
<span class="section">
<a href="performance-schema-functions.html">
14.21 Performance Schema Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="internal-functions.html">
14.22 Internal Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="miscellaneous-functions.html">
14.23 Miscellaneous Functions
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="precision-math.html">
14.24 Precision Math
</a>
</span>
</dt>
<dd>
<dl>
<dt>
<span class="section">
<a href="precision-math-numbers.html">
14.24.1 Types of Numeric Values
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="precision-math-decimal-characteristics.html">
14.24.2 DECIMAL Data Type Characteristics
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="precision-math-expressions.html">
14.24.3 Expression Handling
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="precision-math-rounding.html">
14.24.4 Rounding Behavior
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="precision-math-examples.html">
14.24.5 Precision Math Examples
</a>
</span>
</dt>
</dl>
</dd>
</dl>
</div>
<a class="indexterm" name="idm46045210294496">
</a>
<a class="indexterm" name="idm46045210292992">
</a>
<a class="indexterm" name="idm46045210291920">
</a>
<p>
Expressions can be used at several points in
<a class="link" href="glossary.html#glos_sql" title="SQL">
SQL
</a>
statements, such as in the
<code class="literal">
ORDER BY
</code>
or
<code class="literal">
HAVING
</code>
clauses of
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements, in the
<code class="literal">
WHERE
</code>
clause of a
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
,
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
, or
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
statement, or in
<a class="link" href="set-variable.html" title="15.7.6.1 SET Syntax for Variable Assignment">
<code class="literal">
SET
</code>
</a>
statements. Expressions can be written using values from several
sources, such as literal values, column values,
<code class="literal">
NULL
</code>
, variables, built-in functions and
operators, loadable functions, and stored functions (a type of
stored object).
</p>
<p>
This chapter describes the built-in functions and operators that are
permitted for writing expressions in MySQL. For information about
loadable functions and stored functions, see
<a class="xref" href="server-loadable-functions.html" title="7.7 MySQL Server Loadable Functions">
Section 7.7, “MySQL Server Loadable Functions”
</a>
, and
<a class="xref" href="stored-routines.html" title="27.2 Using Stored Routines">
Section 27.2, “Using Stored Routines”
</a>
. For the rules describing how the
server interprets references to different kinds of functions, see
<a class="xref" href="function-resolution.html" title="11.2.5 Function Name Parsing and Resolution">
Section 11.2.5, “Function Name Parsing and Resolution”
</a>
.
</p>
<p>
An expression that contains
<code class="literal">
NULL
</code>
always produces
a
<code class="literal">
NULL
</code>
value unless otherwise indicated in the
documentation for a particular function or operator.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
By default, there must be no whitespace between a function name
and the parenthesis following it. This helps the MySQL parser
distinguish between function calls and references to tables or
columns that happen to have the same name as a function. However,
spaces around function arguments are permitted.
</p>
<p>
To tell the MySQL server to accept spaces after function names by
starting it with the
<a class="link" href="server-options.html#option_mysqld_sql-mode">
<code class="option">
--sql-mode=IGNORE_SPACE
</code>
</a>
option.
(See
<a class="xref" href="sql-mode.html" title="7.1.11 Server SQL Modes">
Section 7.1.11, “Server SQL Modes”
</a>
.) Individual client programs can
request this behavior by using the
<code class="literal">
CLIENT_IGNORE_SPACE
</code>
option for
<a class="ulink" href="/doc/c-api/8.4/en/mysql-real-connect.html" target="_top">
<code class="literal">
mysql_real_connect()
</code>
</a>
. In either
case, all function names become reserved words.
</p>
</div>
<p>
For the sake of brevity, some examples in this chapter display the
output from the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
program in abbreviated
form. Rather than showing examples in this format:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa5947103"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">MOD</span><span class="token punctuation">(</span><span class="token number">29</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> mod(29,9) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 rows in set (0.00 sec)</span></code></pre>
</div>
<p>
This format is used instead:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa53004479"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">MOD</span><span class="token punctuation">(</span><span class="token number">29</span><span class="token punctuation">,</span><span class="token number">9</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt"> -></span> <span class="token number">2</span></code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/myisam-key-cache.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="myisam-key-cache">
</a>
10.10.2 The MyISAM Key Cache
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="shared-key-cache.html">
10.10.2.1 Shared Key Cache Access
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="multiple-key-caches.html">
10.10.2.2 Multiple Key Caches
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="midpoint-insertion.html">
10.10.2.3 Midpoint Insertion Strategy
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="index-preloading.html">
10.10.2.4 Index Preloading
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="key-cache-block-size.html">
10.10.2.5 Key Cache Block Size
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="key-cache-restructuring.html">
10.10.2.6 Restructuring a Key Cache
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045223094912">
</a>
<a class="indexterm" name="idm46045223093840">
</a>
<p>
To minimize disk I/O, the
<code class="literal">
MyISAM
</code>
storage
engine exploits a strategy that is used by many database
management systems. It employs a cache mechanism to keep the
most frequently accessed table blocks in memory:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For index blocks, a special structure called the
<span class="firstterm">
key cache
</span>
(or
<span class="firstterm">
key buffer
</span>
) is
maintained. The structure contains a number of block buffers
where the most-used index blocks are placed.
</p>
</li>
<li class="listitem">
<p>
For data blocks, MySQL uses no special cache. Instead it
relies on the native operating system file system cache.
</p>
</li>
</ul>
</div>
<p>
This section first describes the basic operation of the
<code class="literal">
MyISAM
</code>
key cache. Then it discusses features
that improve key cache performance and that enable you to better
control cache operation:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Multiple sessions can access the cache concurrently.
</p>
</li>
<li class="listitem">
<p>
You can set up multiple key caches and assign table indexes
to specific caches.
</p>
</li>
</ul>
</div>
<p>
To control the size of the key cache, use the
<a class="link" href="server-system-variables.html#sysvar_key_buffer_size">
<code class="literal">
key_buffer_size
</code>
</a>
system
variable. If this variable is set equal to zero, no key cache is
used. The key cache also is not used if the
<a class="link" href="server-system-variables.html#sysvar_key_buffer_size">
<code class="literal">
key_buffer_size
</code>
</a>
value is too
small to allocate the minimal number of block buffers (8).
</p>
<p>
When the key cache is not operational, index files are accessed
using only the native file system buffering provided by the
operating system. (In other words, table index blocks are
accessed using the same strategy as that employed for table data
blocks.)
</p>
<p>
An index block is a contiguous unit of access to the
<code class="literal">
MyISAM
</code>
index files. Usually the size of an
index block is equal to the size of nodes of the index B-tree.
(Indexes are represented on disk using a B-tree data structure.
Nodes at the bottom of the tree are leaf nodes. Nodes above the
leaf nodes are nonleaf nodes.)
</p>
<p>
All block buffers in a key cache structure are the same size.
This size can be equal to, greater than, or less than the size
of a table index block. Usually one these two values is a
multiple of the other.
</p>
<p>
When data from any table index block must be accessed, the
server first checks whether it is available in some block buffer
of the key cache. If it is, the server accesses data in the key
cache rather than on disk. That is, it reads from the cache or
writes into it rather than reading from or writing to disk.
Otherwise, the server chooses a cache block buffer containing a
different table index block (or blocks) and replaces the data
there by a copy of required table index block. As soon as the
new index block is in the cache, the index data can be accessed.
</p>
<p>
If it happens that a block selected for replacement has been
modified, the block is considered
<span class="quote">
“
<span class="quote">
dirty.
</span>
”
</span>
In this
case, prior to being replaced, its contents are flushed to the
table index from which it came.
</p>
<p>
Usually the server follows an
<span class="firstterm">
LRU
(Least Recently Used)
</span>
strategy: When choosing a block
for replacement, it selects the least recently used index block.
To make this choice easier, the key cache module maintains all
used blocks in a special list (
<span class="firstterm">
LRU
chain
</span>
) ordered by time of use. When a block is
accessed, it is the most recently used and is placed at the end
of the list. When blocks need to be replaced, blocks at the
beginning of the list are the least recently used and become the
first candidates for eviction.
</p>
<p>
The
<code class="literal">
InnoDB
</code>
storage engine also uses an LRU
algorithm, to manage its buffer pool. See
<a class="xref" href="innodb-buffer-pool.html" title="17.5.1 Buffer Pool">
Section 17.5.1, “Buffer Pool”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-limitations-exclusive-to-cluster.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-limitations-exclusive-to-cluster">
</a>
25.2.7.8 Issues Exclusive to NDB Cluster
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045123221408">
</a>
<p>
The following are limitations specific to the
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
storage engine:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<b>
Machine architecture.
</b>
All machines used in the cluster must have the same
architecture. That is, all machines hosting nodes must be
either big-endian or little-endian, and you cannot use a
mixture of both. For example, you cannot have a management
node running on a PowerPC which directs a data node that
is running on an x86 machine. This restriction does not
apply to machines simply running
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
or other clients that may be accessing the cluster's
SQL nodes.
</p>
</li>
<li class="listitem">
<p>
<b>
Binary logging.
</b>
<a class="indexterm" name="idm46045123213216">
</a>
<a class="indexterm" name="idm46045123211728">
</a>
NDB Cluster has the following limitations or restrictions
with regard to binary logging:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
NDB Cluster cannot produce a binary log for tables
having
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
columns but
no primary key.
</p>
</li>
<li class="listitem">
<p>
Only the following schema operations are logged in a
cluster binary log which is
<span class="emphasis">
<em>
not
</em>
</span>
on
the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
executing the statement:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: square; ">
<li class="listitem">
<p>
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
<code class="literal">
DROP TABLE
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="create-database.html" title="15.1.12 CREATE DATABASE Statement">
<code class="literal">
CREATE DATABASE
</code>
</a>
/
<a class="link" href="create-database.html" title="15.1.12 CREATE DATABASE Statement">
<code class="literal">
CREATE
SCHEMA
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="drop-database.html" title="15.1.24 DROP DATABASE Statement">
<code class="literal">
DROP DATABASE
</code>
</a>
/
<a class="link" href="drop-database.html" title="15.1.24 DROP DATABASE Statement">
<code class="literal">
DROP
SCHEMA
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="create-tablespace.html" title="15.1.21 CREATE TABLESPACE Statement">
<code class="literal">
CREATE TABLESPACE
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="alter-tablespace.html" title="15.1.10 ALTER TABLESPACE Statement">
<code class="literal">
ALTER TABLESPACE
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="drop-tablespace.html" title="15.1.33 DROP TABLESPACE Statement">
<code class="literal">
DROP TABLESPACE
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="create-logfile-group.html" title="15.1.16 CREATE LOGFILE GROUP Statement">
<code class="literal">
CREATE LOGFILE GROUP
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="alter-logfile-group.html" title="15.1.6 ALTER LOGFILE GROUP Statement">
<code class="literal">
ALTER LOGFILE GROUP
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="drop-logfile-group.html" title="15.1.28 DROP LOGFILE GROUP Statement">
<code class="literal">
DROP LOGFILE GROUP
</code>
</a>
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<b>
Schema operations.
</b>
Schema operations (DDL statements) are rejected while any
data node restarts. Schema operations are also not
supported while performing an online upgrade or downgrade.
</p>
</li>
<li class="listitem">
<p>
<b>
Number of fragment replicas.
</b>
The number of fragment replicas, as determined by the
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-noofreplicas">
<code class="literal">
NoOfReplicas
</code>
</a>
data
node configuration parameter, is the number of copies of
all data stored by NDB Cluster. Setting this parameter to
1 means there is only a single copy; in this case, no
redundancy is provided, and the loss of a data node
entails loss of data. To guarantee redundancy, and thus
preservation of data even if a data node fails, set this
parameter to 2, which is the default and recommended value
in production.
</p>
<p>
Setting
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-noofreplicas">
<code class="literal">
NoOfReplicas
</code>
</a>
to a value greater than 2 is supported (to a maximum of 4)
but unnecessary to guard against loss of data.
</p>
</li>
</ul>
</div>
<p>
See also
<a class="xref" href="mysql-cluster-limitations-multiple-nodes.html" title="25.2.7.10 Limitations Relating to Multiple NDB Cluster Nodes">
Section 25.2.7.10, “Limitations Relating to Multiple NDB Cluster Nodes”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/rename-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="rename-table">
</a>
15.1.36 RENAME TABLE Statement
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045183202928">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa89532646"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">RENAME</span> <span class="token keyword">TABLE</span>
<em class="replaceable">tbl_name</em> <span class="token keyword">TO</span> <em class="replaceable">new_tbl_name</em>
<span class="token punctuation">[</span><span class="token punctuation">,</span> <em class="replaceable">tbl_name2</em> <span class="token keyword">TO</span> <em class="replaceable">new_tbl_name2</em><span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span></code></pre>
</div>
<p>
<a class="link" href="rename-table.html" title="15.1.36 RENAME TABLE Statement">
<code class="literal">
RENAME TABLE
</code>
</a>
renames one or more
tables. You must have
<a class="link" href="privileges-provided.html#priv_alter">
<code class="literal">
ALTER
</code>
</a>
and
<a class="link" href="privileges-provided.html#priv_drop">
<code class="literal">
DROP
</code>
</a>
privileges for the original
table, and
<a class="link" href="privileges-provided.html#priv_create">
<code class="literal">
CREATE
</code>
</a>
and
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
privileges for the new
table.
</p>
<p>
For example, to rename a table named
<code class="literal">
old_table
</code>
to
<code class="literal">
new_table
</code>
, use this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa52049950"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">RENAME</span> <span class="token keyword">TABLE</span> old_table <span class="token keyword">TO</span> new_table<span class="token punctuation">;</span></code></pre>
</div>
<p>
That statement is equivalent to the following
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa26542964"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> old_table <span class="token keyword">RENAME</span> new_table<span class="token punctuation">;</span></code></pre>
</div>
<p>
<code class="literal">
RENAME TABLE
</code>
, unlike
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER
TABLE
</code>
</a>
, can rename multiple tables within a single
statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa42857512"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">RENAME</span> <span class="token keyword">TABLE</span> old_table1 <span class="token keyword">TO</span> new_table1<span class="token punctuation">,</span>
old_table2 <span class="token keyword">TO</span> new_table2<span class="token punctuation">,</span>
old_table3 <span class="token keyword">TO</span> new_table3<span class="token punctuation">;</span></code></pre>
</div>
<p>
Renaming operations are performed left to right. Thus, to swap two
table names, do this (assuming that a table with the intermediary
name
<code class="literal">
tmp_table
</code>
does not already exist):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa1303115"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">RENAME</span> <span class="token keyword">TABLE</span> old_table <span class="token keyword">TO</span> tmp_table<span class="token punctuation">,</span>
new_table <span class="token keyword">TO</span> old_table<span class="token punctuation">,</span>
tmp_table <span class="token keyword">TO</span> new_table<span class="token punctuation">;</span></code></pre>
</div>
<p>
Metadata locks on tables are acquired in name order, which in some
cases can make a difference in operation outcome when multiple
transactions execute concurrently. See
<a class="xref" href="metadata-locking.html" title="10.11.4 Metadata Locking">
Section 10.11.4, “Metadata Locking”
</a>
.
</p>
<p>
You can rename tables locked with a
<a class="link" href="lock-tables.html" title="15.3.6 LOCK TABLES and UNLOCK TABLES Statements">
<code class="literal">
LOCK
TABLES
</code>
</a>
statement, provided that they are locked with a
<code class="literal">
WRITE
</code>
lock or are the product of renaming
<code class="literal">
WRITE
</code>
-locked tables from earlier steps in a
multiple-table rename operation. For example, this is permitted:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa87318334"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">LOCK</span> <span class="token keyword">TABLE</span> old_table1 <span class="token keyword">WRITE</span><span class="token punctuation">;</span>
<span class="token keyword">RENAME</span> <span class="token keyword">TABLE</span> old_table1 <span class="token keyword">TO</span> new_table1<span class="token punctuation">,</span>
new_table1 <span class="token keyword">TO</span> new_table2<span class="token punctuation">;</span></code></pre>
</div>
<p>
This is not permitted:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa78025772"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">LOCK</span> <span class="token keyword">TABLE</span> old_table1 <span class="token keyword">READ</span><span class="token punctuation">;</span>
<span class="token keyword">RENAME</span> <span class="token keyword">TABLE</span> old_table1 <span class="token keyword">TO</span> new_table1<span class="token punctuation">,</span>
new_table1 <span class="token keyword">TO</span> new_table2<span class="token punctuation">;</span></code></pre>
</div>
<p>
With the transaction table locking conditions satisfied, the
rename operation is done atomically; no other session can access
any of the tables while the rename is in progress.
</p>
<p>
If any errors occur during a
<code class="literal">
RENAME TABLE
</code>
, the
statement fails and no changes are made.
</p>
<p>
You can use
<code class="literal">
RENAME TABLE
</code>
to move a table from
one database to another:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa87316880"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">RENAME</span> <span class="token keyword">TABLE</span> <em class="replaceable">current_db<span class="token punctuation">.</span>tbl_name</em> <span class="token keyword">TO</span> <em class="replaceable">other_db<span class="token punctuation">.</span>tbl_name<span class="token punctuation">;</span></em><span class="token punctuation"></span></code></pre>
</div>
<a class="indexterm" name="idm46045183166896">
</a>
<a class="indexterm" name="idm46045183165408">
</a>
<p>
Using this method to move all tables from one database to a
different one in effect renames the database (an operation for
which MySQL has no single statement), except that the original
database continues to exist, albeit with no tables.
</p>
<p>
Like
<code class="literal">
RENAME TABLE
</code>
,
<code class="literal">
ALTER TABLE ...
RENAME
</code>
can also be used to move a table to a different
database. Regardless of the statement used, if the rename
operation would move the table to a database located on a
different file system, the success of the outcome is platform
specific and depends on the underlying operating system calls used
to move table files.
</p>
<p>
If a table has triggers, attempts to rename the table into a
different database fail with a
<span class="errortext">
Trigger in wrong
schema
</span>
(
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_trg_in_wrong_schema" target="_top">
<code class="literal">
ER_TRG_IN_WRONG_SCHEMA
</code>
</a>
) error.
</p>
<p>
An unencrypted table can be moved to an encryption-enabled
database and vice versa. However, if the
<a class="link" href="server-system-variables.html#sysvar_table_encryption_privilege_check">
<code class="literal">
table_encryption_privilege_check
</code>
</a>
variable is enabled, the
<a class="link" href="privileges-provided.html#priv_table-encryption-admin">
<code class="literal">
TABLE_ENCRYPTION_ADMIN
</code>
</a>
privilege is
required if the table encryption setting differs from the default
database encryption.
</p>
<a class="indexterm" name="idm46045183156096">
</a>
<p>
To rename
<code class="literal">
TEMPORARY
</code>
tables,
<code class="literal">
RENAME
TABLE
</code>
does not work. Use
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER
TABLE
</code>
</a>
instead.
</p>
<p>
<code class="literal">
RENAME TABLE
</code>
works for views, except that views
cannot be renamed into a different database.
</p>
<p>
Any privileges granted specifically for a renamed table or view
are not migrated to the new name. They must be changed manually.
</p>
<p>
<code class="literal">
RENAME TABLE
<em class="replaceable">
<code>
tbl_name
</code>
</em>
TO
<em class="replaceable">
<code>
new_tbl_name
</code>
</em>
</code>
changes
internally generated foreign key constraint names and user-defined
foreign key constraint names that begin with the string
<span class="quote">
“
<span class="quote">
<em class="replaceable">
<code>
tbl_name
</code>
</em>
_ibfk_
</span>
”
</span>
to
reflect the new table name.
<code class="literal">
InnoDB
</code>
interprets
foreign key constraint names that begin with the string
<span class="quote">
“
<span class="quote">
<em class="replaceable">
<code>
tbl_name
</code>
</em>
_ibfk_
</span>
”
</span>
as
internally generated names.
</p>
<p>
Foreign key constraint names that point to the renamed table are
automatically updated unless there is a conflict, in which case
the statement fails with an error. A conflict occurs if the
renamed constraint name already exists. In such cases, you must
drop and re-create the foreign keys for them to function properly.
</p>
<a class="indexterm" name="idm46045183144816">
</a>
<p>
<code class="literal">
RENAME TABLE
<em class="replaceable">
<code>
tbl_name
</code>
</em>
TO
<em class="replaceable">
<code>
new_tbl_name
</code>
</em>
</code>
changes
internally generated and user-defined
<code class="literal">
CHECK
</code>
constraint names that begin with the string
<span class="quote">
“
<span class="quote">
<em class="replaceable">
<code>
tbl_name
</code>
</em>
_chk_
</span>
”
</span>
to reflect
the new table name. MySQL interprets
<code class="literal">
CHECK
</code>
constraint names that begin with the string
<span class="quote">
“
<span class="quote">
<em class="replaceable">
<code>
tbl_name
</code>
</em>
_chk_
</span>
”
</span>
as
internally generated names. Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa51145263"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t1\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
Table<span class="token punctuation">:</span> t1
Create Table<span class="token punctuation">:</span> CREATE TABLE `t1` (
`i1` int(11) DEFAULT NULL,
`i2` int(11) DEFAULT NULL,
CONSTRAINT `t1_chk_1` CHECK ((`i1` > 0)),
CONSTRAINT `t1_chk_2` CHECK ((`i2` < 0))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
</span><span class="token output">1 row in set (0.02 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">RENAME</span> <span class="token keyword">TABLE</span> t1 <span class="token keyword">TO</span> t3<span class="token punctuation">;</span>
<span class="token output">Query OK, 0 rows affected (0.03 sec)</span>
<span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t3\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
Table<span class="token punctuation">:</span> t3
Create Table<span class="token punctuation">:</span> CREATE TABLE `t3` (
`i1` int(11) DEFAULT NULL,
`i2` int(11) DEFAULT NULL,
CONSTRAINT `t3_chk_1` CHECK ((`i1` > 0)),
CONSTRAINT `t3_chk_2` CHECK ((`i2` < 0))
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci
</span><span class="token output">1 row in set (0.01 sec)</span></code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/show-parse-tree.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="show-parse-tree">
</a>
15.7.7.26 SHOW PARSE_TREE Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045170065744">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa97634425"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SHOW</span> PARSE_TREE <em class="replaceable">select_statement</em></code></pre>
</div>
<p>
<a class="link" href="show-parse-tree.html" title="15.7.7.26 SHOW PARSE_TREE Statement">
<code class="literal">
SHOW PARSE_TREE
</code>
</a>
displays a
representation of the parse tree for the input
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement, in JSON format.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
This statement is available only in debug builds, or if the
MySQL server was built using
<a class="link" href="source-configuration-options.html#option_cmake_with_show_parse_tree">
<code class="option">
-DWITH_SHOW_PARSE_TREE
</code>
</a>
. It is
intended for use in testing and development only, and not in
production.
</p>
</div>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa79942265"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> PARSE_TREE <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t3 <span class="token keyword">WHERE</span> o_id <span class="token operator">></span> <span class="token number">2</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
Show_parse_tree<span class="token punctuation">:</span> {
"text"<span class="token punctuation">:</span> "SELECT <span class="token punctuation">*</span> FROM t3 WHERE o_id > 2",
"type"<span class="token punctuation">:</span> "PT_select_stmt",
"components"<span class="token punctuation">:</span> [
{
"text"<span class="token punctuation">:</span> "SELECT <span class="token punctuation">*</span> FROM t3 WHERE o_id > 2",
"type"<span class="token punctuation">:</span> "PT_query_expression",
"components"<span class="token punctuation">:</span> [
{
"text"<span class="token punctuation">:</span> "SELECT <span class="token punctuation">*</span> FROM t3 WHERE o_id > 2",
"type"<span class="token punctuation">:</span> "PT_query_specification",
"components"<span class="token punctuation">:</span> [
{
"text"<span class="token punctuation">:</span> "<span class="token punctuation">*</span>",
"type"<span class="token punctuation">:</span> "PT_select_item_list",
"components"<span class="token punctuation">:</span> [
{
"text"<span class="token punctuation">:</span> "<span class="token punctuation">*</span>",
"type"<span class="token punctuation">:</span> "Item_asterisk"
}
]
},
{
"text"<span class="token punctuation">:</span> "t3",
"type"<span class="token punctuation">:</span> "PT_table_factor_table_ident",
"table_ident"<span class="token punctuation">:</span> "`t3`"
},
{
"text"<span class="token punctuation">:</span> "o_id > 2",
"type"<span class="token punctuation">:</span> "PTI_where",
"components"<span class="token punctuation">:</span> [
{
"text"<span class="token punctuation">:</span> "o_id > 2",
"type"<span class="token punctuation">:</span> "PTI_comp_op",
"operator"<span class="token punctuation">:</span> ">",
"components"<span class="token punctuation">:</span> [
{
"text"<span class="token punctuation">:</span> "o_id",
"type"<span class="token punctuation">:</span> "PTI_simple_ident_ident"
},
{
"text"<span class="token punctuation">:</span> "2",
"type"<span class="token punctuation">:</span> "Item_int"
}
]
}
]
}
]
}
]
}
]
}
</span><span class="token output">1 row in set (0.01 sec)</span></code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-replication-understanding-consistency-guarantees.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="group-replication-understanding-consistency-guarantees">
</a>
20.5.3.1 Understanding Transaction Consistency Guarantees
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045133386288">
</a>
<a class="indexterm" name="idm46045133384768">
</a>
<p>
In terms of distributed consistency guarantees, either in normal
or failure repair operations, Group Replication has always been
an eventual consistency system. This means that as soon as the
incoming traffic slows down or stops, all group members have the
same data content. The events that relate to the consistency of
a system can be split into control operations, either manual or
automatically triggered by failures; and data flow operations.
</p>
<p>
For Group Replication, the control operations that can be
evaluated in terms of consistency are:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
a member joining or leaving, which is covered by Group
Replication's
<a class="xref" href="group-replication-distributed-recovery.html" title="20.5.4 Distributed Recovery">
Section 20.5.4, “Distributed Recovery”
</a>
and
write protection.
</p>
</li>
<li class="listitem">
<p>
network failures, which are covered by the fencing modes.
</p>
</li>
<li class="listitem">
<p>
in single-primary groups, primary failover, which can also
be an operation triggered by
<a class="link" href="group-replication-functions-for-new-primary.html#function_group-replication-set-as-primary">
<code class="literal">
group_replication_set_as_primary()
</code>
</a>
.
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="group-replication-control-operation-failover">
</a>
Consistency Guarantees and Primary Failover
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045133374784">
</a>
<a class="indexterm" name="idm46045133373296">
</a>
<p>
In a single-primary group, in the event of a primary failover
when a secondary is promoted to primary, the new primary can
either be made available to application traffic immediately,
regardless of how large the replication backlog is, or
alternatively access to it can be restricted until the backlog
has been applied.
</p>
<p>
With the first approach, the group takes the minimum time
possible to secure a stable group membership after a primary
failure by electing a new primary and then allowing data
access immediately while it is still applying any possible
backlog from the old primary. Write consistency is ensured,
but reads can temporarily retrieve stale data while the new
primary applies the backlog. For example, if client C1 wrote
<code class="literal">
A=2 WHERE A=1
</code>
on the old primary just
before its failure, when client C1 is reconnected to the new
primary it could potentially read
<code class="literal">
A=1
</code>
until
the new primary applies its backlog and catches up with the
state of the old primary before it left the group.
</p>
<p>
With the second alternative, the system secures a stable group
membership after the primary failure and elects a new primary
in the same way as the first alternative, but in this case the
group then waits until the new primary applies all backlog and
only then does it permit data access. This ensures that in a
situation as described previously, when client C1 is
reconnected to the new primary it reads
<code class="literal">
A=2
</code>
. However, the trade-off is that the
time required to failover is then proportional to the size of
the backlog, which on a correctly configured group should be
small
.
</p>
<p>
You can determine the level of transaction consistency
guarantees provided by members during primary failover using
the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_consistency">
<code class="literal">
group_replication_consistency
</code>
</a>
variable. See
<a class="xref" href="group-replication-configuring-consistency-guarantees.html#group-replication-consistency-level-impact-election" title="Impact of Consistency on Primary Election">
Impact of Consistency on Primary Election
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="group-replication-data-flow-operations">
</a>
Data Flow Operations
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045133360960">
</a>
<p>
Data flow is relevant to group consistency guarantees due to
the reads and writes executed against a group, especially when
these operations are distributed across all members. Data flow
operations apply to both modes of Group Replication:
single-primary and multi-primary, however to make this
explanation clearer it is restricted to single-primary mode.
The usual way to split incoming read or write transactions
across a single-primary group's members is to route writes to
the primary and evenly distribute reads to the secondaries.
Since the group should behave as a single entity, it is
reasonable to expect that writes on the primary are
instantaneously available on the secondaries. Although Group
Replication is written using Group Communication System (GCS)
protocols that implement the Paxos algorithm, some parts of
Group Replication are asynchronous, which implies that data is
asynchronously applied to secondaries. This means that a
client C2 can write
<code class="literal">
B=2 WHERE B=1
</code>
on the
primary, immediately connect to a secondary and read
<code class="literal">
B=1
</code>
. This is because the secondary is still
applying backlog, and has not applied the transaction which
was applied by the primary.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="group-replication-synchronization-points">
</a>
Transaction Synchronization Points
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045133354944">
</a>
<p>
You configure a group's consistency guarantee based on the
point at which you want to synchronize transactions across the
group. To help you understand the concept, this section
simplifies the points of synchronizing transactions across a
group to be at the time of a read operation or at the time of
a write operation. If data is synchronized at the time of a
read, the current client session waits until a given
point, which is the point in time that all preceding update
transactions have been applied, before it can start executing.
With this approach, only this session is affected, all other
concurrent data operations are not affected.
</p>
<p>
If data is synchronized at the time of write, the writing
session waits until all secondaries have written their data.
Group Replication uses a total order on writes, and therefore
this implies waiting for this and all preceding writes that
are in secondaries’ queues to be applied. Therefore when
using this synchronization point, the writing session waits
for all secondaries queues to be applied.
</p>
<p>
Any alternative ensures that in the situation described for
client C2 would always read
<code class="literal">
B=2
</code>
even if
immediately connected to a secondary. Each alternative has its
advantages and disadvantages, which are directly related to
your system workload. The following examples describe
different types of workloads and advise which point of
synchronization is appropriate.
</p>
<p>
Imagine the following situations:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
You want to load-balance reads without deploying
additional restrictions on which server you read from to
avoid reading stale data, group writes are much less
common than group reads.
</p>
</li>
<li class="listitem">
<p>
For a group that has predominantly read-only data, you
want read/write transactions to be applied everywhere once
they commit, so that subsequent reads are done on
up-to-date data that includes the latest write. This
ensures that you do not pay the synchronization cost for
every read-only transaction, but only for read/write
transactions.
</p>
</li>
</ul>
</div>
<p>
In these cases, you should choose to synchronize on writes.
</p>
<p>
Imagine the following situations:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
You want to load balance your reads without deploying
additional restrictions on which server you read from to
avoid reading stale data, group writes are much more
common than group reads.
</p>
</li>
<li class="listitem">
<p>
You want specific transactions in your workload to always
read up-to-date data from the group, for example whenever
sensitive data is updated (such as credentials for a file
or similar data) and you want to enforce that reads
retrieve the most up to date value.
</p>
</li>
</ul>
</div>
<p>
In these cases, you should choose to synchronize on reads.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-replication-ipv6.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="group-replication-ipv6">
</a>
20.5.5 Support For IPv6 And For Mixed IPv6 And IPv4 Groups
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045132868704">
</a>
<a class="indexterm" name="idm46045132867248">
</a>
<p>
Group Replication group members can use IPv6 addresses as an
alternative to IPv4 addresses for communications within the group.
To use IPv6 addresses, the operating system on the server host and
the MySQL Server instance must both be configured to support IPv6.
For instructions to set up IPv6 support for a server instance, see
<a class="xref" href="ipv6-support.html" title="7.1.13 IPv6 Support">
Section 7.1.13, “IPv6 Support”
</a>
.
</p>
<p>
IPv6 addresses, or host names that resolve to them, can be
specified as the network address that the member provides in the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_local_address">
<code class="literal">
group_replication_local_address
</code>
</a>
option for connections from other members. When specified with a
port number, an IPv6 address must be specified in square brackets,
for example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa53742953"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">group_replication_local_address<span class="token operator">=</span> "<span class="token punctuation">[</span>2001<span class="token operator">:</span>db8<span class="token operator">:</span>85a3<span class="token operator">:</span>8d3<span class="token operator">:</span>1319<span class="token operator">:</span>8a2e<span class="token operator">:</span>370<span class="token operator">:</span>7348<span class="token punctuation">]</span><span class="token operator">:</span>33061"</code></pre>
</div>
<p>
The network address or host name specified in
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_local_address">
<code class="literal">
group_replication_local_address
</code>
</a>
is used by Group Replication as the unique identifier for a group
member within the replication group. If a host name specified as
the Group Replication local address for a server instance resolves
to both an IPv4 and an IPv6 address, the IPv4 address is always
used for Group Replication connections. The address or host name
specified as the Group Replication local address is not the same
as the MySQL server SQL protocol host and port, and is not
specified in the
<a class="link" href="server-system-variables.html#sysvar_bind_address">
<code class="literal">
bind_address
</code>
</a>
system variable for the server instance. For the purpose of IP
address permissions for Group Replication (see
<a class="xref" href="group-replication-ip-address-permissions.html" title="20.6.4 Group Replication IP Address Permissions">
Section 20.6.4, “Group Replication IP Address Permissions”
</a>
), the
address that you specify for each group member in
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_local_address">
<code class="literal">
group_replication_local_address
</code>
</a>
must be added to the list for the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_ip_allowlist">
<code class="literal">
group_replication_ip_allowlist
</code>
</a>
system variable on the other servers in the replication group.
</p>
<p>
A replication group can contain a combination of members that
present an IPv6 address as their Group Replication local address,
and members that present an IPv4 address. When a server joins such
a mixed group, it must make the initial contact with the seed
member using the protocol that the seed member advertises in the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_group_seeds">
<code class="literal">
group_replication_group_seeds
</code>
</a>
option, whether that is IPv4 or IPv6. If any of the seed members
for the group are listed in the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_group_seeds">
<code class="literal">
group_replication_group_seeds
</code>
</a>
option with an IPv6 address when a joining member has an IPv4
Group Replication local address, or the reverse, you must also set
up and permit an alternative address for the joining member for
the required protocol (or a host name that resolves to an address
for that protocol). If a joining member does not have a permitted
address for the appropriate protocol, its connection attempt is
refused. The alternative address or host name only needs to be
added to the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_ip_allowlist">
<code class="literal">
group_replication_ip_allowlist
</code>
</a>
system variable on the other servers in the replication group, not
to the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_local_address">
<code class="literal">
group_replication_local_address
</code>
</a>
value for the joining member (which can only contain a single
address).
</p>
<p>
For example, server A is a seed member for a group, and has the
following configuration settings for Group Replication, so that it
is advertising an IPv6 address in the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_group_seeds">
<code class="literal">
group_replication_group_seeds
</code>
</a>
option:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-simple"><div class="docs-select-all right" id="sa67998240"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">group_replication_bootstrap_group<span class="token operator">=</span>on
group_replication_local_address<span class="token operator">=</span> "<span class="token punctuation">[</span>2001<span class="token operator">:</span>db8<span class="token operator">:</span>85a3<span class="token operator">:</span>8d3<span class="token operator">:</span>1319<span class="token operator">:</span>8a2e<span class="token operator">:</span>370<span class="token operator">:</span>7348<span class="token punctuation">]</span><span class="token operator">:</span>33061"
group_replication_group_seeds<span class="token operator">=</span> "<span class="token punctuation">[</span>2001<span class="token operator">:</span>db8<span class="token operator">:</span>85a3<span class="token operator">:</span>8d3<span class="token operator">:</span>1319<span class="token operator">:</span>8a2e<span class="token operator">:</span>370<span class="token operator">:</span>7348<span class="token punctuation">]</span><span class="token operator">:</span>33061"</code></pre>
</div>
<p>
Server B is a joining member for the group, and has the following
configuration settings for Group Replication, so that it has an
IPv4 Group Replication local address:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-simple"><div class="docs-select-all right" id="sa40373293"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">group_replication_bootstrap_group<span class="token operator">=</span>off
group_replication_local_address<span class="token operator">=</span> "203<span class="token punctuation">.</span>0<span class="token punctuation">.</span>113<span class="token punctuation">.</span>21<span class="token operator">:</span>33061"
group_replication_group_seeds<span class="token operator">=</span> "<span class="token punctuation">[</span>2001<span class="token operator">:</span>db8<span class="token operator">:</span>85a3<span class="token operator">:</span>8d3<span class="token operator">:</span>1319<span class="token operator">:</span>8a2e<span class="token operator">:</span>370<span class="token operator">:</span>7348<span class="token punctuation">]</span><span class="token operator">:</span>33061"</code></pre>
</div>
<p>
Server B also has an alternative IPv6 address
<code class="literal">
2001:db8:8b0:40:3d9c:cc43:e006:19e8
</code>
. For Server
B to join the group successfully, both its IPv4 Group Replication
local address, and its alternative IPv6 address, must be listed in
Server A's allowlist, as in the following example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-simple"><div class="docs-select-all right" id="sa59846858"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">group_replication_ip_allowlist<span class="token operator">=</span>
"203<span class="token punctuation">.</span>0<span class="token punctuation">.</span>113<span class="token punctuation">.</span>0<span class="token operator">/</span>24<span class="token punctuation">,</span>2001<span class="token operator">:</span>db8<span class="token operator">:</span>85a3<span class="token operator">:</span>8d3<span class="token operator">:</span>1319<span class="token operator">:</span>8a2e<span class="token operator">:</span>370<span class="token operator">:</span>7348<span class="token punctuation">,</span>
2001<span class="token operator">:</span>db8<span class="token operator">:</span>8b0<span class="token operator">:</span>40<span class="token operator">:</span>3d9c<span class="token operator">:</span>cc43<span class="token operator">:</span>e006<span class="token operator">:</span>19e8"</code></pre>
</div>
<p>
As a best practice for Group Replication IP address permissions,
Server B (and all other group members) should have the same
allowlist as Server A, unless security requirements demand
otherwise.
</p>
<p>
If any or all members of a replication group are using an older
MySQL Server version that does not support the use of IPv6
addresses for Group Replication, a member cannot participate in
the group using an IPv6 address (or a host name that resolves to
one) as its Group Replication local address. This applies both in
the case where at least one existing member uses an IPv6 address
and a new member that does not support this attempts to join, and
in the case where a new member attempts to join using an IPv6
address but the group includes at least one member that does not
support this. In each situation, the new member cannot join. To
make a joining member present an IPv4 address for group
communications, you can either change the value of
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_local_address">
<code class="literal">
group_replication_local_address
</code>
</a>
to an IPv4 address, or configure your DNS to resolve the joining
member's existing host name to an IPv4 address. After you have
upgraded every group member to a MySQL Server version that
supports IPv6 for Group Replication, you can change the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_local_address">
<code class="literal">
group_replication_local_address
</code>
</a>
value for each member to an IPv6 address, or configure your DNS to
present an IPv6 address. Changing the value of
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_local_address">
<code class="literal">
group_replication_local_address
</code>
</a>
takes effect only when you stop and restart Group Replication.
</p>
<p>
IPv6 addresses can also be used as distributed recovery endpoints,
which can be specified using the
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_advertise_recovery_endpoints">
<code class="literal">
group_replication_advertise_recovery_endpoints
</code>
</a>
system variable. The same rules apply to addresses used in this
list. See
<a class="xref" href="group-replication-distributed-recovery-connections.html" title="20.5.4.1 Connections for Distributed Recovery">
Section 20.5.4.1, “Connections for Distributed Recovery”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/my-print-defaults.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="my-print-defaults">
</a>
6.7.2 my_print_defaults — Display Options from Option Files
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045302980416">
</a>
<p>
<a class="link" href="my-print-defaults.html" title="6.7.2 my_print_defaults — Display Options from Option Files">
<span class="command">
<strong>
my_print_defaults
</strong>
</span>
</a>
displays the options that
are present in option groups of option files. The output
indicates what options are used by programs that read the
specified option groups. For example, the
<a class="link" href="mysqlcheck.html" title="6.5.3 mysqlcheck — A Table Maintenance Program">
<span class="command">
<strong>
mysqlcheck
</strong>
</span>
</a>
program reads the
<code class="literal">
[mysqlcheck]
</code>
and
<code class="literal">
[client]
</code>
option groups. To see what options are present in those groups
in the standard option files, invoke
<a class="link" href="my-print-defaults.html" title="6.7.2 my_print_defaults — Display Options from Option Files">
<span class="command">
<strong>
my_print_defaults
</strong>
</span>
</a>
like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa5510615"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">my_print_defaults</span> mysqlcheck client
<span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>myusername</span>
<span class="token constant">--password</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">password</em></span>
<span class="token constant">--host</span><span class="token attr-value"><span class="token punctuation">=</span>localhost</span></code></pre>
</div>
<p>
The output consists of options, one per line, in the form that
they would be specified on the command line.
</p>
<p>
<a class="link" href="my-print-defaults.html" title="6.7.2 my_print_defaults — Display Options from Option Files">
<span class="command">
<strong>
my_print_defaults
</strong>
</span>
</a>
supports the following
options.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_my_print_defaults_help">
</a>
<a class="link" href="my-print-defaults.html#option_my_print_defaults_help">
<code class="option">
--help
</code>
</a>
,
<code class="option">
-?
</code>
</p>
<a class="indexterm" name="idm46045302966224">
</a>
<a class="indexterm" name="idm46045302964736">
</a>
<p>
Display a help message and exit.
</p>
</li>
<li class="listitem">
<p>
<a name="option_my_print_defaults_config-file">
</a>
<a class="link" href="my-print-defaults.html#option_my_print_defaults_config-file">
<code class="option">
--config-file=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
,
<a class="link" href="my-print-defaults.html#option_my_print_defaults_config-file">
<code class="option">
--defaults-file=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
,
<code class="option">
-c
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</p>
<a class="indexterm" name="idm46045302958192">
</a>
<a class="indexterm" name="idm46045302956704">
</a>
<a class="indexterm" name="idm46045302955216">
</a>
<a class="indexterm" name="idm46045302953728">
</a>
<p>
Read only the given option file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_my_print_defaults_debug">
</a>
<a class="link" href="my-print-defaults.html#option_my_print_defaults_debug">
<code class="option">
--debug=
<em class="replaceable">
<code>
debug_options
</code>
</em>
</code>
</a>
,
<code class="option">
-#
<em class="replaceable">
<code>
debug_options
</code>
</em>
</code>
</p>
<a class="indexterm" name="idm46045302948416">
</a>
<a class="indexterm" name="idm46045302946928">
</a>
<p>
Write a debugging log. A typical
<em class="replaceable">
<code>
debug_options
</code>
</em>
string is
<code class="literal">
d:t:o,
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
.
The default is
<code class="literal">
d:t:o,/tmp/my_print_defaults.trace
</code>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_my_print_defaults_defaults-extra-file">
</a>
<a class="link" href="my-print-defaults.html#option_my_print_defaults_defaults-extra-file">
<code class="option">
--defaults-extra-file=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
,
<a class="link" href="my-print-defaults.html#option_my_print_defaults_defaults-extra-file">
<code class="option">
--extra-file=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
,
<code class="option">
-e
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</p>
<a class="indexterm" name="idm46045302938000">
</a>
<a class="indexterm" name="idm46045302936496">
</a>
<a class="indexterm" name="idm46045302934992">
</a>
<a class="indexterm" name="idm46045302933504">
</a>
<p>
Read this option file after the global option file but (on
Unix) before the user option file.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_my_print_defaults_defaults-group-suffix">
</a>
<a class="link" href="my-print-defaults.html#option_my_print_defaults_defaults-group-suffix">
<code class="option">
--defaults-group-suffix=
<em class="replaceable">
<code>
suffix
</code>
</em>
</code>
</a>
,
<code class="option">
-g
<em class="replaceable">
<code>
suffix
</code>
</em>
</code>
</p>
<a class="indexterm" name="idm46045302926880">
</a>
<a class="indexterm" name="idm46045302925376">
</a>
<p>
In addition to the groups named on the command line, read
groups that have the given suffix.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_my_print_defaults_login-path">
</a>
<a class="link" href="my-print-defaults.html#option_my_print_defaults_login-path">
<code class="option">
--login-path=
<em class="replaceable">
<code>
name
</code>
</em>
</code>
</a>
,
<code class="option">
-l
<em class="replaceable">
<code>
name
</code>
</em>
</code>
</p>
<a class="indexterm" name="idm46045302918960">
</a>
<a class="indexterm" name="idm46045302917472">
</a>
<p>
Read options from the named login path in the
<code class="filename">
.mylogin.cnf
</code>
login path file. A
<span class="quote">
“
<span class="quote">
login path
</span>
”
</span>
is an option group containing
options that specify which MySQL server to connect to and
which account to authenticate as. To create or modify a
login path file, use the
<a class="link" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
<span class="command">
<strong>
mysql_config_editor
</strong>
</span>
</a>
utility. See
<a class="xref" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
Section 6.6.7, “mysql_config_editor — MySQL Configuration Utility”
</a>
.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_my_print_defaults_no-login-paths">
</a>
<a class="link" href="my-print-defaults.html#option_my_print_defaults_no-login-paths">
<code class="option">
--no-login-paths
</code>
</a>
</p>
<a class="indexterm" name="idm46045302908736">
</a>
<a class="indexterm" name="idm46045302907248">
</a>
<p>
Skips reading options from the login path file.
</p>
<p>
See
<a class="link" href="my-print-defaults.html#option_my_print_defaults_login-path">
<code class="option">
--login-path
</code>
</a>
for related information.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_my_print_defaults_no-defaults">
</a>
<a class="link" href="my-print-defaults.html#option_my_print_defaults_no-defaults">
<code class="option">
--no-defaults
</code>
</a>
,
<code class="option">
-n
</code>
</p>
<a class="indexterm" name="idm46045302899968">
</a>
<a class="indexterm" name="idm46045302898480">
</a>
<p>
Return an empty string.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_my_print_defaults_show">
</a>
<a class="link" href="my-print-defaults.html#option_my_print_defaults_show">
<code class="option">
--show
</code>
</a>
,
<code class="option">
-s
</code>
</p>
<a class="indexterm" name="idm46045302892656">
</a>
<a class="indexterm" name="idm46045302891168">
</a>
<p>
<a class="link" href="my-print-defaults.html" title="6.7.2 my_print_defaults — Display Options from Option Files">
<span class="command">
<strong>
my_print_defaults
</strong>
</span>
</a>
masks passwords by
default. Use this option to display passwords as cleartext.
</p>
</li>
<li class="listitem">
<p>
<a name="option_my_print_defaults_verbose">
</a>
<a class="link" href="my-print-defaults.html#option_my_print_defaults_verbose">
<code class="option">
--verbose
</code>
</a>
,
<code class="option">
-v
</code>
</p>
<a class="indexterm" name="idm46045302885264">
</a>
<a class="indexterm" name="idm46045302883776">
</a>
<p>
Verbose mode. Print more information about what the program
does.
</p>
</li>
<li class="listitem">
<p>
<a name="option_my_print_defaults_version">
</a>
<a class="link" href="my-print-defaults.html#option_my_print_defaults_version">
<code class="option">
--version
</code>
</a>
,
<code class="option">
-V
</code>
</p>
<a class="indexterm" name="idm46045302879072">
</a>
<a class="indexterm" name="idm46045302877584">
</a>
<p>
Display version information and exit.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/locking-functions.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="locking-functions">
</a>
14.14 Locking Functions
</h2>
</div>
</div>
</div>
<a class="indexterm" name="idm46045199172640">
</a>
<a class="indexterm" name="idm46045199171568">
</a>
<p>
This section describes functions used to manipulate user-level
locks.
</p>
<div class="table">
<a name="idm46045199169600">
</a>
<p class="title">
<b>
Table 14.19 Locking Functions
</b>
</p>
<div class="table-contents">
<table frame="box" rules="all" summary="A reference that lists locking functions.">
<colgroup>
<col style="width: 28%"/>
<col style="width: 71%"/>
</colgroup>
<thead>
<tr>
<th>
Name
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK()
</code>
</a>
</td>
<td>
Get a named lock
</td>
</tr>
<tr>
<td>
<a class="link" href="locking-functions.html#function_is-free-lock">
<code class="literal">
IS_FREE_LOCK()
</code>
</a>
</td>
<td>
Whether the named lock is free
</td>
</tr>
<tr>
<td>
<a class="link" href="locking-functions.html#function_is-used-lock">
<code class="literal">
IS_USED_LOCK()
</code>
</a>
</td>
<td>
Whether the named lock is in use; return connection identifier if
true
</td>
</tr>
<tr>
<td>
<a class="link" href="locking-functions.html#function_release-all-locks">
<code class="literal">
RELEASE_ALL_LOCKS()
</code>
</a>
</td>
<td>
Release all current named locks
</td>
</tr>
<tr>
<td>
<a class="link" href="locking-functions.html#function_release-lock">
<code class="literal">
RELEASE_LOCK()
</code>
</a>
</td>
<td>
Release the named lock
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<a name="function_get-lock">
</a>
<p>
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK(
<em class="replaceable">
<code>
str
</code>
</em>
,
<em class="replaceable">
<code>
timeout
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045199142544">
</a>
<a class="indexterm" name="idm46045199141472">
</a>
<p>
Tries to obtain a lock with a name given by the string
<em class="replaceable">
<code>
str
</code>
</em>
, using a timeout of
<em class="replaceable">
<code>
timeout
</code>
</em>
seconds. A negative
<em class="replaceable">
<code>
timeout
</code>
</em>
value means infinite
timeout. The lock is exclusive. While held by one session,
other sessions cannot obtain a lock of the same name.
</p>
<p>
Returns
<code class="literal">
1
</code>
if the lock was obtained
successfully,
<code class="literal">
0
</code>
if the attempt timed out
(for example, because another client has previously locked the
name), or
<code class="literal">
NULL
</code>
if an error occurred (such
as running out of memory or the thread was killed with
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin kill
</strong>
</span>
</a>
).
</p>
<p>
A lock obtained with
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK()
</code>
</a>
is released explicitly by executing
<a class="link" href="locking-functions.html#function_release-lock">
<code class="literal">
RELEASE_LOCK()
</code>
</a>
or implicitly
when your session terminates (either normally or abnormally).
Locks obtained with
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK()
</code>
</a>
are not released when transactions commit or roll back.
</p>
<p>
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK()
</code>
</a>
is implemented using
the metadata locking (MDL) subsystem. Multiple simultaneous
locks can be acquired and
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK()
</code>
</a>
does not release any
existing locks. For example, suppose that you execute these
statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa86227818"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token function">GET_LOCK</span><span class="token punctuation">(</span><span class="token string">'lock1'</span><span class="token punctuation">,</span><span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token function">GET_LOCK</span><span class="token punctuation">(</span><span class="token string">'lock2'</span><span class="token punctuation">,</span><span class="token number">10</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token function">RELEASE_LOCK</span><span class="token punctuation">(</span><span class="token string">'lock2'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">SELECT</span> <span class="token function">RELEASE_LOCK</span><span class="token punctuation">(</span><span class="token string">'lock1'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The second
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK()
</code>
</a>
acquires
a second lock and both
<a class="link" href="locking-functions.html#function_release-lock">
<code class="literal">
RELEASE_LOCK()
</code>
</a>
calls return 1
(success).
</p>
<p>
It is even possible for a given session to acquire multiple
locks for the same name. Other sessions cannot acquire a lock
with that name until the acquiring session releases all its
locks for the name.
</p>
<p>
Uniquely named locks acquired with
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK()
</code>
</a>
appear in the
Performance Schema
<a class="link" href="performance-schema-metadata-locks-table.html" title="29.12.13.3 The metadata_locks Table">
<code class="literal">
metadata_locks
</code>
</a>
table. The
<code class="literal">
OBJECT_TYPE
</code>
column says
<code class="literal">
USER LEVEL LOCK
</code>
and the
<code class="literal">
OBJECT_NAME
</code>
column indicates the lock name.
In the case that multiple locks are acquired for the
<span class="emphasis">
<em>
same
</em>
</span>
name, only the first lock for the
name registers a row in the
<a class="link" href="performance-schema-metadata-locks-table.html" title="29.12.13.3 The metadata_locks Table">
<code class="literal">
metadata_locks
</code>
</a>
table. Subsequent
locks for the name increment a counter in the lock but do not
acquire additional metadata locks. The
<a class="link" href="performance-schema-metadata-locks-table.html" title="29.12.13.3 The metadata_locks Table">
<code class="literal">
metadata_locks
</code>
</a>
row for the lock
is deleted when the last lock instance on the name is
released.
</p>
<p>
The capability of acquiring multiple locks means there is the
possibility of deadlock among clients. When this happens, the
server chooses a caller and terminates its lock-acquisition
request with an
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_user_lock_deadlock" target="_top">
<code class="literal">
ER_USER_LOCK_DEADLOCK
</code>
</a>
error.
This error does not cause transactions to roll back.
</p>
<p>
MySQL enforces a maximum length on lock names of 64
characters.
</p>
<p>
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK()
</code>
</a>
can be used to
implement application locks or to simulate record locks. Names
are locked on a server-wide basis. If a name has been locked
within one session,
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK()
</code>
</a>
blocks any request by another session for a lock with the same
name. This enables clients that agree on a given lock name to
use the name to perform cooperative advisory locking. But be
aware that it also enables a client that is not among the set
of cooperating clients to lock a name, either inadvertently or
deliberately, and thus prevent any of the cooperating clients
from locking that name. One way to reduce the likelihood of
this is to use lock names that are database-specific or
application-specific. For example, use lock names of the form
<em class="replaceable">
<code>
db_name.str
</code>
</em>
or
<em class="replaceable">
<code>
app_name.str
</code>
</em>
.
</p>
<p>
If multiple clients are waiting for a lock, the order in which
they acquire it is undefined. Applications should not assume
that clients acquire the lock in the same order that they
issued the lock requests.
</p>
<p>
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK()
</code>
</a>
is unsafe for
statement-based replication. A warning is logged if you use
this function when
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="literal">
binlog_format
</code>
</a>
is set to
<code class="literal">
STATEMENT
</code>
.
</p>
<p>
Since
<code class="literal">
GET_LOCK()
</code>
establishes a lock only on
a single
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
, it is not suitable for use
with NDB Cluster, which has no way of enforcing an SQL lock
across multiple MySQL servers. See
<a class="xref" href="mysql-cluster-limitations-multiple-nodes.html" title="25.2.7.10 Limitations Relating to Multiple NDB Cluster Nodes">
Section 25.2.7.10, “Limitations Relating to Multiple NDB Cluster Nodes”
</a>
,
for more information.
</p>
<div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Caution
</div>
<p>
With the capability of acquiring multiple named locks, it is
possible for a single statement to acquire a large number of
locks. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa32797429"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span> <span class="token keyword">SELECT</span> <span class="token function">GET_LOCK</span><span class="token punctuation">(</span>t1<span class="token punctuation">.</span>col_name<span class="token punctuation">)</span> <span class="token keyword">FROM</span> t1<span class="token punctuation">;</span></code></pre>
</div>
<p>
These types of statements may have certain adverse effects.
For example, if the statement fails part way through and
rolls back, locks acquired up to the point of failure still
exist. If the intent is for there to be a correspondence
between rows inserted and locks acquired, that intent is not
satisfied. Also, if it is important that locks are granted
in a certain order, be aware that result set order may
differ depending on which execution plan the optimizer
chooses. For these reasons, it may be best to limit
applications to a single lock-acquisition call per
statement.
</p>
</div>
<p>
A different locking interface is available as either a plugin
service or a set of loadable functions. This interface
provides lock namespaces and distinct read and write locks,
unlike the interface provided by
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK()
</code>
</a>
and related
functions. For details, see
<a class="xref" href="locking-service.html" title="7.6.9.1 The Locking Service">
Section 7.6.9.1, “The Locking Service”
</a>
.
</p>
</li>
<li class="listitem">
<a name="function_is-free-lock">
</a>
<p>
<a class="link" href="locking-functions.html#function_is-free-lock">
<code class="literal">
IS_FREE_LOCK(
<em class="replaceable">
<code>
str
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045199086416">
</a>
<p>
Checks whether the lock named
<em class="replaceable">
<code>
str
</code>
</em>
is free to use (that is, not locked). Returns
<code class="literal">
1
</code>
if the lock is free (no one is using the
lock),
<code class="literal">
0
</code>
if the lock is in use, and
<code class="literal">
NULL
</code>
if an error occurs (such as an
incorrect argument).
</p>
<p>
This function is unsafe for statement-based replication. A
warning is logged if you use this function when
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="literal">
binlog_format
</code>
</a>
is set to
<code class="literal">
STATEMENT
</code>
.
</p>
</li>
<li class="listitem">
<a name="function_is-used-lock">
</a>
<p>
<a class="link" href="locking-functions.html#function_is-used-lock">
<code class="literal">
IS_USED_LOCK(
<em class="replaceable">
<code>
str
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045199073328">
</a>
<p>
Checks whether the lock named
<em class="replaceable">
<code>
str
</code>
</em>
is in use (that is, locked). If so, it returns the connection
identifier of the client session that holds the lock.
Otherwise, it returns
<code class="literal">
NULL
</code>
.
</p>
<p>
This function is unsafe for statement-based replication. A
warning is logged if you use this function when
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="literal">
binlog_format
</code>
</a>
is set to
<code class="literal">
STATEMENT
</code>
.
</p>
</li>
<li class="listitem">
<a name="function_release-all-locks">
</a>
<p>
<a class="link" href="locking-functions.html#function_release-all-locks">
<code class="literal">
RELEASE_ALL_LOCKS()
</code>
</a>
</p>
<a class="indexterm" name="idm46045199061888">
</a>
<p>
Releases all named locks held by the current session and
returns the number of locks released (0 if there were none)
</p>
<p>
This function is unsafe for statement-based replication. A
warning is logged if you use this function when
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="literal">
binlog_format
</code>
</a>
is set to
<code class="literal">
STATEMENT
</code>
.
</p>
</li>
<li class="listitem">
<a name="function_release-lock">
</a>
<p>
<a class="link" href="locking-functions.html#function_release-lock">
<code class="literal">
RELEASE_LOCK(
<em class="replaceable">
<code>
str
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045199051424">
</a>
<p>
Releases the lock named by the string
<em class="replaceable">
<code>
str
</code>
</em>
that was obtained with
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK()
</code>
</a>
. Returns
<code class="literal">
1
</code>
if the lock was released,
<code class="literal">
0
</code>
if the lock was not established by this
thread (in which case the lock is not released), and
<code class="literal">
NULL
</code>
if the named lock did not exist. The
lock does not exist if it was never obtained by a call to
<a class="link" href="locking-functions.html#function_get-lock">
<code class="literal">
GET_LOCK()
</code>
</a>
or if it has
previously been released.
</p>
<p>
The
<a class="link" href="do.html" title="15.2.3 DO Statement">
<code class="literal">
DO
</code>
</a>
statement is convenient
to use with
<a class="link" href="locking-functions.html#function_release-lock">
<code class="literal">
RELEASE_LOCK()
</code>
</a>
. See
<a class="xref" href="do.html" title="15.2.3 DO Statement">
Section 15.2.3, “DO Statement”
</a>
.
</p>
<p>
This function is unsafe for statement-based replication. A
warning is logged if you use this function when
<a class="link" href="replication-options-binary-log.html#sysvar_binlog_format">
<code class="literal">
binlog_format
</code>
</a>
is set to
<code class="literal">
STATEMENT
</code>
.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-replication-applier-status-by-coordinator-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="performance-schema-replication-applier-status-by-coordinator-table">
</a>
29.12.11.6 The replication_applier_status_by_coordinator Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045071427904">
</a>
<a class="indexterm" name="idm46045071426384">
</a>
<p>
For a multithreaded replica, the replica uses multiple worker
threads and a coordinator thread to manage them, and this
table shows the status of the coordinator thread. For a
single-threaded replica, this table is empty. For a
multithreaded replica, the
<a class="link" href="performance-schema-replication-applier-status-by-worker-table.html" title="29.12.11.7 The replication_applier_status_by_worker Table">
<code class="literal">
replication_applier_status_by_worker
</code>
</a>
table shows the status of the worker threads. This table
provides information about the last transaction which was
buffered by the coordinator thread to a worker’s queue, as
well as the transaction it is currently buffering. The start
timestamp refers to when this thread read the first event of
the transaction from the relay log to buffer it to a
worker’s queue, while the end timestamp refers to when the
last event finished buffering to the worker’s queue.
</p>
<p>
The
<a class="link" href="performance-schema-replication-applier-status-by-coordinator-table.html" title="29.12.11.6 The replication_applier_status_by_coordinator Table">
<code class="literal">
replication_applier_status_by_coordinator
</code>
</a>
table has these columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
CHANNEL_NAME
</code>
</p>
<p>
The replication channel which this row is displaying.
There is always a default replication channel, and more
replication channels can be added. See
<a class="xref" href="replication-channels.html" title="19.2.2 Replication Channels">
Section 19.2.2, “Replication Channels”
</a>
for more
information.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
THREAD_ID
</code>
</p>
<p>
The SQL/coordinator thread ID.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SERVICE_STATE
</code>
</p>
<p>
<code class="literal">
ON
</code>
(thread exists and is active or
idle) or
<code class="literal">
OFF
</code>
(thread no longer exists).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LAST_ERROR_NUMBER
</code>
,
<code class="literal">
LAST_ERROR_MESSAGE
</code>
</p>
<p>
The error number and error message of the most recent
error that caused the SQL/coordinator thread to stop. An
error number of 0 and message which is an empty string
means
<span class="quote">
“
<span class="quote">
no error
</span>
”
</span>
. If the
<code class="literal">
LAST_ERROR_MESSAGE
</code>
value is not empty,
the error values also appear in the replica's error
log.
</p>
<p>
Issuing
<a class="link" href="reset-binary-logs-and-gtids.html" title="15.4.1.2 RESET BINARY LOGS AND GTIDS Statement">
<code class="literal">
RESET BINARY LOGS AND
GTIDS
</code>
</a>
or
<a class="link" href="reset-replica.html" title="15.4.2.3 RESET REPLICA Statement">
<code class="literal">
RESET
REPLICA
</code>
</a>
resets the values shown in these
columns.
</p>
<p>
All error codes and messages displayed in the
<code class="literal">
LAST_ERROR_NUMBER
</code>
and
<code class="literal">
LAST_ERROR_MESSAGE
</code>
columns correspond
to error values listed in
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html" target="_top">
Server Error Message Reference
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LAST_ERROR_TIMESTAMP
</code>
</p>
<p>
A timestamp in
<code class="literal">
'
<em class="replaceable">
<code>
YYYY-MM-DD
hh:mm:ss
</code>
</em>
[.
<em class="replaceable">
<code>
fraction
</code>
</em>
]'
</code>
format that shows when the most recent SQL/coordinator
error occurred.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LAST_PROCESSED_TRANSACTION
</code>
</p>
<p>
The global transaction ID (GTID) of the last transaction
processed by this coordinator.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LAST_PROCESSED_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP
</code>
</p>
<p>
A timestamp in
<code class="literal">
'
<em class="replaceable">
<code>
YYYY-MM-DD
hh:mm:ss
</code>
</em>
[.
<em class="replaceable">
<code>
fraction
</code>
</em>
]'
</code>
format that shows when the last transaction processed by
this coordinator was committed on the original source.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LAST_PROCESSED_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP
</code>
</p>
<p>
A timestamp in
<code class="literal">
'
<em class="replaceable">
<code>
YYYY-MM-DD
hh:mm:ss
</code>
</em>
[.
<em class="replaceable">
<code>
fraction
</code>
</em>
]'
</code>
format that shows when the last transaction processed by
this coordinator was committed on the immediate source.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LAST_PROCESSED_TRANSACTION_START_BUFFER_TIMESTAMP
</code>
</p>
<p>
A timestamp in
<code class="literal">
'
<em class="replaceable">
<code>
YYYY-MM-DD
hh:mm:ss
</code>
</em>
[.
<em class="replaceable">
<code>
fraction
</code>
</em>
]'
</code>
format that shows when this coordinator thread started
writing the last transaction to the buffer of a worker
thread.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
LAST_PROCESSED_TRANSACTION_END_BUFFER_TIMESTAMP
</code>
</p>
<p>
A timestamp in
<code class="literal">
'
<em class="replaceable">
<code>
YYYY-MM-DD
hh:mm:ss
</code>
</em>
[.
<em class="replaceable">
<code>
fraction
</code>
</em>
]'
</code>
format that shows when the last transaction was written to
the buffer of a worker thread by this coordinator thread.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PROCESSING_TRANSACTION
</code>
</p>
<p>
The global transaction ID (GTID) of the transaction that
this coordinator thread is currently processing.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PROCESSING_TRANSACTION_ORIGINAL_COMMIT_TIMESTAMP
</code>
</p>
<p>
A timestamp in
<code class="literal">
'
<em class="replaceable">
<code>
YYYY-MM-DD
hh:mm:ss
</code>
</em>
[.
<em class="replaceable">
<code>
fraction
</code>
</em>
]'
</code>
format that shows when the currently processing
transaction was committed on the original source.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PROCESSING_TRANSACTION_IMMEDIATE_COMMIT_TIMESTAMP
</code>
</p>
<p>
A timestamp in
<code class="literal">
'
<em class="replaceable">
<code>
YYYY-MM-DD
hh:mm:ss
</code>
</em>
[.
<em class="replaceable">
<code>
fraction
</code>
</em>
]'
</code>
format that shows when the currently processing
transaction was committed on the immediate source.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PROCESSING_TRANSACTION_START_BUFFER_TIMESTAMP
</code>
</p>
<p>
A timestamp in
<code class="literal">
'
<em class="replaceable">
<code>
YYYY-MM-DD
hh:mm:ss
</code>
</em>
[.
<em class="replaceable">
<code>
fraction
</code>
</em>
]'
</code>
format that shows when this coordinator thread started
writing the currently processing transaction to the buffer
of a worker thread.
</p>
</li>
</ul>
</div>
<p>
When the Performance Schema is disabled, local timing
information is not collected, so the fields showing the start
and end timestamps for buffered transactions are zero.
</p>
<p>
The
<a class="link" href="performance-schema-replication-applier-status-by-coordinator-table.html" title="29.12.11.6 The replication_applier_status_by_coordinator Table">
<code class="literal">
replication_applier_status_by_coordinator
</code>
</a>
table has these indexes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
CHANNEL_NAME
</code>
)
</p>
</li>
<li class="listitem">
<p>
Index on (
<code class="literal">
THREAD_ID
</code>
)
</p>
</li>
</ul>
</div>
<p>
The following table shows the correspondence between
<a class="link" href="performance-schema-replication-applier-status-by-coordinator-table.html" title="29.12.11.6 The replication_applier_status_by_coordinator Table">
<code class="literal">
replication_applier_status_by_coordinator
</code>
</a>
columns and
<a class="link" href="show-replica-status.html" title="15.7.7.35 SHOW REPLICA STATUS Statement">
<code class="literal">
SHOW
REPLICA STATUS
</code>
</a>
columns.
</p>
<div class="informaltable">
<table summary="Correspondence between replication_applier_status_by_coordinator columns and SHOW REPLICA STATUS columns">
<colgroup>
<col style="width: 60%"/>
<col style="width: 40%"/>
</colgroup>
<thead>
<tr>
<th>
<code class="literal">
replication_applier_status_by_coordinator
</code>
Column
</th>
<th>
<code class="literal">
SHOW REPLICA STATUS
</code>
Column
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
THREAD_ID
</code>
</td>
<td>
None
</td>
</tr>
<tr>
<td>
<code class="literal">
SERVICE_STATE
</code>
</td>
<td>
<code class="literal">
Replica_SQL_Running
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
LAST_ERROR_NUMBER
</code>
</td>
<td>
<code class="literal">
Last_SQL_Errno
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
LAST_ERROR_MESSAGE
</code>
</td>
<td>
<code class="literal">
Last_SQL_Error
</code>
</td>
</tr>
<tr>
<td>
<code class="literal">
LAST_ERROR_TIMESTAMP
</code>
</td>
<td>
<code class="literal">
Last_SQL_Error_Timestamp
</code>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-session-connect-attrs-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="performance-schema-session-connect-attrs-table">
</a>
29.12.9.2 The session_connect_attrs Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045071822928">
</a>
<a class="indexterm" name="idm46045071821424">
</a>
<p>
Application programs can provide key-value connection
attributes to be passed to the server at connect time. For
descriptions of common attributes, see
<a class="xref" href="performance-schema-connection-attribute-tables.html" title="29.12.9 Performance Schema Connection Attribute Tables">
Section 29.12.9, “Performance Schema Connection Attribute Tables”
</a>
.
</p>
<p>
The
<a class="link" href="performance-schema-session-connect-attrs-table.html" title="29.12.9.2 The session_connect_attrs Table">
<code class="literal">
session_connect_attrs
</code>
</a>
table
contains connection attributes for all sessions. To see
connection attributes only for the current session, and other
sessions associated with the session account, use the
<a class="link" href="performance-schema-session-account-connect-attrs-table.html" title="29.12.9.1 The session_account_connect_attrs Table">
<code class="literal">
session_account_connect_attrs
</code>
</a>
table.
</p>
<p>
The
<a class="link" href="performance-schema-session-connect-attrs-table.html" title="29.12.9.2 The session_connect_attrs Table">
<code class="literal">
session_connect_attrs
</code>
</a>
table
has these columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
PROCESSLIST_ID
</code>
</p>
<p>
The connection identifier for the session.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ATTR_NAME
</code>
</p>
<p>
The attribute name.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ATTR_VALUE
</code>
</p>
<p>
The attribute value.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ORDINAL_POSITION
</code>
</p>
<p>
The order in which the attribute was added to the set of
connection attributes.
</p>
</li>
</ul>
</div>
<p>
The
<a class="link" href="performance-schema-session-connect-attrs-table.html" title="29.12.9.2 The session_connect_attrs Table">
<code class="literal">
session_connect_attrs
</code>
</a>
table
has these indexes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
PROCESSLIST_ID
</code>
,
<code class="literal">
ATTR_NAME
</code>
)
</p>
</li>
</ul>
</div>
<p>
<a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
<code class="literal">
TRUNCATE TABLE
</code>
</a>
is not permitted
for the
<a class="link" href="performance-schema-session-connect-attrs-table.html" title="29.12.9.2 The session_connect_attrs Table">
<code class="literal">
session_connect_attrs
</code>
</a>
table.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-params-ndbd.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-params-ndbd">
</a>
25.4.2.1 NDB Cluster Data Node Configuration Parameters
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045121913264">
</a>
<a class="indexterm" name="idm46045121911808">
</a>
<a class="indexterm" name="idm46045121910736">
</a>
<p>
The listings in this section provide information about
parameters used in the
<code class="literal">
[ndbd]
</code>
or
<code class="literal">
[ndbd default]
</code>
sections of a
<code class="filename">
config.ini
</code>
file for configuring NDB Cluster
data nodes. For detailed descriptions and other additional
information about each of these parameters, see
<a class="xref" href="mysql-cluster-ndbd-definition.html" title="25.4.3.6 Defining NDB Cluster Data Nodes">
Section 25.4.3.6, “Defining NDB Cluster Data Nodes”
</a>
.
</p>
<p>
These parameters also apply to
<a class="link" href="mysql-cluster-programs-ndbmtd.html" title="25.5.3 ndbmtd — The NDB Cluster Data Node Daemon (Multi-Threaded)">
<span class="command">
<strong>
ndbmtd
</strong>
</span>
</a>
, the
multithreaded version of
<a class="link" href="mysql-cluster-programs-ndbd.html" title="25.5.1 ndbd — The NDB Cluster Data Node Daemon">
<span class="command">
<strong>
ndbd
</strong>
</span>
</a>
. A separate
listing of parameters specific to
<a class="link" href="mysql-cluster-programs-ndbmtd.html" title="25.5.3 ndbmtd — The NDB Cluster Data Node Daemon (Multi-Threaded)">
<span class="command">
<strong>
ndbmtd
</strong>
</span>
</a>
follows.
</p>
<div class="itemizedlist">
<a name="ndbparam-summary-list-ndbd">
</a>
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-arbitration">
Arbitration
</a>
</code>
:
How arbitration should be performed to avoid split-brain
issues in event of node failure.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-arbitrationtimeout">
ArbitrationTimeout
</a>
</code>
:
Maximum time (milliseconds) database partition waits for
arbitration signal.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-backupdatabuffersize">
BackupDataBufferSize
</a>
</code>
:
Default size of databuffer for backup (in bytes).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-backupdatadir">
BackupDataDir
</a>
</code>
:
Path to where to store backups. Note that string '/BACKUP'
is always appended to this setting, so that *effective*
default is FileSystemPath/BACKUP.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-backupdiskwritespeedpct">
BackupDiskWriteSpeedPct
</a>
</code>
:
Sets percentage of data node's allocated maximum write speed
(MaxDiskWriteSpeed) to reserve for LCPs when starting
backup.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-backuplogbuffersize">
BackupLogBufferSize
</a>
</code>
:
Default size of log buffer for backup (in bytes).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-backupmaxwritesize">
BackupMaxWriteSize
</a>
</code>
:
Maximum size of file system writes made by backup (in
bytes).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-backupmemory">
BackupMemory
</a>
</code>
:
Total memory allocated for backups per node (in bytes).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-backupreportfrequency">
BackupReportFrequency
</a>
</code>
:
Frequency of backup status reports during backup in seconds.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-backupwritesize">
BackupWriteSize
</a>
</code>
:
Default size of file system writes made by backup (in
bytes).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-batchsizeperlocalscan">
BatchSizePerLocalScan
</a>
</code>
:
Used to calculate number of lock records for scan with hold
lock.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-buildindexthreads">
BuildIndexThreads
</a>
</code>
:
Number of threads to use for building ordered indexes during
system or node restart. Also applies when running
ndb_restore --rebuild-indexes. Setting this parameter to 0
disables multithreaded building of ordered indexes.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-compressedbackup">
CompressedBackup
</a>
</code>
:
Use zlib to compress backups as they are written.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-compressedlcp">
CompressedLCP
</a>
</code>
:
Write compressed LCPs using zlib.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-connectcheckintervaldelay">
ConnectCheckIntervalDelay
</a>
</code>
:
Time between data node connectivity check stages. Data node
is considered suspect after 1 interval and dead after 2
intervals with no response.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-crashoncorruptedtuple">
CrashOnCorruptedTuple
</a>
</code>
:
When enabled, forces node to shut down whenever it detects
corrupted tuple.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-datadir">
DataDir
</a>
</code>
:
Data directory for this node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-datamemory">
DataMemory
</a>
</code>
:
Number of bytes on each data node allocated for storing
data; subject to available system RAM and size of
IndexMemory.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-defaulthashmapsize">
DefaultHashMapSize
</a>
</code>
:
Set size (in buckets) to use for table hash maps. Three
values are supported: 0, 240, and 3840.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-dicttrace">
DictTrace
</a>
</code>
:
Enable DBDICT debugging; for NDB development.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-diskdatausingsamedisk">
DiskDataUsingSameDisk
</a>
</code>
:
Set to false if Disk Data tablespaces are located on
separate physical disks.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-diskiothreadpool">
DiskIOThreadPool
</a>
</code>
:
Number of unbound threads for file access, applies to disk
data only.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-diskless">
Diskless
</a>
</code>
:
Run without using disk.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-diskpagebufferentries">
DiskPageBufferEntries
</a>
</code>
:
Memory to allocate in DiskPageBufferMemory; very large disk
transactions may require increasing this value.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-diskpagebuffermemory">
DiskPageBufferMemory
</a>
</code>
:
Number of bytes on each data node allocated for disk page
buffer cache.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-disksyncsize">
DiskSyncSize
</a>
</code>
:
Amount of data written to file before synch is forced.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-enablepartiallcp">
EnablePartialLcp
</a>
</code>
:
Enable partial LCP (true); if this is disabled (false), all
LCPs write full checkpoints.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-enableredocontrol">
EnableRedoControl
</a>
</code>
:
Enable adaptive checkpointing speed for controlling redo log
usage.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-encryptedfilesystem">
EncryptedFileSystem
</a>
</code>
:
Encrypt local checkpoint and tablespace files. EXPERIMENTAL;
NOT SUPPORTED IN PRODUCTION.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-eventlogbuffersize">
EventLogBufferSize
</a>
</code>
:
Size of circular buffer for NDB log events within data
nodes.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-executeoncomputer">
ExecuteOnComputer
</a>
</code>
:
String referencing earlier defined COMPUTER.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-extrasendbuffermemory">
ExtraSendBufferMemory
</a>
</code>
:
Memory to use for send buffers in addition to any allocated
by TotalSendBufferMemory or SendBufferMemory. Default (0)
allows up to 16MB.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-filesystempath">
FileSystemPath
</a>
</code>
:
Path to directory where data node stores its data (directory
must exist).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-filesystempathdatafiles">
FileSystemPathDataFiles
</a>
</code>
:
Path to directory where data node stores its Disk Data
files. Default value is FilesystemPathDD, if set; otherwise,
FilesystemPath is used if it is set; otherwise, value of
DataDir is used.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-filesystempathdd">
FileSystemPathDD
</a>
</code>
:
Path to directory where data node stores its Disk Data and
undo files. Default value is FileSystemPath, if set;
otherwise, value of DataDir is used.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-filesystempathundofiles">
FileSystemPathUndoFiles
</a>
</code>
:
Path to directory where data node stores its undo files for
Disk Data. Default value is FilesystemPathDD, if set;
otherwise, FilesystemPath is used if it is set; otherwise,
value of DataDir is used.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-fragmentlogfilesize">
FragmentLogFileSize
</a>
</code>
:
Size of each redo log file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-heartbeatintervaldbapi">
HeartbeatIntervalDbApi
</a>
</code>
:
Time between API node-data node heartbeats. (API connection
closed after 3 missed heartbeats).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-heartbeatintervaldbdb">
HeartbeatIntervalDbDb
</a>
</code>
:
Time between data node-to-data node heartbeats; data node
considered dead after 3 missed heartbeats.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-heartbeatorder">
HeartbeatOrder
</a>
</code>
:
Sets order in which data nodes check each others' heartbeats
for determining whether given node is still active and
connected to cluster. Must be zero for all data nodes or
distinct nonzero values for all data nodes; see
documentation for further guidance.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-hostname">
HostName
</a>
</code>
:
Host name or IP address for this data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-indexmemory">
IndexMemory
</a>
</code>
:
Number of bytes on each data node allocated for storing
indexes; subject to available system RAM and size of
DataMemory.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-indexstatautocreate">
IndexStatAutoCreate
</a>
</code>
:
Enable/disable automatic statistics collection when indexes
are created.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-indexstatautoupdate">
IndexStatAutoUpdate
</a>
</code>
:
Monitor indexes for changes and trigger automatic statistics
updates.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-indexstatsavescale">
IndexStatSaveScale
</a>
</code>
:
Scaling factor used in determining size of stored index
statistics.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-indexstatsavesize">
IndexStatSaveSize
</a>
</code>
:
Maximum size in bytes for saved statistics per index.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-indexstattriggerpct">
IndexStatTriggerPct
</a>
</code>
:
Threshold percent change in DML operations for index
statistics updates. Value is scaled down by
IndexStatTriggerScale.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-indexstattriggerscale">
IndexStatTriggerScale
</a>
</code>
:
Scale down IndexStatTriggerPct by this amount, multiplied by
base 2 logarithm of index size, for large index. Set to 0 to
disable scaling.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-indexstatupdatedelay">
IndexStatUpdateDelay
</a>
</code>
:
Minimum delay between automatic index statistics updates for
given index. 0 means no delay.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-initfragmentlogfiles">
InitFragmentLogFiles
</a>
</code>
:
Initialize fragment log files, using sparse or full format.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-initiallogfilegroup">
InitialLogFileGroup
</a>
</code>
:
Describes log file group that is created during initial
start. See documentation for format.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-initialnoofopenfiles">
InitialNoOfOpenFiles
</a>
</code>
:
Initial number of files open per data node. (One thread is
created per file).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-initialtablespace">
InitialTablespace
</a>
</code>
:
Describes tablespace that is created during initial start.
See documentation for format.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-insertrecoverywork">
InsertRecoveryWork
</a>
</code>
:
Percentage of RecoveryWork used for inserted rows; has no
effect unless partial local checkpoints are in use.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-keepalivesendinterval">
KeepAliveSendInterval
</a>
</code>
:
Time between keep-alive signals on links between data nodes,
in milliseconds. Set to 0 to disable.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-latealloc">
LateAlloc
</a>
</code>
:
Allocate memory after connection to management server has
been established.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-lcpscanprogresstimeout">
LcpScanProgressTimeout
</a>
</code>
:
Maximum time that local checkpoint fragment scan can be
stalled before node is shut down to ensure systemwide LCP
progress. Use 0 to disable.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-locationdomainid">
LocationDomainId
</a>
</code>
:
Assign this data node to specific availability domain or
zone. 0 (default) leaves this unset.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-lockexecutethreadtocpu">
LockExecuteThreadToCPU
</a>
</code>
:
Comma-delimited list of CPU IDs.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-lockmaintthreadstocpu">
LockMaintThreadsToCPU
</a>
</code>
:
CPU ID indicating which CPU runs maintenance threads.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-lockpagesinmainmemory">
LockPagesInMainMemory
</a>
</code>
:
0=disable locking, 1=lock after memory allocation, 2=lock
before memory allocation.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-loglevelcheckpoint">
LogLevelCheckpoint
</a>
</code>
:
Log level of local and global checkpoint information printed
to stdout.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-loglevelcongestion">
LogLevelCongestion
</a>
</code>
:
Level of congestion information printed to stdout.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-loglevelconnection">
LogLevelConnection
</a>
</code>
:
Level of node connect/disconnect information printed to
stdout.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-loglevelerror">
LogLevelError
</a>
</code>
:
Transporter, heartbeat errors printed to stdout.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-loglevelinfo">
LogLevelInfo
</a>
</code>
:
Heartbeat and log information printed to stdout.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-loglevelnoderestart">
LogLevelNodeRestart
</a>
</code>
:
Level of node restart and node failure information printed
to stdout.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-loglevelshutdown">
LogLevelShutdown
</a>
</code>
:
Level of node shutdown information printed to stdout.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-loglevelstartup">
LogLevelStartup
</a>
</code>
:
Level of node startup information printed to stdout.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-loglevelstatistic">
LogLevelStatistic
</a>
</code>
:
Level of transaction, operation, and transporter information
printed to stdout.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-longmessagebuffer">
LongMessageBuffer
</a>
</code>
:
Number of bytes allocated on each data node for internal
long messages.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxallocate">
MaxAllocate
</a>
</code>
:
No longer used; has no effect.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxbufferedepochs">
MaxBufferedEpochs
</a>
</code>
:
Allowed numbered of epochs that subscribing node can lag
behind (unprocessed epochs). Exceeding causes lagging
subscribers to be disconnected.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxbufferedepochbytes">
MaxBufferedEpochBytes
</a>
</code>
:
Total number of bytes allocated for buffering epochs.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxdiskdatalatency">
MaxDiskDataLatency
</a>
</code>
:
Maximum allowed mean latency of disk access (ms) before
starting to abort transactions.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxdiskwritespeed">
MaxDiskWriteSpeed
</a>
</code>
:
Maximum number of bytes per second that can be written by
LCP and backup when no restarts are ongoing.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxdiskwritespeedothernoderestart">
MaxDiskWriteSpeedOtherNodeRestart
</a>
</code>
:
Maximum number of bytes per second that can be written by
LCP and backup when another node is restarting.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxdiskwritespeedownrestart">
MaxDiskWriteSpeedOwnRestart
</a>
</code>
:
Maximum number of bytes per second that can be written by
LCP and backup when this node is restarting.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxfkbuildbatchsize">
MaxFKBuildBatchSize
</a>
</code>
:
Maximum scan batch size to use for building foreign keys.
Increasing this value may speed up builds of foreign keys
but impacts ongoing traffic as well.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxdmloperationspertransaction">
MaxDMLOperationsPerTransaction
</a>
</code>
:
Limit size of transaction; aborts transaction if it requires
more than this many DML operations.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxlcpstartdelay">
MaxLCPStartDelay
</a>
</code>
:
Time in seconds that LCP polls for checkpoint mutex (to
allow other data nodes to complete metadata
synchronization), before putting itself in lock queue for
parallel recovery of table data.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnoofattributes">
MaxNoOfAttributes
</a>
</code>
:
Suggests total number of attributes stored in database (sum
over all tables).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnoofconcurrentindexoperations">
MaxNoOfConcurrentIndexOperations
</a>
</code>
:
Total number of index operations that can execute
simultaneously on one data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnoofconcurrentoperations">
MaxNoOfConcurrentOperations
</a>
</code>
:
Maximum number of operation records in transaction
coordinator.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnoofconcurrentscans">
MaxNoOfConcurrentScans
</a>
</code>
:
Maximum number of scans executing concurrently on data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnoofconcurrentsuboperations">
MaxNoOfConcurrentSubOperations
</a>
</code>
:
Maximum number of concurrent subscriber operations.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnoofconcurrenttransactions">
MaxNoOfConcurrentTransactions
</a>
</code>
:
Maximum number of transactions executing concurrently on
this data node, total number of transactions that can be
executed concurrently is this value times number of data
nodes in cluster.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnooffiredtriggers">
MaxNoOfFiredTriggers
</a>
</code>
:
Total number of triggers that can fire simultaneously on one
data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnooflocaloperations">
MaxNoOfLocalOperations
</a>
</code>
:
Maximum number of operation records defined on this data
node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnooflocalscans">
MaxNoOfLocalScans
</a>
</code>
:
Maximum number of fragment scans in parallel on this data
node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnoofopenfiles">
MaxNoOfOpenFiles
</a>
</code>
:
Maximum number of files open per data node.(One thread is
created per file).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnooforderedindexes">
MaxNoOfOrderedIndexes
</a>
</code>
:
Total number of ordered indexes that can be defined in
system.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnoofsavedmessages">
MaxNoOfSavedMessages
</a>
</code>
:
Maximum number of error messages to write in error log and
maximum number of trace files to retain.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnoofsubscribers">
MaxNoOfSubscribers
</a>
</code>
:
Maximum number of subscribers.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnoofsubscriptions">
MaxNoOfSubscriptions
</a>
</code>
:
Maximum number of subscriptions (default 0 = MaxNoOfTables).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnooftables">
MaxNoOfTables
</a>
</code>
:
Suggests total number of NDB tables stored in database.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnooftriggers">
MaxNoOfTriggers
</a>
</code>
:
Total number of triggers that can be defined in system.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnoofuniquehashindexes">
MaxNoOfUniqueHashIndexes
</a>
</code>
:
Total number of unique hash indexes that can be defined in
system.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxparallelcopyinstances">
MaxParallelCopyInstances
</a>
</code>
:
Number of parallel copies during node restarts. Default is
0, which uses number of LDMs on both nodes, to maximum of
16.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxparallelscansperfragment">
MaxParallelScansPerFragment
</a>
</code>
:
Maximum number of parallel scans per fragment. Once this
limit is reached, scans are serialized.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxreorgbuildbatchsize">
MaxReorgBuildBatchSize
</a>
</code>
:
Maximum scan batch size to use for reorganization of table
partitions. Increasing this value may speed up table
partition reorganization but impacts ongoing traffic as
well.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxstartfailretries">
MaxStartFailRetries
</a>
</code>
:
Maximum retries when data node fails on startup, requires
StopOnError = 0. Setting to 0 causes start attempts to
continue indefinitely.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxuibuildbatchsize">
MaxUIBuildBatchSize
</a>
</code>
:
Maximum scan batch size to use for building unique keys.
Increasing this value may speed up builds of unique keys but
impacts ongoing traffic as well.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-memreportfrequency">
MemReportFrequency
</a>
</code>
:
Frequency of memory reports in seconds; 0 = report only when
exceeding percentage limits.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-mindiskwritespeed">
MinDiskWriteSpeed
</a>
</code>
:
Minimum number of bytes per second that can be written by
LCP and backup.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-minfreepct" title="MinFreePct">
MinFreePct
</a>
</code>
:
Percentage of memory resources to keep in reserve for
restarts.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-nodegroup">
NodeGroup
</a>
</code>
:
Node group to which data node belongs; used only during
initial start of cluster.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-nodegrouptransporters">
NodeGroupTransporters
</a>
</code>
:
Number of transporters to use between nodes in same node
group.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-nodeid">
NodeId
</a>
</code>
:
Number uniquely identifying data node among all nodes in
cluster.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-nooffragmentlogfiles">
NoOfFragmentLogFiles
</a>
</code>
:
Number of 16 MB redo log files in each of 4 file sets
belonging to data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-noofreplicas">
NoOfReplicas
</a>
</code>
:
Number of copies of all data in database.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-numa">
Numa
</a>
</code>
:
(Linux only; requires libnuma) Controls NUMA support.
Setting to 0 permits system to determine use of interleaving
by data node process; 1 means that it is determined by data
node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-odirect">
ODirect
</a>
</code>
:
Use O_DIRECT file reads and writes when possible.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-odirectsyncflag">
ODirectSyncFlag
</a>
</code>
:
O_DIRECT writes are treated as synchronized writes; ignored
when ODirect is not enabled, InitFragmentLogFiles is set to
SPARSE, or both.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-realtimescheduler">
RealtimeScheduler
</a>
</code>
:
When true, data node threads are scheduled as real-time
threads. Default is false.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-recoverywork">
RecoveryWork
</a>
</code>
:
Percentage of storage overhead for LCP files: greater value
means less work in normal operations, more work during
recovery.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-redobuffer">
RedoBuffer
</a>
</code>
:
Number of bytes on each data node allocated for writing redo
logs.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-redoovercommitcounter">
RedoOverCommitCounter
</a>
</code>
:
When RedoOverCommitLimit has been exceeded this many times,
transactions are aborted, and operations are handled as
specified by DefaultOperationRedoProblemAction.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-redoovercommitlimit">
RedoOverCommitLimit
</a>
</code>
:
Each time that flushing current redo buffer takes longer
than this many seconds, number of times that this has
happened is compared to RedoOverCommitCounter.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-requireencryptedbackup">
RequireEncryptedBackup
</a>
</code>
:
Whether backups must be encrypted (1 = encryption required,
otherwise 0).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-requirecertificate">
RequireCertificate
</a>
</code>
:
Node is required to find key and certificate in TLS search
path.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-requiretls">
RequireTls
</a>
</code>
:
Require TLS-authenticated secure connections.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-reservedconcurrentindexoperations">
ReservedConcurrentIndexOperations
</a>
</code>
:
Number of simultaneous index operations having dedicated
resources on one data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-reservedconcurrentoperations">
ReservedConcurrentOperations
</a>
</code>
:
Number of simultaneous operations having dedicated resources
in transaction coordinators on one data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-reservedconcurrentscans">
ReservedConcurrentScans
</a>
</code>
:
Number of simultaneous scans having dedicated resources on
one data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-reservedconcurrenttransactions">
ReservedConcurrentTransactions
</a>
</code>
:
Number of simultaneous transactions having dedicated
resources on one data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-reservedfiredtriggers">
ReservedFiredTriggers
</a>
</code>
:
Number of triggers having dedicated resources on one data
node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-reservedlocalscans">
ReservedLocalScans
</a>
</code>
:
Number of simultaneous fragment scans having dedicated
resources on one data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-reservedtransactionbuffermemory">
ReservedTransactionBufferMemory
</a>
</code>
:
Dynamic buffer space (in bytes) for key and attribute data
allocated to each data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-restartonerrorinsert">
RestartOnErrorInsert
</a>
</code>
:
Control type of restart caused by inserting error (when
StopOnError is enabled).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-restartsubscriberconnecttimeout">
RestartSubscriberConnectTimeout
</a>
</code>
:
Amount of time for data node to wait for subscribing API
nodes to connect. Set to 0 to disable timeout, which is
always resolved to nearest full second.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-schedulerexecutiontimer">
SchedulerExecutionTimer
</a>
</code>
:
Number of microseconds to execute in scheduler before
sending.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-schedulerresponsiveness">
SchedulerResponsiveness
</a>
</code>
:
Set NDB scheduler response optimization 0-10; higher values
provide better response time but lower throughput.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-schedulerspintimer">
SchedulerSpinTimer
</a>
</code>
:
Number of microseconds to execute in scheduler before
sleeping.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-serverport">
ServerPort
</a>
</code>
:
Port used to set up transporter for incoming connections
from API nodes.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-sharedglobalmemory">
SharedGlobalMemory
</a>
</code>
:
Total number of bytes on each data node allocated for any
use.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-spinmethod">
SpinMethod
</a>
</code>
:
Determines spin method used by data node; see documentation
for details.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-startfailretrydelay">
StartFailRetryDelay
</a>
</code>
:
Delay in seconds after start failure prior to retry;
requires StopOnError = 0.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-startfailuretimeout">
StartFailureTimeout
</a>
</code>
:
Milliseconds to wait before terminating. (0=Wait forever).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-startnonodegrouptimeout">
StartNoNodeGroupTimeout
</a>
</code>
:
Time to wait for nodes without nodegroup before trying to
start (0=forever).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-startpartialtimeout">
StartPartialTimeout
</a>
</code>
:
Milliseconds to wait before trying to start without all
nodes. (0=Wait forever).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-startpartitionedtimeout">
StartPartitionedTimeout
</a>
</code>
:
Milliseconds to wait before trying to start partitioned.
(0=Wait forever).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-startupstatusreportfrequency">
StartupStatusReportFrequency
</a>
</code>
:
Frequency of status reports during startup.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-stoponerror">
StopOnError
</a>
</code>
:
When set to 0, data node automatically restarts and recovers
following node failures.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-stringmemory">
StringMemory
</a>
</code>
:
Default size of string memory (0 to 100 = % of maximum, 101+
= actual bytes).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-tcpbind_inaddr_any">
TcpBind_INADDR_ANY
</a>
</code>
:
Bind IP_ADDR_ANY so that connections can be made from
anywhere (for autogenerated connections).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-timebetweenepochs">
TimeBetweenEpochs
</a>
</code>
:
Time between epochs (synchronization used for replication).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-timebetweenepochstimeout">
TimeBetweenEpochsTimeout
</a>
</code>
:
Timeout for time between epochs. Exceeding causes node
shutdown.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-timebetweenglobalcheckpoints">
TimeBetweenGlobalCheckpoints
</a>
</code>
:
Time between group commits of transactions to disk.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-timebetweenglobalcheckpointstimeout">
TimeBetweenGlobalCheckpointsTimeout
</a>
</code>
:
Minimum timeout for group commit of transactions to disk.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-timebetweeninactivetransactionabortcheck">
TimeBetweenInactiveTransactionAbortCheck
</a>
</code>
:
Time between checks for inactive transactions.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-timebetweenlocalcheckpoints">
TimeBetweenLocalCheckpoints
</a>
</code>
:
Time between taking snapshots of database (expressed in
base-2 logarithm of bytes).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-timebetweenwatchdogcheck">
TimeBetweenWatchDogCheck
</a>
</code>
:
Time between execution checks inside data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-timebetweenwatchdogcheckinitial">
TimeBetweenWatchDogCheckInitial
</a>
</code>
:
Time between execution checks inside data node (early start
phases when memory is allocated).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-totalsendbuffermemory">
TotalSendBufferMemory
</a>
</code>
:
Total memory to use for all transporter send buffers..
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-transactionbuffermemory">
TransactionBufferMemory
</a>
</code>
:
Dynamic buffer space (in bytes) for key and attribute data
allocated for each data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-transactiondeadlockdetectiontimeout">
TransactionDeadlockDetectionTimeout
</a>
</code>
:
Time transaction can spend executing within data node. This
is time that transaction coordinator waits for each data
node participating in transaction to execute request. If
data node takes more than this amount of time, transaction
is aborted.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-transactioninactivetimeout">
TransactionInactiveTimeout
</a>
</code>
:
Milliseconds that application waits before executing another
part of transaction. This is time transaction coordinator
waits for application to execute or send another part
(query, statement) of transaction. If application takes too
much time, then transaction is aborted. Timeout = 0 means
that application never times out.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-transactionmemory">
TransactionMemory
</a>
</code>
:
Memory allocated for transactions on each data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-twopassinitialnoderestartcopy">
TwoPassInitialNodeRestartCopy
</a>
</code>
:
Copy data in 2 passes during initial node restart, which
enables multithreaded building of ordered indexes for such
restarts.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-undodatabuffer">
UndoDataBuffer
</a>
</code>
:
Unused; has no effect.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-undoindexbuffer">
UndoIndexBuffer
</a>
</code>
:
Unused; has no effect.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-useshm">
UseShm
</a>
</code>
:
Use shared memory connections between this data node and API
node also running on this host.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-watchdogimmediatekill">
WatchDogImmediateKill
</a>
</code>
:
When true, threads are immediately killed whenever watchdog
issues occur; used for testing and debugging.
</p>
</li>
</ul>
</div>
<p>
The following parameters are specific to
<a class="link" href="mysql-cluster-programs-ndbmtd.html" title="25.5.3 ndbmtd — The NDB Cluster Data Node Daemon (Multi-Threaded)">
<span class="command">
<strong>
ndbmtd
</strong>
</span>
</a>
:
</p>
<div class="itemizedlist">
<a name="ndbparam-summary-list-ndbmtd">
</a>
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbmtd-automaticthreadconfig">
AutomaticThreadConfig
</a>
</code>
:
Use automatic thread configuration; overrides any settings
for ThreadConfig and MaxNoOfExecutionThreads, and disables
ClassicFragmentation.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbmtd-classicfragmentation">
ClassicFragmentation
</a>
</code>
:
When true, use traditional table fragmentation; set false to
enable flexible distribution of fragments among LDMs.
Disabled by AutomaticThreadConfig.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbmtd-enablemultithreadedbackup">
EnableMultithreadedBackup
</a>
</code>
:
Enable multi-threaded backup.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbmtd-maxnoofexecutionthreads">
MaxNoOfExecutionThreads
</a>
</code>
:
For ndbmtd only, specify maximum number of execution
threads.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbmtd-maxsenddelay">
MaxSendDelay
</a>
</code>
:
Maximum number of microseconds to delay sending by ndbmtd.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbmtd-nooffragmentlogparts">
NoOfFragmentLogParts
</a>
</code>
:
Number of redo log file groups belonging to this data node.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbmtd-numcpus">
NumCPUs
</a>
</code>
:
Specify number of CPUs to use with AutomaticThreadConfig.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbmtd-partitionspernode">
PartitionsPerNode
</a>
</code>
:
Determines the number of table partitions created on each
data node; not used if ClassicFragmentation is enabled.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbmtd-threadconfig">
ThreadConfig
</a>
</code>
:
Used for configuration of multithreaded data nodes (ndbmtd).
Default is empty string; see documentation for syntax and
other information.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-features-reserved-words.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="replication-features-reserved-words">
</a>
19.5.1.26 Replication and Reserved Words
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045135235328">
</a>
<a class="indexterm" name="idm46045135233840">
</a>
<p>
You can encounter problems when you attempt to replicate from an
older source to a newer replica and you make use of identifiers
on the source that are reserved words in the newer MySQL version
running on the replica. For example, a table column named
<code class="literal">
rank
</code>
on a MySQL 5.7 source that is
replicating to a MySQL 8.4 replica could cause a
problem because
<code class="literal">
RANK
</code>
became a reserved word
in MySQL 8.0.
</p>
<p>
Replication can fail in such cases with Error 1064
<span class="errortext">
You have an error in your SQL syntax...
</span>
,
<span class="emphasis">
<em>
even if a database or table named using the reserved
word or a table having a column named using the reserved word is
excluded from replication
</em>
</span>
. This is due to the fact
that each SQL event must be parsed by the replica prior to
execution, so that the replica knows which database object or
objects would be affected. Only after the event is parsed can
the replica apply any filtering rules defined by
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-do-db">
<code class="option">
--replicate-do-db
</code>
</a>
,
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-do-table">
<code class="option">
--replicate-do-table
</code>
</a>
,
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-ignore-db">
<code class="option">
--replicate-ignore-db
</code>
</a>
, and
<a class="link" href="replication-options-replica.html#option_mysqld_replicate-ignore-table">
<code class="option">
--replicate-ignore-table
</code>
</a>
.
</p>
<p>
To work around the problem of database, table, or column names
on the source which would be regarded as reserved words by the
replica, do one of the following:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Use one or more
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
statements on the source to change the names of any database
objects where these names would be considered reserved words
on the replica, and change any SQL statements that use the
old names to use the new names instead.
</p>
</li>
<li class="listitem">
<p>
In any SQL statements using these database object names,
write the names as quoted identifiers using backtick
characters (
<code class="literal">
`
</code>
).
</p>
</li>
</ul>
</div>
<p>
For listings of reserved words by MySQL version, see
<a class="ulink" href="/doc/mysqld-version-reference/en/keywords-8-0.html" target="_top">
Keywords and Reserved Words in MySQL 8.0
</a>
, in the
<em class="citetitle">
MySQL Server
Version Reference
</em>
. For identifier quoting rules, see
<a class="xref" href="identifiers.html" title="11.2 Schema Object Names">
Section 11.2, “Schema Object Names”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-gtids.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="replication-gtids">
</a>
19.1.3 Replication with Global Transaction Identifiers
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="replication-gtids-concepts.html">
19.1.3.1 GTID Format and Storage
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-gtids-lifecycle.html">
19.1.3.2 GTID Life Cycle
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-gtids-auto-positioning.html">
19.1.3.3 GTID Auto-Positioning
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-gtids-howto.html">
19.1.3.4 Setting Up Replication Using GTIDs
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-gtids-failover.html">
19.1.3.5 Using GTIDs for Failover and Scaleout
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-gtids-assign-anon.html">
19.1.3.6 Replication From a Source Without GTIDs to a Replica With GTIDs
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-gtids-restrictions.html">
19.1.3.7 Restrictions on Replication with GTIDs
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="replication-gtids-functions.html">
19.1.3.8 Stored Function Examples to Manipulate GTIDs
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045146443104">
</a>
<p>
This section explains transaction-based replication using
<span class="firstterm">
global transaction identifiers
</span>
(GTIDs). When using GTIDs, each transaction can be identified and
tracked as it is committed on the originating server and applied by
any replicas; this means that it is not necessary when using GTIDs
to refer to log files or positions within those files when starting
a new replica or failing over to a new source, which greatly
simplifies these tasks. Because GTID-based replication is completely
transaction-based, it is simple to determine whether sources and
replicas are consistent; as long as all transactions committed on a
source are also committed on a replica, consistency between the two
is guaranteed. You can use either statement-based or row-based
replication with GTIDs (see
<a class="xref" href="replication-formats.html" title="19.2.1 Replication Formats">
Section 19.2.1, “Replication Formats”
</a>
);
however, for best results, we recommend that you use the row-based
format.
</p>
<p>
GTIDs are always preserved between source and replica. This means
that you can always determine the source for any transaction applied
on any replica by examining its binary log. In addition, once a
transaction with a given GTID is committed on a given server, any
subsequent transaction having the same GTID is ignored by that
server. Thus, a transaction committed on the source can be applied
no more than once on the replica, which helps to guarantee
consistency.
</p>
<p>
This section discusses the following topics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
How GTIDs are defined and created, and how they are represented
in a MySQL server (see
<a class="xref" href="replication-gtids-concepts.html" title="19.1.3.1 GTID Format and Storage">
Section 19.1.3.1, “GTID Format and Storage”
</a>
).
</p>
</li>
<li class="listitem">
<p>
The life cycle of a GTID (see
<a class="xref" href="replication-gtids-lifecycle.html" title="19.1.3.2 GTID Life Cycle">
Section 19.1.3.2, “GTID Life Cycle”
</a>
).
</p>
</li>
<li class="listitem">
<p>
The auto-positioning function for synchronizing a replica and
source that use GTIDs (see
<a class="xref" href="replication-gtids-auto-positioning.html" title="19.1.3.3 GTID Auto-Positioning">
Section 19.1.3.3, “GTID Auto-Positioning”
</a>
).
</p>
</li>
<li class="listitem">
<p>
A general procedure for setting up and starting GTID-based
replication (see
<a class="xref" href="replication-gtids-howto.html" title="19.1.3.4 Setting Up Replication Using GTIDs">
Section 19.1.3.4, “Setting Up Replication Using GTIDs”
</a>
).
</p>
</li>
<li class="listitem">
<p>
Suggested methods for provisioning new replication servers when
using GTIDs (see
<a class="xref" href="replication-gtids-failover.html" title="19.1.3.5 Using GTIDs for Failover and Scaleout">
Section 19.1.3.5, “Using GTIDs for Failover and Scaleout”
</a>
).
</p>
</li>
<li class="listitem">
<p>
Restrictions and limitations that you should be aware of when
using GTID-based replication (see
<a class="xref" href="replication-gtids-restrictions.html" title="19.1.3.7 Restrictions on Replication with GTIDs">
Section 19.1.3.7, “Restrictions on Replication with GTIDs”
</a>
).
</p>
</li>
<li class="listitem">
<p>
Stored functions that you can use to work with GTIDs (see
<a class="xref" href="replication-gtids-functions.html" title="19.1.3.8 Stored Function Examples to Manipulate GTIDs">
Section 19.1.3.8, “Stored Function Examples to Manipulate GTIDs”
</a>
).
</p>
</li>
</ul>
</div>
<p>
For information about MySQL Server options and variables relating to
GTID-based replication, see
<a class="xref" href="replication-options-gtids.html" title="19.1.6.5 Global Transaction ID System Variables">
Section 19.1.6.5, “Global Transaction ID System Variables”
</a>
. See also
<a class="xref" href="gtid-functions.html" title="14.18.2 Functions Used with Global Transaction Identifiers (GTIDs)">
Section 14.18.2, “Functions Used with Global Transaction Identifiers (GTIDs)”
</a>
, which describes SQL functions
supported by MySQL 8.4 for use with GTIDs.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/information-schema-innodb-fields-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="information-schema-innodb-fields-table">
</a>
28.4.11 The INFORMATION_SCHEMA INNODB_FIELDS Table
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045077060768">
</a>
<p>
The
<a class="link" href="information-schema-innodb-fields-table.html" title="28.4.11 The INFORMATION_SCHEMA INNODB_FIELDS Table">
<code class="literal">
INNODB_FIELDS
</code>
</a>
table provides
metadata about the key columns (fields) of
<code class="literal">
InnoDB
</code>
indexes.
</p>
<p>
For related usage information and examples, see
<a class="xref" href="innodb-information-schema-system-tables.html" title="17.15.3 InnoDB INFORMATION_SCHEMA Schema Object Tables">
Section 17.15.3, “InnoDB INFORMATION_SCHEMA Schema Object Tables”
</a>
.
</p>
<p>
The
<a class="link" href="information-schema-innodb-fields-table.html" title="28.4.11 The INFORMATION_SCHEMA INNODB_FIELDS Table">
<code class="literal">
INNODB_FIELDS
</code>
</a>
table has these
columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
INDEX_ID
</code>
</p>
<p>
An identifier for the index associated with this key field;
the same value as
<code class="literal">
INNODB_INDEXES.INDEX_ID
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NAME
</code>
</p>
<p>
The name of the original column from the table; the same value
as
<code class="literal">
INNODB_COLUMNS.NAME
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
POS
</code>
</p>
<p>
The ordinal position of the key field within the index,
starting from 0 and incrementing sequentially. When a column
is dropped, the remaining columns are reordered so that the
sequence has no gaps.
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045077046208">
</a>
Example
</h4>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa91526826"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_FIELDS <span class="token keyword">WHERE</span> INDEX_ID <span class="token operator">=</span> <span class="token number">117</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
INDEX_ID<span class="token punctuation">:</span> 117
NAME<span class="token punctuation">:</span> col1
POS<span class="token punctuation">:</span> 0</span></code></pre>
</div>
<h4>
<a name="idm46045077043728">
</a>
Notes
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
You must have the
<a class="link" href="privileges-provided.html#priv_process">
<code class="literal">
PROCESS
</code>
</a>
privilege to query this table.
</p>
</li>
<li class="listitem">
<p>
Use the
<code class="literal">
INFORMATION_SCHEMA
</code>
<a class="link" href="information-schema-columns-table.html" title="28.3.8 The INFORMATION_SCHEMA COLUMNS Table">
<code class="literal">
COLUMNS
</code>
</a>
table or the
<a class="link" href="show-columns.html" title="15.7.7.6 SHOW COLUMNS Statement">
<code class="literal">
SHOW COLUMNS
</code>
</a>
statement to view
additional information about the columns of this table,
including data types and default values.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-releases.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="mysql-releases">
</a>
1.3 MySQL Releases: Innovation and LTS
</h2>
</div>
</div>
</div>
<p>
The MySQL release model is divided into two main tracks: LTS
(Long-Term Support) and Innovation. All LTS and Innovation
releases include bug and security fixes, and are considered
production-grade quality.
</p>
<div class="figure">
<a name="mysql-lts-innovation-versioning-graph">
</a>
<p class="title">
<b>
Figure 1.1 MySQL Release Schedule
</b>
</p>
<div class="figure-contents">
<div class="mediaobject">
<img alt="Graph shows the general release cycle starting with MySQL 8.0.0 Bugfix series, and shows short Innovation releases between each long LTS version. Roughly every two years a new LTS series branch begins, including 8.4.x and 9.7.x." src="images/mysql-lts-innovation-versioning-graph.png" style="width: 100%; max-width: 830px;"/>
</div>
</div>
</div>
<br class="figure-break"/>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="mysql-releases-lts">
</a>
MySQL LTS Releases
</h3>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
Audience
</code>
: If your environment requires a
stable set of features and a longer support period.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Behavior
</code>
: These releases only contain
necessary fixes to reduce the risks associated with changes
in the database software's behavior. There are no removals
within an LTS release. Features can be removed (and added)
only in the first LTS release (such as 8.4.0 LTS) but not
later.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Support
</code>
: An LTS series follows the
<a class="ulink" href="https://www.oracle.com/support/lifetime-support/software.html" target="_blank">
Oracle
Lifetime Support
</a>
Policy, which includes 5 years of
premier support and 3 years of extended support.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="mysql-releases-innovation">
</a>
MySQL Innovation Releases
</h3>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
Audience
</code>
: If you want access to the
latest features, improvements, and changes. These releases
are ideal for developers and DBAs working in fast-paced
development environments with high levels of automated tests
and modern continuous integration techniques for faster
upgrade cycles.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Behavior
</code>
: Apart from new features in
innovation releases, behavior changes are also expected as
code is refactored, deprecated functionality is removed, and
when MySQL is modified to behave more in line with SQL
Standards. This will not happen within an LTS release.
</p>
<p>
Behavior changes can have a big impact, especially when
dealing with anything application-related, such as SQL
syntax, new reserved words, query execution, and query
performance. Behavior changes might require application
changes which can involve considerable effort to migrate. We
intend to provide the necessary tools and configuration
settings to make these transitions easier.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
Support
</code>
: Innovation releases are
supported until the next Innovation release.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="mysql-releases-portfolio">
</a>
MySQL Portfolio
</h3>
</div>
</div>
</div>
<p>
MySQL Server, MySQL Shell, MySQL Router, MySQL Operator for
Kubernetes, and MySQL NDB Cluster have both Innovation and LTS
releases.
</p>
<p>
MySQL Connectors have one release using the latest version
number but remain compatible with all supported MySQL Server
versions. For example, MySQL Connector/Python 9.0.0 is
compatible with MySQL Server 8.0, 8.4, and 9.0.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="mysql-releases-install-upgrade-downgrade">
</a>
Installing, Upgrading, and Downgrading
</h3>
</div>
</div>
</div>
<p>
Having two tracks affects how MySQL is installed, upgraded, and
downgraded. Typically you choose one particular track and all
upgrades progress accordingly.
</p>
<p>
When using the official MySQL repository, the desired track is
defined in the repository configuration. For example, with
<a class="link" href="linux-installation-yum-repo.html" title="2.5.1 Installing MySQL on Linux Using the MySQL Yum Repository">
Yum
</a>
choose
<code class="literal">
mysql-innovation-community
</code>
to install and
upgrade Innovation releases or
<code class="literal">
mysql-8.4-lts-community
</code>
to
install and upgrade MySQL 8.4.x releases.
</p>
<p>
<span class="strong">
<strong>
LTS Notes
</strong>
</span>
</p>
<p>
Functionality remains the same and data format does not change
in an
<a class="link" href="glossary.html#glos_lts_series" title="LTS Series">
LTS series
</a>
,
therefore in-place upgrades and downgrades are possible within
the LTS series. For example, MySQL 8.4.0 can be upgraded to a
later MySQL 8.4.x release. Additional upgrade and downgrade
methods are available, such as
<a class="link" href="clone-plugin.html" title="7.6.7 The Clone Plugin">
the
clone plugin
</a>
.
</p>
<p>
Upgrading to the next
<a class="link" href="glossary.html#glos_lts_series" title="LTS Series">
LTS
series
</a>
is supported, such as 8.4.x LTS to 9.7.x LTS,
while skipping an LTS series is not supported. For example,
8.4.x LTS can't skip 9.7.x LTS to directly upgrade to 10.7.x
LTS.
</p>
<p>
<span class="strong">
<strong>
Innovation Notes
</strong>
</span>
</p>
<p>
An Innovation installation follows similar behavior in that an
Innovation release upgrades to a more recent
<a class="link" href="glossary.html#glos_innovation_series" title="Innovation Series">
Innovation series
</a>
release. For example, MySQL 9.0.0 Innovation would upgrade to
MySQL 9.3.0.
</p>
<p>
The main difference is that you cannot directly upgrade between
an
<a class="link" href="glossary.html#glos_innovation_series" title="Innovation Series">
Innovation
series
</a>
of different major versions, such as 8.3.0 to
9.0.0. Instead, first upgrade to the nearest LTS series and then
upgrade to the following Innovation series. For example,
upgrading 8.3.0 to 8.4.0, and then 8.4.0 to 9.0.0, is a valid
<a class="link" href="upgrade-paths.html" title="3.2 Upgrade Paths">
upgrade path
</a>
.
</p>
<p>
To help make the transition easier, the official MySQL
repository treats the first LTS release as both LTS and
Innovation, so for example with the Innovation track enabled in
your local repository configuration, MySQL 8.3.0 upgrades to
8.4.0, and later to 9.0.0.
</p>
<p>
Innovation release downgrades require a logical dump and load.
</p>
<p>
<span class="strong">
<strong>
Additional Information and
Examples
</strong>
</span>
</p>
<p>
For additional information and specific example supported
scenarios, see
<a class="xref" href="upgrade-paths.html" title="3.2 Upgrade Paths">
Section 3.2, “Upgrade Paths”
</a>
or
<a class="xref" href="downgrading.html" title="Chapter 4 Downgrading MySQL">
Chapter 4,
<i>
Downgrading MySQL
</i>
</a>
. They describe available options
to perform in-place updates (that replace binaries with the
latest packages), a logical dump and load (such as using
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
or
<a class="ulink" href="/doc/mysql-shell/8.4/en/mysql-shell-utilities-dump-instance-schema.html" target="_top">
MySQL
Shell's dump utilities
</a>
), cloning data with the
<a class="link" href="clone-plugin.html" title="7.6.7 The Clone Plugin">
clone plugin
</a>
, and
<a class="link" href="replication-upgrade.html" title="19.5.3 Upgrading or Downgrading a Replication Topology">
asynchronous
replication
</a>
for servers in a replication topology.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-install-windows.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-cluster-install-windows">
</a>
25.3.2 Installing NDB Cluster on Windows
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="mysql-cluster-install-windows-binary.html">
25.3.2.1 Installing NDB Cluster on Windows from a Binary Release
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-install-windows-source.html">
25.3.2.2 Compiling and Installing NDB Cluster from Source on Windows
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-install-windows-initial-start.html">
25.3.2.3 Initial Startup of NDB Cluster on Windows
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="mysql-cluster-install-windows-service.html">
25.3.2.4 Installing NDB Cluster Processes as Windows Services
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045122585728">
</a>
<a class="indexterm" name="idm46045122584240">
</a>
<p>
This section describes installation procedures for NDB Cluster on
Windows hosts. NDB Cluster 8.4 binaries for Windows
can be obtained from
<a class="ulink" href="https://dev.mysql.com/downloads/cluster/" target="_top">
https://dev.mysql.com/downloads/cluster/
</a>
.
For information about installing NDB Cluster on Windows from a
binary release provided by Oracle, see
<a class="xref" href="mysql-cluster-install-windows-binary.html" title="25.3.2.1 Installing NDB Cluster on Windows from a Binary Release">
Section 25.3.2.1, “Installing NDB Cluster on Windows from a Binary Release”
</a>
.
</p>
<p>
It is also possible to compile and install NDB Cluster from source
on Windows using Microsoft Visual Studio. For more information,
see
<a class="xref" href="mysql-cluster-install-windows-source.html" title="25.3.2.2 Compiling and Installing NDB Cluster from Source on Windows">
Section 25.3.2.2, “Compiling and Installing NDB Cluster from Source on Windows”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-importing-data.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-cluster-importing-data">
</a>
25.6.9 Importing Data Into MySQL Cluster
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045091863040">
</a>
<a class="indexterm" name="idm46045091861552">
</a>
<p>
It is common when setting up a new instance of NDB Cluster to need
to import data from an existing NDB Cluster, instance of MySQL, or
other source. This data is most often available in one or more of
the following formats:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
An SQL dump file such as produced by
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
. This can be imported using the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client, as shown later in this
section.
</p>
</li>
<li class="listitem">
<p>
A CSV file produced by
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
or other
export program. Such files can be imported into
<code class="literal">
NDB
</code>
using
<code class="literal">
LOAD DATA
INFILE
</code>
in the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client, or
with the
<a class="link" href="mysql-cluster-programs-ndb-import.html" title="25.5.13 ndb_import — Import CSV Data Into NDB">
<span class="command">
<strong>
ndb_import
</strong>
</span>
</a>
utility provided with
the NDB Cluster distribution. For more information about the
latter, see
<a class="xref" href="mysql-cluster-programs-ndb-import.html" title="25.5.13 ndb_import — Import CSV Data Into NDB">
Section 25.5.13, “ndb_import — Import CSV Data Into NDB”
</a>
.
</p>
</li>
<li class="listitem">
<p>
A native
<code class="literal">
NDB
</code>
backup produced using
<a class="link" href="mysql-cluster-backup-using-management-client.html" title="25.6.8.2 Using The NDB Cluster Management Client to Create a Backup">
<code class="literal">
START BACKUP
</code>
</a>
in the
<code class="literal">
NDB
</code>
management client. To import a native
backup, you must use the
<a class="link" href="mysql-cluster-programs-ndb-restore.html" title="25.5.23 ndb_restore — Restore an NDB Cluster Backup">
<span class="command">
<strong>
ndb_restore
</strong>
</span>
</a>
program that comes as part of NDB Cluster. See
<a class="xref" href="mysql-cluster-programs-ndb-restore.html" title="25.5.23 ndb_restore — Restore an NDB Cluster Backup">
Section 25.5.23, “ndb_restore — Restore an NDB Cluster Backup”
</a>
, for more
about using this program.
</p>
</li>
</ul>
</div>
<p>
When importing data from an SQL file, it is often not necessary to
enforce transactions or foreign keys, and temporarily disabling
these features can speed up the import process greatly. This can
be done using the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client, either from a
client session, or by invoking it on the command line. Within a
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client session, you can perform the
import using the following SQL statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa55364858"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> ndb_use_transactions<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> foreign_key_checks<span class="token operator">=</span><span class="token number">0</span><span class="token punctuation">;</span>
<span class="token keyword">source</span> <span class="token keyword"></span><em class="replaceable"><span class="token keyword">path</span><span class="token operator">/</span><span class="token keyword">to</span><span class="token operator">/</span><span class="token keyword">dumpfile</span></em><span class="token keyword"></span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> ndb_use_transactions<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> foreign_key_checks<span class="token operator">=</span><span class="token number">1</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
When performing the import in this fashion, you
<span class="emphasis">
<em>
must
</em>
</span>
enable
<code class="literal">
ndb_use_transaction
</code>
and
<code class="literal">
foreign_key_checks
</code>
again following execution of
the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client's
<code class="literal">
source
</code>
command. Otherwise, it is possible for
later statements in same session may also be executed without
enforcing transactions or foreign key constraints, and which could
lead to data inconcsistency.
</p>
<p>
From the system shell, you can import the SQL file while disabling
enforcement of transaction and foreign keys by using the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client with the
<a class="link" href="mysql-command-options.html#option_mysql_init-command">
<code class="option">
--init-command
</code>
</a>
option, like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa99554229"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">$<span class="token operator">></span> mysql <span class="token comment" spellcheck="true">--init-command='SET ndb_use_transactions=0; SET foreign_key_checks=0' < <em class="replaceable">path/to/dumpfile</em></span></code></pre>
</div>
<p>
It is also possible to load the data into an
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
table, and convert it to use
the
<code class="literal">
NDB
</code>
storage engine afterwards using ALTER
TABLE ... ENGINE NDB). You should take into account, especially
for many tables, that this may require a number of such
operations; in addition, if foreign keys are used, you must mind
the order of the
<code class="literal">
ALTER TABLE
</code>
statements
carefully, due to the fact that foreign keys do not work between
tables using different MySQL storage engines.
</p>
<p>
You should be aware that the methods described previously in this
section are not optimized for very large data sets or large
transactions. Should an application really need big transactions
or many concurrent transactions as part of normal operation, you
may wish to increase the value of the
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-maxnoofconcurrentoperations">
<code class="literal">
MaxNoOfConcurrentOperations
</code>
</a>
data node configuration parameter, which reserves more memory to
allow a data node to take over a transaction if its transaction
coordinator stops unexpectedly.
</p>
<p>
You may also wish to do this when performing bulk
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
or
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
operations on NDB Cluster
tables. If possible, try to have applications perform these
operations in chunks, for example, by adding
<code class="literal">
LIMIT
</code>
to such statements.
</p>
<p>
If a data import operation does not complete successfully, for
whatever reason, you should be prepared to perform any necessary
cleanup including possibly one or more
<a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
<code class="literal">
DROP
TABLE
</code>
</a>
statements,
<a class="link" href="drop-database.html" title="15.1.24 DROP DATABASE Statement">
<code class="literal">
DROP
DATABASE
</code>
</a>
statements, or both. Failing to do so may leave
the database in an inconsistent state.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-features-max-allowed-packet.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="replication-features-max-allowed-packet">
</a>
19.5.1.20 Replication and max_allowed_packet
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045135361728">
</a>
<a class="indexterm" name="idm46045135360240">
</a>
<p>
<a class="link" href="server-system-variables.html#sysvar_max_allowed_packet">
<code class="literal">
max_allowed_packet
</code>
</a>
sets an
upper limit on the size of any single message between the MySQL
server and clients, including replicas. If you are replicating
large column values (such as might be found in
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
TEXT
</code>
</a>
or
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
columns) and
<a class="link" href="server-system-variables.html#sysvar_max_allowed_packet">
<code class="literal">
max_allowed_packet
</code>
</a>
is too small
on the source, the source fails with an error, and the replica
shuts down the replication I/O (receiver) thread. If
<a class="link" href="server-system-variables.html#sysvar_max_allowed_packet">
<code class="literal">
max_allowed_packet
</code>
</a>
is too small
on the replica, this also causes the replica to stop the I/O
thread.
</p>
<p>
Row-based replication sends all columns and column values for
updated rows from the source to the replica, including values of
columns that were not actually changed by the update. This means
that, when you are replicating large column values using
row-based replication, you must take care to set
<a class="link" href="server-system-variables.html#sysvar_max_allowed_packet">
<code class="literal">
max_allowed_packet
</code>
</a>
large enough
to accommodate the largest row in any table to be replicated,
even if you are replicating updates only, or you are inserting
only relatively small values.
</p>
<p>
On a multi-threaded replica (with
<a class="link" href="replication-options-replica.html#sysvar_replica_parallel_workers">
<code class="literal">
replica_parallel_workers >
0
</code>
</a>
), ensure that the system variable
<a class="link" href="replication-options-replica.html#sysvar_replica_pending_jobs_size_max">
<code class="literal">
replica_pending_jobs_size_max
</code>
</a>
is set to a value equal to or greater than the setting for the
<a class="link" href="server-system-variables.html#sysvar_max_allowed_packet">
<code class="literal">
max_allowed_packet
</code>
</a>
system
variable on the source. The default setting for
<code class="literal">
replica_pending_jobs_size_max
</code>
, 128M, is twice
the default setting for
<code class="literal">
max_allowed_packet
</code>
,
which is 64M.
<code class="literal">
max_allowed_packet
</code>
limits the
packet size that the source can send, but the addition of an
event header can produce a binary log event exceeding this size.
Also, in row-based replication, a single event can be
significantly larger than the
<code class="literal">
max_allowed_packet
</code>
size, because the value of
<code class="literal">
max_allowed_packet
</code>
only limits each column of
the table.
</p>
<p>
The replica actually accepts packets up to the limit set by its
<a class="link" href="replication-options-replica.html#sysvar_replica_max_allowed_packet">
<code class="literal">
replica_max_allowed_packet
</code>
</a>
setting, which default to the maximum setting of 1GB, to prevent
a replication failure due to a large packet. However, the value
of
<a class="link" href="replication-options-replica.html#sysvar_replica_pending_jobs_size_max">
<code class="literal">
replica_pending_jobs_size_max
</code>
</a>
controls the memory that is made available on the replica to
hold incoming packets. The specified memory is shared among all
the replica worker queues.
</p>
<p>
The value of
<a class="link" href="replication-options-replica.html#sysvar_replica_pending_jobs_size_max">
<code class="literal">
replica_pending_jobs_size_max
</code>
</a>
is a soft limit, and if an unusually large event (consisting of
one or multiple packets) exceeds this size, the transaction is
held until all the replica workers have empty queues, and then
processed. All subsequent transactions are held until the large
transaction has been completed. So although unusual events
larger than
<a class="link" href="replication-options-replica.html#sysvar_replica_pending_jobs_size_max">
<code class="literal">
replica_pending_jobs_size_max
</code>
</a>
can be processed, the delay to clear the queues of all the
replica workers and the wait to queue subsequent transactions
can cause lag on the replica and decreased concurrency of the
replica workers.
<a class="link" href="replication-options-replica.html#sysvar_replica_pending_jobs_size_max">
<code class="literal">
replica_pending_jobs_size_max
</code>
</a>
should therefore be set high enough to accommodate most expected
event sizes.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-installation-windows-path.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-installation-windows-path">
</a>
2.3.3.7 Customizing the PATH for MySQL Tools
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045332032512">
</a>
<a class="indexterm" name="idm46045332031424">
</a>
<div class="warning" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Warning
</div>
<p>
You must exercise great care when editing your system
<code class="literal">
PATH
</code>
by hand; accidental deletion or
modification of any portion of the existing
<code class="literal">
PATH
</code>
value can leave you with a
malfunctioning or even unusable system.
</p>
</div>
<p>
To make it easier to invoke MySQL programs, you can add the path
name of the MySQL
<code class="filename">
bin
</code>
directory to your
Windows system
<code class="literal">
PATH
</code>
environment variable:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
On the Windows desktop, right-click the
<span class="guiicon">
My
Computer
</span>
icon, and select
<span class="guimenuitem">
Properties
</span>
.
</p>
</li>
<li class="listitem">
<p>
Next select the
<span class="guimenuitem">
Advanced
</span>
tab from
the
<span class="guimenu">
System Properties
</span>
menu that appears,
and click the
<span class="guibutton">
Environment Variables
</span>
button.
</p>
</li>
<li class="listitem">
<p>
Under
<span class="guilabel">
System Variables
</span>
, select
<span class="guimenuitem">
Path
</span>
, and then click the
<span class="guibutton">
Edit
</span>
button. The
<span class="guimenu">
Edit System
Variable
</span>
dialogue should appear.
</p>
</li>
<li class="listitem">
<p>
Place your cursor at the end of the text appearing in the
space marked
<span class="guilabel">
Variable Value
</span>
. (Use the
<span class="keycap">
<strong>
End
</strong>
</span>
key to ensure that your cursor is
positioned at the very end of the text in this space.) Then
enter the complete path name of your MySQL
<code class="filename">
bin
</code>
directory (for example,
<code class="literal">
C:\Program Files\MySQL\MySQL Server
8.4\bin
</code>
)
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
There must be a semicolon separating this path from any
values present in this field.
</p>
</div>
<p>
Dismiss this dialogue, and each dialogue in turn, by
clicking
<span class="guibutton">
OK
</span>
until all of the
dialogues that were opened have been dismissed. The new
<code class="literal">
PATH
</code>
value should now be available to any
new command shell you open, allowing you to invoke any MySQL
executable program by typing its name at the DOS prompt from
any directory on the system, without having to supply the
path. This includes the servers, the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client, and all MySQL command-line
utilities such as
<a class="link" href="mysqladmin.html" title="6.5.2 mysqladmin — A MySQL Server Administration Program">
<span class="command">
<strong>
mysqladmin
</strong>
</span>
</a>
and
<a class="link" href="mysqldump.html" title="6.5.4 mysqldump — A Database Backup Program">
<span class="command">
<strong>
mysqldump
</strong>
</span>
</a>
.
</p>
</li>
</ul>
</div>
<p>
You should not add the MySQL
<code class="filename">
bin
</code>
directory
to your Windows
<code class="literal">
PATH
</code>
if you are running
multiple MySQL servers on the same machine.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-events-stages-history-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="performance-schema-events-stages-history-table">
</a>
29.12.5.2 The events_stages_history Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045072991920">
</a>
<a class="indexterm" name="idm46045072990416">
</a>
<p>
The
<a class="link" href="performance-schema-events-stages-history-table.html" title="29.12.5.2 The events_stages_history Table">
<code class="literal">
events_stages_history
</code>
</a>
table
contains the
<em class="replaceable">
<code>
N
</code>
</em>
most recent stage
events that have ended per thread. Stage events are not added
to the table until they have ended. When the table contains
the maximum number of rows for a given thread, the oldest
thread row is discarded when a new row for that thread is
added. When a thread ends, all its rows are discarded.
</p>
<p>
The Performance Schema autosizes the value of
<em class="replaceable">
<code>
N
</code>
</em>
during server startup. To set the
number of rows per thread explicitly, set the
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_events_stages_history_size">
<code class="literal">
performance_schema_events_stages_history_size
</code>
</a>
system variable at server startup.
</p>
<p>
The
<a class="link" href="performance-schema-events-stages-history-table.html" title="29.12.5.2 The events_stages_history Table">
<code class="literal">
events_stages_history
</code>
</a>
table
has the same columns and indexing as
<a class="link" href="performance-schema-events-stages-current-table.html" title="29.12.5.1 The events_stages_current Table">
<code class="literal">
events_stages_current
</code>
</a>
. See
<a class="xref" href="performance-schema-events-stages-current-table.html" title="29.12.5.1 The events_stages_current Table">
Section 29.12.5.1, “The events_stages_current Table”
</a>
.
</p>
<p>
<a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
<code class="literal">
TRUNCATE TABLE
</code>
</a>
is permitted for
the
<a class="link" href="performance-schema-events-stages-history-table.html" title="29.12.5.2 The events_stages_history Table">
<code class="literal">
events_stages_history
</code>
</a>
table.
It removes the rows.
</p>
<p>
For more information about the relationship between the three
stage event tables, see
<a class="xref" href="performance-schema-event-tables.html" title="29.9 Performance Schema Tables for Current and Historical Events">
Section 29.9, “Performance Schema Tables for Current and Historical Events”
</a>
.
</p>
<p>
For information about configuring whether to collect stage
events, see
<a class="xref" href="performance-schema-stage-tables.html" title="29.12.5 Performance Schema Stage Event Tables">
Section 29.12.5, “Performance Schema Stage Event Tables”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/keyring-functions-general-purpose.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="keyring-functions-general-purpose">
</a>
8.4.4.12 General-Purpose Keyring Key-Management Functions
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045239685248">
</a>
<a class="indexterm" name="idm46045239683760">
</a>
<a class="indexterm" name="idm46045239682272">
</a>
<p>
MySQL Server supports a keyring service that enables internal
components and plugins to store sensitive information securely
for later retrieval.
</p>
<p>
MySQL Server also includes an SQL interface for keyring key
management, implemented as a set of general-purpose functions
that access the capabilities provided by the internal keyring
service. The keyring functions are contained in a plugin library
file, which also contains a
<code class="literal">
keyring_udf
</code>
plugin that must be enabled prior to function invocation. For
these functions to be used, a keyring plugin such as
<code class="literal">
keyring_okv
</code>
, or a keyring component such as
<code class="literal">
component_keyring_file
</code>
or
<code class="literal">
component_keyring_encrypted_file
</code>
, must be
enabled.
</p>
<p>
The functions described here are general-purpose and intended
for use with any keyring component or plugin. A given keyring
component or plugin may also provide functions of its own that
are intended for use only with that component or plugin; see
<a class="xref" href="keyring-functions-plugin-specific.html" title="8.4.4.13 Plugin-Specific Keyring Key-Management Functions">
Section 8.4.4.13, “Plugin-Specific Keyring Key-Management Functions”
</a>
.
</p>
<p>
The following sections provide installation instructions for the
keyring functions and demonstrate how to use them. For general
keyring information, see
<a class="xref" href="keyring.html" title="8.4.4 The MySQL Keyring">
Section 8.4.4, “The MySQL Keyring”
</a>
.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="keyring-functions-general-purpose.html#keyring-function-installation" title="Installing or Uninstalling General-Purpose Keyring Functions">
Installing or Uninstalling General-Purpose Keyring Functions
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="keyring-functions-general-purpose.html#keyring-function-usage" title="Using General-Purpose Keyring Functions">
Using General-Purpose Keyring Functions
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="keyring-functions-general-purpose.html#keyring-function-reference" title="General-Purpose Keyring Function Reference">
General-Purpose Keyring Function Reference
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="keyring-function-installation">
</a>
Installing or Uninstalling General-Purpose Keyring Functions
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045239669120">
</a>
<a class="indexterm" name="idm46045239667632">
</a>
<a class="indexterm" name="idm46045239666144">
</a>
<a class="indexterm" name="idm46045239664656">
</a>
<a class="indexterm" name="idm46045239663168">
</a>
<a class="indexterm" name="idm46045239661680">
</a>
<p>
This section describes how to install or uninstall the keyring
functions, which are implemented in a plugin library file that
also contains a
<code class="literal">
keyring_udf
</code>
plugin. For
general information about installing or uninstalling plugins
and loadable functions, see
<a class="xref" href="plugin-loading.html" title="7.6.1 Installing and Uninstalling Plugins">
Section 7.6.1, “Installing and Uninstalling Plugins”
</a>
,
and
<a class="xref" href="function-loading.html" title="7.7.1 Installing and Uninstalling Loadable Functions">
Section 7.7.1, “Installing and Uninstalling Loadable Functions”
</a>
.
</p>
<p>
The keyring functions enable keyring key management
operations, but the
<code class="literal">
keyring_udf
</code>
plugin must
also be installed because the functions do not work correctly
without it. Attempts to use the functions without the
<code class="literal">
keyring_udf
</code>
plugin result in an error.
</p>
<p>
To be usable by the server, the plugin library file must be
located in the MySQL plugin directory (the directory named by
the
<a class="link" href="server-system-variables.html#sysvar_plugin_dir">
<code class="literal">
plugin_dir
</code>
</a>
system
variable). If necessary, configure the plugin directory
location by setting the value of
<a class="link" href="server-system-variables.html#sysvar_plugin_dir">
<code class="literal">
plugin_dir
</code>
</a>
at server startup.
</p>
<p>
The plugin library file base name is
<code class="literal">
keyring_udf
</code>
. The file name suffix differs
per platform (for example,
<code class="filename">
.so
</code>
for Unix
and Unix-like systems,
<code class="filename">
.dll
</code>
for Windows).
</p>
<p>
To install the
<code class="literal">
keyring_udf
</code>
plugin and the
keyring functions, use the
<a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
<code class="literal">
INSTALL
PLUGIN
</code>
</a>
and
<a class="link" href="create-function.html" title="15.1.14 CREATE FUNCTION Statement">
<code class="literal">
CREATE
FUNCTION
</code>
</a>
statements, adjusting the
<code class="filename">
.so
</code>
suffix for your platform as
necessary:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa59798282"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSTALL</span> <span class="token keyword">PLUGIN</span> keyring_udf <span class="token keyword">SONAME</span> <span class="token string">'keyring_udf.so'</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">FUNCTION</span> keyring_key_generate <span class="token keyword">RETURNS</span> <span class="token datatype">INTEGER</span>
<span class="token keyword">SONAME</span> <span class="token string">'keyring_udf.so'</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">FUNCTION</span> keyring_key_fetch <span class="token keyword">RETURNS</span> <span class="token keyword">STRING</span>
<span class="token keyword">SONAME</span> <span class="token string">'keyring_udf.so'</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">FUNCTION</span> keyring_key_length_fetch <span class="token keyword">RETURNS</span> <span class="token datatype">INTEGER</span>
<span class="token keyword">SONAME</span> <span class="token string">'keyring_udf.so'</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">FUNCTION</span> keyring_key_type_fetch <span class="token keyword">RETURNS</span> <span class="token keyword">STRING</span>
<span class="token keyword">SONAME</span> <span class="token string">'keyring_udf.so'</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">FUNCTION</span> keyring_key_store <span class="token keyword">RETURNS</span> <span class="token datatype">INTEGER</span>
<span class="token keyword">SONAME</span> <span class="token string">'keyring_udf.so'</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">FUNCTION</span> keyring_key_remove <span class="token keyword">RETURNS</span> <span class="token datatype">INTEGER</span>
<span class="token keyword">SONAME</span> <span class="token string">'keyring_udf.so'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
If the plugin and functions are used on a source replication
server, install them on all replicas as well to avoid
replication issues.
</p>
<p>
Once installed as just described, the plugin and functions
remain installed until uninstalled. To remove them, use the
<a class="link" href="uninstall-plugin.html" title="15.7.4.6 UNINSTALL PLUGIN Statement">
<code class="literal">
UNINSTALL PLUGIN
</code>
</a>
and
<a class="link" href="drop-function.html" title="15.1.26 DROP FUNCTION Statement">
<code class="literal">
DROP FUNCTION
</code>
</a>
statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa33811569"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UNINSTALL</span> <span class="token keyword">PLUGIN</span> keyring_udf<span class="token punctuation">;</span>
<span class="token keyword">DROP</span> <span class="token keyword">FUNCTION</span> keyring_key_generate<span class="token punctuation">;</span>
<span class="token keyword">DROP</span> <span class="token keyword">FUNCTION</span> keyring_key_fetch<span class="token punctuation">;</span>
<span class="token keyword">DROP</span> <span class="token keyword">FUNCTION</span> keyring_key_length_fetch<span class="token punctuation">;</span>
<span class="token keyword">DROP</span> <span class="token keyword">FUNCTION</span> keyring_key_type_fetch<span class="token punctuation">;</span>
<span class="token keyword">DROP</span> <span class="token keyword">FUNCTION</span> keyring_key_store<span class="token punctuation">;</span>
<span class="token keyword">DROP</span> <span class="token keyword">FUNCTION</span> keyring_key_remove<span class="token punctuation">;</span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="keyring-function-usage">
</a>
Using General-Purpose Keyring Functions
</h5>
</div>
</div>
</div>
<a class="indexterm" name="idm46045239637680">
</a>
<p>
Before using the keyring general-purpose functions, install
them according to the instructions provided in
<a class="xref" href="keyring-functions-general-purpose.html#keyring-function-installation" title="Installing or Uninstalling General-Purpose Keyring Functions">
Installing or Uninstalling General-Purpose Keyring Functions
</a>
.
</p>
<p>
The keyring functions are subject to these constraints:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
To use any keyring function, the
<code class="literal">
keyring_udf
</code>
plugin must be enabled.
Otherwise, an error occurs:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa24251735"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">ERROR 1123 (HY000): Can't initialize function 'keyring_key_generate';
This function requires keyring_udf plugin which is not installed.
Please install</code></pre>
</div>
<p>
To install the
<code class="literal">
keyring_udf
</code>
plugin, see
<a class="xref" href="keyring-functions-general-purpose.html#keyring-function-installation" title="Installing or Uninstalling General-Purpose Keyring Functions">
Installing or Uninstalling General-Purpose Keyring Functions
</a>
.
</p>
</li>
<li class="listitem">
<p>
The keyring functions invoke keyring service functions
(see
<a class="xref" href="keyring-service.html" title="7.6.9.2 The Keyring Service">
Section 7.6.9.2, “The Keyring Service”
</a>
). The service
functions in turn use whatever keyring plugin is installed
(for example,
<code class="literal">
keyring_okv
</code>
). Therefore,
to use any keyring function, some underlying keyring
plugin must be enabled. Otherwise, an error occurs:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa62992249"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">ERROR 3188 (HY000): Function 'keyring_key_generate' failed because
underlying keyring service returned an error. Please check if a
keyring plugin is installed and that provided arguments are valid
for the keyring you are using.</code></pre>
</div>
<p>
To install a keyring plugin, see
<a class="xref" href="keyring-plugin-installation.html" title="8.4.4.3 Keyring Plugin Installation">
Section 8.4.4.3, “Keyring Plugin Installation”
</a>
.
</p>
</li>
<li class="listitem">
<p>
A user must possess the global
<a class="link" href="privileges-provided.html#priv_execute">
<code class="literal">
EXECUTE
</code>
</a>
privilege to use
any keyring function. Otherwise, an error occurs:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa95083671"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">ERROR 1123 (HY000): Can't initialize function 'keyring_key_generate';
The user is not privileged to execute this function. User needs to
have EXECUTE</code></pre>
</div>
<p>
To grant the global
<a class="link" href="privileges-provided.html#priv_execute">
<code class="literal">
EXECUTE
</code>
</a>
privilege to a user, use this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa92653165"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">GRANT</span> <span class="token keyword">EXECUTE</span> <span class="token keyword">ON</span> <span class="token operator">*</span><span class="token punctuation">.</span><span class="token operator">*</span> <span class="token keyword">TO</span> <span class="token keyword"><em class="replaceable">user</em></span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Alternatively, should you prefer to avoid granting the
global
<a class="link" href="privileges-provided.html#priv_execute">
<code class="literal">
EXECUTE
</code>
</a>
privilege
while still permitting users to access specific
key-management operations,
<span class="quote">
“
<span class="quote">
wrapper
</span>
”
</span>
stored
programs can be defined (a technique described later in
this section).
</p>
</li>
<li class="listitem">
<p>
A key stored in the keyring by a given user can be
manipulated later only by the same user. That is, the
value of the
<a class="link" href="information-functions.html#function_current-user">
<code class="literal">
CURRENT_USER()
</code>
</a>
function at the time of key manipulation must have the
same value as when the key was stored in the keyring.
(This constraint rules out the use of the keyring
functions for manipulation of instance-wide keys, such as
those created by
<code class="literal">
InnoDB
</code>
to support
tablespace encryption.)
</p>
<p>
To enable multiple users to perform operations on the same
key,
<span class="quote">
“
<span class="quote">
wrapper
</span>
”
</span>
stored programs can be defined
(a technique described later in this section).
</p>
</li>
<li class="listitem">
<p>
Keyring functions support the key types and lengths
supported by the underlying keyring plugin. For
information about keys specific to a particular keyring
plugin, see
<a class="xref" href="keyring-key-types.html" title="8.4.4.10 Supported Keyring Key Types and Lengths">
Section 8.4.4.10, “Supported Keyring Key Types and Lengths”
</a>
.
</p>
</li>
</ul>
</div>
<p>
To create a new random key and store it in the keyring, call
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-generate">
<code class="literal">
keyring_key_generate()
</code>
</a>
, passing
to it an ID for the key, along with the key type (encryption
method) and its length in bytes. The following call creates a
2,048-bit DSA-encrypted key named
<code class="literal">
MyKey
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa59683163"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_generate<span class="token punctuation">(</span><span class="token string">'MyKey'</span><span class="token punctuation">,</span> <span class="token string">'DSA'</span><span class="token punctuation">,</span> <span class="token number">256</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> keyring_key_generate('MyKey', 'DSA', 256) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
A return value of 1 indicates success. If the key cannot be
created, the return value is
<code class="literal">
NULL
</code>
and an
error occurs. One reason this might be is that the underlying
keyring plugin does not support the specified combination of
key type and key length; see
<a class="xref" href="keyring-key-types.html" title="8.4.4.10 Supported Keyring Key Types and Lengths">
Section 8.4.4.10, “Supported Keyring Key Types and Lengths”
</a>
.
</p>
<p>
To be able to check the return type regardless of whether an
error occurs, use
<code class="literal">
SELECT ... INTO
@
<em class="replaceable">
<code>
var_name
</code>
</em>
</code>
and test the
variable value:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa4424268"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_generate<span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">,</span> <span class="token operator">-</span><span class="token number">1</span><span class="token punctuation">)</span> <span class="token keyword">INTO</span> <span class="token variable">@x</span><span class="token punctuation">;</span>
<span class="token output">ERROR 3188 (HY000)<span class="token punctuation">:</span> Function 'keyring_key_generate' failed because
underlying keyring service returned an error. Please check if a
keyring plugin is installed and that provided arguments are valid
for the keyring you are using.</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token variable">@x</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> @x <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NULL <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_generate<span class="token punctuation">(</span><span class="token string">'x'</span><span class="token punctuation">,</span> <span class="token string">'AES'</span><span class="token punctuation">,</span> <span class="token number">16</span><span class="token punctuation">)</span> <span class="token keyword">INTO</span> <span class="token variable">@x</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token variable">@x</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> @x <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
This technique also applies to other keyring functions that
for failure return a value and an error.
</p>
<p>
The ID passed to
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-generate">
<code class="literal">
keyring_key_generate()
</code>
</a>
provides
a means by which to refer to the key in subsequent functions
calls. For example, use the key ID to retrieve its type as a
string or its length in bytes as an integer:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa31151019"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_type_fetch<span class="token punctuation">(</span><span class="token string">'MyKey'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> keyring_key_type_fetch('MyKey') <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> DSA <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_length_fetch<span class="token punctuation">(</span><span class="token string">'MyKey'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> keyring_key_length_fetch('MyKey') <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 256 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
To retrieve a key value, pass the key ID to
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-fetch">
<code class="literal">
keyring_key_fetch()
</code>
</a>
. The
following example uses
<a class="link" href="string-functions.html#function_hex">
<code class="literal">
HEX()
</code>
</a>
to
display the key value because it may contain nonprintable
characters. The example also uses a short key for brevity, but
be aware that longer keys provide better security:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa24752695"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_generate<span class="token punctuation">(</span><span class="token string">'MyShortKey'</span><span class="token punctuation">,</span> <span class="token string">'DSA'</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> keyring_key_generate('MyShortKey', 'DSA', 8) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">HEX</span><span class="token punctuation">(</span>keyring_key_fetch<span class="token punctuation">(</span><span class="token string">'MyShortKey'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> HEX(keyring_key_fetch('MyShortKey')) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1DB3B0FC3328A24C <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
Keyring functions treat key IDs, types, and values as binary
strings, so comparisons are case-sensitive. For example, IDs
of
<code class="literal">
MyKey
</code>
and
<code class="literal">
mykey
</code>
refer
to different keys.
</p>
<p>
To remove a key, pass the key ID to
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-remove">
<code class="literal">
keyring_key_remove()
</code>
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa24962942"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_remove<span class="token punctuation">(</span><span class="token string">'MyKey'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> keyring_key_remove('MyKey') <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
To obfuscate and store a key that you provide, pass the key
ID, type, and value to
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-store">
<code class="literal">
keyring_key_store()
</code>
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa24704662"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_store<span class="token punctuation">(</span><span class="token string">'AES_key'</span><span class="token punctuation">,</span> <span class="token string">'AES'</span><span class="token punctuation">,</span> <span class="token string">'Secret string'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> keyring_key_store('AES_key', 'AES', 'Secret string') <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
As indicated previously, a user must have the global
<a class="link" href="privileges-provided.html#priv_execute">
<code class="literal">
EXECUTE
</code>
</a>
privilege to call
keyring functions, and the user who stores a key in the
keyring initially must be the same user who performs
subsequent operations on the key later, as determined from the
<a class="link" href="information-functions.html#function_current-user">
<code class="literal">
CURRENT_USER()
</code>
</a>
value in effect
for each function call. To permit key operations to users who
do not have the global
<a class="link" href="privileges-provided.html#priv_execute">
<code class="literal">
EXECUTE
</code>
</a>
privilege or who may not be the key
<span class="quote">
“
<span class="quote">
owner,
</span>
”
</span>
use
this technique:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Define
<span class="quote">
“
<span class="quote">
wrapper
</span>
”
</span>
stored programs that
encapsulate the required key operations and have a
<code class="literal">
DEFINER
</code>
value equal to the key owner.
</p>
</li>
<li class="listitem">
<p>
Grant the
<a class="link" href="privileges-provided.html#priv_execute">
<code class="literal">
EXECUTE
</code>
</a>
privilege
for specific stored programs to the individual users who
should be able to invoke them.
</p>
</li>
<li class="listitem">
<p>
If the operations implemented by the wrapper stored
programs do not include key creation, create any necessary
keys in advance, using the account named as the
<code class="literal">
DEFINER
</code>
in the stored program
definitions.
</p>
</li>
</ol>
</div>
<p>
This technique enables keys to be shared among users and
provides to DBAs more fine-grained control over who can do
what with keys, without having to grant global privileges.
</p>
<p>
The following example shows how to set up a shared key named
<code class="literal">
SharedKey
</code>
that is owned by the DBA, and a
<code class="literal">
get_shared_key()
</code>
stored function that
provides access to the current key value. The value can be
retrieved by any user with the
<a class="link" href="privileges-provided.html#priv_execute">
<code class="literal">
EXECUTE
</code>
</a>
privilege for that
function, which is created in the
<code class="literal">
key_schema
</code>
schema.
</p>
<p>
From a MySQL administrative account
(
<code class="literal">
'root'@'localhost'
</code>
in this example),
create the administrative schema and the stored function to
access the key:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa83695613"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">SCHEMA</span> key_schema<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">DEFINER</span> <span class="token operator">=</span> <span class="token string">'root'</span>@<span class="token string">'localhost'</span>
<span class="token keyword">FUNCTION</span> key_schema<span class="token punctuation">.</span>get_shared_key<span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token keyword">RETURNS</span> <span class="token datatype">BLOB</span> <span class="token keyword">READS</span> <span class="token keyword">SQL</span> <span class="token keyword">DATA</span>
<span class="token keyword">RETURN</span> keyring_key_fetch<span class="token punctuation">(</span><span class="token string">'SharedKey'</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
From the administrative account, ensure that the shared key
exists:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa82507161"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_generate<span class="token punctuation">(</span><span class="token string">'SharedKey'</span><span class="token punctuation">,</span> <span class="token string">'DSA'</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> keyring_key_generate('SharedKey', 'DSA', 8) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
From the administrative account, create an ordinary user
account to which key access is to be granted:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa9035732"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'key_user'</span>@<span class="token string">'localhost'</span>
<span class="token keyword">IDENTIFIED</span> <span class="token keyword">BY</span> <span class="token string">'key_user_pwd'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
From the
<code class="literal">
key_user
</code>
account, verify that,
without the proper
<a class="link" href="privileges-provided.html#priv_execute">
<code class="literal">
EXECUTE
</code>
</a>
privilege, the new account cannot access the shared key:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa60219007"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">HEX</span><span class="token punctuation">(</span>key_schema<span class="token punctuation">.</span>get_shared_key<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output">ERROR 1370 (42000)<span class="token punctuation">:</span> execute command denied to user 'key_user'@'localhost'
for routine 'key_schema.get_shared_key'</span></code></pre>
</div>
<p>
From the administrative account, grant
<a class="link" href="privileges-provided.html#priv_execute">
<code class="literal">
EXECUTE
</code>
</a>
to
<code class="literal">
key_user
</code>
for the stored function:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa8002313"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">GRANT</span> <span class="token keyword">EXECUTE</span> <span class="token keyword">ON</span> <span class="token keyword">FUNCTION</span> key_schema<span class="token punctuation">.</span>get_shared_key
<span class="token keyword">TO</span> <span class="token string">'key_user'</span>@<span class="token string">'localhost'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
From the
<code class="literal">
key_user
</code>
account, verify that the
key is now accessible:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa35146736"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">HEX</span><span class="token punctuation">(</span>key_schema<span class="token punctuation">.</span>get_shared_key<span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> HEX(key_schema.get_shared_key()) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 9BAFB9E75CEEB013 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="keyring-function-reference">
</a>
General-Purpose Keyring Function Reference
</h5>
</div>
</div>
</div>
<p>
For each general-purpose keyring function, this section
describes its purpose, calling sequence, and return value. For
information about the conditions under which these functions
can be invoked, see
<a class="xref" href="keyring-functions-general-purpose.html#keyring-function-usage" title="Using General-Purpose Keyring Functions">
Using General-Purpose Keyring Functions
</a>
.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="function_keyring-key-fetch">
</a>
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-fetch">
<code class="literal">
keyring_key_fetch(
<em class="replaceable">
<code>
key_id
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045239530320">
</a>
<a class="indexterm" name="idm46045239529280">
</a>
<p>
Given a key ID, deobfuscates and returns the key value.
</p>
<p>
Arguments:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
key_id
</code>
</em>
: A string that
specifies the key ID.
</p>
</li>
</ul>
</div>
<p>
Return value:
</p>
<p>
Returns the key value as a string for success,
<code class="literal">
NULL
</code>
if the key does not exist, or
<code class="literal">
NULL
</code>
and an error for failure.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Key values retrieved using
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-fetch">
<code class="literal">
keyring_key_fetch()
</code>
</a>
are
subject to the general keyring function limits described
in
<a class="xref" href="keyring-key-types.html" title="8.4.4.10 Supported Keyring Key Types and Lengths">
Section 8.4.4.10, “Supported Keyring Key Types and Lengths”
</a>
. A key value
longer than that length can be stored using a keyring
service function (see
<a class="xref" href="keyring-service.html" title="7.6.9.2 The Keyring Service">
Section 7.6.9.2, “The Keyring Service”
</a>
), but if retrieved
using
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-fetch">
<code class="literal">
keyring_key_fetch()
</code>
</a>
is truncated to the general keyring function limit.
</p>
</div>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa44297031"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_generate<span class="token punctuation">(</span><span class="token string">'RSA_key'</span><span class="token punctuation">,</span> <span class="token string">'RSA'</span><span class="token punctuation">,</span> <span class="token number">16</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> keyring_key_generate('RSA_key', 'RSA', 16) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">HEX</span><span class="token punctuation">(</span>keyring_key_fetch<span class="token punctuation">(</span><span class="token string">'RSA_key'</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> HEX(keyring_key_fetch('RSA_key')) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 91C2253B696064D3556984B6630F891A <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_type_fetch<span class="token punctuation">(</span><span class="token string">'RSA_key'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> keyring_key_type_fetch('RSA_key') <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> RSA <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_length_fetch<span class="token punctuation">(</span><span class="token string">'RSA_key'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> keyring_key_length_fetch('RSA_key') <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 16 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
The example uses
<a class="link" href="string-functions.html#function_hex">
<code class="literal">
HEX()
</code>
</a>
to
display the key value because it may contain nonprintable
characters. The example also uses a short key for brevity,
but be aware that longer keys provide better security.
</p>
</li>
<li class="listitem">
<p>
<a name="function_keyring-key-generate">
</a>
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-generate">
<code class="literal">
keyring_key_generate(
<em class="replaceable">
<code>
key_id
</code>
</em>
,
<em class="replaceable">
<code>
key_type
</code>
</em>
,
<em class="replaceable">
<code>
key_length
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045239506288">
</a>
<a class="indexterm" name="idm46045239505248">
</a>
<p>
Generates a new random key with a given ID, type, and
length, and stores it in the keyring. The type and length
values must be consistent with the values supported by the
underlying keyring plugin. See
<a class="xref" href="keyring-key-types.html" title="8.4.4.10 Supported Keyring Key Types and Lengths">
Section 8.4.4.10, “Supported Keyring Key Types and Lengths”
</a>
.
</p>
<p>
Arguments:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
key_id
</code>
</em>
: A string that
specifies the key ID.
</p>
</li>
<li class="listitem">
<p>
<em class="replaceable">
<code>
key_type
</code>
</em>
: A string that
specifies the key type.
</p>
</li>
<li class="listitem">
<p>
<em class="replaceable">
<code>
key_length
</code>
</em>
: An integer that
specifies the key length in bytes.
</p>
</li>
</ul>
</div>
<p>
Return value:
</p>
<p>
Returns 1 for success, or
<code class="literal">
NULL
</code>
and an
error for failure.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa87216044"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_generate<span class="token punctuation">(</span><span class="token string">'RSA_key'</span><span class="token punctuation">,</span> <span class="token string">'RSA'</span><span class="token punctuation">,</span> <span class="token number">384</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> keyring_key_generate('RSA_key', 'RSA', 384) <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="function_keyring-key-length-fetch">
</a>
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-length-fetch">
<code class="literal">
keyring_key_length_fetch(
<em class="replaceable">
<code>
key_id
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045239490704">
</a>
<a class="indexterm" name="idm46045239489600">
</a>
<p>
Given a key ID, returns the key length.
</p>
<p>
Arguments:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
key_id
</code>
</em>
: A string that
specifies the key ID.
</p>
</li>
</ul>
</div>
<p>
Return value:
</p>
<p>
Returns the key length in bytes as an integer for success,
<code class="literal">
NULL
</code>
if the key does not exist, or
<code class="literal">
NULL
</code>
and an error for failure.
</p>
<p>
Example:
</p>
<p>
See the description of
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-fetch">
<code class="literal">
keyring_key_fetch()
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="function_keyring-key-remove">
</a>
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-remove">
<code class="literal">
keyring_key_remove(
<em class="replaceable">
<code>
key_id
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045239478032">
</a>
<a class="indexterm" name="idm46045239476992">
</a>
<p>
Removes the key with a given ID from the keyring.
</p>
<p>
Arguments:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
key_id
</code>
</em>
: A string that
specifies the key ID.
</p>
</li>
</ul>
</div>
<p>
Return value:
</p>
<p>
Returns 1 for success, or
<code class="literal">
NULL
</code>
for
failure.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa63484670"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_remove<span class="token punctuation">(</span><span class="token string">'AES_key'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> keyring_key_remove('AES_key') <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="function_keyring-key-store">
</a>
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-store">
<code class="literal">
keyring_key_store(
<em class="replaceable">
<code>
key_id
</code>
</em>
,
<em class="replaceable">
<code>
key_type
</code>
</em>
,
<em class="replaceable">
<code>
key
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045239465232">
</a>
<a class="indexterm" name="idm46045239464192">
</a>
<p>
Obfuscates and stores a key in the keyring.
</p>
<p>
Arguments:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
key_id
</code>
</em>
: A string that
specifies the key ID.
</p>
</li>
<li class="listitem">
<p>
<em class="replaceable">
<code>
key_type
</code>
</em>
: A string that
specifies the key type.
</p>
</li>
<li class="listitem">
<p>
<em class="replaceable">
<code>
key
</code>
</em>
: A string that
specifies the key value.
</p>
</li>
</ul>
</div>
<p>
Return value:
</p>
<p>
Returns 1 for success, or
<code class="literal">
NULL
</code>
and an
error for failure.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa80300116"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> keyring_key_store<span class="token punctuation">(</span><span class="token string">'new key'</span><span class="token punctuation">,</span> <span class="token string">'DSA'</span><span class="token punctuation">,</span> <span class="token string">'My key value'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> keyring_key_store('new key', 'DSA', 'My key value') <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
<li class="listitem">
<p>
<a name="function_keyring-key-type-fetch">
</a>
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-type-fetch">
<code class="literal">
keyring_key_type_fetch(
<em class="replaceable">
<code>
key_id
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045239450576">
</a>
<a class="indexterm" name="idm46045239449472">
</a>
<p>
Given a key ID, returns the key type.
</p>
<p>
Arguments:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
key_id
</code>
</em>
: A string that
specifies the key ID.
</p>
</li>
</ul>
</div>
<p>
Return value:
</p>
<p>
Returns the key type as a string for success,
<code class="literal">
NULL
</code>
if the key does not exist, or
<code class="literal">
NULL
</code>
and an error for failure.
</p>
<p>
Example:
</p>
<p>
See the description of
<a class="link" href="keyring-functions-general-purpose.html#function_keyring-key-fetch">
<code class="literal">
keyring_key_fetch()
</code>
</a>
.
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-ndb-cluster-tables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="performance-schema-ndb-cluster-tables">
</a>
29.12.12 Performance Schema NDB Cluster Tables
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="performance-schema-ndb-sync-pending-objects-table.html">
29.12.12.1 The ndb_sync_pending_objects Table
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="performance-schema-ndb-sync-excluded-objects-table.html">
29.12.12.2 The ndb_sync_excluded_objects Table
</a>
</span>
</dt>
</dl>
</div>
<p>
The following table shows all Performance Schema tables relating
to the
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
storage engine.
</p>
<div class="table">
<a name="idm46045070664224">
</a>
<p class="title">
<b>
Table 29.3 Performance Schema NDB Tables
</b>
</p>
<div class="table-contents">
<table frame="box" rules="all" summary="A reference that lists all Performance Schema tables relating to NDB Cluster.">
<colgroup>
<col style="width: 28%"/>
<col style="width: 71%"/>
</colgroup>
<thead>
<tr>
<th>
Table Name
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a class="link" href="performance-schema-ndb-sync-excluded-objects-table.html" title="29.12.12.2 The ndb_sync_excluded_objects Table">
<code class="literal">
ndb_sync_excluded_objects
</code>
</a>
</td>
<td>
NDB objects which cannot be synchronized
</td>
</tr>
<tr>
<td>
<a class="link" href="performance-schema-ndb-sync-pending-objects-table.html" title="29.12.12.1 The ndb_sync_pending_objects Table">
<code class="literal">
ndb_sync_pending_objects
</code>
</a>
</td>
<td>
NDB objects waiting for synchronization
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<p>
Automatic synchronization in
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
attempts to detect and synchronize automatically all mismatches
in metadata between the NDB Cluster's internal dictionary
and the MySQL Server's datadictionary. This is done by
default in the background at regular intervals as determined by
the
<a class="link" href="mysql-cluster-options-variables.html#sysvar_ndb_metadata_check_interval">
<code class="literal">
ndb_metadata_check_interval
</code>
</a>
system variable, unless disabled using
<a class="link" href="mysql-cluster-options-variables.html#sysvar_ndb_metadata_check">
<code class="literal">
ndb_metadata_check
</code>
</a>
or
overridden by setting
<a class="link" href="mysql-cluster-options-variables.html#sysvar_ndb_metadata_sync">
<code class="literal">
ndb_metadata_sync
</code>
</a>
.
</p>
<p>
Information about the current state of automatic synchronization
is exposed by a MySQL server acting as an SQL node in an NDB
Cluster in these two Performance Schema tables:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="performance-schema-ndb-sync-pending-objects-table.html" title="29.12.12.1 The ndb_sync_pending_objects Table">
<code class="literal">
ndb_sync_pending_objects
</code>
</a>
:
Displays information about
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
database objects for which mismatches have been detected
between the
<code class="literal">
NDB
</code>
dictionary and the MySQL
data dictionary. When attempting to synchronize such
objects,
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
removes the object
from the queue awaiting synchronization, and from this
table, and tries to reconcile the mismatch. If
synchronization of the object fails due to a temporary
error, it is picked up and added back to the queue (and to
this table) the next time
<code class="literal">
NDB
</code>
performs
mismatch detection; if the attempts fails due a permanent
error, the object is added to the
<a class="link" href="performance-schema-ndb-sync-excluded-objects-table.html" title="29.12.12.2 The ndb_sync_excluded_objects Table">
<code class="literal">
ndb_sync_excluded_objects
</code>
</a>
table.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-ndb-sync-excluded-objects-table.html" title="29.12.12.2 The ndb_sync_excluded_objects Table">
<code class="literal">
ndb_sync_excluded_objects
</code>
</a>
:
Shows information about
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
database objects for which automatic synchronization has
failed due to permanent errors resulting from mismatches
which cannot be reconciled without manual intervention;
these objects are blocklisted and not considered again for
mismatch detection until this has been done.
</p>
</li>
</ul>
</div>
<p>
The
<a class="link" href="performance-schema-ndb-sync-pending-objects-table.html" title="29.12.12.1 The ndb_sync_pending_objects Table">
<code class="literal">
ndb_sync_pending_objects
</code>
</a>
and
<a class="link" href="performance-schema-ndb-sync-excluded-objects-table.html" title="29.12.12.2 The ndb_sync_excluded_objects Table">
<code class="literal">
ndb_sync_excluded_objects
</code>
</a>
tables
are present only if MySQL has support enabled for the
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
storage engine.
</p>
<p>
These tables are described in more detail in the following two
sections.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/sys-schema-procedures.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="sys-schema-procedures">
</a>
30.4.4 sys Schema Stored Procedures
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="sys-create-synonym-db.html">
30.4.4.1 The create_synonym_db() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-diagnostics.html">
30.4.4.2 The diagnostics() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-execute-prepared-stmt.html">
30.4.4.3 The execute_prepared_stmt() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-disable-background-threads.html">
30.4.4.4 The ps_setup_disable_background_threads() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-disable-consumer.html">
30.4.4.5 The ps_setup_disable_consumer() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-disable-instrument.html">
30.4.4.6 The ps_setup_disable_instrument() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-disable-thread.html">
30.4.4.7 The ps_setup_disable_thread() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-enable-background-threads.html">
30.4.4.8 The ps_setup_enable_background_threads() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-enable-consumer.html">
30.4.4.9 The ps_setup_enable_consumer() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-enable-instrument.html">
30.4.4.10 The ps_setup_enable_instrument() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-enable-thread.html">
30.4.4.11 The ps_setup_enable_thread() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-reload-saved.html">
30.4.4.12 The ps_setup_reload_saved() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-reset-to-default.html">
30.4.4.13 The ps_setup_reset_to_default() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-save.html">
30.4.4.14 The ps_setup_save() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-show-disabled.html">
30.4.4.15 The ps_setup_show_disabled() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-show-disabled-consumers.html">
30.4.4.16 The ps_setup_show_disabled_consumers() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-show-disabled-instruments.html">
30.4.4.17 The ps_setup_show_disabled_instruments() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-show-enabled.html">
30.4.4.18 The ps_setup_show_enabled() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-show-enabled-consumers.html">
30.4.4.19 The ps_setup_show_enabled_consumers() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-setup-show-enabled-instruments.html">
30.4.4.20 The ps_setup_show_enabled_instruments() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-statement-avg-latency-histogram.html">
30.4.4.21 The ps_statement_avg_latency_histogram() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-trace-statement-digest.html">
30.4.4.22 The ps_trace_statement_digest() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-trace-thread.html">
30.4.4.23 The ps_trace_thread() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-ps-truncate-all-tables.html">
30.4.4.24 The ps_truncate_all_tables() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-statement-performance-analyzer.html">
30.4.4.25 The statement_performance_analyzer() Procedure
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="sys-table-exists.html">
30.4.4.26 The table_exists() Procedure
</a>
</span>
</dt>
</dl>
</div>
<p>
The following sections describe
<a class="link" href="sys-schema.html" title="Chapter 30 MySQL sys Schema">
<code class="literal">
sys
</code>
</a>
schema stored procedures.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-replication-options.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="group-replication-options">
</a>
20.9 Group Replication Variables
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="group-replication-system-variables.html">
20.9.1 Group Replication System Variables
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="group-replication-status-variables.html">
20.9.2 Group Replication Status Variables
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045131518720">
</a>
<a class="indexterm" name="idm46045131517232">
</a>
<p>
The next two sections contain information about MySQL server system
and server status variables which are specific to the Group
Replication plugin.
</p>
<div class="table">
<a name="idm46045131515184">
</a>
<p class="title">
<b>
Table 20.4 Group Replication Variable and Option Summary
</b>
</p>
<div class="table-contents">
<table frame="box" rules="all" summary="Reference for MySQL Group Replication command-line options, system variables, and status variables.">
<colgroup>
<col style="width: 20%"/>
<col style="width: 15%"/>
<col style="width: 15%"/>
<col style="width: 15%"/>
<col style="width: 15%"/>
<col style="width: 15%"/>
<col style="width: 15%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Name
</th>
<th scope="col">
Cmd-Line
</th>
<th scope="col">
Option File
</th>
<th scope="col">
System Var
</th>
<th scope="col">
Status Var
</th>
<th scope="col">
Var Scope
</th>
<th scope="col">
Dynamic
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_all_consensus_proposals_count">
Gr_all_consensus_proposals_count
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_all_consensus_time_sum">
Gr_all_consensus_time_sum
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_certification_garbage_collector_count">
Gr_certification_garbage_collector_count
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_certification_garbage_collector_time_sum">
Gr_certification_garbage_collector_time_sum
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_consensus_bytes_received_sum">
Gr_consensus_bytes_received_sum
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_consensus_bytes_sent_sum">
Gr_consensus_bytes_sent_sum
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_control_messages_sent_bytes_sum">
Gr_control_messages_sent_bytes_sum
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_control_messages_sent_count">
Gr_control_messages_sent_count
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_control_messages_sent_roundtrip_time_sum">
Gr_control_messages_sent_roundtrip_time_sum
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_data_messages_sent_bytes_sum">
Gr_data_messages_sent_bytes_sum
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_data_messages_sent_count">
Gr_data_messages_sent_count
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_data_messages_sent_roundtrip_time_sum">
Gr_data_messages_sent_roundtrip_time_sum
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_empty_consensus_proposals_count">
Gr_empty_consensus_proposals_count
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_extended_consensus_count">
Gr_extended_consensus_count
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
Gr_flow_control_throttle_active_count
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Global
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
Gr_flow_control_throttle_count
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Global
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
Gr_flow_control_throttle_last_throttle_timestamp
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Global
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
Gr_flow_control_throttle_time_sum
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Global
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_last_consensus_end_timestamp">
Gr_last_consensus_end_timestamp
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_total_messages_sent_count">
Gr_total_messages_sent_count
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_transactions_consistency_after_sync_count">
Gr_transactions_consistency_after_sync_count
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_transactions_consistency_after_sync_time_sum">
Gr_transactions_consistency_after_sync_time_sum
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_transactions_consistency_after_termination_count">
Gr_transactions_consistency_after_termination_count
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_transactions_consistency_after_termination_time_sum">
Gr_transactions_consistency_after_termination_time_sum
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_transactions_consistency_before_begin_count">
Gr_transactions_consistency_before_begin_count
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-status-variables.html#statvar_Gr_transactions_consistency_before_begin_time_sum">
Gr_transactions_consistency_before_begin_time_sum
</a>
</th>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
Both
</td>
<td>
No
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_advertise_recovery_endpoints">
group_replication_advertise_recovery_endpoints
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_allow_local_lower_version_join">
group_replication_allow_local_lower_version_join
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_auto_increment_increment">
group_replication_auto_increment_increment
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_autorejoin_tries">
group_replication_autorejoin_tries
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_bootstrap_group">
group_replication_bootstrap_group
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_clone_threshold">
group_replication_clone_threshold
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_communication_debug_options">
group_replication_communication_debug_options
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_communication_max_message_size">
group_replication_communication_max_message_size
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_communication_stack">
group_replication_communication_stack
</a>
</th>
<td>
</td>
<td>
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_components_stop_timeout">
group_replication_components_stop_timeout
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_compression_threshold">
group_replication_compression_threshold
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_consistency">
group_replication_consistency
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Both
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_enforce_update_everywhere_checks">
group_replication_enforce_update_everywhere_checks
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_exit_state_action">
group_replication_exit_state_action
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_flow_control_applier_threshold">
group_replication_flow_control_applier_threshold
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_flow_control_certifier_threshold">
group_replication_flow_control_certifier_threshold
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_flow_control_hold_percent">
group_replication_flow_control_hold_percent
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_flow_control_max_quota">
group_replication_flow_control_max_quota
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_flow_control_member_quota_percent">
group_replication_flow_control_member_quota_percent
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_flow_control_min_quota">
group_replication_flow_control_min_quota
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_flow_control_min_recovery_quota">
group_replication_flow_control_min_recovery_quota
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_flow_control_mode">
group_replication_flow_control_mode
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_flow_control_period">
group_replication_flow_control_period
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_flow_control_release_percent">
group_replication_flow_control_release_percent
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_force_members">
group_replication_force_members
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_group_name">
group_replication_group_name
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_group_seeds">
group_replication_group_seeds
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_gtid_assignment_block_size">
group_replication_gtid_assignment_block_size
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_ip_allowlist">
group_replication_ip_allowlist
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_local_address">
group_replication_local_address
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_member_expel_timeout">
group_replication_member_expel_timeout
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_member_weight">
group_replication_member_weight
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_message_cache_size">
group_replication_message_cache_size
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_paxos_single_leader">
group_replication_paxos_single_leader
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_poll_spin_loops">
group_replication_poll_spin_loops
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_preemptive_garbage_collection">
group_replication_preemptive_garbage_collection
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_preemptive_garbage_collection_rows_threshold">
group_replication_preemptive_garbage_collection_rows_threshold
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_get_public_key">
group_replication_recovery_get_public_key
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_public_key_path">
group_replication_recovery_public_key_path
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_reconnect_interval">
group_replication_recovery_reconnect_interval
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_retry_count">
group_replication_recovery_retry_count
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_ca">
group_replication_recovery_ssl_ca
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_capath">
group_replication_recovery_ssl_capath
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_cert">
group_replication_recovery_ssl_cert
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_cipher">
group_replication_recovery_ssl_cipher
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_crl">
group_replication_recovery_ssl_crl
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_crlpath">
group_replication_recovery_ssl_crlpath
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_key">
group_replication_recovery_ssl_key
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_ssl_verify_server_cert">
group_replication_recovery_ssl_verify_server_cert
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_tls_ciphersuites">
group_replication_recovery_tls_ciphersuites
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_tls_version">
group_replication_recovery_tls_version
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_recovery_use_ssl">
group_replication_recovery_use_ssl
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_single_primary_mode">
group_replication_single_primary_mode
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_ssl_mode">
group_replication_ssl_mode
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_start_on_boot">
group_replication_start_on_boot
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_transaction_size_limit">
group_replication_transaction_size_limit
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_unreachable_majority_timeout">
group_replication_unreachable_majority_timeout
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
<tr>
<th scope="row">
<a class="link" href="group-replication-system-variables.html#sysvar_group_replication_view_change_uuid">
group_replication_view_change_uuid
</a>
</th>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
Yes
</td>
<td>
</td>
<td>
Global
</td>
<td>
Yes
</td>
</tr>
</tbody>
</table>
</div>
<div class="table-contents">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 801px;">
<thead>
<tr>
<th scope="col" style="width: 472.031px;">
Name
</th>
<th scope="col" style="width: 43.6875px;">
Cmd-Line
</th>
<th scope="col" style="width: 56.0938px;">
Option File
</th>
<th scope="col" style="width: 58.6406px;">
System Var
</th>
<th scope="col" style="width: 52.2812px;">
Status Var
</th>
<th scope="col" style="width: 48.4375px;">
Var Scope
</th>
<th scope="col" style="width: 69.2969px;">
Dynamic
</th>
</tr>
</thead>
</table>
</div>
</div>
<br class="table-break"/>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-timing.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="performance-schema-timing">
</a>
29.4.1 Performance Schema Event Timing
</h3>
</div>
</div>
</div>
<p>
Events are collected by means of instrumentation added to the
server source code. Instruments time events, which is how the
Performance Schema provides an idea of how long events take. It
is also possible to configure instruments not to collect timing
information. This section discusses the available timers and
their characteristics, and how timing values are represented in
events.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="performance-schema-timers">
</a>
Performance Schema Timers
</h4>
</div>
</div>
</div>
<p>
Performance Schema timers vary in precision and amount of
overhead. To see what timers are available and their
characteristics, check the
<a class="link" href="performance-schema-performance-timers-table.html" title="29.12.22.6 The performance_timers Table">
<code class="literal">
performance_timers
</code>
</a>
table:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa99594257"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>performance_timers<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> TIMER_NAME <span class="token punctuation">|</span> TIMER_FREQUENCY <span class="token punctuation">|</span> TIMER_RESOLUTION <span class="token punctuation">|</span> TIMER_OVERHEAD <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> CYCLE <span class="token punctuation">|</span> 2389029850 <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 72 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> NANOSECOND <span class="token punctuation">|</span> 1000000000 <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 112 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> MICROSECOND <span class="token punctuation">|</span> 1000000 <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 136 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> MILLISECOND <span class="token punctuation">|</span> 1036 <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 168 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> THREAD_CPU <span class="token punctuation">|</span> 339101694 <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 798 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
If the values associated with a given timer name are
<code class="literal">
NULL
</code>
, that timer is not supported on your
platform.
</p>
<p>
The columns have these meanings:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The
<code class="literal">
TIMER_NAME
</code>
column shows the names
of the available timers.
<code class="literal">
CYCLE
</code>
refers
to the timer that is based on the CPU (processor) cycle
counter.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIMER_FREQUENCY
</code>
indicates the number of
timer units per second. For a cycle timer, the frequency
is generally related to the CPU speed. The value shown was
obtained on a system with a 2.4GHz processor. The other
timers are based on fixed fractions of seconds.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIMER_RESOLUTION
</code>
indicates the number
of timer units by which timer values increase at a time.
If a timer has a resolution of 10, its value increases by
10 each time.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIMER_OVERHEAD
</code>
is the minimal number of
cycles of overhead to obtain one timing with the given
timer. The overhead per event is twice the value displayed
because the timer is invoked at the beginning and end of
the event.
</p>
</li>
</ul>
</div>
<p>
The Performance Schema assigns timers as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The wait timer uses
<code class="literal">
CYCLE
</code>
.
</p>
</li>
<li class="listitem">
<p>
The idle, stage, statement, and transaction timers use
<code class="literal">
NANOSECOND
</code>
on platforms where the
<code class="literal">
NANOSECOND
</code>
timer is available,
<code class="literal">
MICROSECOND
</code>
otherwise.
</p>
</li>
</ul>
</div>
<p>
At server startup, the Performance Schema verifies that
assumptions made at build time about timer assignments are
correct, and displays a warning if a timer is not available.
</p>
<p>
To time wait events, the most important criterion is to reduce
overhead, at the possible expense of the timer accuracy, so
using the
<code class="literal">
CYCLE
</code>
timer is the best.
</p>
<p>
The time a statement (or stage) takes to execute is in general
orders of magnitude larger than the time it takes to execute a
single wait. To time statements, the most important criterion
is to have an accurate measure, which is not affected by
changes in processor frequency, so using a timer which is not
based on cycles is the best. The default timer for statements
is
<code class="literal">
NANOSECOND
</code>
. The extra
<span class="quote">
“
<span class="quote">
overhead
</span>
”
</span>
compared to the
<code class="literal">
CYCLE
</code>
timer is not significant, because the
overhead caused by calling a timer twice (once when the
statement starts, once when it ends) is orders of magnitude
less compared to the CPU time used to execute the statement
itself. Using the
<code class="literal">
CYCLE
</code>
timer has no
benefit here, only drawbacks.
</p>
<p>
The precision offered by the cycle counter depends on
processor speed. If the processor runs at 1 GHz (one billion
cycles/second) or higher, the cycle counter delivers
sub-nanosecond precision. Using the cycle counter is much
cheaper than getting the actual time of day. For example, the
standard
<code class="literal">
gettimeofday()
</code>
function can take
hundreds of cycles, which is an unacceptable overhead for data
gathering that may occur thousands or millions of times per
second.
</p>
<p>
Cycle counters also have disadvantages:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
End users expect to see timings in wall-clock units, such
as fractions of a second. Converting from cycles to
fractions of seconds can be expensive. For this reason,
the conversion is a quick and fairly rough multiplication
operation.
</p>
</li>
<li class="listitem">
<p>
Processor cycle rate might change, such as when a laptop
goes into power-saving mode or when a CPU slows down to
reduce heat generation. If a processor's cycle rate
fluctuates, conversion from cycles to real-time units is
subject to error.
</p>
</li>
<li class="listitem">
<p>
Cycle counters might be unreliable or unavailable
depending on the processor or the operating system. For
example, on Pentiums, the instruction is
<code class="literal">
RDTSC
</code>
(an assembly-language rather than
a C instruction) and it is theoretically possible for the
operating system to prevent user-mode programs from using
it.
</p>
</li>
<li class="listitem">
<p>
Some processor details related to out-of-order execution
or multiprocessor synchronization might cause the counter
to seem fast or slow by up to 1000 cycles.
</p>
</li>
</ul>
</div>
<p>
MySQL works with cycle counters on x386 (Windows, macOS,
Linux, Solaris, and other Unix flavors), PowerPC, and IA-64.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h4 class="title">
<a name="performance-schema-timing-in-events">
</a>
Performance Schema Timer Representation in Events
</h4>
</div>
</div>
</div>
<p>
Rows in Performance Schema tables that store current events
and historical events have three columns to represent timing
information:
<code class="literal">
TIMER_START
</code>
and
<code class="literal">
TIMER_END
</code>
indicate when an event started
and finished, and
<code class="literal">
TIMER_WAIT
</code>
indicates
event duration.
</p>
<p>
The
<a class="link" href="performance-schema-setup-instruments-table.html" title="29.12.2.3 The setup_instruments Table">
<code class="literal">
setup_instruments
</code>
</a>
table has
an
<code class="literal">
ENABLED
</code>
column to indicate the
instruments for which to collect events. The table also has a
<code class="literal">
TIMED
</code>
column to indicate which instruments
are timed. If an instrument is not enabled, it produces no
events. If an enabled instrument is not timed, events produced
by the instrument have
<code class="literal">
NULL
</code>
for the
<code class="literal">
TIMER_START
</code>
,
<code class="literal">
TIMER_END
</code>
,
and
<code class="literal">
TIMER_WAIT
</code>
timer values. This in turn
causes those values to be ignored when calculating aggregate
time values in summary tables (sum, minimum, maximum, and
average).
</p>
<p>
Internally, times within events are stored in units given by
the timer in effect when event timing begins. For display when
events are retrieved from Performance Schema tables, times are
shown in picoseconds (trillionths of a second) to normalize
them to a standard unit, regardless of which timer is
selected.
</p>
<p>
The timer baseline (
<span class="quote">
“
<span class="quote">
time zero
</span>
”
</span>
) occurs at
Performance Schema initialization during server startup.
<code class="literal">
TIMER_START
</code>
and
<code class="literal">
TIMER_END
</code>
values in events represent
picoseconds since the baseline.
<code class="literal">
TIMER_WAIT
</code>
values are durations in picoseconds.
</p>
<p>
Picosecond values in events are approximate. Their accuracy is
subject to the usual forms of error associated with conversion
from one unit to another. If the
<code class="literal">
CYCLE
</code>
timer is used and the processor rate varies, there might be
drift. For these reasons, it is not reasonable to look at the
<code class="literal">
TIMER_START
</code>
value for an event as an
accurate measure of time elapsed since server startup. On the
other hand, it is reasonable to use
<code class="literal">
TIMER_START
</code>
or
<code class="literal">
TIMER_WAIT
</code>
values in
<code class="literal">
ORDER
BY
</code>
clauses to order events by start time or
duration.
</p>
<p>
The choice of picoseconds in events rather than a value such
as microseconds has a performance basis. One implementation
goal was to show results in a uniform time unit, regardless of
the timer. In an ideal world this time unit would look like a
wall-clock unit and be reasonably precise; in other words,
microseconds. But to convert cycles or nanoseconds to
microseconds, it would be necessary to perform a division for
every instrumentation. Division is expensive on many
platforms. Multiplication is not expensive, so that is what is
used. Therefore, the time unit is an integer multiple of the
highest possible
<code class="literal">
TIMER_FREQUENCY
</code>
value,
using a multiplier large enough to ensure that there is no
major precision loss. The result is that the time unit is
<span class="quote">
“
<span class="quote">
picoseconds.
</span>
”
</span>
This precision is spurious, but
the decision enables overhead to be minimized.
</p>
<p>
While a wait, stage, statement, or transaction event is
executing, the respective current-event tables display
current-event timing information:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa65160026"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">events_waits_current
events_stages_current
events_statements_current
events_transactions_current</code></pre>
</div>
<p>
To make it possible to determine how long a not-yet-completed
event has been running, the timer columns are set as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
TIMER_START
</code>
is populated.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIMER_END
</code>
is populated with the current
timer value.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TIMER_WAIT
</code>
is populated with the time
elapsed so far (
<code class="literal">
TIMER_END
</code>
−
<code class="literal">
TIMER_START
</code>
).
</p>
</li>
</ul>
</div>
<p>
Events that have not yet completed have an
<code class="literal">
END_EVENT_ID
</code>
value of
<code class="literal">
NULL
</code>
. To assess time elapsed so far for an
event, use the
<code class="literal">
TIMER_WAIT
</code>
column.
Therefore, to identify events that have not yet completed and
have taken longer than
<em class="replaceable">
<code>
N
</code>
</em>
picoseconds thus far, monitoring applications can use this
expression in queries:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa49503662"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">WHERE</span> END_EVENT_ID <span class="token operator">IS</span> <span class="token boolean">NULL</span> <span class="token operator">AND</span> TIMER_WAIT <span class="token operator">></span> <em class="replaceable">N</em></code></pre>
</div>
<p>
Event identification as just described assumes that the
corresponding instruments have
<code class="literal">
ENABLED
</code>
and
<code class="literal">
TIMED
</code>
set to
<code class="literal">
YES
</code>
and
that the relevant consumers are enabled.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/cursors.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="cursors">
</a>
15.6.6 Cursors
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="close.html">
15.6.6.1 Cursor CLOSE Statement
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="declare-cursor.html">
15.6.6.2 Cursor DECLARE Statement
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="fetch.html">
15.6.6.3 Cursor FETCH Statement
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="open.html">
15.6.6.4 Cursor OPEN Statement
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="cursor-restrictions.html">
15.6.6.5 Restrictions on Server-Side Cursors
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045176169264">
</a>
<p>
MySQL supports cursors inside stored programs. The syntax is as in
embedded SQL. Cursors have these properties:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Asensitive: The server may or may not make a copy of its
result table
</p>
</li>
<li class="listitem">
<p>
Read only: Not updatable
</p>
</li>
<li class="listitem">
<p>
Nonscrollable: Can be traversed only in one direction and
cannot skip rows
</p>
</li>
</ul>
</div>
<p>
Cursor declarations must appear before handler declarations and
after variable and condition declarations.
</p>
<p>
Example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa28874666"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">PROCEDURE</span> curdemo<span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token keyword">BEGIN</span>
<span class="token keyword">DECLARE</span> done <span class="token datatype">INT</span> <span class="token keyword">DEFAULT</span> <span class="token boolean">FALSE</span><span class="token punctuation">;</span>
<span class="token keyword">DECLARE</span> a <span class="token datatype">CHAR</span><span class="token punctuation">(</span><span class="token number">16</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">DECLARE</span> b<span class="token punctuation">,</span> c <span class="token datatype">INT</span><span class="token punctuation">;</span>
<span class="token keyword">DECLARE</span> cur1 <span class="token keyword">CURSOR</span> <span class="token keyword">FOR</span> <span class="token keyword">SELECT</span> id<span class="token punctuation">,</span><span class="token keyword">data</span> <span class="token keyword">FROM</span> test<span class="token punctuation">.</span>t1<span class="token punctuation">;</span>
<span class="token keyword">DECLARE</span> cur2 <span class="token keyword">CURSOR</span> <span class="token keyword">FOR</span> <span class="token keyword">SELECT</span> i <span class="token keyword">FROM</span> test<span class="token punctuation">.</span>t2<span class="token punctuation">;</span>
<span class="token keyword">DECLARE</span> <span class="token keyword">CONTINUE</span> <span class="token keyword">HANDLER</span> <span class="token keyword">FOR</span> <span class="token operator">NOT</span> <span class="token keyword">FOUND</span> <span class="token keyword">SET</span> done <span class="token operator">=</span> <span class="token boolean">TRUE</span><span class="token punctuation">;</span>
<span class="token keyword">OPEN</span> cur1<span class="token punctuation">;</span>
<span class="token keyword">OPEN</span> cur2<span class="token punctuation">;</span>
read_loop: <span class="token keyword">LOOP</span>
<span class="token keyword">FETCH</span> cur1 <span class="token keyword">INTO</span> a<span class="token punctuation">,</span> b<span class="token punctuation">;</span>
<span class="token keyword">FETCH</span> cur2 <span class="token keyword">INTO</span> c<span class="token punctuation">;</span>
<span class="token keyword">IF</span> done <span class="token keyword">THEN</span>
<span class="token keyword">LEAVE</span> read_loop<span class="token punctuation">;</span>
<span class="token keyword">END</span> <span class="token keyword">IF</span><span class="token punctuation">;</span>
<span class="token keyword">IF</span> b <span class="token operator"><</span> c <span class="token keyword">THEN</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> test<span class="token punctuation">.</span>t3 <span class="token keyword">VALUES</span> <span class="token punctuation">(</span>a<span class="token punctuation">,</span>b<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">ELSE</span>
<span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> test<span class="token punctuation">.</span>t3 <span class="token keyword">VALUES</span> <span class="token punctuation">(</span>a<span class="token punctuation">,</span>c<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">END</span> <span class="token keyword">IF</span><span class="token punctuation">;</span>
<span class="token keyword">END</span> <span class="token keyword">LOOP</span><span class="token punctuation">;</span>
<span class="token keyword">CLOSE</span> cur1<span class="token punctuation">;</span>
<span class="token keyword">CLOSE</span> cur2<span class="token punctuation">;</span>
<span class="token keyword">END</span><span class="token punctuation">;</span></code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/ipv6-remote-connections.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="ipv6-remote-connections">
</a>
7.1.13.4 Connecting Using IPv6 Nonlocal Host Addresses
</h4>
</div>
</div>
</div>
<p>
The following procedure shows how to configure MySQL to permit
IPv6 connections by remote clients. It is similar to the
preceding procedure for local clients, but the server and client
hosts are distinct and each has its own nonlocal IPv6 address.
The example uses these addresses:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-simple"><div class="docs-select-all right" id="sa38464542"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">Server host<span class="token operator">:</span> 2001<span class="token operator">:</span>db8<span class="token operator">:</span>0<span class="token operator">:</span>f101<span class="token operator">:</span><span class="token operator">:</span>1
Client host<span class="token operator">:</span> 2001<span class="token operator">:</span>db8<span class="token operator">:</span>0<span class="token operator">:</span>f101<span class="token operator">:</span><span class="token operator">:</span>2</code></pre>
</div>
<p>
These addresses are chosen from the nonroutable address range
recommended by
<a class="ulink" href="http://www.iana.org/assignments/ipv6-unicast-address-assignments/ipv6-unicast-address-assignments.xml" target="_blank">
IANA
</a>
for documentation purposes and suffice for testing on your local
network. To accept IPv6 connections from clients outside the
local network, the server host must have a public address. If
your network provider assigns you an IPv6 address, you can use
that. Otherwise, another way to obtain an address is to use an
IPv6 broker; see
<a class="xref" href="ipv6-brokers.html" title="7.1.13.5 Obtaining an IPv6 Address from a Broker">
Section 7.1.13.5, “Obtaining an IPv6 Address from a Broker”
</a>
.
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Start the MySQL server with an appropriate
<a class="link" href="server-system-variables.html#sysvar_bind_address">
<code class="literal">
bind_address
</code>
</a>
setting to
permit it to accept IPv6 connections. For example, put the
following lines in the server option file and restart the
server:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa10941869"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">bind_address</span> <span class="token attr-value"><span class="token punctuation">=</span> *</span></code></pre>
</div>
<p>
Specifying * (or
<code class="literal">
::
</code>
) as the value for
<a class="link" href="server-system-variables.html#sysvar_bind_address">
<code class="literal">
bind_address
</code>
</a>
permits both
IPv4 and IPv6 connections on all server host IPv4 and IPv6
interfaces. If you want to bind the server to a specific
list of addresses, you can do this by specifying a
comma-separated list of values for
<a class="link" href="server-system-variables.html#sysvar_bind_address">
<code class="literal">
bind_address
</code>
</a>
. This example
specifies an IPv4 address as well as the required server
host IPv6 address:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa69210539"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">bind_address</span> <span class="token attr-value"><span class="token punctuation">=</span> 198.51.100.20,2001:db8:0:f101::1</span></code></pre>
</div>
<p>
For more information, see the
<a class="link" href="server-system-variables.html#sysvar_bind_address">
<code class="literal">
bind_address
</code>
</a>
description in
<a class="xref" href="server-system-variables.html" title="7.1.8 Server System Variables">
Section 7.1.8, “Server System Variables”
</a>
.
</p>
</li>
<li class="listitem">
<p>
On the server host (
<code class="literal">
2001:db8:0:f101::1
</code>
),
create an account for a user who can connect from the client
host (
<code class="literal">
2001:db8:0:f101::2
</code>
):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa11188695"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">USER</span> <span class="token string">'remoteipv6user'</span>@<span class="token string">'2001:db8:0:f101::2'</span> <span class="token keyword">IDENTIFIED</span> <span class="token keyword">BY</span> <span class="token string">'remoteipv6pass'</span><span class="token punctuation">;</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
On the client host (
<code class="literal">
2001:db8:0:f101::2
</code>
),
invoke the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client to connect to the
server using the new account:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa33139312"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mysql</span> <span class="token property">-h</span> 2001<span class="token punctuation">:</span>db8<span class="token punctuation">:</span>0<span class="token punctuation">:</span>f101<span class="token punctuation">:</span><span class="token punctuation">:</span>1 <span class="token property">-u</span> remoteipv6user <span class="token property">-premoteipv6pass</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
Try some simple statements that show connection information:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa85907443"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">STATUS</span>
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token keyword">Connection</span>: <span class="token number">2001</span>:db8:<span class="token number">0</span>:f101::<span class="token number">1</span> via TCP<span class="token operator">/</span>IP
<span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">CURRENT_USER</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token variable">@@bind_address</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> CURRENT_USER() <span class="token punctuation">|</span> @@bind_address <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> remoteipv6user@2001:db8:0:f101::2 <span class="token punctuation">|</span> :: <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
</ol>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-install-configuration.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-cluster-install-configuration">
</a>
25.3.3 Initial Configuration of NDB Cluster
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045122266784">
</a>
<a class="indexterm" name="idm46045122265296">
</a>
<a class="indexterm" name="idm46045122263808">
</a>
<p>
In this section, we discuss manual configuration of an installed
NDB Cluster by creating and editing configuration files.
</p>
<p>
For our four-node, four-host NDB Cluster (see
<a class="xref" href="mysql-cluster-installation.html#mysql-cluster-install-nodes-hosts" title="Cluster nodes and host computers">
Cluster nodes and host computers
</a>
), it is
necessary to write four configuration files, one per node host.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Each data node or SQL node requires a
<code class="filename">
my.cnf
</code>
file that provides two pieces of
information: a
<span class="firstterm">
connection
string
</span>
that tells the node where to find the
management node, and a line telling the MySQL server on this
host (the machine hosting the data node) to enable the
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
storage engine.
</p>
<p>
For more information on connection strings, see
<a class="xref" href="mysql-cluster-connection-strings.html" title="25.4.3.3 NDB Cluster Connection Strings">
Section 25.4.3.3, “NDB Cluster Connection Strings”
</a>
.
</p>
</li>
<li class="listitem">
<p>
The management node needs a
<code class="filename">
config.ini
</code>
file telling it how many fragment replicas to maintain, how
much memory to allocate for data and indexes on each data
node, where to find the data nodes, where to save data to disk
on each data node, and where to find any SQL nodes.
</p>
</li>
</ul>
</div>
<p>
<b>
Configuring the data nodes and SQL nodes.
</b>
The
<code class="filename">
my.cnf
</code>
file needed for the data nodes
is fairly simple. The configuration file should be located in
the
<code class="filename">
/etc
</code>
directory and can be edited using
any text editor. (Create the file if it does not exist.) For
example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa70025660"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">vi</span> /etc/my<span class="token punctuation">.</span>cnf</code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
We show
<span class="command">
<strong>
vi
</strong>
</span>
being used here to create the
file, but any text editor should work just as well.
</p>
</div>
<p>
For each data node and SQL node in our example setup,
<code class="filename">
my.cnf
</code>
should look like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa20040471"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token comment" spellcheck="true"># Options for mysqld process:</span>
ndbcluster <span class="token comment" spellcheck="true"># run NDB storage engine</span>
<span class="token selector">[mysql_cluster]</span>
<span class="token comment" spellcheck="true"># Options for NDB Cluster processes:</span>
<span class="token constant">ndb-connectstring</span><span class="token attr-value"><span class="token punctuation">=</span>198.51.100.10 </span><span class="token comment" spellcheck="true"># location of management server</span></code></pre>
</div>
<p>
After entering the preceding information, save this file and exit
the text editor. Do this for the machines hosting data node
<span class="quote">
“
<span class="quote">
A
</span>
”
</span>
, data node
<span class="quote">
“
<span class="quote">
B
</span>
”
</span>
, and the SQL node.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
Once you have started a
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
process with
the
<code class="literal">
ndbcluster
</code>
and
<code class="literal">
ndb-connectstring
</code>
parameters in the
<code class="literal">
[mysqld]
</code>
and
<code class="literal">
[mysql_cluster]
</code>
sections of the
<code class="filename">
my.cnf
</code>
file as shown previously, you cannot
execute any
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
or
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
statements without
having actually started the cluster. Otherwise, these statements
fail with an error. This is by design.
</p>
</div>
<p>
<b>
Configuring the management node.
</b>
The first step in configuring the management node is to create
the directory in which the configuration file can be found and
then to create the file itself. For example (running as
<code class="literal">
root
</code>
):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa82663910"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">mkdir</span> /var/lib/mysql-cluster
<span class="token prompt">$> </span><span class="token command">cd</span> /var/lib/mysql-cluster
<span class="token prompt">$> </span><span class="token command">vi</span> config<span class="token punctuation">.</span>ini</code></pre>
</div>
<p>
For our representative setup, the
<code class="filename">
config.ini
</code>
file should read as follows:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa9860218"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[ndbd default]</span>
<span class="token comment" spellcheck="true"># Options affecting ndbd processes on all data nodes:</span>
<span class="token constant">NoOfReplicas</span><span class="token attr-value"><span class="token punctuation">=</span>2 </span><span class="token comment" spellcheck="true"># Number of fragment replicas</span>
<span class="token constant">DataMemory</span><span class="token attr-value"><span class="token punctuation">=</span>98M </span><span class="token comment" spellcheck="true"># How much memory to allocate for data storage</span>
<span class="token selector">[ndb_mgmd]</span>
<span class="token comment" spellcheck="true"># Management process options:</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span>198.51.100.10 </span><span class="token comment" spellcheck="true"># Hostname or IP address of management node</span>
<span class="token constant">DataDir</span><span class="token attr-value"><span class="token punctuation">=</span>/var/lib/mysql-cluster </span><span class="token comment" spellcheck="true"># Directory for management node log files</span>
<span class="token selector">[ndbd]</span>
<span class="token comment" spellcheck="true"># Options for data node "A":</span>
<span class="token comment" spellcheck="true"> # (one [ndbd] section per data node)</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span>198.51.100.30 </span><span class="token comment" spellcheck="true"># Hostname or IP address</span>
<span class="token constant">NodeId</span><span class="token attr-value"><span class="token punctuation">=</span>2 </span><span class="token comment" spellcheck="true"># Node ID for this data node</span>
<span class="token constant">DataDir</span><span class="token attr-value"><span class="token punctuation">=</span>/usr/local/mysql/data </span><span class="token comment" spellcheck="true"># Directory for this data node's data files</span>
<span class="token selector">[ndbd]</span>
<span class="token comment" spellcheck="true"># Options for data node "B":</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span>198.51.100.40 </span><span class="token comment" spellcheck="true"># Hostname or IP address</span>
<span class="token constant">NodeId</span><span class="token attr-value"><span class="token punctuation">=</span>3 </span><span class="token comment" spellcheck="true"># Node ID for this data node</span>
<span class="token constant">DataDir</span><span class="token attr-value"><span class="token punctuation">=</span>/usr/local/mysql/data </span><span class="token comment" spellcheck="true"># Directory for this data node's data files</span>
<span class="token selector">[mysqld]</span>
<span class="token comment" spellcheck="true"># SQL node options:</span>
<span class="token constant">HostName</span><span class="token attr-value"><span class="token punctuation">=</span>198.51.100.20 </span><span class="token comment" spellcheck="true"># Hostname or IP address</span>
<span class="token comment" spellcheck="true"> # (additional mysqld connections can be</span>
<span class="token comment" spellcheck="true"> # specified for this node for various</span>
<span class="token comment" spellcheck="true"> # purposes such as running ndb_restore)</span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The
<code class="literal">
world
</code>
database can be downloaded from
<a class="ulink" href="/doc/index-other.html" target="_top">
https://dev.mysql.com/doc/index-other.html
</a>
.
</p>
</div>
<p>
After all the configuration files have been created and these
minimal options have been specified, you are ready to proceed with
starting the cluster and verifying that all processes are running.
We discuss how this is done in
<a class="xref" href="mysql-cluster-install-first-start.html" title="25.3.4 Initial Startup of NDB Cluster">
Section 25.3.4, “Initial Startup of NDB Cluster”
</a>
.
</p>
<p>
For more detailed information about the available NDB Cluster
configuration parameters and their uses, see
<a class="xref" href="mysql-cluster-config-file.html" title="25.4.3 NDB Cluster Configuration Files">
Section 25.4.3, “NDB Cluster Configuration Files”
</a>
, and
<a class="xref" href="mysql-cluster-configuration.html" title="25.4 Configuration of NDB Cluster">
Section 25.4, “Configuration of NDB Cluster”
</a>
. For configuration
of NDB Cluster as relates to making backups, see
<a class="xref" href="mysql-cluster-backup-configuration.html" title="25.6.8.3 Configuration for NDB Cluster Backups">
Section 25.6.8.3, “Configuration for NDB Cluster Backups”
</a>
.
</p>
<p>
The default port for Cluster management nodes is 1186. For data
nodes, the cluster can automatically allocate ports from those
that are already free.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/traceable-statements.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="traceable-statements">
</a>
10.15.3 Traceable Statements
</h3>
</div>
</div>
</div>
<p>
Statements which are traceable are listed here:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="replace.html" title="15.2.12 REPLACE Statement">
<code class="literal">
REPLACE
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
with any of the
preceding statements
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="set-statement.html" title="15.7.6 SET Statements">
<code class="literal">
SET
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="do.html" title="15.2.3 DO Statement">
<code class="literal">
DO
</code>
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="declare.html" title="15.6.3 DECLARE Statement">
<code class="literal">
DECLARE
</code>
</a>
,
<a class="link" href="case.html" title="15.6.5.1 CASE Statement">
<code class="literal">
CASE
</code>
</a>
,
<a class="link" href="if.html" title="15.6.5.2 IF Statement">
<code class="literal">
IF
</code>
</a>
, and
<a class="link" href="return.html" title="15.6.5.7 RETURN Statement">
<code class="literal">
RETURN
</code>
</a>
as used in stored
routines
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="call.html" title="15.2.1 CALL Statement">
<code class="literal">
CALL
</code>
</a>
</p>
</li>
</ul>
</div>
<p>
Tracing is supported for both
<code class="literal">
INSERT
</code>
and
<code class="literal">
REPLACE
</code>
statements using
<code class="literal">
VALUES
</code>
,
<code class="literal">
VALUES ROW
</code>
, or
<code class="literal">
SELECT
</code>
.
</p>
<p>
Traces of multi-table
<code class="literal">
UPDATE
</code>
and
<code class="literal">
DELETE
</code>
statements are supported.
</p>
<p>
Tracing of
<code class="literal">
SET optimizer_trace
</code>
is not
supported.
</p>
<p>
For statements which are prepared and executed in separate steps,
preparation and execution are traced separately.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-migrate-keyring.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-migrate-keyring">
</a>
6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045305880480">
</a>
<p>
The
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
utility migrates
keys between one keyring component and another. It supports
offline and online migrations.
</p>
<p>
Invoke
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
like this (enter
the command on a single line):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa54370315"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">mysql_migrate_keyring
<span class="token constant">--component-dir</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">dir_name</em></span>
<span class="token constant">--source-keyring</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">name</em></span>
<span class="token constant">--destination-keyring</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">name</em></span>
<span class="token punctuation">[</span><em class="replaceable">other options</em><span class="token punctuation">]</span></code></pre>
</div>
<p>
For information about key migrations and instructions describing
how to perform them using
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
and other methods, see
<a class="xref" href="keyring-key-migration.html" title="8.4.4.11 Migrating Keys Between Keyring Keystores">
Section 8.4.4.11, “Migrating Keys Between Keyring Keystores”
</a>
.
</p>
<p>
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
supports the following
options, which can be specified on the command line or in the
<code class="literal">
[mysql_migrate_keyring]
</code>
group of an option
file. For information about option files used by MySQL programs,
see
<a class="xref" href="option-files.html" title="6.2.2.2 Using Option Files">
Section 6.2.2.2, “Using Option Files”
</a>
.
</p>
<div class="table">
<a name="idm46045305867536">
</a>
<p class="title">
<b>
Table 6.19 mysql_migrate_keyring Options
</b>
</p>
<div class="table-contents">
<table frame="box" rules="all" summary="Command-line options available for mysql_migrate_keyring.">
<colgroup>
<col style="width: 35%"/>
<col style="width: 64%"/>
</colgroup>
<thead>
<tr>
<th>
Option Name
</th>
<th>
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_component-dir">
--component-dir
</a>
</td>
<td>
Directory for keyring components
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_defaults-extra-file">
--defaults-extra-file
</a>
</td>
<td>
Read named option file in addition to usual option files
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_defaults-file">
--defaults-file
</a>
</td>
<td>
Read only named option file
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_defaults-group-suffix">
--defaults-group-suffix
</a>
</td>
<td>
Option group suffix value
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_destination-keyring">
--destination-keyring
</a>
</td>
<td>
Destination keyring component name
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_destination-keyring-configuration-dir">
--destination-keyring-configuration-dir
</a>
</td>
<td>
Destination keyring component configuration directory
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_get-server-public-key">
--get-server-public-key
</a>
</td>
<td>
Request RSA public key from server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_help">
--help
</a>
</td>
<td>
Display help message and exit
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_host">
--host
</a>
</td>
<td>
Host on which MySQL server is located
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_login-path">
--login-path
</a>
</td>
<td>
Read login path options from .mylogin.cnf
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_no-defaults">
--no-defaults
</a>
</td>
<td>
Read no option files
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_no-login-paths">
--no-login-paths
</a>
</td>
<td>
Do not read login paths from the login path file
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_online-migration">
--online-migration
</a>
</td>
<td>
Migration source is an active server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_password">
--password
</a>
</td>
<td>
Password to use when connecting to server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_port">
--port
</a>
</td>
<td>
TCP/IP port number for connection
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_print-defaults">
--print-defaults
</a>
</td>
<td>
Print default options
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_server-public-key-path">
--server-public-key-path
</a>
</td>
<td>
Path name to file containing RSA public key
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_socket">
--socket
</a>
</td>
<td>
Unix socket file or Windows named pipe to use
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_source-keyring">
--source-keyring
</a>
</td>
<td>
Source keyring component name
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_source-keyring-configuration-dir">
--source-keyring-configuration-dir
</a>
</td>
<td>
Source keyring component configuration directory
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl">
--ssl-ca
</a>
</td>
<td>
File that contains list of trusted SSL Certificate Authorities
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl">
--ssl-capath
</a>
</td>
<td>
Directory that contains trusted SSL Certificate Authority certificate files
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl">
--ssl-cert
</a>
</td>
<td>
File that contains X.509 certificate
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl">
--ssl-cipher
</a>
</td>
<td>
Permissible ciphers for connection encryption
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl">
--ssl-crl
</a>
</td>
<td>
File that contains certificate revocation lists
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl">
--ssl-crlpath
</a>
</td>
<td>
Directory that contains certificate revocation-list files
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl-fips-mode">
--ssl-fips-mode
</a>
</td>
<td>
Whether to enable FIPS mode on client side
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl">
--ssl-key
</a>
</td>
<td>
File that contains X.509 key
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl">
--ssl-mode
</a>
</td>
<td>
Desired security state of connection to server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl">
--ssl-session-data
</a>
</td>
<td>
File that contains SSL session data
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl">
--ssl-session-data-continue-on-failed-reuse
</a>
</td>
<td>
Whether to establish connections if session reuse fails
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_tls-ciphersuites">
--tls-ciphersuites
</a>
</td>
<td>
Permissible TLSv1.3 ciphersuites for encrypted connections
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_tls-sni-servername">
--tls-sni-servername
</a>
</td>
<td>
Server name supplied by the client
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_tls-version">
--tls-version
</a>
</td>
<td>
Permissible TLS protocols for encrypted connections
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_user">
--user
</a>
</td>
<td>
MySQL user name to use when connecting to server
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_verbose">
--verbose
</a>
</td>
<td>
Verbose mode
</td>
</tr>
<tr>
<td>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_version">
--version
</a>
</td>
<td>
Display version information and exit
</td>
</tr>
</tbody>
</table>
</div>
<div class="table-contents">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 739px;">
<thead>
<tr>
<th style="width: 260.906px;">
Option Name
</th>
<th style="width: 477.094px;">
Description
</th>
</tr>
</thead>
</table>
</div>
</div>
<br class="table-break"/>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_help">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_help">
<code class="option">
--help
</code>
</a>
,
<code class="option">
-h
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for help">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--help
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305751472">
</a>
<a class="indexterm" name="idm46045305749984">
</a>
<p>
Display a help message and exit.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_component-dir">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_component-dir">
<code class="option">
--component-dir=
<em class="replaceable">
<code>
dir_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for component-dir">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--component-dir=dir_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Directory name
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305737888">
</a>
<a class="indexterm" name="idm46045305736400">
</a>
<p>
The directory where keyring components are located. This is
typically the value of the
<a class="link" href="server-system-variables.html#sysvar_plugin_dir">
<code class="literal">
plugin_dir
</code>
</a>
system variable
for the local MySQL server.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_component-dir">
<code class="option">
--component-dir
</code>
</a>
,
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_source-keyring">
<code class="option">
--source-keyring
</code>
</a>
,
and
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_destination-keyring">
<code class="option">
--destination-keyring
</code>
</a>
are mandatory for all keyring migration operations
performed by
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
. In
addition, the source and destination components must
differ, and both components must be properly configured so
that
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
can load and
use them.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_defaults-extra-file">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_defaults-extra-file">
<code class="option">
--defaults-extra-file=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for defaults-extra-file">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--defaults-extra-file=file_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305716400">
</a>
<a class="indexterm" name="idm46045305714896">
</a>
<p>
Read this option file after the global option file but (on
Unix) before the user option file. If the file does not
exist or is otherwise inaccessible, an error occurs. If
<em class="replaceable">
<code>
file_name
</code>
</em>
is not an absolute path
name, it is interpreted relative to the current directory.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_defaults-file">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_defaults-file">
<code class="option">
--defaults-file=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for defaults-file">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--defaults-file=file_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305700992">
</a>
<a class="indexterm" name="idm46045305699504">
</a>
<p>
Use only the given option file. If the file does not exist
or is otherwise inaccessible, an error occurs. If
<em class="replaceable">
<code>
file_name
</code>
</em>
is not an absolute path
name, it is interpreted relative to the current directory.
</p>
<p>
Exception: Even with
<a class="link" href="option-file-options.html#option_general_defaults-file">
<code class="option">
--defaults-file
</code>
</a>
, client
programs read
<code class="filename">
.mylogin.cnf
</code>
.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_defaults-group-suffix">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_defaults-group-suffix">
<code class="option">
--defaults-group-suffix=
<em class="replaceable">
<code>
str
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for defaults-group-suffix">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--defaults-group-suffix=str
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305683472">
</a>
<a class="indexterm" name="idm46045305681968">
</a>
<p>
Read not only the usual option groups, but also groups with
the usual names and a suffix of
<em class="replaceable">
<code>
str
</code>
</em>
. For example,
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
normally reads the
<code class="literal">
[mysql_migrate_keyring]
</code>
group. If this
option is given as
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_defaults-group-suffix">
<code class="option">
--defaults-group-suffix=_other
</code>
</a>
,
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
also reads the
<code class="literal">
[mysql_migrate_keyring_other]
</code>
group.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_destination-keyring">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_destination-keyring">
<code class="option">
--destination-keyring=
<em class="replaceable">
<code>
name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for destination-keyring">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--destination-keyring=name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305663168">
</a>
<a class="indexterm" name="idm46045305661664">
</a>
<p>
The destination keyring component for key migration. The
format and interpretation of the option value is the same as
described for the
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_source-keyring">
<code class="option">
--source-keyring
</code>
</a>
option.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_component-dir">
<code class="option">
--component-dir
</code>
</a>
,
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_source-keyring">
<code class="option">
--source-keyring
</code>
</a>
,
and
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_destination-keyring">
<code class="option">
--destination-keyring
</code>
</a>
are mandatory for all keyring migration operations
performed by
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
. In
addition, the source and destination components must
differ, and both components must be properly configured so
that
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
can load and
use them.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_destination-keyring-configuration-dir">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_destination-keyring-configuration-dir">
<code class="option">
--destination-keyring-configuration-dir=
<em class="replaceable">
<code>
dir_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for destination-keyring-configuration-dir">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--destination-keyring-configuration-dir=dir_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Directory name
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305641680">
</a>
<a class="indexterm" name="idm46045305640160">
</a>
<p>
This option applies only if the destination keyring
component global configuration file contains
<code class="literal">
"read_local_config": true
</code>
, indicating
that component configuration is contained in the local
configuration file. The option value specifies the directory
containing that local file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_get-server-public-key">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_get-server-public-key">
<code class="option">
--get-server-public-key
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for get-server-public-key">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--get-server-public-key
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305627360">
</a>
<a class="indexterm" name="idm46045305625856">
</a>
<p>
Request from the server the public key required for RSA key
pair-based password exchange. This option applies to clients
that authenticate with the
<code class="literal">
caching_sha2_password
</code>
authentication
plugin. For that plugin, the server does not send the public
key unless requested. This option is ignored for accounts
that do not authenticate with that plugin. It is also
ignored if RSA-based password exchange is not used, as is
the case when the client connects to the server using a
secure connection.
</p>
<p>
If
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_server-public-key-path">
<code class="option">
--server-public-key-path=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
is given and specifies a valid public key file, it takes
precedence over
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_get-server-public-key">
<code class="option">
--get-server-public-key
</code>
</a>
.
</p>
<p>
For information about the
<code class="literal">
caching_sha2_password
</code>
plugin, see
<a class="xref" href="caching-sha2-pluggable-authentication.html" title="8.4.1.2 Caching SHA-2 Pluggable Authentication">
Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_host">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_host">
<code class="option">
--host=
<em class="replaceable">
<code>
host_name
</code>
</em>
</code>
</a>
,
<code class="option">
-h
<em class="replaceable">
<code>
host_name
</code>
</em>
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for host">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--host=host_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
localhost
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305604784">
</a>
<a class="indexterm" name="idm46045305603296">
</a>
<p>
The host location of the running server that is currently
using one of the key migration keystores. Migration always
occurs on the local host, so the option always specifies a
value for connecting to a local server, such as
<code class="literal">
localhost
</code>
,
<code class="literal">
127.0.0.1
</code>
,
<code class="literal">
::1
</code>
, or the local host IP address or host
name.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_login-path">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_login-path">
<code class="option">
--login-path=
<em class="replaceable">
<code>
name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for login-path">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--login-path=name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305589072">
</a>
<a class="indexterm" name="idm46045305587584">
</a>
<p>
Read options from the named login path in the
<code class="filename">
.mylogin.cnf
</code>
login path file. A
<span class="quote">
“
<span class="quote">
login path
</span>
”
</span>
is an option group containing
options that specify which MySQL server to connect to and
which account to authenticate as. To create or modify a
login path file, use the
<a class="link" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
<span class="command">
<strong>
mysql_config_editor
</strong>
</span>
</a>
utility. See
<a class="xref" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
Section 6.6.7, “mysql_config_editor — MySQL Configuration Utility”
</a>
.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_no-login-paths">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_no-login-paths">
<code class="option">
--no-login-paths
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for no-login-paths">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--no-login-paths
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305573376">
</a>
<a class="indexterm" name="idm46045305571888">
</a>
<p>
Skips reading options from the login path file.
</p>
<p>
See
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_login-path">
<code class="option">
--login-path
</code>
</a>
for related information.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_no-defaults">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_no-defaults">
<code class="option">
--no-defaults
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for no-defaults">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--no-defaults
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305559536">
</a>
<a class="indexterm" name="idm46045305558048">
</a>
<p>
Do not read any option files. If program startup fails due
to reading unknown options from an option file,
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_no-defaults">
<code class="option">
--no-defaults
</code>
</a>
can be used to prevent them from being read.
</p>
<p>
The exception is that the
<code class="filename">
.mylogin.cnf
</code>
file is read in all cases, if it exists. This permits
passwords to be specified in a safer way than on the command
line even when
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_no-defaults">
<code class="option">
--no-defaults
</code>
</a>
is used. To create
<code class="filename">
.mylogin.cnf
</code>
, use
the
<a class="link" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
<span class="command">
<strong>
mysql_config_editor
</strong>
</span>
</a>
utility. See
<a class="xref" href="mysql-config-editor.html" title="6.6.7 mysql_config_editor — MySQL Configuration Utility">
Section 6.6.7, “mysql_config_editor — MySQL Configuration Utility”
</a>
.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_online-migration">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_online-migration">
<code class="option">
--online-migration
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for online-migration">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--online-migration
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Boolean
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
FALSE
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305536512">
</a>
<a class="indexterm" name="idm46045305535024">
</a>
<p>
This option is mandatory when a running server is using the
keyring. It tells
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
to perform an online key migration. The option has these
effects:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
connects to the
server using any connection options specified; these
options are otherwise ignored.
</p>
</li>
<li class="listitem">
<p>
After
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
connects
to the server, it tells the server to pause keyring
operations. When key copying is complete,
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
tells the
server it can resume keyring operations before
disconnecting.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_password">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_password">
<code class="option">
--password[=
<em class="replaceable">
<code>
password
</code>
</em>
]
</code>
</a>
,
<code class="option">
-p[
<em class="replaceable">
<code>
password
</code>
</em>
]
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for password">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--password[=password]
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305514800">
</a>
<a class="indexterm" name="idm46045305513312">
</a>
<p>
The password of the MySQL account used for connecting to the
running server that is currently using one of the key
migration keystores. The password value is optional. If not
given,
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
prompts for
one. If given, there must be
<span class="emphasis">
<em>
no space
</em>
</span>
between
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_password">
<code class="option">
--password=
</code>
</a>
or
<code class="option">
-p
</code>
and the password following it. If no
password option is specified, the default is to send no
password.
</p>
<p>
Specifying a password on the command line should be
considered insecure. To avoid giving the password on the
command line, use an option file. See
<a class="xref" href="password-security-user.html" title="8.1.2.1 End-User Guidelines for Password Security">
Section 8.1.2.1, “End-User Guidelines for Password Security”
</a>
.
</p>
<p>
To explicitly specify that there is no password and that
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
should not prompt
for one, use the
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_password">
<code class="option">
--skip-password
</code>
</a>
option.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_port">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_port">
<code class="option">
--port=
<em class="replaceable">
<code>
port_num
</code>
</em>
</code>
</a>
,
<code class="option">
-P
<em class="replaceable">
<code>
port_num
</code>
</em>
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for port">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--port=port_num
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Numeric
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
0
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305490816">
</a>
<a class="indexterm" name="idm46045305489328">
</a>
<a class="indexterm" name="idm46045305487840">
</a>
<p>
For TCP/IP connections, the port number for connecting to
the running server that is currently using one of the key
migration keystores.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_print-defaults">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_print-defaults">
<code class="option">
--print-defaults
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for print-defaults">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--print-defaults
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305478384">
</a>
<a class="indexterm" name="idm46045305476896">
</a>
<p>
Print the program name and all options that it gets from
option files.
</p>
<p>
For additional information about this and other option-file
options, see
<a class="xref" href="option-file-options.html" title="6.2.2.3 Command-Line Options that Affect Option-File Handling">
Section 6.2.2.3, “Command-Line Options that Affect Option-File Handling”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_server-public-key-path">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_server-public-key-path">
<code class="option">
--server-public-key-path=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for server-public-key-path">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--server-public-key-path=file_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
File name
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305463648">
</a>
<a class="indexterm" name="idm46045305462144">
</a>
<p>
The path name to a file in PEM format containing a
client-side copy of the public key required by the server
for RSA key pair-based password exchange. This option
applies to clients that authenticate with the
<code class="literal">
sha256_password
</code>
(deprecated) or
<code class="literal">
caching_sha2_password
</code>
authentication
plugin. This option is ignored for accounts that do not
authenticate with one of those plugins. It is also ignored
if RSA-based password exchange is not used, as is the case
when the client connects to the server using a secure
connection.
</p>
<p>
If
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_server-public-key-path">
<code class="option">
--server-public-key-path=
<em class="replaceable">
<code>
file_name
</code>
</em>
</code>
</a>
is given and specifies a valid public key file, it takes
precedence over
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_get-server-public-key">
<code class="option">
--get-server-public-key
</code>
</a>
.
</p>
<p>
For
<code class="literal">
sha256_password
</code>
(deprecated), this
option applies only if MySQL was built using OpenSSL.
</p>
<p>
For information about the
<code class="literal">
sha256_password
</code>
and
<code class="literal">
caching_sha2_password
</code>
plugins, see
<a class="xref" href="sha256-pluggable-authentication.html" title="8.4.1.3 SHA-256 Pluggable Authentication">
Section 8.4.1.3, “SHA-256 Pluggable Authentication”
</a>
, and
<a class="xref" href="caching-sha2-pluggable-authentication.html" title="8.4.1.2 Caching SHA-2 Pluggable Authentication">
Section 8.4.1.2, “Caching SHA-2 Pluggable Authentication”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_socket">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_socket">
<code class="option">
--socket=
<em class="replaceable">
<code>
path
</code>
</em>
</code>
</a>
,
<code class="option">
-S
<em class="replaceable">
<code>
path
</code>
</em>
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for socket">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--socket={file_name|pipe_name}
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305440128">
</a>
<a class="indexterm" name="idm46045305438640">
</a>
<p>
For Unix socket file or Windows named pipe connections, the
socket file or named pipe for connecting to the running
server that is currently using one of the key migration
keystores.
</p>
<p>
On Windows, this option applies only if the server was
started with the
<a class="link" href="server-system-variables.html#sysvar_named_pipe">
<code class="literal">
named_pipe
</code>
</a>
system variable enabled to support named-pipe connections.
In addition, the user making the connection must be a member
of the Windows group specified by the
<a class="link" href="server-system-variables.html#sysvar_named_pipe_full_access_group">
<code class="literal">
named_pipe_full_access_group
</code>
</a>
system variable.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_source-keyring">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_source-keyring">
<code class="option">
--source-keyring=
<em class="replaceable">
<code>
name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for source-keyring">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--source-keyring=name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305423168">
</a>
<a class="indexterm" name="idm46045305421680">
</a>
<p>
The source keyring component for key migration. This is the
component library file name specified without any
platform-specific extension such as
<code class="filename">
.so
</code>
or
<code class="filename">
.dll
</code>
. For example, to use the
component for which the library file is
<code class="filename">
component_keyring_file.so
</code>
, specify the
option as
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_source-keyring">
<code class="option">
--source-keyring=component_keyring_file
</code>
</a>
.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_component-dir">
<code class="option">
--component-dir
</code>
</a>
,
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_source-keyring">
<code class="option">
--source-keyring
</code>
</a>
,
and
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_destination-keyring">
<code class="option">
--destination-keyring
</code>
</a>
are mandatory for all keyring migration operations
performed by
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
. In
addition, the source and destination components must
differ, and both components must be properly configured so
that
<a class="link" href="mysql-migrate-keyring.html" title="6.6.8 mysql_migrate_keyring — Keyring Key Migration Utility">
<span class="command">
<strong>
mysql_migrate_keyring
</strong>
</span>
</a>
can load and
use them.
</p>
</div>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_source-keyring-configuration-dir">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_source-keyring-configuration-dir">
<code class="option">
--source-keyring-configuration-dir=
<em class="replaceable">
<code>
dir_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for source-keyring-configuration-dir">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--source-keyring-configuration-dir=dir_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Directory name
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305399488">
</a>
<a class="indexterm" name="idm46045305397984">
</a>
<p>
This option applies only if the source keyring component
global configuration file contains
<code class="literal">
"read_local_config": true
</code>
, indicating
that component configuration is contained in the local
configuration file. The option value specifies the directory
containing that local file.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_ssl">
</a>
<code class="option">
--ssl*
</code>
</p>
<a class="indexterm" name="idm46045305393328">
</a>
<a class="indexterm" name="idm46045305391840">
</a>
<p>
Options that begin with
<code class="option">
--ssl
</code>
specify
whether to connect to the server using encryption and
indicate where to find SSL keys and certificates. See
<a class="xref" href="connection-options.html#encrypted-connection-options" title="Command Options for Encrypted Connections">
Command Options for Encrypted Connections
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_ssl-fips-mode">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl-fips-mode">
<code class="option">
--ssl-fips-mode={OFF|ON|STRICT}
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for ssl-fips-mode">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--ssl-fips-mode={OFF|ON|STRICT}
</code>
</td>
</tr>
<tr>
<th>
Deprecated
</th>
<td>
Yes
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
Enumeration
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<code class="literal">
OFF
</code>
</td>
</tr>
<tr>
<th>
Valid Values
</th>
<td>
<p class="valid-value">
<code class="literal">
OFF
</code>
</p>
<p class="valid-value">
<code class="literal">
ON
</code>
</p>
<p class="valid-value">
<code class="literal">
STRICT
</code>
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305369680">
</a>
<a class="indexterm" name="idm46045305368192">
</a>
<p>
Controls whether to enable FIPS mode on the client side. The
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl-fips-mode">
<code class="option">
--ssl-fips-mode
</code>
</a>
option differs from other
<code class="option">
--ssl-
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
options in that it is not used to establish encrypted
connections, but rather to affect which cryptographic
operations to permit. See
<a class="xref" href="fips-mode.html" title="8.8 FIPS Support">
Section 8.8, “FIPS Support”
</a>
.
</p>
<p>
These
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl-fips-mode">
<code class="option">
--ssl-fips-mode
</code>
</a>
values are permitted:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<code class="literal">
OFF
</code>
: Disable FIPS mode.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ON
</code>
: Enable FIPS mode.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STRICT
</code>
: Enable
<span class="quote">
“
<span class="quote">
strict
</span>
”
</span>
FIPS mode.
</p>
</li>
</ul>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
If the OpenSSL FIPS Object Module is not available, the
only permitted value for
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl-fips-mode">
<code class="option">
--ssl-fips-mode
</code>
</a>
is
<code class="literal">
OFF
</code>
. In this case, setting
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_ssl-fips-mode">
<code class="option">
--ssl-fips-mode
</code>
</a>
to
<code class="literal">
ON
</code>
or
<code class="literal">
STRICT
</code>
causes the client to produce a warning at startup and to
operate in non-FIPS mode.
</p>
</div>
<p>
This option is deprecated. Expect it to be removed in a
future version of MySQL.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_tls-ciphersuites">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_tls-ciphersuites">
<code class="option">
--tls-ciphersuites=
<em class="replaceable">
<code>
ciphersuite_list
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for tls-ciphersuites">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--tls-ciphersuites=ciphersuite_list
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305341088">
</a>
<a class="indexterm" name="idm46045305339600">
</a>
<p>
The permissible ciphersuites for encrypted connections that
use TLSv1.3. The value is a list of one or more
colon-separated ciphersuite names. The ciphersuites that can
be named for this option depend on the SSL library used to
compile MySQL. For details, see
<a class="xref" href="encrypted-connection-protocols-ciphers.html" title="8.3.2 Encrypted Connection TLS Protocols and Ciphers">
Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_tls-sni-servername">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_tls-sni-servername">
<code class="option">
--tls-sni-servername=
<em class="replaceable">
<code>
server_name
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for tls-sni-servername">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--tls-sni-servername=server_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305326544">
</a>
<a class="indexterm" name="idm46045305325040">
</a>
<p>
When specified, the name is passed to the
<code class="literal">
libmysqlclient
</code>
C API library using the
<code class="literal">
MYSQL_OPT_TLS_SNI_SERVERNAME
</code>
option of
<a class="ulink" href="/doc/c-api/8.4/en/mysql-options.html" target="_top">
<code class="literal">
mysql_options()
</code>
</a>
. The server
name is not case-sensitive. To show which server name the
client specified for the current session, if any, check the
<a class="link" href="server-status-variables.html#statvar_Tls_sni_server_name">
<code class="literal">
Tls_sni_server_name
</code>
</a>
status
variable.
</p>
<p>
Server Name Indication (SNI) is an extension to the TLS
protocol (OpenSSL must be compiled using TLS extensions for
this option to function). The MySQL implementation of SNI
represents the client-side only.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_tls-version">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_tls-version">
<code class="option">
--tls-version=
<em class="replaceable">
<code>
protocol_list
</code>
</em>
</code>
</a>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for tls-version">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--tls-version=protocol_list
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
<tr>
<th>
Default Value
</th>
<td>
<p class="valid-value">
<code class="literal">
TLSv1,TLSv1.1,TLSv1.2,TLSv1.3
</code>
(OpenSSL 1.1.1 or higher)
</p>
<p class="valid-value">
<code class="literal">
TLSv1,TLSv1.1,TLSv1.2
</code>
(otherwise)
</p>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305304112">
</a>
<a class="indexterm" name="idm46045305302624">
</a>
<p>
The permissible TLS protocols for encrypted connections. The
value is a list of one or more comma-separated protocol
names. The protocols that can be named for this option
depend on the SSL library used to compile MySQL. For
details, see
<a class="xref" href="encrypted-connection-protocols-ciphers.html" title="8.3.2 Encrypted Connection TLS Protocols and Ciphers">
Section 8.3.2, “Encrypted Connection TLS Protocols and Ciphers”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_user">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_user">
<code class="option">
--user=
<em class="replaceable">
<code>
user_name
</code>
</em>
</code>
</a>
,
<code class="option">
-u
<em class="replaceable">
<code>
user_name
</code>
</em>
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for user">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--user=user_name
</code>
</td>
</tr>
<tr>
<th>
Type
</th>
<td>
String
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305289008">
</a>
<a class="indexterm" name="idm46045305287520">
</a>
<p>
The user name of the MySQL account used for connecting to
the running server that is currently using one of the key
migration keystores.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_verbose">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_verbose">
<code class="option">
--verbose
</code>
</a>
,
<code class="option">
-v
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for verbose">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--verbose
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305277392">
</a>
<a class="indexterm" name="idm46045305275904">
</a>
<p>
Verbose mode. Produce more output about what the program
does.
</p>
</li>
<li class="listitem">
<p>
<a name="option_mysql_migrate_keyring_version">
</a>
<a class="link" href="mysql-migrate-keyring.html#option_mysql_migrate_keyring_version">
<code class="option">
--version
</code>
</a>
,
<code class="option">
-V
</code>
</p>
<div class="informaltable">
<table frame="box" rules="all" summary="Properties for version">
<colgroup>
<col style="width: 30%"/>
<col style="width: 70%"/>
</colgroup>
<tbody>
<tr>
<th>
Command-Line Format
</th>
<td>
<code class="literal">
--version
</code>
</td>
</tr>
</tbody>
</table>
</div>
<a class="indexterm" name="idm46045305265808">
</a>
<a class="indexterm" name="idm46045305264320">
</a>
<p>
Display version information and exit.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-features-drop-if-exists.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="replication-features-drop-if-exists">
</a>
19.5.1.11 Replication of DROP ... IF EXISTS Statements
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045135638944">
</a>
<a class="indexterm" name="idm46045135637456">
</a>
<p>
The
<a class="link" href="drop-database.html" title="15.1.24 DROP DATABASE Statement">
<code class="literal">
DROP DATABASE
IF EXISTS
</code>
</a>
,
<a class="link" href="drop-table.html" title="15.1.32 DROP TABLE Statement">
<code class="literal">
DROP TABLE IF
EXISTS
</code>
</a>
, and
<a class="link" href="drop-view.html" title="15.1.35 DROP VIEW Statement">
<code class="literal">
DROP VIEW IF
EXISTS
</code>
</a>
statements are always replicated, even if the
database, table, or view to be dropped does not exist on the
source. This is to ensure that the object to be dropped no
longer exists on either the source or the replica, once the
replica has caught up with the source.
</p>
<p>
<code class="literal">
DROP ... IF EXISTS
</code>
statements for stored
programs (stored procedures and functions, triggers, and events)
are also replicated, even if the stored program to be dropped
does not exist on the source.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/binlog.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="binlog">
</a>
15.7.8.1 BINLOG Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045168869872">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa97268329"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">BINLOG</span> <span class="token string">'<em class="replaceable">str</em>'</span></code></pre>
</div>
<p>
<a class="link" href="binlog.html" title="15.7.8.1 BINLOG Statement">
<code class="literal">
BINLOG
</code>
</a>
is an internal-use
statement. It is generated by the
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
program as the printable representation of certain events in
binary log files. (See
<a class="xref" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
Section 6.6.9, “mysqlbinlog — Utility for Processing Binary Log Files”
</a>
.) The
<code class="literal">
'
<em class="replaceable">
<code>
str
</code>
</em>
'
</code>
value is a
base 64-encoded string the that server decodes to determine the
data change indicated by the corresponding event.
</p>
<p>
To execute
<a class="link" href="binlog.html" title="15.7.8.1 BINLOG Statement">
<code class="literal">
BINLOG
</code>
</a>
statements when
applying
<a class="link" href="mysqlbinlog.html" title="6.6.9 mysqlbinlog — Utility for Processing Binary Log Files">
<span class="command">
<strong>
mysqlbinlog
</strong>
</span>
</a>
output, a user account
requires the
<a class="link" href="privileges-provided.html#priv_binlog-admin">
<code class="literal">
BINLOG_ADMIN
</code>
</a>
privilege (or the deprecated
<a class="link" href="privileges-provided.html#priv_super">
<code class="literal">
SUPER
</code>
</a>
privilege), or the
<a class="link" href="privileges-provided.html#priv_replication-applier">
<code class="literal">
REPLICATION_APPLIER
</code>
</a>
privilege
plus the appropriate privileges to execute each log event.
</p>
<p>
This statement can execute only format description events and
row events.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/compatibility.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="compatibility">
</a>
1.7 MySQL Standards Compliance
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="extensions-to-ansi.html">
1.7.1 MySQL Extensions to Standard SQL
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="differences-from-ansi.html">
1.7.2 MySQL Differences from Standard SQL
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="constraints.html">
1.7.3 How MySQL Deals with Constraints
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045333578368">
</a>
<a class="indexterm" name="idm46045333576912">
</a>
<a class="indexterm" name="idm46045333575840">
</a>
<a class="indexterm" name="idm46045333574352">
</a>
<a class="indexterm" name="idm46045333572864">
</a>
<p>
This section describes how MySQL relates to the ANSI/ISO SQL
standards. MySQL Server has many extensions to the SQL standard,
and here you can find out what they are and how to use them. You
can also find information about functionality missing from MySQL
Server, and how to work around some of the differences.
</p>
<p>
The SQL standard has been evolving since 1986 and several versions
exist. In this manual,
<span class="quote">
“
<span class="quote">
SQL-92
</span>
”
</span>
refers to the
standard released in 1992.
<span class="quote">
“
<span class="quote">
SQL:1999
</span>
”
</span>
,
<span class="quote">
“
<span class="quote">
SQL:2003
</span>
”
</span>
,
<span class="quote">
“
<span class="quote">
SQL:2008
</span>
”
</span>
, and
<span class="quote">
“
<span class="quote">
SQL:2011
</span>
”
</span>
refer to the versions of the standard
released in the corresponding years, with the last being the most
recent version. We use the phrase
<span class="quote">
“
<span class="quote">
the SQL standard
</span>
”
</span>
or
<span class="quote">
“
<span class="quote">
standard SQL
</span>
”
</span>
to mean the current version of the
SQL Standard at any time.
</p>
<p>
One of our main goals with the product is to continue to work
toward compliance with the SQL standard, but without sacrificing
speed or reliability. We are not afraid to add extensions to SQL
or support for non-SQL features if this greatly increases the
usability of MySQL Server for a large segment of our user base.
The
<a class="link" href="handler.html" title="15.2.5 HANDLER Statement">
<code class="literal">
HANDLER
</code>
</a>
interface is an example
of this strategy. See
<a class="xref" href="handler.html" title="15.2.5 HANDLER Statement">
Section 15.2.5, “HANDLER Statement”
</a>
.
</p>
<p>
We continue to support transactional and nontransactional
databases to satisfy both mission-critical 24/7 usage and heavy
Web or logging usage.
</p>
<p>
MySQL Server was originally designed to work with medium-sized
databases (10-100 million rows, or about 100MB per table) on small
computer systems. Today MySQL Server handles terabyte-sized
databases.
</p>
<p>
We are not targeting real-time support, although MySQL replication
capabilities offer significant functionality.
</p>
<p>
MySQL supports ODBC levels 0 to 3.51.
</p>
<p>
MySQL supports high-availability database clustering using the
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
storage engine. See
<a class="xref" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
Chapter 25,
<i>
MySQL NDB Cluster 8.4
</i>
</a>
.
</p>
<p>
We implement XML functionality which supports most of the W3C
XPath standard. See
<a class="xref" href="xml-functions.html" title="14.11 XML Functions">
Section 14.11, “XML Functions”
</a>
.
</p>
<p>
MySQL supports a native JSON data type as defined by RFC 7159, and
based on the ECMAScript standard (ECMA-262). See
<a class="xref" href="json.html" title="13.5 The JSON Data Type">
Section 13.5, “The JSON Data Type”
</a>
. MySQL also implements a subset of the
SQL/JSON functions specified by a pre-publication draft of the
SQL:2016 standard; see
<a class="xref" href="json-functions.html" title="14.17 JSON Functions">
Section 14.17, “JSON Functions”
</a>
, for more
information.
</p>
<h3>
<a name="idm46045333555408">
</a>
Selecting SQL Modes
</h3>
<p>
The MySQL server can operate in different SQL modes, and can apply
these modes differently for different clients, depending on the
value of the
<a class="link" href="server-system-variables.html#sysvar_sql_mode">
<code class="literal">
sql_mode
</code>
</a>
system
variable. DBAs can set the global SQL mode to match site server
operating requirements, and each application can set its session
SQL mode to its own requirements.
</p>
<p>
Modes affect the SQL syntax MySQL supports and the data validation
checks it performs. This makes it easier to use MySQL in different
environments and to use MySQL together with other database
servers.
</p>
<p>
For more information on setting the SQL mode, see
<a class="xref" href="sql-mode.html" title="7.1.11 Server SQL Modes">
Section 7.1.11, “Server SQL Modes”
</a>
.
</p>
<h3>
<a name="idm46045333550848">
</a>
Running MySQL in ANSI Mode
</h3>
<a class="indexterm" name="idm46045333550128">
</a>
<a class="indexterm" name="idm46045333548640">
</a>
<p>
To run MySQL Server in ANSI mode, start
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
with the
<a class="link" href="server-options.html#option_mysqld_ansi">
<code class="option">
--ansi
</code>
</a>
option. Running the
server in ANSI mode is the same as starting it with the following
options:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa36083667"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token constant">--transaction-isolation</span><span class="token attr-value"><span class="token punctuation">=</span>SERIALIZABLE</span> <span class="token constant">--sql-mode</span><span class="token attr-value"><span class="token punctuation">=</span>ANSI</span></code></pre>
</div>
<p>
To achieve the same effect at runtime, execute these two
statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa66808167"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> <span class="token keyword">TRANSACTION</span> <span class="token keyword">ISOLATION</span> <span class="token keyword">LEVEL</span> <span class="token keyword">SERIALIZABLE</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> sql_mode <span class="token operator">=</span> <span class="token string">'ANSI'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
You can see that setting the
<a class="link" href="server-system-variables.html#sysvar_sql_mode">
<code class="literal">
sql_mode
</code>
</a>
system variable to
<code class="literal">
'ANSI'
</code>
enables all SQL mode options that are
relevant for ANSI mode as follows:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa55954343"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SET</span> <span class="token keyword">GLOBAL</span> sql_mode<span class="token operator">=</span><span class="token string">'ANSI'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token variable">@@GLOBAL.sql_mode</span><span class="token punctuation">;</span>
<span class="token prompt"> -></span> <span class="token string">'REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,ANSI'</span></code></pre>
</div>
<p>
Running the server in ANSI mode with
<a class="link" href="server-options.html#option_mysqld_ansi">
<code class="option">
--ansi
</code>
</a>
is not quite the same as
setting the SQL mode to
<code class="literal">
'ANSI'
</code>
because the
<a class="link" href="server-options.html#option_mysqld_ansi">
<code class="option">
--ansi
</code>
</a>
option also sets the
transaction isolation level.
</p>
<p>
See
<a class="xref" href="server-options.html" title="7.1.7 Server Command Options">
Section 7.1.7, “Server Command Options”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-semisync-monitoring.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="replication-semisync-monitoring">
</a>
19.4.10.3 Semisynchronous Replication Monitoring
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045136141200">
</a>
<p>
The plugins for semisynchronous replication expose a number of
status variables that enable you to monitor their operation. To
check the current values of the status variables, use
<a class="link" href="show-status.html" title="15.7.7.37 SHOW STATUS Statement">
<code class="literal">
SHOW STATUS
</code>
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa19411006"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SHOW</span> <span class="token keyword">STATUS</span> <span class="token operator">LIKE</span> <span class="token string">'Rpl_semi_sync%'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
All
<code class="literal">
Rpl_semi_sync_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
status variables are described at
<a class="xref" href="server-status-variables.html" title="7.1.10 Server Status Variables">
Section 7.1.10, “Server Status Variables”
</a>
. Some examples are:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="server-status-variables.html#statvar_Rpl_semi_sync_source_clients">
<code class="literal">
Rpl_semi_sync_source_clients
</code>
</a>
</p>
<p>
The number of semisynchronous replicas that are connected to
the source server.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-status-variables.html#statvar_Rpl_semi_sync_source_status">
<code class="literal">
Rpl_semi_sync_source_status
</code>
</a>
</p>
<p>
Whether semisynchronous replication currently is operational
on the source server. The value is 1 if the plugin has been
enabled and a commit acknowledgment has not occurred. It is
0 if the plugin is not enabled or the source has fallen back
to asynchronous replication due to commit acknowledgment
timeout.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-status-variables.html#statvar_Rpl_semi_sync_source_no_tx">
<code class="literal">
Rpl_semi_sync_source_no_tx
</code>
</a>
</p>
<p>
The number of commits that were not acknowledged
successfully by a replica.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-status-variables.html#statvar_Rpl_semi_sync_source_yes_tx">
<code class="literal">
Rpl_semi_sync_source_yes_tx
</code>
</a>
</p>
<p>
The number of commits that were acknowledged successfully by
a replica.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="server-status-variables.html#statvar_Rpl_semi_sync_replica_status">
<code class="literal">
Rpl_semi_sync_replica_status
</code>
</a>
</p>
<p>
Whether semisynchronous replication currently is operational
on the replica. This is 1 if the plugin has been enabled and
the replication I/O (receiver) thread is running, 0
otherwise.
</p>
</li>
</ul>
</div>
<p>
When the source switches between asynchronous or semisynchronous
replication due to commit-blocking timeout or a replica catching
up, it sets the value of the
<a class="link" href="server-status-variables.html#statvar_Rpl_semi_sync_source_status">
<code class="literal">
Rpl_semi_sync_source_status
</code>
</a>
status variable appropriately. Automatic fallback from
semisynchronous to asynchronous replication on the source means
that it is possible for the
<a class="link" href="replication-options-source.html#sysvar_rpl_semi_sync_source_enabled">
<code class="literal">
rpl_semi_sync_source_enabled
</code>
</a>
system variable to have a value of 1 on the source side even
when semisynchronous replication is in fact not operational at
the moment. You can monitor the
<a class="link" href="server-status-variables.html#statvar_Rpl_semi_sync_source_status">
<code class="literal">
Rpl_semi_sync_source_status
</code>
</a>
status variable to determine whether the source currently is
using asynchronous or semisynchronous replication.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-binlog-encryption-encryption-keys.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="replication-binlog-encryption-encryption-keys">
</a>
19.3.2.2 Binary Log Encryption Keys
</h4>
</div>
</div>
</div>
<p>
The binary log encryption keys used to encrypt the file
passwords for the log files are 256-bit keys that are generated
specifically for each MySQL server instance using MySQL Server's
keyring service (see
<a class="xref" href="keyring.html" title="8.4.4 The MySQL Keyring">
Section 8.4.4, “The MySQL Keyring”
</a>
). The keyring
service handles the creation, retrieval, and deletion of the
binary log encryption keys. A server instance only creates and
removes keys generated for itself, but it can read keys
generated for other instances if they are stored in the keyring,
as in the case of a server instance that has been cloned by file
copying.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
The binary log encryption keys for a MySQL server instance
must be included in your backup and recovery procedures,
because if the keys required to decrypt the file passwords for
current and retained binary log files or relay log files are
lost, it might not be possible to start the server.
</p>
</div>
<p>
The format of binary log encryption keys in the keyring is as
follows:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa91417414"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">MySQLReplicationKey_<span class="token punctuation">{</span>UUID<span class="token punctuation">}</span>_<span class="token punctuation">{</span>SEQ_NO<span class="token punctuation">}</span></code></pre>
</div>
<p>
For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-simple"><div class="docs-select-all right" id="sa62654577"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-simple">MySQLReplicationKey_00508583<span class="token operator">-</span>b5ce<span class="token operator">-</span>11e8<span class="token operator">-</span>a6a5<span class="token operator">-</span>0010e0734796_1</code></pre>
</div>
<p>
<code class="literal">
{UUID}
</code>
is the true UUID generated by the
MySQL server (the value of the
<a class="link" href="replication-options.html#sysvar_server_uuid">
<code class="literal">
server_uuid
</code>
</a>
system variable).
<code class="literal">
{SEQ_NO}
</code>
is the sequence number for the
binary log encryption key, which is incremented by 1 for each
new key that is generated on the server.
</p>
<p>
The binary log encryption key that is currently in use on the
server is called the binary log master key. The sequence number
for the current binary log master key is stored in the keyring.
The binary log master key is used to encrypt each new log
file's file password, which is a randomly generated 32-byte
file password specific to the log file that is used to encrypt
the file data. The file password is encrypted using AES-CBC (AES
Cipher Block Chaining mode) with the 256-bit binary log
encryption key and a random initialization vector (IV), and is
stored in the log file's file header. The file data is encrypted
using AES-CTR (AES Counter mode) with a 256-bit key generated
from the file password and a nonce also generated from the file
password. It is technically possible to decrypt an encrypted
file offline, if the binary log encryption key used to encrypt
the file password is known, by using tools available in the
OpenSSL cryptography toolkit.
</p>
<p>
If you use file copying to clone a MySQL server instance that
has encryption active so its binary log files and relay log
files are encrypted, ensure that the keyring is also copied, so
that the clone server can read the binary log encryption keys
from the source server. When encryption is activated on the
clone server (either at startup or subsequently), the clone
server recognizes that the binary log encryption keys used with
the copied files include the generated UUID of the source
server. It automatically generates a new binary log encryption
key using its own generated UUID, and uses this to encrypt the
file passwords for subsequent binary log files and relay log
files. The copied files continue to be read using the source
server's keys.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/query-attributes.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="query-attributes">
</a>
11.6 Query Attributes
</h2>
</div>
</div>
</div>
<a class="indexterm" name="idm46045218358416">
</a>
<p>
The most visible part of an SQL statement is the text of the
statement. Clients can also define query attributes that apply to
the next statement sent to the server for execution:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Attributes are defined prior to sending the statement.
</p>
</li>
<li class="listitem">
<p>
Attributes exist until statement execution ends, at which
point the attribute set is cleared.
</p>
</li>
<li class="listitem">
<p>
While attributes exist, they can be accessed on the server
side.
</p>
</li>
</ul>
</div>
<p>
Examples of the ways query attributes may be used:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
A web application produces pages that generate database
queries, and for each query must track the URL of the page
that generated it.
</p>
</li>
<li class="listitem">
<p>
An application passes extra processing information with each
query, for use by a plugin such as an audit plugin or query
rewrite plugin.
</p>
</li>
</ul>
</div>
<p>
MySQL supports these capabilities without the use of workarounds
such as specially formatted comments included in query strings.
The remainder of this section describes how to use query attribute
support, including the prerequisites that must be satisfied.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="query-attributes.html#using-query-attributes" title="Defining and Accessing Query Attributes">
Defining and Accessing Query Attributes
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="query-attributes.html#query-attributes-prerequisites" title="Prerequisites for Using Query Attributes">
Prerequisites for Using Query Attributes
</a>
</p>
</li>
<li class="listitem">
<p>
<a class="xref" href="query-attributes.html#query-attribute-functions" title="Query Attribute Loadable Functions">
Query Attribute Loadable Functions
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="using-query-attributes">
</a>
Defining and Accessing Query Attributes
</h3>
</div>
</div>
</div>
<p>
Applications that use the MySQL C API define query attributes by
calling the
<a class="ulink" href="/doc/c-api/8.4/en/mysql-bind-param.html" target="_top">
<code class="literal">
mysql_bind_param()
</code>
</a>
function. See
<a class="ulink" href="/doc/c-api/8.4/en/mysql-bind-param.html" target="_top">
mysql_bind_param()
</a>
. Other MySQL
connectors may also provide query-attribute support. See the
documentation for individual connectors.
</p>
<p>
The
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client has a
<code class="literal">
query_attributes
</code>
command that enables
defining up to 32 pairs of attribute names and values. See
<a class="xref" href="mysql-commands.html" title="6.5.1.2 mysql Client Commands">
Section 6.5.1.2, “mysql Client Commands”
</a>
.
</p>
<p>
Query attribute names are transmitted using the character set
indicated by the
<a class="link" href="server-system-variables.html#sysvar_character_set_client">
<code class="literal">
character_set_client
</code>
</a>
system
variable.
</p>
<p>
To access query attributes within SQL statements for which
attributes have been defined, install the
<code class="literal">
query_attributes
</code>
component as described in
<a class="xref" href="query-attributes.html#query-attributes-prerequisites" title="Prerequisites for Using Query Attributes">
Prerequisites for Using Query Attributes
</a>
. The component
implements a
<a class="link" href="query-attributes.html#function_mysql-query-attribute-string">
<code class="literal">
mysql_query_attribute_string()
</code>
</a>
loadable function that takes an attribute name argument and
returns the attribute value as a string, or
<code class="literal">
NULL
</code>
if the attribute does not exist. See
<a class="xref" href="query-attributes.html#query-attribute-functions" title="Query Attribute Loadable Functions">
Query Attribute Loadable Functions
</a>
.
</p>
<p>
The following examples use the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client
<code class="literal">
query_attributes
</code>
command to define attribute
name/value pairs, and the
<a class="link" href="query-attributes.html#function_mysql-query-attribute-string">
<code class="literal">
mysql_query_attribute_string()
</code>
</a>
function to access attribute values by name.
</p>
<p>
This example defines two attributes named
<code class="literal">
n1
</code>
and
<code class="literal">
n2
</code>
. The first
<code class="literal">
SELECT
</code>
shows how to retrieve those attributes, and also demonstrates
that retrieving a nonexistent attribute (
<code class="literal">
n3
</code>
)
returns
<code class="literal">
NULL
</code>
. The second
<code class="literal">
SELECT
</code>
shows that attributes do not persist
across statements.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa52185679"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> query_attributes n1 v1 n2 v2<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span>
mysql_query_attribute_string<span class="token punctuation">(</span><span class="token string">'n1'</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> <span class="token string">'attr 1'</span><span class="token punctuation">,</span>
mysql_query_attribute_string<span class="token punctuation">(</span><span class="token string">'n2'</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> <span class="token string">'attr 2'</span><span class="token punctuation">,</span>
mysql_query_attribute_string<span class="token punctuation">(</span><span class="token string">'n3'</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> <span class="token string">'attr 3'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> attr 1 <span class="token punctuation">|</span> attr 2 <span class="token punctuation">|</span> attr 3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> v1 <span class="token punctuation">|</span> v2 <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span>
mysql_query_attribute_string<span class="token punctuation">(</span><span class="token string">'n1'</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> <span class="token string">'attr 1'</span><span class="token punctuation">,</span>
mysql_query_attribute_string<span class="token punctuation">(</span><span class="token string">'n2'</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> <span class="token string">'attr 2'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> attr 1 <span class="token punctuation">|</span> attr 2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
As shown by the second
<code class="literal">
SELECT
</code>
statement,
attributes defined prior to a given statement are available only
to that statement and are cleared after the statement executes.
To use an attribute value across multiple statements, assign it
to a variable. The following example shows how to do this, and
illustrates that attribute values are available in subsequent
statements by means of the variables, but not by calling
<a class="link" href="query-attributes.html#function_mysql-query-attribute-string">
<code class="literal">
mysql_query_attribute_string()
</code>
</a>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa56033934"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> query_attributes n1 v1 n2 v2<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SET</span>
<span class="token variable">@attr1</span> <span class="token operator">=</span> mysql_query_attribute_string<span class="token punctuation">(</span><span class="token string">'n1'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
<span class="token variable">@attr2</span> <span class="token operator">=</span> mysql_query_attribute_string<span class="token punctuation">(</span><span class="token string">'n2'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span>
<span class="token variable">@attr1</span><span class="token punctuation">,</span> mysql_query_attribute_string<span class="token punctuation">(</span><span class="token string">'n1'</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> <span class="token string">'attr 1'</span><span class="token punctuation">,</span>
<span class="token variable">@attr2</span><span class="token punctuation">,</span> mysql_query_attribute_string<span class="token punctuation">(</span><span class="token string">'n2'</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> <span class="token string">'attr 2'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> @attr1 <span class="token punctuation">|</span> attr 1 <span class="token punctuation">|</span> @attr2 <span class="token punctuation">|</span> attr 2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> v1 <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> v2 <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
Attributes can also be saved for later use by storing them in a
table:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa22416118"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t1 <span class="token punctuation">(</span>c1 <span class="token datatype">CHAR</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span><span class="token punctuation">,</span> c2 <span class="token datatype">CHAR</span><span class="token punctuation">(</span><span class="token number">20</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> query_attributes n1 v1 n2 v2<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> t1 <span class="token punctuation">(</span>c1<span class="token punctuation">,</span> c2<span class="token punctuation">)</span> <span class="token keyword">VALUES</span><span class="token punctuation">(</span>
mysql_query_attribute_string<span class="token punctuation">(</span><span class="token string">'n1'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
mysql_query_attribute_string<span class="token punctuation">(</span><span class="token string">'n2'</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> c1 <span class="token punctuation">|</span> c2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> v1 <span class="token punctuation">|</span> v2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
Query attributes are subject to these limitations and
restrictions:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If multiple attribute-definition operations occur prior to
sending a statement to the server for execution, the most
recent definition operation applies and replaces attributes
defined in earlier operations.
</p>
</li>
<li class="listitem">
<p>
If multiple attributes are defined with the same name,
attempts to retrieve the attribute value have an undefined
result.
</p>
</li>
<li class="listitem">
<p>
An attribute defined with an empty name cannot be retrieved
by name.
</p>
</li>
<li class="listitem">
<p>
Attributes are not available to statements prepared with
<a class="link" href="prepare.html" title="15.5.1 PREPARE Statement">
<code class="literal">
PREPARE
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
The
<a class="link" href="query-attributes.html#function_mysql-query-attribute-string">
<code class="literal">
mysql_query_attribute_string()
</code>
</a>
function cannot be used in DDL statements.
</p>
</li>
<li class="listitem">
<p>
Attributes are not replicated. Statements that invoke the
<a class="link" href="query-attributes.html#function_mysql-query-attribute-string">
<code class="literal">
mysql_query_attribute_string()
</code>
</a>
function will not get the same value on all servers.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="query-attributes-prerequisites">
</a>
Prerequisites for Using Query Attributes
</h3>
</div>
</div>
</div>
<p>
To access query attributes within SQL statements for which
attributes have been defined, the
<code class="literal">
query_attributes
</code>
component must be installed.
Do so using this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa69347645"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSTALL</span> <span class="token keyword">COMPONENT</span> <span class="token string">"file://component_query_attributes"</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Component installation is a one-time operation that need not be
done per server startup.
<a class="link" href="install-component.html" title="15.7.4.3 INSTALL COMPONENT Statement">
<code class="literal">
INSTALL
COMPONENT
</code>
</a>
loads the component, and also registers it
in the
<code class="literal">
mysql.component
</code>
system table to cause
it to be loaded during subsequent server startups.
</p>
<p>
The
<code class="literal">
query_attributes
</code>
component accesses query
attributes to implement a
<a class="link" href="query-attributes.html#function_mysql-query-attribute-string">
<code class="literal">
mysql_query_attribute_string()
</code>
</a>
function. See
<a class="xref" href="query-attribute-components.html" title="7.5.4 Query Attribute Components">
Section 7.5.4, “Query Attribute Components”
</a>
.
</p>
<p>
To uninstall the
<code class="literal">
query_attributes
</code>
component,
use this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa35081325"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">UNINSTALL</span> <span class="token keyword">COMPONENT</span> <span class="token string">"file://component_query_attributes"</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
<a class="link" href="uninstall-component.html" title="15.7.4.5 UNINSTALL COMPONENT Statement">
<code class="literal">
UNINSTALL COMPONENT
</code>
</a>
unloads the
component, and unregisters it from the
<code class="literal">
mysql.component
</code>
system table to cause it not
to be loaded during subsequent server startups.
</p>
<p>
Because installing and uninstalling the
<code class="literal">
query_attributes
</code>
component installs and
uninstalls the
<a class="link" href="query-attributes.html#function_mysql-query-attribute-string">
<code class="literal">
mysql_query_attribute_string()
</code>
</a>
function that the component implements, it is not necessary to
use
<a class="link" href="create-function-loadable.html" title="15.7.4.1 CREATE FUNCTION Statement for Loadable Functions">
<code class="literal">
CREATE
FUNCTION
</code>
</a>
or
<a class="link" href="drop-function-loadable.html" title="15.7.4.2 DROP FUNCTION Statement for Loadable Functions">
<code class="literal">
DROP
FUNCTION
</code>
</a>
to do so.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h3 class="title">
<a name="query-attribute-functions">
</a>
Query Attribute Loadable Functions
</h3>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a name="function_mysql-query-attribute-string">
</a>
<a class="link" href="query-attributes.html#function_mysql-query-attribute-string">
<code class="literal">
mysql_query_attribute_string(
<em class="replaceable">
<code>
name
</code>
</em>
)
</code>
</a>
</p>
<a class="indexterm" name="idm46045218268448">
</a>
<p>
Applications can define attributes that apply to the next
query sent to the server. The
<a class="link" href="query-attributes.html#function_mysql-query-attribute-string">
<code class="literal">
mysql_query_attribute_string()
</code>
</a>
function returns an attribute value as a string, given the
attribute name. This function enables a query to access and
incorporate values of the attributes that apply to it.
</p>
<p>
<a class="link" href="query-attributes.html#function_mysql-query-attribute-string">
<code class="literal">
mysql_query_attribute_string()
</code>
</a>
is installed by installing the
<code class="literal">
query_attributes
</code>
component. See
<a class="xref" href="query-attributes.html" title="11.6 Query Attributes">
Section 11.6, “Query Attributes”
</a>
, which also discusses the
purpose and use of query attributes.
</p>
<p>
Arguments:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
<em class="replaceable">
<code>
name
</code>
</em>
: The attribute name.
</p>
</li>
</ul>
</div>
<p>
Return value:
</p>
<p>
Returns the attribute value as a string for success, or
<code class="literal">
NULL
</code>
if the attribute does not exist.
</p>
<p>
Example:
</p>
<p>
The following example uses the
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
client
<code class="literal">
query_attributes
</code>
command to define
query attributes that can be retrieved by
<a class="link" href="query-attributes.html#function_mysql-query-attribute-string">
<code class="literal">
mysql_query_attribute_string()
</code>
</a>
.
The
<code class="literal">
SELECT
</code>
shows that retrieving a
nonexistent attribute (
<code class="literal">
n3
</code>
) returns
<code class="literal">
NULL
</code>
.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa99040379"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> query_attributes n1 v1 n2 v2<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span>
<span class="token prompt"> -></span> mysql_query_attribute_string<span class="token punctuation">(</span><span class="token string">'n1'</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> <span class="token string">'attr 1'</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> mysql_query_attribute_string<span class="token punctuation">(</span><span class="token string">'n2'</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> <span class="token string">'attr 2'</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> mysql_query_attribute_string<span class="token punctuation">(</span><span class="token string">'n3'</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> <span class="token string">'attr 3'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> attr 1 <span class="token punctuation">|</span> attr 2 <span class="token punctuation">|</span> attr 3 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> v1 <span class="token punctuation">|</span> v2 <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/sys-ps-setup-disable-consumer.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="sys-ps-setup-disable-consumer">
</a>
30.4.4.5 The ps_setup_disable_consumer() Procedure
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045061537760">
</a>
<a class="indexterm" name="idm46045061536304">
</a>
<p>
Disables Performance Schema consumers with names that contain
the argument. Produces a result set indicating how many
consumers were disabled. Already disabled consumers do not
count.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="sys-ps-setup-disable-consumer-parameters">
</a>
Parameters
</h5>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
consumer VARCHAR(128)
</code>
: The value used
to match consumer names, which are identified by using
<code class="literal">
%consumer%
</code>
as an operand for a
<a class="link" href="string-comparison-functions.html#operator_like">
<code class="literal">
LIKE
</code>
</a>
pattern match.
</p>
<p>
A value of
<code class="literal">
''
</code>
matches all consumers.
</p>
</li>
</ul>
</div>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="sys-ps-setup-disable-consumer-example">
</a>
Example
</h5>
</div>
</div>
</div>
<p>
Disable all statement consumers:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa36186617"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CALL</span> sys<span class="token punctuation">.</span>ps_setup_disable_consumer<span class="token punctuation">(</span><span class="token string">'statement'</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> summary <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> Disabled 4 consumers <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-examples.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="performance-schema-examples">
</a>
29.19 Using the Performance Schema to Diagnose Problems
</h2>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="performance-schema-query-profiling.html">
29.19.1 Query Profiling Using Performance Schema
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="performance-schema-obtaining-parent-events.html">
29.19.2 Obtaining Parent Event Information
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045064282992">
</a>
<a class="indexterm" name="idm46045064281536">
</a>
<p>
The Performance Schema is a tool to help a DBA do performance
tuning by taking real measurements instead of
<span class="quote">
“
<span class="quote">
wild
guesses.
</span>
”
</span>
This section demonstrates some ways to use the
Performance Schema for this purpose. The discussion here relies on
the use of event filtering, which is described in
<a class="xref" href="performance-schema-filtering.html" title="29.4.2 Performance Schema Event Filtering">
Section 29.4.2, “Performance Schema Event Filtering”
</a>
.
</p>
<p>
The following example provides one methodology that you can use to
analyze a repeatable problem, such as investigating a performance
bottleneck. To begin, you should have a repeatable use case where
performance is deemed
<span class="quote">
“
<span class="quote">
too slow
</span>
”
</span>
and needs
optimization, and you should enable all instrumentation (no
pre-filtering at all).
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Run the use case.
</p>
</li>
<li class="listitem">
<p>
Using the Performance Schema tables, analyze the root cause of
the performance problem. This analysis relies heavily on
post-filtering.
</p>
</li>
<li class="listitem">
<p>
For problem areas that are ruled out, disable the
corresponding instruments. For example, if analysis shows that
the issue is not related to file I/O in a particular storage
engine, disable the file I/O instruments for that engine. Then
truncate the history and summary tables to remove previously
collected events.
</p>
</li>
<li class="listitem">
<p>
Repeat the process at step 1.
</p>
<p>
With each iteration, the Performance Schema output,
particularly the
<a class="link" href="performance-schema-events-waits-history-long-table.html" title="29.12.4.3 The events_waits_history_long Table">
<code class="literal">
events_waits_history_long
</code>
</a>
table,
contains less and less
<span class="quote">
“
<span class="quote">
noise
</span>
”
</span>
caused by
nonsignificant instruments, and given that this table has a
fixed size, contains more and more data relevant to the
analysis of the problem at hand.
</p>
<p>
With each iteration, investigation should lead closer and
closer to the root cause of the problem, as the
<span class="quote">
“
<span class="quote">
signal/noise
</span>
”
</span>
ratio improves, making analysis
easier.
</p>
</li>
<li class="listitem">
<p>
Once a root cause of performance bottleneck is identified,
take the appropriate corrective action, such as:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Tune the server parameters (cache sizes, memory, and so
forth).
</p>
</li>
<li class="listitem">
<p>
Tune a query by writing it differently,
</p>
</li>
<li class="listitem">
<p>
Tune the database schema (tables, indexes, and so forth).
</p>
</li>
<li class="listitem">
<p>
Tune the code (this applies to storage engine or server
developers only).
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
Start again at step 1, to see the effects of the changes on
performance.
</p>
</li>
</ol>
</div>
<p>
The
<code class="literal">
mutex_instances.LOCKED_BY_THREAD_ID
</code>
and
<code class="literal">
rwlock_instances.WRITE_LOCKED_BY_THREAD_ID
</code>
columns are extremely important for investigating performance
bottlenecks or deadlocks. This is made possible by Performance
Schema instrumentation as follows:
</p>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Suppose that thread 1 is stuck waiting for a mutex.
</p>
</li>
<li class="listitem">
<p>
You can determine what the thread is waiting for:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa32038304"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>events_waits_current
<span class="token keyword">WHERE</span> THREAD_ID <span class="token operator">=</span> <em class="replaceable">thread_1</em><span class="token punctuation">;</span></code></pre>
</div>
<p>
Say the query result identifies that the thread is waiting for
mutex A, found in
<code class="literal">
events_waits_current.OBJECT_INSTANCE_BEGIN
</code>
.
</p>
</li>
<li class="listitem">
<p>
You can determine which thread is holding mutex A:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa92843656"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>mutex_instances
<span class="token keyword">WHERE</span> OBJECT_INSTANCE_BEGIN <span class="token operator">=</span> <em class="replaceable">mutex_A</em><span class="token punctuation">;</span></code></pre>
</div>
<p>
Say the query result identifies that it is thread 2 holding
mutex A, as found in
<code class="literal">
mutex_instances.LOCKED_BY_THREAD_ID
</code>
.
</p>
</li>
<li class="listitem">
<p>
You can see what thread 2 is doing:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa89411573"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>events_waits_current
<span class="token keyword">WHERE</span> THREAD_ID <span class="token operator">=</span> <em class="replaceable">thread_2</em><span class="token punctuation">;</span></code></pre>
</div>
</li>
</ol>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/create-table-select.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="create-table-select">
</a>
15.1.20.4 CREATE TABLE ... SELECT Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045185318000">
</a>
<a class="indexterm" name="idm46045185316960">
</a>
<p>
You can create one table from another by adding a
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement at the end of
the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa14286032"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> <em class="replaceable">new_tbl</em> <span class="token punctuation">[</span><span class="token keyword">AS</span><span class="token punctuation">]</span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <em class="replaceable">orig_tbl</em><span class="token punctuation">;</span></code></pre>
</div>
<p>
MySQL creates new columns for all elements in the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa69317508"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> test <span class="token punctuation">(</span>a <span class="token datatype">INT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span> <span class="token keyword">AUTO_INCREMENT</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span> <span class="token punctuation">(</span>a<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">KEY</span><span class="token punctuation">(</span>b<span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">ENGINE</span><span class="token operator">=</span>InnoDB <span class="token keyword">SELECT</span> b<span class="token punctuation">,</span>c <span class="token keyword">FROM</span> test2<span class="token punctuation">;</span></code></pre>
</div>
<p>
This creates an
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
table with
three columns,
<code class="literal">
a
</code>
,
<code class="literal">
b
</code>
, and
<code class="literal">
c
</code>
. The
<code class="literal">
ENGINE
</code>
option is
part of the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement, and should not be used following the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
; this would result in a
syntax error. The same is true for other
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
options such as
<code class="literal">
CHARSET
</code>
.
</p>
<p>
Notice that the columns from the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement are appended to
the right side of the table, not overlapped onto it. Take the
following example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa54922320"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> foo<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> n <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> bar <span class="token punctuation">(</span>m <span class="token datatype">INT</span><span class="token punctuation">)</span> <span class="token keyword">SELECT</span> n <span class="token keyword">FROM</span> foo<span class="token punctuation">;</span>
<span class="token output">Query OK, 1 row affected (0.02 sec)</span>
<span class="token output">Records: 1 Duplicates: 0 Warnings: 0</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> bar<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> m <span class="token punctuation">|</span> n <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
</div>
<p>
For each row in table
<code class="literal">
foo
</code>
, a row is inserted
in
<code class="literal">
bar
</code>
with the values from
<code class="literal">
foo
</code>
and default values for the new columns.
</p>
<p>
In a table resulting from
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE ...
SELECT
</code>
</a>
, columns named only in the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
part come first.
Columns named in both parts or only in the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
part come after that. The
data type of
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
columns can
be overridden by also specifying the column in the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
part.
</p>
<p>
For storage engines that support both atomic DDL and foreign key
constraints, creation of foreign keys is not permitted in
<a class="link" href="create-table-select.html" title="15.1.20.4 CREATE TABLE ... SELECT Statement">
<code class="literal">
CREATE
TABLE ... SELECT
</code>
</a>
statements when row-based replication
is in use. Foreign key constraints can be added later using
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
.
</p>
<p>
You can precede the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
by
<code class="literal">
IGNORE
</code>
or
<code class="literal">
REPLACE
</code>
to
indicate how to handle rows that duplicate unique key values.
With
<code class="literal">
IGNORE
</code>
, rows that duplicate an existing
row on a unique key value are discarded. With
<code class="literal">
REPLACE
</code>
, new rows replace rows that have the
same unique key value. If neither
<code class="literal">
IGNORE
</code>
nor
<code class="literal">
REPLACE
</code>
is specified, duplicate unique key
values result in an error. For more information, see
<a class="xref" href="sql-mode.html#ignore-effect-on-execution" title="The Effect of IGNORE on Statement Execution">
The Effect of IGNORE on Statement Execution
</a>
.
</p>
<p>
You can also use a
<a class="link" href="values.html" title="15.2.19 VALUES Statement">
<code class="literal">
VALUES
</code>
</a>
statement in the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
part of
<code class="literal">
CREATE TABLE ... SELECT
</code>
; the
<code class="literal">
VALUES
</code>
portion of the statement must include
a table alias using an
<code class="literal">
AS
</code>
clause. To name the
columns coming from
<code class="literal">
VALUES
</code>
, supply column
aliases with the table alias; otherwise, the default column
names
<code class="literal">
column_0
</code>
,
<code class="literal">
column_1
</code>
,
<code class="literal">
column_2
</code>
, ..., are used.
</p>
<p>
Otherwise, naming of columns in the table thus created follows
the same rules as described previously in this section.
Examples:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa38714903"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> tv1
<span class="token operator">></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <span class="token punctuation">(</span><span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> v<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">TABLE</span> tv1<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> column_0 <span class="token punctuation">|</span> column_1 <span class="token punctuation">|</span> column_2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 3 <span class="token punctuation">|</span> 5 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2 <span class="token punctuation">|</span> 4 <span class="token punctuation">|</span> 6 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> tv2
<span class="token operator">></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <span class="token punctuation">(</span><span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> v<span class="token punctuation">(</span>x<span class="token punctuation">,</span>y<span class="token punctuation">,</span>z<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">TABLE</span> tv2<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> x <span class="token punctuation">|</span> y <span class="token punctuation">|</span> z <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 3 <span class="token punctuation">|</span> 5 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2 <span class="token punctuation">|</span> 4 <span class="token punctuation">|</span> 6 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> tv3 <span class="token punctuation">(</span>a <span class="token datatype">INT</span><span class="token punctuation">,</span> b <span class="token datatype">INT</span><span class="token punctuation">,</span> c <span class="token datatype">INT</span><span class="token punctuation">)</span>
<span class="token operator">></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <span class="token punctuation">(</span><span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> v<span class="token punctuation">(</span>x<span class="token punctuation">,</span>y<span class="token punctuation">,</span>z<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">TABLE</span> tv3<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a <span class="token punctuation">|</span> b <span class="token punctuation">|</span> c <span class="token punctuation">|</span> x <span class="token punctuation">|</span> y <span class="token punctuation">|</span> z <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 3 <span class="token punctuation">|</span> 5 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> 2 <span class="token punctuation">|</span> 4 <span class="token punctuation">|</span> 6 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> tv4 <span class="token punctuation">(</span>a <span class="token datatype">INT</span><span class="token punctuation">,</span> b <span class="token datatype">INT</span><span class="token punctuation">,</span> c <span class="token datatype">INT</span><span class="token punctuation">)</span>
<span class="token operator">></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <span class="token punctuation">(</span><span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> v<span class="token punctuation">(</span>x<span class="token punctuation">,</span>y<span class="token punctuation">,</span>z<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">TABLE</span> tv4<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a <span class="token punctuation">|</span> b <span class="token punctuation">|</span> c <span class="token punctuation">|</span> x <span class="token punctuation">|</span> y <span class="token punctuation">|</span> z <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 3 <span class="token punctuation">|</span> 5 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> 2 <span class="token punctuation">|</span> 4 <span class="token punctuation">|</span> 6 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> tv5 <span class="token punctuation">(</span>a <span class="token datatype">INT</span><span class="token punctuation">,</span> b <span class="token datatype">INT</span><span class="token punctuation">,</span> c <span class="token datatype">INT</span><span class="token punctuation">)</span>
<span class="token operator">></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> <span class="token punctuation">(</span><span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> v<span class="token punctuation">(</span>a<span class="token punctuation">,</span>b<span class="token punctuation">,</span>c<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">TABLE</span> tv5<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a <span class="token punctuation">|</span> b <span class="token punctuation">|</span> c <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 3 <span class="token punctuation">|</span> 5 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2 <span class="token punctuation">|</span> 4 <span class="token punctuation">|</span> 6 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
When selecting all columns and using the default column names,
you can omit
<code class="literal">
SELECT *
</code>
, so the statement just
used to create table
<code class="literal">
tv1
</code>
can also be written
as shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa74354426"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> tv1 <span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">TABLE</span> tv1<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> column_0 <span class="token punctuation">|</span> column_1 <span class="token punctuation">|</span> column_2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 3 <span class="token punctuation">|</span> 5 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 2 <span class="token punctuation">|</span> 4 <span class="token punctuation">|</span> 6 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
When using
<a class="link" href="values.html" title="15.2.19 VALUES Statement">
<code class="literal">
VALUES
</code>
</a>
as the source
of the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
, all columns are
always selected into the new table, and individual columns
cannot be selected as they can be when selecting from a named
table; each of the following statements produces an error
(
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_operand_columns" target="_top">
<code class="literal">
ER_OPERAND_COLUMNS
</code>
</a>
):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa38557289"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> tvx
<span class="token keyword">SELECT</span> <span class="token punctuation">(</span>x<span class="token punctuation">,</span>z<span class="token punctuation">)</span> <span class="token keyword">FROM</span> <span class="token punctuation">(</span><span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> v<span class="token punctuation">(</span>x<span class="token punctuation">,</span>y<span class="token punctuation">,</span>z<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> tvx <span class="token punctuation">(</span>a <span class="token datatype">INT</span><span class="token punctuation">,</span> c <span class="token datatype">INT</span><span class="token punctuation">)</span>
<span class="token keyword">SELECT</span> <span class="token punctuation">(</span>x<span class="token punctuation">,</span>z<span class="token punctuation">)</span> <span class="token keyword">FROM</span> <span class="token punctuation">(</span><span class="token keyword">VALUES</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">5</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">ROW</span><span class="token punctuation">(</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">,</span><span class="token number">6</span><span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">AS</span> v<span class="token punctuation">(</span>x<span class="token punctuation">,</span>y<span class="token punctuation">,</span>z<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Similarly, you can use a
<a class="link" href="table.html" title="15.2.16 TABLE Statement">
<code class="literal">
TABLE
</code>
</a>
statement in place of the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
.
This follows the same rules as with
<a class="link" href="values.html" title="15.2.19 VALUES Statement">
<code class="literal">
VALUES
</code>
</a>
; all columns of the source
table and their names in the source table are always inserted
into the new table. Examples:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa15549529"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">TABLE</span> t1<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a <span class="token punctuation">|</span> b <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 6 <span class="token punctuation">|</span> 7 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> <span class="token punctuation">-</span>4 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 14 <span class="token punctuation">|</span> 6 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> tt1 <span class="token keyword">TABLE</span> t1<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">TABLE</span> tt1<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> a <span class="token punctuation">|</span> b <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 6 <span class="token punctuation">|</span> 7 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> <span class="token punctuation">-</span>4 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> 14 <span class="token punctuation">|</span> 6 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> tt2 <span class="token punctuation">(</span>x <span class="token datatype">INT</span><span class="token punctuation">)</span> <span class="token keyword">TABLE</span> t1<span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">TABLE</span> tt2<span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> x <span class="token punctuation">|</span> a <span class="token punctuation">|</span> b <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> 1 <span class="token punctuation">|</span> 2 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> 6 <span class="token punctuation">|</span> 7 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> 10 <span class="token punctuation">|</span> <span class="token punctuation">-</span>4 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">|</span> NULL <span class="token punctuation">|</span> 14 <span class="token punctuation">|</span> 6 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
Because the ordering of the rows in the underlying
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statements cannot always
be determined,
<code class="literal">
CREATE TABLE ... IGNORE SELECT
</code>
and
<code class="literal">
CREATE TABLE ... REPLACE SELECT
</code>
statements are flagged as unsafe for statement-based
replication. Such statements produce a warning in the error log
when using statement-based mode and are written to the binary
log using the row-based format when using
<code class="literal">
MIXED
</code>
mode. See also
<a class="xref" href="replication-sbr-rbr.html" title="19.2.1.1 Advantages and Disadvantages of Statement-Based and Row-Based Replication">
Section 19.2.1.1, “Advantages and Disadvantages of Statement-Based and Row-Based
Replication”
</a>
.
</p>
<p>
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE ...
SELECT
</code>
</a>
does not automatically create any indexes for
you. This is done intentionally to make the statement as
flexible as possible. If you want to have indexes in the created
table, you should specify these before the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa74516547"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> bar <span class="token punctuation">(</span><span class="token keyword">UNIQUE</span> <span class="token punctuation">(</span>n<span class="token punctuation">)</span><span class="token punctuation">)</span> <span class="token keyword">SELECT</span> n <span class="token keyword">FROM</span> foo<span class="token punctuation">;</span></code></pre>
</div>
<p>
For
<code class="literal">
CREATE TABLE ... SELECT
</code>
, the destination
table does not preserve information about whether columns in the
selected-from table are generated columns. The
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
part of the statement
cannot assign values to generated columns in the destination
table.
</p>
<p>
For
<code class="literal">
CREATE TABLE ... SELECT
</code>
, the destination
table does preserve expression default values from the original
table.
</p>
<p>
Some conversion of data types might occur. For example, the
<code class="literal">
AUTO_INCREMENT
</code>
attribute is not preserved,
and
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
VARCHAR
</code>
</a>
columns can become
<a class="link" href="char.html" title="13.3.2 The CHAR and VARCHAR Types">
<code class="literal">
CHAR
</code>
</a>
columns. Retrained
attributes are
<code class="literal">
NULL
</code>
(or
<code class="literal">
NOT
NULL
</code>
) and, for those columns that have them,
<code class="literal">
CHARACTER SET
</code>
,
<code class="literal">
COLLATION
</code>
,
<code class="literal">
COMMENT
</code>
, and the
<code class="literal">
DEFAULT
</code>
clause.
</p>
<p>
When creating a table with
<a class="link" href="create-table-select.html" title="15.1.20.4 CREATE TABLE ... SELECT Statement">
<code class="literal">
CREATE
TABLE ... SELECT
</code>
</a>
, make sure to alias any function
calls or expressions in the query. If you do not, the
<code class="literal">
CREATE
</code>
statement might fail or result in
undesirable column names.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa60624195"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> artists_and_works
<span class="token keyword">SELECT</span> artist<span class="token punctuation">.</span><span class="token keyword">name</span><span class="token punctuation">,</span> <span class="token function">COUNT</span><span class="token punctuation">(</span><span class="token keyword">work</span><span class="token punctuation">.</span>artist_id<span class="token punctuation">)</span> <span class="token keyword">AS</span> number_of_works
<span class="token keyword">FROM</span> artist <span class="token keyword">LEFT</span> <span class="token keyword">JOIN</span> <span class="token keyword">work</span> <span class="token keyword">ON</span> artist<span class="token punctuation">.</span>id <span class="token operator">=</span> <span class="token keyword">work</span><span class="token punctuation">.</span>artist_id
<span class="token keyword">GROUP</span> <span class="token keyword">BY</span> artist<span class="token punctuation">.</span>id<span class="token punctuation">;</span></code></pre>
</div>
<p>
You can also explicitly specify the data type for a column in
the created table:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa38030509"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> foo <span class="token punctuation">(</span>a <span class="token datatype">TINYINT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">)</span> <span class="token keyword">SELECT</span> b<span class="token operator">+</span><span class="token number">1</span> <span class="token keyword">AS</span> a <span class="token keyword">FROM</span> bar<span class="token punctuation">;</span></code></pre>
</div>
<p>
For
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
... SELECT
</code>
</a>
, if
<code class="literal">
IF NOT EXISTS
</code>
is
given and the target table exists, nothing is inserted into the
destination table, and the statement is not logged.
</p>
<p>
To ensure that the binary log can be used to re-create the
original tables, MySQL does not permit concurrent inserts during
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE ...
SELECT
</code>
</a>
. For more information, see
<a class="xref" href="atomic-ddl.html" title="15.1.1 Atomic Data Definition Statement Support">
Section 15.1.1, “Atomic Data Definition Statement Support”
</a>
.
</p>
<p>
You cannot use
<code class="literal">
FOR UPDATE
</code>
as part of the
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
in a statement such as
<a class="link" href="create-table-select.html" title="15.1.20.4 CREATE TABLE ... SELECT Statement">
<code class="literal">
CREATE
TABLE
<em class="replaceable">
<code>
new_table
</code>
</em>
SELECT ... FROM
<em class="replaceable">
<code>
old_table
</code>
</em>
...
</code>
</a>
. If you
attempt to do so, the statement fails.
</p>
<p>
<a class="link" href="create-table-select.html" title="15.1.20.4 CREATE TABLE ... SELECT Statement">
<code class="literal">
CREATE
TABLE ... SELECT
</code>
</a>
operations apply
<code class="literal">
ENGINE_ATTRIBUTE
</code>
and
<code class="literal">
SECONDARY_ENGINE_ATTRIBUTE
</code>
values to columns
only. Table and index
<code class="literal">
ENGINE_ATTRIBUTE
</code>
and
<code class="literal">
SECONDARY_ENGINE_ATTRIBUTE
</code>
values are not
applied to the new table unless specified explicitly.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/identifier-mapping.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="identifier-mapping">
</a>
11.2.4 Mapping of Identifiers to File Names
</h3>
</div>
</div>
</div>
<p>
There is a correspondence between database and table identifiers
and names in the file system. For the basic structure, MySQL
represents each database as a directory in the data directory,
and depending upon the storage engine, each table may be
represented by one or more files in the appropriate database
directory.
</p>
<p>
For the data and index files, the exact representation on disk
is storage engine specific. These files may be stored in the
database directory, or the information may be stored in a
separate file.
<code class="literal">
InnoDB
</code>
data is stored in the
InnoDB data files. If you are using tablespaces with
<code class="literal">
InnoDB
</code>
, then the specific tablespace files
you create are used instead.
</p>
<p>
Any character is legal in database or table identifiers except
ASCII NUL (
<code class="literal">
X'00'
</code>
). MySQL encodes any
characters that are problematic in the corresponding file system
objects when it creates database directories or table files:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Basic Latin letters (
<code class="literal">
a..zA..Z
</code>
), digits
(
<code class="literal">
0..9
</code>
) and underscore
(
<code class="literal">
_
</code>
) are encoded as is. Consequently,
their case sensitivity directly depends on file system
features.
</p>
</li>
<li class="listitem">
<p>
All other national letters from alphabets that have
uppercase/lowercase mapping are encoded as shown in the
following table. Values in the Code Range column are UCS-2
values.
</p>
<div class="informaltable">
<table summary="The encoding for national letters from alphabets that have uppercase/lowercase mapping, excluding basic Latin letters (a..zA..Z), digits (0..9) and underscore (_), which are encoded as is.">
<colgroup>
<col style="width: 15%"/>
<col style="width: 15%"/>
<col style="width: 15%"/>
<col style="width: 15%"/>
<col style="width: 15%"/>
<col style="width: 25%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
Code Range
</th>
<th scope="col">
Pattern
</th>
<th scope="col">
Number
</th>
<th scope="col">
Used
</th>
<th scope="col">
Unused
</th>
<th scope="col">
Blocks
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
00C0..017F
</th>
<td>
[@][0..4][g..z]
</td>
<td>
5*20= 100
</td>
<td>
97
</td>
<td>
3
</td>
<td>
Latin-1 Supplement + Latin Extended-A
</td>
</tr>
<tr>
<th scope="row">
0370..03FF
</th>
<td>
[@][5..9][g..z]
</td>
<td>
5*20= 100
</td>
<td>
88
</td>
<td>
12
</td>
<td>
Greek and Coptic
</td>
</tr>
<tr>
<th scope="row">
0400..052F
</th>
<td>
[@][g..z][0..6]
</td>
<td>
20*7= 140
</td>
<td>
137
</td>
<td>
3
</td>
<td>
Cyrillic + Cyrillic Supplement
</td>
</tr>
<tr>
<th scope="row">
0530..058F
</th>
<td>
[@][g..z][7..8]
</td>
<td>
20*2= 40
</td>
<td>
38
</td>
<td>
2
</td>
<td>
Armenian
</td>
</tr>
<tr>
<th scope="row">
2160..217F
</th>
<td>
[@][g..z][9]
</td>
<td>
20*1= 20
</td>
<td>
16
</td>
<td>
4
</td>
<td>
Number Forms
</td>
</tr>
<tr>
<th scope="row">
0180..02AF
</th>
<td>
[@][g..z][a..k]
</td>
<td>
20*11=220
</td>
<td>
203
</td>
<td>
17
</td>
<td>
Latin Extended-B + IPA Extensions
</td>
</tr>
<tr>
<th scope="row">
1E00..1EFF
</th>
<td>
[@][g..z][l..r]
</td>
<td>
20*7= 140
</td>
<td>
136
</td>
<td>
4
</td>
<td>
Latin Extended Additional
</td>
</tr>
<tr>
<th scope="row">
1F00..1FFF
</th>
<td>
[@][g..z][s..z]
</td>
<td>
20*8= 160
</td>
<td>
144
</td>
<td>
16
</td>
<td>
Greek Extended
</td>
</tr>
<tr>
<th scope="row">
.... ....
</th>
<td>
[@][a..f][g..z]
</td>
<td>
6*20= 120
</td>
<td>
0
</td>
<td>
120
</td>
<td>
RESERVED
</td>
</tr>
<tr>
<th scope="row">
24B6..24E9
</th>
<td>
[@][@][a..z]
</td>
<td>
26
</td>
<td>
26
</td>
<td>
0
</td>
<td>
Enclosed Alphanumerics
</td>
</tr>
<tr>
<th scope="row">
FF21..FF5A
</th>
<td>
[@][a..z][@]
</td>
<td>
26
</td>
<td>
26
</td>
<td>
0
</td>
<td>
Halfwidth and Fullwidth forms
</td>
</tr>
</tbody>
</table>
</div>
<div class="informaltable">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 431px; width: 709px;">
<thead>
<tr>
<th scope="col" style="width: 106.188px;">
Code Range
</th>
<th scope="col" style="width: 106.188px;">
Pattern
</th>
<th scope="col" style="width: 106.188px;">
Number
</th>
<th scope="col" style="width: 106.188px;">
Used
</th>
<th scope="col" style="width: 106.188px;">
Unused
</th>
<th scope="col" style="width: 177.062px;">
Blocks
</th>
</tr>
</thead>
</table>
</div>
<p>
One of the bytes in the sequence encodes lettercase. For
example:
<code class="literal">
LATIN CAPITAL LETTER A WITH
GRAVE
</code>
is encoded as
<code class="literal">
@0G
</code>
,
whereas
<code class="literal">
LATIN SMALL LETTER A WITH GRAVE
</code>
is encoded as
<code class="literal">
@0g
</code>
. Here the third byte
(
<code class="literal">
G
</code>
or
<code class="literal">
g
</code>
) indicates
lettercase. (On a case-insensitive file system, both letters
are treated as the same.)
</p>
<p>
For some blocks, such as Cyrillic, the second byte
determines lettercase. For other blocks, such as Latin1
Supplement, the third byte determines lettercase. If two
bytes in the sequence are letters (as in Greek Extended),
the leftmost letter character stands for lettercase. All
other letter bytes must be in lowercase.
</p>
</li>
<li class="listitem">
<p>
All nonletter characters except underscore
(
<code class="literal">
_
</code>
), as well as letters from alphabets
that do not have uppercase/lowercase mapping (such as
Hebrew) are encoded using hexadecimal representation using
lowercase letters for hexadecimal digits
<code class="literal">
a..f
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-clike"><div class="docs-select-all right" id="sa71996784"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-clike"><span class="token number">0x003F</span> <span class="token operator">-</span><span class="token operator">></span> @003f
<span class="token number">0xFFFF</span> <span class="token operator">-</span><span class="token operator">></span> @ffff</code></pre>
</div>
<p>
The hexadecimal values correspond to character values in the
<code class="literal">
ucs2
</code>
double-byte character set.
</p>
</li>
</ul>
</div>
<p>
On Windows, some names such as
<code class="literal">
nul
</code>
,
<code class="literal">
prn
</code>
, and
<code class="literal">
aux
</code>
are encoded
by appending
<code class="literal">
@@@
</code>
to the name when the server
creates the corresponding file or directory. This occurs on all
platforms for portability of the corresponding database object
between platforms.
</p>
<p>
The following names are reserved and appended with
<code class="literal">
@@@
</code>
if used in schema or table names:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
CON
</p>
</li>
<li class="listitem">
<p>
PRN
</p>
</li>
<li class="listitem">
<p>
AUX
</p>
</li>
<li class="listitem">
<p>
NUL
</p>
</li>
<li class="listitem">
<p>
COM1 through COM9
</p>
</li>
<li class="listitem">
<p>
LPT1 through LPT9
</p>
</li>
</ul>
</div>
<p>
CLOCK$ is also a member of this group of reserved names, but is
not appended with
<code class="literal">
@@@
</code>
, but
<code class="literal">
@0024
</code>
instead. That is, if CLOCK$ is used as
a schema or table name, it is written to the file system as
<code class="filename">
CLOCK@0024
</code>
. The same is true for any use of
$ (dollar sign) in a schema or table name; it is replaced with
<code class="filename">
@0024
</code>
on the filesystem.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
These names are also written to
<a class="link" href="information-schema-innodb-tables-table.html" title="28.4.23 The INFORMATION_SCHEMA INNODB_TABLES Table">
<code class="literal">
INNODB_TABLES
</code>
</a>
in their appended
forms, but are written to
<a class="link" href="information-schema-tables-table.html" title="28.3.38 The INFORMATION_SCHEMA TABLES Table">
<code class="literal">
TABLES
</code>
</a>
in their unappended form, as entered by the user.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/nested-loop-joins.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="nested-loop-joins">
</a>
10.2.1.7 Nested-Loop Join Algorithms
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045229583488">
</a>
<a class="indexterm" name="idm46045229582432">
</a>
<a class="indexterm" name="idm46045229580944">
</a>
<a class="indexterm" name="idm46045229579856">
</a>
<p>
MySQL executes joins between tables using a nested-loop
algorithm or variations on it.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="xref" href="nested-loop-joins.html#nested-loop-join-algorithm" title="Nested-Loop Join Algorithm">
Nested-Loop Join Algorithm
</a>
</p>
</li>
</ul>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="nested-loop-join-algorithm">
</a>
Nested-Loop Join Algorithm
</h5>
</div>
</div>
</div>
<p>
A simple nested-loop join (NLJ) algorithm reads rows from
the first table in a loop one at a time, passing each row to
a nested loop that processes the next table in the join.
This process is repeated as many times as there remain
tables to be joined.
</p>
<p>
Assume that a join between three tables
<code class="literal">
t1
</code>
,
<code class="literal">
t2
</code>
, and
<code class="literal">
t3
</code>
is to be executed using the following
join types:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa19208388"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">Table Join Type
t1 range
t2 ref
t3 ALL</code></pre>
</div>
<p>
If a simple NLJ algorithm is used, the join is processed
like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-clike"><div class="docs-select-all right" id="sa64464486"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-clike"><span class="token keyword">for</span> each row <span class="token keyword">in</span> t1 matching range <span class="token punctuation">{</span>
<span class="token keyword">for</span> each row <span class="token keyword">in</span> t2 matching reference key <span class="token punctuation">{</span>
<span class="token keyword">for</span> each row <span class="token keyword">in</span> t3 <span class="token punctuation">{</span>
<span class="token keyword">if</span> row satisfies join conditions<span class="token punctuation">,</span> send to client
<span class="token punctuation">}</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
</div>
<p>
Because the NLJ algorithm passes rows one at a time from
outer loops to inner loops, it typically reads tables
processed in the inner loops many times.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-replication-probes-and-statistics.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="group-replication-probes-and-statistics">
</a>
20.7.2.1 Probes and Statistics
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045132204592">
</a>
<p>
The monitoring mechanism works by having each member deploying a
set of probes to collect information about its work queues and
throughput. It then propagates that information to the group
periodically to share that data with the other members.
</p>
<p>
Such probes are scattered throughout the plugin stack and allow
one to establish metrics, such as:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
the certifier queue size;
</p>
</li>
<li class="listitem">
<p>
the replication applier queue size;
</p>
</li>
<li class="listitem">
<p>
the total number of transactions certified;
</p>
</li>
<li class="listitem">
<p>
the total number of remote transactions applied in the
member;
</p>
</li>
<li class="listitem">
<p>
the total number of local transactions.
</p>
</li>
</ul>
</div>
<p>
Once a member receives a message with statistics from another
member, it calculates additional metrics regarding how many
transactions were certified, applied and locally executed in the
last monitoring period.
</p>
<p>
Monitoring data is shared with others in the group periodically.
The monitoring period must be high enough to allow the other
members to decide on the current write requests, but low enough
that it has minimal impact on group bandwidth. The information
is shared every second, and this period is sufficient to address
both concerns.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-channels.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="replication-channels">
</a>
19.2.2 Replication Channels
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="channels-commands-single-channel.html">
19.2.2.1 Commands for Operations on a Single Channel
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="channels-with-prev-replication.html">
19.2.2.2 Compatibility with Previous Replication Statements
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="channels-startup-options.html">
19.2.2.3 Startup Options and Replication Channels
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="channels-naming-conventions.html">
19.2.2.4 Replication Channel Naming Conventions
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045138188240">
</a>
<a class="indexterm" name="idm46045138187168">
</a>
<p>
In MySQL multi-source replication, a replica opens multiple
replication channels, one for each source server. The replication
channels represent the path of transactions flowing from a source to
the replica. Each replication channel has its own receiver (I/O)
thread, one or more applier (SQL) threads, and relay log. When
transactions from a source are received by a channel's receiver
thread, they are added to the channel's relay log file and
passed through to the channel's applier threads. This enables each
channel to function independently.
</p>
<p>
This section describes how channels can be used in a replication
topology, and the impact they have on single-source replication. For
instructions to configure sources and replicas for multi-source
replication, to start, stop and reset multi-source replicas, and to
monitor multi-source replication, see
<a class="xref" href="replication-multi-source.html" title="19.1.5 MySQL Multi-Source Replication">
Section 19.1.5, “MySQL Multi-Source Replication”
</a>
.
</p>
<p>
The maximum number of channels that can be created on one replica
server in a multi-source replication topology is 256. Each
replication channel must have a unique (nonempty) name, as explained
in
<a class="xref" href="channels-naming-conventions.html" title="19.2.2.4 Replication Channel Naming Conventions">
Section 19.2.2.4, “Replication Channel Naming Conventions”
</a>
. The error codes
and messages that are issued when multi-source replication is
enabled specify the channel that generated the error.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Each channel on a multi-source replica must replicate from a
different source. You cannot set up multiple replication channels
from a single replica to a single source. This is because the
server IDs of replicas must be unique in a replication topology.
The source distinguishes replicas only by their server IDs, not by
the names of the replication channels, so it cannot recognize
different replication channels from the same replica.
</p>
</div>
<p>
A multi-source replica can also be set up as a multi-threaded
replica, by setting the system variable
<a class="link" href="replication-options-replica.html#sysvar_replica_parallel_workers">
<code class="literal">
replica_parallel_workers
</code>
</a>
to a value
greater than 0. When you do this on a multi-source replica, each
channel on the replica has the specified number of applier threads,
plus a coordinator thread to manage them. You cannot configure the
number of applier threads for individual channels.
</p>
<p>
Multi-source replicas can be configured with replication filters on
specific replication channels. Channel specific replication filters
can be used when the same database or table is present on multiple
sources, and you only need the replica to replicate it from one
source. For GTID-based replication, if the same transaction might
arrive from multiple sources (such as in a diamond topology), you
must ensure the filtering setup is the same on all channels. For
more information, see
<a class="xref" href="replication-rules-channel-based-filters.html" title="19.2.5.4 Replication Channel Based Filters">
Section 19.2.5.4, “Replication Channel Based Filters”
</a>
.
</p>
<p>
To provide compatibility with previous versions, the MySQL server
automatically creates on startup a default channel whose name is the
empty string (
<code class="literal">
""
</code>
). This channel is always
present; it cannot be created or destroyed by the user. If no other
channels (having nonempty names) have been created, replication
statements act on the default channel only, so that all replication
statements from older replicas function as expected (see
<a class="xref" href="channels-with-prev-replication.html" title="19.2.2.2 Compatibility with Previous Replication Statements">
Section 19.2.2.2, “Compatibility with Previous Replication Statements”
</a>
. Statements
applying to replication channels as described in this section can be
used only when there is at least one named channel.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/information-schema-character-sets-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="information-schema-character-sets-table">
</a>
28.3.4 The INFORMATION_SCHEMA CHARACTER_SETS Table
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045080333712">
</a>
<p>
The
<a class="link" href="information-schema-character-sets-table.html" title="28.3.4 The INFORMATION_SCHEMA CHARACTER_SETS Table">
<code class="literal">
CHARACTER_SETS
</code>
</a>
table provides
information about available character sets.
</p>
<p>
The
<a class="link" href="information-schema-character-sets-table.html" title="28.3.4 The INFORMATION_SCHEMA CHARACTER_SETS Table">
<code class="literal">
CHARACTER_SETS
</code>
</a>
table has these
columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
CHARACTER_SET_NAME
</code>
</p>
<p>
The character set name.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DEFAULT_COLLATE_NAME
</code>
</p>
<p>
The default collation for the character set.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DESCRIPTION
</code>
</p>
<p>
A description of the character set.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
MAXLEN
</code>
</p>
<p>
The maximum number of bytes required to store one character.
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045080320784">
</a>
Notes
</h4>
<p>
Character set information is also available from the
<a class="link" href="show-character-set.html" title="15.7.7.4 SHOW CHARACTER SET Statement">
<code class="literal">
SHOW CHARACTER SET
</code>
</a>
statement. See
<a class="xref" href="show-character-set.html" title="15.7.7.4 SHOW CHARACTER SET Statement">
Section 15.7.7.4, “SHOW CHARACTER SET Statement”
</a>
. The following statements are
equivalent:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa93165941"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>CHARACTER_SETS
<span class="token punctuation">[</span><span class="token keyword">WHERE</span> CHARACTER_SET_NAME <span class="token operator">LIKE</span> <span class="token string">'<em class="replaceable">wild</em>'</span><span class="token punctuation">]</span>
<span class="token keyword">SHOW</span> <span class="token keyword">CHARACTER</span> <span class="token keyword">SET</span>
<span class="token punctuation">[</span><span class="token operator">LIKE</span> <span class="token string">'<em class="replaceable">wild</em>'</span><span class="token punctuation">]</span></code></pre>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-status-variable-tables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="performance-schema-status-variable-tables">
</a>
29.12.15 Performance Schema Status Variable Tables
</h3>
</div>
</div>
</div>
<p>
The MySQL server maintains many status variables that provide
information about its operation (see
<a class="xref" href="server-status-variables.html" title="7.1.10 Server Status Variables">
Section 7.1.10, “Server Status Variables”
</a>
). Status variable
information is available in these Performance Schema tables:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
global_status
</code>
</a>
: Global status
variables. An application that wants only global values
should use this table.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
session_status
</code>
</a>
: Status
variables for the current session. An application that wants
all status variable values for its own session should use
this table. It includes the session variables for its
session, as well as the values of global variables that have
no session counterpart.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
status_by_thread
</code>
</a>
: Session
status variables for each active session. An application
that wants to know the session variable values for specific
sessions should use this table. It includes session
variables only, identified by thread ID.
</p>
</li>
</ul>
</div>
<p>
There are also summary tables that provide status variable
information aggregated by account, host name, and user name. See
<a class="xref" href="performance-schema-status-variable-summary-tables.html" title="29.12.20.12 Status Variable Summary Tables">
Section 29.12.20.12, “Status Variable Summary Tables”
</a>
.
</p>
<p>
The session variable tables
(
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
session_status
</code>
</a>
,
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
status_by_thread
</code>
</a>
) contain
information only for active sessions, not terminated sessions.
</p>
<p>
The Performance Schema collects statistics for global status
variables only for threads for which the
<code class="literal">
INSTRUMENTED
</code>
value is
<code class="literal">
YES
</code>
in the
<a class="link" href="performance-schema-threads-table.html" title="29.12.22.8 The threads Table">
<code class="literal">
threads
</code>
</a>
table. Statistics
for session status variables are always collected, regardless of
the
<code class="literal">
INSTRUMENTED
</code>
value.
</p>
<p>
The Performance Schema does not collect statistics for
<code class="literal">
Com_
<em class="replaceable">
<code>
xxx
</code>
</em>
</code>
status
variables in the status variable tables. To obtain global and
per-session statement execution counts, use the
<a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
<code class="literal">
events_statements_summary_global_by_event_name
</code>
</a>
and
<a class="link" href="performance-schema-statement-summary-tables.html" title="29.12.20.3 Statement Summary Tables">
<code class="literal">
events_statements_summary_by_thread_by_event_name
</code>
</a>
tables, respectively. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa99193409"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> EVENT_NAME<span class="token punctuation">,</span> COUNT_STAR
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>events_statements_summary_global_by_event_name
<span class="token keyword">WHERE</span> EVENT_NAME <span class="token operator">LIKE</span> <span class="token string">'statement/sql/%'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
global_status
</code>
</a>
and
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
session_status
</code>
</a>
tables have these
columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
VARIABLE_NAME
</code>
</p>
<p>
The status variable name.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VARIABLE_VALUE
</code>
</p>
<p>
The status variable value. For
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
global_status
</code>
</a>
, this column
contains the global value. For
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
session_status
</code>
</a>
, this column
contains the variable value for the current session.
</p>
</li>
</ul>
</div>
<p>
The
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
global_status
</code>
</a>
and
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
session_status
</code>
</a>
tables have these
indexes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
VARIABLE_NAME
</code>
)
</p>
</li>
</ul>
</div>
<p>
The
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
status_by_thread
</code>
</a>
table contains
the status of each active thread. It has these columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
THREAD_ID
</code>
</p>
<p>
The thread identifier of the session in which the status
variable is defined.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VARIABLE_NAME
</code>
</p>
<p>
The status variable name.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
VARIABLE_VALUE
</code>
</p>
<p>
The session variable value for the session named by the
<code class="literal">
THREAD_ID
</code>
column.
</p>
</li>
</ul>
</div>
<p>
The
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
status_by_thread
</code>
</a>
table has
these indexes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
THREAD_ID
</code>
,
<code class="literal">
VARIABLE_NAME
</code>
)
</p>
</li>
</ul>
</div>
<p>
The
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
status_by_thread
</code>
</a>
table contains
status variable information only about foreground threads. If
the
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_max_thread_instances">
<code class="literal">
performance_schema_max_thread_instances
</code>
</a>
system variable is not autoscaled (signified by a value of
−1) and the maximum permitted number of instrumented
thread objects is not greater than the number of background
threads, the table is empty.
</p>
<p>
The Performance Schema supports
<a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
<code class="literal">
TRUNCATE
TABLE
</code>
</a>
for status variable tables as follows:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
global_status
</code>
</a>
: Resets thread,
account, host, and user status. Resets global status
variables except those that the server never resets.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
session_status
</code>
</a>
: Not supported.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-status-variable-tables.html" title="29.12.15 Performance Schema Status Variable Tables">
<code class="literal">
status_by_thread
</code>
</a>
: Aggregates
status for all threads to the global status and account
status, then resets thread status. If account statistics are
not collected, the session status is added to host and user
status, if host and user status are collected.
</p>
<p>
Account, host, and user statistics are not collected if the
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_accounts_size">
<code class="literal">
performance_schema_accounts_size
</code>
</a>
,
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_hosts_size">
<code class="literal">
performance_schema_hosts_size
</code>
</a>
,
and
<a class="link" href="performance-schema-system-variables.html#sysvar_performance_schema_users_size">
<code class="literal">
performance_schema_users_size
</code>
</a>
system variables, respectively, are set to 0.
</p>
</li>
</ul>
</div>
<p>
<a class="link" href="flush.html#flush-status">
<code class="literal">
FLUSH STATUS
</code>
</a>
adds the session
status from all active sessions to the global status variables,
resets the status of all active sessions, and resets account,
host, and user status values aggregated from disconnected
sessions.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/entering-queries.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="entering-queries">
</a>
5.2 Entering Queries
</h2>
</div>
</div>
</div>
<a class="indexterm" name="idm46045325644992">
</a>
<a class="indexterm" name="idm46045325643504">
</a>
<a class="indexterm" name="idm46045325642016">
</a>
<p>
Make sure that you are connected to the server, as discussed in
the previous section. Doing so does not in itself select any
database to work with, but that is okay. At this point, it is more
important to find out a little about how to issue queries than to
jump right in creating tables, loading data into them, and
retrieving data from them. This section describes the basic
principles of entering queries, using several queries you can try
out to familiarize yourself with how
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
works.
</p>
<p>
Here is a simple query that asks the server to tell you its
version number and the current date. Type it in as shown here
following the
<code class="literal">
mysql>
</code>
prompt and press Enter:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa71310189"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">VERSION</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">CURRENT_DATE</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> VERSION() <span class="token punctuation">|</span> CURRENT_DATE <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 8.4.0<span class="token punctuation">-</span>tr <span class="token punctuation">|</span> 2024<span class="token punctuation">-</span>01<span class="token punctuation">-</span>25 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span>
<span class="token prompt">mysql></span></code></pre>
</div>
<p>
This query illustrates several things about
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
A query normally consists of an SQL statement followed by a
semicolon. (There are some exceptions where a semicolon may be
omitted.
<code class="literal">
QUIT
</code>
, mentioned earlier, is one of
them. We'll get to others later.)
</p>
</li>
<li class="listitem">
<p>
When you issue a query,
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
sends it to
the server for execution and displays the results, then prints
another
<code class="literal">
mysql>
</code>
prompt to indicate that
it is ready for another query.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
displays query output in tabular form
(rows and columns). The first row contains labels for the
columns. The rows following are the query results. Normally,
column labels are the names of the columns you fetch from
database tables. If you're retrieving the value of an
expression rather than a table column (as in the example just
shown),
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
labels the column using the
expression itself.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
shows how many rows were returned and
how long the query took to execute, which gives you a rough
idea of server performance. These values are imprecise because
they represent wall clock time (not CPU or machine time), and
because they are affected by factors such as server load and
network latency. (For brevity, the
<span class="quote">
“
<span class="quote">
rows in set
</span>
”
</span>
line is sometimes not shown in the remaining examples in this
chapter.)
</p>
</li>
</ul>
</div>
<p>
Keywords may be entered in any lettercase. The following queries
are equivalent:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa23261091"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">VERSION</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">CURRENT_DATE</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">select</span> <span class="token function">version</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">current_date</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">SeLeCt</span> <span class="token function">vErSiOn</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token keyword">current_DATE</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Here is another query. It demonstrates that you can use
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
as a simple calculator:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa97979266"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">SIN</span><span class="token punctuation">(</span><span class="token function">PI</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator">/</span><span class="token number">4</span><span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token punctuation">(</span><span class="token number">4</span><span class="token operator">+</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token operator">*</span><span class="token number">5</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> SIN(PI()/4) <span class="token punctuation">|</span> (4<span class="token punctuation">+</span>1)*5 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 0.70710678118655 <span class="token punctuation">|</span> 25 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.02 sec)</span></code></pre>
</div>
<p>
The queries shown thus far have been relatively short, single-line
statements. You can even enter multiple statements on a single
line. Just end each one with a semicolon:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa46000823"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">VERSION</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span> <span class="token keyword">SELECT</span> <span class="token function">NOW</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> VERSION() <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 8.4.0<span class="token punctuation">-</span>tr <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> NOW() <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> 2024<span class="token punctuation">-</span>01<span class="token punctuation">-</span>25 18:33:04 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output">1 row in set (0.00 sec)</span></code></pre>
</div>
<p>
A query need not be given all on a single line, so lengthy queries
that require several lines are not a problem.
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
determines where your statement ends by
looking for the terminating semicolon, not by looking for the end
of the input line. (In other words,
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
accepts free-format input: it collects input lines but does not
execute them until it sees the semicolon.)
</p>
<p>
Here is a simple multiple-line statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa91167729"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span>
<span class="token prompt"> -></span> <span class="token function">USER</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">CURRENT_DATE</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> USER() <span class="token punctuation">|</span> CURRENT_DATE <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> jon@localhost <span class="token punctuation">|</span> 2018<span class="token punctuation">-</span>08<span class="token punctuation">-</span>24 <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
In this example, notice how the prompt changes from
<code class="literal">
mysql>
</code>
to
<code class="literal">
->
</code>
after you
enter the first line of a multiple-line query. This is how
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
indicates that it has not yet seen a
complete statement and is waiting for the rest. The prompt is your
friend, because it provides valuable feedback. If you use that
feedback, you can always be aware of what
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
is waiting for.
</p>
<p>
If you decide you do not want to execute a query that you are in
the process of entering, cancel it by typing
<code class="literal">
\c
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa15211615"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span>
<span class="token prompt"> -></span> <span class="token function">USER</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> \c
<span class="token prompt">mysql></span></code></pre>
</div>
<p>
Here, too, notice the prompt. It switches back to
<code class="literal">
mysql>
</code>
after you type
<code class="literal">
\c
</code>
,
providing feedback to indicate that
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
is
ready for a new query.
</p>
<p>
The following table shows each of the prompts you may see and
summarizes what they mean about the state that
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
is in.
</p>
<a class="indexterm" name="idm46045325590672">
</a>
<div class="informaltable">
<table summary="MySQL prompts and the meaning of each prompt.">
<colgroup>
<col style="width: 10%"/>
<col style="width: 80%"/>
</colgroup>
<thead>
<tr>
<th>
Prompt
</th>
<th>
Meaning
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<code class="literal">
mysql>
</code>
</td>
<td>
Ready for new query
</td>
</tr>
<tr>
<td>
<code class="literal">
->
</code>
</td>
<td>
Waiting for next line of multiple-line query
</td>
</tr>
<tr>
<td>
<code class="literal">
'>
</code>
</td>
<td>
Waiting for next line, waiting for completion of a string that began
with a single quote (
<code class="literal">
'
</code>
)
</td>
</tr>
<tr>
<td>
<code class="literal">
">
</code>
</td>
<td>
Waiting for next line, waiting for completion of a string that began
with a double quote (
<code class="literal">
"
</code>
)
</td>
</tr>
<tr>
<td>
<code class="literal">
`>
</code>
</td>
<td>
Waiting for next line, waiting for completion of an identifier that
began with a backtick (
<code class="literal">
`
</code>
)
</td>
</tr>
<tr>
<td>
<code class="literal">
/*>
</code>
</td>
<td>
Waiting for next line, waiting for completion of a comment that began
with
<code class="literal">
/*
</code>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Multiple-line statements commonly occur by accident when you
intend to issue a query on a single line, but forget the
terminating semicolon. In this case,
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
waits for more input:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa51716689"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">USER</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span></code></pre>
</div>
<p>
If this happens to you (you think you've entered a statement but
the only response is a
<code class="literal">
->
</code>
prompt), most
likely
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
is waiting for the semicolon. If
you don't notice what the prompt is telling you, you might sit
there for a while before realizing what you need to do. Enter a
semicolon to complete the statement, and
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
executes it:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa4659601"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token function">USER</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> USER() <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> jon@localhost <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
The
<code class="literal">
'>
</code>
and
<code class="literal">
">
</code>
prompts
occur during string collection (another way of saying that MySQL
is waiting for completion of a string). In MySQL, you can write
strings surrounded by either
<code class="literal">
'
</code>
or
<code class="literal">
"
</code>
characters (for example,
<code class="literal">
'hello'
</code>
or
<code class="literal">
"goodbye"
</code>
), and
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
lets you enter strings that span multiple
lines. When you see a
<code class="literal">
'>
</code>
or
<code class="literal">
">
</code>
prompt, it means that you have entered a
line containing a string that begins with a
<code class="literal">
'
</code>
or
<code class="literal">
"
</code>
quote character, but have not yet entered
the matching quote that terminates the string. This often
indicates that you have inadvertently left out a quote character.
For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa7300027"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> my_table <span class="token keyword">WHERE</span> <span class="token keyword">name</span> <span class="token operator">=</span> <span class="token string">'Smith AND age < 30;
'</span><span class="token operator">></span></code></pre>
</div>
<p>
If you enter this
<a class="link" href="select.html" title="15.2.13 SELECT Statement">
<code class="literal">
SELECT
</code>
</a>
statement,
then press
<span class="keycap">
<strong>
Enter
</strong>
</span>
and wait for the result, nothing
happens. Instead of wondering why this query takes so long, notice
the clue provided by the
<code class="literal">
'>
</code>
prompt. It tells
you that
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
expects to see the rest of an
unterminated string. (Do you see the error in the statement? The
string
<code class="literal">
'Smith
</code>
is missing the second single
quotation mark.)
</p>
<p>
At this point, what do you do? The simplest thing is to cancel the
query. However, you cannot just type
<code class="literal">
\c
</code>
in this
case, because
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
interprets it as part of
the string that it is collecting. Instead, enter the closing quote
character (so
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
knows you've finished the
string), then type
<code class="literal">
\c
</code>
:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa2385785"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> my_table <span class="token keyword">WHERE</span> <span class="token keyword">name</span> <span class="token operator">=</span> <span class="token string">'Smith AND age < 30;
'</span><span class="token operator">></span> '\c
<span class="token prompt">mysql></span></code></pre>
</div>
<p>
The prompt changes back to
<code class="literal">
mysql>
</code>
,
indicating that
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
is ready for a new query.
</p>
<p>
The
<code class="literal">
`>
</code>
prompt is similar to the
<code class="literal">
'>
</code>
and
<code class="literal">
">
</code>
prompts, but
indicates that you have begun but not completed a backtick-quoted
identifier.
</p>
<p>
It is important to know what the
<code class="literal">
'>
</code>
,
<code class="literal">
">
</code>
, and
<code class="literal">
`>
</code>
prompts
signify, because if you mistakenly enter an unterminated string,
any further lines you type appear to be ignored by
<a class="link" href="mysql.html" title="6.5.1 mysql — The MySQL Command-Line Client">
<span class="command">
<strong>
mysql
</strong>
</span>
</a>
—including a line containing
<code class="literal">
QUIT
</code>
. This can be quite confusing, especially
if you do not know that you need to supply the terminating quote
before you can cancel the current query.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Multiline statements from this point on are written without the
secondary (
<code class="literal">
->
</code>
or other) prompts, to make
it easier to copy and paste the statements to try for yourself.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replica-logs-status.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="replica-logs-status">
</a>
19.2.4.2 Replication Metadata Repositories
</h4>
</div>
</div>
</div>
<p>
A replica server creates two replication metadata repositories,
the connection metadata repository and the applier metadata
repository. The replication metadata repositories survive a
replica server's shutdown. If binary log file position
based replication is in use, when the replica restarts, it reads
the two repositories to determine how far it previously
proceeded in reading the binary log from the source and in
processing its own relay log. If GTID-based replication is in
use, the replica does not use the replication metadata
repositories for that purpose, but does need them for the other
metadata that they contain.
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The replica's
<span class="emphasis">
<em>
connection metadata
repository
</em>
</span>
contains information that the
replication I/O (receiver) thread needs to connect to the
replication source server and retrieve transactions from the
source's binary log. The metadata in this repository
includes the connection configuration, the replication user
account details, the SSL settings for the connection, and
the file name and position where the replication receiver
thread is currently reading from the source's binary log.
</p>
</li>
<li class="listitem">
<p>
The replica's
<span class="emphasis">
<em>
applier metadata
repository
</em>
</span>
contains information that the
replication SQL (applier) thread needs to read and apply
transactions from the replica's relay log. The metadata in
this repository includes the file name and position up to
which the replication applier thread has executed the
transactions in the relay log, and the equivalent position
in the source's binary log. It also includes metadata for
the process of applying transactions, such as the number of
worker threads and the
<code class="literal">
PRIVILEGE_CHECKS_USER
</code>
account for the
channel.
</p>
</li>
</ul>
</div>
<p>
The connection metadata repository is written to the
<code class="literal">
slave_master_info
</code>
table in the
<code class="literal">
mysql
</code>
system schema, and the applier metadata
repository is written to the
<code class="literal">
slave_relay_log_info
</code>
table in the
<code class="literal">
mysql
</code>
system schema. A warning message is
issued if
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
is unable to initialize the
tables for the replication metadata repositories, but the
replica is allowed to continue starting. This situation is most
likely to occur when upgrading from a version of MySQL that does
not support the use of tables for the repositories to one in
which they are supported.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<div class="orderedlist">
<ol class="orderedlist" type="1">
<li class="listitem">
<p>
Do not attempt to update or insert rows in the
<code class="literal">
mysql.slave_master_info
</code>
or
<code class="literal">
mysql.slave_relay_log_info
</code>
tables
manually. Doing so can cause undefined behavior, and is
not supported. Execution of any statement requiring a
write lock on either or both of the
<code class="literal">
slave_master_info
</code>
and
<code class="literal">
slave_relay_log_info
</code>
tables is
disallowed while replication is ongoing (although
statements that perform only reads are permitted at any
time).
</p>
</li>
<li class="listitem">
<p>
Access privileges for the connection metadata repository
table
<code class="literal">
mysql.slave_master_info
</code>
should be
restricted to the database administrator, because it
contains the replication user account name and password
for connecting to the source. Use a restricted access mode
to protect database backups that include this table. You
can clear the replication user account credentials from
the connection metadata repository, and instead always
provide them using a
<a class="link" href="start-replica.html" title="15.4.2.4 START REPLICA Statement">
<code class="literal">
START
REPLICA
</code>
</a>
statement to start the replication
channel. This approach means that the replication channel
always needs operator intervention to restart, but the
account name and password are not recorded in the
replication metadata repositories.
</p>
</li>
</ol>
</div>
</div>
<p>
<a class="link" href="reset-replica.html" title="15.4.2.3 RESET REPLICA Statement">
<code class="literal">
RESET REPLICA
</code>
</a>
clears the data in
the replication metadata repositories, with the exception of the
replication connection parameters (depending on the MySQL Server
release). For details, see the description for
<a class="link" href="reset-replica.html" title="15.4.2.3 RESET REPLICA Statement">
<code class="literal">
RESET REPLICA
</code>
</a>
.
</p>
<p>
You can set the
<code class="literal">
GTID_ONLY
</code>
option of the
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
</a>
statement to stop a replication channel from persisting file
names and file positions in the replication metadata
repositories. This avoids writes and reads to the tables in
situations where GTID-based replication does not actually
require them. With the
<code class="literal">
GTID_ONLY
</code>
setting, the
connection metadata repository and the applier metadata
repository are not updated when the replica queues and applies
events in a transaction, or when the replication threads are
stopped and started. File positions are tracked in memory, and
can be viewed using
<a class="link" href="show-replica-status.html" title="15.7.7.35 SHOW REPLICA STATUS Statement">
<code class="literal">
SHOW REPLICA
STATUS
</code>
</a>
if they are needed. The replication metadata
repositories are only synchronized in the following situations:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
When a
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION SOURCE
TO
</code>
</a>
statement is issued.
</p>
</li>
<li class="listitem">
<p>
When a
<a class="link" href="reset-replica.html" title="15.4.2.3 RESET REPLICA Statement">
<code class="literal">
RESET REPLICA
</code>
</a>
statement is issued.
<code class="literal">
RESET REPLICA ALL
</code>
deletes rather than updates the repositories, so they are
synchronized implicitly.
</p>
</li>
<li class="listitem">
<p>
When a replication channel is initialized.
</p>
</li>
<li class="listitem">
<p>
If the replication metadata repositories are moved from
files to tables.
</p>
</li>
</ul>
</div>
<p>
Creating the replication metadata repositories as tables is the
default; the use of files is deprecated.
</p>
<p>
The
<code class="literal">
mysql.slave_master_info
</code>
and
<code class="literal">
mysql.slave_relay_log_info
</code>
tables are created
using the
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
transactional
storage engine. Updates to the applier metadata repository table
are committed together with the transactions, meaning that the
replica's progress information recorded in that repository is
always consistent with what has been applied to the database,
even in the event of an unexpected server halt. For information
on the combination of settings on a replica that is most
resilient to unexpected halts, see
<a class="xref" href="replication-solutions-unexpected-replica-halt.html" title="19.4.2 Handling an Unexpected Halt of a Replica">
Section 19.4.2, “Handling an Unexpected Halt of a Replica”
</a>
.
</p>
<p>
When you back up the replica's data or transfer a snapshot of
its data to create a new replica, ensure that you include the
<code class="literal">
mysql.slave_master_info
</code>
and
<code class="literal">
mysql.slave_relay_log_info
</code>
tables containing
the replication metadata repositories. For cloning operations,
note that when the replication metadata repositories are created
as tables, they are copied to the recipient during a cloning
operation, but when they are created as files, they are not
copied. When binary log file position based replication is in
use, the replication metadata repositories are needed to resume
replication after restarting the restored, copied, or cloned
replica. If you do not have the relay log files, but still have
the applier metadata repository, you can check it to determine
how far the replication SQL thread has executed in the source's
binary log. Then you can use a
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE
REPLICATION SOURCE TO
</code>
</a>
statement with the
<code class="literal">
SOURCE_LOG_FILE
</code>
and
<code class="literal">
SOURCE_LOG_POS
</code>
options to tell the replica to
re-read the binary logs from the source from that point
(provided that the required binary logs still exist on the
source).
</p>
<p>
One additional repository, the applier worker metadata
repository, is created primarily for internal use, and holds
status information about worker threads on a multithreaded
replica. The applier worker metadata repository includes the
names and positions for the relay log file and the source's
binary log file for each worker thread. If the applier metadata
repository is created as a table, which is the default, the
applier worker metadata repository is written to the
<code class="literal">
mysql.slave_worker_info
</code>
table. If the applier
metadata repository is written to a file, the applier worker
metadata repository is written to the
<code class="filename">
worker-relay-log.info
</code>
file. For external
use, status information for worker threads is presented in the
Performance Schema
<a class="link" href="performance-schema-replication-applier-status-by-worker-table.html" title="29.12.11.7 The replication_applier_status_by_worker Table">
<code class="literal">
replication_applier_status_by_worker
</code>
</a>
table.
</p>
<p>
The replication metadata repositories originally contained
information similar to that shown in the output of the
<a class="link" href="show-replica-status.html" title="15.7.7.35 SHOW REPLICA STATUS Statement">
<code class="literal">
SHOW REPLICA STATUS
</code>
</a>
statement,
which is discussed in
<a class="xref" href="replication-statements-replica.html" title="15.4.2 SQL Statements for Controlling Replica Servers">
Section 15.4.2, “SQL Statements for Controlling Replica Servers”
</a>
. Further
information has since been added to the replication metadata
repositories which is not displayed by the
<a class="link" href="show-replica-status.html" title="15.7.7.35 SHOW REPLICA STATUS Statement">
<code class="literal">
SHOW REPLICA STATUS
</code>
</a>
statement.
</p>
<p>
For the connection metadata repository, the following table
shows the correspondence between the columns in the
<code class="literal">
mysql.slave_master_info
</code>
table, the columns
displayed by
<a class="link" href="show-replica-status.html" title="15.7.7.35 SHOW REPLICA STATUS Statement">
<code class="literal">
SHOW REPLICA STATUS
</code>
</a>
,
and the lines in the deprecated
<code class="filename">
master.info
</code>
file.
</p>
<div class="informaltable">
<table summary="The correspondence between the columns in the mysql.slave_master_info table, the columns displayed by SHOW REPLICA STATUS, and the lines in the deprecated master.info file.">
<colgroup>
<col style="width: 31%"/>
<col style="width: 40%"/>
<col style="width: 16%"/>
<col style="width: 18%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
<code class="literal">
slave_master_info
</code>
Table Column
</th>
<th scope="col">
<code class="literal">
SHOW REPLICA STATUS
</code>
Column
</th>
<th scope="col">
<code class="filename">
master.info
</code>
File Line
</th>
<th scope="col">
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<code class="literal">
Number_of_lines
</code>
</th>
<td>
[None]
</td>
<td>
1
</td>
<td>
Number of columns in the table (or lines in the file)
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Master_log_name
</code>
</th>
<td>
<code class="literal">
Source_Log_File
</code>
</td>
<td>
2
</td>
<td>
The name of the binary log currently being read from the source
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Master_log_pos
</code>
</th>
<td>
<code class="literal">
Read_Source_Log_Pos
</code>
</td>
<td>
3
</td>
<td>
The current position within the binary log that has been read from the
source
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Host
</code>
</th>
<td>
<code class="literal">
Source_Host
</code>
</td>
<td>
4
</td>
<td>
The host name of the replication source server
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
User_name
</code>
</th>
<td>
<code class="literal">
Source_User
</code>
</td>
<td>
5
</td>
<td>
The replication user account name used to connect to the source
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
User_password
</code>
</th>
<td>
Password (not shown by
<a class="link" href="show-replica-status.html" title="15.7.7.35 SHOW REPLICA STATUS Statement">
<code class="literal">
SHOW REPLICA
STATUS
</code>
</a>
)
</td>
<td>
6
</td>
<td>
The replication user account password used to connect to the source
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Port
</code>
</th>
<td>
<code class="literal">
Source_Port
</code>
</td>
<td>
7
</td>
<td>
The network port used to connect to the replication source server
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Connect_retry
</code>
</th>
<td>
<code class="literal">
Connect_Retry
</code>
</td>
<td>
8
</td>
<td>
The period (in seconds) that the replica waits before trying to
reconnect to the source
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Enabled_ssl
</code>
</th>
<td>
<code class="literal">
Source_SSL_Allowed
</code>
</td>
<td>
9
</td>
<td>
Whether the replica supports SSL connections
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Ssl_ca
</code>
</th>
<td>
<code class="literal">
Source_SSL_CA_File
</code>
</td>
<td>
10
</td>
<td>
The file used for the Certificate Authority (CA) certificate
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Ssl_capath
</code>
</th>
<td>
<code class="literal">
Source_SSL_CA_Path
</code>
</td>
<td>
11
</td>
<td>
The path to the Certificate Authority (CA) certificate
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Ssl_cert
</code>
</th>
<td>
<code class="literal">
Source_SSL_Cert
</code>
</td>
<td>
12
</td>
<td>
The name of the SSL certificate file
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Ssl_cipher
</code>
</th>
<td>
<code class="literal">
Source_SSL_Cipher
</code>
</td>
<td>
13
</td>
<td>
The list of possible ciphers used in the handshake for the SSL
connection
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Ssl_key
</code>
</th>
<td>
<code class="literal">
Source_SSL_Key
</code>
</td>
<td>
14
</td>
<td>
The name of the SSL key file
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Ssl_verify_server_cert
</code>
</th>
<td>
<code class="literal">
Source_SSL_Verify_Server_Cert
</code>
</td>
<td>
15
</td>
<td>
Whether to verify the server certificate
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Heartbeat
</code>
</th>
<td>
[None]
</td>
<td>
16
</td>
<td>
Interval between replication heartbeats, in seconds
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Bind
</code>
</th>
<td>
<code class="literal">
Source_Bind
</code>
</td>
<td>
17
</td>
<td>
Which of the replica's network interfaces should be used for
connecting to the source
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Ignored_server_ids
</code>
</th>
<td>
<code class="literal">
Replicate_Ignore_Server_Ids
</code>
</td>
<td>
18
</td>
<td>
The list of server IDs to be ignored. Note that for
<code class="literal">
Ignored_server_ids
</code>
the list of server
IDs is preceded by the total number of server IDs to
ignore.
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Uuid
</code>
</th>
<td>
<code class="literal">
Source_UUID
</code>
</td>
<td>
19
</td>
<td>
The source's unique ID
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Retry_count
</code>
</th>
<td>
<code class="literal">
Source_Retry_Count
</code>
</td>
<td>
20
</td>
<td>
Maximum number of reconnection attempts permitted
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Ssl_crl
</code>
</th>
<td>
[None]
</td>
<td>
21
</td>
<td>
Path to an SSL certificate revocation-list file
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Ssl_crlpath
</code>
</th>
<td>
[None]
</td>
<td>
22
</td>
<td>
Path to a directory containing SSL certificate revocation-list files
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Enabled_auto_position
</code>
</th>
<td>
<code class="literal">
Auto_position
</code>
</td>
<td>
23
</td>
<td>
Whether GTID auto-positioning is in use or not
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Channel_name
</code>
</th>
<td>
<code class="literal">
Channel_name
</code>
</td>
<td>
24
</td>
<td>
The name of the replication channel
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Tls_version
</code>
</th>
<td>
<code class="literal">
Source_TLS_Version
</code>
</td>
<td>
25
</td>
<td>
TLS version on the source
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Public_key_path
</code>
</th>
<td>
<code class="literal">
Source_public_key_path
</code>
</td>
<td>
26
</td>
<td>
Name of the RSA public key file
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Get_public_key
</code>
</th>
<td>
<code class="literal">
Get_source_public_key
</code>
</td>
<td>
27
</td>
<td>
Whether to request RSA public key from source
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Network_namespace
</code>
</th>
<td>
<code class="literal">
Network_namespace
</code>
</td>
<td>
28
</td>
<td>
Network namespace
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Master_compression_algorithm
</code>
</th>
<td>
[None]
</td>
<td>
29
</td>
<td>
Permitted compression algorithms for the connection to the source
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Master_zstd_compression_level
</code>
</th>
<td>
[None]
</td>
<td>
30
</td>
<td>
<code class="literal">
zstd
</code>
compression level
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Tls_ciphersuites
</code>
</th>
<td>
[None]
</td>
<td>
31
</td>
<td>
Permitted ciphersuites for TLSv1.3
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Source_connection_auto_failover
</code>
</th>
<td>
[None]
</td>
<td>
32
</td>
<td>
Whether the asynchronous connection failover mechanism is activated
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Gtid_only
</code>
</th>
<td>
[None]
</td>
<td>
33
</td>
<td>
Whether the channel uses only GTIDs and does not persist positions
</td>
</tr>
</tbody>
</table>
</div>
<div class="informaltable">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 752px;">
<thead>
<tr>
<th scope="col" style="width: 258.891px;">
<code class="literal">
slave_master_info
</code>
Table Column
</th>
<th scope="col" style="width: 242.641px;">
<code class="literal">
SHOW REPLICA STATUS
</code>
Column
</th>
<th scope="col" style="width: 96.3906px;">
<code class="filename">
master.info
</code>
File Line
</th>
<th scope="col" style="width: 153.266px;">
Description
</th>
</tr>
</thead>
</table>
</div>
<p>
For the applier metadata repository, the following table shows
the correspondence between the columns in the
<code class="literal">
mysql.slave_relay_log_info
</code>
table, the columns
displayed by
<a class="link" href="show-replica-status.html" title="15.7.7.35 SHOW REPLICA STATUS Statement">
<code class="literal">
SHOW REPLICA STATUS
</code>
</a>
,
and the lines in the deprecated
<code class="filename">
relay-log.info
</code>
file.
</p>
<div class="informaltable">
<table summary="The correspondence between the columns in the mysql.slave_relay_log_info table, the columns displayed by SHOW REPLICA STATUS, and the lines in the deprecated relay-log.info file.">
<colgroup>
<col style="width: 30%"/>
<col style="width: 40%"/>
<col style="width: 15%"/>
<col style="width: 20%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
<code class="literal">
slave_relay_log_info
</code>
Table Column
</th>
<th scope="col">
<code class="literal">
SHOW REPLICA STATUS
</code>
Column
</th>
<th scope="col">
Line in
<code class="filename">
relay-log.info
</code>
File
</th>
<th scope="col">
Description
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
<code class="literal">
Number_of_lines
</code>
</th>
<td>
[None]
</td>
<td>
1
</td>
<td>
Number of columns in the table or lines in the file
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Relay_log_name
</code>
</th>
<td>
<code class="literal">
Relay_Log_File
</code>
</td>
<td>
2
</td>
<td>
The name of the current relay log file
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Relay_log_pos
</code>
</th>
<td>
<code class="literal">
Relay_Log_Pos
</code>
</td>
<td>
3
</td>
<td>
The current position within the relay log file; events up to this
position have been executed on the replica database
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Master_log_name
</code>
</th>
<td>
<code class="literal">
Relay_Source_Log_File
</code>
</td>
<td>
4
</td>
<td>
The name of the source's binary log file from which the events in the
relay log file were read
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Master_log_pos
</code>
</th>
<td>
<code class="literal">
Exec_Source_Log_Pos
</code>
</td>
<td>
5
</td>
<td>
The equivalent position within the source's binary log file of the
events that have been executed on the replica
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Sql_delay
</code>
</th>
<td>
<code class="literal">
SQL_Delay
</code>
</td>
<td>
6
</td>
<td>
The number of seconds that the replica must lag the source
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Number_of_workers
</code>
</th>
<td>
[None]
</td>
<td>
7
</td>
<td>
The number of worker threads for applying replication transactions in
parallel
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Id
</code>
</th>
<td>
[None]
</td>
<td>
8
</td>
<td>
ID used for internal purposes; currently this is always 1
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Channel_name
</code>
</th>
<td>
<code class="literal">
Channel_name
</code>
</td>
<td>
9
</td>
<td>
The name of the replication channel
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Privilege_checks_username
</code>
</th>
<td>
[None]
</td>
<td>
10
</td>
<td>
The user name for the
<code class="literal">
PRIVILEGE_CHECKS_USER
</code>
account
for the channel
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Privilege_checks_hostname
</code>
</th>
<td>
[None]
</td>
<td>
11
</td>
<td>
The host name for the
<code class="literal">
PRIVILEGE_CHECKS_USER
</code>
account
for the channel
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Require_row_format
</code>
</th>
<td>
[None]
</td>
<td>
12
</td>
<td>
Whether the channel accepts only row-based events
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Require_table_primary_key_check
</code>
</th>
<td>
[None]
</td>
<td>
13
</td>
<td>
The channel's policy on whether tables must have primary keys for
<code class="literal">
CREATE TABLE
</code>
and
<code class="literal">
ALTER
TABLE
</code>
operations
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Assign_gtids_to_anonymous_transactions_type
</code>
</th>
<td>
[None]
</td>
<td>
14
</td>
<td>
If the channel assigns a GTID to replicated transactions that do not
already have one, using the replica's local UUID,
this value is
<code class="literal">
LOCAL
</code>
; if the channel
does so using instead a UUID which has been set manually,
the value is
<code class="literal">
UUID
</code>
. If the channel does
not assign a GTID in such cases, the value is
<code class="literal">
OFF
</code>
.
</td>
</tr>
<tr>
<th scope="row">
<code class="literal">
Assign_gtids_to_anonymous_transactions_value
</code>
</th>
<td>
[None]
</td>
<td>
15
</td>
<td>
The UUID used in the GTIDs assigned to anonymous transactions
</td>
</tr>
</tbody>
</table>
</div>
<div class="informaltable">
<table cellpadding="0" cellspacing="0" style="position: fixed; top: 0px; display: none; left: 401px; width: 793px;">
<thead>
<tr>
<th scope="col" style="width: 364.516px;">
<code class="literal">
slave_relay_log_info
</code>
Table Column
</th>
<th scope="col" style="width: 177.641px;">
<code class="literal">
SHOW REPLICA STATUS
</code>
Column
</th>
<th scope="col" style="width: 72px;">
Line in
<code class="filename">
relay-log.info
</code>
File
</th>
<th scope="col" style="width: 177.641px;">
Description
</th>
</tr>
</thead>
</table>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/information-schema-innodb-cmp-per-index-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="information-schema-innodb-cmp-per-index-table">
</a>
28.4.8 The INFORMATION_SCHEMA INNODB_CMP_PER_INDEX and
INNODB_CMP_PER_INDEX_RESET Tables
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045077207360">
</a>
<a class="indexterm" name="idm46045077205856">
</a>
<p>
The
<a class="link" href="information-schema-innodb-cmp-per-index-table.html" title="28.4.8 The INFORMATION_SCHEMA INNODB_CMP_PER_INDEX and INNODB_CMP_PER_INDEX_RESET Tables">
<code class="literal">
INNODB_CMP_PER_INDEX
</code>
</a>
and
<a class="link" href="information-schema-innodb-cmp-per-index-table.html" title="28.4.8 The INFORMATION_SCHEMA INNODB_CMP_PER_INDEX and INNODB_CMP_PER_INDEX_RESET Tables">
<code class="literal">
INNODB_CMP_PER_INDEX_RESET
</code>
</a>
tables
provide status information on operations related to
<a class="link" href="glossary.html#glos_compression" title="compression">
compressed
</a>
<code class="literal">
InnoDB
</code>
tables and indexes, with separate
statistics for each combination of database, table, and index, to
help you evaluate the performance and usefulness of compression
for specific tables.
</p>
<p>
For a compressed
<code class="literal">
InnoDB
</code>
table, both the table
data and all the
<a class="link" href="glossary.html#glos_secondary_index" title="secondary index">
secondary
indexes
</a>
are compressed. In this context, the table data is
treated as just another index, one that happens to contain all the
columns: the
<a class="link" href="glossary.html#glos_clustered_index" title="clustered index">
clustered
index
</a>
.
</p>
<p>
The
<a class="link" href="information-schema-innodb-cmp-per-index-table.html" title="28.4.8 The INFORMATION_SCHEMA INNODB_CMP_PER_INDEX and INNODB_CMP_PER_INDEX_RESET Tables">
<code class="literal">
INNODB_CMP_PER_INDEX
</code>
</a>
and
<a class="link" href="information-schema-innodb-cmp-per-index-table.html" title="28.4.8 The INFORMATION_SCHEMA INNODB_CMP_PER_INDEX and INNODB_CMP_PER_INDEX_RESET Tables">
<code class="literal">
INNODB_CMP_PER_INDEX_RESET
</code>
</a>
tables
have these columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
DATABASE_NAME
</code>
</p>
<p>
The schema (database) containing the applicable table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLE_NAME
</code>
</p>
<p>
The table to monitor for compression statistics.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
INDEX_NAME
</code>
</p>
<p>
The index to monitor for compression statistics.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COMPRESS_OPS
</code>
</p>
<p>
The number of compression operations attempted.
<a class="link" href="glossary.html#glos_page" title="page">
Pages
</a>
are compressed whenever
an empty page is created or the space for the uncompressed
modification log runs out.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COMPRESS_OPS_OK
</code>
</p>
<p>
The number of successful compression operations. Subtract from
the
<code class="literal">
COMPRESS_OPS
</code>
value to get the number of
<a class="link" href="glossary.html#glos_compression_failure" title="compression failure">
compression
failures
</a>
. Divide by the
<code class="literal">
COMPRESS_OPS
</code>
value to get the percentage of compression failures.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COMPRESS_TIME
</code>
</p>
<p>
The total time in seconds used for compressing data in this
index.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNCOMPRESS_OPS
</code>
</p>
<p>
The number of uncompression operations performed. Compressed
<code class="literal">
InnoDB
</code>
pages are uncompressed whenever
compression
<a class="link" href="glossary.html#glos_compression_failure" title="compression failure">
fails
</a>
, or the
first time a compressed page is accessed in the
<a class="link" href="glossary.html#glos_buffer_pool" title="buffer pool">
buffer pool
</a>
and the
uncompressed page does not exist.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
UNCOMPRESS_TIME
</code>
</p>
<p>
The total time in seconds used for uncompressing data in this
index.
</p>
</li>
</ul>
</div>
<h4>
<a name="idm46045077171712">
</a>
Example
</h4>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa8194516"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_CMP_PER_INDEX\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
database_name<span class="token punctuation">:</span> employees
table_name<span class="token punctuation">:</span> salaries
index_name<span class="token punctuation">:</span> PRIMARY
compress_ops<span class="token punctuation">:</span> 0
compress_ops_ok<span class="token punctuation">:</span> 0
compress_time<span class="token punctuation">:</span> 0
uncompress_ops<span class="token punctuation">:</span> 23451
uncompress_time<span class="token punctuation">:</span> 4
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 2. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
database_name<span class="token punctuation">:</span> employees
table_name<span class="token punctuation">:</span> salaries
index_name<span class="token punctuation">:</span> emp_no
compress_ops<span class="token punctuation">:</span> 0
compress_ops_ok<span class="token punctuation">:</span> 0
compress_time<span class="token punctuation">:</span> 0
uncompress_ops<span class="token punctuation">:</span> 1597
uncompress_time<span class="token punctuation">:</span> 0</span></code></pre>
</div>
<h4>
<a name="idm46045077168944">
</a>
Notes
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Use these tables to measure the effectiveness of
<code class="literal">
InnoDB
</code>
table
<a class="link" href="glossary.html#glos_compression" title="compression">
compression
</a>
for
specific tables, indexes, or both.
</p>
</li>
<li class="listitem">
<p>
You must have the
<a class="link" href="privileges-provided.html#priv_process">
<code class="literal">
PROCESS
</code>
</a>
privilege to query these tables.
</p>
</li>
<li class="listitem">
<p>
Use the
<code class="literal">
INFORMATION_SCHEMA
</code>
<a class="link" href="information-schema-columns-table.html" title="28.3.8 The INFORMATION_SCHEMA COLUMNS Table">
<code class="literal">
COLUMNS
</code>
</a>
table or the
<a class="link" href="show-columns.html" title="15.7.7.6 SHOW COLUMNS Statement">
<code class="literal">
SHOW COLUMNS
</code>
</a>
statement to view
additional information about the columns of these tables,
including data types and default values.
</p>
</li>
<li class="listitem">
<p>
Because collecting separate measurements for every index
imposes substantial performance overhead,
<a class="link" href="information-schema-innodb-cmp-per-index-table.html" title="28.4.8 The INFORMATION_SCHEMA INNODB_CMP_PER_INDEX and INNODB_CMP_PER_INDEX_RESET Tables">
<code class="literal">
INNODB_CMP_PER_INDEX
</code>
</a>
and
<a class="link" href="information-schema-innodb-cmp-per-index-table.html" title="28.4.8 The INFORMATION_SCHEMA INNODB_CMP_PER_INDEX and INNODB_CMP_PER_INDEX_RESET Tables">
<code class="literal">
INNODB_CMP_PER_INDEX_RESET
</code>
</a>
statistics are not gathered by default. You must enable the
<a class="link" href="innodb-parameters.html#sysvar_innodb_cmp_per_index_enabled">
<code class="literal">
innodb_cmp_per_index_enabled
</code>
</a>
system variable before performing the operations on compressed
tables that you want to monitor.
</p>
</li>
<li class="listitem">
<p>
For usage information, see
<a class="xref" href="innodb-compression-tuning-monitoring.html" title="17.9.1.4 Monitoring InnoDB Table Compression at Runtime">
Section 17.9.1.4, “Monitoring InnoDB Table Compression at Runtime”
</a>
and
<a class="xref" href="innodb-information-schema-examples-compression-sect.html" title="17.15.1.3 Using the Compression Information Schema Tables">
Section 17.15.1.3, “Using the Compression Information Schema Tables”
</a>
.
For general information about
<code class="literal">
InnoDB
</code>
table
compression, see
<a class="xref" href="innodb-compression.html" title="17.9 InnoDB Table and Page Compression">
Section 17.9, “InnoDB Table and Page Compression”
</a>
.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/information-schema-tp-thread-group-stats-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="information-schema-tp-thread-group-stats-table">
</a>
28.5.3 The INFORMATION_SCHEMA TP_THREAD_GROUP_STATS Table
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045076047872">
</a>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The
<code class="literal">
INFORMATION_SCHEMA
</code>
thread pool tables are
deprecated, and subject to removal in a future version of MySQL.
You should use the versions available as Performance Schema
tables instead. See
<a class="xref" href="performance-schema-thread-pool-tables.html" title="29.12.16 Performance Schema Thread Pool Tables">
Section 29.12.16, “Performance Schema Thread Pool Tables”
</a>
.
Applications should transition away from the old tables to the
new tables. For example, if an application uses this query:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa24162535"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span>TP_THREAD_GROUP_STATS<span class="token punctuation">;</span></code></pre>
</div>
<p>
The application should use this query instead:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa7750430"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>tp_thread_group_stats<span class="token punctuation">;</span></code></pre>
</div>
</div>
<p>
The
<code class="literal">
TP_THREAD_GROUP_STATS
</code>
table reports
statistics per thread group. There is one row per group.
</p>
<p>
For descriptions of the columns in the
<code class="literal">
INFORMATION_SCHEMA
</code>
<code class="literal">
TP_THREAD_GROUP_STATS
</code>
table, see
<a class="xref" href="performance-schema-tp-thread-group-stats-table.html" title="29.12.16.3 The tp_thread_group_stats Table">
Section 29.12.16.3, “The tp_thread_group_stats Table”
</a>
.
The Performance Schema
<a class="link" href="performance-schema-tp-thread-group-stats-table.html" title="29.12.16.3 The tp_thread_group_stats Table">
<code class="literal">
tp_thread_group_stats
</code>
</a>
table has
equivalent columns.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/information-schema-tablespaces-extensions-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="information-schema-tablespaces-extensions-table">
</a>
28.3.40 The INFORMATION_SCHEMA TABLESPACES_EXTENSIONS Table
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045078278304">
</a>
<p>
The
<a class="link" href="information-schema-tablespaces-extensions-table.html" title="28.3.40 The INFORMATION_SCHEMA TABLESPACES_EXTENSIONS Table">
<code class="literal">
TABLESPACES_EXTENSIONS
</code>
</a>
table
provides information about tablespace attributes defined for
primary storage engines.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
The
<a class="link" href="information-schema-tablespaces-extensions-table.html" title="28.3.40 The INFORMATION_SCHEMA TABLESPACES_EXTENSIONS Table">
<code class="literal">
TABLESPACES_EXTENSIONS
</code>
</a>
table is
reserved for future use.
</p>
</div>
<p>
The
<a class="link" href="information-schema-tablespaces-extensions-table.html" title="28.3.40 The INFORMATION_SCHEMA TABLESPACES_EXTENSIONS Table">
<code class="literal">
TABLESPACES_EXTENSIONS
</code>
</a>
table has
these columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
TABLESPACE_NAME
</code>
</p>
<p>
The name of the tablespace.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ENGINE_ATTRIBUTE
</code>
</p>
<p>
Tablespace attributes defined for the primary storage engine.
Reserved for future use.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/charset-configuration.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="charset-configuration">
</a>
12.15 Character Set Configuration
</h2>
</div>
</div>
</div>
<p>
The MySQL server has a compiled-in default character set and
collation. To change these defaults, use the
<a class="link" href="server-system-variables.html#sysvar_character_set_server">
<code class="option">
--character-set-server
</code>
</a>
and
<a class="link" href="server-system-variables.html#sysvar_collation_server">
<code class="option">
--collation-server
</code>
</a>
options when you
start the server. See
<a class="xref" href="server-options.html" title="7.1.7 Server Command Options">
Section 7.1.7, “Server Command Options”
</a>
. The
collation must be a legal collation for the default character set.
To determine which collations are available for each character
set, use the
<a class="link" href="show-collation.html" title="15.7.7.5 SHOW COLLATION Statement">
<code class="literal">
SHOW COLLATION
</code>
</a>
statement or query the
<code class="literal">
INFORMATION_SCHEMA
</code>
<a class="link" href="information-schema-collations-table.html" title="28.3.6 The INFORMATION_SCHEMA COLLATIONS Table">
<code class="literal">
COLLATIONS
</code>
</a>
table.
</p>
<p>
If you try to use a character set that is not compiled into your
binary, you might run into the following problems:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
If your program uses an incorrect path to determine where the
character sets are stored (which is typically the
<code class="filename">
share/mysql/charsets
</code>
or
<code class="filename">
share/charsets
</code>
directory under the MySQL
installation directory), this can be fixed by using the
<code class="option">
--character-sets-dir
</code>
option when you run the
program. For example, to specify a directory to be used by
MySQL client programs, list it in the
<code class="literal">
[client]
</code>
group of your option file. The
examples given here show what the setting might look like for
Unix or Windows, respectively:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa28300049"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[client]</span>
<span class="token constant">character-sets-dir</span><span class="token attr-value"><span class="token punctuation">=</span>/usr/local/mysql/share/mysql/charsets</span>
<span class="token selector">[client]</span>
<span class="token constant">character-sets-dir</span><span class="token attr-value"><span class="token punctuation">=</span>"C:/Program Files/MySQL/MySQL Server 8.4/share/charsets"</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
If the character set is a complex character set that cannot be
loaded dynamically, you must recompile the program with
support for the character set.
</p>
<p>
For Unicode character sets, you can define collations without
recompiling by using LDML notation. See
<a class="xref" href="adding-collation-unicode-uca.html" title="12.14.4 Adding a UCA Collation to a Unicode Character Set">
Section 12.14.4, “Adding a UCA Collation to a Unicode Character Set”
</a>
.
</p>
</li>
<li class="listitem">
<p>
If the character set is a dynamic character set, but you do
not have a configuration file for it, you should install the
configuration file for the character set from a new MySQL
distribution.
</p>
</li>
<li class="listitem">
<p>
If your character set index file
(
<code class="filename">
Index.xml
</code>
) does not contain the name for
the character set, your program displays an error message:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-none"><div class="docs-select-all right" id="sa48751358"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">Character set '<em class="replaceable">charset_name</em>' is not a compiled character set and is not
specified in the '/usr/share/mysql/charsets/Index.xml' file</code></pre>
</div>
<p>
To solve this problem, you should either get a new index file
or manually add the name of any missing character sets to the
current file.
</p>
</li>
</ul>
</div>
<p>
You can force client programs to use specific character set as
follows:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa87190508"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[client]</span>
<span class="token constant">default-character-set</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">charset_name</em></span></code></pre>
</div>
<p>
This is normally unnecessary. However, when
<a class="link" href="server-system-variables.html#sysvar_character_set_system">
<code class="literal">
character_set_system
</code>
</a>
differs from
<a class="link" href="server-system-variables.html#sysvar_character_set_server">
<code class="literal">
character_set_server
</code>
</a>
or
<a class="link" href="server-system-variables.html#sysvar_character_set_client">
<code class="literal">
character_set_client
</code>
</a>
, and you
input characters manually (as database object identifiers, column
values, or both), these may be displayed incorrectly in output
from the client or the output itself may be formatted incorrectly.
In such cases, starting the mysql client with
<a class="link" href="mysql-command-options.html#option_mysql_default-character-set">
<code class="option">
--default-character-set=
<em class="replaceable">
<code>
system_character_set
</code>
</em>
</code>
</a>
—that
is, setting the client character set to match the system character
set—should fix the problem.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/sys-user-summary-by-statement-latency.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="sys-user-summary-by-statement-latency">
</a>
30.4.3.45 The user_summary_by_statement_latency and
x$user_summary_by_statement_latency Views
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045061876800">
</a>
<a class="indexterm" name="idm46045061875344">
</a>
<a class="indexterm" name="idm46045061873840">
</a>
<a class="indexterm" name="idm46045061872320">
</a>
<p>
These views summarize overall statement statistics, grouped by
user. By default, rows are sorted by descending total latency.
</p>
<p>
The
<a class="link" href="sys-user-summary-by-statement-latency.html" title="30.4.3.45 The user_summary_by_statement_latency and x$user_summary_by_statement_latency Views">
<code class="literal">
user_summary_by_statement_latency
</code>
</a>
and
<a class="link" href="sys-user-summary-by-statement-latency.html" title="30.4.3.45 The user_summary_by_statement_latency and x$user_summary_by_statement_latency Views">
<code class="literal">
x$user_summary_by_statement_latency
</code>
</a>
views have these columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
user
</code>
</p>
<p>
The client user name. Rows for which the
<code class="literal">
USER
</code>
column in the underlying
Performance Schema table is
<code class="literal">
NULL
</code>
are
assumed to be for background threads and are reported with
a host name of
<code class="literal">
background
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total
</code>
</p>
<p>
The total number of statements for the user.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total_latency
</code>
</p>
<p>
The total wait time of timed statements for the user.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
max_latency
</code>
</p>
<p>
The maximum single wait time of timed statements for the
user.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
lock_latency
</code>
</p>
<p>
The total time waiting for locks by timed statements for
the user.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
cpu_latency
</code>
</p>
<p>
The time spent on CPU for the current thread.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
rows_sent
</code>
</p>
<p>
The total number of rows returned by statements for the
user.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
rows_examined
</code>
</p>
<p>
The total number of rows read from storage engines by
statements for the user.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
rows_affected
</code>
</p>
<p>
The total number of rows affected by statements for the
user.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
full_scans
</code>
</p>
<p>
The total number of full table scans by statements for the
user.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-shell-tutorial-python-documents-add.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-shell-tutorial-python-documents-add">
</a>
22.4.3.2 Working with Collections
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045127206352">
</a>
<p>
To work with the collections in a schema, use the
<code class="literal">
db
</code>
global object to access the current
schema. In this example we are using the
<code class="literal">
world_x
</code>
schema imported previously, and the
<code class="literal">
countryinfo
</code>
collection. Therefore, the format
of the operations you issue is
<code class="literal">
db.
<em class="replaceable">
<code>
collection_name
</code>
</em>
.operation
</code>
,
where
<em class="replaceable">
<code>
collection_name
</code>
</em>
is the name of
the collection which the operation is executed against. In the
following examples, the operations are executed against the
<code class="literal">
countryinfo
</code>
collection.
</p>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="idm46045127199696">
</a>
Add a Document
</h5>
</div>
</div>
</div>
<p>
Use the
<code class="literal">
add()
</code>
method to insert one document
or a list of documents into an existing collection. Insert the
following document into the
<code class="literal">
countryinfo
</code>
collection. As this is multi-line content, press
<span class="keycap">
<strong>
Enter
</strong>
</span>
twice to insert the document.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-mysqlsh"><div class="docs-select-all right" id="sa98792496"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-mysqlsh"><span class="token prompt">mysql-py></span> db<span class="token punctuation">.</span>countryinfo<span class="token punctuation">.</span><span class="token function">add</span><span class="token punctuation">(</span>
<span class="token inlinejson"> <span class="token punctuation">{</span>
<span class="token property">"GNP"</span><span class="token operator">:</span> .<span class="token number">6</span><span class="token punctuation">,</span>
<span class="token property">"IndepYear"</span><span class="token operator">:</span> <span class="token number">1967</span><span class="token punctuation">,</span>
<span class="token property">"Name"</span><span class="token operator">:</span> <span class="token string">"Sealand"</span><span class="token punctuation">,</span>
<span class="token property">"Code:"</span><span class="token operator">:</span> <span class="token string">"SEA"</span><span class="token punctuation">,</span>
<span class="token property">"demographics"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"LifeExpectancy"</span><span class="token operator">:</span> <span class="token number">79</span><span class="token punctuation">,</span>
<span class="token property">"Population"</span><span class="token operator">:</span> <span class="token number">27</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"geography"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"Continent"</span><span class="token operator">:</span> <span class="token string">"Europe"</span><span class="token punctuation">,</span>
<span class="token property">"Region"</span><span class="token operator">:</span> <span class="token string">"British Islands"</span><span class="token punctuation">,</span>
<span class="token property">"SurfaceArea"</span><span class="token operator">:</span> <span class="token number">193</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"government"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"GovernmentForm"</span><span class="token operator">:</span> <span class="token string">"Monarchy"</span><span class="token punctuation">,</span>
<span class="token property">"HeadOfState"</span><span class="token operator">:</span> <span class="token string">"Michael Bates"</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></span>
<span class="token punctuation">)</span></code></pre>
</div>
<p>
The method returns the status of the operation. You can verify
the operation by searching for the document. For example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-mysqlsh"><div class="docs-select-all right" id="sa74165273"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-mysqlsh"><span class="token prompt">mysql-py></span> db<span class="token punctuation">.</span>countryinfo<span class="token punctuation">.</span><span class="token function">find</span><span class="token punctuation">(</span><span class="token string">"Name = 'Sealand'"</span><span class="token punctuation">)</span>
<span class="token inlinejson"><span class="token punctuation">{</span>
<span class="token property">"GNP"</span><span class="token operator">:</span> <span class="token number">0.6</span><span class="token punctuation">,</span>
<span class="token property">"_id"</span><span class="token operator">:</span> <span class="token string">"00005e2ff4af00000000000000f4"</span><span class="token punctuation">,</span>
<span class="token property">"Name"</span><span class="token operator">:</span> <span class="token string">"Sealand"</span><span class="token punctuation">,</span>
<span class="token property">"Code:"</span><span class="token operator">:</span> <span class="token string">"SEA"</span><span class="token punctuation">,</span>
<span class="token property">"IndepYear"</span><span class="token operator">:</span> <span class="token number">1967</span><span class="token punctuation">,</span>
<span class="token property">"geography"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"Region"</span><span class="token operator">:</span> <span class="token string">"British Islands"</span><span class="token punctuation">,</span>
<span class="token property">"Continent"</span><span class="token operator">:</span> <span class="token string">"Europe"</span><span class="token punctuation">,</span>
<span class="token property">"SurfaceArea"</span><span class="token operator">:</span> <span class="token number">193</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"government"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"HeadOfState"</span><span class="token operator">:</span> <span class="token string">"Michael Bates"</span><span class="token punctuation">,</span>
<span class="token property">"GovernmentForm"</span><span class="token operator">:</span> <span class="token string">"Monarchy"</span>
<span class="token punctuation">}</span><span class="token punctuation">,</span>
<span class="token property">"demographics"</span><span class="token operator">:</span> <span class="token punctuation">{</span>
<span class="token property">"Population"</span><span class="token operator">:</span> <span class="token number">27</span><span class="token punctuation">,</span>
<span class="token property">"LifeExpectancy"</span><span class="token operator">:</span> <span class="token number">79</span>
<span class="token punctuation">}</span>
<span class="token punctuation">}</span></span></code></pre>
</div>
<p>
Note that in addition to the fields specified when the
document was added, there is one more field, the
<code class="literal">
_id
</code>
. Each document requires an identifier
field called
<code class="literal">
_id
</code>
. The value of the
<code class="literal">
_id
</code>
field must be unique among all
documents in the same collection. Document IDs are generated
by the server, not the client, so MySQL Shell does not
automatically set an
<code class="literal">
_id
</code>
value. MySQL sets
an
<code class="literal">
_id
</code>
value if the document does not
contain the
<code class="literal">
_id
</code>
field. For more
information, see
<a class="ulink" href="/doc/x-devapi-userguide/en/understanding-automatic-document-ids.html" target="_top">
Understanding Document IDs
</a>
.
</p>
</div>
<div class="simplesect">
<div class="titlepage">
<div>
<div class="simple">
<h5 class="title">
<a name="idm46045127185632">
</a>
Related Information
</h5>
</div>
</div>
</div>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
See
<a class="ulink" href="/doc/x-devapi-userguide/en/crud-ebnf-collection-crud-functions.html#crud-ebnf-collectionaddfunction" target="_top">
CollectionAddFunction
</a>
for
the full syntax definition.
</p>
</li>
<li class="listitem">
<p>
See
<a class="ulink" href="/doc/x-devapi-userguide/en/understanding-automatic-document-ids.html" target="_top">
Understanding Document IDs
</a>
.
</p>
</li>
</ul>
</div>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-security-mysql-security-procedures.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-security-mysql-security-procedures">
</a>
25.6.21.3 NDB Cluster and MySQL Security Procedures
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045086914368">
</a>
<a class="indexterm" name="idm46045086912880">
</a>
<p>
In this section, we discuss MySQL standard security procedures
as they apply to running NDB Cluster.
</p>
<p>
In general, any standard procedure for running MySQL securely
also applies to running a MySQL Server as part of an NDB
Cluster. First and foremost, you should always run a MySQL
Server as the
<code class="literal">
mysql
</code>
operating system user;
this is no different from running MySQL in a standard
(non-Cluster) environment. The
<code class="literal">
mysql
</code>
system
account should be uniquely and clearly defined. Fortunately,
this is the default behavior for a new MySQL installation. You
can verify that the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
process is running
as the
<code class="literal">
mysql
</code>
operating system user by using
the system command such as the one shown here:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-terminal"><div class="docs-select-all right" id="sa26699881"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal"><span class="token prompt">$> </span><span class="token command">ps</span> aux | grep mysql
root 10467 0<span class="token punctuation">.</span>0 0<span class="token punctuation">.</span>1 3616 1380 pts/3 S 11<span class="token punctuation">:</span>53 0<span class="token punctuation">:</span>00 \
/bin/sh <span class="token punctuation">.</span>/mysqld_safe <span class="token property">--ndbcluster</span> <span class="token constant">--ndb-connectstring</span><span class="token attr-value"><span class="token punctuation">=</span>localhost:1186</span>
mysql 10512 0<span class="token punctuation">.</span>2 2<span class="token punctuation">.</span>5 58528 26636 pts/3 Sl 11<span class="token punctuation">:</span>53 0<span class="token punctuation">:</span>00 \
/usr/local/mysql/libexec/mysqld <span class="token constant">--basedir</span><span class="token attr-value"><span class="token punctuation">=</span>/usr/local/mysql</span> \
<span class="token constant">--datadir</span><span class="token attr-value"><span class="token punctuation">=</span>/usr/local/mysql/var</span> <span class="token constant">--user</span><span class="token attr-value"><span class="token punctuation">=</span>mysql</span> <span class="token property">--ndbcluster</span> \
<span class="token constant">--ndb-connectstring</span><span class="token attr-value"><span class="token punctuation">=</span>localhost:1186</span> <span class="token constant">--pid-file</span><span class="token attr-value"><span class="token punctuation">=</span>/usr/local/mysql/var/mothra.pid</span> \
<span class="token constant">--log-error</span><span class="token attr-value"><span class="token punctuation">=</span>/usr/local/mysql/var/mothra.err</span>
jon 10579 0<span class="token punctuation">.</span>0 0<span class="token punctuation">.</span>0 2736 688 pts/0 S+ 11<span class="token punctuation">:</span>54 0<span class="token punctuation">:</span>00 grep mysql</code></pre>
</div>
<p>
If the
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
process is running as any other
user than
<code class="literal">
mysql
</code>
, you should immediately shut
it down and restart it as the
<code class="literal">
mysql
</code>
user. If
this user does not exist on the system, the
<code class="literal">
mysql
</code>
user account should be created, and
this user should be part of the
<code class="literal">
mysql
</code>
user
group; in this case, you should also make sure that the MySQL
data directory on this system (as set using the
<a class="link" href="server-system-variables.html#sysvar_datadir">
<code class="option">
--datadir
</code>
</a>
option for
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
) is owned by the
<code class="literal">
mysql
</code>
user, and that the SQL node's
<code class="filename">
my.cnf
</code>
file includes
<code class="literal">
user=mysql
</code>
in the
<code class="literal">
[mysqld]
</code>
section. Alternatively, you can start the MySQL server process
with
<a class="link" href="server-options.html#option_mysqld_user">
<code class="option">
--user=mysql
</code>
</a>
on the command
line, but it is preferable to use the
<code class="filename">
my.cnf
</code>
option, since you might forget to
use the command-line option and so have
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
running as another user
unintentionally. The
<a class="link" href="mysqld-safe.html" title="6.3.2 mysqld_safe — MySQL Server Startup Script">
<span class="command">
<strong>
mysqld_safe
</strong>
</span>
</a>
startup
script forces MySQL to run as the
<code class="literal">
mysql
</code>
user.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
Never run
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
as the system root user.
Doing so means that potentially any file on the system can be
read by MySQL, and thus—should MySQL be
compromised—by an attacker.
</p>
</div>
<p>
<a class="indexterm" name="idm46045086886960">
</a>
As mentioned in the previous section (see
<a class="xref" href="mysql-cluster-security-mysql-privileges.html" title="25.6.21.2 NDB Cluster and MySQL Privileges">
Section 25.6.21.2, “NDB Cluster and MySQL Privileges”
</a>
), you
should always set a root password for the MySQL Server as soon
as you have it running. You should also delete the anonymous
user account that is installed by default. You can accomplish
these tasks using the following statements:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa36374745"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql">$<span class="token operator">></span> mysql <span class="token operator">-</span>u root
<span class="token prompt">mysql></span> <span class="token keyword">UPDATE</span> mysql<span class="token punctuation">.</span><span class="token keyword">user</span>
<span class="token prompt"> -></span> <span class="token keyword">SET</span> <span class="token keyword">Password</span><span class="token operator">=</span><span class="token function">PASSWORD</span><span class="token punctuation">(</span><span class="token string">'<em class="replaceable">secure_password</em>'</span><span class="token punctuation">)</span>
<span class="token prompt"> -></span> <span class="token keyword">WHERE</span> <span class="token keyword">User</span><span class="token operator">=</span><span class="token string">'root'</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">DELETE</span> <span class="token keyword">FROM</span> mysql<span class="token punctuation">.</span><span class="token keyword">user</span>
<span class="token prompt"> -></span> <span class="token keyword">WHERE</span> <span class="token keyword">User</span><span class="token operator">=</span><span class="token string">''</span><span class="token punctuation">;</span>
<span class="token prompt">mysql></span> <span class="token keyword">FLUSH</span> <span class="token keyword">PRIVILEGES</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Be very careful when executing the
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
statement not to omit the
<code class="literal">
WHERE
</code>
clause, or you risk deleting
<span class="emphasis">
<em>
all
</em>
</span>
MySQL users. Be sure to run the
<a class="link" href="flush.html#flush-privileges">
<code class="literal">
FLUSH PRIVILEGES
</code>
</a>
statement as
soon as you have modified the
<code class="literal">
mysql.user
</code>
table, so that the changes take immediate effect. Without
<a class="link" href="flush.html#flush-privileges">
<code class="literal">
FLUSH PRIVILEGES
</code>
</a>
, the changes do
not take effect until the next time that the server is
restarted.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
<a class="indexterm" name="idm46045086871184">
</a>
<a class="indexterm" name="idm46045086869696">
</a>
Many of the NDB Cluster utilities such as
<a class="link" href="mysql-cluster-programs-ndb-show-tables.html" title="25.5.27 ndb_show_tables — Display List of NDB Tables">
<span class="command">
<strong>
ndb_show_tables
</strong>
</span>
</a>
,
<a class="link" href="mysql-cluster-programs-ndb-desc.html" title="25.5.9 ndb_desc — Describe NDB Tables">
<span class="command">
<strong>
ndb_desc
</strong>
</span>
</a>
, and
<a class="link" href="mysql-cluster-programs-ndb-select-all.html" title="25.5.25 ndb_select_all — Print Rows from an NDB Table">
<span class="command">
<strong>
ndb_select_all
</strong>
</span>
</a>
also work without
authentication and can reveal table names, schemas, and data.
By default these are installed on Unix-style systems with the
permissions
<code class="literal">
wxr-xr-x
</code>
(755), which means
they can be executed by any user that can access the
<code class="filename">
mysql/bin
</code>
directory.
</p>
<p>
See
<a class="xref" href="mysql-cluster-programs.html" title="25.5 NDB Cluster Programs">
Section 25.5, “NDB Cluster Programs”
</a>
, for more
information about these utilities.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/subquery-optimization.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="subquery-optimization">
</a>
10.2.2 Optimizing Subqueries, Derived Tables, View References, and Common Table
Expressions
</h3>
</div>
</div>
</div>
<div class="toc">
<dl class="toc">
<dt>
<span class="section">
<a href="semijoins-antijoins.html">
10.2.2.1 Optimizing IN and EXISTS Subquery Predicates with Semijoin and Antijoin
Transformations
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="subquery-materialization.html">
10.2.2.2 Optimizing Subqueries with Materialization
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="subquery-optimization-with-exists.html">
10.2.2.3 Optimizing Subqueries with the EXISTS Strategy
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="derived-table-optimization.html">
10.2.2.4 Optimizing Derived Tables, View References, and Common Table Expressions
with Merging or Materialization
</a>
</span>
</dt>
<dt>
<span class="section">
<a href="derived-condition-pushdown-optimization.html">
10.2.2.5 Derived Condition Pushdown Optimization
</a>
</span>
</dt>
</dl>
</div>
<a class="indexterm" name="idm46045228413680">
</a>
<a class="indexterm" name="idm46045228412224">
</a>
<a class="indexterm" name="idm46045228410736">
</a>
<a class="indexterm" name="idm46045228409248">
</a>
<a class="indexterm" name="idm46045228407760">
</a>
<a class="indexterm" name="idm46045228406272">
</a>
<a class="indexterm" name="idm46045228404784">
</a>
<a class="indexterm" name="idm46045228403280">
</a>
<p>
The MySQL query optimizer has different strategies available to
evaluate subqueries:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For a subquery used with an
<code class="literal">
IN
</code>
,
<code class="literal">
= ANY
</code>
, or
<code class="literal">
EXISTS
</code>
predicate, the optimizer has these choices:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Semijoin
</p>
</li>
<li class="listitem">
<p>
Materialization
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXISTS
</code>
strategy
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
For a subquery used with a
<code class="literal">
NOT IN
</code>
,
<code class="literal">
<> ALL
</code>
or
<code class="literal">
NOT
EXISTS
</code>
predicate, the optimizer has these choices:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Materialization
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
EXISTS
</code>
strategy
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<p>
For a derived table, the optimizer has these choices (which also
apply to view references and common table expressions):
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Merge the derived table into the outer query block
</p>
</li>
<li class="listitem">
<p>
Materialize the derived table to an internal temporary table
</p>
</li>
</ul>
</div>
<p>
The following discussion provides more information about the
preceding optimization strategies.
</p>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
A limitation on
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
and
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
statements that use a
subquery to modify a single table is that the optimizer does
not use semijoin or materialization subquery optimizations. As
a workaround, try rewriting them as multiple-table
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
and
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
statements that use a
join rather than a subquery.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/innodb-page-compression.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="innodb-page-compression">
</a>
17.9.2 InnoDB Page Compression
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045161144928">
</a>
<a class="indexterm" name="idm46045161143856">
</a>
<p>
<code class="literal">
InnoDB
</code>
supports page-level compression for
tables that reside in
<a class="link" href="glossary.html#glos_file_per_table" title="file-per-table">
file-per-table
</a>
tablespaces. This feature is referred to as
<span class="emphasis">
<em>
Transparent
Page Compression
</em>
</span>
. Page compression is enabled by
specifying the
<code class="literal">
COMPRESSION
</code>
attribute with
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
or
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
. Supported compression
algorithms include
<code class="literal">
Zlib
</code>
and
<code class="literal">
LZ4
</code>
.
</p>
<h4>
<a name="idm46045161135648">
</a>
Supported Platforms
</h4>
<p>
Page compression requires sparse file and hole punching support.
Page compression is supported on Windows with NTFS, and on the
following subset of MySQL-supported Linux platforms where the
kernel level provides hole punching support:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
RHEL 7 and derived distributions that use kernel version
3.10.0-123 or higher
</p>
</li>
<li class="listitem">
<p>
OEL 5.10 (UEK2) kernel version 2.6.39 or higher
</p>
</li>
<li class="listitem">
<p>
OEL 6.5 (UEK3) kernel version 3.8.13 or higher
</p>
</li>
<li class="listitem">
<p>
OEL 7.0 kernel version 3.8.13 or higher
</p>
</li>
<li class="listitem">
<p>
SLE11 kernel version 3.0-x
</p>
</li>
<li class="listitem">
<p>
SLE12 kernel version 3.12-x
</p>
</li>
<li class="listitem">
<p>
OES11 kernel version 3.0-x
</p>
</li>
<li class="listitem">
<p>
Ubuntu 14.0.4 LTS kernel version 3.13 or higher
</p>
</li>
<li class="listitem">
<p>
Ubuntu 12.0.4 LTS kernel version 3.2 or higher
</p>
</li>
<li class="listitem">
<p>
Debian 7 kernel version 3.2 or higher
</p>
</li>
</ul>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
All of the available file systems for a given Linux distribution
may not support hole punching.
</p>
</div>
<h4>
<a name="idm46045161124528">
</a>
How Page Compression Works
</h4>
<p>
When a page is written, it is compressed using the specified
compression algorithm. The compressed data is written to disk,
where the hole punching mechanism releases empty blocks from the
end of the page. If compression fails, data is written out as-is.
</p>
<h4>
<a name="idm46045161123120">
</a>
Hole Punch Size on Linux
</h4>
<p>
On Linux systems, the file system block size is the unit size used
for hole punching. Therefore, page compression only works if page
data can be compressed to a size that is less than or equal to the
<code class="literal">
InnoDB
</code>
page size minus the file system block
size. For example, if
<a class="link" href="innodb-parameters.html#sysvar_innodb_page_size">
<code class="literal">
innodb_page_size=16K
</code>
</a>
and the file
system block size is 4K, page data must compress to less than or
equal to 12K to make hole punching possible.
</p>
<h4>
<a name="idm46045161119632">
</a>
Hole Punch Size on Windows
</h4>
<p>
On Windows systems, the underlying infrastructure for sparse files
is based on NTFS compression. Hole punching size is the NTFS
compression unit, which is 16 times the NTFS cluster size. Cluster
sizes and their compression units are shown in the following
table:
</p>
<div class="table">
<a name="idm46045161118208">
</a>
<p class="title">
<b>
Table 17.13 Windows NTFS Cluster Size and Compression Units
</b>
</p>
<div class="table-contents">
<table frame="all" summary="Windows NTFS cluster size and compression units.">
<colgroup>
<col style="width: 50%"/>
<col style="width: 50%"/>
</colgroup>
<thead>
<tr>
<th>
Cluster Size
</th>
<th>
Compression Unit
</th>
</tr>
</thead>
<tbody>
<tr>
<td>
512 Bytes
</td>
<td>
8 KB
</td>
</tr>
<tr>
<td>
1 KB
</td>
<td>
16 KB
</td>
</tr>
<tr>
<td>
2 KB
</td>
<td>
32 KB
</td>
</tr>
<tr>
<td>
4 KB
</td>
<td>
64 KB
</td>
</tr>
</tbody>
</table>
</div>
</div>
<br class="table-break"/>
<p>
Page compression on Windows systems only works if page data can be
compressed to a size that is less than or equal to the
<code class="literal">
InnoDB
</code>
page size minus the compression unit
size.
</p>
<p>
The default NTFS cluster size is 4KB, for which the compression
unit size is 64KB. This means that page compression has no benefit
for an out-of-the box Windows NTFS configuration, as the maximum
<a class="link" href="innodb-parameters.html#sysvar_innodb_page_size">
<code class="literal">
innodb_page_size
</code>
</a>
is also 64KB.
</p>
<p>
For page compression to work on Windows, the file system must be
created with a cluster size smaller than 4K, and the
<a class="link" href="innodb-parameters.html#sysvar_innodb_page_size">
<code class="literal">
innodb_page_size
</code>
</a>
must be at least
twice the size of the compression unit. For example, for page
compression to work on Windows, you could build the file system
with a cluster size of 512 Bytes (which has a compression unit of
8KB) and initialize
<code class="literal">
InnoDB
</code>
with an
<a class="link" href="innodb-parameters.html#sysvar_innodb_page_size">
<code class="literal">
innodb_page_size
</code>
</a>
value of 16K or
greater.
</p>
<h4>
<a name="idm46045161096512">
</a>
Enabling Page Compression
</h4>
<p>
To enable page compression, specify the
<code class="literal">
COMPRESSION
</code>
attribute in the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement. For
example:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa50917523"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> t1 <span class="token punctuation">(</span>c1 <span class="token datatype">INT</span><span class="token punctuation">)</span> <span class="token keyword">COMPRESSION</span><span class="token operator">=</span><span class="token string">"zlib"</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
You can also enable page compression in an
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
statement. However,
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE ...
COMPRESSION
</code>
</a>
only updates the tablespace compression
attribute. Writes to the tablespace that occur after setting the
new compression algorithm use the new setting, but to apply the
new compression algorithm to existing pages, you must rebuild the
table using
<a class="link" href="optimize-table.html" title="15.7.3.4 OPTIMIZE TABLE Statement">
<code class="literal">
OPTIMIZE TABLE
</code>
</a>
.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa95289515"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> t1 <span class="token keyword">COMPRESSION</span><span class="token operator">=</span><span class="token string">"zlib"</span><span class="token punctuation">;</span>
<span class="token keyword">OPTIMIZE</span> <span class="token keyword">TABLE</span> t1<span class="token punctuation">;</span></code></pre>
</div>
<h4>
<a name="idm46045161086992">
</a>
Disabling Page Compression
</h4>
<p>
To disable page compression, set
<code class="literal">
COMPRESSION=None
</code>
using
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE
</code>
</a>
. Writes to the
tablespace that occur after setting
<code class="literal">
COMPRESSION=None
</code>
no longer use page
compression. To uncompress existing pages, you must rebuild the
table using
<a class="link" href="optimize-table.html" title="15.7.3.4 OPTIMIZE TABLE Statement">
<code class="literal">
OPTIMIZE TABLE
</code>
</a>
after
setting
<code class="literal">
COMPRESSION=None
</code>
.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa65731333"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">ALTER</span> <span class="token keyword">TABLE</span> t1 <span class="token keyword">COMPRESSION</span><span class="token operator">=</span><span class="token string">"None"</span><span class="token punctuation">;</span>
<span class="token keyword">OPTIMIZE</span> <span class="token keyword">TABLE</span> t1<span class="token punctuation">;</span></code></pre>
</div>
<h4>
<a name="idm46045161080096">
</a>
Page Compression Metadata
</h4>
<p>
Page compression metadata is found in the Information Schema
<a class="link" href="information-schema-innodb-tablespaces-table.html" title="28.4.24 The INFORMATION_SCHEMA INNODB_TABLESPACES Table">
<code class="literal">
INNODB_TABLESPACES
</code>
</a>
table, in the
following columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
FS_BLOCK_SIZE
</code>
: The file system block size,
which is the unit size used for hole punching.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FILE_SIZE
</code>
: The apparent size of the file,
which represents the maximum size of the file, uncompressed.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ALLOCATED_SIZE
</code>
: The actual size of the
file, which is the amount of space allocated on disk.
</p>
</li>
</ul>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
On Unix-like systems,
<code class="literal">
ls -l
<em class="replaceable">
<code>
tablespace_name
</code>
</em>
.ibd
</code>
shows
the apparent file size (equivalent to
<code class="literal">
FILE_SIZE
</code>
) in bytes. To view the actual
amount of space allocated on disk (equivalent to
<code class="literal">
ALLOCATED_SIZE
</code>
), use
<code class="literal">
du
--block-size=1
<em class="replaceable">
<code>
tablespace_name
</code>
</em>
.ibd
</code>
. The
<code class="literal">
--block-size=1
</code>
option prints the allocated
space in bytes instead of blocks, so that it can be compared to
<code class="literal">
ls -l
</code>
output.
</p>
<p>
Use
<a class="link" href="show-create-table.html" title="15.7.7.11 SHOW CREATE TABLE Statement">
<code class="literal">
SHOW CREATE TABLE
</code>
</a>
to view the
current page compression setting (
<code class="literal">
Zlib
</code>
,
<code class="literal">
Lz4
</code>
, or
<code class="literal">
None
</code>
). A table may
contain a mix of pages with different compression settings.
</p>
</div>
<p>
In the following example, page compression metadata for the
employees table is retrieved from the Information Schema
<a class="link" href="information-schema-innodb-tablespaces-table.html" title="28.4.24 The INFORMATION_SCHEMA INNODB_TABLESPACES Table">
<code class="literal">
INNODB_TABLESPACES
</code>
</a>
table.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa45712629"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token comment" spellcheck="true"># Create the employees table with Zlib page compression</span>
<span class="token keyword">CREATE</span> <span class="token keyword">TABLE</span> employees <span class="token punctuation">(</span>
emp_no <span class="token datatype">INT</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
birth_date <span class="token datatype">DATE</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
first_name <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">14</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
last_name <span class="token datatype">VARCHAR</span><span class="token punctuation">(</span><span class="token number">16</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
gender <span class="token datatype">ENUM</span> <span class="token punctuation">(</span><span class="token string">'M'</span><span class="token punctuation">,</span><span class="token string">'F'</span><span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
hire_date <span class="token datatype">DATE</span> <span class="token operator">NOT</span> <span class="token boolean">NULL</span><span class="token punctuation">,</span>
<span class="token keyword">PRIMARY</span> <span class="token keyword">KEY</span> <span class="token punctuation">(</span>emp_no<span class="token punctuation">)</span>
<span class="token punctuation">)</span> <span class="token keyword">COMPRESSION</span><span class="token operator">=</span><span class="token string">"zlib"</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true"># Insert data (not shown)</span>
<span class="token comment" spellcheck="true"># Query page compression metadata in INFORMATION_SCHEMA.INNODB_TABLESPACES</span>
<span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> SPACE<span class="token punctuation">,</span> <span class="token keyword">NAME</span><span class="token punctuation">,</span> FS_BLOCK_SIZE<span class="token punctuation">,</span> FILE_SIZE<span class="token punctuation">,</span> ALLOCATED_SIZE <span class="token keyword">FROM</span>
INFORMATION_SCHEMA<span class="token punctuation">.</span>INNODB_TABLESPACES <span class="token keyword">WHERE</span> <span class="token keyword">NAME</span><span class="token operator">=</span><span class="token string">'employees/employees'</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
SPACE<span class="token punctuation">:</span> 45
NAME<span class="token punctuation">:</span> employees/employees
FS_BLOCK_SIZE<span class="token punctuation">:</span> 4096
FILE_SIZE<span class="token punctuation">:</span> 23068672
ALLOCATED_SIZE<span class="token punctuation">:</span> 19415040</span></code></pre>
</div>
<p>
Page compression metadata for the employees table shows that the
apparent file size is 23068672 bytes while the actual file size
(with page compression) is 19415040 bytes. The file system block
size is 4096 bytes, which is the block size used for hole
punching.
</p>
<h4>
<a name="idm46045161056096">
</a>
Identifying Tables Using Page Compression
</h4>
<p>
To identify tables for which page compression is enabled, you can
check the Information Schema
<a class="link" href="information-schema-tables-table.html" title="28.3.38 The INFORMATION_SCHEMA TABLES Table">
<code class="literal">
TABLES
</code>
</a>
table's
<code class="literal">
CREATE_OPTIONS
</code>
column for tables
defined with the
<code class="literal">
COMPRESSION
</code>
attribute:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa37729320"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token keyword">TABLE_NAME</span><span class="token punctuation">,</span> TABLE_SCHEMA<span class="token punctuation">,</span> CREATE_OPTIONS <span class="token keyword">FROM</span> INFORMATION_SCHEMA<span class="token punctuation">.</span><span class="token keyword">TABLES</span>
<span class="token keyword">WHERE</span> CREATE_OPTIONS <span class="token operator">LIKE</span> <span class="token string">'%COMPRESSION=%'</span><span class="token punctuation">;</span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> TABLE_NAME <span class="token punctuation">|</span> TABLE_SCHEMA <span class="token punctuation">|</span> CREATE_OPTIONS <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span>
<span class="token output"><span class="token punctuation">|</span> employees <span class="token punctuation">|</span> test <span class="token punctuation">|</span> COMPRESSION="zlib" <span class="token punctuation">|</span></span>
<span class="token output"><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">-</span><span class="token punctuation">+</span></span></code></pre>
</div>
<p>
<a class="link" href="show-create-table.html" title="15.7.7.11 SHOW CREATE TABLE Statement">
<code class="literal">
SHOW CREATE TABLE
</code>
</a>
also shows the
<code class="literal">
COMPRESSION
</code>
attribute, if used.
</p>
<h4>
<a name="idm46045161047104">
</a>
Page Compression Limitations and Usage Notes
</h4>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Page compression is disabled if the file system block size (or
compression unit size on Windows) * 2 >
<a class="link" href="innodb-parameters.html#sysvar_innodb_page_size">
<code class="literal">
innodb_page_size
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
Page compression is not supported for tables that reside in
shared tablespaces, which include the system tablespace,
temporary tablespaces, and general tablespaces.
</p>
</li>
<li class="listitem">
<p>
Page compression is not supported for undo log tablespaces.
</p>
</li>
<li class="listitem">
<p>
Page compression is not supported for redo log pages.
</p>
</li>
<li class="listitem">
<p>
R-tree pages, which are used for spatial indexes, are not
compressed.
</p>
</li>
<li class="listitem">
<p>
Pages that belong to compressed tables
(
<code class="literal">
ROW_FORMAT=COMPRESSED
</code>
) are left as-is.
</p>
</li>
<li class="listitem">
<p>
During recovery, updated pages are written out in an
uncompressed form.
</p>
</li>
<li class="listitem">
<p>
Loading a page-compressed tablespace on a server that does not
support the compression algorithm that was used causes an I/O
error.
</p>
</li>
<li class="listitem">
<p>
Before downgrading to an earlier version of MySQL that does
not support page compression, uncompress the tables that use
the page compression feature. To uncompress a table, run
<a class="link" href="alter-table.html" title="15.1.9 ALTER TABLE Statement">
<code class="literal">
ALTER TABLE ...
COMPRESSION=None
</code>
</a>
and
<a class="link" href="optimize-table.html" title="15.7.3.4 OPTIMIZE TABLE Statement">
<code class="literal">
OPTIMIZE
TABLE
</code>
</a>
.
</p>
</li>
<li class="listitem">
<p>
Page-compressed tablespaces can be copied between Linux and
Windows servers if the compression algorithm that was used is
available on both servers.
</p>
</li>
<li class="listitem">
<p>
Preserving page compression when moving a page-compressed
tablespace file from one host to another requires a utility
that preserves sparse files.
</p>
</li>
<li class="listitem">
<p>
Better page compression may be achieved on Fusion-io hardware
with NVMFS than on other platforms, as NVMFS is designed to
take advantage of punch hole functionality.
</p>
</li>
<li class="listitem">
<p>
Using the page compression feature with a large
<code class="literal">
InnoDB
</code>
page size and relatively small file
system block size could result in write amplification. For
example, a maximum
<code class="literal">
InnoDB
</code>
page size of 64KB
with a 4KB file system block size may improve compression but
may also increase demand on the buffer pool, leading to
increased I/O and potential write amplification.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-error-summary-tables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="performance-schema-error-summary-tables">
</a>
29.12.20.11 Error Summary Tables
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045067998416">
</a>
<a class="indexterm" name="idm46045067996896">
</a>
<a class="indexterm" name="idm46045067995376">
</a>
<a class="indexterm" name="idm46045067993856">
</a>
<a class="indexterm" name="idm46045067992336">
</a>
<a class="indexterm" name="idm46045067990816">
</a>
<a class="indexterm" name="idm46045067989296">
</a>
<a class="indexterm" name="idm46045067987776">
</a>
<a class="indexterm" name="idm46045067986256">
</a>
<a class="indexterm" name="idm46045067984736">
</a>
<p>
The Performance Schema maintains summary tables for
aggregating statistical information about server errors (and
warnings). For a list of server errors, see
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html" target="_top">
Server Error Message Reference
</a>
.
</p>
<p>
Collection of error information is controlled by the
<code class="literal">
error
</code>
instrument, which is enabled by
default. Timing information is not collected.
</p>
<p>
Each error summary table has three columns that identify the
error:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
ERROR_NUMBER
</code>
is the numeric error
value. The value is unique.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ERROR_NAME
</code>
is the symbolic error name
corresponding to the
<code class="literal">
ERROR_NUMBER
</code>
value. The value is unique.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SQLSTATE
</code>
is the SQLSTATE value
corresponding to the
<code class="literal">
ERROR_NUMBER
</code>
value. The value is not necessarily unique.
</p>
</li>
</ul>
</div>
<p>
For example, if
<code class="literal">
ERROR_NUMBER
</code>
is 1050,
<code class="literal">
ERROR_NAME
</code>
is
<a class="ulink" href="/doc/mysql-errors/8.4/en/server-error-reference.html#error_er_table_exists_error" target="_top">
<code class="literal">
ER_TABLE_EXISTS_ERROR
</code>
</a>
and
<code class="literal">
SQLSTATE
</code>
is
<code class="literal">
42S01
</code>
.
</p>
<p>
Example error event summary information:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa60251128"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">SELECT</span> <span class="token operator">*</span>
<span class="token keyword">FROM</span> performance_schema<span class="token punctuation">.</span>events_errors_summary_global_by_error
<span class="token keyword">WHERE</span> SUM_ERROR_RAISED <span class="token operator"><></span> <span class="token number">0</span>\G
<span class="token output"><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 1. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
ERROR_NUMBER<span class="token punctuation">:</span> 1064
ERROR_NAME<span class="token punctuation">:</span> ER_PARSE_ERROR
SQL_STATE<span class="token punctuation">:</span> 42000
SUM_ERROR_RAISED<span class="token punctuation">:</span> 1
SUM_ERROR_HANDLED<span class="token punctuation">:</span> 0
FIRST_SEEN<span class="token punctuation">:</span> 2016-06-28 07<span class="token punctuation">:</span>34<span class="token punctuation">:</span>02
LAST_SEEN<span class="token punctuation">:</span> 2016-06-28 07<span class="token punctuation">:</span>34<span class="token punctuation">:</span>02
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 2. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
ERROR_NUMBER<span class="token punctuation">:</span> 1146
ERROR_NAME<span class="token punctuation">:</span> ER_NO_SUCH_TABLE
SQL_STATE<span class="token punctuation">:</span> 42S02
SUM_ERROR_RAISED<span class="token punctuation">:</span> 2
SUM_ERROR_HANDLED<span class="token punctuation">:</span> 0
FIRST_SEEN<span class="token punctuation">:</span> 2016-06-28 07<span class="token punctuation">:</span>34<span class="token punctuation">:</span>05
LAST_SEEN<span class="token punctuation">:</span> 2016-06-28 07<span class="token punctuation">:</span>36<span class="token punctuation">:</span>18
<span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span> 3. row <span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span><span class="token punctuation">*</span>
ERROR_NUMBER<span class="token punctuation">:</span> 1317
ERROR_NAME<span class="token punctuation">:</span> ER_QUERY_INTERRUPTED
SQL_STATE<span class="token punctuation">:</span> 70100
SUM_ERROR_RAISED<span class="token punctuation">:</span> 1
SUM_ERROR_HANDLED<span class="token punctuation">:</span> 0
FIRST_SEEN<span class="token punctuation">:</span> 2016-06-28 11<span class="token punctuation">:</span>01<span class="token punctuation">:</span>49
LAST_SEEN<span class="token punctuation">:</span> 2016-06-28 11<span class="token punctuation">:</span>01<span class="token punctuation">:</span>49</span></code></pre>
</div>
<p>
Each error summary table has one or more grouping columns to
indicate how the table aggregates errors:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="performance-schema-error-summary-tables.html" title="29.12.20.11 Error Summary Tables">
<code class="literal">
events_errors_summary_by_account_by_error
</code>
</a>
has
<code class="literal">
USER
</code>
,
<code class="literal">
HOST
</code>
, and
<code class="literal">
ERROR_NUMBER
</code>
columns. Each row
summarizes events for a given account (user and host
combination) and error.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-error-summary-tables.html" title="29.12.20.11 Error Summary Tables">
<code class="literal">
events_errors_summary_by_host_by_error
</code>
</a>
has
<code class="literal">
HOST
</code>
and
<code class="literal">
ERROR_NUMBER
</code>
columns. Each row
summarizes events for a given host and error.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-error-summary-tables.html" title="29.12.20.11 Error Summary Tables">
<code class="literal">
events_errors_summary_by_thread_by_error
</code>
</a>
has
<code class="literal">
THREAD_ID
</code>
and
<code class="literal">
ERROR_NUMBER
</code>
columns. Each row
summarizes events for a given thread and error.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-error-summary-tables.html" title="29.12.20.11 Error Summary Tables">
<code class="literal">
events_errors_summary_by_user_by_error
</code>
</a>
has
<code class="literal">
USER
</code>
and
<code class="literal">
ERROR_NUMBER
</code>
columns. Each row
summarizes events for a given user and error.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-error-summary-tables.html" title="29.12.20.11 Error Summary Tables">
<code class="literal">
events_errors_summary_global_by_error
</code>
</a>
has an
<code class="literal">
ERROR_NUMBER
</code>
column. Each row
summarizes events for a given error.
</p>
</li>
</ul>
</div>
<p>
Each error summary table has these summary columns containing
aggregated values:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
SUM_ERROR_RAISED
</code>
</p>
<p>
This column aggregates the number of times the error
occurred.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SUM_ERROR_HANDLED
</code>
</p>
<p>
This column aggregates the number of times the error was
handled by an SQL exception handler.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FIRST_SEEN
</code>
,
<code class="literal">
LAST_SEEN
</code>
</p>
<p>
Timestamp indicating when the error was first seen and
most recently seen.
</p>
</li>
</ul>
</div>
<p>
A
<code class="literal">
NULL
</code>
row in each error summary table is
used to aggregate statistics for all errors that lie out of
range of the instrumented errors. For example, if MySQL Server
errors lie in the range from
<em class="replaceable">
<code>
M
</code>
</em>
to
<em class="replaceable">
<code>
N
</code>
</em>
and an error is raised with
number
<em class="replaceable">
<code>
Q
</code>
</em>
not in that range, the
error is aggregated in the
<code class="literal">
NULL
</code>
row. The
<code class="literal">
NULL
</code>
row is the row with
<code class="literal">
ERROR_NUMBER=0
</code>
,
<code class="literal">
ERROR_NAME=NULL
</code>
, and
<code class="literal">
SQLSTATE=NULL
</code>
.
</p>
<p>
The error summary tables have these indexes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="performance-schema-error-summary-tables.html" title="29.12.20.11 Error Summary Tables">
<code class="literal">
events_errors_summary_by_account_by_error
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
USER
</code>
,
<code class="literal">
HOST
</code>
,
<code class="literal">
ERROR_NUMBER
</code>
)
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-error-summary-tables.html" title="29.12.20.11 Error Summary Tables">
<code class="literal">
events_errors_summary_by_host_by_error
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
HOST
</code>
,
<code class="literal">
ERROR_NUMBER
</code>
)
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-error-summary-tables.html" title="29.12.20.11 Error Summary Tables">
<code class="literal">
events_errors_summary_by_thread_by_error
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
THREAD_ID
</code>
,
<code class="literal">
ERROR_NUMBER
</code>
)
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-error-summary-tables.html" title="29.12.20.11 Error Summary Tables">
<code class="literal">
events_errors_summary_by_user_by_error
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
USER
</code>
,
<code class="literal">
ERROR_NUMBER
</code>
)
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<a class="link" href="performance-schema-error-summary-tables.html" title="29.12.20.11 Error Summary Tables">
<code class="literal">
events_errors_summary_global_by_error
</code>
</a>
:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
Primary key on (
<code class="literal">
ERROR_NUMBER
</code>
)
</p>
</li>
</ul>
</div>
</li>
</ul>
</div>
<p>
<a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
<code class="literal">
TRUNCATE TABLE
</code>
</a>
is permitted for
error summary tables. It has these effects:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For summary tables not aggregated by account, host, or
user, truncation resets the summary columns to zero or
<code class="literal">
NULL
</code>
rather than removing rows.
</p>
</li>
<li class="listitem">
<p>
For summary tables aggregated by account, host, or user,
truncation removes rows for accounts, hosts, or users with
no connections, and resets the summary columns to zero or
<code class="literal">
NULL
</code>
for the remaining rows.
</p>
</li>
</ul>
</div>
<p>
In addition, each error summary table that is aggregated by
account, host, user, or thread is implicitly truncated by
truncation of the connection table on which it depends, or
truncation of
<a class="link" href="performance-schema-error-summary-tables.html" title="29.12.20.11 Error Summary Tables">
<code class="literal">
events_errors_summary_global_by_error
</code>
</a>
.
For details, see
<a class="xref" href="performance-schema-connection-tables.html" title="29.12.8 Performance Schema Connection Tables">
Section 29.12.8, “Performance Schema Connection Tables”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-backup-configuration.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="mysql-cluster-backup-configuration">
</a>
25.6.8.3 Configuration for NDB Cluster Backups
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045091957632">
</a>
<a class="indexterm" name="idm46045091956144">
</a>
<a class="indexterm" name="idm46045091954656">
</a>
<a class="indexterm" name="idm46045091953168">
</a>
<p>
Five configuration parameters are essential for backup:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="indexterm" name="idm46045091950448">
</a>
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-backupdatabuffersize">
<code class="literal">
BackupDataBufferSize
</code>
</a>
</p>
<p>
The amount of memory used to buffer data before it is
written to disk.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045091946816">
</a>
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-backuplogbuffersize">
<code class="literal">
BackupLogBufferSize
</code>
</a>
</p>
<p>
The amount of memory used to buffer log records before these
are written to disk.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045091943232">
</a>
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-backupmemory">
<code class="literal">
BackupMemory
</code>
</a>
</p>
<p>
The total memory allocated in a data node for backups. This
should be the sum of the memory allocated for the backup
data buffer and the backup log buffer.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045091939552">
</a>
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-backupwritesize">
<code class="literal">
BackupWriteSize
</code>
</a>
</p>
<p>
The default size of blocks written to disk. This applies for
both the backup data buffer and the backup log buffer.
</p>
</li>
<li class="listitem">
<p>
<a class="indexterm" name="idm46045091935936">
</a>
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-backupmaxwritesize">
<code class="literal">
BackupMaxWriteSize
</code>
</a>
</p>
<p>
The maximum size of blocks written to disk. This applies for
both the backup data buffer and the backup log buffer.
</p>
</li>
</ul>
</div>
<p>
In addition,
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-compressedbackup">
<code class="literal">
CompressedBackup
</code>
</a>
causes
<code class="literal">
NDB
</code>
to use compression when creating and
writing to backup files.
</p>
<p>
More detailed information about these parameters can be found in
<a class="link" href="mysql-cluster-ndbd-definition.html#mysql-cluster-backup-parameters" title="Backup parameters">
Backup
Parameters
</a>
.
</p>
<p>
You can also set a location for the backup files using the
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-backupdatadir">
<code class="literal">
BackupDataDir
</code>
</a>
configuration parameter. The default is
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-filesystempath">
<code class="literal">
FileSystemPath
</code>
</a>
<code class="filename">
/BACKUP/BACKUP-
<em class="replaceable">
<code>
backup_id
</code>
</em>
</code>
.
</p>
<p>
You can enforce encryption of backup files by setting
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-requireencryptedbackup">
<code class="literal">
RequireEncryptedBackup
</code>
</a>
to 1; this prevents the creation of backups without specifying
<code class="literal">
ENCRYPT
PASSWORD=
<em class="replaceable">
<code>
password
</code>
</em>
</code>
as part
of a
<code class="literal">
START BACKUP
</code>
command.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-features-shutdowns.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="replication-features-shutdowns">
</a>
19.5.1.28 Replication and Source or Replica Shutdowns
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045135192640">
</a>
<a class="indexterm" name="idm46045135191152">
</a>
<a class="indexterm" name="idm46045135189664">
</a>
<a class="indexterm" name="idm46045135188176">
</a>
<p>
It is safe to shut down a replication source server and restart
it later. When a replica loses its connection to the source, the
replica tries to reconnect immediately and retries periodically
if that fails. The default is to retry every 60 seconds. This
may be changed with the
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION
SOURCE TO
</code>
</a>
statement. A replica also is able to deal
with network connectivity outages. However, the replica notices
the network outage only after receiving no data from the source
for
<a class="link" href="replication-options-replica.html#sysvar_replica_net_timeout">
<code class="literal">
replica_net_timeout
</code>
</a>
seconds. If your outages are short, you may want to decrease the
value of
<a class="link" href="replication-options-replica.html#sysvar_replica_net_timeout">
<code class="literal">
replica_net_timeout
</code>
</a>
.
See
<a class="xref" href="replication-solutions-unexpected-replica-halt.html" title="19.4.2 Handling an Unexpected Halt of a Replica">
Section 19.4.2, “Handling an Unexpected Halt of a Replica”
</a>
.
</p>
<p>
An unclean shutdown (for example, a crash) on the source side
can result in the source's binary log having a final position
less than the most recent position read by the replica, due to
the source's binary log file not being flushed. This can cause
the replica not to be able to replicate when the source comes
back up. Setting
<a class="link" href="replication-options-binary-log.html#sysvar_sync_binlog">
<code class="literal">
sync_binlog=1
</code>
</a>
in the source server's
<code class="filename">
my.cnf
</code>
file helps to
minimize this problem because it causes the source to flush its
binary log more frequently. For the greatest possible durability
and consistency in a replication setup using
<code class="literal">
InnoDB
</code>
with transactions, you should also set
<a class="link" href="innodb-parameters.html#sysvar_innodb_flush_log_at_trx_commit">
<code class="literal">
innodb_flush_log_at_trx_commit=1
</code>
</a>
.
With this setting, the contents of the
<code class="literal">
InnoDB
</code>
redo log buffer are written out to the log file at each
transaction commit and the log file is flushed to disk. Note
that the durability of transactions is still not guaranteed with
this setting, because operating systems or disk hardware may
tell
<a class="link" href="mysqld.html" title="6.3.1 mysqld — The MySQL Server">
<span class="command">
<strong>
mysqld
</strong>
</span>
</a>
that the flush-to-disk operation
has taken place, even though it has not.
</p>
<p>
Shutting down a replica cleanly is safe because it keeps track
of where it left off. However, be careful that the replica does
not have temporary tables open; see
<a class="xref" href="replication-features-temptables.html" title="19.5.1.31 Replication and Temporary Tables">
Section 19.5.1.31, “Replication and Temporary Tables”
</a>
. Unclean
shutdowns might produce problems, especially if the disk cache
was not flushed to disk before the problem occurred:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
For transactions, the replica commits and then updates
<code class="filename">
relay-log.info
</code>
. If an unexpected exit
occurs between these two operations, relay log processing
proceeds further than the information file indicates and the
replica re-executes the events from the last transaction in
the relay log after it has been restarted.
</p>
</li>
<li class="listitem">
<p>
A similar problem can occur if the replica updates
<code class="filename">
relay-log.info
</code>
but the server host
crashes before the write has been flushed to disk. To
minimize the chance of this occurring, set
<a class="link" href="replication-options-replica.html#sysvar_sync_relay_log_info">
<code class="literal">
sync_relay_log_info=1
</code>
</a>
in
the replica
<code class="filename">
my.cnf
</code>
file. Setting
<a class="link" href="replication-options-replica.html#sysvar_sync_relay_log_info">
<code class="literal">
sync_relay_log_info
</code>
</a>
to 0
causes no writes to be forced to disk and the server relies
on the operating system to flush the file from time to time.
</p>
</li>
</ul>
</div>
<p>
The fault tolerance of your system for these types of problems
is greatly increased if you have a good uninterruptible power
supply.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/loading-tables.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="loading-tables">
</a>
5.3.3 Loading Data into a Table
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045325408192">
</a>
<a class="indexterm" name="idm46045325406736">
</a>
<a class="indexterm" name="idm46045325405248">
</a>
<p>
After creating your table, you need to populate it. The
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD DATA
</code>
</a>
and
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements are useful for
this.
</p>
<p>
Suppose that your pet records can be described as shown here.
(Observe that MySQL expects dates in
<code class="literal">
'
<em class="replaceable">
<code>
YYYY-MM-DD
</code>
</em>
'
</code>
format; this may differ from what you are used to.)
</p>
<div class="informaltable">
<table summary="Example of pet records mentioned in the preceding text.">
<colgroup>
<col style="width: 10%"/>
<col style="width: 10%"/>
<col style="width: 10%"/>
<col style="width: 05%"/>
<col style="width: 20%"/>
<col style="width: 20%"/>
</colgroup>
<thead>
<tr>
<th scope="col">
name
</th>
<th scope="col">
owner
</th>
<th scope="col">
species
</th>
<th scope="col">
sex
</th>
<th scope="col">
birth
</th>
<th scope="col">
death
</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">
Fluffy
</th>
<td>
Harold
</td>
<td>
cat
</td>
<td>
f
</td>
<td>
1993-02-04
</td>
<td>
</td>
</tr>
<tr>
<th scope="row">
Claws
</th>
<td>
Gwen
</td>
<td>
cat
</td>
<td>
m
</td>
<td>
1994-03-17
</td>
<td>
</td>
</tr>
<tr>
<th scope="row">
Buffy
</th>
<td>
Harold
</td>
<td>
dog
</td>
<td>
f
</td>
<td>
1989-05-13
</td>
<td>
</td>
</tr>
<tr>
<th scope="row">
Fang
</th>
<td>
Benny
</td>
<td>
dog
</td>
<td>
m
</td>
<td>
1990-08-27
</td>
<td>
</td>
</tr>
<tr>
<th scope="row">
Bowser
</th>
<td>
Diane
</td>
<td>
dog
</td>
<td>
m
</td>
<td>
1979-08-31
</td>
<td>
1995-07-29
</td>
</tr>
<tr>
<th scope="row">
Chirpy
</th>
<td>
Gwen
</td>
<td>
bird
</td>
<td>
f
</td>
<td>
1998-09-11
</td>
<td>
</td>
</tr>
<tr>
<th scope="row">
Whistler
</th>
<td>
Gwen
</td>
<td>
bird
</td>
<td>
</td>
<td>
1997-12-09
</td>
<td>
</td>
</tr>
<tr>
<th scope="row">
Slim
</th>
<td>
Benny
</td>
<td>
snake
</td>
<td>
m
</td>
<td>
1996-04-29
</td>
<td>
</td>
</tr>
</tbody>
</table>
</div>
<p>
Because you are beginning with an empty table, an easy way to
populate it is to create a text file containing a row for each
of your animals, then load the contents of the file into the
table with a single statement.
</p>
<p>
You could create a text file
<code class="filename">
pet.txt
</code>
containing one record per line, with values separated by tabs,
and given in the order in which the columns were listed in the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement. For
missing values (such as unknown sexes or death dates for animals
that are still living), you can use
<code class="literal">
NULL
</code>
values. To represent these in your text file, use
<code class="literal">
\N
</code>
(backslash, capital-N). For example, the
record for Whistler the bird would look like this (where the
whitespace between values is a single tab character):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-none"><div class="docs-select-all right" id="sa99773372"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-none">Whistler Gwen bird \N 1997-12-09 \N</code></pre>
</div>
<p>
To load the text file
<code class="filename">
pet.txt
</code>
into the
<code class="literal">
pet
</code>
table, use this statement:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa89099957"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">LOAD</span> <span class="token keyword">DATA</span> <span class="token keyword">LOCAL</span> <span class="token keyword">INFILE</span> <span class="token string">'/path/pet.txt'</span> <span class="token keyword">INTO</span> <span class="token keyword">TABLE</span> pet<span class="token punctuation">;</span></code></pre>
</div>
<p>
If you created the file on Windows with an editor that uses
<code class="literal">
\r\n
</code>
as a line terminator, you should use
this statement instead:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa40976185"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">LOAD</span> <span class="token keyword">DATA</span> <span class="token keyword">LOCAL</span> <span class="token keyword">INFILE</span> <span class="token string">'/path/pet.txt'</span> <span class="token keyword">INTO</span> <span class="token keyword">TABLE</span> pet
<span class="token keyword">LINES</span> <span class="token keyword">TERMINATED</span> <span class="token keyword">BY</span> <span class="token string">'\r\n'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
(On an Apple machine running macOS, you would likely want to use
<code class="literal">
LINES TERMINATED BY '\r'
</code>
.)
</p>
<p>
You can specify the column value separator and end of line
marker explicitly in the
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD
DATA
</code>
</a>
statement if you wish, but the defaults are tab
and linefeed. These are sufficient for the statement to read the
file
<code class="filename">
pet.txt
</code>
properly.
</p>
<p>
If the statement fails, it is likely that your MySQL
installation does not have local file capability enabled by
default. See
<a class="xref" href="load-data-local-security.html" title="8.1.6 Security Considerations for LOAD DATA LOCAL">
Section 8.1.6, “Security Considerations for LOAD DATA LOCAL”
</a>
, for
information on how to change this.
</p>
<p>
When you want to add new records one at a time, the
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statement is useful. In
its simplest form, you supply values for each column, in the
order in which the columns were listed in the
<a class="link" href="create-table.html" title="15.1.20 CREATE TABLE Statement">
<code class="literal">
CREATE TABLE
</code>
</a>
statement. Suppose
that Diane gets a new hamster named
<span class="quote">
“
<span class="quote">
Puffball.
</span>
”
</span>
You
could add a new record using an
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statement like this:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa68604746"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">INSERT</span> <span class="token keyword">INTO</span> pet
<span class="token keyword">VALUES</span> <span class="token punctuation">(</span><span class="token string">'Puffball'</span><span class="token punctuation">,</span><span class="token string">'Diane'</span><span class="token punctuation">,</span><span class="token string">'hamster'</span><span class="token punctuation">,</span><span class="token string">'f'</span><span class="token punctuation">,</span><span class="token string">'1999-03-30'</span><span class="token punctuation">,</span><span class="token boolean">NULL</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
String and date values are specified as quoted strings here.
Also, with
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
, you can insert
<code class="literal">
NULL
</code>
directly to represent a missing value.
You do not use
<code class="literal">
\N
</code>
like you do with
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD DATA
</code>
</a>
.
</p>
<p>
From this example, you should be able to see that there would be
a lot more typing involved to load your records initially using
several
<a class="link" href="insert.html" title="15.2.7 INSERT Statement">
<code class="literal">
INSERT
</code>
</a>
statements rather
than a single
<a class="link" href="load-data.html" title="15.2.9 LOAD DATA Statement">
<code class="literal">
LOAD DATA
</code>
</a>
statement.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/information-schema-parameters-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="information-schema-parameters-table">
</a>
28.3.20 The INFORMATION_SCHEMA PARAMETERS Table
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045079440640">
</a>
<p>
The
<a class="link" href="information-schema-parameters-table.html" title="28.3.20 The INFORMATION_SCHEMA PARAMETERS Table">
<code class="literal">
PARAMETERS
</code>
</a>
table provides
information about parameters for stored routines (stored
procedures and stored functions), and about return values for
stored functions. The
<a class="link" href="information-schema-parameters-table.html" title="28.3.20 The INFORMATION_SCHEMA PARAMETERS Table">
<code class="literal">
PARAMETERS
</code>
</a>
table does not include built-in (native) functions or loadable
functions.
</p>
<p>
The
<a class="link" href="information-schema-parameters-table.html" title="28.3.20 The INFORMATION_SCHEMA PARAMETERS Table">
<code class="literal">
PARAMETERS
</code>
</a>
table has these
columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
SPECIFIC_CATALOG
</code>
</p>
<p>
The name of the catalog to which the routine containing the
parameter belongs. This value is always
<code class="literal">
def
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SPECIFIC_SCHEMA
</code>
</p>
<p>
The name of the schema (database) to which the routine
containing the parameter belongs.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SPECIFIC_NAME
</code>
</p>
<p>
The name of the routine containing the parameter.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ORDINAL_POSITION
</code>
</p>
<p>
For successive parameters of a stored procedure or function,
the
<code class="literal">
ORDINAL_POSITION
</code>
values are 1, 2, 3,
and so forth. For a stored function, there is also a row that
applies to the function return value (as described by the
<code class="literal">
RETURNS
</code>
clause). The return value is not a
true parameter, so the row that describes it has these unique
characteristics:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: circle; ">
<li class="listitem">
<p>
The
<code class="literal">
ORDINAL_POSITION
</code>
value is 0.
</p>
</li>
<li class="listitem">
<p>
The
<code class="literal">
PARAMETER_NAME
</code>
and
<code class="literal">
PARAMETER_MODE
</code>
values are
<code class="literal">
NULL
</code>
because the return value has no
name and the mode does not apply.
</p>
</li>
</ul>
</div>
</li>
<li class="listitem">
<p>
<code class="literal">
PARAMETER_MODE
</code>
</p>
<p>
The mode of the parameter. This value is one of
<code class="literal">
IN
</code>
,
<code class="literal">
OUT
</code>
, or
<code class="literal">
INOUT
</code>
. For a stored function return value,
this value is
<code class="literal">
NULL
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PARAMETER_NAME
</code>
</p>
<p>
The name of the parameter. For a stored function return value,
this value is
<code class="literal">
NULL
</code>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DATA_TYPE
</code>
</p>
<p>
The parameter data type.
</p>
<p>
The
<code class="literal">
DATA_TYPE
</code>
value is the type name only
with no other information. The
<code class="literal">
DTD_IDENTIFIER
</code>
value contains the type name
and possibly other information such as the precision or
length.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CHARACTER_MAXIMUM_LENGTH
</code>
</p>
<p>
For string parameters, the maximum length in characters.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CHARACTER_OCTET_LENGTH
</code>
</p>
<p>
For string parameters, the maximum length in bytes.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NUMERIC_PRECISION
</code>
</p>
<p>
For numeric parameters, the numeric precision.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NUMERIC_SCALE
</code>
</p>
<p>
For numeric parameters, the numeric scale.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DATETIME_PRECISION
</code>
</p>
<p>
For temporal parameters, the fractional seconds precision.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CHARACTER_SET_NAME
</code>
</p>
<p>
For character string parameters, the character set name.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
COLLATION_NAME
</code>
</p>
<p>
For character string parameters, the collation name.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DTD_IDENTIFIER
</code>
</p>
<p>
The parameter data type.
</p>
<p>
The
<code class="literal">
DATA_TYPE
</code>
value is the type name only
with no other information. The
<code class="literal">
DTD_IDENTIFIER
</code>
value contains the type name
and possibly other information such as the precision or
length.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ROUTINE_TYPE
</code>
</p>
<p>
<code class="literal">
PROCEDURE
</code>
for stored procedures,
<code class="literal">
FUNCTION
</code>
for stored functions.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/sys-io-global-by-file-by-latency.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="sys-io-global-by-file-by-latency">
</a>
30.4.3.12 The io_global_by_file_by_latency and x$io_global_by_file_by_latency
Views
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045062999264">
</a>
<a class="indexterm" name="idm46045062997808">
</a>
<a class="indexterm" name="idm46045062996304">
</a>
<a class="indexterm" name="idm46045062994800">
</a>
<p>
These views summarize global I/O consumers to display time
waiting for I/O, grouped by file. By default, rows are sorted
by descending total latency.
</p>
<p>
The
<a class="link" href="sys-io-global-by-file-by-latency.html" title="30.4.3.12 The io_global_by_file_by_latency and x$io_global_by_file_by_latency Views">
<code class="literal">
io_global_by_file_by_latency
</code>
</a>
and
<a class="link" href="sys-io-global-by-file-by-latency.html" title="30.4.3.12 The io_global_by_file_by_latency and x$io_global_by_file_by_latency Views">
<code class="literal">
x$io_global_by_file_by_latency
</code>
</a>
views have these columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
file
</code>
</p>
<p>
The file path name.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total
</code>
</p>
<p>
The total number of I/O events for the file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total_latency
</code>
</p>
<p>
The total wait time of timed I/O events for the file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
count_read
</code>
</p>
<p>
The total number of read I/O events for the file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
read_latency
</code>
</p>
<p>
The total wait time of timed read I/O events for the file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
count_write
</code>
</p>
<p>
The total number of write I/O events for the file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
write_latency
</code>
</p>
<p>
The total wait time of timed write I/O events for the
file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
count_misc
</code>
</p>
<p>
The total number of other I/O events for the file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
misc_latency
</code>
</p>
<p>
The total wait time of timed other I/O events for the
file.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/install-plugin.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="install-plugin">
</a>
15.7.4.4 INSTALL PLUGIN Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045171738464">
</a>
<a class="indexterm" name="idm46045171737376">
</a>
<a class="indexterm" name="idm46045171736304">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa64526415"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">INSTALL</span> <span class="token keyword">PLUGIN</span> <em class="replaceable">plugin_name</em> <span class="token keyword">SONAME</span> <span class="token string">'<em class="replaceable">shared_library_name</em>'</span></code></pre>
</div>
<p>
This statement installs a server plugin. It requires the
<a class="link" href="privileges-provided.html#priv_insert">
<code class="literal">
INSERT
</code>
</a>
privilege for the
<code class="literal">
mysql.plugin
</code>
system table because it adds a
row to that table to register the plugin.
</p>
<p>
<em class="replaceable">
<code>
plugin_name
</code>
</em>
is the name of the plugin
as defined in the plugin descriptor structure contained in the
library file (see
<a class="ulink" href="/doc/extending-mysql/8.4/en/plugin-data-structures.html" target="_top">
Plugin Data Structures
</a>
).
Plugin names are not case-sensitive. For maximal compatibility,
plugin names should be limited to ASCII letters, digits, and
underscore because they are used in C source files, shell
command lines, M4 and Bourne shell scripts, and SQL
environments.
</p>
<p>
<em class="replaceable">
<code>
shared_library_name
</code>
</em>
is the name of
the shared library that contains the plugin code. The name
includes the file name extension (for example,
<code class="filename">
libmyplugin.so
</code>
,
<code class="filename">
libmyplugin.dll
</code>
, or
<code class="filename">
libmyplugin.dylib
</code>
).
</p>
<p>
The shared library must be located in the plugin directory (the
directory named by the
<a class="link" href="server-system-variables.html#sysvar_plugin_dir">
<code class="literal">
plugin_dir
</code>
</a>
system variable).
The library must be in the plugin directory itself, not in a
subdirectory. By default,
<a class="link" href="server-system-variables.html#sysvar_plugin_dir">
<code class="literal">
plugin_dir
</code>
</a>
is the
<code class="filename">
plugin
</code>
directory under the directory named
by the
<code class="literal">
pkglibdir
</code>
configuration variable, but
it can be changed by setting the value of
<a class="link" href="server-system-variables.html#sysvar_plugin_dir">
<code class="literal">
plugin_dir
</code>
</a>
at server startup.
For example, set its value in a
<code class="filename">
my.cnf
</code>
file:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-ini"><div class="docs-select-all right" id="sa90331524"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-ini"><span class="token selector">[mysqld]</span>
<span class="token constant">plugin_dir</span><span class="token attr-value"><span class="token punctuation">=</span><em class="replaceable">/path/to/plugin/directory</em></span></code></pre>
</div>
<p>
If the value of
<a class="link" href="server-system-variables.html#sysvar_plugin_dir">
<code class="literal">
plugin_dir
</code>
</a>
is a
relative path name, it is taken to be relative to the MySQL base
directory (the value of the
<a class="link" href="server-system-variables.html#sysvar_basedir">
<code class="literal">
basedir
</code>
</a>
system variable).
</p>
<p>
<a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
<code class="literal">
INSTALL PLUGIN
</code>
</a>
loads and
initializes the plugin code to make the plugin available for
use. A plugin is initialized by executing its initialization
function, which handles any setup that the plugin must perform
before it can be used. When the server shuts down, it executes
the deinitialization function for each plugin that is loaded so
that the plugin has a chance to perform any final cleanup.
</p>
<p>
<a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
<code class="literal">
INSTALL PLUGIN
</code>
</a>
also registers the
plugin by adding a line that indicates the plugin name and
library file name to the
<code class="literal">
mysql.plugin
</code>
system
table. During the normal startup sequence, the server loads and
initializes plugins registered in
<code class="literal">
mysql.plugin
</code>
. This means that a plugin is
installed with
<a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
<code class="literal">
INSTALL PLUGIN
</code>
</a>
only once, not every time the server starts. If the server is
started with the
<a class="link" href="server-options.html#option_mysqld_skip-grant-tables">
<code class="option">
--skip-grant-tables
</code>
</a>
option,
plugins registered in the
<code class="literal">
mysql.plugin
</code>
table
are not loaded and are unavailable.
</p>
<p>
A plugin library can contain multiple plugins. For each of them
to be installed, use a separate
<a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
<code class="literal">
INSTALL
PLUGIN
</code>
</a>
statement. Each statement names a different
plugin, but all of them specify the same library name.
</p>
<p>
<a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
<code class="literal">
INSTALL PLUGIN
</code>
</a>
causes the server
to read option (
<code class="filename">
my.cnf
</code>
) files just as
during server startup. This enables the plugin to pick up any
relevant options from those files. It is possible to add plugin
options to an option file even before loading a plugin (if the
<code class="literal">
loose
</code>
prefix is used). It is also possible to
uninstall a plugin, edit
<code class="filename">
my.cnf
</code>
, and
install the plugin again. Restarting the plugin this way enables
it to the new option values without a server restart.
</p>
<p>
For options that control individual plugin loading at server
startup, see
<a class="xref" href="plugin-loading.html" title="7.6.1 Installing and Uninstalling Plugins">
Section 7.6.1, “Installing and Uninstalling Plugins”
</a>
. If you need to
load plugins for a single server startup when the
<a class="link" href="server-options.html#option_mysqld_skip-grant-tables">
<code class="option">
--skip-grant-tables
</code>
</a>
option is
given (which tells the server not to read system tables), use
the
<a class="link" href="server-options.html#option_mysqld_plugin-load">
<code class="option">
--plugin-load
</code>
</a>
option. See
<a class="xref" href="server-options.html" title="7.1.7 Server Command Options">
Section 7.1.7, “Server Command Options”
</a>
.
</p>
<p>
To remove a plugin, use the
<a class="link" href="uninstall-plugin.html" title="15.7.4.6 UNINSTALL PLUGIN Statement">
<code class="literal">
UNINSTALL
PLUGIN
</code>
</a>
statement.
</p>
<p>
For additional information about plugin loading, see
<a class="xref" href="plugin-loading.html" title="7.6.1 Installing and Uninstalling Plugins">
Section 7.6.1, “Installing and Uninstalling Plugins”
</a>
.
</p>
<p>
To see what plugins are installed, use the
<a class="link" href="show-plugins.html" title="15.7.7.27 SHOW PLUGINS Statement">
<code class="literal">
SHOW PLUGINS
</code>
</a>
statement or query
the
<code class="literal">
INFORMATION_SCHEMA
</code>
the
<a class="link" href="information-schema-plugins-table.html" title="28.3.22 The INFORMATION_SCHEMA PLUGINS Table">
<code class="literal">
PLUGINS
</code>
</a>
table.
</p>
<p>
If you recompile a plugin library and need to reinstall it, you
can use either of the following methods:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Use
<a class="link" href="uninstall-plugin.html" title="15.7.4.6 UNINSTALL PLUGIN Statement">
<code class="literal">
UNINSTALL PLUGIN
</code>
</a>
to
uninstall all plugins in the library, install the new plugin
library file in the plugin directory, and then use
<a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
<code class="literal">
INSTALL PLUGIN
</code>
</a>
to install all
plugins in the library. This procedure has the advantage
that it can be used without stopping the server. However, if
the plugin library contains many plugins, you must issue
many
<a class="link" href="install-plugin.html" title="15.7.4.4 INSTALL PLUGIN Statement">
<code class="literal">
INSTALL PLUGIN
</code>
</a>
and
<a class="link" href="uninstall-plugin.html" title="15.7.4.6 UNINSTALL PLUGIN Statement">
<code class="literal">
UNINSTALL PLUGIN
</code>
</a>
statements.
</p>
</li>
<li class="listitem">
<p>
Stop the server, install the new plugin library file in the
plugin directory, and restart the server.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/performance-schema-tp-thread-group-stats-table.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="performance-schema-tp-thread-group-stats-table">
</a>
29.12.16.3 The tp_thread_group_stats Table
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045069770432">
</a>
<a class="indexterm" name="idm46045069768928">
</a>
<p>
The
<a class="link" href="performance-schema-tp-thread-group-stats-table.html" title="29.12.16.3 The tp_thread_group_stats Table">
<code class="literal">
tp_thread_group_stats
</code>
</a>
table
reports statistics per thread group. There is one row per
group.
</p>
<p>
The
<a class="link" href="performance-schema-tp-thread-group-stats-table.html" title="29.12.16.3 The tp_thread_group_stats Table">
<code class="literal">
tp_thread_group_stats
</code>
</a>
table
has these columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
TP_GROUP_ID
</code>
</p>
<p>
The thread group ID. This is a unique key within the
table.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONNECTIONS_STARTED
</code>
</p>
<p>
The number of connections started.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
CONNECTIONS_CLOSED
</code>
</p>
<p>
The number of connections closed.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
QUERIES_EXECUTED
</code>
</p>
<p>
The number of statements executed. This number is
incremented when a statement starts executing, not when it
finishes.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
QUERIES_QUEUED
</code>
</p>
<p>
The number of statements received that were queued for
execution. This does not count statements that the thread
group was able to begin executing immediately without
queuing, which can happen under the conditions described
in
<a class="xref" href="thread-pool-operation.html" title="7.6.3.3 Thread Pool Operation">
Section 7.6.3.3, “Thread Pool Operation”
</a>
.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
THREADS_STARTED
</code>
</p>
<p>
The number of threads started.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
PRIO_KICKUPS
</code>
</p>
<p>
The number of statements that have been moved from
low-priority queue to high-priority queue based on the
value of the
<a class="link" href="server-system-variables.html#sysvar_thread_pool_prio_kickup_timer">
<code class="literal">
thread_pool_prio_kickup_timer
</code>
</a>
system variable. If this number increases quickly,
consider increasing the value of that variable. A quickly
increasing counter means that the priority system is not
keeping transactions from starting too early. For
<a class="link" href="innodb-storage-engine.html" title="Chapter 17 The InnoDB Storage Engine">
<code class="literal">
InnoDB
</code>
</a>
, this most likely
means deteriorating performance due to too many concurrent
transactions..
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
STALLED_QUERIES_EXECUTED
</code>
</p>
<p>
The number of statements that have become defined as
stalled due to executing for longer than the value of the
<a class="link" href="server-system-variables.html#sysvar_thread_pool_stall_limit">
<code class="literal">
thread_pool_stall_limit
</code>
</a>
system variable.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BECOME_CONSUMER_THREAD
</code>
</p>
<p>
The number of times thread have been assigned the consumer
thread role.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BECOME_RESERVE_THREAD
</code>
</p>
<p>
The number of times threads have been assigned the reserve
thread role.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BECOME_WAITING_THREAD
</code>
</p>
<p>
The number of times threads have been assigned the waiter
thread role. When statements are queued, this happens very
often, even in normal operation, so rapid increases in
this value are normal in the case of a highly loaded
system where statements are queued up.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
WAKE_THREAD_STALL_CHECKER
</code>
</p>
<p>
The number of times the stall check thread decided to wake
or create a thread to possibly handle some statements or
take care of the waiter thread role.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
SLEEP_WAITS
</code>
</p>
<p>
The number of
<code class="literal">
THD_WAIT_SLEEP
</code>
waits.
These occur when threads go to sleep (for example, by
calling the
<a class="link" href="miscellaneous-functions.html#function_sleep">
<code class="literal">
SLEEP()
</code>
</a>
function).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
DISK_IO_WAITS
</code>
</p>
<p>
The number of
<code class="literal">
THD_WAIT_DISKIO
</code>
waits.
These occur when threads perform disk I/O that is likely
to not hit the file system cache. Such waits occur when
the buffer pool reads and writes data to disk, not for
normal reads from and writes to files.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ROW_LOCK_WAITS
</code>
</p>
<p>
The number of
<code class="literal">
THD_WAIT_ROW_LOCK
</code>
waits
for release of a row lock by another transaction.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GLOBAL_LOCK_WAITS
</code>
</p>
<p>
The number of
<code class="literal">
THD_WAIT_GLOBAL_LOCK
</code>
waits for a global lock to be released.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
META_DATA_LOCK_WAITS
</code>
</p>
<p>
The number of
<code class="literal">
THD_WAIT_META_DATA_LOCK
</code>
waits for a metadata lock to be released.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
TABLE_LOCK_WAITS
</code>
</p>
<p>
The number of
<code class="literal">
THD_WAIT_TABLE_LOCK
</code>
waits
for a table to be unlocked that the statement needs to
access.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
USER_LOCK_WAITS
</code>
</p>
<p>
The number of
<code class="literal">
THD_WAIT_USER_LOCK
</code>
waits
for a special lock constructed by the user thread.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
BINLOG_WAITS
</code>
</p>
<p>
The number of
<code class="literal">
THD_WAIT_BINLOG_WAITS
</code>
waits for the binary log to become free.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
GROUP_COMMIT_WAITS
</code>
</p>
<p>
The number of
<code class="literal">
THD_WAIT_GROUP_COMMIT
</code>
waits. These occur when a group commit must wait for the
other parties to complete their part of a transaction.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
FSYNC_WAITS
</code>
</p>
<p>
The number of
<code class="literal">
THD_WAIT_SYNC
</code>
waits for a
file sync operation.
</p>
</li>
</ul>
</div>
<p>
The
<a class="link" href="performance-schema-tp-thread-group-stats-table.html" title="29.12.16.3 The tp_thread_group_stats Table">
<code class="literal">
tp_thread_group_stats
</code>
</a>
table
has these indexes:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Unique index on (
<code class="literal">
TP_GROUP_ID
</code>
)
</p>
</li>
</ul>
</div>
<p>
<a class="link" href="truncate-table.html" title="15.1.37 TRUNCATE TABLE Statement">
<code class="literal">
TRUNCATE TABLE
</code>
</a>
is not permitted
for the
<a class="link" href="performance-schema-tp-thread-group-stats-table.html" title="29.12.16.3 The tp_thread_group_stats Table">
<code class="literal">
tp_thread_group_stats
</code>
</a>
table.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/group-replication-throttling.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="group-replication-throttling">
</a>
20.7.2.2 Group Replication Throttling
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045132194528">
</a>
<p>
Based on the metrics gathered across all servers in the group, a
throttling mechanism kicks in and decides whether to limit the
rate a member is able to execute/commit new transactions.
</p>
<p>
Therefore, metrics acquired from all members are the basis for
calculating the capacity of each member: if a member has a large
queue (for certification or the applier thread), then the
capacity to execute new transactions should be close to ones
certified or applied in the last period.
</p>
<p>
The lowest capacity of all the members in the group determines
the real capacity of the group, while the number of local
transactions determines how many members are writing to it, and,
consequently, how many members should that available capacity be
shared with.
</p>
<p>
This means that every member has an established write quota
based on the available capacity, in other words a number of
transactions it can safely issue for the next period. The
writer-quota is enforced by the throttling mechanism if the
queue size of the certifier or the binary log applier exceeds a
user-defined threshold.
</p>
<p>
The quota is reduced by the number of transactions that were
delayed in the last period, and then also further reduced by 10%
to allow the queue that triggered the problem to reduce its
size. In order to avoid large jumps in throughput once the queue
size goes beyond the threshold, the throughput is only allowed
to grow by the same 10% per period after that.
</p>
<p>
The current throttling mechanism does not penalize transactions
below quota, but delays finishing those transactions that exceed
it until the end of the monitoring period. As a consequence, if
the quota is very small for the write requests issued some
transactions may have latencies close to the monitoring period.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/mysql-cluster-programs-ndb-print-sys-file.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h3 class="title">
<a name="mysql-cluster-programs-ndb-print-sys-file">
</a>
25.5.21 ndb_print_sys_file — Print NDB System File Contents
</h3>
</div>
</div>
</div>
<a class="indexterm" name="idm46045100026144">
</a>
<p>
<a class="link" href="mysql-cluster-programs-ndb-print-sys-file.html" title="25.5.21 ndb_print_sys_file — Print NDB System File Contents">
<span class="command">
<strong>
ndb_print_sys_file
</strong>
</span>
</a>
obtains diagnostic
information from an NDB Cluster system file.
</p>
<h4>
<a name="idm46045100023328">
</a>
Usage
</h4>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-terminal"><div class="docs-select-all right" id="sa44824964"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-terminal">ndb_print_sys_file <em class="replaceable">file_name</em></code></pre>
</div>
<p>
<em class="replaceable">
<code>
file_name
</code>
</em>
is the name of a cluster
system file (sysfile). Cluster system files are located in a
data node's data directory
(
<a class="link" href="mysql-cluster-ndbd-definition.html#ndbparam-ndbd-datadir">
<code class="literal">
DataDir
</code>
</a>
); the path
under this directory to system files matches the pattern
<code class="filename">
ndb_
<em class="replaceable">
<code>
#
</code>
</em>
_fs/D
<em class="replaceable">
<code>
#
</code>
</em>
/DBDIH/P
<em class="replaceable">
<code>
#
</code>
</em>
.sysfile
</code>
.
In each case, the
<em class="replaceable">
<code>
#
</code>
</em>
represents a
number (not necessarily the same number). For more information,
see
<a class="ulink" href="/doc/ndb-internals/en/ndb-internals-ndbd-filesystemdir-files.html" target="_top">
NDB Cluster Data Node File System Directory
</a>
.
</p>
<p>
Like
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html" title="25.5.17 ndb_print_backup_file — Print NDB Backup File Contents">
<span class="command">
<strong>
ndb_print_backup_file
</strong>
</span>
</a>
and
<a class="link" href="mysql-cluster-programs-ndb-print-schema-file.html" title="25.5.20 ndb_print_schema_file — Print NDB Schema File Contents">
<span class="command">
<strong>
ndb_print_schema_file
</strong>
</span>
</a>
(and unlike most of the
other
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDB
</code>
</a>
utilities that are
intended to be run on a management server host or to connect to
a management server)
<a class="link" href="mysql-cluster-programs-ndb-print-backup-file.html" title="25.5.17 ndb_print_backup_file — Print NDB Backup File Contents">
<span class="command">
<strong>
ndb_print_backup_file
</strong>
</span>
</a>
must be run on a cluster data node, since it accesses the data
node file system directly. Because it does not make use of the
management server, this utility can be used when the management
server is not running, and even when the cluster has been
completely shut down.
</p>
<h4>
<a name="idm46045100009776">
</a>
Additional Options
</h4>
<p>
None.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/serialized-dictionary-information.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h2 class="title">
<a name="serialized-dictionary-information">
</a>
16.6 Serialized Dictionary Information (SDI)
</h2>
</div>
</div>
</div>
<p>
In addition to storing metadata about database objects in the data
dictionary, MySQL stores it in serialized form. This data is
referred to as serialized dictionary information (SDI).
<code class="literal">
InnoDB
</code>
stores SDI data within its tablespace
files.
<a class="link" href="mysql-cluster.html" title="Chapter 25 MySQL NDB Cluster 8.4">
<code class="literal">
NDBCLUSTER
</code>
</a>
stores SDI data in
the NDB dictionary. Other storage engines store SDI data in
<code class="filename">
.sdi
</code>
files that are created for a given table
in the table's database directory. SDI data is generated in a
compact
<code class="literal">
JSON
</code>
format.
</p>
<p>
Serialized dictionary information (SDI) is present in all
<code class="literal">
InnoDB
</code>
tablespace files except for temporary
tablespace and undo tablespace files. SDI records in an
<code class="literal">
InnoDB
</code>
tablespace file only describe table and
tablespace objects contained within the tablespace.
</p>
<p>
SDI data is updated by DDL operations on a table or
<a class="link" href="check-table.html" title="15.7.3.2 CHECK TABLE Statement">
<code class="literal">
CHECK TABLE FOR
UPGRADE
</code>
</a>
. SDI data is not updated when the MySQL server
is upgraded to a new release or version.
</p>
<p>
The presence of SDI data provides metadata redundancy. For
example, if the data dictionary becomes unavailable, object
metadata can be extracted directly from
<code class="literal">
InnoDB
</code>
tablespace files using the
<a class="link" href="ibd2sdi.html" title="6.6.1 ibd2sdi — InnoDB Tablespace SDI Extraction Utility">
<span class="command">
<strong>
ibd2sdi
</strong>
</span>
</a>
tool.
</p>
<p>
For
<code class="literal">
InnoDB
</code>
, an SDI record requires a single
index page, which is 16KB in size by default. However, SDI data is
compressed to reduce the storage footprint.
</p>
<p>
For partitioned
<code class="literal">
InnoDB
</code>
tables comprised of
multiple tablespaces, SDI data is stored in the tablespace file of
the first partition.
</p>
<p>
The MySQL server uses an internal API that is accessed during
<a class="link" href="glossary.html#glos_ddl" title="DDL">
DDL
</a>
operations to create and
maintain SDI records.
</p>
<p>
The
<a class="link" href="import-table.html" title="15.2.6 IMPORT TABLE Statement">
<code class="literal">
IMPORT TABLE
</code>
</a>
statement imports
<code class="literal">
MyISAM
</code>
tables based on information contained in
<code class="filename">
.sdi
</code>
files. For more information, see
<a class="xref" href="import-table.html" title="15.2.6 IMPORT TABLE Statement">
Section 15.2.6, “IMPORT TABLE Statement”
</a>
.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/sys-io-global-by-file-by-bytes.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="sys-io-global-by-file-by-bytes">
</a>
30.4.3.11 The io_global_by_file_by_bytes and x$io_global_by_file_by_bytes Views
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045063028000">
</a>
<a class="indexterm" name="idm46045063026544">
</a>
<a class="indexterm" name="idm46045063025040">
</a>
<a class="indexterm" name="idm46045063023536">
</a>
<p>
These views summarize global I/O consumers to display amount
of I/O, grouped by file. By default, rows are sorted by
descending total I/O (bytes read and written).
</p>
<p>
The
<a class="link" href="sys-io-global-by-file-by-bytes.html" title="30.4.3.11 The io_global_by_file_by_bytes and x$io_global_by_file_by_bytes Views">
<code class="literal">
io_global_by_file_by_bytes
</code>
</a>
and
<a class="link" href="sys-io-global-by-file-by-bytes.html" title="30.4.3.11 The io_global_by_file_by_bytes and x$io_global_by_file_by_bytes Views">
<code class="literal">
x$io_global_by_file_by_bytes
</code>
</a>
views have these columns:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
file
</code>
</p>
<p>
The file path name.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
count_read
</code>
</p>
<p>
The total number of read events for the file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total_read
</code>
</p>
<p>
The total number of bytes read from the file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
avg_read
</code>
</p>
<p>
The average number of bytes per read from the file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
count_write
</code>
</p>
<p>
The total number of write events for the file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total_written
</code>
</p>
<p>
The total number of bytes written to the file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
avg_write
</code>
</p>
<p>
The average number of bytes per write to the file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
total
</code>
</p>
<p>
The total number of bytes read and written for the file.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
write_pct
</code>
</p>
<p>
The percentage of total bytes of I/O that were writes.
</p>
</li>
</ul>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/subquery-materialization.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="subquery-materialization">
</a>
10.2.2.2 Optimizing Subqueries with Materialization
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045228220464">
</a>
<a class="indexterm" name="idm46045228219424">
</a>
<a class="indexterm" name="idm46045228217936">
</a>
<p>
The optimizer uses materialization to enable more efficient
subquery processing. Materialization speeds up query execution
by generating a subquery result as a temporary table, normally
in memory. The first time MySQL needs the subquery result, it
materializes that result into a temporary table. Any
subsequent time the result is needed, MySQL refers again to
the temporary table. The optimizer may index the table with a
hash index to make lookups fast and inexpensive. The index
contains unique values to eliminate duplicates and make the
table smaller.
</p>
<p>
Subquery materialization uses an in-memory temporary table
when possible, falling back to on-disk storage if the table
becomes too large. See
<a class="xref" href="internal-temporary-tables.html" title="10.4.4 Internal Temporary Table Use in MySQL">
Section 10.4.4, “Internal Temporary Table Use in MySQL”
</a>
.
</p>
<p>
If materialization is not used, the optimizer sometimes
rewrites a noncorrelated subquery as a correlated subquery.
For example, the following
<code class="literal">
IN
</code>
subquery is
noncorrelated (
<em class="replaceable">
<code>
where_condition
</code>
</em>
involves only columns from
<code class="literal">
t2
</code>
and not
<code class="literal">
t1
</code>
):
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa4243619"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1
<span class="token keyword">WHERE</span> t1<span class="token punctuation">.</span>a <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> t2<span class="token punctuation">.</span>b <span class="token keyword">FROM</span> t2 <span class="token keyword">WHERE</span> <em class="replaceable">where_condition</em><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The optimizer might rewrite this as an
<code class="literal">
EXISTS
</code>
correlated subquery:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa33649410"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1
<span class="token keyword">WHERE</span> <span class="token keyword">EXISTS</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> t2<span class="token punctuation">.</span>b <span class="token keyword">FROM</span> t2 <span class="token keyword">WHERE</span> <em class="replaceable">where_condition</em> <span class="token operator">AND</span> t1<span class="token punctuation">.</span>a<span class="token operator">=</span>t2<span class="token punctuation">.</span>b<span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Subquery materialization using a temporary table avoids such
rewrites and makes it possible to execute the subquery only
once rather than once per row of the outer query.
</p>
<p>
For subquery materialization to be used in MySQL, the
<a class="link" href="server-system-variables.html#sysvar_optimizer_switch">
<code class="literal">
optimizer_switch
</code>
</a>
system
variable
<a class="link" href="switchable-optimizations.html#optflag_materialization">
<code class="literal">
materialization
</code>
</a>
flag must be enabled. (See
<a class="xref" href="switchable-optimizations.html" title="10.9.2 Switchable Optimizations">
Section 10.9.2, “Switchable Optimizations”
</a>
.) With the
<a class="link" href="switchable-optimizations.html#optflag_materialization">
<code class="literal">
materialization
</code>
</a>
flag
enabled, materialization applies to subquery predicates that
appear anywhere (in the select list,
<code class="literal">
WHERE
</code>
,
<code class="literal">
ON
</code>
,
<code class="literal">
GROUP BY
</code>
,
<code class="literal">
HAVING
</code>
, or
<code class="literal">
ORDER BY
</code>
),
for predicates that fall into any of these use cases:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The predicate has this form, when no outer expression
<em class="replaceable">
<code>
oe_i
</code>
</em>
or inner expression
<em class="replaceable">
<code>
ie_i
</code>
</em>
is nullable.
<em class="replaceable">
<code>
N
</code>
</em>
is 1 or larger.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa91268358"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token punctuation">(</span><em class="replaceable">oe_1</em><span class="token punctuation">,</span> <em class="replaceable">oe_2</em><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">,</span> <em class="replaceable">oe_N</em><span class="token punctuation">)</span> <span class="token punctuation">[</span><span class="token operator">NOT</span><span class="token punctuation">]</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <em class="replaceable">ie_1</em><span class="token punctuation">,</span> <em class="replaceable">i_2</em><span class="token punctuation">,</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">,</span> <em class="replaceable">ie_N</em> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
The predicate has this form, when there is a single outer
expression
<em class="replaceable">
<code>
oe
</code>
</em>
and inner
expression
<em class="replaceable">
<code>
ie
</code>
</em>
. The expressions
can be nullable.
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting one-line language-sql"><div class="docs-select-all right" id="sa46470425"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><em class="replaceable">oe</em> <span class="token punctuation">[</span><span class="token operator">NOT</span><span class="token punctuation">]</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> <em class="replaceable">ie</em> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">)</span></code></pre>
</div>
</li>
<li class="listitem">
<p>
The predicate is
<code class="literal">
IN
</code>
or
<code class="literal">
NOT
IN
</code>
and a result of
<code class="literal">
UNKNOWN
</code>
(
<code class="literal">
NULL
</code>
) has the same meaning as a result
of
<code class="literal">
FALSE
</code>
.
</p>
</li>
</ul>
</div>
<p>
The following examples illustrate how the requirement for
equivalence of
<code class="literal">
UNKNOWN
</code>
and
<code class="literal">
FALSE
</code>
predicate evaluation affects whether
subquery materialization can be used. Assume that
<em class="replaceable">
<code>
where_condition
</code>
</em>
involves columns
only from
<code class="literal">
t2
</code>
and not
<code class="literal">
t1
</code>
so that the subquery is noncorrelated.
</p>
<p>
This query is subject to materialization:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa44275379"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1
<span class="token keyword">WHERE</span> t1<span class="token punctuation">.</span>a <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> t2<span class="token punctuation">.</span>b <span class="token keyword">FROM</span> t2 <span class="token keyword">WHERE</span> <em class="replaceable">where_condition</em><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Here, it does not matter whether the
<code class="literal">
IN
</code>
predicate returns
<code class="literal">
UNKNOWN
</code>
or
<code class="literal">
FALSE
</code>
. Either way, the row from
<code class="literal">
t1
</code>
is not included in the query result.
</p>
<p>
An example where subquery materialization is not used is the
following query, where
<code class="literal">
t2.b
</code>
is a nullable
column:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa37034004"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SELECT</span> <span class="token operator">*</span> <span class="token keyword">FROM</span> t1
<span class="token keyword">WHERE</span> <span class="token punctuation">(</span>t1<span class="token punctuation">.</span>a<span class="token punctuation">,</span>t1<span class="token punctuation">.</span>b<span class="token punctuation">)</span> <span class="token operator">NOT</span> <span class="token keyword">IN</span> <span class="token punctuation">(</span><span class="token keyword">SELECT</span> t2<span class="token punctuation">.</span>a<span class="token punctuation">,</span>t2<span class="token punctuation">.</span>b <span class="token keyword">FROM</span> t2
<span class="token keyword">WHERE</span> <em class="replaceable">where_condition</em><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
The following restrictions apply to the use of subquery
materialization:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
The types of the inner and outer expressions must match.
For example, the optimizer might be able to use
materialization if both expressions are integer or both
are decimal, but cannot if one expression is integer and
the other is decimal.
</p>
</li>
<li class="listitem">
<p>
The inner expression cannot be a
<a class="link" href="blob.html" title="13.3.4 The BLOB and TEXT Types">
<code class="literal">
BLOB
</code>
</a>
.
</p>
</li>
</ul>
</div>
<p>
Use of
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
with a query
provides some indication of whether the optimizer uses
subquery materialization:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
Compared to query execution that does not use
materialization,
<code class="literal">
select_type
</code>
may change
from
<code class="literal">
DEPENDENT SUBQUERY
</code>
to
<code class="literal">
SUBQUERY
</code>
. This indicates that, for a
subquery that would be executed once per outer row,
materialization enables the subquery to be executed just
once.
</p>
</li>
<li class="listitem">
<p>
For extended
<a class="link" href="explain.html" title="15.8.2 EXPLAIN Statement">
<code class="literal">
EXPLAIN
</code>
</a>
output, the text displayed by a following
<a class="link" href="show-warnings.html" title="15.7.7.42 SHOW WARNINGS Statement">
<code class="literal">
SHOW WARNINGS
</code>
</a>
includes
<code class="literal">
materialize
</code>
and
<code class="literal">
materialized-subquery
</code>
.
</p>
</li>
</ul>
</div>
<p>
MySQL can also apply subquery materialization to a
single-table
<a class="link" href="update.html" title="15.2.17 UPDATE Statement">
<code class="literal">
UPDATE
</code>
</a>
or
<a class="link" href="delete.html" title="15.2.2 DELETE Statement">
<code class="literal">
DELETE
</code>
</a>
statement that uses a
<code class="literal">
[NOT] IN
</code>
or
<code class="literal">
[NOT] EXISTS
</code>
subquery predicate, provided that the statement does not use
<code class="literal">
ORDER BY
</code>
or
<code class="literal">
LIMIT
</code>
, and
that subquery materialization is allowed by an optimizer hint
or by the
<a class="link" href="server-system-variables.html#sysvar_optimizer_switch">
<code class="literal">
optimizer_switch
</code>
</a>
setting.
</p>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/replication-howto-slaveinit.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="replication-howto-slaveinit">
</a>
19.1.2.7 Setting the Source Configuration on the Replica
</h4>
</div>
</div>
</div>
<p>
To set up the replica to communicate with the source for
replication, configure the replica with the necessary connection
information. To do this, on the replica, execute the following
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
</a>
statement, replacing the option values with the actual values
relevant to your system:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa81183765"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token prompt">mysql></span> <span class="token keyword">CHANGE</span> <span class="token keyword">REPLICATION</span> <span class="token keyword">SOURCE</span> <span class="token keyword">TO</span>
<span class="token prompt"> -></span> <span class="token keyword">SOURCE_HOST</span><span class="token operator">=</span><span class="token string">'<em class="replaceable">source_host_name</em>'</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">SOURCE_USER</span><span class="token operator">=</span><span class="token string">'<em class="replaceable">replication_user_name</em>'</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">SOURCE_PASSWORD</span><span class="token operator">=</span><span class="token string">'<em class="replaceable">replication_password</em>'</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">SOURCE_LOG_FILE</span><span class="token operator">=</span><span class="token string">'<em class="replaceable">recorded_log_file_name</em>'</span><span class="token punctuation">,</span>
<span class="token prompt"> -></span> <span class="token keyword">SOURCE_LOG_POS</span><span class="token operator">=</span><em class="replaceable">recorded_log_position</em><span class="token punctuation">;</span></code></pre>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
Replication cannot use Unix socket files. You must be able to
connect to the source MySQL server using TCP/IP.
</p>
</div>
<p>
The
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
</a>
statement has other options as well. For example, it is possible
to set up secure replication using SSL. For a full list of
options, and information about the maximum permissible length
for the string-valued options, see
<a class="xref" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
Section 15.4.2.2, “CHANGE REPLICATION SOURCE TO Statement”
</a>
.
</p>
<div class="important" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Important
</div>
<p>
As noted in
<a class="xref" href="replication-howto-repuser.html" title="19.1.2.3 Creating a User for Replication">
Section 19.1.2.3, “Creating a User for Replication”
</a>
, if
you are not using a secure connection and the user account
named in the
<code class="literal">
SOURCE_USER
</code>
option
authenticates with the
<code class="literal">
caching_sha2_password
</code>
plugin (the default
in MySQL 8.4), you must specify the
<code class="literal">
SOURCE_PUBLIC_KEY_PATH
</code>
or
<code class="literal">
GET_SOURCE_PUBLIC_KEY
</code>
option in the
<a class="link" href="change-replication-source-to.html" title="15.4.2.2 CHANGE REPLICATION SOURCE TO Statement">
<code class="literal">
CHANGE REPLICATION SOURCE TO
</code>
</a>
statement to enable RSA key pair-based password exchange.
</p>
</div>
</div>
<br/>
</div>
|
https://dev.mysql.com/doc/refman/8.4/en/set-role.html | <div id="docs-body">
<div class="section">
<div class="titlepage">
<div>
<div>
<h4 class="title">
<a name="set-role">
</a>
15.7.1.11 SET ROLE Statement
</h4>
</div>
</div>
</div>
<a class="indexterm" name="idm46045172894256">
</a>
<a class="indexterm" name="idm46045172893184">
</a>
<a class="indexterm" name="idm46045172891696">
</a>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa3926288"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">ROLE</span> {
<span class="token keyword">DEFAULT</span>
<span class="token operator">|</span> <span class="token keyword">NONE</span>
<span class="token operator">|</span> <span class="token keyword">ALL</span>
<span class="token operator">|</span> <span class="token keyword">ALL</span> <span class="token keyword">EXCEPT</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
<span class="token operator">|</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">[</span><span class="token punctuation">,</span> <span class="token keyword"><em class="replaceable">role</em></span> <span class="token punctuation">]</span> <span class="token punctuation">.</span><span class="token punctuation">.</span><span class="token punctuation">.</span>
}</code></pre>
</div>
<p>
<a class="link" href="set-role.html" title="15.7.1.11 SET ROLE Statement">
<code class="literal">
SET ROLE
</code>
</a>
modifies the current
user's effective privileges within the current session by
specifying which of its granted roles are active. Granted roles
include those granted explicitly to the user and those named in
the
<a class="link" href="server-system-variables.html#sysvar_mandatory_roles">
<code class="literal">
mandatory_roles
</code>
</a>
system
variable value.
</p>
<p>
Examples:
</p>
<div class="copytoclipboard-wrapper">
<pre class="programlisting language-sql"><div class="docs-select-all right" id="sa42455848"><div class="copy-help left">Press ⌘+C to copy</div> <div class="right"><button class="clipboard-btn" title="Copy to Clipboard"><span class="icon-clipboard"></span></button></div></div><code class="language-sql"><span class="token keyword">SET</span> <span class="token keyword">ROLE</span> <span class="token keyword">DEFAULT</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> <span class="token keyword">ROLE</span> <span class="token string">'role1'</span><span class="token punctuation">,</span> <span class="token string">'role2'</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> <span class="token keyword">ROLE</span> <span class="token keyword">ALL</span><span class="token punctuation">;</span>
<span class="token keyword">SET</span> <span class="token keyword">ROLE</span> <span class="token keyword">ALL</span> <span class="token keyword">EXCEPT</span> <span class="token string">'role1'</span><span class="token punctuation">,</span> <span class="token string">'role2'</span><span class="token punctuation">;</span></code></pre>
</div>
<p>
Each role name uses the format described in
<a class="xref" href="role-names.html" title="8.2.5 Specifying Role Names">
Section 8.2.5, “Specifying Role Names”
</a>
. The host name part of the role
name, if omitted, defaults to
<code class="literal">
'%'
</code>
.
</p>
<p>
Privileges that the user has been granted directly (rather than
through roles) remain unaffected by changes to the active roles.
</p>
<p>
The statement permits these role specifiers:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<code class="literal">
DEFAULT
</code>
: Activate the account default
roles. Default roles are those specified with
<a class="link" href="set-default-role.html" title="15.7.1.9 SET DEFAULT ROLE Statement">
<code class="literal">
SET DEFAULT ROLE
</code>
</a>
.
</p>
<p>
When a user connects to the server and authenticates
successfully, the server determines which roles to activate
as the default roles. If the
<a class="link" href="server-system-variables.html#sysvar_activate_all_roles_on_login">
<code class="literal">
activate_all_roles_on_login
</code>
</a>
system variable is enabled, the server activates all granted
roles. Otherwise, the server executes
<a class="link" href="set-role.html" title="15.7.1.11 SET ROLE Statement">
<code class="literal">
SET ROLE
DEFAULT
</code>
</a>
implicitly. The server activates only
default roles that can be activated. The server writes
warnings to its error log for default roles that cannot be
activated, but the client receives no warnings.
</p>
<p>
If a user executes
<a class="link" href="set-role.html" title="15.7.1.11 SET ROLE Statement">
<code class="literal">
SET ROLE
DEFAULT
</code>
</a>
during a session, an error occurs if any
default role cannot be activated (for example, if it does
not exist or is not granted to the user). In this case, the
current active roles are not changed.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
NONE
</code>
: Set the active roles to
<code class="literal">
NONE
</code>
(no active roles).
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ALL
</code>
: Activate all roles granted to the
account.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
ALL EXCEPT
<em class="replaceable">
<code>
role
</code>
</em>
[,
<em class="replaceable">
<code>
role
</code>
</em>
] ...
</code>
: Activate
all roles granted to the account except those named. The
named roles need not exist or be granted to the account.
</p>
</li>
<li class="listitem">
<p>
<code class="literal">
<em class="replaceable">
<code>
role
</code>
</em>
[,
<em class="replaceable">
<code>
role
</code>
</em>
] ...
</code>
: Activate
the named roles, which must be granted to the account.
</p>
</li>
</ul>
</div>
<div class="note" style="margin-left: 0.5in; margin-right: 0.5in;">
<div class="admon-title">
Note
</div>
<p>
<a class="link" href="set-default-role.html" title="15.7.1.9 SET DEFAULT ROLE Statement">
<code class="literal">
SET DEFAULT ROLE
</code>
</a>
and
<a class="link" href="set-role.html" title="15.7.1.11 SET ROLE Statement">
<code class="literal">
SET ROLE
DEFAULT
</code>
</a>
are different statements:
</p>
<div class="itemizedlist">
<ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">
<p>
<a class="link" href="set-default-role.html" title="15.7.1.9 SET DEFAULT ROLE Statement">
<code class="literal">
SET DEFAULT ROLE
</code>
</a>
defines
which account roles to activate by default within account
sessions.
</p>
</li>
<li class="listitem">
<p>
<a class="link" href="set-role.html" title="15.7.1.11 SET ROLE Statement">
<code class="literal">
SET ROLE
DEFAULT
</code>
</a>
sets the active roles within the current
session to the current account default roles.
</p>
</li>
</ul>
</div>
</div>
<p>
For role usage examples, see
<a class="xref" href="roles.html" title="8.2.10 Using Roles">
Section 8.2.10, “Using Roles”
</a>
.
</p>
</div>
<br/>
</div>
|
Subsets and Splits